From 9d401a58619a9bf45ea218db5faebb349db4e7f8 Mon Sep 17 00:00:00 2001 From: Lucas Scharenbroich Date: Mon, 21 Feb 2022 14:25:55 -0600 Subject: [PATCH] Fix masking bug in sprite pre-calc --- src/Sprite.s | 2 +- src/Sprite2.s | 19 +++++++++++++------ src/SpriteRender.s | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Sprite.s b/src/Sprite.s index c8c935e..cf6253c 100644 --- a/src/Sprite.s +++ b/src/Sprite.s @@ -586,7 +586,7 @@ SPRITE_PLANE_SPAN equ VBUFF_STRIDE_BYTES ; 52 ; X = sprite index _PrecalcAllSpriteInfo lda _Sprites+SPRITE_ID,x - and #$2E00 + and #$3E00 xba sta _Sprites+SPRITE_DISP,x ; use bits 9 through 13 for full dispatch diff --git a/src/Sprite2.s b/src/Sprite2.s index 9bc35d2..d3feb2d 100644 --- a/src/Sprite2.s +++ b/src/Sprite2.s @@ -114,9 +114,12 @@ _MarkDirtySprite txa and #$0007 - clc - adc _Sprites+SPRITE_CLIP_HEIGHT,y + pha + + lda _Sprites+SPRITE_CLIP_HEIGHT,y ; Nominal value between 0 and 16+7 = 23 = 10111 dec + clc + adc 1,s and #$0018 sta AreaIndex @@ -135,13 +138,17 @@ _MarkDirtySprite txa and #$0003 - clc - adc _Sprites+SPRITE_CLIP_WIDTH,y + sta 1,s + + lda _Sprites+SPRITE_CLIP_WIDTH,y ; max width = 8 = 0x08 dec - and #$000C - lsr + clc + adc 1,s + lsr ; max value = 4 = 0x04 + and #$0006 ora AreaIndex sta AreaIndex + pla ; Calculate the modified origin address for the sprite. We need to look at the sprite flip bits ; to determine which of the four sprite stamps is the correct one to use. Then, offset that origin diff --git a/src/SpriteRender.s b/src/SpriteRender.s index 2e5386b..5a4b1ca 100644 --- a/src/SpriteRender.s +++ b/src/SpriteRender.s @@ -4,7 +4,7 @@ _DrawSpriteSheet DISP_VFLIP equ $0004 ; hard code these because they are internal values DISP_HFLIP equ $0002 -DISP_MASK equ $00F9 +DISP_MASK equ $0018 ; Isolate the size bits phx