Optimize some HRAM usage

This commit is contained in:
xCrystal 2023-09-30 19:12:57 +02:00
parent 336b3e77af
commit e53ae0eac9
48 changed files with 254 additions and 258 deletions

View File

@ -72,8 +72,8 @@ DEF MONMENU_MENUOPTION EQU 1
DEF NUM_MONMENU_ITEMS EQU 8 DEF NUM_MONMENU_ITEMS EQU 8
; start/select menu return values ; start/select menu return values
DEF HMENURETURN_SCRIPT EQU %10000000 DEF MENURETURN_SCRIPT EQU %10000000
DEF HMENURETURN_ASM EQU %11111111 DEF MENURETURN_ASM EQU %11111111
; PartyMenuQualityPointers indexes (see data/party_menu_qualities.asm) ; PartyMenuQualityPointers indexes (see data/party_menu_qualities.asm)
const_def const_def

View File

@ -1,5 +1,5 @@
; Special routines can be used with the "special" map script command. ; 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 MACRO add_special
\1Special:: \1Special::

View File

@ -2304,7 +2304,7 @@ This is a bug with `HaircutOrGrooming` in [engine/events/haircut.asm](https://gi
.ok .ok
inc hl inc hl
ld a, [hli] ld a, [hli]
ld [wScriptVar], a ldh [hScriptVar], a
ld c, [hl] ld c, [hl]
call ChangeHappiness call ChangeHappiness
ret ret

View File

@ -102,7 +102,7 @@ $~~~~$*Exit overworld loop*
--- ---
wMapStatus == MAPSTATUS_HANDLE: <c>the remainder of the code goes at this level</c> wMapStatus == MAPSTATUS_HANDLE: <c>the remainder of the code goes at this level</c>
> wOverworldDelay <= 2 <c>2 is *MaxOverworldDelay*</c>\ > hOverworldDelay <= 2 <c>2 is *MaxOverworldDelay*</c>\
> MapEventStatus == MAPEVENTS_ON:\ > MapEventStatus == MAPEVENTS_ON:\
>$~~~~$*Get joypad* <c>update hJoyDown, hJoyReleased, hJoyPressed</c>\ >$~~~~$*Get joypad* <c>update hJoyDown, hJoyReleased, hJoyPressed</c>\
>$~~~~$*Refresh pals* >$~~~~$*Refresh pals*
@ -295,7 +295,7 @@ wMapStatus == MAPSTATUS_HANDLE: <c>the remainder of the code goes at this level<
>> **CheckObjectEnteringVisibleRange** (wPlayerStepFlags[PLAYERSTEP_STOP_F] == TRUE) >> **CheckObjectEnteringVisibleRange** (wPlayerStepFlags[PLAYERSTEP_STOP_F] == TRUE)
> DelayFrames(wOverworldDelay) > DelayFrames(hOverworldDelay)
> <f>**HandleMapBackground**</f> <c>_UpdateSprites + ScrollScreen</c> > <f>**HandleMapBackground**</f> <c>_UpdateSprites + ScrollScreen</c>

View File

@ -70,12 +70,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii
## `$15`: <code>setval <i>value</i></code> ## `$15`: <code>setval <i>value</i></code>
<code>[wScriptVar] = <i>value</i></code> <code>[hScriptVar] = <i>value</i></code>
## `$16`: <code>addval <i>value</i></code> ## `$16`: <code>addval <i>value</i></code>
<code>[wScriptVar] += <i>value</i></code> <code>[hScriptVar] += <i>value</i></code>
## `$17`: <code>random <i>value</i></code> ## `$17`: <code>random <i>value</i></code>
@ -86,12 +86,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii
## `$19`: <code>readmem <i>address</i></code> ## `$19`: <code>readmem <i>address</i></code>
<code>[wScriptVar] = [<i>address</i>]</code> <code>[hScriptVar] = [<i>address</i>]</code>
## `$1A`: <code>writemem <i>address</i></code> ## `$1A`: <code>writemem <i>address</i></code>
<code>[<i>address</i>] = [wScriptVar]</code> <code>[<i>address</i>] = [hScriptVar]</code>
## `$1B`: <code>loadmem <i>address</i>, <i>value</i></code> ## `$1B`: <code>loadmem <i>address</i>, <i>value</i></code>
@ -101,12 +101,12 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii
## `$1C`: <code>readvar <i>variable</i></code> ## `$1C`: <code>readvar <i>variable</i></code>
<code>[wScriptVar] = GetVarAction(<i>variable</i>)</code> <code>[hScriptVar] = GetVarAction(<i>variable</i>)</code>
## `$1D`: <code>writevar <i>variable</i></code> ## `$1D`: <code>writevar <i>variable</i></code>
<code>GetVarAction(<i>variable</i>) = [wScriptVar]</code> <code>GetVarAction(<i>variable</i>) = [hScriptVar]</code>
## `$1E`: <code>loadvar <i>variable</i>, <i>value</i></code> ## `$1E`: <code>loadvar <i>variable</i>, <i>value</i></code>
@ -216,21 +216,21 @@ Until this document is filled out, the [G/S Scripting Compendium](https://hax.ii
## `$3F`: <code>getnum <i>string_buffer</i></code> ## `$3F`: <code>getnum <i>string_buffer</i></code>
<code>GetStringBuffer(<i>string_buffer</i>) = PrintNum([wScriptVar])</code> <code>GetStringBuffer(<i>string_buffer</i>) = PrintNum([hScriptVar])</code>
## `$40`: <code>getmonname <i>string_buffer</i>, <i>mon_id</i></code> ## `$40`: <code>getmonname <i>string_buffer</i>, <i>mon_id</i></code>
<code>GetStringBuffer(<i>string_buffer</i>) = GetPokemonName(<i>mon_id</i>)</code> <code>GetStringBuffer(<i>string_buffer</i>) = GetPokemonName(<i>mon_id</i>)</code>
If <code><i>mon_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[wScriptVar]` instead. If <code><i>mon_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[hScriptVar]` instead.
## `$41`: <code>getitemname <i>string_buffer</i>, <i>item_id</i></code> ## `$41`: <code>getitemname <i>string_buffer</i>, <i>item_id</i></code>
<code>GetStringBuffer(<i>string_buffer</i>) = GetItemName(<i>item_id</i>)</code> <code>GetStringBuffer(<i>string_buffer</i>) = GetItemName(<i>item_id</i>)</code>
If <code><i>item_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[wScriptVar]` instead. If <code><i>item_id</i></code> = `USE_SCRIPT_VAR`, then it uses `[hScriptVar]` instead.
## `$42`: <code>getcurlandmarkname <i>string_buffer</i></code> ## `$42`: <code>getcurlandmarkname <i>string_buffer</i></code>

View File

@ -193,9 +193,9 @@ BattleAnimDelayFrame:
; Like DelayFrame but wastes battery life. ; Like DelayFrame but wastes battery life.
ld a, 1 ld a, 1
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
.wait .wait
ld a, [wVBlankOccurred] ldh a, [hVBlankOccurred]
and a and a
jr nz, .wait jr nz, .wait
ret ret

View File

@ -53,11 +53,11 @@ BoardMenuScript::
done done
.SubmenuCallback: .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. ; it has also taken care of queuing it into wQueuedScriptBank/wQueuedScriptAddr.
readmem hMenuReturn readmem wMenuReturn
ifequal HMENURETURN_SCRIPT, .CallbackScript ifequal MENURETURN_SCRIPT, .CallbackScript
ifequal HMENURETURN_ASM, .CallbackAsm ifequal MENURETURN_ASM, .CallbackAsm
end end
.CallbackScript: .CallbackScript:
@ -68,7 +68,7 @@ BoardMenuScript::
end end
BoardMenu:: BoardMenu::
; returns the selected menu item (BOARDMENUITEM_*) in wScriptVar upon exit ; returns the selected menu item (BOARDMENUITEM_*) in hScriptVar upon exit
ld a, [wBoardMenuLastCursorPosition] ld a, [wBoardMenuLastCursorPosition]
cp NUM_BOARD_MENU_ITEMS cp NUM_BOARD_MENU_ITEMS
jr c, .ok jr c, .ok
@ -107,7 +107,7 @@ BoardMenu::
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_BOARD_MENU_F, [hl] res SECONDARYSPRITES_BOARD_MENU_F, [hl]
ld a, [wBoardMenuCursorPosition] ld a, [wBoardMenuCursorPosition]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
DrawBoardMenuTilesAndClearPriorityAttr: DrawBoardMenuTilesAndClearPriorityAttr:
@ -217,13 +217,13 @@ DIE_MAX_NUMBER EQU 6
ld hl, wDisplaySecondarySprites ld hl, wDisplaySecondarySprites
res SECONDARYSPRITES_DIE_ROLL_F, [hl] res SECONDARYSPRITES_DIE_ROLL_F, [hl]
xor a ; FALSE xor a ; FALSE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.confirm_roll .confirm_roll
call UpdateSprites call UpdateSprites
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
BoardMenu_BreakDieAnimation: BoardMenu_BreakDieAnimation:
@ -341,8 +341,8 @@ BoardMenu_Party:
.quit .quit
; if quitted party menu after using field move ; if quitted party menu after using field move
call BoardMenu_CloseSubmenu call BoardMenu_CloseSubmenu
ld a, HMENURETURN_SCRIPT ld a, MENURETURN_SCRIPT
ldh [hMenuReturn], a ld [wMenuReturn], a
ret ret
BoardMenu_Pack: BoardMenu_Pack:
@ -352,8 +352,8 @@ BoardMenu_Pack:
ld a, [wPackUsedItem] ld a, [wPackUsedItem]
and a and a
ret z ret z
ld a, HMENURETURN_SCRIPT ld a, MENURETURN_SCRIPT
ldh [hMenuReturn], a ld [wMenuReturn], a
ret ret
BoardMenu_Pokegear: BoardMenu_Pokegear:
@ -363,7 +363,7 @@ BoardMenu_Pokegear:
BoardMenu_OpenSubmenu: BoardMenu_OpenSubmenu:
xor a xor a
ldh [hMenuReturn], a ld [wMenuReturn], a
ldh [hBGMapMode], a ldh [hBGMapMode], a
call LoadStandardMenuHeader call LoadStandardMenuHeader
farcall FadeOutPalettesToWhite farcall FadeOutPalettesToWhite

View File

@ -24,7 +24,7 @@ BuenasPassword:
.wrong .wrong
ld a, b ld a, b
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.MenuHeader: .MenuHeader:

View File

@ -5,7 +5,7 @@ AskRememberPassword:
ld a, $1 ld a, $1
.okay .okay
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.DoMenu: .DoMenu:

View File

@ -88,12 +88,12 @@ ContestDropOffMons:
; ... and replacing it with the terminator byte ; ... and replacing it with the terminator byte
ld [hl], -1 ld [hl], -1
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.fainted .fainted
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
ContestReturnMons: ContestReturnMons:

View File

@ -303,12 +303,12 @@ CheckCaughtCelebi:
bit BATTLERESULT_CAUGHT_CELEBI, a bit BATTLERESULT_CAUGHT_CELEBI, a
jr z, .false jr z, .false
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
jr .done jr .done
.false .false
xor a ; FALSE xor a ; FALSE
ld [wScriptVar], a ldh [hScriptVar], a
.done .done
ret ret

View File

@ -413,14 +413,14 @@ DayCareManOutside:
.Load0: .Load0:
call PrintText1bpp call PrintText1bpp
xor a ; FALSE xor a ; FALSE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.PartyFull: .PartyFull:
ld hl, .NoRoomForEggText ld hl, .NoRoomForEggText
call PrintText1bpp call PrintText1bpp
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.FoundAnEggText: .FoundAnEggText:

View File

@ -1,9 +1,9 @@
GiveDratini: 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. ; 0: give it a special moveset with Extremespeed.
; 1: give it the normal moveset of a level 15 Dratini. ; 1: give it the normal moveset of a level 15 Dratini.
ld a, [wScriptVar] ldh a, [hScriptVar]
cp $2 cp $2
ret nc ret nc
ld bc, wPartyCount ld bc, wPartyCount
@ -30,7 +30,7 @@ GiveDratini:
.GiveMoveset: .GiveMoveset:
push hl push hl
ld a, [wScriptVar] ldh a, [hScriptVar]
ld hl, .Movesets ld hl, .Movesets
ld bc, .Moveset1 - .Moveset0 ld bc, .Moveset1 - .Moveset0
call AddNTimes call AddNTimes

View File

@ -50,7 +50,7 @@ CheckFruitTree:
ld b, 2 ld b, 2
call GetFruitTreeFlag call GetFruitTreeFlag
ld a, c ld a, c
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
PickedFruitTree: PickedFruitTree:

View File

@ -2,14 +2,14 @@ BillsGrandfather:
farcall SelectMonFromParty farcall SelectMonFromParty
jr c, .cancel jr c, .cancel
ld a, [wCurPartySpecies] ld a, [wCurPartySpecies]
ld [wScriptVar], a ldh [hScriptVar], a
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
call GetPokemonName call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3 jp CopyPokemonName_Buffer1_Buffer3
.cancel .cancel
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
OlderHaircutBrother: OlderHaircutBrother:
@ -48,19 +48,19 @@ HaircutOrGrooming:
.ok .ok
inc hl inc hl
ld a, [hli] ld a, [hli]
ld [wScriptVar], a ldh [hScriptVar], a
ld c, [hl] ld c, [hl]
call ChangeHappiness call ChangeHappiness
ret ret
.nope .nope
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.egg .egg
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
INCLUDE "data/events/happiness_probabilities.asm" INCLUDE "data/events/happiness_probabilities.asm"

View File

@ -13,7 +13,7 @@ GetFirstPokemonHappiness:
.done .done
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
ld a, [hl] ld a, [hl]
ld [wScriptVar], a ldh [hScriptVar], a
call GetPokemonName call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3 jp CopyPokemonName_Buffer1_Buffer3
@ -26,7 +26,7 @@ CheckFirstMonIsEgg:
xor a xor a
.egg .egg
ld [wScriptVar], a ldh [hScriptVar], a
call GetPokemonName call GetPokemonName
jp CopyPokemonName_Buffer1_Buffer3 jp CopyPokemonName_Buffer1_Buffer3

View File

@ -12,11 +12,11 @@ HealMachineAnim:
ld a, [wPartyCount] ld a, [wPartyCount]
and a and a
ret z 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) ; 0: Up and left (Pokemon Center)
; 1: Left (Elm's Lab) ; 1: Left (Elm's Lab)
; 2: Up (Hall of Fame) ; 2: Up (Hall of Fame)
ld a, [wScriptVar] ldh a, [hScriptVar]
ld [wHealMachineAnimType], a ld [wHealMachineAnimType], a
ldh a, [rOBP1] ldh a, [rOBP1]
ld [wHealMachineTempOBP1], a ld [wHealMachineTempOBP1], a

View File

@ -30,7 +30,7 @@ SelectApricornForKurt:
ld [wMenuSelection], a ld [wMenuSelection], a
call Kurt_SelectApricorn call Kurt_SelectApricorn
ld a, c ld a, c
ld [wScriptVar], a ldh [hScriptVar], a
and a and a
jr z, .done jr z, .done
ld [wCurItem], a ld [wCurItem], a

View File

@ -1,6 +1,6 @@
CheckForLuckyNumberWinners: CheckForLuckyNumberWinners:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ld [wTempByteValue], a ld [wTempByteValue], a
ld a, [wPartyCount] ld a, [wPartyCount]
and a and a
@ -79,7 +79,7 @@ CheckForLuckyNumberWinners:
cp EGG cp EGG
jr z, .SkipBoxMon jr z, .SkipBoxMon
call .CompareLuckyNumberToMonID ; sets wScriptVar and wCurPartySpecies appropriately call .CompareLuckyNumberToMonID ; sets hScriptVar and wCurPartySpecies appropriately
jr nc, .SkipBoxMon jr nc, .SkipBoxMon
ld a, TRUE ld a, TRUE
ld [wTempByteValue], a ld [wTempByteValue], a
@ -100,7 +100,7 @@ CheckForLuckyNumberWinners:
jr c, .BoxesLoop jr c, .BoxesLoop
call CloseSRAM call CloseSRAM
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
ret z ; found nothing ret z ; found nothing
@ -167,7 +167,7 @@ CheckForLuckyNumberWinners:
.okay .okay
inc b inc b
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jr z, .bettermatch jr z, .bettermatch
cp b cp b
@ -176,7 +176,7 @@ CheckForLuckyNumberWinners:
.bettermatch .bettermatch
dec b dec b
ld a, b ld a, b
ld [wScriptVar], a ldh [hScriptVar], a
pop bc pop bc
ld a, b ld a, b
ld [wCurPartySpecies], a ld [wCurPartySpecies], a

View File

@ -52,22 +52,22 @@ CheckMagikarpLength:
call SkipNames call SkipNames
call CopyBytes call CopyBytes
ld a, MAGIKARPLENGTH_BEAT_RECORD ld a, MAGIKARPLENGTH_BEAT_RECORD
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.not_long_enough .not_long_enough
ld a, MAGIKARPLENGTH_TOO_SHORT ld a, MAGIKARPLENGTH_TOO_SHORT
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.declined .declined
ld a, MAGIKARPLENGTH_REFUSED ld a, MAGIKARPLENGTH_REFUSED
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.not_magikarp .not_magikarp
xor a ; MAGIKARPLENGTH_NOT_MAGIKARP xor a ; MAGIKARPLENGTH_NOT_MAGIKARP
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.MagikarpGuruMeasureText: .MagikarpGuruMeasureText:

View File

@ -1,5 +1,5 @@
MagnetTrain: MagnetTrain:
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jr nz, .ToGoldenrod jr nz, .ToGoldenrod
ld a, 1 ; forwards ld a, 1 ; forwards

View File

@ -37,7 +37,7 @@ FindItemInBallScript::
.TryReceiveItem: .TryReceiveItem:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ld a, [wItemBallItemID] ld a, [wItemBallItemID]
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
call GetItemName call GetItemName
@ -51,5 +51,5 @@ FindItemInBallScript::
call ReceiveItem call ReceiveItem
ret nc ret nc
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret

View File

@ -23,18 +23,18 @@ MoveTutor:
call CheckCanLearnMoveTutorMove call CheckCanLearnMoveTutorMove
jr nc, .loop jr nc, .loop
xor a ; FALSE xor a ; FALSE
ld [wScriptVar], a ldh [hScriptVar], a
jr .quit jr .quit
.cancel .cancel
ld a, -1 ld a, -1
ld [wScriptVar], a ldh [hScriptVar], a
.quit .quit
call CloseSubmenu call CloseSubmenu
ret ret
.GetMoveTutorMove: .GetMoveTutorMove:
ld a, [wScriptVar] ldh a, [hScriptVar]
cp MOVETUTOR_FLAMETHROWER cp MOVETUTOR_FLAMETHROWER
jr z, .flamethrower jr z, .flamethrower
cp MOVETUTOR_THUNDERBOLT cp MOVETUTOR_THUNDERBOLT

View File

@ -678,12 +678,12 @@ Script_UsedWaterfall:
.CheckContinueWaterfall: .CheckContinueWaterfall:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ld a, [wPlayerTile] ld a, [wPlayerTile]
call CheckWaterfallTile call CheckWaterfallTile
ret z ret z
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.WaterfallStep: .WaterfallStep:
@ -1070,7 +1070,7 @@ TryStrengthOW:
jr .done jr .done
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
WhirlpoolFunction: WhirlpoolFunction:
@ -1409,7 +1409,7 @@ HasRockSmash:
xor a xor a
jr .done jr .done
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
FishFunction: FishFunction:
@ -1570,7 +1570,7 @@ Fishing_CheckFacingUp:
xor a xor a
.up .up
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_FishCastRod: Script_FishCastRod:
@ -1776,11 +1776,11 @@ AskCutScript:
.CheckMap: .CheckMap:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call CheckMapForSomethingToCut call CheckMapForSomethingToCut
ret c ret c
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
AskCutText: AskCutText:

View File

@ -1,5 +1,5 @@
PlaySlowCry: PlaySlowCry:
ld a, [wScriptVar] ldh a, [hScriptVar]
call LoadCry call LoadCry
jr c, .done jr c, .done

View File

@ -142,7 +142,7 @@ DoPoisonStep::
jr nz, .party_loop jr nz, .party_loop
predef CheckPlayerPartyForFitMon predef CheckPlayerPartyForFitMon
ld a, d ld a, d
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.PoisonFaintText: .PoisonFaintText:

View File

@ -57,12 +57,12 @@ GiveShuckle:
ld hl, wDailyFlags1 ld hl, wDailyFlags1
set DAILYFLAGS1_GOT_SHUCKIE_TODAY_F, [hl] set DAILYFLAGS1_GOT_SHUCKIE_TODAY_F, [hl]
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.NotGiven: .NotGiven:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
SpecialShuckleOT: SpecialShuckleOT:
@ -123,20 +123,20 @@ ReturnShuckie:
callfar RemoveMonFromPartyOrBox callfar RemoveMonFromPartyOrBox
ld a, SHUCKIE_RETURNED ld a, SHUCKIE_RETURNED
.HappyToStayWithYou: .HappyToStayWithYou:
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.refused .refused
ld a, SHUCKIE_REFUSED ld a, SHUCKIE_REFUSED
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.DontReturn: .DontReturn:
xor a ; SHUCKIE_WRONG_MON xor a ; SHUCKIE_WRONG_MON
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.fainted .fainted
ld a, SHUCKIE_FAINTED ld a, SHUCKIE_FAINTED
ld [wScriptVar], a ldh [hScriptVar], a
ret ret

View File

@ -16,55 +16,55 @@ Special::
INCLUDE "data/events/special_pointers.asm" INCLUDE "data/events/special_pointers.asm"
SetPlayerPalette: SetPlayerPalette:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld d, a ld d, a
farcall _SetPlayerPalette farcall _SetPlayerPalette
ret ret
GameCornerPrizeMonCheckDex: GameCornerPrizeMonCheckDex:
ld a, [wScriptVar] ldh a, [hScriptVar]
dec a dec a
call CheckCaughtMon call CheckCaughtMon
ret nz ret nz
ld a, [wScriptVar] ldh a, [hScriptVar]
dec a dec a
call SetSeenAndCaughtMon call SetSeenAndCaughtMon
call FadeToMenu call FadeToMenu
ld a, [wScriptVar] ldh a, [hScriptVar]
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
farcall NewPokedexEntry farcall NewPokedexEntry
call ExitAllMenus call ExitAllMenus
ret ret
UnusedSetSeenMon: UnusedSetSeenMon:
ld a, [wScriptVar] ldh a, [hScriptVar]
dec a dec a
call SetSeenMon call SetSeenMon
ret ret
FindPartyMonAboveLevel: FindPartyMonAboveLevel:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, a ld b, a
farcall _FindPartyMonAboveLevel farcall _FindPartyMonAboveLevel
jr z, FoundNone jr z, FoundNone
jr FoundOne jr FoundOne
FindPartyMonAtLeastThatHappy: FindPartyMonAtLeastThatHappy:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, a ld b, a
farcall _FindPartyMonAtLeastThatHappy farcall _FindPartyMonAtLeastThatHappy
jr z, FoundNone jr z, FoundNone
jr FoundOne jr FoundOne
FindPartyMonThatSpecies: FindPartyMonThatSpecies:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, a ld b, a
farcall _FindPartyMonThatSpecies farcall _FindPartyMonThatSpecies
jr z, FoundNone jr z, FoundNone
jr FoundOne jr FoundOne
FindPartyMonThatSpeciesYourTrainerID: FindPartyMonThatSpeciesYourTrainerID:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, a ld b, a
farcall _FindPartyMonThatSpeciesYourTrainerID farcall _FindPartyMonThatSpeciesYourTrainerID
jr z, FoundNone jr z, FoundNone
@ -72,12 +72,12 @@ FindPartyMonThatSpeciesYourTrainerID:
FoundOne: FoundOne:
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
FoundNone: FoundNone:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
NameRival: NameRival:
@ -116,20 +116,20 @@ DisplayLinkRecord:
PlayersHousePC: PlayersHousePC:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
farcall _PlayersHousePC farcall _PlayersHousePC
ld a, c ld a, c
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
BugContestJudging: BugContestJudging:
farcall _BugContestJudging farcall _BugContestJudging
ld a, b ld a, b
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
MapRadio: MapRadio:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld e, a ld e, a
farcall PlayRadio farcall PlayRadio
ret ret
@ -138,7 +138,7 @@ UnownPuzzle:
call FadeToMenu call FadeToMenu
farcall _UnownPuzzle farcall _UnownPuzzle
ld a, [wSolvedUnownPuzzle] ld a, [wSolvedUnownPuzzle]
ld [wScriptVar], a ldh [hScriptVar], a
call ExitAllMenus call ExitAllMenus
ret ret
@ -221,15 +221,15 @@ ClearBGPalettesBufferScreen:
ScriptReturnCarry: ScriptReturnCarry:
jr c, .carry jr c, .carry
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.carry .carry
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
ActivateFishingSwarm: ActivateFishingSwarm:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld [wFishingSwarmFlag], a ld [wFishingSwarmFlag], a
ret ret
@ -272,7 +272,7 @@ SnorlaxAwake:
; next to Snorlax. ; next to Snorlax.
; outputs: ; outputs:
; wScriptVar is 1 if the conditions are met, otherwise 0. ; hScriptVar is 1 if the conditions are met, otherwise 0.
; check background music ; check background music
ld a, [wMapMusic] ld a, [wMapMusic]
@ -305,7 +305,7 @@ SnorlaxAwake:
.nope .nope
xor a xor a
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.ProximityCoords: .ProximityCoords:
@ -339,7 +339,7 @@ GameboyCheck:
.cgb .cgb
ld a, GBCHECK_CGB ld a, GBCHECK_CGB
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
FadeOutMusic: FadeOutMusic:

View File

@ -48,12 +48,12 @@ SweetScentEncounter:
.start_battle .start_battle
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.no_battle .no_battle
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ld [wBattleType], a ld [wBattleType], a
ret ret

View File

@ -16,12 +16,12 @@ TreeMonEncounter:
ld a, BATTLETYPE_TREE ld a, BATTLETYPE_TREE
ld [wBattleType], a ld [wBattleType], a
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.no_battle .no_battle
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
RockMonEncounter: RockMonEncounter:

View File

@ -77,7 +77,7 @@ SpecialKabutoChamber:
ret ret
DisplayUnownWords: DisplayUnownWords:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld hl, MenuHeaders_UnownWalls ld hl, MenuHeaders_UnownWalls
and a and a
jr z, .load jr z, .load
@ -102,7 +102,7 @@ DisplayUnownWords:
ld e, SCREEN_WIDTH ld e, SCREEN_WIDTH
add hl, de add hl, de
add hl, de add hl, de
ld a, [wScriptVar] ldh a, [hScriptVar]
ld c, a ld c, a
ld de, UnownWalls ld de, UnownWalls
and a and a

View File

@ -211,7 +211,7 @@ SlotsLoop:
ret ret
.matching_sevens .matching_sevens
ld a, [wTextDelayFrames] ldh a, [hTextDelayFrames]
and $7 and $7
ret nz ret nz
ldh a, [rBGP] ldh a, [rBGP]
@ -1638,7 +1638,7 @@ Slots_InitBias:
and a and a
ret z ret z
ld hl, .Normal ld hl, .Normal
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jr z, .okay jr z, .okay
ld hl, .Lucky ld hl, .Lucky

View File

@ -794,7 +794,7 @@ PuzzlePieceBorderData:
INCBIN "gfx/unown_puzzle/tile_borders.2bpp" INCBIN "gfx/unown_puzzle/tile_borders.2bpp"
LoadUnownPuzzlePiecesGFX: LoadUnownPuzzlePiecesGFX:
ld a, [wScriptVar] ldh a, [hScriptVar]
maskbits NUM_UNOWN_PUZZLES maskbits NUM_UNOWN_PUZZLES
ld e, a ld e, a
ld d, 0 ld d, 0

View File

@ -206,7 +206,7 @@ Gen2ToGen2LinkComms:
call Link_PrepPartyData_Gen2 call Link_PrepPartyData_Gen2
call FixDataForLinkTransfer call FixDataForLinkTransfer
call CheckLinkTimeout_Gen2 call CheckLinkTimeout_Gen2
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jp z, LinkTimeout jp z, LinkTimeout
ldh a, [hSerialConnectionStatus] ldh a, [hSerialConnectionStatus]
@ -1574,8 +1574,6 @@ ExitLinkCommunications:
call GetCGBLayout call GetCGBLayout
call WaitBGMap2 call WaitBGMap2
xor a xor a
ld [wUnusedLinkCommunicationByte], a
xor a
ldh [rSB], a ldh [rSB], a
ldh [hSerialSend], a ldh [hSerialSend], a
ld a, (0 << rSC_ON) | (1 << rSC_CLOCK) ld a, (0 << rSC_ON) | (1 << rSC_CLOCK)
@ -2041,7 +2039,7 @@ INCLUDE "engine/movie/trade_animation.asm"
CheckTimeCapsuleCompatibility: CheckTimeCapsuleCompatibility:
; Checks to see if your party is compatible with the Gen 1 games. ; 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 ; 0: Party is okay
; 1: At least one Pokémon was introduced in Gen 2 ; 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 ; 2: At least one Pokémon has a move that was introduced in Gen 2
@ -2117,7 +2115,7 @@ CheckTimeCapsuleCompatibility:
ld a, $3 ld a, $3
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
GetIncompatibleMonName: GetIncompatibleMonName:
@ -2299,12 +2297,12 @@ WaitForLinkedFriend:
ld c, 50 ld c, 50
call DelayFrames call DelayFrames
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.done .done
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
CheckLinkTimeout_Receptionist: CheckLinkTimeout_Receptionist:
@ -2323,13 +2321,13 @@ CheckLinkTimeout_Receptionist:
call Link_CheckCommunicationError call Link_CheckCommunicationError
xor a xor a
ldh [hVBlank], a ldh [hVBlank], a
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
ret nz ret nz
jp Link_ResetSerialRegistersAfterLinkClosure jp Link_ResetSerialRegistersAfterLinkClosure
CheckLinkTimeout_Gen2: CheckLinkTimeout_Gen2:
; if wScriptVar = 0 on exit, link connection is closed ; if hScriptVar = 0 on exit, link connection is closed
ld a, $5 ld a, $5
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
ld hl, wLinkTimeoutFrames ld hl, wLinkTimeoutFrames
@ -2343,7 +2341,7 @@ CheckLinkTimeout_Gen2:
call DelayFrame call DelayFrame
call DelayFrame call DelayFrame
call Link_CheckCommunicationError call Link_CheckCommunicationError
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jr z, .exit jr z, .exit
@ -2380,7 +2378,7 @@ endc
.timeout .timeout
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.exit .exit
@ -2412,7 +2410,7 @@ Link_CheckCommunicationError:
ld a, TRUE ld a, TRUE
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ld hl, wLinkTimeoutFrames ld hl, wLinkTimeoutFrames
xor a xor a
ld [hli], a ld [hli], a
@ -2470,7 +2468,7 @@ TryQuickSave:
vc_hook Wireless_TryQuickSave_block_input_2 vc_hook Wireless_TryQuickSave_block_input_2
xor a ; FALSE xor a ; FALSE
.return_result .return_result
ld [wScriptVar], a ldh [hScriptVar], a
ld c, 30 ld c, 30
call DelayFrames call DelayFrames
pop af pop af
@ -2495,12 +2493,12 @@ CheckBothSelectedSameRoom:
xor a xor a
ldh [hVBlank], a ldh [hVBlank], a
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.fail .fail
xor a ; FALSE xor a ; FALSE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
TimeCapsule: TimeCapsule:
@ -2598,7 +2596,7 @@ CableClubCheckWhichChris:
dec a ; FALSE dec a ; FALSE
.yes .yes
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
GSLinkCommsBorderGFX: ; unreferenced GSLinkCommsBorderGFX: ; unreferenced

View File

@ -122,14 +122,14 @@ StartMenu::
.ExitMenuRunScript: .ExitMenuRunScript:
call ExitMenu call ExitMenu
ld a, HMENURETURN_SCRIPT ld a, MENURETURN_SCRIPT
ldh [hMenuReturn], a ld [wMenuReturn], a
ret ret
.ExitMenuRunScriptCloseText: .ExitMenuRunScriptCloseText:
call ExitMenu call ExitMenu
ld a, HMENURETURN_SCRIPT ld a, MENURETURN_SCRIPT
ldh [hMenuReturn], a ld [wMenuReturn], a
jr .ReturnEnd2 jr .ReturnEnd2
.ExitMenuCallFuncCloseText: .ExitMenuCallFuncCloseText:

View File

@ -100,7 +100,7 @@ CheckWildEncountersScriptFlag:
StartMap: StartMap:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
xor a xor a
ld [wScriptRunning], a ld [wScriptRunning], a
ld hl, wMapStatus ld hl, wMapStatus
@ -179,11 +179,11 @@ MaxOverworldDelay:
ResetOverworldDelay: ResetOverworldDelay:
ld a, [MaxOverworldDelay] ld a, [MaxOverworldDelay]
ld [wOverworldDelay], a ldh [hOverworldDelay], a
ret ret
NextOverworldFrame: NextOverworldFrame:
ld a, [wOverworldDelay] ldh a, [hOverworldDelay]
and a and a
ret z ret z
ld c, a ld c, a
@ -806,7 +806,7 @@ PlayerMovementPointers:
CheckMenuOW: CheckMenuOW:
xor a xor a
ldh [hMenuReturn], a ld [wMenuReturn], a
ldh a, [hJoyPressed] ldh a, [hJoyPressed]
bit SELECT_F, a bit SELECT_F, a
@ -843,9 +843,9 @@ SelectMenuScript:
StartMenuCallback: StartMenuCallback:
SelectMenuCallback: SelectMenuCallback:
readmem hMenuReturn readmem wMenuReturn
ifequal HMENURETURN_SCRIPT, .Script ifequal MENURETURN_SCRIPT, .Script
ifequal HMENURETURN_ASM, .Asm ifequal MENURETURN_ASM, .Asm
end end
.Script: .Script:

View File

@ -389,7 +389,7 @@ Script_yesorno:
jr c, .no jr c, .no
ld a, TRUE ld a, TRUE
.no .no
ld [wScriptVar], a ldh [hScriptVar], a
vc_hook Unknown_yesorno_ret vc_hook Unknown_yesorno_ret
ret ret
@ -413,7 +413,7 @@ Script_pokepic:
call GetScriptByte call GetScriptByte
and a and a
jr nz, .ok jr nz, .ok
ld a, [wScriptVar] ldh a, [hScriptVar]
.ok .ok
ld [wCurPartySpecies], a ld [wCurPartySpecies], a
farcall Pokepic farcall Pokepic
@ -431,7 +431,7 @@ Script_verticalmenu:
jr nc, .ok jr nc, .ok
xor a xor a
.ok .ok
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script__2dmenu: Script__2dmenu:
@ -442,7 +442,7 @@ Script__2dmenu:
jr nc, .ok jr nc, .ok
xor a xor a
.ok .ok
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_battletowertext: Script_battletowertext:
@ -490,7 +490,7 @@ Script_verbosegiveitemvar:
call GetScriptByte call GetScriptByte
cp ITEM_FROM_MEM cp ITEM_FROM_MEM
jr nz, .ok jr nz, .ok
ld a, [wScriptVar] ldh a, [hScriptVar]
.ok .ok
ld [wCurItem], a ld [wCurItem], a
call GetScriptByte call GetScriptByte
@ -503,7 +503,7 @@ Script_verbosegiveitemvar:
jr c, .ok2 jr c, .ok2
xor a xor a
.ok2 .ok2
ld [wScriptVar], a ldh [hScriptVar], a
call CurItemName call CurItemName
ld de, wStringBuffer1 ld de, wStringBuffer1
ld a, STRING_BUFFER_4 ld a, STRING_BUFFER_4
@ -587,7 +587,7 @@ Script_pokemart:
Script_elevator: Script_elevator:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld e, a ld e, a
call GetScriptByte call GetScriptByte
@ -597,7 +597,7 @@ Script_elevator:
farcall Elevator farcall Elevator
ret c ret c
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_trade: Script_trade:
@ -636,7 +636,7 @@ Script_askforphonenumber:
call GetScriptByte call GetScriptByte
ld a, PHONE_CONTACT_REFUSED ld a, PHONE_CONTACT_REFUSED
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_describedecoration: Script_describedecoration:
@ -690,7 +690,7 @@ Script_scripttalkafter:
Script_trainerflagaction: Script_trainerflagaction:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ld hl, wTempTrainerEventFlag ld hl, wTempTrainerEventFlag
ld e, [hl] ld e, [hl]
inc hl inc hl
@ -702,7 +702,7 @@ Script_trainerflagaction:
and a and a
ret z ret z
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_winlosstext: Script_winlosstext:
@ -726,12 +726,12 @@ Script_endifjustbattled:
Script_checkjustbattled: Script_checkjustbattled:
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ld a, [wRunningTrainerBattleScript] ld a, [wRunningTrainerBattleScript]
and a and a
ret nz ret nz
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_encountermusic: Script_encountermusic:
@ -791,7 +791,7 @@ Script_cry:
pop af pop af
and a and a
jr nz, .ok jr nz, .ok
ld a, [wScriptVar] ldh a, [hScriptVar]
.ok .ok
call PlayMonCry call PlayMonCry
ret ret
@ -1059,7 +1059,7 @@ Script_loademote:
call GetScriptByte call GetScriptByte
cp EMOTE_FROM_MEM cp EMOTE_FROM_MEM
jr nz, .not_var_emote jr nz, .not_var_emote
ld a, [wScriptVar] ldh a, [hScriptVar]
.not_var_emote .not_var_emote
ld c, a ld c, a
farcall LoadEmote farcall LoadEmote
@ -1067,7 +1067,7 @@ Script_loademote:
Script_showemote: Script_showemote:
call GetScriptByte call GetScriptByte
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
call GetScriptObject call GetScriptObject
cp LAST_TALKED cp LAST_TALKED
@ -1165,7 +1165,7 @@ Script_startbattle:
predef StartBattle predef StartBattle
ld a, [wBattleResult] ld a, [wBattleResult]
and ~BATTLERESULT_BITMASK and ~BATTLERESULT_BITMASK
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_catchtutorial: Script_catchtutorial:
@ -1308,33 +1308,33 @@ Script_memjump:
jp ScriptJump jp ScriptJump
Script_iffalse: Script_iffalse:
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jp nz, SkipTwoScriptBytes jp nz, SkipTwoScriptBytes
jp Script_sjump jp Script_sjump
Script_iftrue: Script_iftrue:
ld a, [wScriptVar] ldh a, [hScriptVar]
and a and a
jp nz, Script_sjump jp nz, Script_sjump
jp SkipTwoScriptBytes jp SkipTwoScriptBytes
Script_ifequal: Script_ifequal:
call GetScriptByte call GetScriptByte
ld hl, wScriptVar ld hl, hScriptVar
cp [hl] cp [hl]
jr z, Script_sjump jr z, Script_sjump
jr SkipTwoScriptBytes jr SkipTwoScriptBytes
Script_ifnotequal: Script_ifnotequal:
call GetScriptByte call GetScriptByte
ld hl, wScriptVar ld hl, hScriptVar
cp [hl] cp [hl]
jr nz, Script_sjump jr nz, Script_sjump
jr SkipTwoScriptBytes jr SkipTwoScriptBytes
Script_ifgreater: Script_ifgreater:
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, a ld b, a
call GetScriptByte call GetScriptByte
cp b cp b
@ -1344,7 +1344,7 @@ Script_ifgreater:
Script_ifless: Script_ifless:
call GetScriptByte call GetScriptByte
ld b, a ld b, a
ld a, [wScriptVar] ldh a, [hScriptVar]
cp b cp b
jr c, Script_sjump jr c, Script_sjump
jr SkipTwoScriptBytes jr SkipTwoScriptBytes
@ -1404,12 +1404,12 @@ Script_sdefer:
Script_checkscene: Script_checkscene:
call CheckScenes call CheckScenes
jr z, .no_scene jr z, .no_scene
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.no_scene .no_scene
ld a, $ff ld a, $ff
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_checkmapscene: Script_checkmapscene:
@ -1422,12 +1422,12 @@ Script_checkmapscene:
or e or e
jr z, .no_scene jr z, .no_scene
ld a, [de] ld a, [de]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.no_scene .no_scene
ld a, $ff ld a, $ff
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_setscene: Script_setscene:
@ -1458,7 +1458,7 @@ Script_readmem:
call GetScriptByte call GetScriptByte
ld h, a ld h, a
ld a, [hl] ld a, [hl]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_writemem: Script_writemem:
@ -1466,7 +1466,7 @@ Script_writemem:
ld l, a ld l, a
call GetScriptByte call GetScriptByte
ld h, a ld h, a
ld a, [wScriptVar] ldh a, [hScriptVar]
ld [hl], a ld [hl], a
ret ret
@ -1481,19 +1481,19 @@ Script_loadmem:
Script_setval: Script_setval:
call GetScriptByte call GetScriptByte
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_addval: Script_addval:
call GetScriptByte call GetScriptByte
ld hl, wScriptVar ld hl, hScriptVar
add [hl] add [hl]
ld [hl], a ld [hl], a
ret ret
Script_random: Script_random:
call GetScriptByte call GetScriptByte
ld [wScriptVar], a ldh [hScriptVar], a
and a and a
ret z ret z
@ -1522,11 +1522,11 @@ Script_random:
.finish .finish
push af push af
ld a, [wScriptVar] ldh a, [hScriptVar]
ld c, a ld c, a
pop af pop af
call SimpleDivide call SimpleDivide
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.Divide256byC: .Divide256byC:
@ -1545,13 +1545,13 @@ Script_readvar:
call GetScriptByte call GetScriptByte
call GetVarAction call GetVarAction
ld a, [de] ld a, [de]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_writevar: Script_writevar:
call GetScriptByte call GetScriptByte
call GetVarAction call GetVarAction
ld a, [wScriptVar] ldh a, [hScriptVar]
ld [de], a ld [de], a
ret ret
@ -1569,7 +1569,7 @@ GetVarAction:
Script_checkver: Script_checkver:
ld a, [.gs_version] ld a, [.gs_version]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.gs_version: .gs_version:
@ -1579,7 +1579,7 @@ Script_getmonname:
call GetScriptByte call GetScriptByte
and a and a
jr nz, .gotit jr nz, .gotit
ld a, [wScriptVar] ldh a, [hScriptVar]
.gotit .gotit
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
call GetPokemonName call GetPokemonName
@ -1603,7 +1603,7 @@ Script_getitemname:
call GetScriptByte call GetScriptByte
and a ; USE_SCRIPT_VAR and a ; USE_SCRIPT_VAR
jr nz, .ok jr nz, .ok
ld a, [wScriptVar] ldh a, [hScriptVar]
.ok .ok
ld [wNamedObjectIndex], a ld [wNamedObjectIndex], a
call GetItemName call GetItemName
@ -1671,7 +1671,7 @@ Script_getchips:
Script_getnum: Script_getnum:
call ResetStringBuffer1 call ResetStringBuffer1
ld de, wScriptVar ld de, hScriptVar
ld hl, wStringBuffer1 ld hl, wStringBuffer1
lb bc, PRINTNUM_LEFTALIGN | 1, 3 lb bc, PRINTNUM_LEFTALIGN | 1, 3
call PrintNum call PrintNum
@ -1728,7 +1728,7 @@ Script_giveitem:
call GetScriptByte call GetScriptByte
cp ITEM_FROM_MEM cp ITEM_FROM_MEM
jr nz, .ok jr nz, .ok
ld a, [wScriptVar] ldh a, [hScriptVar]
.ok .ok
ld [wCurItem], a ld [wCurItem], a
call GetScriptByte call GetScriptByte
@ -1737,16 +1737,16 @@ Script_giveitem:
call ReceiveItem call ReceiveItem
jr nc, .full jr nc, .full
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.full .full
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_takeitem: Script_takeitem:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld [wCurItem], a ld [wCurItem], a
call GetScriptByte call GetScriptByte
@ -1757,19 +1757,19 @@ Script_takeitem:
call TossItem call TossItem
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_checkitem: Script_checkitem:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld [wCurItem], a ld [wCurItem], a
ld hl, wNumItems ld hl, wNumItems
call CheckItem call CheckItem
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_givecoins: Script_givecoins:
@ -1800,7 +1800,7 @@ CompareCoinsAction:
.less .less
ld a, HAVE_LESS ld a, HAVE_LESS
.done .done
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
GetCoinsAccount: GetCoinsAccount:
@ -1850,60 +1850,60 @@ LoadChipAmountToMem:
Script_checktime: Script_checktime:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
farcall CheckTime farcall CheckTime
call GetScriptByte call GetScriptByte
and c and c
ret z ret z
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_checkpoke: Script_checkpoke:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld hl, wPartySpecies ld hl, wPartySpecies
ld de, 1 ld de, 1
call IsInArray call IsInArray
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_addcellnum: Script_addcellnum:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld c, a ld c, a
farcall AddPhoneNumber farcall AddPhoneNumber
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_delcellnum: Script_delcellnum:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld c, a ld c, a
farcall DelCellNum farcall DelCellNum
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_checkcellnum: Script_checkcellnum:
; returns false if the cell number is not in your phone ; returns false if the cell number is not in your phone
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld c, a ld c, a
farcall CheckCellNum farcall CheckCellNum
ret nc ret nc
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_specialphonecall: Script_specialphonecall:
@ -1921,7 +1921,7 @@ Script_checkphonecall:
jr z, .ok jr z, .ok
ld a, TRUE ld a, TRUE
.ok .ok
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_givepoke: Script_givepoke:
@ -1946,14 +1946,14 @@ Script_givepoke:
.ok .ok
farcall GivePoke farcall GivePoke
ld a, b ld a, b
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_giveegg: 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 xor a ; PARTYMON
ld [wScriptVar], a ldh [hScriptVar], a
ld [wMonType], a ld [wMonType], a
call GetScriptByte call GetScriptByte
ld [wCurPartySpecies], a ld [wCurPartySpecies], a
@ -1962,7 +1962,7 @@ Script_giveegg:
farcall GiveEgg farcall GiveEgg
ret nc ret nc
ld a, 2 ld a, 2
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_setevent: Script_setevent:
@ -1995,7 +1995,7 @@ Script_checkevent:
jr z, .false jr z, .false
ld a, TRUE ld a, TRUE
.false .false
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_setflag: Script_setflag:
@ -2028,7 +2028,7 @@ Script_checkflag:
jr z, .false jr z, .false
ld a, TRUE ld a, TRUE
.false .false
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
_EngineFlagAction: _EngineFlagAction:
@ -2129,13 +2129,13 @@ Script_writecmdqueue:
Script_delcmdqueue: Script_delcmdqueue:
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
call GetScriptByte call GetScriptByte
ld b, a ld b, a
farcall DelCmdQueue ; no need to farcall farcall DelCmdQueue ; no need to farcall
ret c ret c
ld a, TRUE ld a, TRUE
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_changemapblocks: Script_changemapblocks:
@ -2354,12 +2354,12 @@ Script_wait:
Script_checksave: Script_checksave:
farcall CheckSave farcall CheckSave
ld a, c ld a, c
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
Script_checkver_duplicate: ; unreferenced Script_checkver_duplicate: ; unreferenced
ld a, [.gs_version] ld a, [.gs_version]
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.gs_version: .gs_version:

View File

@ -158,8 +158,8 @@ UseRegisteredItem:
cp 1 cp 1
jr nz, ._cantuse jr nz, ._cantuse
scf scf
ld a, HMENURETURN_SCRIPT ld a, MENURETURN_SCRIPT
ldh [hMenuReturn], a ld [wMenuReturn], a
ret ret
.CantUse: .CantUse:

View File

@ -818,12 +818,12 @@ RandomUnseenWildMon:
ld hl, .JustSawSomeRareMonText ld hl, .JustSawSomeRareMonText
call PrintText2bpp call PrintText2bpp
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.done .done
ld a, $1 ld a, $1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.JustSawSomeRareMonText: .JustSawSomeRareMonText:

View File

@ -80,7 +80,7 @@ CheckPartyFullAfterContest:
xor a xor a
ld [wContestMonSpecies], a ld [wContestMonSpecies], a
and a ; BUGCONTEST_CAUGHT_MON and a ; BUGCONTEST_CAUGHT_MON
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.TryAddToBox: .TryAddToBox:
@ -139,12 +139,12 @@ CheckPartyFullAfterContest:
xor a xor a
ld [wContestMon], a ld [wContestMon], a
ld a, BUGCONTEST_BOXED_MON ld a, BUGCONTEST_BOXED_MON
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.DidntCatchAnything: .DidntCatchAnything:
ld a, BUGCONTEST_NO_CATCH ld a, BUGCONTEST_NO_CATCH
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
GiveANickname_YesNo: GiveANickname_YesNo:

View File

@ -185,7 +185,7 @@ CheckPokeMail::
pop bc pop bc
.return .return
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
GivePokeMail:: GivePokeMail::

View File

@ -1,52 +1,52 @@
BeastsCheck: BeastsCheck:
; Check if the player owns all three legendary beasts. ; 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. ; 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 a, RAIKOU
ld [wScriptVar], a ldh [hScriptVar], a
call CheckOwnMonAnywhere call CheckOwnMonAnywhere
jr nc, .notexist jr nc, .notexist
ld a, ENTEI ld a, ENTEI
ld [wScriptVar], a ldh [hScriptVar], a
call CheckOwnMonAnywhere call CheckOwnMonAnywhere
jr nc, .notexist jr nc, .notexist
ld a, SUICUNE ld a, SUICUNE
ld [wScriptVar], a ldh [hScriptVar], a
call CheckOwnMonAnywhere call CheckOwnMonAnywhere
jr nc, .notexist jr nc, .notexist
; they exist ; they exist
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.notexist .notexist
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
MonCheck: MonCheck:
; Check if the player owns any Pokémon of the species in wScriptVar. ; Check if the player owns any Pokémon of the species in hScriptVar.
; Return the result in wScriptVar. ; Return the result in hScriptVar.
call CheckOwnMonAnywhere call CheckOwnMonAnywhere
jr c, .exists jr c, .exists
; doesn't exist ; doesn't exist
xor a xor a
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
.exists .exists
ld a, 1 ld a, 1
ld [wScriptVar], a ldh [hScriptVar], a
ret ret
CheckOwnMonAnywhere: 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. ; It must exist in either party or PC, and have the player's OT and ID.
; If there are no monsters in the party, ; If there are no monsters in the party,
@ -182,13 +182,13 @@ CheckOwnMonAnywhere:
CheckOwnMon: CheckOwnMon:
; Check if a Pokémon belongs to the player and is of a specific species. ; 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]. ; we have in [hl].
; inputs: ; inputs:
; hl, pointer to PartyMonNSpecies ; hl, pointer to PartyMonNSpecies
; bc, pointer to PartyMonNOT ; bc, pointer to PartyMonNOT
; wScriptVar should contain the species we're looking for ; hScriptVar should contain the species we're looking for
; outputs: ; outputs:
; sets carry if monster matches species, ID, and OT name. ; sets carry if monster matches species, ID, and OT name.
@ -201,7 +201,7 @@ CheckOwnMon:
; check species ; check species
ld a, [wScriptVar] ldh a, [hScriptVar]
ld b, [hl] ld b, [hl]
cp b cp b
jr nz, .notfound jr nz, .notfound

View File

@ -1,13 +1,13 @@
DelayFrame:: DelayFrame::
; Wait for one frame ; Wait for one frame
ld a, 1 ld a, 1
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
; Wait for the next VBlank, halting to conserve battery ; Wait for the next VBlank, halting to conserve battery
.halt .halt
halt halt
nop nop
ld a, [wVBlankOccurred] ldh a, [hVBlankOccurred]
and a and a
jr nz, .halt jr nz, .halt
ret ret

View File

@ -295,11 +295,11 @@ JoyTextDelay::
and a and a
jr z, .checkframedelay jr z, .checkframedelay
ld a, 15 ld a, 15
ld [wTextDelayFrames], a ldh [hTextDelayFrames], a
ret ret
.checkframedelay .checkframedelay
ld a, [wTextDelayFrames] ldh a, [hTextDelayFrames]
and a and a
jr z, .restartframedelay jr z, .restartframedelay
xor a xor a
@ -308,7 +308,7 @@ JoyTextDelay::
.restartframedelay .restartframedelay
ld a, 5 ld a, 5
ld [wTextDelayFrames], a ldh [hTextDelayFrames], a
ret ret
WaitPressAorB_BlinkCursor:: WaitPressAorB_BlinkCursor::

View File

@ -44,7 +44,7 @@ PrintLetterDelay::
ld a, TEXT_DELAY_FAST ld a, TEXT_DELAY_FAST
.updatedelay .updatedelay
ld [wTextDelayFrames], a ldh [hTextDelayFrames], a
.checkjoypad .checkjoypad
call GetJoypad call GetJoypad
@ -68,7 +68,7 @@ PrintLetterDelay::
jr .end jr .end
.wait .wait
ld a, [wTextDelayFrames] ldh a, [hTextDelayFrames]
and a and a
jr nz, .checkjoypad jr nz, .checkjoypad

View File

@ -115,7 +115,7 @@ VBlank0::
; vblank-sensitive operations are done ; vblank-sensitive operations are done
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
; if hWindowHUDLY is active, enable interrupts so the LCD interrupt can trigger ; if hWindowHUDLY is active, enable interrupts so the LCD interrupt can trigger
ldh a, [hWindowHUDLY] ldh a, [hWindowHUDLY]
@ -141,18 +141,18 @@ VBlank0::
sbc b sbc b
ldh [hRandomSub], a ldh [hRandomSub], a
ld a, [wOverworldDelay] ldh a, [hOverworldDelay]
and a and a
jr z, .ok jr z, .ok
dec a dec a
ld [wOverworldDelay], a ldh [hOverworldDelay], a
.ok .ok
ld a, [wTextDelayFrames] ldh a, [hTextDelayFrames]
and a and a
jr z, .ok2 jr z, .ok2
dec a dec a
ld [wTextDelayFrames], a ldh [hTextDelayFrames], a
.ok2 .ok2
call UpdateJoypad call UpdateJoypad
@ -199,7 +199,7 @@ VBlank2::
rst Bankswitch rst Bankswitch
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
ret ret
VBlank1:: VBlank1::
@ -228,7 +228,7 @@ VBlank1::
.done .done
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
; get requested ints ; get requested ints
ldh a, [rIF] ldh a, [rIF]
@ -296,7 +296,7 @@ VBlank3::
.done .done
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
ldh a, [rIF] ldh a, [rIF]
push af push af
@ -351,7 +351,7 @@ VBlank4::
call UpdateJoypad call UpdateJoypad
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
call AskSerial call AskSerial
@ -385,7 +385,7 @@ VBlank5::
.done .done
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
call UpdateJoypad call UpdateJoypad
@ -433,7 +433,7 @@ VBlank6::
.done .done
xor a xor a
ld [wVBlankOccurred], a ldh [hVBlankOccurred], a
ld a, BANK(_UpdateSound) ld a, BANK(_UpdateSound)
rst Bankswitch rst Bankswitch

View File

@ -7,12 +7,14 @@ hSRAMBank:: db
hVBlankCounter:: db hVBlankCounter:: db
hOverworldDelay:: db
hTextDelayFrames:: db
hVBlankOccurred:: db
hROMBank:: db hROMBank:: db
hVBlank:: db hVBlank:: db
hMapEntryMethod:: db hMapEntryMethod:: db
hMenuReturn:: db
hJoypadReleased:: db hJoypadReleased:: db
hJoypadPressed:: db hJoypadPressed:: db
hJoypadDown:: db hJoypadDown:: db
@ -127,6 +129,8 @@ hBGMapTileCount:: db
hMapAnims:: db hMapAnims:: db
hTileAnimFrame:: db hTileAnimFrame:: db
hScriptVar:: db
hLastTalked:: db hLastTalked:: db
hRandomAdd:: db hRandomAdd:: db

View File

@ -140,8 +140,6 @@ wLinkMode::
; a LINK_* value for the link type ; a LINK_* value for the link type
db db
wScriptVar:: db
wPlayerNextMovement:: db wPlayerNextMovement:: db
wPlayerMovement:: db wPlayerMovement:: db
@ -1195,17 +1193,13 @@ wCursorCurrentTile:: dw
ds 3 ds 3
wMoreMenuDataEnd:: wMoreMenuDataEnd::
wOverworldDelay:: db wMenuReturn:: db
wTextDelayFrames:: db
wVBlankOccurred:: db
wPredefID:: db wPredefID:: db
wPredefHL:: dw wPredefHL:: dw
wPredefAddress:: dw wPredefAddress:: dw
wFarCallBC:: dw wFarCallBC:: dw
wUnusedLinkCommunicationByte:: db
wGameTimerPaused:: wGameTimerPaused::
; bit 0: game timer paused ; bit 0: game timer paused
; bit 7: something mobile ; bit 7: something mobile