kep-hack/engine/overworld/clear_variables.asm
Llinos Evans 228de2b718 Groundwork for the Candy Jar rework
This does everything except the incrementation.

If you defeat a Meltan, `wCandyJarCount` increments by 1, capping at 40. This is represented in-game as 10, going up to 400, simply by adding a 0 at the end. This, in effect, replicates the Meltan quest from Pokemon Go.

Once 40/400 is reached, the Candy Jar will become an evolution stone, evolving Meltan. Instead of consuming the Jar, the Candies inside are zeroed out.

Currently, the Candy Jar increments, but only once, thus why this is being committed on a separate branch. The bug appears to be at `engine\battle\core.asm`, line 842-861, likely 854-856. It's possible that it could be due to its position in WRAM, or that it's a `db` instead of a `dw`.
2023-05-31 13:37:55 +01:00

30 lines
911 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.
ld a, $0 ; No? Let's zero both of these out then.
ld [wMysteryBoxActive], a ; This is now deactivated.
ld [wDontSwitchOffMysteryBoxYet], a ; To be activated when a Meltan is defeated later.
.skip
ret