mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-05 03:57:52 +00:00
More work on PLASMA loading.
This commit is contained in:
parent
5334bca39c
commit
64c3c8298f
@ -1158,7 +1158,7 @@ disk_finishLoad: !zone
|
|||||||
jsr closeFile
|
jsr closeFile
|
||||||
lda #0 ; zero out...
|
lda #0 ; zero out...
|
||||||
sta partFileRef ; ... the file reference so we know it's no longer open
|
sta partFileRef ; ... the file reference so we know it's no longer open
|
||||||
+ 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 }
|
+ !if DEBUG { jsr printMem }
|
||||||
@ -1630,48 +1630,161 @@ 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
|
||||||
ldx #1 ; start at first aux mem segment (0=main mem, 1=aux)
|
; copy the shadow code down to $100, so we can read aux mem bytes
|
||||||
.loop: lda tSegType,x ; grab flags & type
|
ldx #.fixupShadow_end - .fixupShadow - 1
|
||||||
and #$F ; just type now
|
- lda .fixupShadow,x
|
||||||
|
sta .getFixupByte,x
|
||||||
|
dex
|
||||||
|
bpl -
|
||||||
|
; Now scan aux mem for fixup segments
|
||||||
|
ldx #1 ; start at first aux mem segment (0=main mem, 1=aux)
|
||||||
|
.loop: lda tSegType,x ; grab flags & type
|
||||||
|
and #$F ; just type now
|
||||||
cmp #RES_TYPE_FIXUP
|
cmp #RES_TYPE_FIXUP
|
||||||
bne .next
|
beq .found
|
||||||
|
.next: lda tSegLink,x ; next in chain
|
||||||
|
tax ; to X reg index
|
||||||
|
bne .loop ; non-zero = not end of chain - loop again
|
||||||
|
rts ; fail with X=0
|
||||||
|
|
||||||
|
.found ; Found one fixup seg.
|
||||||
|
lda tSegAdrLo,x ; grab its address
|
||||||
|
sta pSrc ; save to the accessor routine
|
||||||
|
lda tSegAdrHi,x ; hi byte too
|
||||||
|
sta pSrc+1
|
||||||
|
|
||||||
|
; Find the corresponding main-mem seg
|
||||||
|
stx .resume+1 ; save scan position so we can resume later
|
||||||
|
lda tSegRes,x ; get seg num for this fixup
|
||||||
|
sta resNum ; that's what we're looking for
|
||||||
|
lda #RES_TYPE_MODULE ; type module is in main mem
|
||||||
|
sta resType ; that's the type
|
||||||
|
lda #0 ; look in main mem
|
||||||
|
sta isAuxCmd
|
||||||
|
jsr scanForResource
|
||||||
|
bne + ; we better find it
|
||||||
|
brk
|
||||||
|
+ lda tSegAdrLo,x ; get the segment's address
|
||||||
|
sta .mainBase ; and save it
|
||||||
|
lda tSegAdrHi,x ; hi byte too
|
||||||
|
sta .mainBase+1
|
||||||
|
|
||||||
|
; Find the corresponding aux-mem seg
|
||||||
|
lda #RES_TYPE_BYTECODE ; it's of type bytecode
|
||||||
|
sta resType
|
||||||
|
inc isAuxCmd ; it'll be in aux mem
|
||||||
|
jsr scanForResource
|
||||||
|
bne + ; we better find it
|
||||||
|
brk
|
||||||
|
+ lda tSegAdrLo,x
|
||||||
|
sta .auxBase
|
||||||
|
lda tSegAdrHi,x
|
||||||
|
sta .auxBase+1
|
||||||
|
|
||||||
|
; Process the fixups
|
||||||
|
.proc jsr .fetchFixup ; get key byte
|
||||||
|
tay ; save it aside, and also check the hi bit
|
||||||
|
bmi .fxAux ; yes, it's aux mem fixup
|
||||||
|
.fxMain jsr .fetchFixup ; get the lo byte of the offset
|
||||||
|
clc
|
||||||
|
adc .mainBase
|
||||||
|
sta pDst
|
||||||
|
tya
|
||||||
|
adc .mainBase+1
|
||||||
|
sta pDst+1
|
||||||
|
ldy #0
|
||||||
|
clc
|
||||||
|
jsr .adMain
|
||||||
|
iny
|
||||||
|
jsr .adMain
|
||||||
|
bne .proc ; always taken
|
||||||
|
.adMain lda (pDst),y
|
||||||
|
adc .mainBase,y
|
||||||
|
sta (pDst),y
|
||||||
|
rts
|
||||||
|
.fxAux cmp #$FF ; end of fixups?
|
||||||
|
beq .resume ; if so, resume scanning
|
||||||
|
jsr .fetchFixup ; get lo byte of offset
|
||||||
|
clc
|
||||||
|
adc .auxBase
|
||||||
|
sta pDst
|
||||||
|
tya
|
||||||
|
and #$7F ; mask off the hi bit flag
|
||||||
|
adc .auxBase+1
|
||||||
|
sta pDst+1
|
||||||
|
ldy #0
|
||||||
|
sta setAuxWr
|
||||||
|
jsr .adAux
|
||||||
|
iny
|
||||||
|
jsr .adAux
|
||||||
|
sta clrAuxWr
|
||||||
|
bne .proc ; always taken
|
||||||
|
.adAux jsr .getBytecode
|
||||||
|
adc .mainBase,y
|
||||||
|
sta (pDst),y
|
||||||
|
rts
|
||||||
|
.resume ldx #11 ; self-modified earlier
|
||||||
|
; fix up the stubs
|
||||||
|
lda .mainBase
|
||||||
|
sta pDst
|
||||||
|
lda .mainBase+1
|
||||||
|
sta pDst+1
|
||||||
|
.stub ldy #0
|
||||||
|
lda (pDst),y
|
||||||
|
cmp #$20 ; stubs start with JSR $3xx
|
||||||
|
bne .estub
|
||||||
|
ldy #2
|
||||||
|
lda (pDst),y
|
||||||
|
cmp #3
|
||||||
|
bne .estub
|
||||||
|
clc
|
||||||
|
ldx #0
|
||||||
|
jsr .adStub
|
||||||
|
inx
|
||||||
|
jsr .adStub
|
||||||
|
lda pDst
|
||||||
|
clc
|
||||||
|
adc #5
|
||||||
|
sta pDst
|
||||||
|
bcc .stub
|
||||||
|
inc pDst+1
|
||||||
|
bne .stub ; always taken
|
||||||
|
.adStub iny
|
||||||
|
lda (pDst),y
|
||||||
|
adc .auxBase,x
|
||||||
|
sta (pDst),y
|
||||||
|
rts
|
||||||
|
.estub ; done with stubs
|
||||||
|
jmp .next ; go scan for more fixup blocks
|
||||||
|
|
||||||
|
.fetchFixup:
|
||||||
|
jsr .getFixupByte ; get a byte from aux mem
|
||||||
|
inc pSrc ; and advance the pointer
|
||||||
|
bne +
|
||||||
|
inc pSrc+1 ; hi byte too, if necessary
|
||||||
|
+ rts
|
||||||
|
|
||||||
lda pTmp ; compare pTmp
|
|
||||||
cmp tSegAdrLo,x ; to this seg addr
|
|
||||||
lda pTmp+1 ; including...
|
|
||||||
sbc tSegAdrHi,x ; ...hi byte
|
|
||||||
bcc .next ; if pTmp < seg addr then keep searching
|
|
||||||
lda pTmp ; compare pTmp
|
|
||||||
cmp tSegAdrLo,y ; to *next* seg addr
|
|
||||||
lda pTmp+1 ; including...
|
|
||||||
sbc tSegAdrHi,y ; ...hi byte
|
|
||||||
bcc .found ; if pTmp < next seg addr then perfect!
|
|
||||||
.next: lda tSegLink,x ; next in chain
|
|
||||||
tax ; to X reg index
|
|
||||||
bne .loop ; non-zero = not end of chain - loop again
|
|
||||||
rts ; fail with X=0
|
|
||||||
.fixupShadow:
|
.fixupShadow:
|
||||||
!pseudopc $100 {
|
!pseudopc $100 {
|
||||||
.getFixupByte:
|
.getFixupByte:
|
||||||
sta setAuxRd
|
sta setAuxRd
|
||||||
.fixupAddr = *+1
|
lda (pSrc),y
|
||||||
lda $1111
|
|
||||||
sta clrAuxRd
|
sta clrAuxRd
|
||||||
rts
|
rts
|
||||||
.getBytecode:
|
.getBytecode:
|
||||||
sta setAuxRd
|
sta setAuxRd
|
||||||
.bytecodeAddr = *+1
|
lda (pDst),y
|
||||||
lda $1111
|
|
||||||
sta clrAuxRd
|
sta clrAuxRd
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
.fixupShadow_end = *
|
.fixupShadow_end = *
|
||||||
|
.mainBase !word 0
|
||||||
|
.auxBase !word 0
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Segment tables
|
; Segment tables
|
||||||
|
|
||||||
!if DEBUG { !align 255,0 }
|
!if DEBUG { !align 255,0 }
|
||||||
|
|
||||||
tSegLink = * : !fill MAX_SEGS
|
tSegLink = * : !fill MAX_SEGS
|
||||||
tSegType = * : !fill MAX_SEGS
|
tSegType = * : !fill MAX_SEGS
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
TOP_LINE = $2180 ; 24 lines down from top
|
TOP_LINE = $2180 ; 24 lines down from top
|
||||||
NLINES = 128
|
NLINES = 128
|
||||||
TEX_SIZE = $555 ; 32x32 + 16x16 + 8x8 + 4x4 + 2x2 + 1x1
|
TEX_SIZE = $555 ; 32x32 + 16x16 + 8x8 + 4x4 + 2x2 + 1x1
|
||||||
|
PLASMA_FRAME_SIZE = $200
|
||||||
|
|
||||||
; Byte offset for each pixel in the blit unroll
|
; Byte offset for each pixel in the blit unroll
|
||||||
BLIT_OFF0 = 5
|
BLIT_OFF0 = 5
|
||||||
@ -55,6 +56,7 @@ mapWidth = $62 ; len 1
|
|||||||
mapHeight = $63 ; len 1
|
mapHeight = $63 ; len 1
|
||||||
spriteX = $64 ; len 2
|
spriteX = $64 ; len 2
|
||||||
spriteY = $66 ; len 2
|
spriteY = $66 ; len 2
|
||||||
|
plasmaFrames = $68 ; len 2
|
||||||
|
|
||||||
; Sprite calculations zero page
|
; Sprite calculations zero page
|
||||||
bSgnSinT = $90
|
bSgnSinT = $90
|
||||||
@ -87,24 +89,20 @@ expandVec = $800
|
|||||||
;---------------------------------
|
;---------------------------------
|
||||||
|
|
||||||
; Main-mem tables and buffers
|
; Main-mem tables and buffers
|
||||||
tableStart = $A000
|
tableStart = $A700
|
||||||
decodeTo01 = $A000
|
decodeTo01 = $A700
|
||||||
decodeTo01b = $A100
|
decodeTo01b = $A800
|
||||||
decodeTo23 = $A200
|
decodeTo23 = $A900
|
||||||
decodeTo23b = $A300
|
decodeTo23b = $AA00
|
||||||
decodeTo45 = $A400
|
decodeTo45 = $AB00
|
||||||
decodeTo56 = $A500
|
decodeTo56 = $AC00
|
||||||
decodeTo57 = $A600
|
decodeTo57 = $AD00
|
||||||
clrBlitRollE = $A700 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
clrBlitRollE = $AE00 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||||
clrBlitRollO = $A7C2 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
clrBlitRollO = $AEC2 ; size 3*(128/2) = $C0, plus 2 for tya and rts
|
||||||
texAddrLo = $A884
|
texAddrLo = $AF84
|
||||||
texAddrHi = texAddrLo + MAX_TEXTURES
|
texAddrHi = texAddrLo + MAX_TEXTURES
|
||||||
blitRoll = $A900 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts
|
blitRoll = $B000 ; Unrolled blitting code. Size 29*128 = $E80, plus 1 for rts
|
||||||
tableEnd = $B781
|
tableEnd = $BE81
|
||||||
|
|
||||||
plasmaCode = $B800
|
|
||||||
plasmaFrames = $BD00
|
|
||||||
plasmaEnd = $BF00
|
|
||||||
|
|
||||||
; mipmap level offsets
|
; mipmap level offsets
|
||||||
MIP_OFFSET_0 = 0
|
MIP_OFFSET_0 = 0
|
||||||
|
@ -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 = 1 ; 1=some logging, 2=lots of logging
|
DEBUG = 0 ; 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
|
||||||
@ -1568,14 +1568,12 @@ initMem: !zone
|
|||||||
ldy #>(tableEnd-tableStart)
|
ldy #>(tableEnd-tableStart)
|
||||||
jsr mainLoader
|
jsr mainLoader
|
||||||
; Reserve memory for the PLASMA frame stack
|
; Reserve memory for the PLASMA frame stack
|
||||||
lda #SET_MEM_TARGET
|
|
||||||
ldx #<plasmaFrames
|
|
||||||
ldy #>plasmaFrames
|
|
||||||
jsr mainLoader
|
|
||||||
lda #REQUEST_MEMORY
|
lda #REQUEST_MEMORY
|
||||||
ldx #<(plasmaEnd-plasmaFrames)
|
ldx #0
|
||||||
ldy #>(plasmaEnd-plasmaFrames)
|
ldy #>PLASMA_FRAME_SIZE
|
||||||
jsr mainLoader
|
jsr mainLoader
|
||||||
|
stx plasmaFrames
|
||||||
|
sty plasmaFrames+1
|
||||||
; Load the font engine
|
; Load the font engine
|
||||||
!if DEBUG { +prStr : !text "Loading font engine.",0 }
|
!if DEBUG { +prStr : !text "Loading font engine.",0 }
|
||||||
lda #SET_MEM_TARGET
|
lda #SET_MEM_TARGET
|
||||||
@ -1586,16 +1584,6 @@ initMem: !zone
|
|||||||
ldx #RES_TYPE_CODE
|
ldx #RES_TYPE_CODE
|
||||||
ldy #3 ; hard coded for now: code #3 is the font engine
|
ldy #3 ; hard coded for now: code #3 is the font engine
|
||||||
jsr mainLoader
|
jsr mainLoader
|
||||||
; Load the font engine
|
|
||||||
!if DEBUG { +prStr : !text "Loading game loop.",0 }
|
|
||||||
lda #SET_MEM_TARGET
|
|
||||||
ldx #<plasmaCode
|
|
||||||
ldy #>plasmaCode
|
|
||||||
jsr mainLoader
|
|
||||||
lda #QUEUE_LOAD
|
|
||||||
ldx #RES_TYPE_CODE
|
|
||||||
ldy #4 ; hard coded for now: code #4 is the game loop
|
|
||||||
jsr mainLoader
|
|
||||||
!if DEBUG { +prStr : !text "Loading expansion code.",0 }
|
!if DEBUG { +prStr : !text "Loading expansion code.",0 }
|
||||||
; Load the texture expansion code into aux mem.
|
; Load the texture expansion code into aux mem.
|
||||||
lda #SET_MEM_TARGET
|
lda #SET_MEM_TARGET
|
||||||
@ -1642,8 +1630,6 @@ initMem: !zone
|
|||||||
pla
|
pla
|
||||||
tax ; and hi byte in X
|
tax ; and hi byte in X
|
||||||
jsr setFONT
|
jsr setFONT
|
||||||
; Test PLASMA
|
|
||||||
jsr plasmaCode
|
|
||||||
; Set to write text on both hi-res pages at the same time
|
; Set to write text on both hi-res pages at the same time
|
||||||
lda #pHGR3
|
lda #pHGR3
|
||||||
jsr displayMODE
|
jsr displayMODE
|
||||||
|
Loading…
Reference in New Issue
Block a user