Enforce capacity limit of sprite list in VRAM (#2); actually fix LoadSpriteGFX (#8) [bugfix to 59bda0b36b]

This commit is contained in:
xCrystal 2023-09-02 13:01:45 +02:00
parent 74f2a55332
commit ea4ab28652
3 changed files with 10 additions and 5 deletions

View File

@ -42,7 +42,10 @@ DEF SPRITEOAMSTRUCT_ATTRIBUTES rb ; 3
DEF SPRITEOAMSTRUCT_LENGTH EQU _RS
DEF NUM_SPRITE_OAM_STRUCTS EQU 40 ; see wShadowOAM
DEF SPRITE_GFX_LIST_CAPACITY EQU 32 ; see wUsedSprites
; see wUsedSprites
DEF WALKING_SPRITE_GFX_LIST_CAPACITY EQU 9
DEF STILL_SPRITE_GFX_LIST_CAPACITY EQU 10
DEF SPRITE_GFX_LIST_CAPACITY EQU 1 + WALKING_SPRITE_GFX_LIST_CAPACITY + STILL_SPRITE_GFX_LIST_CAPACITY
; PokeAnims indexes (see engine/gfx/pic_animation.asm)
const_def

View File

@ -23,4 +23,5 @@ Level1GroupSprites:
db SPRITE_POKE_BALL
db SPRITE_FRUIT_TREE
db SPRITE_ROCK
; max 3 of 10 still sprites
db 0 ; end

View File

@ -333,9 +333,9 @@ LoadSpriteGFX:
ret
.LoadSprite:
push de
push bc
call GetSprite
pop de
pop bc
ld a, l
ret
@ -383,9 +383,10 @@ ArrangeUsedSprites:
ld a, [hl]
call GetSpriteLength
; There are only two tables, so don't go any further than that.
; Don't go any further than the second row in the second table.
add b
jr c, .quit
cp $a0 + 1
jr nc, .quit
ld [hl], b
ld b, a