Kinda loading scripts module, but it appears to be trashing memory.

This commit is contained in:
Martin Haye
2014-07-08 16:02:10 -07:00
parent 8a8204ec77
commit d06884c0e9
3 changed files with 19 additions and 5 deletions

View File

@@ -1171,8 +1171,8 @@ class ScriptModule
def emitCodeFixup(toAddr)
{
// Src addr is reversed (i.e. it's hi then lo)
emitFixupByte((dataAddr() >> 8) | 0x80)
emitFixupByte(dataAddr())
emitFixupByte((bytecodeAddr() >> 8) | 0x80)
emitFixupByte(bytecodeAddr())
emitCodeWord(toAddr)
}
@@ -1192,7 +1192,6 @@ class ScriptModule
emitCodeByte(0x26) // LA
emitCodeFixup(addString(text) + ((nScripts+1)*5)) // offset to skip over stubs
emitCodeWord(0) // placeholder for the string address
emitCodeByte(0x54) // CALL
emitCodeWord(vec_displayStr)
}
@@ -1206,7 +1205,6 @@ class ScriptModule
def y = trig.@y.toInteger()
emitCodeByte(0x26) // LA
emitCodeFixup((idx+1) * 5)
emitCodeWord(0) // placeholder for func addr
emitCodeByte(0x2A) // CB
assert x >= 0 && x < 255
emitCodeByte(x)

View File

@@ -19,7 +19,7 @@ MAX_SEGS = 96
DO_COMP_CHECKSUMS = 0 ; during compression debugging
DEBUG_DECOMP = 0
DEBUG = 0
DEBUG = 1
; Zero page temporary variables
tmp = $2 ; len 2
@@ -1150,6 +1150,7 @@ disk_finishLoad: !zone
+ lda .nFixups ; any fixups encountered?
beq +
jsr doAllFixups ; found fixups - execute and free them
+prStr : !text "Fixups done.",0
+ rts
.notEnd bmi .load ; hi bit set -> queued for load
iny ; not set, not queued, so skip over it

View File

@@ -88,6 +88,7 @@ byte loopStr[] = "Entering keyboard loop.\n"
word mapNum = 1
word pFont
word pMap
word pScripts
word cmdTbl[64]
; Movement amounts when walking at each angle
@@ -371,12 +372,19 @@ def initMap()
; Start up the raycaster
initRaycaster(pMap)
; Load the scripts for this map
^$c051
pScripts = loader(QUEUE_LOAD, MAIN_MEM, ((mapNum+$20)<<8) | RES_TYPE_MODULE)
printHex(pScripts)
loader(FINISH_LOAD, MAIN_MEM, 1) ; 1 = keep open
; Set initial player position
^playerDir = 1
*playerX = $280
*playerY = $380
; Draw the first frame
printHex($BBCC)
renderFrame()
end
@@ -512,6 +520,10 @@ def kbdLoop()
loop
end
def foofunc
puts(@loopStr)
end
;==================================================================================================
; Main code.
;
@@ -543,6 +555,9 @@ initMap()
setWindow2()
printVec.0 = $4c
printVec:1 = displayStr
; Main keyboard loop
puts(@loopStr)
kbdLoop()