mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-11 18:23:48 +00:00
Debugging PLASMA loader.
This commit is contained in:
parent
64c3c8298f
commit
269770da90
@ -626,7 +626,7 @@ class PackPartitions
|
|||||||
|
|
||||||
// Extract offsets of the bytecode functions from the fixup table
|
// Extract offsets of the bytecode functions from the fixup table
|
||||||
def sp = 0
|
def sp = 0
|
||||||
def defs = [initStart-byteCodeStart]
|
def defs = [initStart-byteCodeStart+2]
|
||||||
def invDefs = [:]
|
def invDefs = [:]
|
||||||
(1..<defCount).each {
|
(1..<defCount).each {
|
||||||
assert fixup[sp++] == 2 // code table fixup
|
assert fixup[sp++] == 2 // code table fixup
|
||||||
@ -703,9 +703,19 @@ class PackPartitions
|
|||||||
}
|
}
|
||||||
newFixup.add((byte)0xFF)
|
newFixup.add((byte)0xFF)
|
||||||
|
|
||||||
modules[name] = [num:num, buf:ByteBuffer.wrap(newAsmCode)]
|
modules[name] = [num:num, buf:wrapByteArray(newAsmCode)]
|
||||||
bytecodes[name] = [num:num, buf:ByteBuffer.wrap(byteCode.toArray(new byte[byteCode.size]))]
|
bytecodes[name] = [num:num, buf:wrapByteList(byteCode)]
|
||||||
fixups[name] = [num:num, buf:ByteBuffer.wrap(newFixup.toArray(new byte[newFixup.size]))]
|
fixups[name] = [num:num, buf:wrapByteList(newFixup)]
|
||||||
|
}
|
||||||
|
|
||||||
|
def wrapByteArray(array) {
|
||||||
|
def buf = ByteBuffer.wrap(array)
|
||||||
|
buf.position(array.length)
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
|
def wrapByteList(list) {
|
||||||
|
return wrapByteArray(list.toArray(new byte[list.size]))
|
||||||
}
|
}
|
||||||
|
|
||||||
def readFont(name, path)
|
def readFont(name, path)
|
||||||
|
@ -18,7 +18,7 @@ MAX_SEGS = 96
|
|||||||
|
|
||||||
DO_COMP_CHECKSUMS = 0 ; during compression debugging
|
DO_COMP_CHECKSUMS = 0 ; during compression debugging
|
||||||
DEBUG_DECOMP = 0
|
DEBUG_DECOMP = 0
|
||||||
DEBUG = 0
|
DEBUG = 1
|
||||||
|
|
||||||
; Zero page temporary variables
|
; Zero page temporary variables
|
||||||
tmp = $2 ; len 2
|
tmp = $2 ; len 2
|
||||||
@ -347,7 +347,7 @@ fatalError: !zone
|
|||||||
init: !zone
|
init: !zone
|
||||||
; put something interesting on the screen :)
|
; put something interesting on the screen :)
|
||||||
jsr home
|
jsr home
|
||||||
+prStr : !text "Welcome to Lawless Legends.",0
|
+prStr : !text "Welcome to MythOS.",0
|
||||||
; close all files
|
; close all files
|
||||||
lda #0
|
lda #0
|
||||||
jsr closeFile
|
jsr closeFile
|
||||||
@ -734,6 +734,7 @@ coalesce: !zone
|
|||||||
ora tSegType,y ; and next seg
|
ora tSegType,y ; and next seg
|
||||||
bmi .next ; if either is active or has a type, can't combine
|
bmi .next ; if either is active or has a type, can't combine
|
||||||
; we can combine the next segment into this one.
|
; we can combine the next segment into this one.
|
||||||
|
!if DEBUG { jsr .debug }
|
||||||
stx tmp
|
stx tmp
|
||||||
tya
|
tya
|
||||||
tax
|
tax
|
||||||
@ -746,6 +747,20 @@ coalesce: !zone
|
|||||||
tax ; to X reg index
|
tax ; to X reg index
|
||||||
bne .loop ; non-zero = not end of chain - loop again
|
bne .loop ; non-zero = not end of chain - loop again
|
||||||
.done rts
|
.done rts
|
||||||
|
!if DEBUG {
|
||||||
|
.debug +prStr : !text "Coalesce ",0
|
||||||
|
pha
|
||||||
|
tya
|
||||||
|
pha
|
||||||
|
lda tSegAdrLo,x
|
||||||
|
ldy tSegAdrHi,x
|
||||||
|
+prYA
|
||||||
|
+crout
|
||||||
|
pla
|
||||||
|
tay
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@ -1161,8 +1176,7 @@ disk_finishLoad: !zone
|
|||||||
+ lda .nFixups ; any fixups encountered?
|
+ lda .nFixups ; any fixups encountered?
|
||||||
bne +
|
bne +
|
||||||
jsr doAllFixups ; found fixups - execute and free them
|
jsr doAllFixups ; found fixups - execute and free them
|
||||||
+ !if DEBUG { jsr printMem }
|
+ rts
|
||||||
rts
|
|
||||||
.notEnd bmi .load ; hi bit set -> queued for load
|
.notEnd bmi .load ; hi bit set -> queued for load
|
||||||
iny ; not set, not queued, so skip over it
|
iny ; not set, not queued, so skip over it
|
||||||
iny
|
iny
|
||||||
@ -1253,7 +1267,6 @@ disk_finishLoad: !zone
|
|||||||
+prStr : !text "num=",0
|
+prStr : !text "num=",0
|
||||||
+prByte resNum
|
+prByte resNum
|
||||||
+prStr : !text "isAux=",0
|
+prStr : !text "isAux=",0
|
||||||
+prByte isAuxCmd
|
|
||||||
rts
|
rts
|
||||||
.debug2:+prStr : !text "reqLen=",0
|
.debug2:+prStr : !text "reqLen=",0
|
||||||
+prWord reqLen
|
+prWord reqLen
|
||||||
@ -1630,6 +1643,7 @@ setupDecomp:
|
|||||||
; Apply fixups to all modules that were loaded this round, and free the fixup
|
; Apply fixups to all modules that were loaded this round, and free the fixup
|
||||||
; resources from memory.
|
; resources from memory.
|
||||||
doAllFixups: !zone
|
doAllFixups: !zone
|
||||||
|
!if DEBUG { +prStr : !text "Doing all fixups.",0 }
|
||||||
; copy the shadow code down to $100, so we can read aux mem bytes
|
; copy the shadow code down to $100, so we can read aux mem bytes
|
||||||
ldx #.fixupShadow_end - .fixupShadow - 1
|
ldx #.fixupShadow_end - .fixupShadow - 1
|
||||||
- lda .fixupShadow,x
|
- lda .fixupShadow,x
|
||||||
@ -1645,9 +1659,12 @@ doAllFixups: !zone
|
|||||||
.next: lda tSegLink,x ; next in chain
|
.next: lda tSegLink,x ; next in chain
|
||||||
tax ; to X reg index
|
tax ; to X reg index
|
||||||
bne .loop ; non-zero = not end of chain - loop again
|
bne .loop ; non-zero = not end of chain - loop again
|
||||||
rts ; fail with X=0
|
lda #1
|
||||||
|
sta isAuxCmd
|
||||||
|
jmp coalesce ; really free up the fixup blocks by coalescing them into free mem
|
||||||
|
|
||||||
.found ; Found one fixup seg.
|
.found ; Found one fixup seg.
|
||||||
|
sta tSegLink,x ; just the type (getting rid of 'active' flag)
|
||||||
lda tSegAdrLo,x ; grab its address
|
lda tSegAdrLo,x ; grab its address
|
||||||
sta pSrc ; save to the accessor routine
|
sta pSrc ; save to the accessor routine
|
||||||
lda tSegAdrHi,x ; hi byte too
|
lda tSegAdrHi,x ; hi byte too
|
||||||
@ -1681,18 +1698,20 @@ doAllFixups: !zone
|
|||||||
lda tSegAdrHi,x
|
lda tSegAdrHi,x
|
||||||
sta .auxBase+1
|
sta .auxBase+1
|
||||||
|
|
||||||
|
!if DEBUG { jsr .debug1 }
|
||||||
|
|
||||||
; Process the fixups
|
; Process the fixups
|
||||||
.proc jsr .fetchFixup ; get key byte
|
.proc jsr .fetchFixup ; get key byte
|
||||||
tay ; save it aside, and also check the hi bit
|
tax ; save it aside, and also check the hi bit
|
||||||
bmi .fxAux ; yes, it's aux mem fixup
|
bmi .fxAux ; yes, it's aux mem fixup
|
||||||
.fxMain jsr .fetchFixup ; get the lo byte of the offset
|
.fxMain jsr .fetchFixup ; get the lo byte of the offset
|
||||||
clc
|
clc
|
||||||
adc .mainBase
|
adc .mainBase
|
||||||
sta pDst
|
sta pDst
|
||||||
tya
|
txa
|
||||||
adc .mainBase+1
|
adc .mainBase+1
|
||||||
sta pDst+1
|
sta pDst+1
|
||||||
ldy #0
|
!if DEBUG { jsr .debug2 }
|
||||||
clc
|
clc
|
||||||
jsr .adMain
|
jsr .adMain
|
||||||
iny
|
iny
|
||||||
@ -1703,16 +1722,16 @@ doAllFixups: !zone
|
|||||||
sta (pDst),y
|
sta (pDst),y
|
||||||
rts
|
rts
|
||||||
.fxAux cmp #$FF ; end of fixups?
|
.fxAux cmp #$FF ; end of fixups?
|
||||||
beq .resume ; if so, resume scanning
|
beq .stubs ; if so, go do the stubs
|
||||||
jsr .fetchFixup ; get lo byte of offset
|
jsr .fetchFixup ; get lo byte of offset
|
||||||
clc
|
clc
|
||||||
adc .auxBase
|
adc .auxBase
|
||||||
sta pDst
|
sta pDst
|
||||||
tya
|
txa
|
||||||
and #$7F ; mask off the hi bit flag
|
and #$7F ; mask off the hi bit flag
|
||||||
adc .auxBase+1
|
adc .auxBase+1
|
||||||
sta pDst+1
|
sta pDst+1
|
||||||
ldy #0
|
!if DEBUG { jsr .debug3 }
|
||||||
sta setAuxWr
|
sta setAuxWr
|
||||||
jsr .adAux
|
jsr .adAux
|
||||||
iny
|
iny
|
||||||
@ -1723,20 +1742,25 @@ doAllFixups: !zone
|
|||||||
adc .mainBase,y
|
adc .mainBase,y
|
||||||
sta (pDst),y
|
sta (pDst),y
|
||||||
rts
|
rts
|
||||||
.resume ldx #11 ; self-modified earlier
|
.stubs ; fix up the stubs
|
||||||
; fix up the stubs
|
|
||||||
lda .mainBase
|
lda .mainBase
|
||||||
sta pDst
|
sta pDst
|
||||||
lda .mainBase+1
|
lda .mainBase+1
|
||||||
sta pDst+1
|
sta pDst+1
|
||||||
.stub ldy #0
|
.stub ldy #0
|
||||||
lda (pDst),y
|
lda (pDst),y
|
||||||
cmp #$20 ; stubs start with JSR $3xx
|
cmp #$20 ; aux mem stubs marked by JSR $3DC
|
||||||
bne .estub
|
bne .resume ; not a stub, resume scanning
|
||||||
ldy #2
|
iny
|
||||||
lda (pDst),y
|
lda (pDst),y
|
||||||
cmp #3
|
cmp #$DC
|
||||||
bne .estub
|
bne .resume ; not a stub, resume scanning
|
||||||
|
iny
|
||||||
|
lda (pDst),y
|
||||||
|
cmp #$03
|
||||||
|
bne .resume ; not a stub, resume scanning
|
||||||
|
; found a stub, adjust it.
|
||||||
|
!if DEBUG { jsr .debug4 }
|
||||||
clc
|
clc
|
||||||
ldx #0
|
ldx #0
|
||||||
jsr .adStub
|
jsr .adStub
|
||||||
@ -1754,10 +1778,11 @@ doAllFixups: !zone
|
|||||||
adc .auxBase,x
|
adc .auxBase,x
|
||||||
sta (pDst),y
|
sta (pDst),y
|
||||||
rts
|
rts
|
||||||
.estub ; done with stubs
|
.resume ldx #11 ; self-modified earlier
|
||||||
jmp .next ; go scan for more fixup blocks
|
jmp .next ; go scan for more fixup blocks
|
||||||
|
|
||||||
.fetchFixup:
|
.fetchFixup:
|
||||||
|
ldy #0
|
||||||
jsr .getFixupByte ; get a byte from aux mem
|
jsr .getFixupByte ; get a byte from aux mem
|
||||||
inc pSrc ; and advance the pointer
|
inc pSrc ; and advance the pointer
|
||||||
bne +
|
bne +
|
||||||
@ -1778,6 +1803,31 @@ doAllFixups: !zone
|
|||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
.fixupShadow_end = *
|
.fixupShadow_end = *
|
||||||
|
!if DEBUG {
|
||||||
|
.debug1 +prStr : !text "Found fixup, res=",0
|
||||||
|
+prByte resNum
|
||||||
|
+prStr : !text "mainBase=",0
|
||||||
|
+prWord .mainBase
|
||||||
|
+prStr : !text "auxBase=",0
|
||||||
|
+prWord .auxBase
|
||||||
|
+crout
|
||||||
|
rts
|
||||||
|
.debug2 +prStr : !text " main fixup, addr=",0
|
||||||
|
+prWord pDst
|
||||||
|
+crout
|
||||||
|
+waitKey
|
||||||
|
rts
|
||||||
|
.debug3 +prStr : !text " aux fixup, addr=",0
|
||||||
|
+prWord pDst
|
||||||
|
+crout
|
||||||
|
+waitKey
|
||||||
|
rts
|
||||||
|
.debug4 +prStr : !text " main stub, addr=",0
|
||||||
|
+prWord pDst
|
||||||
|
+crout
|
||||||
|
+waitKey
|
||||||
|
rts
|
||||||
|
}
|
||||||
.mainBase !word 0
|
.mainBase !word 0
|
||||||
.auxBase !word 0
|
.auxBase !word 0
|
||||||
|
|
||||||
|
@ -44,6 +44,18 @@
|
|||||||
jsr _prSpace
|
jsr _prSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!macro prYA {
|
||||||
|
jsr _prY
|
||||||
|
jsr _prA
|
||||||
|
jsr _prSpace
|
||||||
|
}
|
||||||
|
|
||||||
|
!macro prAY {
|
||||||
|
jsr _prA
|
||||||
|
jsr _prY
|
||||||
|
jsr _prSpace
|
||||||
|
}
|
||||||
|
|
||||||
!macro prXY {
|
!macro prXY {
|
||||||
jsr _prX
|
jsr _prX
|
||||||
jsr _prY
|
jsr _prY
|
||||||
|
@ -13,7 +13,7 @@ start:
|
|||||||
|
|
||||||
; Conditional assembly flags
|
; Conditional assembly flags
|
||||||
DOUBLE_BUFFER = 1 ; whether to double-buffer
|
DOUBLE_BUFFER = 1 ; whether to double-buffer
|
||||||
DEBUG = 0 ; 1=some logging, 2=lots of logging
|
DEBUG = 1 ; 1=some logging, 2=lots of logging
|
||||||
DEBUG_COLUMN = -1
|
DEBUG_COLUMN = -1
|
||||||
|
|
||||||
; temporary hack to try blocker sprites
|
; temporary hack to try blocker sprites
|
||||||
@ -1604,6 +1604,12 @@ initMem: !zone
|
|||||||
ldx #RES_TYPE_SCREEN
|
ldx #RES_TYPE_SCREEN
|
||||||
ldy #1
|
ldy #1
|
||||||
jsr mainLoader
|
jsr mainLoader
|
||||||
|
; Load the game loop module
|
||||||
|
!if DEBUG { +prStr : !text "Loading game loop.",0 }
|
||||||
|
lda #QUEUE_LOAD
|
||||||
|
ldx #RES_TYPE_MODULE
|
||||||
|
ldy #1 ; hard coded for now: module #1 is the game loop
|
||||||
|
jsr mainLoader
|
||||||
; Load the map into main mem
|
; Load the map into main mem
|
||||||
!if DEBUG { +prStr : !text "Loading map.",0 }
|
!if DEBUG { +prStr : !text "Loading map.",0 }
|
||||||
lda #QUEUE_LOAD
|
lda #QUEUE_LOAD
|
||||||
|
Loading…
Reference in New Issue
Block a user