mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-06-09 10:29:30 +00:00
Add opcode store/restore. Fix abs addr issue
This commit is contained in:
parent
40be26392e
commit
4d6832066c
|
@ -92,22 +92,36 @@ EvtLoop
|
|||
DoFrame
|
||||
|
||||
; This sets up the environment for calling the blitter. The blitter code takes care of moving from
|
||||
; line to line and should be set up ahead of time with appropriate epilougs for lines to periodically
|
||||
; line to line and should be set up ahead of time with appropriate epilogues for lines to periodically
|
||||
; enable interrupts and other stuff. In short, we call into the code once and, when it returns, all of
|
||||
; the lines set up to render will be finished.
|
||||
|
||||
sep #$20 ; 8-bit acc
|
||||
lda BlitBuff+2 ; set the data bank to the code field
|
||||
sta blt_entry+3 ; Patch into the long jump
|
||||
pha
|
||||
pha ; push twice because we will use it later
|
||||
rep #$20
|
||||
|
||||
tsc ; save the stack pointer
|
||||
inc ; adjust for the plb below
|
||||
sta stk_save+1 ; save a cycle by storing while bank is set
|
||||
|
||||
ldx #80*2 ; This is the word to exit from
|
||||
ldy Tile2CodeOffset,x ; Get the offset
|
||||
ldy Col2CodeOffset,x ; Get the offset
|
||||
|
||||
lda BlitBuff+1 ; set the data bank to the code field
|
||||
sta blt_entry+2 ; Patch into the long jump
|
||||
pha
|
||||
plb
|
||||
plb
|
||||
sep #$20 ; 8-bit acc
|
||||
lda BlitBuff+2 ; set the data bank to the code field
|
||||
sta blt_entry+3 ; Patch into the long jump
|
||||
rep #$20
|
||||
|
||||
plb ; set the data bank to the code field
|
||||
|
||||
ldx #16*2 ; Y-register is set correctly
|
||||
lda #OPCODE_SAVE
|
||||
jsr SaveOpcode
|
||||
|
||||
ldx #80*2 ; X-register is overwritten by SaveOpcode
|
||||
ldal CodeFieldEvenBRA,x ; Get the value to place there
|
||||
ldx #16*2
|
||||
jsr SetConst
|
||||
|
@ -144,6 +158,14 @@ stk_save lda #0000 ; load the stack
|
|||
tcs
|
||||
cli ; re-enable interrupts
|
||||
|
||||
plb ; set the bank back to the code field
|
||||
ldx #80*2 ; This is the word to exit from
|
||||
ldal Col2CodeOffset,x ; Get the offset
|
||||
tay
|
||||
ldx #16*2
|
||||
lda #OPCODE_SAVE
|
||||
; jsr RestoreOpcode
|
||||
|
||||
phk ; restore data bank
|
||||
plb
|
||||
jmp EvtLoop
|
||||
|
@ -294,6 +316,8 @@ VBLTASK hex 00000000
|
|||
|
||||
GrafInit lda #$8888
|
||||
jsr ClearToColor
|
||||
lda #0000
|
||||
jsr SetSCBs
|
||||
jsr GrafOn
|
||||
jsr ShadowOn
|
||||
rts
|
||||
|
@ -503,3 +527,25 @@ qtRec adrl $0000
|
|||
put blitter/Template.s
|
||||
put blitter/Tables.s
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
PER_TILE_SIZE equ 3
|
||||
]step equ 0
|
||||
Tile2CodeOffset lup 82
|
||||
Col2CodeOffset lup 82
|
||||
dw CODE_TOP+{]step*PER_TILE_SIZE}
|
||||
]step equ ]step+1
|
||||
--^
|
||||
|
@ -194,3 +194,4 @@ CodeFieldOddBRA
|
|||
bra *+15 ; 79
|
||||
bra *+12 ; 80
|
||||
bra *+9 ; 81 -- need to skip over two JMP instructions
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ CODE_ENTRY equ entry_jmp-base+1 ; low byte of the page-aligned jump
|
|||
CODE_TOP equ loop-base
|
||||
CODE_LEN equ top-base
|
||||
CODE_EXIT equ even_exit-base
|
||||
OPCODE_SAVE equ odd_exit-base+1 ; spot to save the code field opcode when patching exit BRA
|
||||
|
||||
; Locations that need the page offset added
|
||||
PagePatches da {long_0-base+2}
|
||||
|
@ -36,6 +37,41 @@ BankPatches da {long_0-base+3}
|
|||
da {long_6-base+3}
|
||||
BankPatchNum equ *-BankPatches
|
||||
|
||||
; Copy tile data into code field. Their are specialized copy routines
|
||||
;
|
||||
; CopyTileConst -- the first 16 tile numbers are reserved and can be used
|
||||
; to draw a solid tile block
|
||||
CopyTile cmp #$0010
|
||||
bcs :invalid
|
||||
asl
|
||||
tax
|
||||
ldal TilePatterns,x
|
||||
bra CopyTileConst
|
||||
:invalid rts
|
||||
|
||||
TilePatterns dw $0000,$1111,$2222,$3333
|
||||
dw $4444,$5555,$6666,$7777
|
||||
dw $8888,$9999,$AAAA,$BBBB
|
||||
dw $CCCC,$DDDD,$EEEE,$FFFF
|
||||
|
||||
CopyTileConst sta: $0000,y
|
||||
sta: $0003,y
|
||||
sta $1000,y
|
||||
sta $1003,y
|
||||
sta $2000,y
|
||||
sta $2003,y
|
||||
sta $3000,y
|
||||
sta $3003,y
|
||||
sta $4000,y
|
||||
sta $4003,y
|
||||
sta $5000,y
|
||||
sta $5003,y
|
||||
sta $6000,y
|
||||
sta $6003,y
|
||||
sta $7000,y
|
||||
sta $7003,y
|
||||
rts
|
||||
|
||||
; Patch out the final JMP to jump to the long JML return code
|
||||
;
|
||||
; Y = starting line * $1000
|
||||
|
@ -88,7 +124,116 @@ SetConst jmp (:tbl,x)
|
|||
sta $3000,y
|
||||
sta $2000,y
|
||||
sta $1000,y
|
||||
sta $0000,y
|
||||
sta: $0000,y
|
||||
:bottom rts
|
||||
|
||||
; SaveOpcode
|
||||
;
|
||||
; Save the values to the restore location. This should only be used to patch the
|
||||
; code field since the save location is fixed.
|
||||
;
|
||||
; X = number of lines * 2, 0 to 32
|
||||
; Y = starting line * $1000
|
||||
; A = store location * $1000
|
||||
SaveOpcode pha ; save the accumulator
|
||||
ldal :tbl,x
|
||||
dec
|
||||
plx ; put the accumulator into X
|
||||
pha ; push the address into the stack
|
||||
rts ; and jump
|
||||
|
||||
:tbl da :bottom-00,:bottom-06,:bottom-12,:bottom-18
|
||||
da :bottom-24,:bottom-30,:bottom-36,:bottom-42
|
||||
da :bottom-48,:bottom-54,:bottom-60,:bottom-66
|
||||
da :bottom-72,:bottom-78,:bottom-84,:bottom-90
|
||||
da :bottom-96
|
||||
:top lda $F000,y
|
||||
sta $F000,x
|
||||
lda $E000,y
|
||||
sta $E000,x
|
||||
lda $D000,y
|
||||
sta $D000,x
|
||||
lda $C000,y
|
||||
sta $C000,x
|
||||
lda $B000,y
|
||||
sta $B000,x
|
||||
lda $A000,y
|
||||
sta $A000,x
|
||||
lda $9000,y
|
||||
sta $9000,x
|
||||
lda $8000,y
|
||||
sta $8000,x
|
||||
lda $7000,y
|
||||
sta $7000,x
|
||||
lda $6000,y
|
||||
sta $6000,x
|
||||
lda $5000,y
|
||||
sta $5000,x
|
||||
lda $4000,y
|
||||
sta $4000,x
|
||||
lda $3000,y
|
||||
sta $3000,x
|
||||
lda $2000,y
|
||||
sta $2000,x
|
||||
lda $1000,y
|
||||
sta $1000,x
|
||||
lda: $0000,y
|
||||
sta: $0000,x
|
||||
:bottom rts
|
||||
|
||||
; RestoreOpcode
|
||||
;
|
||||
; Restore the values to the opcode location. This should only be used to restore the
|
||||
; code field.
|
||||
;
|
||||
; X = number of lines * 2, 0 to 32
|
||||
; Y = starting line * $1000
|
||||
; A = store location * $1000
|
||||
RestoreOpcode pha ; save the accumulator
|
||||
ldal :tbl,x
|
||||
dec
|
||||
plx ; put the accumulator into X
|
||||
pha ; push the address into the stack
|
||||
rts ; and jump
|
||||
|
||||
:tbl da :bottom-00,:bottom-06,:bottom-12,:bottom-18
|
||||
da :bottom-24,:bottom-30,:bottom-36,:bottom-42
|
||||
da :bottom-48,:bottom-54,:bottom-60,:bottom-66
|
||||
da :bottom-72,:bottom-78,:bottom-84,:bottom-90
|
||||
da :bottom-96
|
||||
|
||||
:top lda $F000,x
|
||||
sta $F000,y
|
||||
lda $E000,x
|
||||
sta $E000,y
|
||||
lda $D000,x
|
||||
sta $D000,y
|
||||
lda $C000,x
|
||||
sta $C000,y
|
||||
lda $B000,x
|
||||
sta $B000,y
|
||||
lda $A000,x
|
||||
sta $A000,y
|
||||
lda $9000,x
|
||||
sta $9000,y
|
||||
lda $8000,x
|
||||
sta $8000,y
|
||||
lda $7000,x
|
||||
sta $7000,y
|
||||
lda $6000,x
|
||||
sta $6000,y
|
||||
lda $5000,x
|
||||
sta $5000,y
|
||||
lda $4000,x
|
||||
sta $4000,y
|
||||
lda $3000,x
|
||||
sta $3000,y
|
||||
lda $2000,x
|
||||
sta $2000,y
|
||||
lda $1000,x
|
||||
sta $1000,y
|
||||
lda: $0000,x
|
||||
sta: $0000,y
|
||||
:bottom rts
|
||||
|
||||
; SetScreenAddrs
|
||||
|
@ -135,7 +280,7 @@ SetScreenAddrs sec
|
|||
sbc #160
|
||||
sta STK_ADDR+$1000,y
|
||||
sbc #160
|
||||
sta STK_ADDR+$0000,y
|
||||
sta: STK_ADDR+$0000,y
|
||||
:bottom rts
|
||||
|
||||
; SetAbsAddres
|
||||
|
@ -182,7 +327,7 @@ SetAbsAddrs sec
|
|||
sbc #$1000
|
||||
sta $1000,y
|
||||
sbc #$1000
|
||||
sta $0000,y
|
||||
sta: $0000,y
|
||||
:bottom rts
|
||||
|
||||
; Full up a full bank with blitter templates. Currently we can fit 16 lines per bank, so need
|
||||
|
@ -442,6 +587,23 @@ top
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user