summaryrefslogtreecommitdiff
path: root/engine/items
diff options
context:
space:
mode:
authorentrpntr <entrpntr@gmail.com>2020-05-04 14:25:55 -0400
committerentrpntr <entrpntr@gmail.com>2020-05-04 14:25:55 -0400
commitfd35959d94c9487e74b2376e529302b32061af83 (patch)
tree73b910d50e9af87d598e70a94900fd18f5f5fdaf /engine/items
parent39a7f59931e03e4ebd155e061ac6e71a6d6bd97a (diff)
Clean up text, and some bank 3 code.
Diffstat (limited to 'engine/items')
-rwxr-xr-xengine/items/item_effects.asm769
-rwxr-xr-xengine/items/pack.asm1589
2 files changed, 1236 insertions, 1122 deletions
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 3b31aef8..ddbd1001 100755
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -1,17 +1,17 @@
-_DoItemEffect:: ; e7a6 (3:67a6)
+_DoItemEffect::
ld a, [wCurItem]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetItemName
call CopyName1
- ld a, $1
- ld [wFieldMoveSucceeded], a
+ ld a, 1
+ ld [wItemEffectSucceeded], a
ld a, [wCurItem]
dec a
- ld hl, .ItemEffects
+ ld hl, ItemEffects
rst JumpTable
ret
-.ItemEffects
+ItemEffects:
dw MasterBall
dw UltraBall
dw Brightpowder
@@ -206,26 +206,31 @@ PokeBall: ; e926
UltraBall: ; e926
ld a, [wBattleMode]
dec a
- jp nz, Functionf7e7
+ jp nz, UseBallInTrainerBattle
+
ld a, [wPartyCount]
cp PARTY_LENGTH
- jr nz, .room_in_party_or_pc
- ld a, $1
+ jr nz, .room_in_party
+
+ ld a, BANK(sBoxCount)
call OpenSRAM
- ld a, [$ad6c]
- cp $14
+ ld a, [sBoxCount]
+ cp MONS_PER_BOX
call CloseSRAM
- jp z, FailToUseBall
-.room_in_party_or_pc
+ jp z, Ball_BoxIsFullMessage
+
+.room_in_party
xor a
ld [wWildMon], a
ld a, [wCurItem]
cp PARK_BALL
call nz, ReturnToBattle_UseBall
+
ld hl, wOptions
res NO_TEXT_SCROLL, [hl]
- ld hl, Text_UsedItem ; $7884
+ ld hl, ItemUsedText
call PrintText
+
ld a, [wEnemyMonCatchRate]
ld b, a
ld a, [wBattleType]
@@ -236,7 +241,8 @@ UltraBall: ; e926
jp z, .catch_without_fail
ld a, [wCurItem]
ld c, a
- ld hl, BallMultiplierFunctionTable ; $6c73
+ ld hl, BallMultiplierFunctionTable
+
.get_multiplier_loop
ld a, [hli]
cp $ff
@@ -260,8 +266,10 @@ UltraBall: ; e926
cp LEVEL_BALL
ld a, b
jp z, .skip_hp_calc
+
ld a, b
ldh [hMultiplicand + 2], a
+
ld hl, wEnemyMonHP
ld b, [hl]
inc hl
@@ -270,24 +278,19 @@ UltraBall: ; e926
ld d, [hl]
inc hl
ld e, [hl]
-; (3 * MaxHP - 2 * CurHP) / (3 * MaxHP) * level
sla c
rl b
+
ld h, d
ld l, e
add hl, de
add hl, de
ld d, h
ld e, l
-; This routine is buggy. The intention is to get de, the Max HP score,
-; to be an 8-bit number. To do this, we divide both bc and de by 4.
-; It only does this division once, and doesn't check to make sure that
-; e is not zero. In addition to passing along a divide-by-zero error,
-; this could also cause an unusually small denominator to be passed,
-; sending the resulting catch rate through the floor.
ld a, d
and a
- jr z, .okay_hp_div
+ jr z, .okay_1
+
srl d
rr e
srl d
@@ -296,11 +299,12 @@ UltraBall: ; e926
rr c
srl b
rr c
+
ld a, c
and a
- jr nz, .okay_hp_div
+ jr nz, .okay_1
ld c, $1
-.okay_hp_div
+.okay_1
ld b, e
push bc
@@ -316,7 +320,7 @@ UltraBall: ; e926
ld a, b
ldh [hDivisor], a
- ld b, $4
+ ld b, 4
call Divide
ldh a, [hQuotient + 3]
@@ -332,62 +336,63 @@ UltraBall: ; e926
ld b, a
ld a, [wEnemyMonStatus]
and 1 << FRZ | SLP
- ld c, $a
- jr nz, .add_status
+ ld c, 10
+ jr nz, .addstatus
; ld a, [wEnemyMonStatus]
and a
- ld c, $5
- jr nz, .add_status
- ld c, $0
-.add_status
+ ld c, 5
+ jr nz, .addstatus
+ ld c, 0
+.addstatus
ld a, b
add c
- jr nc, .max_catch_rate
+ jr nc, .max_1
ld a, $ff
-.max_catch_rate
- ld d, a
- push de
-
- ; BUG: farcall overwrites a,
- ; and GetItemHeldEffect takes b anyway.
-
- ; This is probably the reason
- ; the HELD_CATCH_CHANCE effect
- ; is never used.
+.max_1
+ ; BUG: farcall overwrites a, and GetItemHeldEffect takes b anyway.
+ ; This is probably the reason the HELD_CATCH_CHANCE effect is never used.
; Uncomment the line below to fix.
-
+ ld d, a
+ push de
ld a, [wBattleMonItem]
; ld b, a
- farcall GetItemHeldEffect ; d:7e9b
+ farcall GetItemHeldEffect
ld a, b
cp HELD_CATCH_CHANCE
pop de
ld a, d
- jr nz, .skip_hp_calc
+ jr nz, .max_2
add c
- jr nc, .skip_hp_calc
+ jr nc, .max_2
ld a, $ff
+.max_2
+
.skip_hp_calc
ld b, a
- ld [wCurHPAnimMaxHP], a
+ ld [wBuffer1], a
call Random
+
cp b
- ld a, $0
+ ld a, 0
jr z, .catch_without_fail
- jr nc, .asm_ea23
+ jr nc, .fail_to_catch
+
.catch_without_fail
ld a, [wEnemyMonSpecies]
-.asm_ea23
+
+.fail_to_catch
ld [wWildMon], a
ld c, 20
call DelayFrames
+
ld a, [wCurItem]
- cp POKE_BALL + 1
- jr c, .asm_ea34
- ld a, $5
-.asm_ea34
+ cp POKE_BALL + 1 ; Assumes Master/Ultra/Great come before
+ jr c, .not_kurt_ball
+ ld a, POKE_BALL
+.not_kurt_ball
ld [wBattleAnimParam], a
+
ld de, ANIM_THROW_POKE_BALL
ld a, e
ld [wFXAnimID], a
@@ -398,23 +403,25 @@ UltraBall: ; e926
ld [wBuffer2], a
ld [wNumHits], a
predef PlayBattleAnim
+
ld a, [wWildMon]
and a
jr nz, .caught
ld a, [wBuffer2]
cp $1
- ld hl, Text_ThePokemonBrokeFree ; $6e09
- jp z, .break_free
+ ld hl, BallBrokeFreeText
+ jp z, .shake_and_break_free
cp $2
- ld hl, Text_AppearedToBeCaught ; $6e0e
- jp z, .break_free
+ ld hl, BallAppearedCaughtText
+ jp z, .shake_and_break_free
cp $3
- ld hl, Text_AarghAlmostHadIt ; $6e13
- jp z, .break_free
+ ld hl, BallAlmostHadItText
+ jp z, .shake_and_break_free
cp $4
- ld hl, Text_ShootItWasSoCloseToo ; $6e18
- jp z, .break_free
+ ld hl, BallSoCloseText
+ jp z, .shake_and_break_free
.caught
+
ld hl, wEnemyMonStatus
ld a, [hli]
push af
@@ -432,6 +439,10 @@ UltraBall: ; e926
ld a, [hl]
push af
set SUBSTATUS_TRANSFORMED, [hl]
+
+; This code is buggy. Any wild Pokémon that has Transformed will be
+; caught as a Ditto, even if it was something else like Mew.
+; To fix, do not set [wTempEnemyMonSpecies] to DITTO.
bit SUBSTATUS_TRANSFORMED, a
jr nz, .ditto
jr .not_ditto
@@ -446,16 +457,19 @@ UltraBall: ; e926
ld hl, wEnemyBackupDVs
ld a, [wEnemyMonDVs]
ld [hli], a
- ld a, [wEnemyMonMovesEnd + 1]
+ ld a, [wEnemyMonDVs + 1]
ld [hl], a
+
.load_data
ld a, [wTempEnemyMonSpecies]
ld [wCurPartySpecies], a
ld a, [wEnemyMonLevel]
ld [wCurPartyLevel], a
farcall LoadEnemyMon
+
pop af
ld [wEnemySubStatus5], a
+
pop hl
pop af
ld [hl], a
@@ -467,162 +481,205 @@ UltraBall: ; e926
dec hl
pop af
ld [hl], a
+
ld hl, wEnemySubStatus5
bit SUBSTATUS_TRANSFORMED, [hl]
- jr nz, .transformed
+ jr nz, .Transformed
ld hl, wWildMonMoves
ld de, wEnemyMonMoves
ld bc, NUM_MOVES
call CopyBytes
+
ld hl, wWildMonPP
ld de, wEnemyMonPP
ld bc, NUM_MOVES
call CopyBytes
-.transformed
+
+.Transformed:
ld a, [wEnemyMonSpecies]
ld [wWildMon], a
ld [wCurPartySpecies], a
- ld [wd151], a
+ ld [wTempSpecies], a
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
- jp z, .finish_tutorial
- ld hl, Text_GotchaMonWasCaught ; $6e1d
+ jp z, .FinishTutorial
+
+ ld hl, Text_GotchaMonWasCaught
call PrintText
+
call ClearSprites
- ld a, [wd151]
+
+ ld a, [wTempSpecies]
dec a
call CheckCaughtMon
+
ld a, c
push af
- ld a, [wd151]
+ ld a, [wTempSpecies]
dec a
call SetSeenAndCaughtMon
pop af
and a
- jr nz, .skip_dex
+ jr nz, .skip_pokedex
+
call CheckReceivedDex
- jr z, .skip_dex
- ld hl, Text_MonNewlyAddedToPokedex ; $6e44
+ jr z, .skip_pokedex
+
+ ld hl, NewDexDataText
call PrintText
+
call ClearSprites
+
ld a, [wEnemyMonSpecies]
- ld [wd151], a
+ ld [wTempSpecies], a
predef NewPokedexEntry
-.skip_dex
+
+.skip_pokedex
ld a, [wBattleType]
cp BATTLETYPE_CONTEST
jp z, .catch_bug_contest_mon
ld a, [wPartyCount]
cp PARTY_LENGTH
- jr z, .send_mon_to_pc
- xor a
+ jr z, .SendToPC
+
+ xor a ; PARTYMON
ld [wMonType], a
call ClearSprites
+
predef TryAddMonToParty
+
ld a, [wCurItem]
cp FRIEND_BALL
- jr nz, .skip_party_mon_friend_ball
+ jr nz, .SkipPartyMonFriendBall
+
ld a, [wPartyCount]
dec a
ld hl, wPartyMon1Happiness
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
+
ld a, FRIEND_BALL_HAPPINESS
ld [hl], a
-.skip_party_mon_friend_ball
- ld hl, Text_AskNicknameNewlyCaughtMon ; $6e49
+
+.SkipPartyMonFriendBall:
+ ld hl, AskGiveNicknameText
call PrintText
+
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
+
call YesNoBox
- jp c, .end_ball_function
+ jp c, .return_from_capture
+
ld a, [wPartyCount]
dec a
ld [wCurPartyMon], a
- ld hl, wPartyMon1Nickname
+ ld hl, wPartyMonNicknames
ld bc, MON_NAME_LENGTH
call AddNTimes
+
ld d, h
ld e, l
push de
- xor a
+ xor a ; PARTYMON
ld [wMonType], a
- ld b, $0
+ ld b, NAME_MON
farcall NamingScreen
+
call RotateThreePalettesRight
+
call LoadStandardFont
+
pop hl
ld de, wStringBuffer1
call InitName
- jp .end_ball_function
-.send_mon_to_pc
+ jp .return_from_capture
+
+.SendToPC:
call ClearSprites
+
predef SendMonIntoBox
+
ld a, BANK(sBoxCount)
call OpenSRAM
+
ld a, [sBoxCount]
cp MONS_PER_BOX
- jr nz, .not_full_yet
+ jr nz, .BoxNotFullYet
ld hl, wBattleResult
- set 7, [hl]
-.not_full_yet
+ set BATTLERESULT_BOX_FULL, [hl]
+.BoxNotFullYet:
ld a, [wCurItem]
cp FRIEND_BALL
- jr nz, .skip_box_mon_friend_ball
+ jr nz, .SkipBoxMonFriendBall
+ ; The captured mon is now first in the box
ld a, FRIEND_BALL_HAPPINESS
ld [sBoxMon1Happiness], a
-.skip_box_mon_friend_ball
+.SkipBoxMonFriendBall:
call CloseSRAM
- ld hl, Text_AskNicknameNewlyCaughtMon ; $6e49
+
+ ld hl, AskGiveNicknameText
call PrintText
+
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
+
call YesNoBox
- jr c, .init_name_in_sram
+ jr c, .SkipBoxMonNickname
+
xor a
ld [wCurPartyMon], a
- ld a, $2
+ ld a, BOXMON
ld [wMonType], a
ld de, wMonOrItemNameBuffer
- ld b, $0
+ ld b, NAME_MON
farcall NamingScreen
- ld a, $1
+
+ ld a, BANK(sBoxMonNicknames)
call OpenSRAM
ld hl, wMonOrItemNameBuffer
ld de, sBoxMonNicknames
ld bc, MON_NAME_LENGTH
call CopyBytes
+
ld hl, sBoxMonNicknames
ld de, wStringBuffer1
call InitName
+
call CloseSRAM
-.init_name_in_sram
- ld a, $1
+
+.SkipBoxMonNickname:
+ ld a, BANK(sBoxMonNicknames)
call OpenSRAM
ld hl, sBoxMonNicknames
ld de, wMonOrItemNameBuffer
ld bc, MON_NAME_LENGTH
call CopyBytes
+
call CloseSRAM
- ld hl, Text_SentToBillsPC ; $6e3f
+
+ ld hl, BallSentToPCText
call PrintText
+
call RotateThreePalettesRight
call LoadStandardFont
- jr .end_ball_function
+ jr .return_from_capture
.catch_bug_contest_mon
- farcall BugContest_SetCaughtContestMon ; same bank
- jr .end_ball_function
+ farcall BugContest_SetCaughtContestMon
+ jr .return_from_capture
-.finish_tutorial
- ld hl, Text_GotchaMonWasCaught ; $6e1d
-.break_free
+.FinishTutorial:
+ ld hl, Text_GotchaMonWasCaught
+
+.shake_and_break_free
call PrintText
call ClearSprites
-.end_ball_function
+
+.return_from_capture
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
ret z
@@ -630,11 +687,14 @@ UltraBall: ; e926
ret z
cp BATTLETYPE_CONTEST
jr z, .used_park_ball
+
ld a, [wWildMon]
and a
jr z, .toss
+
call ClearBGPalettes
call ClearTilemap
+
.toss
ld hl, wNumItems
inc a
@@ -646,7 +706,9 @@ UltraBall: ; e926
dec [hl]
ret
-BallMultiplierFunctionTable: ; ec73
+BallMultiplierFunctionTable:
+; table of routines that increase or decrease the catch rate based on
+; which ball is used in a certain situation.
dbw ULTRA_BALL, UltraBallMultiplier
dbw GREAT_BALL, GreatBallMultiplier
dbw SAFARI_BALL, SafariBallMultiplier ; Safari Ball, leftover from RBY
@@ -657,9 +719,10 @@ BallMultiplierFunctionTable: ; ec73
dbw MOON_BALL, MoonBallMultiplier
dbw LOVE_BALL, LoveBallMultiplier
dbw PARK_BALL, ParkBallMultiplier
- db $ff
+ db -1 ; end
UltraBallMultiplier:
+; multiply catch rate by 2
sla b
ret nc
ld b, $ff
@@ -668,6 +731,7 @@ UltraBallMultiplier:
GreatBallMultiplier:
SafariBallMultiplier:
ParkBallMultiplier:
+; multiply catch rate by 1.5
ld a, b
srl a
add b
@@ -677,11 +741,16 @@ ParkBallMultiplier:
ret
HeavyBallMultiplier:
- ld a, [wEnemyMon]
+; subtract 20 from catch rate if weight < 102.4 kg
+; else add 0 to catch rate if weight < 204.8 kg
+; else add 20 to catch rate if weight < 307.2 kg
+; else add 30 to catch rate if weight < 409.6 kg
+; else add 40 to catch rate (never happens)
+ ld a, [wEnemyMonSpecies]
dec a
ld hl, PokedexDataPointerTable
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
add hl, de
rlca
@@ -702,27 +771,28 @@ HeavyBallMultiplier:
inc hl
inc hl
call GetFarHalfword
+
srl h
rr l
ld b, h
ld c, l
+
+rept 4
srl b
rr c
+endr
+ call .subbc
+
srl b
rr c
- srl b
- rr c
- srl b
- rr c
- call .sub_bc
- srl b
- rr c
- call .sub_bc
+ call .subbc
+
ld a, h
pop bc
jr .compare
-.sub_bc
+.subbc
+ ; subtract bc from hl
push bc
ld a, b
cpl
@@ -737,9 +807,10 @@ HeavyBallMultiplier:
.compare
ld c, a
- cp 1024 >> 8 ; 102.4 kg
+ cp HIGH(1024) ; 102.4 kg
jr c, .lightmon
- ld hl, .WeightsTable ; $6d18
+
+ ld hl, .WeightsTable
.lookup
ld a, c
cp [hl]
@@ -765,17 +836,19 @@ HeavyBallMultiplier:
ld b, $1
ret
-.WeightsTable
+.WeightsTable:
; weight factor, boost
- db 2048 >> 8, 0
- db 3072 >> 8, 20
- db 4096 >> 8, 30
- db 65280 >> 8, 40
+ db HIGH(2048), 0
+ db HIGH(3072), 20
+ db HIGH(4096), 30
+ db HIGH(65280), 40
LureBallMultiplier:
+; multiply catch rate by 3 if this is a fishing rod battle
ld a, [wBattleType]
cp BATTLETYPE_FISH
ret nz
+
ld a, b
add a
jr c, .asm_ed2d
@@ -795,22 +868,25 @@ MoonBallMultiplier:
ld a, [wTempEnemyMonSpecies]
dec a
ld c, a
- ld b, $0
+ ld b, 0
ld hl, EvosAttacksPointers ; $67bd
add hl, bc
add hl, bc
ld a, BANK(EvosAttacksPointers) ; $10
call GetFarHalfword
pop bc
+
push bc
ld a, BANK(EvosAttacksPointers) ; $10
call GetFarByte
cp EVOLVE_ITEM
pop bc
ret nz
+
inc hl
inc hl
inc hl
+
; Moon Stone's constant from Pokémon Red is used.
; No Pokémon evolve with Burn Heal,
; so Moon Balls always have a catch rate of 1×.
@@ -820,6 +896,7 @@ MoonBallMultiplier:
cp MOON_STONE_RED ; BURN_HEAL
pop bc
ret nz
+
sla b
jr c, .max
sla b
@@ -833,11 +910,15 @@ LoveBallMultiplier:
; This function is buggy.
; Intent: multiply catch rate by 8 if mons are of same species, different sex
; Reality: multiply catch rate by 8 if mons are of same species, same sex
+
+ ; does species match?
ld a, [wTempEnemyMonSpecies]
ld c, a
ld a, [wTempBattleMonSpecies]
cp c
ret nz
+
+ ; check player mon species
push bc
ld a, [wTempBattleMonSpecies]
ld [wCurPartySpecies], a
@@ -896,6 +977,7 @@ FastBallMultiplier:
.asm_edc5
ld a, BANK(FleeMons)
call GetFarByte
+
inc hl
cp $ff
jr z, .asm_eddc
@@ -942,32 +1024,33 @@ LevelBallMultiplier:
; These two texts were carried over from gen 1.
; They are not used in gen 2, and are dummied out.
-Text_ThisMonCantBeCaught:
- text_far Text_ThisMonCantBeCaught_
- db "@"
+BallDodgedText:
+ text_far _BallDodgedText
+ text_end
-Text_YouMissedThePokemon:
- text_far Text_YouMissedThePokemon_
- db "@"
+BallMissedText:
+ text_far _BallMissedText
+ text_end
-Text_ThePokemonBrokeFree:
- text_far Text_ThePokemonBrokeFree_
- db "@"
+BallBrokeFreeText:
+ text_far _BallBrokeFreeText
+ text_end
-Text_AppearedToBeCaught:
- text_far Text_AppearedToBeCaught_
- db "@"
+BallAppearedCaughtText:
+ text_far _BallAppearedCaughtText
+ text_end
-Text_AarghAlmostHadIt:
- text_far Text_AarghAlmostHadIt_
- db "@"
+BallAlmostHadItText:
+ text_far _BallAlmostHadItText
+ text_end
-Text_ShootItWasSoCloseToo:
- text_far Text_ShootItWasSoCloseToo_
- db "@"
+BallSoCloseText:
+ text_far _BallSoCloseText
+ text_end
Text_GotchaMonWasCaught:
- text_far Text_GotchaMonWasCaught_
+ ; Gotcha! @ was caught!@ @
+ text_far Text_BallCaught
text_asm
call WaitSFX
push bc
@@ -977,24 +1060,24 @@ Text_GotchaMonWasCaught:
ld de, MUSIC_CAPTURE
call PlayMusic
pop bc
- ld hl, Text_CaughtMonWaitbutton
+ ld hl, WaitButtonText
ret
-Text_CaughtMonWaitbutton:
- text_far Text_Promptbutton_2
- db "@"
+WaitButtonText:
+ text_far _WaitButtonText
+ text_end
-Text_SentToBillsPC:
- text_far Text_SentToBillsPC_
- db "@"
+BallSentToPCText:
+ text_far _BallSentToPCText
+ text_end
-Text_MonNewlyAddedToPokedex:
- text_far Text_MonNewlyAddedToPokedex_
- db "@"
+NewDexDataText:
+ text_far _NewDexDataText
+ text_end
-Text_AskNicknameNewlyCaughtMon:
- text_far Text_AskNicknameNewlyCaughtMon_
- db "@"
+AskGiveNicknameText:
+ text_far _AskGiveNicknameText
+ text_end
ReturnToBattle_UseBall:
farcall _ReturnToBattle_UseBall
@@ -1028,13 +1111,13 @@ WaterStone: ; ee63
ld a, [wd154]
and a
jr z, .failed
- jp Functionf7dc
+ jp UseDisposableItem
.failed
- call Functionf839
+ call WontHaveAnyEffectMessage
.cancel
xor a
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
ret
@@ -1050,6 +1133,7 @@ Protein: ; ee91
call Functionef2d
ld a, MON_STAT_EXP
call GetPartyParamLocation
+
add hl, bc
ld a, [hl]
cp 100
@@ -1066,15 +1150,19 @@ Protein: ; ee91
ld de, wStringBuffer2
ld bc, ITEM_NAME_LENGTH
call CopyBytes
- call Functionf7c7
- ld hl, Text_StatRoseFromVitamin ; $6efa
+
+ call Play_SFX_FULL_HEAL
+
+ ld hl, ItemStatRoseText
call PrintText
+
ld c, HAPPINESS_USEDITEM
farcall ChangeHappiness
- jp Functionf7dc
+
+ jp UseDisposableItem
Functioneed7:
- ld hl, Text_WontHaveAnyEffect ; $7866
+ ld hl, ItemWontHaveEffectText
call PrintText
jp ClearPalettes
@@ -1085,17 +1173,17 @@ Functioneee0: ; eee0 (3:6ee0)
ld e, l
ld a, MON_STAT_EXP - 1
call GetPartyParamLocation
- ld b, $1
+ ld b, TRUE
predef_jump CalcMonStats
Functioneef3: ; eef3 (3:6ef3)
xor a
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
jp ClearPalettes
-Text_StatRoseFromVitamin:
- text_far Text_StatRoseFromVitamin_
- db "@"
+ItemStatRoseText:
+ text_far _ItemStatRoseText
+ text_end
StatStrings:
dw .health
@@ -1220,7 +1308,7 @@ RareCandy: ; ef68 (3:6f68)
xor a
ld [wForceEvolution], a
farcall EvolvePokemon
- jp Functionf7dc
+ jp UseDisposableItem
HealPowder: ; f003 (3:7003)
ld b, $1
@@ -1231,7 +1319,7 @@ HealPowder: ; f003 (3:7003)
jr nz, .asm_f01f
ld c, $f
farcall ChangeHappiness
- call Functionf81d
+ call LooksBitterMessage
ld a, $0
.asm_f01f
jp Functionf0f4
@@ -1275,9 +1363,9 @@ Functionf030: ; f030 (3:7030)
ld a, b
ld [wPartyMenuActionText], a
call Functionf086
- call Functionf7c7
+ call Play_SFX_FULL_HEAL
call Functionf2cf
- call Functionf7dc
+ call UseDisposableItem
ld a, $0
ret
@@ -1386,7 +1474,7 @@ RevivalHerb: ; f0ff
jr nz, .asm_f11b
ld c, $11
farcall ChangeHappiness
- call Functionf81d
+ call LooksBitterMessage
ld a, $0
.asm_f11b
jp Functionf0f4
@@ -1436,7 +1524,7 @@ Functionf12c: ; f12c (3:712c)
ld a, $f7
ld [wPartyMenuActionText], a
call Functionf2cf
- call Functionf7dc
+ call UseDisposableItem
ld a, $0
ret
@@ -1469,7 +1557,7 @@ Functionf19a: ; f19a (3:719a)
ld a, $f5
ld [wPartyMenuActionText], a
call Functionf2cf
- call Functionf7dc
+ call UseDisposableItem
ld a, $0
ret
@@ -1481,7 +1569,7 @@ BitterBerry: ; f1c0
res 7, [hl]
xor a
ldh [hBattleTurn], a
- call Functionf7d0
+ call UseItemText
ld hl, ConfusedNoMoreText
call StdBattleTextbox
ld a, $0
@@ -1516,7 +1604,7 @@ asm_f1e8:
cp $0
jr nz, .asm_f1fc
farcall ChangeHappiness
- call Functionf81d
+ call LooksBitterMessage
ld a, $0
.asm_f1fc
jp Functionf0f4
@@ -1541,7 +1629,7 @@ Functionf1ff: ; f1ff (3:71ff)
ld a, PARTYMENUTEXT_HEAL_HP
ld [wPartyMenuActionText], a
call Functionf2cf
- call Functionf7dc
+ call UseDisposableItem
ld a, $0
ret
@@ -1564,7 +1652,7 @@ Functionf24f: ; f24f (3:724f)
ld a, [wCurPartySpecies]
cp EGG
jr nz, .asm_f25f
- call Functionf82f
+ call CantUseOnEggMessage
scf
ret
@@ -1636,7 +1724,7 @@ Functionf2cf: ; f2cf (3:72cf)
jp WaitPressAorB_BlinkCursor
Functionf2ef: ; f2ef (3:72ef)
- call Functionf839
+ call WontHaveAnyEffectMessage
jr Functionf2f8
Functionf2f4: ; f2f4 (3:72f4)
@@ -1922,14 +2010,14 @@ Functionf46f: ; f46f (3:746f)
.asm_f496
push bc
- ld hl, Text_MilkDrinkCantBeUsed
+ ld hl, .ItemCantUseOnMonText
call MenuTextboxBackup
pop bc
jr Functionf46f
-Text_MilkDrinkCantBeUsed:
- text_far Text_MilkDrinkCantBeUsed_
- db "@"
+.ItemCantUseOnMonText:
+ text_far _ItemCantUseOnMonText
+ text_end
EscapeRope: ; f4a5 (3:74a5)
xor a
@@ -1937,7 +2025,7 @@ EscapeRope: ; f4a5 (3:74a5)
farcall EscapeRopeFunction ; same bank
ld a, [wFieldMoveSucceeded]
cp $1
- call z, Functionf7dc
+ call z, UseDisposableItem
ret
SuperRepel: ; f4b8 (3:74b8)
@@ -1953,22 +2041,23 @@ Repel: ; f4c0 (3:74c0)
asm_f4c2:
ld a, [wRepelEffect]
and a
- ld hl, Text_RepelsEffectsStillLinger
+ ld hl, RepelUsedEarlierIsStillInEffectText
jp nz, PrintText
+
ld a, b
ld [wRepelEffect], a
- jp Functionf7d0
+ jp UseItemText
-Text_RepelsEffectsStillLinger:
- text_far Text_RepelUsedEarlierIsStillInEffect
- db "@"
+RepelUsedEarlierIsStillInEffectText:
+ text_far _RepelUsedEarlierIsStillInEffectText
+ text_end
XAccuracy: ; f4d8 (3:74d8)
ld hl, wPlayerSubStatus4
bit SUBSTATUS_X_ACCURACY, [hl]
- jp nz, Functionf811
+ jp nz, WontHaveAnyEffect_NotUsedMessage
set SUBSTATUS_X_ACCURACY, [hl]
- jp Functionf7d0
+ jp UseItemText
PokeDoll: ; f4e5 (3:74e5)
ld a, [wBattleMode]
@@ -1978,7 +2067,7 @@ PokeDoll: ; f4e5 (3:74e5)
ld [wForcedSwitch], a
inc a
ld [wBattleResult], a
- jp Functionf7d0
+ jp UseItemText
.asm_f4f6
xor a
@@ -1988,22 +2077,22 @@ PokeDoll: ; f4e5 (3:74e5)
GuardSpec: ; f4fb (3:74fb)
ld hl, wPlayerSubStatus4
bit SUBSTATUS_MIST, [hl]
- jp nz, Functionf811
+ jp nz, WontHaveAnyEffect_NotUsedMessage
set SUBSTATUS_MIST, [hl]
- jp Functionf7d0
+ jp UseItemText
DireHit: ; f508 (3:7508)
ld hl, wPlayerSubStatus4
bit SUBSTATUS_FOCUS_ENERGY, [hl]
- jp nz, Functionf811
+ jp nz, WontHaveAnyEffect_NotUsedMessage
set SUBSTATUS_FOCUS_ENERGY, [hl]
- jp Functionf7d0
+ jp UseItemText
XAttack: ; f515
XDefend: ; f515
XSpecial: ; f515
XSpeed: ; f515
- call Functionf7d0
+ call UseItemText
ld a, [wCurItem]
ld hl, .x_item_table
.asm_f51e
@@ -2022,8 +2111,10 @@ XSpeed: ; f515
ld [wEffectFailed], a
farcall RaiseStat
call WaitSFX
+
farcall BattleCommand_StatUpMessage
farcall BattleCommand_StatUpFailText
+
ld a, [wCurBattleMon]
ld [wCurPartyMon], a
ld c, HAPPINESS_USEDXITEM
@@ -2036,7 +2127,7 @@ XSpeed: ; f515
db X_SPEED, SPEED
db X_SPECIAL, SP_ATTACK
-PokeFlute: ; f55c (3:755c)
+PokeFlute:
ld a, [wBattleMode]
and a
jr nz, .dummy
@@ -2051,7 +2142,7 @@ PokeFlute: ; f55c (3:755c)
call .CureSleep
ld a, [wBattleMode]
- cp $1
+ cp WILD_BATTLE
jr z, .skip_otrainer
ld hl, wOTPartyMon1Status
call .CureSleep
@@ -2068,19 +2159,19 @@ PokeFlute: ; f55c (3:755c)
ld a, [wceed]
and a
- ld hl, Text_NowThatsACatchyTune ; $75bc
+ ld hl, .PlayedFluteText
jp z, PrintText
- ld hl, Text_PlayedThePokeFlute ; $75c6
+ ld hl, .PlayedTheFlute
call PrintText
ld a, [wLowHealthAlarm]
- and $80
+ and 1 << DANGER_ON_F
jr nz, .dummy2
.dummy2
- ld hl, Text_AllSleepingMonWokeUp ; $75c1
+ ld hl, .FluteWakeUpText
jp PrintText
-.CureSleep: ; f5a4 (3:75a4)
+.CureSleep:
ld de, PARTYMON_STRUCT_LENGTH
ld c, PARTY_LENGTH
@@ -2100,16 +2191,17 @@ PokeFlute: ; f55c (3:755c)
jr nz, .loop
ret
-Text_NowThatsACatchyTune:
- text_far Text_NowThatsACatchyTune_
- db "@"
+.PlayedFluteText:
+ text_far _PlayedFluteText
+ text_end
-Text_AllSleepingMonWokeUp:
- text_far Text_AllSleepingMonWokeUp_
- db "@"
+.FluteWakeUpText:
+ text_far _FluteWakeUpText
+ text_end
-Text_PlayedThePokeFlute:
- text_far Text_PlayedThePokeFlute_
+.PlayedTheFlute:
+ ; played the # FLUTE.@ @
+ text_far Text_PlayedPokeFlute
text_asm
ld a, [wBattleMode]
and a
@@ -2125,13 +2217,13 @@ Text_PlayedThePokeFlute:
.terminator db "@"
-CoinCase: ; f5e1 (3:75e1)
- ld hl, Text_CoinCase
+CoinCase:
+ ld hl, .CoinCaseCountText
jp MenuTextboxWaitButton
-Text_CoinCase:
- text_far Text_CoinCase_
- db "@"
+.CoinCaseCountText:
+ text_far _CoinCaseCountText
+ text_end
OldRod: ; f5ec (3:75ec)
ld e, $0
@@ -2171,13 +2263,14 @@ PPUp: ; f606 (3:7606)
jp z, Functionf6f6
cp ELIXER
jp z, Functionf6f6
- ld hl, Text_RaiseThePPOfWhichMove
+ ld hl, RaiseThePPOfWhichMoveText
ld a, [wMovementBufferCount]
cp PP_UP
jr z, .asm_f62e
- ld hl, Text_RestoreThePPOfWhichMove
+ ld hl, RestoreThePPOfWhichMoveText
.asm_f62e
call PrintText
+
ld a, [wCurMoveNum]
push af
xor a
@@ -2188,6 +2281,7 @@ PPUp: ; f606 (3:7606)
ld hl, $62f3
rst FarCall
pop bc
+
ld a, b
ld [wCurMoveNum], a
jr nz, .asm_f60c
@@ -2212,7 +2306,7 @@ PPUp: ; f606 (3:7606)
cp $c0
jr c, .asm_f67e
.asm_f676
- ld hl, Text_PPIsMaxedOut ; $7776
+ ld hl, PPIsMaxedOutText
call PrintText
jr .asm_f614
@@ -2223,12 +2317,13 @@ PPUp: ; f606 (3:7606)
ld a, $1
ld [wd151], a
call Functionf893
- call Functionf7c7
- ld hl, Text_PPsIncreased ; $777b
+ call Play_SFX_FULL_HEAL
+
+ ld hl, PPsIncreasedText
call PrintText
asm_f693:
call ClearPalettes
- jp Functionf7dc
+ jp UseDisposableItem
asm_f699:
ld a, [wBattleMode]
@@ -2244,8 +2339,8 @@ asm_f699:
jr nz, .asm_f6b3
call Functionf6be
.asm_f6b3
- call Functionf7c7
- ld hl, Text_PPWasRestored
+ call Play_SFX_FULL_HEAL
+ ld hl, PPRestoredText
call PrintText
jr asm_f693
@@ -2319,7 +2414,7 @@ Functionf6f6: ; f6f6 (3:76f6)
and a
jp nz, asm_f699
Functionf724: ; f724 (3:7724)
- call Functionf839
+ call WontHaveAnyEffectMessage
Functionf727: ; f727 (3:7727)
call ClearPalettes
xor a
@@ -2366,25 +2461,25 @@ Functionf72f: ; f72f (3:772f)
xor a
ret
-Text_RaiseThePPOfWhichMove:
- text_far Text_RaiseThePPOfWhichMove_
- db "@"
+RaiseThePPOfWhichMoveText:
+ text_far _RaiseThePPOfWhichMoveText
+ text_end
-Text_RestoreThePPOfWhichMove:
- text_far Text_RestoreThePPOfWhichMove_
- db "@"
+RestoreThePPOfWhichMoveText:
+ text_far _RestoreThePPOfWhichMoveText
+ text_end
-Text_PPIsMaxedOut:
- text_far Text_PPIsMaxedOut_
- db "@"
+PPIsMaxedOutText:
+ text_far _PPIsMaxedOutText
+ text_end
-Text_PPsIncreased:
- text_far Text_PPsIncreased_
- db "@"
+PPsIncreasedText:
+ text_far _PPsIncreasedText
+ text_end
-Text_PPWasRestored:
- text_far Text_PPWasRestored_
- db "@"
+PPRestoredText:
+ text_far _PPRestoredText
+ text_end
Squirtbottle: ; f785 (3:7785)
farcall SquirtbottleFunction ; 14:4763
@@ -2403,7 +2498,7 @@ SacredAsh: ; f79a (3:779a)
ld a, [wFieldMoveSucceeded]
cp $1
ret nz
- call Functionf7dc
+ call UseDisposableItem
ret
NormalBox: ; f7aa (3:77aa)
@@ -2414,13 +2509,15 @@ GorgeousBox: ; f7ae (3:77ae)
ld c, DECOFLAG_GOLD_TROPHY_DOLL
asm_f7b0:
farcall SetSpecificDecorationFlag
- ld hl, Text_TrophyInside ; $77bf
+
+ ld hl, .SentTrophyHomeText
call PrintText
- jp Functionf7dc
-Text_TrophyInside:
- text_far Text_TrophyInside_
- db "@"
+ jp UseDisposableItem
+
+.SentTrophyHomeText:
+ text_far _SentTrophyHomeText
+ text_end
AmuletCoin: ; f7c4
BerserkGene: ; f7c4
@@ -2513,29 +2610,29 @@ Twistedspoon: ; f7c4
UpGrade: ; f7c4
WhtApricorn: ; f7c4
YlwApricorn: ; f7c4
- jp Functionf834
+ jp IsntTheTimeMessage
-Functionf7c7: ; f7c7 (3:77c7)
+Play_SFX_FULL_HEAL:
push de
ld de, SFX_FULL_HEAL
call WaitPlaySFX
pop de
ret
-Functionf7d0: ; f7d0 (3:77d0)
- ld hl, Text_UsedItem
+UseItemText:
+ ld hl, ItemUsedText
call PrintText
- call Functionf7c7
+ call Play_SFX_FULL_HEAL
call WaitPressAorB_BlinkCursor
-Functionf7dc: ; f7dc (3:77dc)
- ld hl, wTMsHMsEnd
- ld a, $1
+UseDisposableItem:
+ ld hl, wNumItems
+ ld a, 1
ld [wItemQuantityChangeBuffer], a
jp TossItem
-Functionf7e7: ; f7e7 (3:77e7)
+UseBallInTrainerBattle:
call ReturnToBattle_UseBall
- ld de, Start
+ ld de, ANIM_THROW_POKE_BALL
ld a, e
ld [wFXAnimID], a
ld a, d
@@ -2545,108 +2642,114 @@ Functionf7e7: ; f7e7 (3:77e7)
ldh [hBattleTurn], a
ld [wNumHits], a
predef PlayBattleAnim
- ld hl, Text_BlockedTheBall
+ ld hl, BallBlockedText
call PrintText
- ld hl, Text_DontBeAThief
+ ld hl, BallDontBeAThiefText
call PrintText
- jr Functionf7dc
+ jr UseDisposableItem
-Functionf811: ; f811 (3:7811)
- ld hl, Text_WontHaveAnyEffect
+WontHaveAnyEffect_NotUsedMessage:
+ ld hl, ItemWontHaveEffectText
call PrintText
+
+ ; Item wasn't used.
ld a, $2
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
ret
-Functionf81d: ; f81d (3:781d)
- ld hl, Text_LooksBitter
+LooksBitterMessage:
+ ld hl, ItemLooksBitterText
jp PrintText
-FailToUseBall: ; f823 (3:7823)
- ld hl, Text_CantUseBallBoxIsFull
+Ball_BoxIsFullMessage:
+ ld hl, BallBoxFullText
call PrintText
+
+ ; Item wasn't used.
ld a, $2
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
ret
-Functionf82f: ; f82f (3:782f)
- ld hl, Text_CantUseOnEgg
- jr asm_f84b
+CantUseOnEggMessage:
+ ld hl, ItemCantUseOnEggText
+ jr CantUseItemMessage
-Functionf834: ; f834 (3:7834)
- ld hl, Text_IsntTheTimeToUseThat
- jr asm_f84b
+IsntTheTimeMessage:
+ ld hl, ItemOakWarningText
+ jr CantUseItemMessage
-Functionf839: ; f839 (3:7839)
- ld hl, Text_WontHaveAnyEffect
- jr asm_f84b
+WontHaveAnyEffectMessage:
+ ld hl, ItemWontHaveEffectText
+ jr CantUseItemMessage
-Functionf83e:
- ld hl, Text_BelongsToSomeoneElse
- jr asm_f84b
+BelongsToSomeoneElseMessage:
+ ld hl, ItemBelongsToSomeoneElseText
+ jr CantUseItemMessage
-Functionf843:
- ld hl, Text_CyclingIsntAllowed
- jr asm_f84b
+CyclingIsntAllowedMessage:
+ ld hl, NoCyclingText
+ jr CantUseItemMessage
-Functionf848:
- ld hl, Text_CantGetOnYourItemNow
-asm_f84b:
+CantGetOnYourBikeMessage:
+ ld hl, ItemCantGetOnText
+
+CantUseItemMessage:
+; Item couldn't be used.
xor a
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
jp PrintText
-Text_LooksBitter:
- text_far Text_LooksBitter_
- db "@"
+ItemLooksBitterText:
+ text_far _ItemLooksBitterText
+ text_end
-Text_CantUseOnEgg:
- text_far Text_CantUseOnEgg_
- db "@"
+ItemCantUseOnEggText:
+ text_far _ItemCantUseOnEggText
+ text_end
-Text_IsntTheTimeToUseThat:
- text_far Text_IsntTheTimeToUseThat_
- db "@"
+ItemOakWarningText:
+ text_far _ItemOakWarningText
+ text_end
-Text_BelongsToSomeoneElse:
- text_far Text_BelongsToSomeoneElse_
- db "@"
+ItemBelongsToSomeoneElseText:
+ text_far _ItemBelongsToSomeoneElseText
+ text_end
-Text_WontHaveAnyEffect:
- text_far Text_WontHaveAnyEffect_
- db "@"
+ItemWontHaveEffectText:
+ text_far _ItemWontHaveEffectText
+ text_end
-Text_BlockedTheBall:
- text_far Text_BlockedTheBall_
- db "@"
+BallBlockedText:
+ text_far _BallBlockedText
+ text_end
-Text_DontBeAThief:
- text_far Text_DontBeAThief_
- db "@"
+BallDontBeAThiefText:
+ text_far _BallDontBeAThiefText
+ text_end
-Text_CyclingIsntAllowed:
- text_far Text_CyclingIsntAllowed_
- db "@"
+NoCyclingText:
+ text_far _NoCyclingText
+ text_end
-Text_CantGetOnYourItemNow:
- text_far Text_CantGetOnYourItemNow_
- db "@"
+ItemCantGetOnText:
+ text_far _ItemCantGetOnText
+ text_end
-Text_CantUseBallBoxIsFull:
- text_far Text_CantUseBallBoxIsFull_
- db "@"
+BallBoxFullText:
+ text_far _BallBoxFullText
+ text_end
-Text_UsedItem:
- text_far Text_UsedItem_
- db "@"
+ItemUsedText:
+ text_far _ItemUsedText
+ text_end
-Text_GotOnItem:
- text_far Text_GotOnItem_
- db "@"
+ItemGotOnText:
+ text_far _ItemGotOnText
+ text_end
-Text_GotOffItem:
- text_far Text_GotOffItem_
- db "@"
+ItemGotOffText:
+ text_far _ItemGotOffText
+ text_end
Functionf893: ; f893 (3:7893)
ld a, $2
diff --git a/engine/items/pack.asm b/engine/items/pack.asm
index 76b0f5e7..e7caceca 100755
--- a/engine/items/pack.asm
+++ b/engine/items/pack.asm
@@ -1,62 +1,77 @@
+; Pack.Jumptable and BattlePack.Jumptable indexes
+ const_def
+ const PACKSTATE_INITGFX ; 0
+ const PACKSTATE_INITITEMSPOCKET ; 1
+ const PACKSTATE_ITEMSPOCKETMENU ; 2
+ const PACKSTATE_INITBALLSPOCKET ; 3
+ const PACKSTATE_BALLSPOCKETMENU ; 4
+ const PACKSTATE_INITKEYITEMSPOCKET ; 5
+ const PACKSTATE_KEYITEMSPOCKETMENU ; 6
+ const PACKSTATE_INITTMHMPOCKET ; 7
+ const PACKSTATE_TMHMPOCKETMENU ; 8
+ const PACKSTATE_QUITNOSCRIPT ; 9
+ const PACKSTATE_QUITRUNSCRIPT ; 10
+
Pack:
ld hl, wOptions
set NO_TEXT_SCROLL, [hl]
- call Function10aba
-.asm_10438
+ call InitPackBuffers
+.loop
call JoyTextDelay
- ld a, [wce63]
+ ld a, [wJumptableIndex]
bit 7, a
- jr nz, .asm_1044a
- call Function10456
+ jr nz, .done
+ call .RunJumptable
call DelayFrame
- jr .asm_10438
+ jr .loop
-.asm_1044a
- ld a, [wce65]
+.done
+ ld a, [wCurPocket]
ld [wLastPocket], a
ld hl, wOptions
res NO_TEXT_SCROLL, [hl]
ret
-Function10456: ; 10456 (4:4456)
- ld a, [wce63]
- ld hl, .Jumptable ; $4460
- call Function10c9b
+.RunJumptable:
+ ld a, [wJumptableIndex]
+ ld hl, .Jumptable
+ call Pack_GetJumptablePointer
jp hl
-.Jumptable
- dw Pack_InitGFX
- dw Pack_InitItemsPocket
- dw Pack_ItemsPocketMenu
- dw Pack_InitBallsPocket
- dw Pack_BallsPocketMenu
- dw Pack_InitKeyItemsPocket
- dw Pack_KeyItemsPocketMenu
- dw Pack_InitTMHMPocket
- dw Pack_TMHMPocketMenu
- dw Pack_ExitNoScript
- dw Pack_ExitRunScript
-
-Pack_InitGFX:
+.Jumptable:
+; entries correspond to PACKSTATE_* constants
+ dw .InitGFX ; 0
+ dw .InitItemsPocket ; 1
+ dw .ItemsPocketMenu ; 2
+ dw .InitBallsPocket ; 3
+ dw .BallsPocketMenu ; 4
+ dw .InitKeyItemsPocket ; 5
+ dw .KeyItemsPocketMenu ; 6
+ dw .InitTMHMPocket ; 7
+ dw .TMHMPocketMenu ; 8
+ dw Pack_QuitNoScript ; 9
+ dw Pack_QuitRunScript ; 10
+
+.InitGFX:
xor a
ldh [hBGMapMode], a
- call Function10d70
- ld a, [wce64]
- ld [wce63], a
- call Function10e5b
+ call Pack_InitGFX
+ ld a, [wPackJumptableIndex]
+ ld [wJumptableIndex], a
+ call Pack_InitColors
ret
-Pack_InitItemsPocket:
- xor a
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitItemsPocket:
+ xor a ; ITEM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-Pack_ItemsPocketMenu:
- ld hl, ItemsPocketMenuDataHeader
+.ItemsPocketMenu:
+ ld hl, ItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -67,25 +82,24 @@ Pack_ItemsPocketMenu:
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
-.asm_104b7
- ld b, $7
- ld c, $3
- call Function10cef
+ ld b, PACKSTATE_INITTMHMPOCKET ; left
+ ld c, PACKSTATE_INITBALLSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function105f5
+ call .ItemBallsKey_LoadSubmenu
ret
-Pack_InitKeyItemsPocket:
- ld a, $2
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitKeyItemsPocket:
+ ld a, KEY_ITEM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-Pack_KeyItemsPocketMenu:
- ld hl, KeyItemsPocketMenuDataHeader ; $4e9a
+.KeyItemsPocketMenu:
+ ld hl, KeyItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wKeyItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -96,42 +110,42 @@ Pack_KeyItemsPocketMenu:
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
- ld b, $3
- ld c, $7
- call Function10cef
+ ld b, PACKSTATE_INITBALLSPOCKET ; left
+ ld c, PACKSTATE_INITTMHMPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function105f5
+ call .ItemBallsKey_LoadSubmenu
ret
-Pack_InitTMHMPocket:
- ld a, $3
- ld [wce65], a
- call Function10e51
- call Function10dd6
+.InitTMHMPocket:
+ ld a, TM_HM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
xor a
ldh [hBGMapMode], a
- call Function10cca
- call Function10c96
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-Pack_TMHMPocketMenu:
+.TMHMPocketMenu:
farcall TMHMPocket
- ld b, $5
- ld c, $1
- call Function10cef
+ ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
+ ld c, PACKSTATE_INITITEMSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
farcall _CheckTossableItem
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_1053a
- ld hl, TMHMPocketSubmenuDataHeader_Give ; $456b
- ld de, TMHMPocketSubmenuJumptable_Give ; $4583
- jr .asm_10540
-
-.asm_1053a
- ld hl, TMHMPocketSubmenuDataHeader_NoGive ; $4554
- ld de, TMHMPocketSubmenuJumptable_NoGive ; $4567
-.asm_10540
+ jr nz, .use_quit
+ ld hl, .MenuHeader2
+ ld de, .Jumptable2
+ jr .load_jump
+
+.use_quit
+ ld hl, .MenuHeader1
+ ld de, .Jumptable1
+.load_jump
push de
call LoadMenuHeader
call VerticalMenu
@@ -140,76 +154,74 @@ Pack_TMHMPocketMenu:
ret c
ld a, [wMenuCursorY]
dec a
- call Function10c9b
+ call Pack_GetJumptablePointer
jp hl
-TMHMPocketSubmenuDataHeader_NoGive:
- db $40
- db 07, 00
- db 11, 06
- dw .MenuData2
- db 1
+.MenuHeader1:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 7, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData_1
+ db 1 ; default option
-.MenuData2:
- db $c0
- db 2
+.MenuData_1:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
+ db 2 ; items
db "USE@"
db "QUIT@"
-TMHMPocketSubmenuJumptable_NoGive:
- dw UseTMorHM
+.Jumptable1:
+ dw .UseItem
dw QuitItemSubmenu
-TMHMPocketSubmenuDataHeader_Give:
- db $40
- db 05, 00
- db 11, 06
- dw .MenuData2
- db 1
+.MenuHeader2:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 5, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData_2
+ db 1 ; default option
-.MenuData2:
- db $c0
- db 3
+.MenuData_2:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
+ db 3 ; items
db "USE@"
db "GIVE@"
db "QUIT@"
-TMHMPocketSubmenuJumptable_Give:
- dw UseTMorHM
+.Jumptable2:
+ dw .UseItem
dw GiveItem
dw QuitItemSubmenu
-UseTMorHM:
+.UseItem:
farcall AskTeachTMHM
ret c
farcall ChooseMonToLearnTMHM
- jr c, .asm_105a9
+ jr c, .declined
ld hl, wOptions
ld a, [hl]
push af
- res 4, [hl]
+ res NO_TEXT_SCROLL, [hl]
farcall TeachTMHM
pop af
ld [wOptions], a
-.asm_105a9
+.declined
xor a
ldh [hBGMapMode], a
- call Function10d70
- call Function10cca
- call Function10e5b
+ call Pack_InitGFX
+ call WaitBGMap_DrawPackGFX
+ call Pack_InitColors
ret
-Pack_InitBallsPocket:
- ld a, $1
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitBallsPocket:
+ ld a, BALL_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-Pack_BallsPocketMenu:
- ld hl, BallsPocketMenuDataHeader ; $4eca
+.BallsPocketMenu:
+ ld hl, BallsPocketMenuHeader
call CopyMenuHeader
ld a, [wBallsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -220,71 +232,71 @@ Pack_BallsPocketMenu:
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
- ld b, $1
- ld c, $5
- call Function10cef
+ ld b, PACKSTATE_INITITEMSPOCKET ; left
+ ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function105f5
+ call .ItemBallsKey_LoadSubmenu
ret
-Function105f5: ; 105f5 (4:45f5)
+.ItemBallsKey_LoadSubmenu:
farcall _CheckTossableItem
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_10629
+ jr nz, .tossable
farcall CheckSelectableItem
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_1061b
+ jr nz, .selectable
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_10637
- jr .asm_10657
+ jr nz, .usable
+ jr .unusable
-.asm_1061b
+.selectable
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_1063f
- jr .asm_1065f
+ jr nz, .selectable_usable
+ jr .selectable_unusable
-.asm_10629
+.tossable
farcall CheckSelectableItem
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_10647
- jr .asm_1064f
-
-.asm_10637
- ld hl, ItemSubmenuDataHeader_UseGiveTossSelQuit ; $4679
- ld de, ItemSubmenuJumptable_UseGiveTossSelQuit ; $469a
- jr .asm_10665
-
-.asm_1063f
- ld hl, ItemSubmenuDataHeader_UseGiveTossQuit ; $46a4
- ld de, ItemSubmenuJumptable_UseGiveTossQuit ; $46c1
- jr .asm_10665
-
-.asm_10647
- ld hl, ItemSubmenuDataHeader_UseQuit ; $46c9
- ld de, ItemSubmenuJumptable_UseQuit ; $46dc
- jr .asm_10665
-
-.asm_1064f
- ld hl, ItemSubmenuDataHeader_UseSelQuit ; $46e0
- ld de, ItemSubmenuJumptable_UseSelQuit ; $46f7
- jr .asm_10665
-
-.asm_10657
- ld hl, ItemSubmenuDataHeader_GiveTossSelQuit ; $46fd
- ld de, ItemSubmenuJumptable_GiveTossSelQuit ; $471a
- jr .asm_10665
-
-.asm_1065f
- ld hl, ItemSubmenuDataHeader_GiveTossQuit ; $4722
- ld de, ItemSubmenuJumptable_GiveTossQuit ; $473b
-.asm_10665
+ jr nz, .tossable_selectable
+ jr .tossable_unselectable
+
+.usable
+ ld hl, MenuHeader_UsableKeyItem
+ ld de, Jumptable_UseGiveTossRegisterQuit
+ jr .build_menu
+
+.selectable_usable
+ ld hl, MenuHeader_UsableItem
+ ld de, Jumptable_UseGiveTossQuit
+ jr .build_menu
+
+.tossable_selectable
+ ld hl, MenuHeader_UnusableItem
+ ld de, Jumptable_UseQuit
+ jr .build_menu
+
+.tossable_unselectable
+ ld hl, MenuHeader_UnusableKeyItem
+ ld de, Jumptable_UseRegisterQuit
+ jr .build_menu
+
+.unusable
+ ld hl, MenuHeader_HoldableKeyItem
+ ld de, Jumptable_GiveTossRegisterQuit
+ jr .build_menu
+
+.selectable_unusable
+ ld hl, MenuHeader_HoldableItem
+ ld de, Jumptable_GiveTossQuit
+.build_menu
push de
call LoadMenuHeader
call VerticalMenu
@@ -293,18 +305,17 @@ Function105f5: ; 105f5 (4:45f5)
ret c
ld a, [wMenuCursorY]
dec a
- call Function10c9b
+ call Pack_GetJumptablePointer
jp hl
-ItemSubmenuDataHeader_UseGiveTossSelQuit:
- db $40 ; flags
- db 02, 00 ; start coords
- db 12, 06 ; end coords
- dw .MenuData2
+MenuHeader_UsableKeyItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 2, SCREEN_WIDTH - 14, TEXTBOX_Y
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 5 ; items
db "USE@"
db "GIVE@"
@@ -312,106 +323,101 @@ ItemSubmenuDataHeader_UseGiveTossSelQuit:
db "SEL@"
db "QUIT@"
-ItemSubmenuJumptable_UseGiveTossSelQuit:
+Jumptable_UseGiveTossRegisterQuit:
dw UseItem
dw GiveItem
dw TossMenu
dw RegisterItem
dw QuitItemSubmenu
-ItemSubmenuDataHeader_UseGiveTossQuit:
- db $40 ; flags
- db 03, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+MenuHeader_UsableItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 3, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 4 ; items
db "USE@"
db "GIVE@"
db "TOSS@"
db "QUIT@"
-ItemSubmenuJumptable_UseGiveTossQuit:
+Jumptable_UseGiveTossQuit:
dw UseItem
dw GiveItem
dw TossMenu
dw QuitItemSubmenu
-ItemSubmenuDataHeader_UseQuit:
- db %01000000 ; flags
- db 07, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+MenuHeader_UnusableItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 7, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "USE@"
db "QUIT@"
-ItemSubmenuJumptable_UseQuit:
+Jumptable_UseQuit:
dw UseItem
dw QuitItemSubmenu
-ItemSubmenuDataHeader_UseSelQuit:
- db %01000000 ; flags
- db 05, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+MenuHeader_UnusableKeyItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 5, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "USE@"
db "SEL@"
db "QUIT@"
-ItemSubmenuJumptable_UseSelQuit:
+Jumptable_UseRegisterQuit:
dw UseItem
dw RegisterItem
dw QuitItemSubmenu
-ItemSubmenuDataHeader_GiveTossSelQuit:
- db $40 ; flags
- db 03, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+MenuHeader_HoldableKeyItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 3, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 4 ; items
db "GIVE@"
db "TOSS@"
db "SEL@"
db "QUIT@"
-ItemSubmenuJumptable_GiveTossSelQuit:
+Jumptable_GiveTossRegisterQuit:
dw GiveItem
dw TossMenu
dw RegisterItem
dw QuitItemSubmenu
-ItemSubmenuDataHeader_GiveTossQuit:
- db $40 ; flags
- db 05, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+MenuHeader_HoldableItem:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 5, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .MenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.MenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 3 ; items
db "GIVE@"
db "TOSS@"
db "QUIT@"
-ItemSubmenuJumptable_GiveTossQuit:
+Jumptable_GiveTossQuit:
dw GiveItem
dw TossMenu
dw QuitItemSubmenu
@@ -419,102 +425,103 @@ ItemSubmenuJumptable_GiveTossQuit:
UseItem:
farcall CheckItemMenu
ld a, [wItemAttributeParamBuffer]
- ld hl, .Jumptable
+ ld hl, .dw
rst JumpTable
ret
-.Jumptable
- dw .NotTheTime
- dw .NotTheTime
- dw .NotTheTime
- dw .NotTheTime
- dw .Current
- dw .Party
- dw .Field
+.dw
+; entries correspond to ITEMMENU_* constants
+ dw .Oak ; ITEMMENU_NOUSE
+ dw .Oak
+ dw .Oak
+ dw .Oak
+ dw .Current ; ITEMMENU_CURRENT
+ dw .Party ; ITEMMENU_PARTY
+ dw .Field ; ITEMMENU_CLOSE
-.NotTheTime
- ld hl, Text_ThisIsntTheTime
- call Function10cb9
+.Oak:
+ ld hl, OakThisIsntTheTimeText
+ call Pack_PrintTextNoScroll
ret
-.Current
+.Current:
call DoItemEffect
ret
-.Party
+.Party:
ld a, [wPartyCount]
and a
- jr z, .no_pokemon
+ jr z, .NoPokemon
call DoItemEffect
xor a
ldh [hBGMapMode], a
- call Function10d70
- call Function10cca
- call Function10e5b
+ call Pack_InitGFX
+ call WaitBGMap_DrawPackGFX
+ call Pack_InitColors
ret
-.no_pokemon
- ld hl, Text_YouDontHaveAPokemon
- call Function10cb9
+.NoPokemon:
+ ld hl, YouDontHaveAMonText
+ call Pack_PrintTextNoScroll
ret
-.Field
+.Field:
call DoItemEffect
- ld a, [wFieldMoveSucceeded]
+ ld a, [wItemEffectSucceeded]
and a
- jr z, .NotTheTime
- ld a, $a
- ld [wce63], a
+ jr z, .Oak
+ ld a, PACKSTATE_QUITRUNSCRIPT
+ ld [wJumptableIndex], a
ret
TossMenu:
- ld hl, Text_ThrowAwayHowMany
- call Function10cb9
- farcall SelectQuantityToToss ; 9:4f20
+ ld hl, AskThrowAwayText
+ call Pack_PrintTextNoScroll
+ farcall SelectQuantityToToss
push af
call ExitMenu
pop af
- jr c, .asm_107cc
- call Function10e38
- ld hl, Text_ConfirmThrowAway
+ jr c, .finish
+ call Pack_GetItemName
+ ld hl, AskQuantityThrowAwayText
call MenuTextbox
call YesNoBox
push af
call ExitMenu
pop af
- jr c, .asm_107cc
- ld hl, wTMsHMsEnd
+ jr c, .finish
+ ld hl, wNumItems
ld a, [wCurItemQuantity]
call TossItem
- call Function10e38
- ld hl, Text_ThrewAway
- call Function10cb9
-.asm_107cc
+ call Pack_GetItemName
+ ld hl, ThrewAwayText
+ call Pack_PrintTextNoScroll
+.finish
ret
-Function107cd:
- ld a, [wce65]
- and a
- jr z, .asm_107e2
- dec a
- jr z, .asm_107da
- dec a
- jr z, .asm_107ea
+Unreferenced_ResetPocketCursorPositions:
+ ld a, [wCurPocket]
+ and a ; ITEM_POCKET
+ jr z, .items
+ dec a ; BALL_POCKET
+ jr z, .balls
+ dec a ; KEY_ITEM_POCKET
+ jr z, .key
ret
-.asm_107da
+.balls
xor a
ld [wBallsPocketCursor], a
ld [wBallsPocketScrollPosition], a
ret
-.asm_107e2
+.items
xor a
ld [wItemsPocketCursor], a
ld [wItemsPocketScrollPosition], a
ret
-.asm_107ea
+.key
xor a
ld [wKeyItemsPocketCursor], a
ld [wKeyItemsPocketScrollPosition], a
@@ -524,156 +531,156 @@ RegisterItem:
farcall CheckSelectableItem
ld a, [wItemAttributeParamBuffer]
and a
- jr nz, .asm_10826
- ld a, [wce65]
+ jr nz, .cant_register
+ ld a, [wCurPocket]
rrca
rrca
- and $c0
+ and REGISTERED_POCKET
ld b, a
ld a, [wCurItemQuantity]
inc a
- and $3f
+ and REGISTERED_NUMBER
or b
ld [wWhichRegisteredItem], a
ld a, [wCurItem]
ld [wRegisteredItem], a
- call Function10e38
+ call Pack_GetItemName
ld de, SFX_FULL_HEAL
call WaitPlaySFX
- ld hl, Text_RegisteredTheItem
- call Function10cb9
+ ld hl, RegisteredItemText
+ call Pack_PrintTextNoScroll
ret
-.asm_10826
- ld hl, Text_CantRegisterThatItem
- call Function10cb9
+.cant_register
+ ld hl, CantRegisterText
+ call Pack_PrintTextNoScroll
ret
GiveItem:
ld a, [wPartyCount]
and a
- jp z, Function108b6
+ jp z, .NoPokemon
ld a, [wOptions]
push af
- res 4, a
+ res NO_TEXT_SCROLL, a
ld [wOptions], a
- ld a, $8
+ ld a, PARTYMENUACTION_GIVE_ITEM
ld [wPartyMenuActionText], a
call ClearBGPalettes
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuGFX
-.asm_10857
+.loop
farcall WritePartyMenuTilemap
farcall PrintPartyMenuText
call WaitBGMap
call SetPalettes
call DelayFrame
farcall PartyMenuSelect
- jr c, .asm_108a5
+ jr c, .finish
ld a, [wCurPartySpecies]
cp EGG
- jr nz, .asm_10883
- ld hl, Text_AnEggCantHoldAnItem
+ jr nz, .give
+ ld hl, .AnEggCantHoldAnItemText
call PrintText
- jr .asm_10857
+ jr .loop
-.asm_10883
- ld a, [wce63]
+.give
+ ld a, [wJumptableIndex]
push af
- ld a, [wce64]
+ ld a, [wPackJumptableIndex]
push af
call GetCurNick
ld hl, wStringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, $b
+ ld bc, MON_NAME_LENGTH
call CopyBytes
call TryGiveItemToPartymon
pop af
- ld [wce64], a
+ ld [wPackJumptableIndex], a
pop af
- ld [wce63], a
-.asm_108a5
+ ld [wJumptableIndex], a
+.finish
pop af
ld [wOptions], a
xor a
ldh [hBGMapMode], a
- call Function10d70
- call Function10cca
- call Function10e5b
+ call Pack_InitGFX
+ call WaitBGMap_DrawPackGFX
+ call Pack_InitColors
ret
-Function108b6: ; 108b6 (4:48b6)
- ld hl, Text_YouDontHaveAPokemon ; $4f13
- call Function10cb9
+.NoPokemon:
+ ld hl, YouDontHaveAMonText
+ call Pack_PrintTextNoScroll
ret
-
-Text_AnEggCantHoldAnItem:
- text_far Text_AnEGGCantHoldAnItem
- db "@"
+.AnEggCantHoldAnItemText:
+ text_far _AnEggCantHoldAnItemText
+ text_end
QuitItemSubmenu:
ret
BattlePack:
ld hl, wOptions
- set 4, [hl]
- call Function10aba
-.asm_108cb
+ set NO_TEXT_SCROLL, [hl]
+ call InitPackBuffers
+.loop
call JoyTextDelay
- ld a, [wce63]
+ ld a, [wJumptableIndex]
bit 7, a
- jr nz, .asm_108dd
- call Function108e9
+ jr nz, .end
+ call .RunJumptable
call DelayFrame
- jr .asm_108cb
+ jr .loop
-.asm_108dd
- ld a, [wce65]
+.end
+ ld a, [wCurPocket]
ld [wLastPocket], a
ld hl, wOptions
- res 4, [hl]
+ res NO_TEXT_SCROLL, [hl]
ret
-Function108e9: ; 108e9 (4:48e9)
- ld a, [wce63]
+.RunJumptable:
+ ld a, [wJumptableIndex]
ld hl, .Jumptable
- call Function10c9b
+ call Pack_GetJumptablePointer
jp hl
-.Jumptable
- dw BattlePack_InitGFX
- dw BattlePack_InitItemsPocket
- dw BattlePack_ItemsPocketMenu
- dw BattlePack_InitBallsPocket
- dw BattlePack_BallsPocketMenu
- dw BattlePack_InitKeyItemsPocket
- dw BattlePack_KeyItemsPocketMenu
- dw BattlePack_InitTMHMPocket
- dw BattlePack_TMHMPocketMenu
- dw Pack_ExitNoScript
- dw Pack_ExitRunScript
-
-BattlePack_InitGFX:
+.Jumptable:
+; entries correspond to PACKSTATE_* constants
+ dw .InitGFX ; 0
+ dw .InitItemsPocket ; 1
+ dw .ItemsPocketMenu ; 2
+ dw .InitBallsPocket ; 3
+ dw .BallsPocketMenu ; 4
+ dw .InitKeyItemsPocket ; 5
+ dw .KeyItemsPocketMenu ; 6
+ dw .InitTMHMPocket ; 7
+ dw .TMHMPocketMenu ; 8
+ dw Pack_QuitNoScript ; 9
+ dw Pack_QuitRunScript ; 10
+
+.InitGFX:
xor a
ldh [hBGMapMode], a
- call Function10d70
- ld a, [wce64]
- ld [wce63], a
- call Function10e5b
+ call Pack_InitGFX
+ ld a, [wPackJumptableIndex]
+ ld [wJumptableIndex], a
+ call Pack_InitColors
ret
-BattlePack_InitItemsPocket:
- xor a
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitItemsPocket:
+ xor a ; ITEM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-BattlePack_ItemsPocketMenu:
- ld hl, $4e6a
+.ItemsPocketMenu:
+ ld hl, ItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -684,24 +691,24 @@ BattlePack_ItemsPocketMenu:
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
- ld b, $7
- ld c, $3
- call Function10cef
+ ld b, PACKSTATE_INITTMHMPOCKET ; left
+ ld c, PACKSTATE_INITBALLSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function10a03
+ call ItemSubmenu
ret
-BattlePack_InitKeyItemsPocket:
- ld a, $2
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitKeyItemsPocket:
+ ld a, KEY_ITEM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-BattlePack_KeyItemsPocketMenu:
- ld hl, $4e9a
+.KeyItemsPocketMenu:
+ ld hl, KeyItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wKeyItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -712,47 +719,47 @@ BattlePack_KeyItemsPocketMenu:
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
- ld b, $3
- ld c, $7
- call Function10cef
+ ld b, PACKSTATE_INITBALLSPOCKET ; left
+ ld c, PACKSTATE_INITTMHMPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function10a03
+ call ItemSubmenu
ret
-BattlePack_InitTMHMPocket:
- ld a, $3
- ld [wce65], a
- call Function10e51
- call Function10dd6
+.InitTMHMPocket:
+ ld a, TM_HM_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
xor a
ldh [hBGMapMode], a
- call Function10cca
- ld hl, Text_PackEmptyString
- call Function10cb9
- call Function10c96
+ call WaitBGMap_DrawPackGFX
+ ld hl, PackEmptyText
+ call Pack_PrintTextNoScroll
+ call Pack_JumptableNext
ret
-BattlePack_TMHMPocketMenu:
- farcall TMHMPocket ; b:457a
- ld b, $5
- ld c, $1
- call Function10cef
+.TMHMPocketMenu:
+ farcall TMHMPocket
+ ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
+ ld c, PACKSTATE_INITITEMSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
xor a
- call Function10a0c
+ call TMHMSubmenu
ret
-BattlePack_InitBallsPocket:
- ld a, $1
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
- call Function10c96
+.InitBallsPocket:
+ ld a, BALL_POCKET
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
+ call Pack_JumptableNext
ret
-BattlePack_BallsPocketMenu:
- ld hl, $4eca
+.BallsPocketMenu:
+ ld hl, BallsPocketMenuHeader
call CopyMenuHeader
ld a, [wBallsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -763,27 +770,27 @@ BattlePack_BallsPocketMenu:
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
- ld b, $1
- ld c, $5
- call Function10cef
+ ld b, PACKSTATE_INITITEMSPOCKET ; left
+ ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
+ call Pack_InterpretJoypad
ret c
- call Function10a03
+ call ItemSubmenu
ret
-Function10a03: ; 10a03 (4:4a03)
+ItemSubmenu:
farcall CheckItemContext
ld a, [wItemAttributeParamBuffer]
-Function10a0c: ; 10a0c (4:4a0c)
+TMHMSubmenu:
and a
- jr z, .asm_10a17
- ld hl, BattlePackUseQuitMenuDataHeader
- ld de, BattlePackUseQuitJumptable
- jr .asm_10a1d
-
-.asm_10a17
- ld hl, BattlePackQuitMenuDataHeader
- ld de, BattlePackQuitJumptable
-.asm_10a1d
+ jr z, .NoUse
+ ld hl, .UsableMenuHeader
+ ld de, .UsableJumptable
+ jr .proceed
+
+.NoUse:
+ ld hl, .UnusableMenuHeader
+ ld de, .UnusableJumptable
+.proceed
push de
call LoadMenuHeader
call VerticalMenu
@@ -792,155 +799,156 @@ Function10a0c: ; 10a0c (4:4a0c)
ret c
ld a, [wMenuCursorY]
dec a
- call Function10c9b
+ call Pack_GetJumptablePointer
jp hl
-BattlePackUseQuitMenuDataHeader:
- db $40 ; flags
- db 07, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+.UsableMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 7, TEXTBOX_HEIGHT, TEXTBOX_Y - 1
+ dw .UsableMenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.UsableMenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 2 ; items
db "USE@"
db "QUIT@"
-BattlePackUseQuitJumptable:
- dw BattlePack_UseItem
- dw BattlePack_QuitSubmenu
+.UsableJumptable:
+ dw .Use
+ dw .Quit
-BattlePackQuitMenuDataHeader:
- db $40 ; flags
- db 09, 00 ; start coords
- db 11, 06 ; end coords
- dw .MenuData2
+.UnusableMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 9, SCREEN_WIDTH - 14, TEXTBOX_Y - 1
+ dw .UnusableMenuData
db 1 ; default option
-.MenuData2:
- db $c0 ; flags
+.UnusableMenuData:
+ db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags
db 1 ; items
db "QUIT@"
-BattlePackQuitJumptable:
- dw BattlePack_QuitSubmenu
+.UnusableJumptable:
+ dw .Quit
-BattlePack_UseItem:
+.Use:
farcall CheckItemContext
ld a, [wItemAttributeParamBuffer]
- ld hl, $4a67
+ ld hl, .ItemFunctionJumptable
rst JumpTable
ret
- dw Function10a75
- dw Function10a75
- dw Function10a75
- dw Function10a75
- dw Function10a7c
- dw Function10a86
- dw Function10aa1
+.ItemFunctionJumptable:
+; entries correspond to ITEMMENU_* constants
+ dw .Oak ; ITEMMENU_NOUSE
+ dw .Oak
+ dw .Oak
+ dw .Oak
+ dw .Unused ; ITEMMENU_CURRENT
+ dw .BattleField ; ITEMMENU_PARTY
+ dw .BattleOnly ; ITEMMENU_CLOSE
-Function10a75:
- ld hl, Text_ThisIsntTheTime
- call Function10cb9
+.Oak:
+ ld hl, OakThisIsntTheTimeText
+ call Pack_PrintTextNoScroll
ret
-Function10a7c:
+.Unused:
call DoItemEffect
- ld a, [wFieldMoveSucceeded]
+ ld a, [wItemEffectSucceeded]
and a
- jr nz, asm_10a9c
+ jr nz, .ReturnToBattle
ret
-Function10a86:
+.BattleField:
call DoItemEffect
- ld a, [wFieldMoveSucceeded]
+ ld a, [wItemEffectSucceeded]
and a
- jr nz, asm_10aae
+ jr nz, .quit_run_script
xor a
ldh [hBGMapMode], a
- call Function10d70
- call Function10cca
- call Function10e5b
+ call Pack_InitGFX
+ call WaitBGMap_DrawPackGFX
+ call Pack_InitColors
ret
-asm_10a9c:
+.ReturnToBattle:
call ClearBGPalettes
- jr asm_10aae
+ jr .quit_run_script
-Function10aa1:
+.BattleOnly:
call DoItemEffect
- ld a, [wFieldMoveSucceeded]
+ ld a, [wItemEffectSucceeded]
and a
- jr z, Function10a75
+ jr z, .Oak
cp $2
- jr z, asm_10ab4
-asm_10aae:
- ld a, $a
- ld [wce63], a
+ jr z, .didnt_use_item
+.quit_run_script
+ ld a, PACKSTATE_QUITRUNSCRIPT
+ ld [wJumptableIndex], a
ret
-asm_10ab4:
+.didnt_use_item
xor a
- ld [wFieldMoveSucceeded], a
+ ld [wItemEffectSucceeded], a
ret
-
-BattlePack_QuitSubmenu:
+.Quit:
ret
-Function10aba: ; 10aba (4:4aba)
+InitPackBuffers:
xor a
- ld [wce63], a
+ ld [wJumptableIndex], a
+ ; pocket id -> jumptable index
ld a, [wLastPocket]
- and $3
+ maskbits NUM_POCKETS
ld [wCurPocket], a
inc a
add a
dec a
- ld [wce64], a
- xor a
+ ld [wPackJumptableIndex], a
+ xor a ; FALSE
ld [wPackUsedItem], a
xor a
ld [wSwitchItem], a
ret
-DepositSellInitPackBuffers: ; 10ad5 (4:4ad5)
+DepositSellInitPackBuffers:
xor a
ldh [hBGMapMode], a
- ld [wce63], a
- ld [wce64], a
- ld [wCurPocket], a
+ ld [wJumptableIndex], a ; PACKSTATE_INITGFX
+ ld [wPackJumptableIndex], a ; PACKSTATE_INITGFX
+ ld [wCurPocket], a ; ITEM_POCKET
ld [wPackUsedItem], a
ld [wSwitchItem], a
- call Function10d70
- call Function10e5b
+ call Pack_InitGFX
+ call Pack_InitColors
ret
DepositSellPack:
.loop
- call Function10af7
- call Function10b9f
+ call .RunJumptable
+ call DepositSellTutorial_InterpretJoypad
jr c, .loop
ret
-Function10af7: ; 10af7 (4:4af7)
- ld a, [wce63]
+.RunJumptable:
+ ld a, [wJumptableIndex]
ld hl, .Jumptable
- call Function10c9b
+ call Pack_GetJumptablePointer
jp hl
-.Jumptable
- dw DepositOrSell_ItemPocket
- dw DepositOrSell_BallsPocket
- dw DepositOrSell_KeyItemsPocket
- dw DepositOrSell_TMHMPocket
-
-DepositOrSell_ItemPocket:
- xor a
- call Function10b92
- ld hl, PC_Mart_ItemsPocketMenuDataHeader ; $4e82
+.Jumptable:
+; entries correspond to *_POCKET constants
+ dw .ItemsPocket
+ dw .BallsPocket
+ dw .KeyItemsPocket
+ dw .TMHMPocket
+
+.ItemsPocket:
+ xor a ; ITEM_POCKET
+ call InitPocket
+ ld hl, PC_Mart_ItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -953,10 +961,10 @@ DepositOrSell_ItemPocket:
ld [wItemsPocketCursor], a
ret
-DepositOrSell_KeyItemsPocket:
- ld a, $2
- call Function10b92
- ld hl, PC_Mart_KeyItemsPocketMenuDataHeader ; $4eb2
+.KeyItemsPocket:
+ ld a, KEY_ITEM_POCKET
+ call InitPocket
+ ld hl, PC_Mart_KeyItemsPocketMenuHeader
call CopyMenuHeader
ld a, [wKeyItemsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -969,19 +977,19 @@ DepositOrSell_KeyItemsPocket:
ld [wKeyItemsPocketCursor], a
ret
-DepositOrSell_TMHMPocket:
- ld a, $3
- call Function10b92
- call Function10cca
- farcall TMHMPocket ; b:457a
+.TMHMPocket:
+ ld a, TM_HM_POCKET
+ call InitPocket
+ call WaitBGMap_DrawPackGFX
+ farcall TMHMPocket
ld a, [wCurItem]
ld [wCurItem], a
ret
-DepositOrSell_BallsPocket:
- ld a, $1
- call Function10b92
- ld hl, PC_Mart_BallsPocketMenuDataHeader ; $4ee2
+.BallsPocket:
+ ld a, BALL_POCKET
+ call InitPocket
+ ld hl, PC_Mart_BallsPocketMenuHeader
call CopyMenuHeader
ld a, [wBallsPocketCursor]
ld [wMenuCursorBuffer], a
@@ -994,61 +1002,61 @@ DepositOrSell_BallsPocket:
ld [wBallsPocketCursor], a
ret
-Function10b92: ; 10b92 (4:4b92)
- ld [wce65], a
- call Function10e51
- call Function10dd6
- call Function10cca
+InitPocket:
+ ld [wCurPocket], a
+ call ClearPocketList
+ call DrawPocketName
+ call WaitBGMap_DrawPackGFX
ret
-Function10b9f: ; 10b9f (4:4b9f)
+DepositSellTutorial_InterpretJoypad:
ld hl, wMenuJoypad
ld a, [hl]
- and $1
- jr nz, .asm_10bb8
+ and A_BUTTON
+ jr nz, .a_button
ld a, [hl]
- and $2
- jr nz, .asm_10bbf
+ and B_BUTTON
+ jr nz, .b_button
ld a, [hl]
- and $20
- jr nz, .asm_10bc5
+ and D_LEFT
+ jr nz, .d_left
ld a, [hl]
- and $10
- jr nz, .asm_10bd8
+ and D_RIGHT
+ jr nz, .d_right
scf
ret
-.asm_10bb8
- ld a, $1
- ld [wce66], a
+.a_button
+ ld a, TRUE
+ ld [wPackUsedItem], a
and a
ret
-.asm_10bbf
- xor a
- ld [wce66], a
+.b_button
+ xor a ; FALSE
+ ld [wPackUsedItem], a
and a
ret
-.asm_10bc5
- ld a, [wce63]
+.d_left
+ ld a, [wJumptableIndex]
dec a
- and $3
- ld [wce63], a
+ maskbits NUM_POCKETS
+ ld [wJumptableIndex], a
push de
- ld de, $62
+ ld de, SFX_SWITCH_POCKETS
call PlaySFX
pop de
scf
ret
-.asm_10bd8
- ld a, [wce63]
+.d_right
+ ld a, [wJumptableIndex]
inc a
- and $3
- ld [wce63], a
+ maskbits NUM_POCKETS
+ ld [wJumptableIndex], a
push de
- ld de, $62
+ ld de, SFX_SWITCH_POCKETS
call PlaySFX
pop de
scf
@@ -1058,42 +1066,42 @@ TutorialPack:
call DepositSellInitPackBuffers
ld a, [wInputType]
or a
- jr z, .asm_10bfa
- farcall _DudeAutoInput_RightA ; 70:4dee
-.asm_10bfa
- call Function10c07
- call Function10b9f
- jr c, .asm_10bfa
- xor a
- ld [wce66], a
+ jr z, .loop
+ farcall _DudeAutoInput_RightA
+.loop
+ call .RunJumptable
+ call DepositSellTutorial_InterpretJoypad
+ jr c, .loop
+ xor a ; FALSE
+ ld [wPackUsedItem], a
ret
-Function10c07: ; 10c07 (4:4c07)
- ld a, [wce63]
- ld hl, $4c11
- call Function10c9b
+.RunJumptable:
+ ld a, [wJumptableIndex]
+ ld hl, .dw
+ call Pack_GetJumptablePointer
jp hl
-.Jumptable
- dw TutorialItems
- dw TutorialBalls
- dw TutorialKeyItems
- dw TutorialTMHM
-
-TutorialItems:
- xor a
- ld hl, TutorialItemsMenuDataHeader
- jr asm_10c8a
-
-TutorialItemsMenuDataHeader:
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
- dw .MenuData2
+.dw
+; entries correspond to *_POCKET constants
+ dw .Items
+ dw .Balls
+ dw .KeyItems
+ dw .TMHM
+
+.Items:
+ xor a ; ITEM_POCKET
+ ld hl, .ItemsMenuHeader
+ jr .DisplayPocket
+
+.ItemsMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .ItemsMenuData
db 1 ; default option
-.MenuData2:
- db $ae ; flags
+.ItemsMenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, wDudeNumItems
@@ -1101,20 +1109,19 @@ TutorialItemsMenuDataHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription
-TutorialKeyItems:
- ld a, $2
- ld hl, TutorialKeyItemsMenuDataHeader
- jr asm_10c8a
+.KeyItems:
+ ld a, KEY_ITEM_POCKET
+ ld hl, .KeyItemsMenuHeader
+ jr .DisplayPocket
-TutorialKeyItemsMenuDataHeader:
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
- dw .MenuData2
+.KeyItemsMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .KeyItemsMenuData
db 1 ; default option
-.MenuData2:
- db $ae ; flags
+.KeyItemsMenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 1 ; horizontal spacing
dbw 0, wDudeNumKeyItems
@@ -1122,29 +1129,28 @@ TutorialKeyItemsMenuDataHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription
-TutorialTMHM:
- ld a, $3
- call Function10b92
- call Function10cca
+.TMHM:
+ ld a, TM_HM_POCKET
+ call InitPocket
+ call WaitBGMap_DrawPackGFX
farcall TMHMPocket
ld a, [wCurItem]
ld [wCurItem], a
ret
-TutorialBalls:
- ld a, $1
- ld hl, TutorialBallsMenuDataHeader
- jr asm_10c8a
+.Balls:
+ ld a, BALL_POCKET
+ ld hl, .BallsMenuHeader
+ jr .DisplayPocket
-TutorialBallsMenuDataHeader:
- db $40 ; flags
- db 01, 07 ; start coords
- db 11, 19 ; end coords
- dw .MenuData2
+.BallsMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .BallsMenuData
db 1 ; default option
-.MenuData2:
- db $ae ; flags
+.BallsMenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
db 5, 8 ; rows, columns
db 2 ; horizontal spacing
dbw 0, wDudeNumBalls
@@ -1152,22 +1158,22 @@ TutorialBallsMenuDataHeader:
dba PlaceMenuItemQuantity
dba UpdateItemDescription
-asm_10c8a:
+.DisplayPocket:
push hl
- call Function10b92
+ call InitPocket
pop hl
call CopyMenuHeader
call ScrollingMenu
ret
-Function10c96: ; 10c96 (4:4c96)
- ld hl, wce63
+Pack_JumptableNext:
+ ld hl, wJumptableIndex
inc [hl]
ret
-Function10c9b: ; 10c9b (4:4c9b)
+Pack_GetJumptablePointer:
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
add hl, de
ld a, [hli]
@@ -1175,91 +1181,91 @@ Function10c9b: ; 10c9b (4:4c9b)
ld l, a
ret
-Pack_ExitNoScript:
- ld hl, wce63
+Pack_QuitNoScript:
+ ld hl, wJumptableIndex
set 7, [hl]
- xor a
- ld [wce66], a
+ xor a ; FALSE
+ ld [wPackUsedItem], a
ret
-Pack_ExitRunScript:
- ld hl, wce63
+Pack_QuitRunScript:
+ ld hl, wJumptableIndex
set 7, [hl]
- ld a, $1
- ld [wce66], a
+ ld a, TRUE
+ ld [wPackUsedItem], a
ret
-Function10cb9: ; 10cb9 (4:4cb9)
+Pack_PrintTextNoScroll:
ld a, [wOptions]
push af
- set 4, a
+ set NO_TEXT_SCROLL, a
ld [wOptions], a
call PrintText
pop af
ld [wOptions], a
ret
-Function10cca: ; 10cca (4:4cca)
+WaitBGMap_DrawPackGFX:
call WaitBGMap
-Function10ccd: ; 10ccd (4:4ccd)
- ld a, [wce65]
- and $3
+DrawPackGFX:
+ ld a, [wCurPocket]
+ maskbits NUM_POCKETS
ld e, a
- ld d, $0
+ ld d, 0
ld hl, PackGFXPointers
add hl, de
add hl, de
ld a, [hli]
ld e, a
ld d, [hl]
- ld hl, $9500
+ ld hl, vTiles2 tile $50
lb bc, BANK(PackGFX), 15
call Request2bpp
ret
PackGFXPointers:
- dw PackGFX + $f0 * 1
- dw PackGFX + $f0 * 3
- dw PackGFX + $f0 * 0
- dw PackGFX + $f0 * 2
+ dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET
+ dw PackGFX + (15 tiles) * 3 ; BALL_POCKET
+ dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
+ dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET
-Function10cef: ; 10cef (4:4cef)
+Pack_InterpretJoypad:
ld hl, wMenuJoypad
ld a, [wSwitchItem]
and a
- jr nz, .asm_10d4c
+ jr nz, .switching_item
ld a, [hl]
- and $1
- jr nz, .asm_10d13
+ and A_BUTTON
+ jr nz, .a_button
ld a, [hl]
- and $2
- jr nz, .asm_10d15
+ and B_BUTTON
+ jr nz, .b_button
ld a, [hl]
- and $20
- jr nz, .asm_10d1c
+ and D_LEFT
+ jr nz, .d_left
ld a, [hl]
- and $10
- jr nz, .asm_10d2d
+ and D_RIGHT
+ jr nz, .d_right
ld a, [hl]
- and $4
- jr nz, .asm_10d3e
+ and SELECT
+ jr nz, .select
scf
ret
-.asm_10d13
+.a_button
and a
ret
-.asm_10d15
- ld a, $9
- ld [wce63], a
+.b_button
+ ld a, PACKSTATE_QUITNOSCRIPT
+ ld [wJumptableIndex], a
scf
ret
-.asm_10d1c
+.d_left
ld a, b
- ld [wce63], a
- ld [wce64], a
+ ld [wJumptableIndex], a
+ ld [wPackJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
call PlaySFX
@@ -1267,10 +1273,10 @@ Function10cef: ; 10cef (4:4cef)
scf
ret
-.asm_10d2d
+.d_right
ld a, c
- ld [wce63], a
- ld [wce64], a
+ ld [wJumptableIndex], a
+ ld [wPackJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
call PlaySFX
@@ -1278,296 +1284,301 @@ Function10cef: ; 10cef (4:4cef)
scf
ret
-.asm_10d3e
- farcall SwitchItemsInBag ; 9:4834
- ld hl, Text_MoveItemWhere
- call Function10cb9
+.select
+ farcall SwitchItemsInBag
+ ld hl, AskItemMoveText
+ call Pack_PrintTextNoScroll
scf
ret
-.asm_10d4c
+.switching_item
ld a, [hl]
- and $5
- jr nz, .asm_10d58
+ and A_BUTTON | SELECT
+ jr nz, .place_insert
ld a, [hl]
- and $2
- jr nz, .asm_10d6a
+ and B_BUTTON
+ jr nz, .end_switch
scf
ret
-.asm_10d58
- farcall SwitchItemsInBag ; 9:4834
+.place_insert
+ farcall SwitchItemsInBag
ld de, SFX_SWITCH_POKEMON
call WaitPlaySFX
ld de, SFX_SWITCH_POKEMON
call WaitPlaySFX
-.asm_10d6a
+.end_switch
xor a
ld [wSwitchItem], a
scf
ret
-Function10d70: ; 10d70 (4:4d70)
+Pack_InitGFX:
call ClearBGPalettes
call ClearTilemap
call ClearSprites
call DisableLCD
ld hl, PackMenuGFX
- ld de, $9000
- ld bc, $600
+ ld de, vTiles2
+ ld bc, $60 tiles
ld a, BANK(PackMenuGFX)
- call FarCopyBytes ; same bank
+ call FarCopyBytes
+; Background
hlcoord 0, 1
ld bc, 11 * SCREEN_WIDTH
ld a, $24
call ByteFill
+; This is where the items themselves will be listed.
hlcoord 5, 1
lb bc, 11, 15
call ClearBox
+; ◀▶ POCKET ▼▲ ITEMS
hlcoord 0, 0
ld a, $28
- ld c, $14
-.asm_10da5
+ ld c, SCREEN_WIDTH
+.loop
ld [hli], a
inc a
dec c
- jr nz, .asm_10da5
- call Function10dd6
- call Function10dc0
- hlcoord 0, 12
- ld bc, IncGradGBPalTable_13
+ jr nz, .loop
+ call DrawPocketName
+ call PlacePackGFX
+; Place the textbox for displaying the item description
+ hlcoord 0, SCREEN_HEIGHT - 4 - 2
+ lb bc, 4, SCREEN_WIDTH - 2
call Textbox
call EnableLCD
- call Function10ccd
+ call DrawPackGFX
ret
-Function10dc0: ; 10dc0 (4:4dc0)
+PlacePackGFX:
hlcoord 0, 3
ld a, $50
- ld de, $f
- ld b, $3
-.asm_10dca
- ld c, $5
-.asm_10dcc
+ ld de, SCREEN_WIDTH - 5
+ ld b, 3
+.row
+ ld c, 5
+.column
ld [hli], a
inc a
dec c
- jr nz, .asm_10dcc
+ jr nz, .column
add hl, de
dec b
- jr nz, .asm_10dca
+ jr nz, .row
ret
-Function10dd6: ; 10dd6 (4:4dd6)
- ld a, [wce65]
+DrawPocketName:
+ ld a, [wCurPocket]
+ ; * 15
ld d, a
swap a
sub d
- ld d, $0
+ ld d, 0
ld e, a
ld hl, .tilemap
add hl, de
ld d, h
ld e, l
hlcoord 0, 7
- ld c, $3
-.asm_10deb
- ld b, $5
-.asm_10ded
+ ld c, 3
+.row
+ ld b, 5
+.col
ld a, [de]
inc de
ld [hli], a
dec b
- jr nz, .asm_10ded
+ jr nz, .col
ld a, c
- ld c, $f
+ ld c, SCREEN_WIDTH - 5
add hl, bc
ld c, a
dec c
- jr nz, .asm_10deb
+ jr nz, .row
ret
.tilemap
+; ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $06, $07, $08, $09, $0a ; Items
db $02, $05, $05, $05, $03 ; bottom border
+; BALL_POCKET
db $00, $04, $04, $04, $01 ; top border
db $15, $16, $17, $18, $19 ; Balls
db $02, $05, $05, $05, $03 ; bottom border
+; KEY_ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $0b, $0c, $0d, $0e, $0f ; Key Items
db $02, $05, $05, $05, $03 ; bottom border
+; TM_HM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $10, $11, $12, $13, $14 ; TM/HM
db $02, $05, $05, $05, $03 ; bottom border
-Function10e38: ; 10e38 (4:4e38)
+Pack_GetItemName:
ld a, [wCurItem]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetItemName
call CopyName1
ret
-Pack_ClearTilemap:
+Unreferenced_Pack_ClearTilemap:
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
call ByteFill
ret
-Function10e51: ; 10e51 (4:4e51)
+ClearPocketList:
hlcoord 5, 2
- lb bc, 10, 15
+ lb bc, 10, SCREEN_WIDTH - 5
call ClearBox
ret
-Function10e5b: ; 10e5b (4:4e5b)
+Pack_InitColors:
call WaitBGMap
- ld b, $14
+ ld b, SCGB_PACKPALS
call GetSGBLayout
call SetPalettes
call DelayFrame
ret
-ItemsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
+ItemsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
-.MenuData2:
- db $ae
- db 5, 8
- db 2
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumItems
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
-
-PC_Mart_ItemsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $2e
- db 5, 8
- db 2
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
+
+PC_Mart_ItemsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumItems
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
-
-KeyItemsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $ae
- db 5, 8
- db 1
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
+
+KeyItemsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_NORMAL ; item format
dbw 0, wNumKeyItems
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
-
-PC_Mart_KeyItemsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $2e
- db 5, 8
- db 1
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
+
+PC_Mart_KeyItemsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_NORMAL ; item format
dbw 0, wNumKeyItems
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
-
-BallsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $ae
- db 5, 8
- db 2
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
+
+BallsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP | STATICMENU_CURSOR ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumBalls
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
-
-PC_Mart_BallsPocketMenuDataHeader:
- db $40
- db 01, 07
- db 11, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $2e
- db 5, 8
- db 2
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
+
+PC_Mart_BallsPocketMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 7, 1, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_ENABLE_SELECT | STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP ; flags
+ db 5, 8 ; rows, columns
+ db SCROLLINGMENU_ITEMS_QUANTITY ; item format
dbw 0, wNumBalls
- dba PlaceMenuItemName ; 9:49dc
- dba PlaceMenuItemQuantity ; 9:49eb
- dba UpdateItemDescription ; 9:43eb
+ dba PlaceMenuItemName
+ dba PlaceMenuItemQuantity
+ dba UpdateItemDescription
-Text_PackNoItems:
- text_far Text_PackNoItems_
- db "@"
+PackNoItemText:
+ text_far _PackNoItemText
+ text_end
-Text_ThrowAwayHowMany:
- text_far Text_ThrowAwayHowMany_
- db "@"
+AskThrowAwayText:
+ text_far _AskThrowAwayText
+ text_end
-Text_ConfirmThrowAway:
- text_far Text_ConfirmThrowAway_
- db "@"
+AskQuantityThrowAwayText:
+ text_far _AskQuantityThrowAwayText
+ text_end
-Text_ThrewAway:
- text_far Text_ThrewAway_
- db "@"
+ThrewAwayText:
+ text_far _ThrewAwayText
+ text_end
-Text_ThisIsntTheTime:
- text_far Text_ThisIsntTheTime_
- db "@"
+OakThisIsntTheTimeText:
+ text_far _OakThisIsntTheTimeText
+ text_end
-Text_YouDontHaveAPokemon:
- text_far Text_YouDontHaveAMon
- db "@"
+YouDontHaveAMonText:
+ text_far _YouDontHaveAMonText
+ text_end
-Text_RegisteredTheItem:
- text_far Text_RegisteredTheItem_
- db "@"
+RegisteredItemText:
+ text_far _RegisteredItemText
+ text_end
-Text_CantRegisterThatItem:
- text_far Text_CantRegisterThatItem_
- db "@"
+CantRegisterText:
+ text_far _CantRegisterText
+ text_end
-Text_MoveItemWhere:
- text_far Text_MoveItemWhere_
- db "@"
+AskItemMoveText:
+ text_far _AskItemMoveText
+ text_end
-Text_PackEmptyString:
- text_far Text_PackEmptyString_
- db "@"
+PackEmptyText:
+ text_far _PackEmptyText
+ text_end
-Text_CantUseItInABattle:
- text_far Text_YouCantUseItInABattle
- db "@"
+YouCantUseItInABattleText:
+ text_far _YouCantUseItInABattleText
+ text_end
-PackMenuGFX: INCBIN "gfx/pack/pack_menu.2bpp"
-PackGFX: INCBIN "gfx/pack/pack.2bpp"
+PackMenuGFX:
+INCBIN "gfx/pack/pack_menu.2bpp"
+PackGFX:
+INCBIN "gfx/pack/pack.2bpp"