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" sta BankLoad ; Store "Bank Pointer"
; Load in the 256 color background into BG1 buffer ; Load in the 256 color background into BG1 buffer
brl :nobackground ; brl :nobackground
DoLoadBG1 DoLoadBG1
lda BankLoad lda BankLoad
ldx #BG1DataFile 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 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 _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 ; _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. ; finally patch out the code field. Right now, the BRA operand is getting overwritten by tile data.
jsr _ApplyBG0XPosPre jsr _ApplyBG0XPosPre
; jsr _ApplyBG1XPosPre jsr _ApplyBG1XPosPre
jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data 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 _ApplyTilesFast ; This function actually draws the new tiles into the code field
jsr _ApplyBG0XPos ; Patch the code field instructions with exit BRA opcode 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 ; The code fields are locked in now and ready to be rendered

View File

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

View File

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