kep-hack/engine/overworld/clear_variables.asm
Llinos Evans 138bfd7042 Multiple bug fixes
* Moves the Mystery Box activation into Event Constants. This means that now, the Mystery Box activation is handled in the save, preventing some jank from happening when resetting.
* The "don't switch off the box yet" variable is now always unset after entering a map. Meltan itself allows the variable to keep being re-set, which is super handy. Now, whenever you enter and exit maps, it'll work properly.
* Flying, using an Escape Rope, and using Dig, all now unset the Mystery Box. If for some reason everything fucks up, this'll fix it.
* Fixed a text bug with the scientist in Celadon University.
* Fixed a menu alignment issue with the Vermilion Beauty.
* Attempted to fix the Battle Tent exit. Failed. This is a really, really bad bug, hopefully this gets sorted sometime.
2023-08-31 02:48:01 +01:00

30 lines
888 B
NASM

ClearVariablesOnEnterMap::
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
ldh [rWY], a
xor a
ldh [hAutoBGTransferEnabled], a
ld [wStepCounter], a
ld [wLoneAttackNo], a
ldh [hJoyPressed], a
ldh [hJoyReleased], a
ldh [hJoyHeld], a
ld [wActionResultOrTookBattleTurn], a
ld hl, wCardKeyDoorY
ld [hli], a
ld [hl], a
ld hl, wWhichTrade
ld bc, wStandingOnWarpPadOrHole - wWhichTrade
call FillMemory
; The Mystery Box for Meltan gets switched off when leaving every map, but SPECIFICALLY not after a battle.
; Because leaving battle is map re-entry, this exception is included.
ld a, [wDontSwitchOffMysteryBoxYet] ; Load WRAM bit.
and a ; Did a battle just happen?
jr nz, .skip ; Yes? Off you go then.
ResetEvent EVENT_MYSTERY_BOX_ACTIVATED
.skip
ld a, $0 ; No? Let's zero this out then.
ld [wDontSwitchOffMysteryBoxYet], a ; To be activated when a Meltan is defeated later.
ret