Fix some minor bugs in the TwoLayer rendering functions

This commit is contained in:
Lucas Scharenbroich 2022-06-27 00:32:44 -05:00
parent c501e9f944
commit 81e0aeb351
4 changed files with 13 additions and 19 deletions

View File

@ -85,7 +85,7 @@ ScreenHeight equ 14
sta BankLoad ; Store "Bank Pointer"
; Load in the 256 color background into BG1 buffer
brl :nobackground
; brl :nobackground
DoLoadBG1
lda BankLoad
ldx #BG1DataFile

View File

@ -25,12 +25,12 @@ _Render
stz SpriteRemovedFlag ; If we remove a sprite, then we need to flag a rebuild for the next frame
jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen
; jsr _ApplyBG1YPos
jsr _ApplyBG1YPos
; _ApplyBG0Xpos need to be split because we have to set the offsets, then draw in any updated tiles, and
; finally patch out the code field. Right now, the BRA operand is getting overwritten by tile data.
jsr _ApplyBG0XPosPre
; jsr _ApplyBG1XPosPre
jsr _ApplyBG1XPosPre
jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data
@ -40,7 +40,7 @@ _Render
jsr _ApplyTilesFast ; This function actually draws the new tiles into the code field
jsr _ApplyBG0XPos ; Patch the code field instructions with exit BRA opcode
; jsr _ApplyBG1XPos ; Update the direct page value based on the horizontal position
jsr _ApplyBG1XPos ; Update the direct page value based on the horizontal position
; The code fields are locked in now and ready to be rendered

View File

@ -257,7 +257,7 @@ _SetTile
ldy #TwoLyrDynProcs
brl :pickDynProc
:pickTwoLyrProc ldy #SlowProcs ; #TwoLyrProcs
:pickTwoLyrProc ldy #TwoLyrProcs
lda procIdx
jsr _SetTileProcs
jmp _PushDirtyTileX

View File

@ -2,6 +2,7 @@
; routines, there's nothing in here that is particularly well optimized.
Tile0TwoLyr
ldal TileStore+TS_WORD_OFFSET,x
and #$00FF
ora #$4800
sta: $0004,y
@ -42,6 +43,7 @@ Tile0TwoLyr
sta $7000,y
sta $7003,y
rep #$20
plb
rts
; Draw from the sprite buffer into a fully transparent tile
@ -140,20 +142,16 @@ _TmpTileDataToCodeField
; Copy a tile into the tile data buffer and then render to the code field
CopyTileATwoLyr
lda TileStore+TS_JMP_ADDR,x ; Get the address of the exception handler
ldal TileStore+TS_JMP_ADDR,x ; Get the address of the exception handler
sta _JTBL_CACHE
lda TileStore+TS_WORD_OFFSET,x ; Load the word offset of this tile (0 to 82 in steps of 2)
ldal TileStore+TS_WORD_OFFSET,x ; Load the word offset of this tile (0 to 82 in steps of 2)
ora #$B100 ; Pre-calc the LDA (dp),y opcode + operand
xba
sta _OP_CACHE
lda TileStore+TS_CODE_ADDR_HIGH,x
pha
ldy TileStore+TS_CODE_ADDR_LOW,x
lda TileStore+TS_TILE_ADDR,x
ldal TileStore+TS_TILE_ADDR,x
tax
plb
]line equ 0
lup 8
@ -171,20 +169,16 @@ CopyTileATwoLyr
jmp _TmpTileDataToCodeField
CopyTileVTwoLyr
lda TileStore+TS_JMP_ADDR,x ; Get the address of the exception handler
ldal TileStore+TS_JMP_ADDR,x ; Get the address of the exception handler
sta _JTBL_CACHE
lda TileStore+TS_WORD_OFFSET,x ; Load the word offset of this tile (0 to 82 in steps of 2)
ldal TileStore+TS_WORD_OFFSET,x ; Load the word offset of this tile (0 to 82 in steps of 2)
ora #$B100 ; Pre-calc the LDA (dp),y opcode + operand
xba
sta _OP_CACHE
lda TileStore+TS_CODE_ADDR_HIGH,x
pha
ldy TileStore+TS_CODE_ADDR_LOW,x
lda TileStore+TS_TILE_ADDR,x
ldal TileStore+TS_TILE_ADDR,x
tax
plb
]src equ 7
]dest equ 0