Create function to update only secondary sprites to optimize die roll animation (#11)

This commit is contained in:
xCrystal
2023-09-30 13:30:30 +02:00
parent 49a3f6b8c8
commit 8967898bc9
3 changed files with 34 additions and 4 deletions

View File

@@ -3078,6 +3078,35 @@ InitSprites:
dw wObject11Struct
dw wObject12Struct
_UpdateSecondarySprites:
; this is a shorter _UpdateSprites for when only secondary sprites have changed since the last sprites update,
; but NOT expanded, which would require to displace primary (NPC) sprites in OAM.
; if it is detected that the size of secondary sprites has increased in the end,
; fall back to calling _UpdateSprites to avoid corruption.
ld a, [wVramState]
bit 0, a
ret z
ld a, [hUsedSpriteIndex]
push af
xor a
ldh [hUsedSpriteIndex], a
.go
ldh a, [hOAMUpdate]
push af
ld a, 1
ldh [hOAMUpdate], a
call InitSecondarySprites
pop af
ldh [hOAMUpdate], a
ldh a, [hUsedSpriteIndex]
ld c, a
pop af
cp c
ret nc
jp _UpdateSprites
InitSecondarySprites:
ld a, [wDisplaySecondarySprites]
bit SECONDARYSPRITES_BOARD_MENU_F, a