Fix some pokecrystal bug and glitches (#8)

Credits sequence changes move selection menu behavior; Swimming NPCs aren't limited by their movement radius; No bump noise if standing on tile E; The unused phonecall script command may crash; ScriptCall can overflow wScriptStack and crash; LoadSpriteGFX does not limit the capacity of UsedSprites; ReadObjectEvents overflows into wObjectMasks; ClearWRAM only clears WRAM bank 1; BattleAnimCmd_ClearObjs only clears the first 6⅔ objects; Options menu fails to clear joypad state on initialization
This commit is contained in:
xCrystal
2023-07-27 13:01:32 +02:00
parent d30b9dd60f
commit 59bda0b36b
12 changed files with 24 additions and 47 deletions

View File

@@ -543,13 +543,12 @@ TryObjectEvent:
ld a, [hl]
and MAPOBJECT_TYPE_MASK
; BUG: TryObjectEvent arbitrary code execution (see docs/bugs_and_glitches.md)
push bc
ld de, 3
ld hl, ObjectEventTypeArray
call IsInArray
jr nc, .nope
pop bc
jr nc, .nope
inc hl
ld a, [hli]

View File

@@ -4,10 +4,10 @@ CanObjectMoveInDirection:
bit SWIMMING_F, [hl]
jr z, .not_swimming
; BUG: Swimming NPCs aren't limited by their movement radius (see docs/bugs_and_glitches.md)
ld hl, OBJECT_FLAGS1
add hl, bc
bit NOCLIP_TILES_F, [hl]
jr nz, .noclip_tiles
push hl
push bc
call WillObjectBumpIntoLand

View File

@@ -316,8 +316,6 @@ AddSpriteGFX:
ret
LoadSpriteGFX:
; BUG: LoadSpriteGFX does not limit the capacity of UsedSprites (see docs/bugs_and_glitches.md)
ld hl, wUsedSprites
ld b, SPRITE_GFX_LIST_CAPACITY
.loop
@@ -335,7 +333,9 @@ LoadSpriteGFX:
ret
.LoadSprite:
push de
call GetSprite
pop de
ld a, l
ret

View File

@@ -391,9 +391,9 @@ DoPlayerMovement::
db FACE_UP | FACE_LEFT ; COLL_HOP_UP_LEFT
.CheckWarp:
; BUG: No bump noise if standing on tile $3E (see docs/bugs_and_glitches.md)
ld a, [wWalkingDirection]
cp STANDING
jr z, .not_warp
ld e, a
ld d, 0
ld hl, .EdgeWarps
@@ -405,8 +405,6 @@ DoPlayerMovement::
ld a, TRUE
ld [wWalkingIntoEdgeWarp], a
ld a, [wWalkingDirection]
cp STANDING
jr z, .not_warp
ld e, a
ld a, [wPlayerDirection]

View File

@@ -1238,12 +1238,13 @@ Script_memcall:
; fallthrough
ScriptCall:
; BUG: ScriptCall can overflow wScriptStack and crash (see docs/bugs_and_glitches.md)
push de
ld hl, wScriptStackSize
ld e, [hl]
ld a, [hl]
cp 5
ret nc
push de
inc [hl]
ld e, a
ld d, 0
ld hl, wScriptStack
add hl, de