mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-11-26 22:50:22 +00:00
Add proper handling of wraparound in vertical positioning
This commit is contained in:
parent
4b390fef20
commit
160a9afafb
@ -27,9 +27,9 @@ MoveRight
|
||||
pla
|
||||
rts
|
||||
|
||||
MoveDown
|
||||
MoveUp
|
||||
clc
|
||||
adc StartY ; Increment the virtual X-position
|
||||
adc StartY ; Increment the virtual Y-position
|
||||
jsr SetBG0YPos
|
||||
|
||||
lda StartY
|
||||
@ -39,7 +39,7 @@ MoveDown
|
||||
jsr DoFrame
|
||||
rts
|
||||
|
||||
MoveUp
|
||||
MoveDown
|
||||
pha
|
||||
lda StartY
|
||||
sec
|
||||
@ -104,3 +104,4 @@ FPSStr str 'FPS'
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -643,10 +643,16 @@ BlitInit
|
||||
stz ScreenTileHeight
|
||||
stz ScreenTileWidth
|
||||
stz StartX
|
||||
stz StartXMod164
|
||||
stz StartY
|
||||
stz StartYMod208
|
||||
stz EngineMode
|
||||
stz DirtyBits
|
||||
stz LastPatchOffset
|
||||
stz BG1StartX
|
||||
stz BG1StartXMod164
|
||||
stz BG1StartY
|
||||
stz BG1StartYMod208
|
||||
|
||||
]step equ 0
|
||||
lup 13
|
||||
@ -976,5 +982,6 @@ qtRec adrl $0000
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -64,10 +64,13 @@ Render
|
||||
jsr ShadowOff
|
||||
jsr ShadowOn
|
||||
|
||||
jsr _ApplyBG0XPos ; Patch the PEA instructions with exit BRA opcode
|
||||
; It's important to do _ApplyBG0YPos first because it calculates the value of StartY % 208 which is
|
||||
; used in all of the other loops
|
||||
|
||||
jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen
|
||||
jsr _ApplyBG0XPos ; Patch the PEA instructions with exit BRA opcode
|
||||
jsr _ApplyBG1YPos ; Adjust the index values into the BG1 bank buffer
|
||||
jsr _ApplyBG1XPos ; Adjust the direct page pointers to the BG1 bank
|
||||
jsr _ApplyBG1YPos
|
||||
|
||||
ldx #0 ; Blit the full virtual buffer to the screen
|
||||
ldy ScreenHeight
|
||||
@ -90,3 +93,5 @@ Render
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,16 +1,38 @@
|
||||
; Initialization and setup routines for the second background
|
||||
_InitBG1
|
||||
jsr _ApplyBG1XPos
|
||||
jsr _ApplyBG1YPos
|
||||
jsr _ApplyBG1XPos
|
||||
rts
|
||||
|
||||
SetBG1XPos
|
||||
sta BG1StartX
|
||||
rts
|
||||
cmp BG1StartX
|
||||
beq :out ; Easy, if nothing changed, then nothing changes
|
||||
|
||||
ldx BG1StartX ; Load the old value (but don't save it yet)
|
||||
sta BG1StartX ; Save the new position
|
||||
|
||||
lda #DIRTY_BIT_BG1_X
|
||||
tsb DirtyBits ; Check if the value is already dirty, if so exit
|
||||
bne :out ; without overwriting the original value
|
||||
|
||||
stx OldBG1StartX ; First change, so preserve the value
|
||||
:out rts
|
||||
|
||||
|
||||
SetBG1YPos
|
||||
sta BG1StartY
|
||||
rts
|
||||
cmp BG1StartY
|
||||
beq :out ; Easy, if nothing changed, then nothing changes
|
||||
|
||||
ldx BG1StartY ; Load the old value (but don't save it yet)
|
||||
sta BG1StartY ; Save the new position
|
||||
|
||||
lda #DIRTY_BIT_BG1_Y
|
||||
tsb DirtyBits ; Check if the value is already dirty, if so exit
|
||||
bne :out ; without overwriting the original value
|
||||
|
||||
stx OldBG1StartY ; First change, so preserve the value
|
||||
:out rts
|
||||
|
||||
|
||||
; Everytime either BG1 or BG0 X-position changes, we have to update the direct page values. We
|
||||
; *could* do this by adjusting the since address offset, but we have to change up to 200 values
|
||||
@ -86,9 +108,12 @@ _ApplyBG1YPos
|
||||
:draw_count equ tmp2
|
||||
:ytbl_idx equ tmp3
|
||||
|
||||
stz :ytbl_idx ; Start copying from the first entry in the table
|
||||
lda BG1StartY
|
||||
jsr Mod208
|
||||
sta BG1StartYMod208
|
||||
sta :ytbl_idx ; Start copying from the first entry in the table
|
||||
|
||||
lda StartY ; This is the base line of the virtual screen
|
||||
lda StartYMod208 ; This is the base line of the virtual screen
|
||||
sta :virt_line ; Keep track of it
|
||||
|
||||
lda ScreenHeight
|
||||
@ -246,6 +271,13 @@ CopyBG1YTableToBG1Addr
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,12 +24,16 @@ OldStartY equ 32
|
||||
|
||||
LastPatchOffset equ 34 ; Offset into code field that was patched with BRA instructions
|
||||
StartXMod164 equ 36
|
||||
StartYMod208 equ 38
|
||||
|
||||
BG1StartX equ 38 ; Logical offset of the second background
|
||||
BG1StartXMod164 equ 40
|
||||
BG1StartX equ 40 ; Logical offset of the second background
|
||||
BG1StartXMod164 equ 42
|
||||
|
||||
BG1StartY equ 42
|
||||
BG1StartYMod208 equ 44
|
||||
BG1StartY equ 44
|
||||
BG1StartYMod208 equ 46
|
||||
|
||||
OldBG1StartX equ 48
|
||||
OldBG1StartY equ 50
|
||||
|
||||
bstk equ 208 ; 16-byte stack to push bank addresses
|
||||
|
||||
@ -66,6 +70,10 @@ DIRTY_BIT_BG1_Y equ $0008
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@ _ApplyBG0XPos
|
||||
|
||||
; This code is fairly succinct. See the corresponding code in Vert.s for more detailed comments.
|
||||
:ok
|
||||
lda StartY ; This is the base line of the virtual screen
|
||||
lda StartYMod208 ; This is the base line of the virtual screen
|
||||
sta :virt_line ; Keep track of it
|
||||
|
||||
lda ScreenHeight
|
||||
@ -745,3 +745,4 @@ SetCodeEntryOpcode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
|
||||
; SetBG0YPos
|
||||
;
|
||||
; Set the virtual position of the primary background layer. In addition to
|
||||
; updating the direct page state locations, this routine needs to
|
||||
; Set the virtual position of the primary background layer.
|
||||
SetBG0YPos
|
||||
cmp StartY
|
||||
beq :out ; Easy, if nothing changed, then nothing changes
|
||||
@ -38,6 +37,9 @@ _ApplyBG0YPos
|
||||
stz :rtbl_idx ; Start copying from the first entry in the table
|
||||
|
||||
lda StartY ; This is the base line of the virtual screen
|
||||
jsr Mod208
|
||||
sta StartYMod208
|
||||
|
||||
sta :virt_line ; Keep track of it
|
||||
|
||||
; copy a range of address from the table into the destination bank. If we restrict ourselves to
|
||||
@ -188,3 +190,4 @@ CopyRTableToStkAddr
|
||||
sta: STK_ADDR+$0000,y
|
||||
:none rts
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user