From e53ae0eac97bc91309290d13d45e384a230f9d4b Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 30 Sep 2023 19:12:57 +0200 Subject: [PATCH] Optimize some HRAM usage --- constants/menu_constants.asm | 4 +- data/events/special_pointers.asm | 2 +- docs/bugs_and_glitches.md | 2 +- docs/develop/index.md | 4 +- docs/event_commands.md | 18 ++-- engine/battle_anims/anim_commands.asm | 4 +- engine/board/menu.asm | 26 ++--- engine/events/buena.asm | 2 +- engine/events/buena_menu.asm | 2 +- engine/events/bug_contest/contest_2.asm | 4 +- engine/events/celebi.asm | 4 +- engine/events/daycare.asm | 4 +- engine/events/dratini.asm | 6 +- engine/events/fruit_trees.asm | 2 +- engine/events/haircut.asm | 10 +- engine/events/happiness_egg.asm | 4 +- engine/events/heal_machine_anim.asm | 4 +- engine/events/kurt.asm | 2 +- engine/events/lucky_number.asm | 10 +- engine/events/magikarp.asm | 8 +- engine/events/magnet_train.asm | 2 +- engine/events/misc_scripts.asm | 4 +- engine/events/move_tutor.asm | 6 +- engine/events/overworld.asm | 14 +-- engine/events/play_slow_cry.asm | 2 +- engine/events/poisonstep.asm | 2 +- engine/events/shuckle.asm | 12 +-- engine/events/specials.asm | 44 ++++---- engine/events/sweet_scent.asm | 4 +- engine/events/treemons.asm | 4 +- engine/events/unown_walls.asm | 4 +- engine/games/slot_machine.asm | 4 +- engine/games/unown_puzzle.asm | 2 +- engine/link/link.asm | 30 +++--- engine/menus/start_menu.asm | 8 +- engine/overworld/events.asm | 14 +-- engine/overworld/scripting.asm | 138 ++++++++++++------------ engine/overworld/select_menu.asm | 4 +- engine/overworld/wildmons.asm | 4 +- engine/pokemon/caught_data.asm | 6 +- engine/pokemon/mail.asm | 2 +- engine/pokemon/search_owned.asm | 28 ++--- home/delay.asm | 4 +- home/joypad.asm | 6 +- home/print_text.asm | 4 +- home/vblank.asm | 22 ++-- ram/hram.asm | 8 +- ram/wram.asm | 8 +- 48 files changed, 254 insertions(+), 258 deletions(-) diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index 626dcefe2..9924faf6d 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -72,8 +72,8 @@ DEF MONMENU_MENUOPTION EQU 1 DEF NUM_MONMENU_ITEMS EQU 8 ; start/select menu return values -DEF HMENURETURN_SCRIPT EQU %10000000 -DEF HMENURETURN_ASM EQU %11111111 +DEF MENURETURN_SCRIPT EQU %10000000 +DEF MENURETURN_ASM EQU %11111111 ; PartyMenuQualityPointers indexes (see data/party_menu_qualities.asm) const_def diff --git a/data/events/special_pointers.asm b/data/events/special_pointers.asm index 1490b29ab..46db068b2 100644 --- a/data/events/special_pointers.asm +++ b/data/events/special_pointers.asm @@ -1,5 +1,5 @@ ; Special routines can be used with the "special" map script command. -; They often use wScriptVar for arguments and return values. +; They often use hScriptVar for arguments and return values. MACRO add_special \1Special:: diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index 74c896468..001e45a6e 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -2304,7 +2304,7 @@ This is a bug with `HaircutOrGrooming` in [engine/events/haircut.asm](https://gi .ok inc hl ld a, [hli] - ld [wScriptVar], a + ldh [hScriptVar], a ld c, [hl] call ChangeHappiness ret diff --git a/docs/develop/index.md b/docs/develop/index.md index 56f2c4325..5a20d41b4 100755 --- a/docs/develop/index.md +++ b/docs/develop/index.md @@ -102,7 +102,7 @@ $~~~~$*Exit overworld loop* --- wMapStatus == MAPSTATUS_HANDLE: the remainder of the code goes at this level -> wOverworldDelay <= 2 2 is *MaxOverworldDelay*\ +> hOverworldDelay <= 2 2 is *MaxOverworldDelay*\ > MapEventStatus == MAPEVENTS_ON:\ >$~~~~$*Get joypad* update hJoyDown, hJoyReleased, hJoyPressed\ >$~~~~$*Refresh pals* @@ -295,7 +295,7 @@ wMapStatus == MAPSTATUS_HANDLE: the remainder of the code goes at this level< >> **CheckObjectEnteringVisibleRange** (wPlayerStepFlags[PLAYERSTEP_STOP_F] == TRUE) -> DelayFrames(wOverworldDelay) +> DelayFrames(hOverworldDelay) > **HandleMapBackground** _UpdateSprites + ScrollScreen diff --git a/docs/event_commands.md b/docs/event_commands.md index 75f269d51..e6aa4c229 100644 --- a/docs/event_commands.md +++ b/docs/event_commands.md @@ -70,12 +70,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii ## `$15`: setval value -[wScriptVar] = value +[hScriptVar] = value ## `$16`: addval value -[wScriptVar] += value +[hScriptVar] += value ## `$17`: random value @@ -86,12 +86,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii ## `$19`: readmem address -[wScriptVar] = [address] +[hScriptVar] = [address] ## `$1A`: writemem address -[address] = [wScriptVar] +[address] = [hScriptVar] ## `$1B`: loadmem address, value @@ -101,12 +101,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii ## `$1C`: readvar variable -[wScriptVar] = GetVarAction(variable) +[hScriptVar] = GetVarAction(variable) ## `$1D`: writevar variable -GetVarAction(variable) = [wScriptVar] +GetVarAction(variable) = [hScriptVar] ## `$1E`: loadvar variable, value @@ -216,21 +216,21 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii ## `$3F`: getnum string_buffer -GetStringBuffer(string_buffer) = PrintNum([wScriptVar]) +GetStringBuffer(string_buffer) = PrintNum([hScriptVar]) ## `$40`: getmonname string_buffer, mon_id GetStringBuffer(string_buffer) = GetPokemonName(mon_id) -If mon_id = `USE_SCRIPT_VAR`, then it uses `[wScriptVar]` instead. +If mon_id = `USE_SCRIPT_VAR`, then it uses `[hScriptVar]` instead. ## `$41`: getitemname string_buffer, item_id GetStringBuffer(string_buffer) = GetItemName(item_id) -If item_id = `USE_SCRIPT_VAR`, then it uses `[wScriptVar]` instead. +If item_id = `USE_SCRIPT_VAR`, then it uses `[hScriptVar]` instead. ## `$42`: getcurlandmarkname string_buffer diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index 8c99c3edf..ddf8556a2 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -193,9 +193,9 @@ BattleAnimDelayFrame: ; Like DelayFrame but wastes battery life. ld a, 1 - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a .wait - ld a, [wVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr nz, .wait ret diff --git a/engine/board/menu.asm b/engine/board/menu.asm index 06cebd59c..04743f144 100755 --- a/engine/board/menu.asm +++ b/engine/board/menu.asm @@ -53,11 +53,11 @@ BoardMenuScript:: done .SubmenuCallback: -; if submenu has requested a callback through hMenuReturn, +; if submenu has requested a callback through wMenuReturn, ; it has also taken care of queuing it into wQueuedScriptBank/wQueuedScriptAddr. - readmem hMenuReturn - ifequal HMENURETURN_SCRIPT, .CallbackScript - ifequal HMENURETURN_ASM, .CallbackAsm + readmem wMenuReturn + ifequal MENURETURN_SCRIPT, .CallbackScript + ifequal MENURETURN_ASM, .CallbackAsm end .CallbackScript: @@ -68,7 +68,7 @@ BoardMenuScript:: end BoardMenu:: -; returns the selected menu item (BOARDMENUITEM_*) in wScriptVar upon exit +; returns the selected menu item (BOARDMENUITEM_*) in hScriptVar upon exit ld a, [wBoardMenuLastCursorPosition] cp NUM_BOARD_MENU_ITEMS jr c, .ok @@ -107,7 +107,7 @@ BoardMenu:: ld hl, wDisplaySecondarySprites res SECONDARYSPRITES_BOARD_MENU_F, [hl] ld a, [wBoardMenuCursorPosition] - ld [wScriptVar], a + ldh [hScriptVar], a ret DrawBoardMenuTilesAndClearPriorityAttr: @@ -217,13 +217,13 @@ DIE_MAX_NUMBER EQU 6 ld hl, wDisplaySecondarySprites res SECONDARYSPRITES_DIE_ROLL_F, [hl] xor a ; FALSE - ld [wScriptVar], a + ldh [hScriptVar], a ret .confirm_roll call UpdateSprites ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret BoardMenu_BreakDieAnimation: @@ -341,8 +341,8 @@ BoardMenu_Party: .quit ; if quitted party menu after using field move call BoardMenu_CloseSubmenu - ld a, HMENURETURN_SCRIPT - ldh [hMenuReturn], a + ld a, MENURETURN_SCRIPT + ld [wMenuReturn], a ret BoardMenu_Pack: @@ -352,8 +352,8 @@ BoardMenu_Pack: ld a, [wPackUsedItem] and a ret z - ld a, HMENURETURN_SCRIPT - ldh [hMenuReturn], a + ld a, MENURETURN_SCRIPT + ld [wMenuReturn], a ret BoardMenu_Pokegear: @@ -363,7 +363,7 @@ BoardMenu_Pokegear: BoardMenu_OpenSubmenu: xor a - ldh [hMenuReturn], a + ld [wMenuReturn], a ldh [hBGMapMode], a call LoadStandardMenuHeader farcall FadeOutPalettesToWhite diff --git a/engine/events/buena.asm b/engine/events/buena.asm index 3c936173c..7452edfbc 100644 --- a/engine/events/buena.asm +++ b/engine/events/buena.asm @@ -24,7 +24,7 @@ BuenasPassword: .wrong ld a, b - ld [wScriptVar], a + ldh [hScriptVar], a ret .MenuHeader: diff --git a/engine/events/buena_menu.asm b/engine/events/buena_menu.asm index fada80138..e9b626d54 100644 --- a/engine/events/buena_menu.asm +++ b/engine/events/buena_menu.asm @@ -5,7 +5,7 @@ AskRememberPassword: ld a, $1 .okay - ld [wScriptVar], a + ldh [hScriptVar], a ret .DoMenu: diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm index ddfad8644..8c6d14ba0 100644 --- a/engine/events/bug_contest/contest_2.asm +++ b/engine/events/bug_contest/contest_2.asm @@ -88,12 +88,12 @@ ContestDropOffMons: ; ... and replacing it with the terminator byte ld [hl], -1 xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .fainted ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret ContestReturnMons: diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 63d973e6e..1880c92dc 100644 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm @@ -303,12 +303,12 @@ CheckCaughtCelebi: bit BATTLERESULT_CAUGHT_CELEBI, a jr z, .false ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a jr .done .false xor a ; FALSE - ld [wScriptVar], a + ldh [hScriptVar], a .done ret diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm index 369128384..9ba20bcf3 100644 --- a/engine/events/daycare.asm +++ b/engine/events/daycare.asm @@ -413,14 +413,14 @@ DayCareManOutside: .Load0: call PrintText1bpp xor a ; FALSE - ld [wScriptVar], a + ldh [hScriptVar], a ret .PartyFull: ld hl, .NoRoomForEggText call PrintText1bpp ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret .FoundAnEggText: diff --git a/engine/events/dratini.asm b/engine/events/dratini.asm index 2dd97eaee..c95592e02 100644 --- a/engine/events/dratini.asm +++ b/engine/events/dratini.asm @@ -1,9 +1,9 @@ GiveDratini: -; if wScriptVar is 0 or 1, change the moveset of the last Dratini in the party. +; if hScriptVar is 0 or 1, change the moveset of the last Dratini in the party. ; 0: give it a special moveset with Extremespeed. ; 1: give it the normal moveset of a level 15 Dratini. - ld a, [wScriptVar] + ldh a, [hScriptVar] cp $2 ret nc ld bc, wPartyCount @@ -30,7 +30,7 @@ GiveDratini: .GiveMoveset: push hl - ld a, [wScriptVar] + ldh a, [hScriptVar] ld hl, .Movesets ld bc, .Moveset1 - .Moveset0 call AddNTimes diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm index c0cee0e20..36ddcbccd 100644 --- a/engine/events/fruit_trees.asm +++ b/engine/events/fruit_trees.asm @@ -50,7 +50,7 @@ CheckFruitTree: ld b, 2 call GetFruitTreeFlag ld a, c - ld [wScriptVar], a + ldh [hScriptVar], a ret PickedFruitTree: diff --git a/engine/events/haircut.asm b/engine/events/haircut.asm index ab1635b70..84d7f166c 100644 --- a/engine/events/haircut.asm +++ b/engine/events/haircut.asm @@ -2,14 +2,14 @@ BillsGrandfather: farcall SelectMonFromParty jr c, .cancel ld a, [wCurPartySpecies] - ld [wScriptVar], a + ldh [hScriptVar], a ld [wNamedObjectIndex], a call GetPokemonName jp CopyPokemonName_Buffer1_Buffer3 .cancel xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret OlderHaircutBrother: @@ -48,19 +48,19 @@ HaircutOrGrooming: .ok inc hl ld a, [hli] - ld [wScriptVar], a + ldh [hScriptVar], a ld c, [hl] call ChangeHappiness ret .nope xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .egg ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret INCLUDE "data/events/happiness_probabilities.asm" diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm index ac3e165b9..1a3cd8ed9 100644 --- a/engine/events/happiness_egg.asm +++ b/engine/events/happiness_egg.asm @@ -13,7 +13,7 @@ GetFirstPokemonHappiness: .done ld [wNamedObjectIndex], a ld a, [hl] - ld [wScriptVar], a + ldh [hScriptVar], a call GetPokemonName jp CopyPokemonName_Buffer1_Buffer3 @@ -26,7 +26,7 @@ CheckFirstMonIsEgg: xor a .egg - ld [wScriptVar], a + ldh [hScriptVar], a call GetPokemonName jp CopyPokemonName_Buffer1_Buffer3 diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm index b5b6df31a..d0d9cca1d 100644 --- a/engine/events/heal_machine_anim.asm +++ b/engine/events/heal_machine_anim.asm @@ -12,11 +12,11 @@ HealMachineAnim: ld a, [wPartyCount] and a ret z - ; The location of the healing machine relative to the player is stored in wScriptVar. + ; The location of the healing machine relative to the player is stored in hScriptVar. ; 0: Up and left (Pokemon Center) ; 1: Left (Elm's Lab) ; 2: Up (Hall of Fame) - ld a, [wScriptVar] + ldh a, [hScriptVar] ld [wHealMachineAnimType], a ldh a, [rOBP1] ld [wHealMachineTempOBP1], a diff --git a/engine/events/kurt.asm b/engine/events/kurt.asm index 20e7d0a28..7dfa20296 100644 --- a/engine/events/kurt.asm +++ b/engine/events/kurt.asm @@ -30,7 +30,7 @@ SelectApricornForKurt: ld [wMenuSelection], a call Kurt_SelectApricorn ld a, c - ld [wScriptVar], a + ldh [hScriptVar], a and a jr z, .done ld [wCurItem], a diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm index f5443920c..44a47a0cb 100644 --- a/engine/events/lucky_number.asm +++ b/engine/events/lucky_number.asm @@ -1,6 +1,6 @@ CheckForLuckyNumberWinners: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ld [wTempByteValue], a ld a, [wPartyCount] and a @@ -79,7 +79,7 @@ CheckForLuckyNumberWinners: cp EGG jr z, .SkipBoxMon - call .CompareLuckyNumberToMonID ; sets wScriptVar and wCurPartySpecies appropriately + call .CompareLuckyNumberToMonID ; sets hScriptVar and wCurPartySpecies appropriately jr nc, .SkipBoxMon ld a, TRUE ld [wTempByteValue], a @@ -100,7 +100,7 @@ CheckForLuckyNumberWinners: jr c, .BoxesLoop call CloseSRAM - ld a, [wScriptVar] + ldh a, [hScriptVar] and a ret z ; found nothing @@ -167,7 +167,7 @@ CheckForLuckyNumberWinners: .okay inc b - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jr z, .bettermatch cp b @@ -176,7 +176,7 @@ CheckForLuckyNumberWinners: .bettermatch dec b ld a, b - ld [wScriptVar], a + ldh [hScriptVar], a pop bc ld a, b ld [wCurPartySpecies], a diff --git a/engine/events/magikarp.asm b/engine/events/magikarp.asm index 03b8b00cc..b2bc2d400 100644 --- a/engine/events/magikarp.asm +++ b/engine/events/magikarp.asm @@ -52,22 +52,22 @@ CheckMagikarpLength: call SkipNames call CopyBytes ld a, MAGIKARPLENGTH_BEAT_RECORD - ld [wScriptVar], a + ldh [hScriptVar], a ret .not_long_enough ld a, MAGIKARPLENGTH_TOO_SHORT - ld [wScriptVar], a + ldh [hScriptVar], a ret .declined ld a, MAGIKARPLENGTH_REFUSED - ld [wScriptVar], a + ldh [hScriptVar], a ret .not_magikarp xor a ; MAGIKARPLENGTH_NOT_MAGIKARP - ld [wScriptVar], a + ldh [hScriptVar], a ret .MagikarpGuruMeasureText: diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm index 9a4013006..c184dc9ff 100644 --- a/engine/events/magnet_train.asm +++ b/engine/events/magnet_train.asm @@ -1,5 +1,5 @@ MagnetTrain: - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jr nz, .ToGoldenrod ld a, 1 ; forwards diff --git a/engine/events/misc_scripts.asm b/engine/events/misc_scripts.asm index 24e4088e3..1565f271e 100644 --- a/engine/events/misc_scripts.asm +++ b/engine/events/misc_scripts.asm @@ -37,7 +37,7 @@ FindItemInBallScript:: .TryReceiveItem: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ld a, [wItemBallItemID] ld [wNamedObjectIndex], a call GetItemName @@ -51,5 +51,5 @@ FindItemInBallScript:: call ReceiveItem ret nc ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret diff --git a/engine/events/move_tutor.asm b/engine/events/move_tutor.asm index 89fe671e7..554abfd99 100644 --- a/engine/events/move_tutor.asm +++ b/engine/events/move_tutor.asm @@ -23,18 +23,18 @@ MoveTutor: call CheckCanLearnMoveTutorMove jr nc, .loop xor a ; FALSE - ld [wScriptVar], a + ldh [hScriptVar], a jr .quit .cancel ld a, -1 - ld [wScriptVar], a + ldh [hScriptVar], a .quit call CloseSubmenu ret .GetMoveTutorMove: - ld a, [wScriptVar] + ldh a, [hScriptVar] cp MOVETUTOR_FLAMETHROWER jr z, .flamethrower cp MOVETUTOR_THUNDERBOLT diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index 3f537aae8..93f6f36ca 100644 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -678,12 +678,12 @@ Script_UsedWaterfall: .CheckContinueWaterfall: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ld a, [wPlayerTile] call CheckWaterfallTile ret z ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .WaterfallStep: @@ -1070,7 +1070,7 @@ TryStrengthOW: jr .done .done - ld [wScriptVar], a + ldh [hScriptVar], a ret WhirlpoolFunction: @@ -1409,7 +1409,7 @@ HasRockSmash: xor a jr .done .done - ld [wScriptVar], a + ldh [hScriptVar], a ret FishFunction: @@ -1570,7 +1570,7 @@ Fishing_CheckFacingUp: xor a .up - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_FishCastRod: @@ -1776,11 +1776,11 @@ AskCutScript: .CheckMap: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call CheckMapForSomethingToCut ret c ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret AskCutText: diff --git a/engine/events/play_slow_cry.asm b/engine/events/play_slow_cry.asm index 6839b3960..7e4a704f2 100644 --- a/engine/events/play_slow_cry.asm +++ b/engine/events/play_slow_cry.asm @@ -1,5 +1,5 @@ PlaySlowCry: - ld a, [wScriptVar] + ldh a, [hScriptVar] call LoadCry jr c, .done diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm index 2ba59b5c1..ab2348bfb 100644 --- a/engine/events/poisonstep.asm +++ b/engine/events/poisonstep.asm @@ -142,7 +142,7 @@ DoPoisonStep:: jr nz, .party_loop predef CheckPlayerPartyForFitMon ld a, d - ld [wScriptVar], a + ldh [hScriptVar], a ret .PoisonFaintText: diff --git a/engine/events/shuckle.asm b/engine/events/shuckle.asm index 9b98c1dae..c1bbca3c4 100644 --- a/engine/events/shuckle.asm +++ b/engine/events/shuckle.asm @@ -57,12 +57,12 @@ GiveShuckle: ld hl, wDailyFlags1 set DAILYFLAGS1_GOT_SHUCKIE_TODAY_F, [hl] ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .NotGiven: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret SpecialShuckleOT: @@ -123,20 +123,20 @@ ReturnShuckie: callfar RemoveMonFromPartyOrBox ld a, SHUCKIE_RETURNED .HappyToStayWithYou: - ld [wScriptVar], a + ldh [hScriptVar], a ret .refused ld a, SHUCKIE_REFUSED - ld [wScriptVar], a + ldh [hScriptVar], a ret .DontReturn: xor a ; SHUCKIE_WRONG_MON - ld [wScriptVar], a + ldh [hScriptVar], a ret .fainted ld a, SHUCKIE_FAINTED - ld [wScriptVar], a + ldh [hScriptVar], a ret diff --git a/engine/events/specials.asm b/engine/events/specials.asm index 12e55befd..462cc21c8 100644 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -16,55 +16,55 @@ Special:: INCLUDE "data/events/special_pointers.asm" SetPlayerPalette: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld d, a farcall _SetPlayerPalette ret GameCornerPrizeMonCheckDex: - ld a, [wScriptVar] + ldh a, [hScriptVar] dec a call CheckCaughtMon ret nz - ld a, [wScriptVar] + ldh a, [hScriptVar] dec a call SetSeenAndCaughtMon call FadeToMenu - ld a, [wScriptVar] + ldh a, [hScriptVar] ld [wNamedObjectIndex], a farcall NewPokedexEntry call ExitAllMenus ret UnusedSetSeenMon: - ld a, [wScriptVar] + ldh a, [hScriptVar] dec a call SetSeenMon ret FindPartyMonAboveLevel: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, a farcall _FindPartyMonAboveLevel jr z, FoundNone jr FoundOne FindPartyMonAtLeastThatHappy: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, a farcall _FindPartyMonAtLeastThatHappy jr z, FoundNone jr FoundOne FindPartyMonThatSpecies: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, a farcall _FindPartyMonThatSpecies jr z, FoundNone jr FoundOne FindPartyMonThatSpeciesYourTrainerID: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, a farcall _FindPartyMonThatSpeciesYourTrainerID jr z, FoundNone @@ -72,12 +72,12 @@ FindPartyMonThatSpeciesYourTrainerID: FoundOne: ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret FoundNone: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret NameRival: @@ -116,20 +116,20 @@ DisplayLinkRecord: PlayersHousePC: xor a - ld [wScriptVar], a + ldh [hScriptVar], a farcall _PlayersHousePC ld a, c - ld [wScriptVar], a + ldh [hScriptVar], a ret BugContestJudging: farcall _BugContestJudging ld a, b - ld [wScriptVar], a + ldh [hScriptVar], a ret MapRadio: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld e, a farcall PlayRadio ret @@ -138,7 +138,7 @@ UnownPuzzle: call FadeToMenu farcall _UnownPuzzle ld a, [wSolvedUnownPuzzle] - ld [wScriptVar], a + ldh [hScriptVar], a call ExitAllMenus ret @@ -221,15 +221,15 @@ ClearBGPalettesBufferScreen: ScriptReturnCarry: jr c, .carry xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .carry ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret ActivateFishingSwarm: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld [wFishingSwarmFlag], a ret @@ -272,7 +272,7 @@ SnorlaxAwake: ; next to Snorlax. ; outputs: -; wScriptVar is 1 if the conditions are met, otherwise 0. +; hScriptVar is 1 if the conditions are met, otherwise 0. ; check background music ld a, [wMapMusic] @@ -305,7 +305,7 @@ SnorlaxAwake: .nope xor a .done - ld [wScriptVar], a + ldh [hScriptVar], a ret .ProximityCoords: @@ -339,7 +339,7 @@ GameboyCheck: .cgb ld a, GBCHECK_CGB .done - ld [wScriptVar], a + ldh [hScriptVar], a ret FadeOutMusic: diff --git a/engine/events/sweet_scent.asm b/engine/events/sweet_scent.asm index 05a6afc3e..00db91440 100644 --- a/engine/events/sweet_scent.asm +++ b/engine/events/sweet_scent.asm @@ -48,12 +48,12 @@ SweetScentEncounter: .start_battle ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .no_battle xor a - ld [wScriptVar], a + ldh [hScriptVar], a ld [wBattleType], a ret diff --git a/engine/events/treemons.asm b/engine/events/treemons.asm index f0184816b..34ff84619 100644 --- a/engine/events/treemons.asm +++ b/engine/events/treemons.asm @@ -16,12 +16,12 @@ TreeMonEncounter: ld a, BATTLETYPE_TREE ld [wBattleType], a ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .no_battle xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret RockMonEncounter: diff --git a/engine/events/unown_walls.asm b/engine/events/unown_walls.asm index 1958cd8ed..851e08aca 100644 --- a/engine/events/unown_walls.asm +++ b/engine/events/unown_walls.asm @@ -77,7 +77,7 @@ SpecialKabutoChamber: ret DisplayUnownWords: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld hl, MenuHeaders_UnownWalls and a jr z, .load @@ -102,7 +102,7 @@ DisplayUnownWords: ld e, SCREEN_WIDTH add hl, de add hl, de - ld a, [wScriptVar] + ldh a, [hScriptVar] ld c, a ld de, UnownWalls and a diff --git a/engine/games/slot_machine.asm b/engine/games/slot_machine.asm index e8adb20e1..6d9179329 100644 --- a/engine/games/slot_machine.asm +++ b/engine/games/slot_machine.asm @@ -211,7 +211,7 @@ SlotsLoop: ret .matching_sevens - ld a, [wTextDelayFrames] + ldh a, [hTextDelayFrames] and $7 ret nz ldh a, [rBGP] @@ -1638,7 +1638,7 @@ Slots_InitBias: and a ret z ld hl, .Normal - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jr z, .okay ld hl, .Lucky diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm index 19d257cec..a6223c921 100644 --- a/engine/games/unown_puzzle.asm +++ b/engine/games/unown_puzzle.asm @@ -794,7 +794,7 @@ PuzzlePieceBorderData: INCBIN "gfx/unown_puzzle/tile_borders.2bpp" LoadUnownPuzzlePiecesGFX: - ld a, [wScriptVar] + ldh a, [hScriptVar] maskbits NUM_UNOWN_PUZZLES ld e, a ld d, 0 diff --git a/engine/link/link.asm b/engine/link/link.asm index b82e3d03d..3e74c8e9a 100644 --- a/engine/link/link.asm +++ b/engine/link/link.asm @@ -206,7 +206,7 @@ Gen2ToGen2LinkComms: call Link_PrepPartyData_Gen2 call FixDataForLinkTransfer call CheckLinkTimeout_Gen2 - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jp z, LinkTimeout ldh a, [hSerialConnectionStatus] @@ -1574,8 +1574,6 @@ ExitLinkCommunications: call GetCGBLayout call WaitBGMap2 xor a - ld [wUnusedLinkCommunicationByte], a - xor a ldh [rSB], a ldh [hSerialSend], a ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) @@ -2041,7 +2039,7 @@ INCLUDE "engine/movie/trade_animation.asm" CheckTimeCapsuleCompatibility: ; Checks to see if your party is compatible with the Gen 1 games. -; Returns the following in wScriptVar: +; Returns the following in hScriptVar: ; 0: Party is okay ; 1: At least one Pokémon was introduced in Gen 2 ; 2: At least one Pokémon has a move that was introduced in Gen 2 @@ -2117,7 +2115,7 @@ CheckTimeCapsuleCompatibility: ld a, $3 .done - ld [wScriptVar], a + ldh [hScriptVar], a ret GetIncompatibleMonName: @@ -2299,12 +2297,12 @@ WaitForLinkedFriend: ld c, 50 call DelayFrames ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .done xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret CheckLinkTimeout_Receptionist: @@ -2323,13 +2321,13 @@ CheckLinkTimeout_Receptionist: call Link_CheckCommunicationError xor a ldh [hVBlank], a - ld a, [wScriptVar] + ldh a, [hScriptVar] and a ret nz jp Link_ResetSerialRegistersAfterLinkClosure CheckLinkTimeout_Gen2: -; if wScriptVar = 0 on exit, link connection is closed +; if hScriptVar = 0 on exit, link connection is closed ld a, $5 ld [wPlayerLinkAction], a ld hl, wLinkTimeoutFrames @@ -2343,7 +2341,7 @@ CheckLinkTimeout_Gen2: call DelayFrame call DelayFrame call Link_CheckCommunicationError - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jr z, .exit @@ -2380,7 +2378,7 @@ endc .timeout xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .exit @@ -2412,7 +2410,7 @@ Link_CheckCommunicationError: ld a, TRUE .done - ld [wScriptVar], a + ldh [hScriptVar], a ld hl, wLinkTimeoutFrames xor a ld [hli], a @@ -2470,7 +2468,7 @@ TryQuickSave: vc_hook Wireless_TryQuickSave_block_input_2 xor a ; FALSE .return_result - ld [wScriptVar], a + ldh [hScriptVar], a ld c, 30 call DelayFrames pop af @@ -2495,12 +2493,12 @@ CheckBothSelectedSameRoom: xor a ldh [hVBlank], a ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret .fail xor a ; FALSE - ld [wScriptVar], a + ldh [hScriptVar], a ret TimeCapsule: @@ -2598,7 +2596,7 @@ CableClubCheckWhichChris: dec a ; FALSE .yes - ld [wScriptVar], a + ldh [hScriptVar], a ret GSLinkCommsBorderGFX: ; unreferenced diff --git a/engine/menus/start_menu.asm b/engine/menus/start_menu.asm index 33ad45955..d6c2b1173 100644 --- a/engine/menus/start_menu.asm +++ b/engine/menus/start_menu.asm @@ -122,14 +122,14 @@ StartMenu:: .ExitMenuRunScript: call ExitMenu - ld a, HMENURETURN_SCRIPT - ldh [hMenuReturn], a + ld a, MENURETURN_SCRIPT + ld [wMenuReturn], a ret .ExitMenuRunScriptCloseText: call ExitMenu - ld a, HMENURETURN_SCRIPT - ldh [hMenuReturn], a + ld a, MENURETURN_SCRIPT + ld [wMenuReturn], a jr .ReturnEnd2 .ExitMenuCallFuncCloseText: diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 3e6fd25b3..42e917702 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -100,7 +100,7 @@ CheckWildEncountersScriptFlag: StartMap: xor a - ld [wScriptVar], a + ldh [hScriptVar], a xor a ld [wScriptRunning], a ld hl, wMapStatus @@ -179,11 +179,11 @@ MaxOverworldDelay: ResetOverworldDelay: ld a, [MaxOverworldDelay] - ld [wOverworldDelay], a + ldh [hOverworldDelay], a ret NextOverworldFrame: - ld a, [wOverworldDelay] + ldh a, [hOverworldDelay] and a ret z ld c, a @@ -806,7 +806,7 @@ PlayerMovementPointers: CheckMenuOW: xor a - ldh [hMenuReturn], a + ld [wMenuReturn], a ldh a, [hJoyPressed] bit SELECT_F, a @@ -843,9 +843,9 @@ SelectMenuScript: StartMenuCallback: SelectMenuCallback: - readmem hMenuReturn - ifequal HMENURETURN_SCRIPT, .Script - ifequal HMENURETURN_ASM, .Asm + readmem wMenuReturn + ifequal MENURETURN_SCRIPT, .Script + ifequal MENURETURN_ASM, .Asm end .Script: diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index 65c802ab9..c914cd33b 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -389,7 +389,7 @@ Script_yesorno: jr c, .no ld a, TRUE .no - ld [wScriptVar], a + ldh [hScriptVar], a vc_hook Unknown_yesorno_ret ret @@ -413,7 +413,7 @@ Script_pokepic: call GetScriptByte and a jr nz, .ok - ld a, [wScriptVar] + ldh a, [hScriptVar] .ok ld [wCurPartySpecies], a farcall Pokepic @@ -431,7 +431,7 @@ Script_verticalmenu: jr nc, .ok xor a .ok - ld [wScriptVar], a + ldh [hScriptVar], a ret Script__2dmenu: @@ -442,7 +442,7 @@ Script__2dmenu: jr nc, .ok xor a .ok - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_battletowertext: @@ -490,7 +490,7 @@ Script_verbosegiveitemvar: call GetScriptByte cp ITEM_FROM_MEM jr nz, .ok - ld a, [wScriptVar] + ldh a, [hScriptVar] .ok ld [wCurItem], a call GetScriptByte @@ -503,7 +503,7 @@ Script_verbosegiveitemvar: jr c, .ok2 xor a .ok2 - ld [wScriptVar], a + ldh [hScriptVar], a call CurItemName ld de, wStringBuffer1 ld a, STRING_BUFFER_4 @@ -587,7 +587,7 @@ Script_pokemart: Script_elevator: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld e, a call GetScriptByte @@ -597,7 +597,7 @@ Script_elevator: farcall Elevator ret c ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_trade: @@ -636,7 +636,7 @@ Script_askforphonenumber: call GetScriptByte ld a, PHONE_CONTACT_REFUSED .done - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_describedecoration: @@ -690,7 +690,7 @@ Script_scripttalkafter: Script_trainerflagaction: xor a - ld [wScriptVar], a + ldh [hScriptVar], a ld hl, wTempTrainerEventFlag ld e, [hl] inc hl @@ -702,7 +702,7 @@ Script_trainerflagaction: and a ret z ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_winlosstext: @@ -726,12 +726,12 @@ Script_endifjustbattled: Script_checkjustbattled: ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ld a, [wRunningTrainerBattleScript] and a ret nz xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_encountermusic: @@ -791,7 +791,7 @@ Script_cry: pop af and a jr nz, .ok - ld a, [wScriptVar] + ldh a, [hScriptVar] .ok call PlayMonCry ret @@ -1059,7 +1059,7 @@ Script_loademote: call GetScriptByte cp EMOTE_FROM_MEM jr nz, .not_var_emote - ld a, [wScriptVar] + ldh a, [hScriptVar] .not_var_emote ld c, a farcall LoadEmote @@ -1067,7 +1067,7 @@ Script_loademote: Script_showemote: call GetScriptByte - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte call GetScriptObject cp LAST_TALKED @@ -1165,7 +1165,7 @@ Script_startbattle: predef StartBattle ld a, [wBattleResult] and ~BATTLERESULT_BITMASK - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_catchtutorial: @@ -1308,33 +1308,33 @@ Script_memjump: jp ScriptJump Script_iffalse: - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jp nz, SkipTwoScriptBytes jp Script_sjump Script_iftrue: - ld a, [wScriptVar] + ldh a, [hScriptVar] and a jp nz, Script_sjump jp SkipTwoScriptBytes Script_ifequal: call GetScriptByte - ld hl, wScriptVar + ld hl, hScriptVar cp [hl] jr z, Script_sjump jr SkipTwoScriptBytes Script_ifnotequal: call GetScriptByte - ld hl, wScriptVar + ld hl, hScriptVar cp [hl] jr nz, Script_sjump jr SkipTwoScriptBytes Script_ifgreater: - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, a call GetScriptByte cp b @@ -1344,7 +1344,7 @@ Script_ifgreater: Script_ifless: call GetScriptByte ld b, a - ld a, [wScriptVar] + ldh a, [hScriptVar] cp b jr c, Script_sjump jr SkipTwoScriptBytes @@ -1404,12 +1404,12 @@ Script_sdefer: Script_checkscene: call CheckScenes jr z, .no_scene - ld [wScriptVar], a + ldh [hScriptVar], a ret .no_scene ld a, $ff - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_checkmapscene: @@ -1422,12 +1422,12 @@ Script_checkmapscene: or e jr z, .no_scene ld a, [de] - ld [wScriptVar], a + ldh [hScriptVar], a ret .no_scene ld a, $ff - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_setscene: @@ -1458,7 +1458,7 @@ Script_readmem: call GetScriptByte ld h, a ld a, [hl] - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_writemem: @@ -1466,7 +1466,7 @@ Script_writemem: ld l, a call GetScriptByte ld h, a - ld a, [wScriptVar] + ldh a, [hScriptVar] ld [hl], a ret @@ -1481,19 +1481,19 @@ Script_loadmem: Script_setval: call GetScriptByte - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_addval: call GetScriptByte - ld hl, wScriptVar + ld hl, hScriptVar add [hl] ld [hl], a ret Script_random: call GetScriptByte - ld [wScriptVar], a + ldh [hScriptVar], a and a ret z @@ -1522,11 +1522,11 @@ Script_random: .finish push af - ld a, [wScriptVar] + ldh a, [hScriptVar] ld c, a pop af call SimpleDivide - ld [wScriptVar], a + ldh [hScriptVar], a ret .Divide256byC: @@ -1545,13 +1545,13 @@ Script_readvar: call GetScriptByte call GetVarAction ld a, [de] - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_writevar: call GetScriptByte call GetVarAction - ld a, [wScriptVar] + ldh a, [hScriptVar] ld [de], a ret @@ -1569,7 +1569,7 @@ GetVarAction: Script_checkver: ld a, [.gs_version] - ld [wScriptVar], a + ldh [hScriptVar], a ret .gs_version: @@ -1579,7 +1579,7 @@ Script_getmonname: call GetScriptByte and a jr nz, .gotit - ld a, [wScriptVar] + ldh a, [hScriptVar] .gotit ld [wNamedObjectIndex], a call GetPokemonName @@ -1603,7 +1603,7 @@ Script_getitemname: call GetScriptByte and a ; USE_SCRIPT_VAR jr nz, .ok - ld a, [wScriptVar] + ldh a, [hScriptVar] .ok ld [wNamedObjectIndex], a call GetItemName @@ -1671,7 +1671,7 @@ Script_getchips: Script_getnum: call ResetStringBuffer1 - ld de, wScriptVar + ld de, hScriptVar ld hl, wStringBuffer1 lb bc, PRINTNUM_LEFTALIGN | 1, 3 call PrintNum @@ -1728,7 +1728,7 @@ Script_giveitem: call GetScriptByte cp ITEM_FROM_MEM jr nz, .ok - ld a, [wScriptVar] + ldh a, [hScriptVar] .ok ld [wCurItem], a call GetScriptByte @@ -1737,16 +1737,16 @@ Script_giveitem: call ReceiveItem jr nc, .full ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret .full xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_takeitem: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld [wCurItem], a call GetScriptByte @@ -1757,19 +1757,19 @@ Script_takeitem: call TossItem ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_checkitem: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld [wCurItem], a ld hl, wNumItems call CheckItem ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_givecoins: @@ -1800,7 +1800,7 @@ CompareCoinsAction: .less ld a, HAVE_LESS .done - ld [wScriptVar], a + ldh [hScriptVar], a ret GetCoinsAccount: @@ -1850,60 +1850,60 @@ LoadChipAmountToMem: Script_checktime: xor a - ld [wScriptVar], a + ldh [hScriptVar], a farcall CheckTime call GetScriptByte and c ret z ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_checkpoke: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld hl, wPartySpecies ld de, 1 call IsInArray ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_addcellnum: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld c, a farcall AddPhoneNumber ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_delcellnum: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld c, a farcall DelCellNum ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_checkcellnum: ; returns false if the cell number is not in your phone xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld c, a farcall CheckCellNum ret nc ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_specialphonecall: @@ -1921,7 +1921,7 @@ Script_checkphonecall: jr z, .ok ld a, TRUE .ok - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_givepoke: @@ -1946,14 +1946,14 @@ Script_givepoke: .ok farcall GivePoke ld a, b - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_giveegg: -; if no room in the party, return 0 in wScriptVar; else, return 2 +; if no room in the party, return 0 in hScriptVar; else, return 2 xor a ; PARTYMON - ld [wScriptVar], a + ldh [hScriptVar], a ld [wMonType], a call GetScriptByte ld [wCurPartySpecies], a @@ -1962,7 +1962,7 @@ Script_giveegg: farcall GiveEgg ret nc ld a, 2 - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_setevent: @@ -1995,7 +1995,7 @@ Script_checkevent: jr z, .false ld a, TRUE .false - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_setflag: @@ -2028,7 +2028,7 @@ Script_checkflag: jr z, .false ld a, TRUE .false - ld [wScriptVar], a + ldh [hScriptVar], a ret _EngineFlagAction: @@ -2129,13 +2129,13 @@ Script_writecmdqueue: Script_delcmdqueue: xor a - ld [wScriptVar], a + ldh [hScriptVar], a call GetScriptByte ld b, a farcall DelCmdQueue ; no need to farcall ret c ld a, TRUE - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_changemapblocks: @@ -2354,12 +2354,12 @@ Script_wait: Script_checksave: farcall CheckSave ld a, c - ld [wScriptVar], a + ldh [hScriptVar], a ret Script_checkver_duplicate: ; unreferenced ld a, [.gs_version] - ld [wScriptVar], a + ldh [hScriptVar], a ret .gs_version: diff --git a/engine/overworld/select_menu.asm b/engine/overworld/select_menu.asm index 4b678fd07..370cd721d 100644 --- a/engine/overworld/select_menu.asm +++ b/engine/overworld/select_menu.asm @@ -158,8 +158,8 @@ UseRegisteredItem: cp 1 jr nz, ._cantuse scf - ld a, HMENURETURN_SCRIPT - ldh [hMenuReturn], a + ld a, MENURETURN_SCRIPT + ld [wMenuReturn], a ret .CantUse: diff --git a/engine/overworld/wildmons.asm b/engine/overworld/wildmons.asm index d258d96ea..5c1985982 100644 --- a/engine/overworld/wildmons.asm +++ b/engine/overworld/wildmons.asm @@ -818,12 +818,12 @@ RandomUnseenWildMon: ld hl, .JustSawSomeRareMonText call PrintText2bpp xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .done ld a, $1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .JustSawSomeRareMonText: diff --git a/engine/pokemon/caught_data.asm b/engine/pokemon/caught_data.asm index 3ac0fcd61..58c5ae813 100644 --- a/engine/pokemon/caught_data.asm +++ b/engine/pokemon/caught_data.asm @@ -80,7 +80,7 @@ CheckPartyFullAfterContest: xor a ld [wContestMonSpecies], a and a ; BUGCONTEST_CAUGHT_MON - ld [wScriptVar], a + ldh [hScriptVar], a ret .TryAddToBox: @@ -139,12 +139,12 @@ CheckPartyFullAfterContest: xor a ld [wContestMon], a ld a, BUGCONTEST_BOXED_MON - ld [wScriptVar], a + ldh [hScriptVar], a ret .DidntCatchAnything: ld a, BUGCONTEST_NO_CATCH - ld [wScriptVar], a + ldh [hScriptVar], a ret GiveANickname_YesNo: diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm index eef206a57..de78abe92 100644 --- a/engine/pokemon/mail.asm +++ b/engine/pokemon/mail.asm @@ -185,7 +185,7 @@ CheckPokeMail:: pop bc .return - ld [wScriptVar], a + ldh [hScriptVar], a ret GivePokeMail:: diff --git a/engine/pokemon/search_owned.asm b/engine/pokemon/search_owned.asm index 2edb987eb..ce65ad6ad 100644 --- a/engine/pokemon/search_owned.asm +++ b/engine/pokemon/search_owned.asm @@ -1,52 +1,52 @@ BeastsCheck: ; Check if the player owns all three legendary beasts. ; They must exist in either party or PC, and have the player's OT and ID. -; Return the result in wScriptVar. +; Return the result in hScriptVar. ld a, RAIKOU - ld [wScriptVar], a + ldh [hScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ld a, ENTEI - ld [wScriptVar], a + ldh [hScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ld a, SUICUNE - ld [wScriptVar], a + ldh [hScriptVar], a call CheckOwnMonAnywhere jr nc, .notexist ; they exist ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret .notexist xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret MonCheck: -; Check if the player owns any Pokémon of the species in wScriptVar. -; Return the result in wScriptVar. +; Check if the player owns any Pokémon of the species in hScriptVar. +; Return the result in hScriptVar. call CheckOwnMonAnywhere jr c, .exists ; doesn't exist xor a - ld [wScriptVar], a + ldh [hScriptVar], a ret .exists ld a, 1 - ld [wScriptVar], a + ldh [hScriptVar], a ret CheckOwnMonAnywhere: -; Check if the player owns any monsters of the species in wScriptVar. +; Check if the player owns any monsters of the species in hScriptVar. ; It must exist in either party or PC, and have the player's OT and ID. ; If there are no monsters in the party, @@ -182,13 +182,13 @@ CheckOwnMonAnywhere: CheckOwnMon: ; Check if a Pokémon belongs to the player and is of a specific species. -; We compare the species we are looking for in [wScriptVar] to the species +; We compare the species we are looking for in [hScriptVar] to the species ; we have in [hl]. ; inputs: ; hl, pointer to PartyMonNSpecies ; bc, pointer to PartyMonNOT -; wScriptVar should contain the species we're looking for +; hScriptVar should contain the species we're looking for ; outputs: ; sets carry if monster matches species, ID, and OT name. @@ -201,7 +201,7 @@ CheckOwnMon: ; check species - ld a, [wScriptVar] + ldh a, [hScriptVar] ld b, [hl] cp b jr nz, .notfound diff --git a/home/delay.asm b/home/delay.asm index ebdcccb11..b9d263a37 100644 --- a/home/delay.asm +++ b/home/delay.asm @@ -1,13 +1,13 @@ DelayFrame:: ; Wait for one frame ld a, 1 - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ; Wait for the next VBlank, halting to conserve battery .halt halt nop - ld a, [wVBlankOccurred] + ldh a, [hVBlankOccurred] and a jr nz, .halt ret diff --git a/home/joypad.asm b/home/joypad.asm index 6a656e31b..a095c856b 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -295,11 +295,11 @@ JoyTextDelay:: and a jr z, .checkframedelay ld a, 15 - ld [wTextDelayFrames], a + ldh [hTextDelayFrames], a ret .checkframedelay - ld a, [wTextDelayFrames] + ldh a, [hTextDelayFrames] and a jr z, .restartframedelay xor a @@ -308,7 +308,7 @@ JoyTextDelay:: .restartframedelay ld a, 5 - ld [wTextDelayFrames], a + ldh [hTextDelayFrames], a ret WaitPressAorB_BlinkCursor:: diff --git a/home/print_text.asm b/home/print_text.asm index a654e20a9..007413d03 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -44,7 +44,7 @@ PrintLetterDelay:: ld a, TEXT_DELAY_FAST .updatedelay - ld [wTextDelayFrames], a + ldh [hTextDelayFrames], a .checkjoypad call GetJoypad @@ -68,7 +68,7 @@ PrintLetterDelay:: jr .end .wait - ld a, [wTextDelayFrames] + ldh a, [hTextDelayFrames] and a jr nz, .checkjoypad diff --git a/home/vblank.asm b/home/vblank.asm index 3737c4317..deac90453 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -115,7 +115,7 @@ VBlank0:: ; vblank-sensitive operations are done xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ; if hWindowHUDLY is active, enable interrupts so the LCD interrupt can trigger ldh a, [hWindowHUDLY] @@ -141,18 +141,18 @@ VBlank0:: sbc b ldh [hRandomSub], a - ld a, [wOverworldDelay] + ldh a, [hOverworldDelay] and a jr z, .ok dec a - ld [wOverworldDelay], a + ldh [hOverworldDelay], a .ok - ld a, [wTextDelayFrames] + ldh a, [hTextDelayFrames] and a jr z, .ok2 dec a - ld [wTextDelayFrames], a + ldh [hTextDelayFrames], a .ok2 call UpdateJoypad @@ -199,7 +199,7 @@ VBlank2:: rst Bankswitch xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ret VBlank1:: @@ -228,7 +228,7 @@ VBlank1:: .done xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ; get requested ints ldh a, [rIF] @@ -296,7 +296,7 @@ VBlank3:: .done xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ldh a, [rIF] push af @@ -351,7 +351,7 @@ VBlank4:: call UpdateJoypad xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a call AskSerial @@ -385,7 +385,7 @@ VBlank5:: .done xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a call UpdateJoypad @@ -433,7 +433,7 @@ VBlank6:: .done xor a - ld [wVBlankOccurred], a + ldh [hVBlankOccurred], a ld a, BANK(_UpdateSound) rst Bankswitch diff --git a/ram/hram.asm b/ram/hram.asm index 57710930b..9a0a37b58 100644 --- a/ram/hram.asm +++ b/ram/hram.asm @@ -7,12 +7,14 @@ hSRAMBank:: db hVBlankCounter:: db +hOverworldDelay:: db +hTextDelayFrames:: db +hVBlankOccurred:: db + hROMBank:: db hVBlank:: db hMapEntryMethod:: db -hMenuReturn:: db - hJoypadReleased:: db hJoypadPressed:: db hJoypadDown:: db @@ -127,6 +129,8 @@ hBGMapTileCount:: db hMapAnims:: db hTileAnimFrame:: db +hScriptVar:: db + hLastTalked:: db hRandomAdd:: db diff --git a/ram/wram.asm b/ram/wram.asm index b58b2c4e3..50a012319 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -140,8 +140,6 @@ wLinkMode:: ; a LINK_* value for the link type db -wScriptVar:: db - wPlayerNextMovement:: db wPlayerMovement:: db @@ -1195,17 +1193,13 @@ wCursorCurrentTile:: dw ds 3 wMoreMenuDataEnd:: -wOverworldDelay:: db -wTextDelayFrames:: db -wVBlankOccurred:: db +wMenuReturn:: db wPredefID:: db wPredefHL:: dw wPredefAddress:: dw wFarCallBC:: dw -wUnusedLinkCommunicationByte:: db - wGameTimerPaused:: ; bit 0: game timer paused ; bit 7: something mobile