From 5bc9cc7ff2e6f3af385bb56576ee579eb6729ad7 Mon Sep 17 00:00:00 2001 From: Lucas Scharenbroich Date: Mon, 22 Nov 2021 13:26:25 -0600 Subject: [PATCH] Add a SPRITE_HIDE flag to toggle whether a sprite is drawn or not --- src/Defs.s | 1 + src/Sprite.s | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Defs.s b/src/Defs.s index be27d62..a9869c5 100644 --- a/src/Defs.s +++ b/src/Defs.s @@ -138,6 +138,7 @@ TILE_VFLIP_BIT equ $0400 TILE_HFLIP_BIT equ $0200 ; Sprite constants +SPRITE_HIDE equ $8000 SPRITE_16X16 equ $1800 SPRITE_16X8 equ $1000 SPRITE_8X16 equ $0800 diff --git a/src/Sprite.s b/src/Sprite.s index 6fc04a1..1448caf 100644 --- a/src/Sprite.s +++ b/src/Sprite.s @@ -190,7 +190,11 @@ _RenderSprites ; Draw the sprite into the sprint plane buffer(s) - jsr _DrawSpriteY ; Use variant that takes the Y-register arg + lda _Sprites+SPRITE_ID,y + bit #SPRITE_HIDE + bne :next + + jsr _DrawSpriteYA ; Use variant that takes the Y-register arg ; Mark the appropriate tiles as dirty and as occupied by a sprite so that the ApplyTiles ; subroutine will get the drawn data from the sprite plane into the code field where it @@ -199,8 +203,8 @@ _RenderSprites ldx tmp0 ; Restore the index into the sprite array jsr _MarkDirtySprite ; Mark the tiles that this sprite overlaps as dirty - ldx tmp0 ; Restore the index again - brl :next + ldy tmp0 ; Restore the index again + bra :next ; _GetTileAt ; @@ -330,6 +334,7 @@ _DrawSprite txy _DrawSpriteY lda _Sprites+SPRITE_ID,y +_DrawSpriteYA and #$1E00 ; use bits 9, 10, 11 and 12 to dispatch xba tax