Shrinking Sprites - Out of Sync
Posted: Sat May 29, 2021 1:01 am
I understand that chained sprites cannot use the vertical shrink factor for scaling, only the anchor sprite can. With that in mind I have the following code and it's functional (I cut out everything that isn't responsible for this bug):
I've set up my code so that holding the A button shrinks the little alien character. Eventually the values wrap back around and the alien is full size again. But since the values aren't equal they don't always sync up and the right (dependent) half of the sprite will collapse into itself to the left since it ignores vertical shrinking. This is one of those weird cases where I know exactly why this is happening but not how to prevent it.
EDIT: I wrote #$0111 instead to AlienShrink2 and that fixed it.
Code: Select all
pushall ;this macro pushes all regs except a7 onto the stack
sub.w #$0111,(AlienShrink)
sub.w #$0100,(AlienShrink2)
JSR chainsprite
popall
chainsprite:
;Sprite Select (1)
move.w #$8000+1,$3C0000
move.w (AlienShrink),$3C0002
move.w #$8200+1,$3C0000
move.w #$F404,$3C0002
move.w #$8400+1,$3C0000
move.w #$2800,$3C0002
;Attribs at $0040
;Sprite (1) - Tile (1)
move.w #$0040,$3C0000
move.w #$2001,$3C0002
move.w #$0041,$3C0000
move.w #$0100,$3C0002
;Sprite (1) - Tile (2)
move.w #$0040+2,$3C0000
move.w #$2002,$3C0002
move.w #$0041+2,$3C0000
move.w #$0100,$3C0002
;Sprite (1) - Tile (3)
move.w #$0040+4,$3C0000
move.w #$2003,$3C0002
move.w #$0041+4,$3C0000
move.w #$0100,$3C0002
;Sprite (1) - Tile (4)
move.w #$0040+6,$3C0000
move.w #$2004,$3C0002
move.w #$0041+6,$3C0000
move.w #$0100,$3C0002
;Sprite Select (2)
move.w #$8000+2,$3C0000
move.w (AlienShrink2),$3C0002
move.w #$8200+2,$3C0000
MOVE.W #$0040,$3C0002
MOVE.W #$8400+2,$3C0000
MOVE.W #$0000,$3C0002
;Attribs at $0080
;Sprite (2) - Tile (1)
MOVE.W #$0080,$3C0000
MOVE.W #$2005,$3C0002
MOVE.W #$0081,$3C0000
MOVE.W #$0100,$3C0002
MOVE.W #$0080+2,$3C0000
MOVE.W #$2006,$3C0002
MOVE.W #$0081+2,$3C0000
MOVE.W #$0100,$3C0002
MOVE.W #$0080+4,$3C0000
MOVE.W #$2007,$3C0002
MOVE.W #$0081+4,$3C0000
MOVE.W #$0100,$3C0002
MOVE.W #$0080+6,$3C0000
MOVE.W #$2008,$3C0002
MOVE.W #$0081+6,$3C0000
MOVE.W #$0100,$3C0002
RTS
EDIT: I wrote #$0111 instead to AlienShrink2 and that fixed it.