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

@@ -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:

View File

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

View File

@@ -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