From 81e0aeb351a532282c1b6ee59124555bad41a06c Mon Sep 17 00:00:00 2001 From: Lucas Scharenbroich Date: Mon, 27 Jun 2022 00:32:44 -0500 Subject: [PATCH] Fix some minor bugs in the TwoLayer rendering functions --- demos/sprites/App.Main.s | 2 +- src/Render.s | 6 +++--- src/Tiles.s | 2 +- src/render/TwoLayer.s | 22 ++++++++-------------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/demos/sprites/App.Main.s b/demos/sprites/App.Main.s index 7e278fb..e2f9747 100644 --- a/demos/sprites/App.Main.s +++ b/demos/sprites/App.Main.s @@ -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 diff --git a/src/Render.s b/src/Render.s index 404ed10..56d73f8 100644 --- a/src/Render.s +++ b/src/Render.s @@ -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 diff --git a/src/Tiles.s b/src/Tiles.s index aa99e57..ad55581 100644 --- a/src/Tiles.s +++ b/src/Tiles.s @@ -257,7 +257,7 @@ _SetTile ldy #TwoLyrDynProcs brl :pickDynProc -:pickTwoLyrProc ldy #SlowProcs ; #TwoLyrProcs +:pickTwoLyrProc ldy #TwoLyrProcs lda procIdx jsr _SetTileProcs jmp _PushDirtyTileX diff --git a/src/render/TwoLayer.s b/src/render/TwoLayer.s index 738445f..8ca2df6 100644 --- a/src/render/TwoLayer.s +++ b/src/render/TwoLayer.s @@ -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