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

@ -80,4 +80,3 @@ PredefPointers::
add_predef AnimateFrontpic
add_predef Unused_HOF_AnimateAlignedFrontpic
add_predef HOF_AnimateFrontpic
dbw -1, DummyEndPredef ; pointless

View File

@ -644,9 +644,8 @@ BattleAnimCmd_ResetObp0:
ret
BattleAnimCmd_ClearObjs:
; BUG: BattleAnimCmd only clears the first 6⅔ objects (see docs/bugs_and_glitches.md)
ld hl, wActiveAnimObjects
ld a, $a0
ld a, NUM_ANIM_OBJECTS * BATTLEANIMSTRUCT_LENGTH
.loop
ld [hl], 0
inc hl

View File

@ -11,7 +11,7 @@
DEF NUM_OPTIONS EQU const_value ; 8
_Option:
; BUG: Options menu fails to clear joypad state on initialization (see docs/bugs_and_glitches.md)
call ClearJoypad
ld hl, hInMenu
ld a, [hl]
push af

View File

@ -73,11 +73,13 @@ Credits::
call GetCreditsPalette
call SetPalettes
; BUG: Credits sequence changes move selection menu behavior (see docs/bugs_and_glitches.md)
ldh a, [hVBlank]
push af
ld a, $5
ldh [hVBlank], a
ldh a, [hInMenu]
push af
ld a, TRUE
ldh [hInMenu], a
xor a
@ -101,6 +103,8 @@ Credits::
ldh [hLCDCPointer], a
ldh [hBGMapAddress], a
pop af
ldh [hInMenu], a
pop af
ldh [hVBlank], a
pop af
ldh [rSVBK], a

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

View File

@ -93,19 +93,6 @@ GetRemainingSpaceInPhoneList:
INCLUDE "data/phone/permanent_numbers.asm"
BrokenPlaceFarString:
; This routine is not in bank 0 and will fail or crash if called.
ldh a, [hROMBank]
push af
ld a, b
rst Bankswitch
call PlaceString
pop af
rst Bankswitch
ret
CheckPhoneCall::
; Check if the phone is ringing in the overworld.
@ -496,14 +483,12 @@ PhoneCall::
ld [hl], "☎"
inc hl
inc hl
; BUG: The unused phonecall script command may crash (see docs/bugs_and_glitches.md)
ld a, [wPhoneScriptBank]
ld b, a
ld a, [wPhoneCaller]
ld e, a
ld a, [wPhoneCaller + 1]
ld d, a
call BrokenPlaceFarString
ld a, [wPhoneScriptBank]
call PlaceFarString
ret
Phone_NoSignal:

View File

@ -184,7 +184,6 @@ ClearVRAM::
ClearWRAM::
; Wipe swappable WRAM banks (1-7)
; Assumes CGB or AGB
; BUG: ClearWRAM only clears WRAM bank 1 (see docs/bugs_and_glitches.md)
ld a, 1
.bank_loop
@ -197,7 +196,7 @@ ClearWRAM::
pop af
inc a
cp 8
jr nc, .bank_loop
jr c, .bank_loop
ret
ClearsScratch::

View File

@ -573,13 +573,13 @@ ReadObjectEvents::
ld a, [wCurMapObjectEventCount]
call CopyMapObjectEvents
; get NUM_OBJECTS - [wCurMapObjectEventCount]
; BUG: ReadObjectEvents overflows into wObjectMasks (see docs/bugs_and_glitches.md)
; get NUM_OBJECTS - [wCurMapObjectEventCount] - 1
ld a, [wCurMapObjectEventCount]
ld c, a
ld a, NUM_OBJECTS
ld a, NUM_OBJECTS - 1
sub c
jr z, .skip
jr c, .skip
; could have done "inc hl" instead
ld bc, 1
@ -2264,10 +2264,3 @@ LoadMapTileset::
pop bc
pop hl
ret
DummyEndPredef::
; Unused function at the end of PredefPointers.
rept 16
nop
endr
ret