You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Optimize some HRAM usage
This commit is contained in:
@@ -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
|
||||
|
@@ -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::
|
||||
|
@@ -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
|
||||
|
@@ -102,7 +102,7 @@ $~~~~$*Exit overworld loop*
|
||||
---
|
||||
|
||||
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:\
|
||||
>$~~~~$*Get joypad* <c>update hJoyDown, hJoyReleased, hJoyPressed</c>\
|
||||
>$~~~~$*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)
|
||||
|
||||
> DelayFrames(wOverworldDelay)
|
||||
> DelayFrames(hOverworldDelay)
|
||||
|
||||
> <f>**HandleMapBackground**</f> <c>_UpdateSprites + ScrollScreen</c>
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
<code>[wScriptVar] = <i>value</i></code>
|
||||
<code>[hScriptVar] = <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>
|
||||
@@ -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>
|
||||
|
||||
<code>[wScriptVar] = [<i>address</i>]</code>
|
||||
<code>[hScriptVar] = [<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>
|
||||
@@ -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>
|
||||
|
||||
<code>[wScriptVar] = GetVarAction(<i>variable</i>)</code>
|
||||
<code>[hScriptVar] = GetVarAction(<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>
|
||||
@@ -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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -24,7 +24,7 @@ BuenasPassword:
|
||||
|
||||
.wrong
|
||||
ld a, b
|
||||
ld [wScriptVar], a
|
||||
ldh [hScriptVar], a
|
||||
ret
|
||||
|
||||
.MenuHeader:
|
||||
|
@@ -5,7 +5,7 @@ AskRememberPassword:
|
||||
ld a, $1
|
||||
|
||||
.okay
|
||||
ld [wScriptVar], a
|
||||
ldh [hScriptVar], a
|
||||
ret
|
||||
|
||||
.DoMenu:
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
@@ -50,7 +50,7 @@ CheckFruitTree:
|
||||
ld b, 2
|
||||
call GetFruitTreeFlag
|
||||
ld a, c
|
||||
ld [wScriptVar], a
|
||||
ldh [hScriptVar], a
|
||||
ret
|
||||
|
||||
PickedFruitTree:
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user