From ea4ab28652105d4a87289072d3c67abd2cd48b5d Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 2 Sep 2023 13:01:45 +0200 Subject: [PATCH] Enforce capacity limit of sprite list in VRAM (#2); actually fix LoadSpriteGFX (#8) [bugfix to 59bda0b36b2bfd1afd0dedcb44cee26ea262949d] --- constants/gfx_constants.asm | 5 ++++- data/maps/outdoor_sprites.asm | 1 + engine/overworld/overworld.asm | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm index 61e4c0c7c..c3709869f 100644 --- a/constants/gfx_constants.asm +++ b/constants/gfx_constants.asm @@ -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 diff --git a/data/maps/outdoor_sprites.asm b/data/maps/outdoor_sprites.asm index 14d025f53..c1a02a6c7 100644 --- a/data/maps/outdoor_sprites.asm +++ b/data/maps/outdoor_sprites.asm @@ -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 diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 8faa60773..8939d08e8 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -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