summaryrefslogtreecommitdiff
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
parent39a7f59931e03e4ebd155e061ac6e71a6d6bd97a (diff)
Clean up text, and some bank 3 code.
-rw-r--r--constants/text_constants.asm4
-rwxr-xr-xdata/text/battle.asm3
-rwxr-xr-xdata/text/common_1.asm123
-rw-r--r--data/text/common_2.asm115
-rw-r--r--data/text/common_3.asm174
-rw-r--r--engine/events/daycare.asm6
-rwxr-xr-xengine/items/item_effects.asm769
-rwxr-xr-xengine/items/pack.asm1589
-rw-r--r--engine/pokegear/radio.asm6
-rw-r--r--engine/pokemon/bills_pc_top.asm226
-rwxr-xr-xengine/pokemon/health.asm8
-rw-r--r--engine/pokemon/learn.asm165
-rwxr-xr-xengine/pokemon/move_mon.asm886
-rw-r--r--main.asm10
14 files changed, 2204 insertions, 1880 deletions
diff --git a/constants/text_constants.asm b/constants/text_constants.asm
index 745fb52c..f1c3a0bf 100644
--- a/constants/text_constants.asm
+++ b/constants/text_constants.asm
@@ -33,12 +33,12 @@ TEXTBOX_INNERY EQU TEXTBOX_Y + 2
; PrintNum bit flags
const_def 5
const PRINTNUM_MONEY_F ; 5
- const PRINTNUM_LEFTALIGN_F ; 6
+ const PRINTNUM_LEFTALIGN_F ; 6
const PRINTNUM_LEADINGZEROS_F ; 7
; PrintNum arguments (see engine/math/print_num.asm)
PRINTNUM_MONEY EQU 1 << PRINTNUM_MONEY_F
-PRINTNUM_LEFTALIGN EQU 1 << PRINTNUM_LEFTALIGN_F
+PRINTNUM_LEFTALIGN EQU 1 << PRINTNUM_LEFTALIGN_F
PRINTNUM_LEADINGZEROS EQU 1 << PRINTNUM_LEADINGZEROS_F
; character sets (see charmap.asm)
diff --git a/data/text/battle.asm b/data/text/battle.asm
index cccc9421..58fad4a9 100755
--- a/data/text/battle.asm
+++ b/data/text/battle.asm
@@ -405,9 +405,8 @@ BecameConfusedText:
text "<TARGET>"
line "became confused!"
prompt
-; ItemHealedConfusion
-BattleText_ItemHealedConfusion: ; ItemHealedConfusion
+BattleText_ItemHealedConfusion:
text "A @"
text_ram wStringBuffer1
text " rid"
diff --git a/data/text/common_1.asm b/data/text/common_1.asm
index a1c9fdb2..0bea4456 100755
--- a/data/text/common_1.asm
+++ b/data/text/common_1.asm
@@ -27,7 +27,7 @@ _NothingHereText::
line "here…"
done
-UnknownText_0x1bc0a2::
+_RecoveredSomeHPText::
text_ram wStringBuffer1
text_start
line "recovered @"
@@ -35,65 +35,65 @@ UnknownText_0x1bc0a2::
text "HP!"
done
-UnknownText_0x1bc0bb::
+_CuredOfPoisonText::
text_ram wStringBuffer1
text "'s"
line "cured of poison."
done
-UnknownText_0x1bc0d2::
+_RidOfParalysisText::
text_ram wStringBuffer1
text "'s"
line "rid of paralysis."
done
-UnknownText_0x1bc0ea::
+_BurnWasHealedText::
text_ram wStringBuffer1
text "'s"
line "burn was healed."
done
-UnknownText_0x1bc101::
+_WasDefrostedText::
text_ram wStringBuffer1
text_start
line "was defrosted."
done
-UnknownText_0x1bc115::
+_WokeUpText::
text_ram wStringBuffer1
text_start
line "woke up."
done
-UnknownText_0x1bc123::
+_HealthReturnedText::
text_ram wStringBuffer1
text "'s"
line "health returned."
done
-UnknownText_0x1bc13a::
+_RevitalizedText::
text_ram wStringBuffer1
text_start
line "is revitalized."
done
-UnknownText_0x1bc14f::
+_GrewToLevelText::
text_ram wStringBuffer1
text " grew to"
line "level @"
text_decimal wCurPartyLevel, 1, 3
text "!@"
- sound_dex_fanfare_50_79
+ sound_dex_fanfare_50_79 ; plays SFX_DEX_FANFARE_50_79, identical to SFX_LEVEL_UP
text_promptbutton
- db "@"
+ text_end
-UnknownText_0x1bc16e::
+_CameToItsSensesText::
text_ram wStringBuffer1
text " came"
line "to its senses."
done
-UnknownText_0x1bc29c::
+_OakTimeWokeUpText::
text "<……><……><……><……><……><……>"
line "<……><……><……><……><……><……>"
@@ -104,48 +104,52 @@ UnknownText_0x1bc29c::
line "clock for me?"
prompt
-UnknownText_0x1bc2eb::
+_OakTimeWhatTimeIsItText::
text "What time is it?"
done
-UnknownText_0x1bc2fd::
- text "What?@@"
+_OakTimeWhatHoursText::
+ text "What?@"
+ text_end
+
+_OakTimeHoursQuestionMarkText::
text "?"
done
-UnknownText_0x1bc308::
+_OakTimeHowManyMinutesText::
text "How many minutes?"
done
-UnknownText_0x1bc31b::
- text "Whoa!@@"
+_OakTimeWhoaMinutesText::
+ text "Whoa!@"
+ text_end
-UnknownText_0x1bc323::
+_OakTimeMinutesQuestionMarkText::
text "?"
done
-UnknownText_0x1bc326::
+_OakTimeOversleptText::
text "!"
line "I overslept!"
done
-UnknownText_0x1bc336::
+_OakTimeYikesText::
text "!"
line "Yikes! I over-"
cont "slept!"
done
-UnknownText_0x1bc34f::
+_OakTimeSoDarkText::
text "!"
line "No wonder it's so"
cont "dark!"
done
-UnknownText_0x1bc369::
+_OakTimeWhatDayIsItText::
text "What day is it?"
done
-UnknownText_0x1bc37a::
+_OakTimeIsItText::
text ", is it?"
done
@@ -445,7 +449,9 @@ _WillTradeText::
text " will"
line "trade @"
text_ram wOTTrademonSpeciesName
- db "@@"
+ text_end
+
+ text_end ; unused
_ForYourMonWillTradeText::
text "for @"
@@ -477,7 +483,9 @@ _OPT_OakText1::
text_start
line "OAK: @"
text_ram wMonOrItemNameBuffer
- db "@@"
+ text_end
+
+ text_end ; unused
_OPT_OakText2::
text_start
@@ -618,7 +626,7 @@ _OPT_ExcitingText::
line "exciting."
done
-_OPT_GroovyText::
+_OPT_NowText::
text_start
line "now!"
done
@@ -666,7 +674,7 @@ _PokedexShowText::
text_start
line "@"
text_ram wStringBuffer1
- db "@"
+ text_end
; Pokémon Music Channel / Pokémusic
@@ -815,7 +823,9 @@ _PnP_Text4::
text_ram wStringBuffer2
text " @"
text_ram wStringBuffer1
- db "@@"
+ text_end
+
+ text_end ; unused
_PnP_CuteText::
text_start
@@ -901,7 +911,9 @@ _PnP_Text5::
text_start
line "@"
text_ram wStringBuffer1
- db "@@"
+ text_end
+
+ text_end ; unused
_RocketRadioText1::
text_start
@@ -1020,7 +1032,7 @@ _ReceiveItemText::
text "!@"
sound_item
text_promptbutton
- db "@"
+ text_end
_NoCoinsText::
text "You have no coins."
@@ -1031,26 +1043,27 @@ _NoCoinCaseText::
line "COIN CASE."
prompt
-UnknownText_0x1bd407::
+_NPCTradeCableText::
text "OK, connect the"
line "Game Link Cable."
prompt
-UnknownText_0x1bd429::
+Text_NPCTraded::
text "<PLAYER> traded"
line "@"
text_ram wStringBuffer2
text " for"
cont "@"
text_ram wMonOrItemNameBuffer
- text ".@@"
+ text ".@"
+ text_end
-UnknownText_0x1bd445::
+_NPCTradeFanfareText::
sound_dex_fanfare_80_109
text_pause
- db "@"
+ text_end
-UnknownText_0x1bd449::
+_NPCTradeIntroText1::
text "I collect #MON."
line "Do you have"
cont "@"
@@ -1063,12 +1076,12 @@ UnknownText_0x1bd449::
text "?"
done
-UnknownText_0x1bd48c::
+_NPCTradeCancelText1::
text "You don't want to"
line "trade? Aww…"
done
-UnknownText_0x1bd4aa::
+_NPCTradeWrongText1::
text "Huh? That's not"
line "@"
text_ram wStringBuffer1
@@ -1076,7 +1089,7 @@ UnknownText_0x1bd4aa::
cont "What a letdown…"
done
-UnknownText_0x1bd4d2::
+_NPCTradeCompleteText1::
text "Yay! I got myself"
line "@"
text_ram wStringBuffer1
@@ -1084,14 +1097,14 @@ UnknownText_0x1bd4d2::
cont "Thanks!"
done
-UnknownText_0x1bd4f4::
+_NPCTradeAfterText1::
text "Hi, how's my old"
line "@"
text_ram wStringBuffer2
text " doing?"
done
-UnknownText_0x1bd512::
+_NPCTradeIntroText2::
text "Hi, I'm looking"
line "for this #MON."
@@ -1106,7 +1119,7 @@ UnknownText_0x1bd512::
text "?"
done
-UnknownText_0x1bd565::
+_NPCTradeCancelText2::
text "You don't have"
line "one either?"
@@ -1114,7 +1127,7 @@ UnknownText_0x1bd565::
line "disappointing…"
done
-UnknownText_0x1bd5a1::
+_NPCTradeWrongText2::
text "You don't have"
line "@"
text_ram wStringBuffer1
@@ -1122,7 +1135,7 @@ UnknownText_0x1bd5a1::
cont "too bad, then."
done
-UnknownText_0x1bd5cc::
+_NPCTradeCompleteText2::
text "Great! Thank you!"
para "I finally got"
@@ -1131,7 +1144,7 @@ UnknownText_0x1bd5cc::
text "."
done
-UnknownText_0x1bd5f4::
+_NPCTradeAfterText2::
text "Hi! The @"
text_ram wMonOrItemNameBuffer
text_start
@@ -1139,7 +1152,7 @@ UnknownText_0x1bd5f4::
cont "doing great!"
done
-UnknownText_0x1bd621::
+_NPCTradeIntroText3::
text_ram wMonOrItemNameBuffer
text "'s cute,"
line "but I don't have"
@@ -1155,12 +1168,12 @@ UnknownText_0x1bd621::
text "?"
done
-UnknownText_0x1bd673::
+_NPCTradeCancelText3::
text "You don't want to"
line "trade? Oh, darn…"
done
-UnknownText_0x1bd696::
+_NPCTradeWrongText3::
text "That's not"
line "@"
text_ram wStringBuffer1
@@ -1170,7 +1183,7 @@ UnknownText_0x1bd696::
line "me if you get one."
done
-UnknownText_0x1bd6cd::
+_NPCTradeCompleteText3::
text "Wow! Thank you!"
line "I always wanted"
cont "@"
@@ -1178,7 +1191,7 @@ UnknownText_0x1bd6cd::
text "!"
done
-UnknownText_0x1bd6f5::
+_NPCTradeAfterText3::
text "How is that"
line "@"
text_ram wStringBuffer2
@@ -1377,7 +1390,7 @@ _OnlyOneMonText::
line "just one #MON."
prompt
-_CantRaiseEggText::
+_CantAcceptEggText::
text "Sorry, but I can't"
line "accept an EGG."
prompt
@@ -1461,7 +1474,7 @@ _HaveNoRoomText::
line "for it."
prompt
-_DCNotEnoughMoneyText::
+_NotEnoughMoneyText::
text "You don't have"
line "enough money."
prompt
@@ -1507,7 +1520,7 @@ _TakeGoodCareOfEggText::
line "it."
done
-_RefuseEggText::
+_IllKeepItThanksText::
text "Well then, I'll"
line "keep it. Thanks!"
done
diff --git a/data/text/common_2.asm b/data/text/common_2.asm
index b2ff0450..42ed8df5 100644
--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -160,6 +160,7 @@ _RodNothingText::
text "Not even a nibble!"
prompt
+; unused
_UnusedNothingHereText::
text "Looks like there's"
line "nothing here."
@@ -228,13 +229,13 @@ _ItemfinderNopeText::
line "isn't responding."
prompt
-UnknownText_0x1c0acc::
+_PoisonFaintText::
text_ram wStringBuffer3
text_start
line "fainted!"
prompt
-UnknownText_0x1c0ada::
+_PoisonWhiteoutText::
text "<PLAYER> is out of"
line "useable #MON!"
@@ -242,18 +243,18 @@ UnknownText_0x1c0ada::
line "out!"
prompt
-UnknownText_0x1c0b03::
+_UseSweetScentText::
text_ram wStringBuffer3
text " used"
line "SWEET SCENT!"
done
-UnknownText_0x1c0b1a::
+_SweetScentNothingText::
text "Looks like there's"
line "nothing here…"
done
-UnknownText_0x1c0b3b::
+_SquirtbottleNothingText::
text "<PLAYER> sprinkled"
line "water."
@@ -261,26 +262,26 @@ UnknownText_0x1c0b3b::
line "happened…"
done
-UnknownText_0x1c0b65::
+_UseSacredAshText::
text "<PLAYER>'s #MON"
line "were all healed!"
done
-Text_AnEGGCantHoldAnItem::
+_AnEggCantHoldAnItemText::
text "An EGG can't hold"
line "an item."
prompt
-Text_PackNoItems_::
+_PackNoItemText::
text "No items."
done
-Text_ThrowAwayHowMany_::
+_AskThrowAwayText::
text "Throw away how"
line "many?"
done
-Text_ConfirmThrowAway_::
+_AskQuantityThrowAwayText::
text "Throw away @"
text_decimal wItemQuantityChangeBuffer, 1, 2
text_start
@@ -289,46 +290,46 @@ Text_ConfirmThrowAway_::
text "(S)?"
done
-Text_ThrewAway_::
+_ThrewAwayText::
text "Threw away"
line "@"
text_ram wStringBuffer2
text "(S)."
prompt
-Text_ThisIsntTheTime_::
+_OakThisIsntTheTimeText::
text "OAK: <PLAYER>!"
line "This isn't the"
cont "time to use that!"
prompt
-Text_YouDontHaveAMon::
+_YouDontHaveAMonText::
text "You don't have a"
line "#MON!"
prompt
-Text_RegisteredTheItem_::
+_RegisteredItemText::
text "Registered the"
line "@"
text_ram wStringBuffer2
text "."
prompt
-Text_CantRegisterThatItem_::
+_CantRegisterText::
text "You can't register"
line "that item."
prompt
-Text_MoveItemWhere_::
+_AskItemMoveText::
text "Where should this"
line "be moved to?"
done
-Text_PackEmptyString_::
+_PackEmptyText::
text_start
done
-Text_YouCantUseItInABattle::
+_YouCantUseItInABattleText::
text "You can't use it"
line "in a battle."
prompt
@@ -376,7 +377,9 @@ Text_BattleEffectActivate::
text "<USER>'s"
line "@"
text_ram wStringBuffer2
- db "@@"
+ text_end
+
+ text_end ; unused
_BattleStatWentWayUpText::
text_pause
@@ -391,7 +394,9 @@ Text_BattleFoeEffectActivate::
text "<TARGET>'s"
line "@"
text_ram wStringBuffer2
- db "@@"
+ text_end
+
+ text_end ; unused
_BattleStatSharplyFellText::
text_pause
@@ -403,7 +408,8 @@ _BattleStatFellText::
prompt
Text_BattleUser::
- text "<USER>@@"
+ text "<USER>@"
+ text_end
_BattleMadeWhirlwindText::
text_start
@@ -438,7 +444,8 @@ _BattleDugText::
Text_BreedHuh::
text "Huh?"
- para "@@"
+ para "@"
+ text_end
_BreedClearboxText::
text_start
@@ -450,7 +457,7 @@ _BreedEggHatchText::
line "out of its EGG!@"
sound_caught_mon
text_promptbutton
- db "@"
+ text_end
_BreedAskNicknameText::
text "Give a nickname to"
@@ -469,7 +476,7 @@ _LeftWithDayCareLadyText::
_LeftWithDayCareManText::
text "It's @"
- text_ram wDayCareMan + 1
+ text_ram wBreedMon1Nick
text_start
line "that was left with"
cont "the DAY-CARE MAN."
@@ -513,51 +520,51 @@ _EmptyMailboxText::
line "here."
prompt
-ClearedMailPutAwayText::
+_MailClearedPutAwayText::
text "The cleared MAIL"
line "was put away."
prompt
-MailPackFullText::
+_MailPackFullText::
text "The PACK is full."
prompt
-MailMessageLostText::
+_MailMessageLostText::
text "The MAIL's message"
line "will be lost. OK?"
done
-MailAlreadyHoldingItemText::
+_MailAlreadyHoldingItemText::
text "It's already hold-"
line "ing an item."
prompt
-MailEggText::
+_MailEggText::
text "An EGG can't hold"
line "any MAIL."
prompt
-MailMovedFromBoxText::
+_MailMovedFromBoxText::
text "The MAIL was moved"
line "from the MAILBOX."
prompt
-Text_WasSentToBillsPC::
+_WasSentToBillsPCText::
text_ram wStringBuffer1
text " was"
line "sent to BILL's PC."
prompt
-Text_GottaHavePokemon_::
+_PCGottaHavePokemonText::
text "You gotta have"
line "#MON to call!"
prompt
-Text_BillsPCWhat_::
+_PCWhatText::
text "What?"
done
-Text_PleaseRemoveMailBeforeMovePkmnWOMail_::
+_PCMonHoldingMailText::
text "There is a #MON"
line "holding MAIL."
@@ -565,17 +572,17 @@ Text_PleaseRemoveMailBeforeMovePkmnWOMail_::
line "MAIL."
prompt
-Text_YouDontHaveASinglePokemon_::
+_PCNoSingleMonText::
text "You don't have a"
line "single #MON!"
prompt
-Text_ItsYourLastPokemon_::
+_PCCantDepositLastMonText::
text "You can't deposit"
line "your last #MON!"
prompt
-Text_CantTakeAnyMorePokemon_::
+_PCCantTakeText::
text "You can't take any"
line "more #MON."
prompt
@@ -586,11 +593,11 @@ _ContestCaughtMonText::
text "!"
prompt
-UnknownText_0x1c10cf::
+_ContestAskSwitchText::
text "Switch #MON?"
done
-UnknownText_0x1c10dd::
+_ContestAlreadyCaughtText::
text "You already caught"
line "a @"
text_ram wStringBuffer1
@@ -609,7 +616,8 @@ _ContestJudging_FirstPlaceText::
line "who caught a"
cont "@"
text_ram wStringBuffer1
- text "!@@"
+ text "!@"
+ text_end
_ContestJudging_FirstPlaceScoreText::
text_start
@@ -629,7 +637,8 @@ _ContestJudging_SecondPlaceText::
para "who caught a"
line "@"
text_ram wStringBuffer1
- text "!@@"
+ text "!@"
+ text_end
_ContestJudging_SecondPlaceScoreText::
text_start
@@ -649,7 +658,8 @@ _ContestJudging_ThirdPlaceText::
para "who caught a"
line "@"
text_ram wStringBuffer1
- text "!@@"
+ text "!@"
+ text_end
_ContestJudging_ThirdPlaceScoreText::
text_start
@@ -660,7 +670,7 @@ _ContestJudging_ThirdPlaceScoreText::
text " points!"
prompt
-UnknownText_0x1c1203::
+_MagikarpGuruMeasureText::
text "Let me measure"
line "that MAGIKARP."
@@ -670,7 +680,7 @@ UnknownText_0x1c1203::
text "."
prompt
-UnknownText_0x1c123a::
+_KarpGuruRecordText::
text "CURRENT RECORD"
para "@"
@@ -679,9 +689,9 @@ UnknownText_0x1c123a::
line "@"
text_ram wMagikarpRecordHoldersName
text_promptbutton
- db "@"
+ text_end
-UnknownText_0x1c1261::
+_LuckyNumberMatchPartyText::
text "Congratulations!"
para "We have a match"
@@ -693,7 +703,7 @@ UnknownText_0x1c1261::
line "your party."
prompt
-UnknownText_0x1c12ae::
+_LuckyNumberMatchPCText::
text "Congratulations!"
para "We have a match"
@@ -705,7 +715,7 @@ UnknownText_0x1c12ae::
line "your PC BOX."
prompt
-UnknownText_0x1c12fc::
+_CaughtAskNicknameText::
text "Give a nickname to"
line "the @"
text_ram wStringBuffer1
@@ -973,11 +983,11 @@ _OakPCText4::
line "OAK's PC closed."
done
-UnknownText_0x1c1a5b::
+_DummyGameYeahText::
text " , yeah!"
done
-UnknownText_0x1c1a65::
+_DummyGameDarnText::
text "Darn…"
done
@@ -1149,11 +1159,12 @@ _OakText2::
text "This world is in-"
line "habited by crea-"
cont "tures that we call"
- cont "#MON.@@"
+ cont "#MON.@"
+ text_end
_OakText3::
text_promptbutton
- db "@"
+ text_end
_OakText4::
text "People and #MON"
diff --git a/data/text/common_3.asm b/data/text/common_3.asm
index 520326dd..4064b0f4 100644
--- a/data/text/common_3.asm
+++ b/data/text/common_3.asm
@@ -1,116 +1,117 @@
-UnknownText_0x1c505e::
+_SlotsStartText::
text "Start!"
done
-UnknownText_0x1c5066::
+_SlotsNotEnoughCoinsText::
text "Not enough"
line "coins."
prompt
-UnknownText_0x1c5079::
+_SlotsRanOutOfCoinsText::
text "Darn… Ran out of"
line "coins…"
done
-UnknownText_0x1c5092::
+_SlotsPlayAgainText::
text "Play again?"
done
-UnknownText_0x1c509f::
+_SlotsLinedUpText::
text "lined up!"
line "Won @"
text_ram wStringBuffer2
text " coins!"
done
-UnknownText_0x1c50bb::
+_SlotsDarnText::
text "Darn!"
done
-UnknownText_0x1c5821::
+_GearTodayText::
text_today
- db "@"
+ text_end
-UnknownText_0x1c5824::
+_GearEllipseText::
text "<……>"
done
-UnknownText_0x1c5827::
+_GearOutOfServiceText::
text "You're out of the"
line "service area."
prompt
-UnknownText_0x1c5847::
+_PokegearAskWhoCallText::
text "Whom do you want"
line "to call?"
done
-UnknownText_0x1c5862::
+_PokegearPressButtonText::
text "Press any button"
line "to exit."
done
-UnknownText_0x1c587d::
+_PokegearAskDeleteText::
text "Delete this stored"
line "phone number?"
done
-UnknownText_0x1c5565::
+_PhoneWrongNumberText::
text "Huh? Sorry, wrong"
line "number!"
done
-UnknownText_0x1c5580::
+_PhoneClickText::
text "Click!"
done
-UnknownText_0x1c5588::
+_PhoneEllipseText::
text "<……>"
done
-UnknownText_0x1c558b::
+_PhoneOutOfAreaText::
text "That number is out"
line "of the area."
done
-UnknownText_0x1c55ac::
+_PhoneJustTalkToThemText::
text "Just go talk to"
line "that person!"
done
-UnknownText_0x1c55ca::
+_PhoneThankYouText::
text "Thank you!"
done
+; unused
UnknownText_0x1c55d6::
text " :"
done
-UnknownText_0x1c55db::
+_PasswordAskResetText::
text "Password OK."
line "Select CONTINUE &"
cont "reset settings."
prompt
-UnknownText_0x1c560b::
+_PasswordWrongText::
text "Wrong password!"
prompt
-UnknownText_0x1c561c::
+_PasswordAskResetClockText::
text "Reset the clock?"
done
-UnknownText_0x1c562e::
+_PasswordAskEnterText::
text "Please enter the"
line "password."
done
-UnknownText_0x1c564a::
+_ClearAllSaveDataText::
text "Clear all save"
line "data area?"
done
-Text_LearnedMove_::
+_LearnedMoveText::
text_ram wMonOrItemNameBuffer
text " learned"
line "@"
@@ -118,21 +119,21 @@ Text_LearnedMove_::
text "!@"
sound_dex_fanfare_50_79
text_promptbutton
- db "@"
+ text_end
-Text_ForgetWhich_::
+_MoveAskForgetText::
text "Which move should"
next "be forgotten?"
done
-Text_StopLearning_::
+_StopLearningMoveText::
text "Stop learning"
line "@"
text_ram wStringBuffer2
text "?"
done
-Text_DidNotLearn_::
+_DidNotLearnMoveText::
text_ram wMonOrItemNameBuffer
text_start
line "did not learn"
@@ -141,7 +142,7 @@ Text_DidNotLearn_::
text "."
prompt
-Text_TryingToLearn_::
+_AskForgetMoveText::
text_ram wMonOrItemNameBuffer
text " is"
line "trying to learn"
@@ -162,12 +163,14 @@ Text_TryingToLearn_::
text "?"
done
-Text_1_2_and_Poof_::
+Text_MoveForgetCount::
text "1, 2 and…@"
text_pause
- db "@@"
+ text_end
-Text_PoofForgot_::
+ text_end ; unused
+
+_MoveForgotText::
text " Poof!@"
text_pause
text_start
@@ -182,47 +185,47 @@ Text_PoofForgot_::
para "And…"
prompt
-Text_CantForgetHM_::
+_MoveCantForgetHMText::
text "HM moves can't be"
line "forgotten now."
prompt
-UnknownText_0x1c5793::
+_CardFlipPlayWithThreeCoinsText::
text "Play with three"
line "coins?"
done
-UnknownText_0x1c57ab::
+_CardFlipNotEnoughCoinsText::
text "Not enough coins…"
prompt
-UnknownText_0x1c57be::
+_CardFlipChooseACardText::
text "Choose a card."
done
-UnknownText_0x1c57ce::
+_CardFlipPlaceYourBetText::
text "Place your bet."
done
-UnknownText_0x1c57df::
+_CardFlipPlayAgainText::
text "Want to play"
line "again?"
done
-UnknownText_0x1c57f4::
+_CardFlipShuffledText::
text "The cards have"
line "been shuffled."
prompt
-UnknownText_0x1c5813::
+_CardFlipYeahText::
text "Yeah!"
done
-UnknownText_0x1c581a::
+_CardFlipDarnText::
text "Darn…"
done
-Text_ThisMonCantBeCaught_::
+_BallDodgedText::
text "It dodged the"
line "thrown BALL!"
@@ -230,66 +233,68 @@ Text_ThisMonCantBeCaught_::
line "can't be caught!"
prompt
-Text_YouMissedThePokemon_::
+_BallMissedText::
text "You missed the"
line "#MON!"
prompt
-Text_ThePokemonBrokeFree_::
+_BallBrokeFreeText::
text "Oh no! The #MON"
line "broke free!"
prompt
-Text_AppearedToBeCaught_::
+_BallAppearedCaughtText::
text "Aww! It appeared"
line "to be caught!"
prompt
-Text_AarghAlmostHadIt_::
+_BallAlmostHadItText::
text "Aargh!"
line "Almost had it!"
prompt
-Text_ShootItWasSoCloseToo_::
+_BallSoCloseText::
text "Shoot! It was so"
line "close too!"
prompt
-Text_GotchaMonWasCaught_::
+Text_BallCaught::
text "Gotcha! @"
text_ram wEnemyMonNick
text_start
line "was caught!@"
sound_caught_mon
- db "@@"
+ text_end
+
+ text_end ; unused
-Text_Promptbutton_2::
+_WaitButtonText::
text_promptbutton
- db "@"
+ text_end
-Text_SentToBillsPC_::
+_BallSentToPCText::
text_ram wMonOrItemNameBuffer
text " was"
line "sent to BILL's PC."
prompt
-Text_MonNewlyAddedToPokedex_::
+_NewDexDataText::
text_ram wEnemyMonNick
text "'s data"
line "was newly added to"
cont "the #DEX.@"
sound_slot_machine_start
text_promptbutton
- db "@"
+ text_end
-Text_AskNicknameNewlyCaughtMon_::
+_AskGiveNicknameText::
text "Give a nickname to"
line "@"
text_ram wStringBuffer1
text "?"
done
-Text_StatRoseFromVitamin_::
+_ItemStatRoseText::
text_ram wStringBuffer1
text "'s"
line "@"
@@ -297,18 +302,18 @@ Text_StatRoseFromVitamin_::
text " rose."
prompt
-Text_MilkDrinkCantBeUsed_::
+_ItemCantUseOnMonText::
text "That can't be used"
line "on this #MON."
prompt
-Text_RepelUsedEarlierIsStillInEffect::
+_RepelUsedEarlierIsStillInEffectText::
text "The REPEL used"
line "earlier is still"
cont "in effect."
prompt
-Text_NowThatsACatchyTune_::
+_PlayedFluteText::
text "Played the #"
line "FLUTE."
@@ -316,50 +321,53 @@ Text_NowThatsACatchyTune_::
line "catchy tune!"
prompt
-Text_AllSleepingMonWokeUp_::
+_FluteWakeUpText::
text "All sleeping"
line "#MON woke up."
prompt
-Text_PlayedThePokeFlute_::
+Text_PlayedPokeFlute::
text "<PLAYER> played the"
line "# FLUTE.@"
text_promptbutton
- db "@@"
+ text_end
+
+ text_end ; unused
-Text_CoinCase_::
+; BUG: "done" is not a valid terminator here, needs to change to "text_end"
+_CoinCaseCountText::
text "Coins:"
line "@"
text_decimal wCoins, 2, 4
done
-Text_RaiseThePPOfWhichMove_::
+_RaiseThePPOfWhichMoveText::
text "Raise the PP of"
line "which move?"
done
-Text_RestoreThePPOfWhichMove_::
+_RestoreThePPOfWhichMoveText::
text "Restore the PP of"
line "which move?"
done
-Text_PPIsMaxedOut_::
+_PPIsMaxedOutText::
text_ram wStringBuffer2
text "'s PP"
line "is maxed out."
prompt
-Text_PPsIncreased_::
+_PPsIncreasedText::
text_ram wStringBuffer2
text "'s PP"
line "increased."
prompt
-Text_PPWasRestored_::
+_PPRestoredText::
text "PP was restored."
prompt
-Text_TrophyInside_::
+_SentTrophyHomeText::
text "There was a trophy"
line "inside!@"
sound_dex_fanfare_50_79
@@ -371,73 +379,73 @@ Text_TrophyInside_::
line "trophy home."
prompt
-Text_LooksBitter_::
+_ItemLooksBitterText::
text "It looks bitter…"
prompt
-Text_CantUseOnEgg_::
+_ItemCantUseOnEggText::
text "That can't be used"
line "on an EGG."
prompt
-Text_IsntTheTimeToUseThat_::
+_ItemOakWarningText::
text "OAK: <PLAYER>!"
line "This isn't the"
cont "time to use that!"
prompt
-Text_BelongsToSomeoneElse_::
+_ItemBelongsToSomeoneElseText::
text "That belongs to"
line "someone else!"
prompt
-Text_WontHaveAnyEffect_::
+_ItemWontHaveEffectText::
text "It won't have any"
line "effect."
prompt
-Text_BlockedTheBall_::
+_BallBlockedText::
text "The trainer"
line "blocked the BALL!"
prompt
-Text_DontBeAThief_::
+_BallDontBeAThiefText::
text "Don't be a thief!"
prompt
-Text_CyclingIsntAllowed_::
+_NoCyclingText::
text "Cycling isn't"
line "allowed here."
prompt
-Text_CantGetOnYourItemNow_::
+_ItemCantGetOnText::
text "Can't get on your"
line "@"
text_ram wStringBuffer1
text " now."
prompt
-Text_CantUseBallBoxIsFull_::
+_BallBoxFullText::
text "The #MON BOX"
line "is full. That"
cont "can't be used now."
prompt
-Text_UsedItem_::
+_ItemUsedText::
text "<PLAYER> used the"
line "@"
text_ram wStringBuffer2
text "."
done
-Text_GotOnItem_::
+_ItemGotOnText::
text "<PLAYER> got on the@"
text_low
text_ram wStringBuffer2
text "."
prompt
-Text_GotOffItem_::
+_ItemGotOffText::
text "<PLAYER> got off@"
text_low
text "the @"
diff --git a/engine/events/daycare.asm b/engine/events/daycare.asm
index 4cd12087..9cbe61ce 100644
--- a/engine/events/daycare.asm
+++ b/engine/events/daycare.asm
@@ -321,7 +321,7 @@ PrintDayCareText:
.CantAcceptEgg:
; Sorry, but I can't accept an EGG.
- text_far _CantRaiseEggText
+ text_far _CantAcceptEggText
db "@"
.RemoveMail:
@@ -376,7 +376,7 @@ PrintDayCareText:
.NotEnoughMoney:
; You don't have enough money.
- text_far _DCNotEnoughMoneyText
+ text_far _NotEnoughMoneyText
db "@"
.OhFineThen:
@@ -456,7 +456,7 @@ DayCareManOutside:
.IllKeepItThanksText:
; Well then, I'll keep it. Thanks!
- text_far _RefuseEggText
+ text_far _IllKeepItThanksText
db "@"
.PartyFullText:
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"
diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm
index 44babe34..761f84c3 100644
--- a/engine/pokegear/radio.asm
+++ b/engine/pokegear/radio.asm
@@ -450,7 +450,7 @@ OaksPKMNTalk9:
dw .OPT_SuaveDebonairText
dw .OPT_PowerfulText
dw .OPT_ExcitingText
- dw .OPT_GroovyText
+ dw .OPT_NowText
dw .OPT_InspiringText
dw .OPT_FriendlyText
dw .OPT_HotHotHotText
@@ -491,8 +491,8 @@ OaksPKMNTalk9:
text_far _OPT_ExcitingText
text_end
-.OPT_GroovyText:
- text_far _OPT_GroovyText
+.OPT_NowText:
+ text_far _OPT_NowText
text_end
.OPT_InspiringText:
diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm
index 25166209..0975c750 100644
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -1,24 +1,24 @@
_BillsPC:
- call BillsPC_CheckHavePokemon
+ call .CheckCanUsePC
ret c
- call BillsPC_LogIn
- call BillsPC_UsePC
- jp BillsPC_LogOut
+ call .LogIn
+ call .UseBillsPC
+ jp .LogOut
-BillsPC_CheckHavePokemon: ; e3e5 (3:63e5)
- ld a, [wPokemonData]
+.CheckCanUsePC:
+ ld a, [wPartyCount]
and a
ret nz
- ld hl, Text_GottaHavePokemon
+ ld hl, .PCGottaHavePokemonText
call MenuTextboxBackup
scf
ret
-Text_GottaHavePokemon:
- text_far Text_GottaHavePokemon_
- db "@"
+.PCGottaHavePokemonText:
+ text_far _PCGottaHavePokemonText
+ text_end
-BillsPC_LogIn: ; e3f7 (3:63f7)
+.LogIn:
xor a
ldh [hBGMapMode], a
call LoadStandardMenuHeader
@@ -26,57 +26,56 @@ BillsPC_LogIn: ; e3f7 (3:63f7)
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
- ld hl, Text_BillsPCWhat
+ set NO_TEXT_SCROLL, [hl]
+ ld hl, .PCWhatText
call PrintText
pop af
ld [wOptions], a
call LoadFontsBattleExtra
ret
-Text_BillsPCWhat:
- text_far Text_BillsPCWhat_
- db "@"
+.PCWhatText:
+ text_far _PCWhatText
+ text_end
-BillsPC_LogOut: ; e41a (3:641a)
+.LogOut:
call CloseSubmenu
ret
-BillsPC_UsePC: ; e41e (3:641e)
- ld hl, BillsPC_TopMenuDataHeader
+.UseBillsPC:
+ ld hl, .MenuHeader
call LoadMenuHeader
ld a, $1
-.asm_e426
+.loop
ld [wMenuCursorBuffer], a
call SetPalettes
xor a
ld [wWhichIndexSet], a
ldh [hBGMapMode], a
call DoNthMenu
- jr c, .asm_e446
+ jr c, .cancel
ld a, [wMenuCursorBuffer]
push af
ld a, [wMenuSelection]
- ld hl, BillsPC_TopMenuJumptable
+ ld hl, .Jumptable
rst JumpTable
pop bc
ld a, b
- jr nc, .asm_e426
-.asm_e446
+ jr nc, .loop
+.cancel
call CloseWindow
ret
-BillsPC_TopMenuDataHeader:
- db $40
- db 00, 00
- db 17, 19
- dw .MenuData2
- db 1
-
-.MenuData2:
- db $80
- db 0
- dw BillsPC_TopMenuItems
+.MenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_CURSOR ; flags
+ db 0 ; items
+ dw .items
dw PlaceMenuStrings
dw .strings
@@ -87,16 +86,20 @@ BillsPC_TopMenuDataHeader:
db "MOVE <PK><MN> W/O MAIL@"
db "SEE YA!@"
-BillsPC_TopMenuJumptable:
+.Jumptable:
dw BillsPC_WithdrawMenu
dw BillsPC_DepositMenu
dw BillsPC_ChangeBoxMenu
dw BillsPC_MovePKMNMenu
dw BillsPC_SeeYa
-BillsPC_TopMenuItems:
- db 5
- db 0, 1, 2, 3, 4
+.items
+ db 5 ; # items
+ db 0 ; WITHDRAW
+ db 1 ; DEPOSIT
+ db 2 ; CHANGE BOX
+ db 3 ; MOVE PKMN
+ db 4 ; SEE YA!
db -1
BillsPC_SeeYa:
@@ -105,121 +108,123 @@ BillsPC_SeeYa:
BillsPC_MovePKMNMenu:
call LoadStandardMenuHeader
- farcall IsAnyPokemonHoldingMail ; 11:488c
- jr nc, .asm_e4bb
- ld hl, Text_PleaseRemoveMailBeforeMovePkmnWOMail
+ farcall IsAnyMonHoldingMail
+ jr nc, .no_mail
+ ld hl, .PCMonHoldingMailText
call PrintText
- jr .asm_e4cf
+ jr .quit
-.asm_e4bb
+.no_mail
farcall StartMoveMonWOMail_SaveGame
- jr c, .asm_e4cf
- farcall MovePKMNWithoutMail_ ; 38:6f47
+ jr c, .quit
+ farcall _MovePKMNWithoutMail
call ReturnToMapFromSubmenu
call ClearPCItemScreen
-.asm_e4cf
+
+.quit
call CloseWindow
and a
ret
-Text_PleaseRemoveMailBeforeMovePkmnWOMail:
- text_far Text_PleaseRemoveMailBeforeMovePkmnWOMail_
- db "@"
+.PCMonHoldingMailText:
+ text_far _PCMonHoldingMailText
+ text_end
BillsPC_DepositMenu:
call LoadStandardMenuHeader
- farcall DepositPokemon_ ; 38:6b9e
+ farcall _DepositPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
call CloseWindow
and a
ret
-Functione4ed:
+Unreferenced_Functione4ed:
ld a, [wPartyCount]
and a
- jr z, .asm_e4f9
- cp $2
- jr c, .asm_e501
+ jr z, .no_mon
+ cp 2
+ jr c, .only_one_mon
and a
ret
-.asm_e4f9
- ld hl, Text_YouDontHaveASinglePokemon
+.no_mon
+ ld hl, .PCNoSingleMonText
call MenuTextboxBackup
scf
ret
-.asm_e501
- ld hl, Text_ItsYourLastPokemon
+.only_one_mon
+ ld hl, .PCCantDepositLastMonText
call MenuTextboxBackup
scf
ret
-Text_YouDontHaveASinglePokemon:
- text_far Text_YouDontHaveASinglePokemon_
- db "@"
+.PCNoSingleMonText:
+ text_far _PCNoSingleMonText
+ text_end
-Text_ItsYourLastPokemon:
- text_far Text_ItsYourLastPokemon_
- db "@"
+.PCCantDepositLastMonText:
+ text_far _PCCantDepositLastMonText
+ text_end
-CheckCurPartyMonFainted: ; e513 (3:6513)
+CheckCurPartyMonFainted:
ld hl, wPartyMon1HP
- ld de, $30
+ ld de, PARTYMON_STRUCT_LENGTH
ld b, $0
-.asm_e51b
+.loop
ld a, [wCurPartyMon]
cp b
- jr z, .asm_e526
+ jr z, .skip
ld a, [hli]
or [hl]
- jr nz, .asm_e532
+ jr nz, .notfainted
dec hl
-.asm_e526
+
+.skip
inc b
ld a, [wPartyCount]
cp b
- jr z, .asm_e530
+ jr z, .done
add hl, de
- jr .asm_e51b
+ jr .loop
-.asm_e530
+.done
scf
ret
-.asm_e532
+.notfainted
and a
ret
BillsPC_WithdrawMenu:
call LoadStandardMenuHeader
- farcall WithdrawPokemon_ ; 38:6d71
+ farcall _WithdrawPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
call CloseWindow
and a
ret
-Functione548:
+Unreferenced_Functione548:
ld a, [wPartyCount]
- cp $6
+ cp PARTY_LENGTH
jr nc, .asm_e551
and a
ret
.asm_e551
- ld hl, Text_CantTakeAnyMorePokemon
+ ld hl, PCCantTakeText
call MenuTextboxBackup
scf
ret
-Text_CantTakeAnyMorePokemon:
- text_far Text_CantTakeAnyMorePokemon_
- db "@"
+PCCantTakeText:
+ text_far _PCCantTakeText
+ text_end
BillsPC_ChangeBoxMenu:
- farcall ChangeBox_
+ farcall _ChangeBox
and a
ret
@@ -237,32 +242,32 @@ ClearPCItemScreen:
lb bc, 10, 18
call Textbox
hlcoord 0, 12
- ld bc, IncGradGBPalTable_13
+ lb bc, 4, 18
call Textbox
call WaitBGMap2
- call SetPalettes
+ call SetPalettes ; load regular palettes?
ret
CopyBoxmonToTempMon:
ld a, [wCurPartyMon]
ld hl, sBoxMon1Species
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld de, wTempMonSpecies
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, BANK(sBoxMon1Species)
call OpenSRAM
call CopyBytes
call CloseSRAM
ret
-Function65b4:
+Unreferenced_LoadBoxMonListing:
ld a, [wCurBox]
cp b
- jr z, .asm_e5cc
+ jr z, .same_box
ld a, b
- ld hl, Bank3BoxAddrs
- ld bc, $3
+ ld hl, .BoxAddrs
+ ld bc, 3
call AddNTimes
ld a, [hli]
push af
@@ -270,29 +275,30 @@ Function65b4:
ld h, [hl]
ld l, a
pop af
- jr .asm_e5d1
+ jr .okay
-.asm_e5cc
+.same_box
ld a, BANK(sBoxCount)
ld hl, sBoxCount
-.asm_e5d1
+
+.okay
call OpenSRAM
ld a, [hl]
- ld bc, sBoxMon1 - sBox
+ ld bc, sBoxMons - sBox
add hl, bc
ld b, a
ld c, $0
ld de, wBoxPartialData
ld a, b
and a
- jr z, .asm_e645
-.asm_e5e3
+ jr z, .empty_box
+.loop
push hl
push bc
ld a, c
- ld bc, $0
+ ld bc, sBoxMon1Species - sBoxMons
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
@@ -301,6 +307,7 @@ Function65b4:
call GetBaseData
pop bc
pop hl
+
push hl
push bc
ld a, c
@@ -310,24 +317,26 @@ Function65b4:
call CopyBytes
pop bc
pop hl
+
push hl
push bc
ld a, c
- ld bc, $1f
+ ld bc, MON_LEVEL
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
inc de
pop bc
pop hl
+
push hl
push bc
ld a, c
- ld bc, $15
+ ld bc, MON_DVS
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
and $f0
@@ -340,21 +349,22 @@ Function65b4:
ld a, [wBaseGender]
cp b
ld a, $1
- jr c, .asm_e63d
+ jr c, .okay2
xor a
-.asm_e63d
+.okay2
ld [de], a
inc de
pop bc
pop hl
+
inc c
dec b
- jr nz, .asm_e5e3
-.asm_e645
+ jr nz, .loop
+.empty_box
call CloseSRAM
ret
-Bank3BoxAddrs:
+.BoxAddrs:
dba sBox1
dba sBox2
dba sBox3
diff --git a/engine/pokemon/health.asm b/engine/pokemon/health.asm
index 8bf0752a..022477b0 100755
--- a/engine/pokemon/health.asm
+++ b/engine/pokemon/health.asm
@@ -4,12 +4,12 @@ HealParty: ; c69d (3:469d)
ld hl, wPartySpecies
.asm_c6a4
ld a, [hli]
- cp $ff
+ cp -1
jr z, .asm_c6bb
- cp $fd
+ cp EGG
jr z, .asm_c6b2
push hl
- call Functionc6bc
+ call HealPartyMon
pop hl
.asm_c6b2
ld a, [wCurPartyMon]
@@ -20,7 +20,7 @@ HealParty: ; c69d (3:469d)
.asm_c6bb
ret
-Functionc6bc: ; c6bc (3:46bc)
+HealPartyMon:
ld a, $0
call GetPartyParamLocation
ld d, h
diff --git a/engine/pokemon/learn.asm b/engine/pokemon/learn.asm
index fe6ff121..2c66dcd5 100644
--- a/engine/pokemon/learn.asm
+++ b/engine/pokemon/learn.asm
@@ -1,131 +1,150 @@
LearnMove:
call LoadTilemapToTempTilemap
ld a, [wCurPartyMon]
- ld hl, wPartyMon1Nickname
+ ld hl, wPartyMonNicknames
call GetNick
ld hl, wStringBuffer1
ld de, wMonOrItemNameBuffer
- ld bc, $b
+ ld bc, MON_NAME_LENGTH
call CopyBytes
+
.loop
ld hl, wPartyMon1Moves
- ld bc, $30
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld d, h
ld e, l
- ld b, $4
-.asm_660f
+ ld b, NUM_MOVES
+; Get the first empty move slot. This routine also serves to
+; determine whether the Pokemon learning the moves already has
+; all four slots occupied, in which case one would need to be
+; deleted.
+.next
ld a, [hl]
and a
- jr z, .asm_6643
+ jr z, .learn
inc hl
dec b
- jr nz, .asm_660f
+ jr nz, .next
+; If we're here, we enter the routine for forgetting a move
+; to make room for the new move we're trying to learn.
push de
- call .AlreadyHaveFourMoves
+ call ForgetMove
pop de
- jp c, .ConfirmStopLearning
+ jp c, .cancel
+
push hl
push de
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
+
ld b, a
ld a, [wBattleMode]
and a
- jr z, .asm_6638
+ jr z, .not_disabled
ld a, [wDisabledMove]
cp b
- jr nz, .asm_6638
+ jr nz, .not_disabled
xor a
ld [wDisabledMove], a
ld [wPlayerDisableCount], a
-.asm_6638
+.not_disabled
+
call GetMoveName
- ld hl, Text_1_2_and_Poof
+ ld hl, Text_1_2_and_Poof ; 1, 2 and…
call PrintText
pop de
pop hl
-.asm_6643
+
+.learn
ld a, [wPutativeTMHMMove]
ld [hl], a
- ld bc, $15
+ ld bc, MON_PP - MON_MOVES
add hl, bc
+
push hl
push de
dec a
- ld hl, Moves + MOVE_PP ; $5b03
- ld bc, $7
+ ld hl, Moves + MOVE_PP
+ ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
pop de
pop hl
+
ld [hl], a
+
ld a, [wBattleMode]
and a
- jp z, .LearnedMove
+ jp z, .learned
+
ld a, [wCurPartyMon]
ld b, a
ld a, [wCurBattleMon]
cp b
- jp nz, .LearnedMove
+ jp nz, .learned
+
ld a, [wPlayerSubStatus5]
- bit 3, a
- jp nz, .LearnedMove
+ bit SUBSTATUS_TRANSFORMED, a
+ jp nz, .learned
+
ld h, d
ld l, e
ld de, wBattleMonMoves
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
- ld bc, $11
+ ld bc, wPartyMon1PP - (wPartyMon1Moves + NUM_MOVES)
add hl, bc
ld de, wBattleMonPP
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
- jp .LearnedMove
+ jp .learned
-.ConfirmStopLearning: ; 6694 (1:6694)
- ld hl, Text_StopLearning
+.cancel
+ ld hl, StopLearningMoveText
call PrintText
call YesNoBox
jp c, .loop
- ld hl, Text_DidNotLearn
+
+ ld hl, DidNotLearnMoveText
call PrintText
- ld b, $0
+ ld b, 0
ret
-.LearnedMove: ; 66a9 (1:66a9)
- ld hl, Text_LearnedMove
+.learned
+ ld hl, LearnedMoveText
call PrintText
- ld b, $1
+ ld b, 1
ret
-.AlreadyHaveFourMoves: ; 66b2 (1:66b2)
+ForgetMove:
push hl
- ld hl, Text_TryingToLearn
+ ld hl, AskForgetMoveText
call PrintText
call YesNoBox
pop hl
ret c
- ld bc, -4
+ ld bc, -NUM_MOVES
add hl, bc
push hl
ld de, wListMoves_MoveIndicesBuffer
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
pop hl
-.asm_66cd
+.loop
push hl
- ld hl, Text_ForgetWhich
+ ld hl, MoveAskForgetText
call PrintText
hlcoord 5, 2
- ld b, $8
- ld c, $d
+ ld b, NUM_MOVES * 2
+ ld c, MOVE_NAME_LENGTH
call Textbox
- hlcoord 7, 4
- ld a, $28
+ hlcoord 5 + 2, 2 + 2
+ ld a, SCREEN_WIDTH * 2
ld [wBuffer1], a
predef ListMoves
+ ; w2DMenuData
ld a, $4
ld [w2DMenuCursorInitY], a
ld a, $6
@@ -151,12 +170,12 @@ LearnMove:
pop af
pop hl
bit 1, a
- jr nz, .asm_6748
+ jr nz, .cancel
push hl
ld a, [wMenuCursorY]
dec a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
push af
@@ -165,56 +184,56 @@ LearnMove:
pop bc
pop de
ld a, d
- jr c, .asm_673f
+ jr c, .hmmove
pop hl
add hl, bc
and a
ret
-.asm_673f
- ld hl, Text_CantForgetHM
+.hmmove
+ ld hl, MoveCantForgetHMText
call PrintText
pop hl
- jr .asm_66cd
+ jr .loop
-.asm_6748
+.cancel
scf
ret
-Text_LearnedMove:
- text_far Text_LearnedMove_
- db "@"
+LearnedMoveText:
+ text_far _LearnedMoveText
+ text_end
-Text_ForgetWhich:
- text_far Text_ForgetWhich_
- db "@"
+MoveAskForgetText:
+ text_far _MoveAskForgetText
+ text_end
-Text_StopLearning:
- text_far Text_StopLearning_
- db "@"
+StopLearningMoveText:
+ text_far _StopLearningMoveText
+ text_end
-Text_DidNotLearn:
- text_far Text_DidNotLearn_
- db "@"
+DidNotLearnMoveText:
+ text_far _DidNotLearnMoveText
+ text_end
-Text_TryingToLearn:
- text_far Text_TryingToLearn_
- db "@"
+AskForgetMoveText:
+ text_far _AskForgetMoveText
+ text_end
Text_1_2_and_Poof:
- text_far Text_1_2_and_Poof_
+ text_far Text_MoveForgetCount ; 1, 2 and…
text_asm
push de
ld de, SFX_SWITCH_POKEMON
call PlaySFX
pop de
- ld hl, .PoofForgot
+ ld hl, .MoveForgotText
ret
-.PoofForgot:
- text_far Text_PoofForgot_
- db "@"
+.MoveForgotText:
+ text_far _MoveForgotText
+ text_end
-Text_CantForgetHM:
- text_far Text_CantForgetHM_
- db "@"
+MoveCantForgetHMText:
+ text_far _MoveCantForgetHMText
+ text_end
diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm
index c4ecbdc7..566e23ee 100755
--- a/engine/pokemon/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
@@ -1,34 +1,47 @@
-TryAddMonToParty:: ; d892 (3:5892)
+RANDY_OT_ID EQU 01001
+
+TryAddMonToParty:
+; Check if to copy wild mon or generate a new one
+ ; Whose is it?
ld de, wPartyCount
ld a, [wMonType]
and $f
- jr z, .asm_d89f
+ jr z, .getpartylocation ; PARTYMON
ld de, wOTPartyCount
-.asm_d89f
+
+.getpartylocation
+ ; Do we have room for it?
ld a, [de]
inc a
- cp $7
+ cp PARTY_LENGTH + 1
ret nc
+ ; Increase the party count
ld [de], a
- ld a, [de]
- ldh [hMoveMon], a
+ ld a, [de] ; Why are we doing this?
+ ldh [hMoveMon], a ; HRAM backup
add e
ld e, a
- jr nc, .asm_d8ad
+ jr nc, .loadspecies
inc d
-.asm_d8ad
+
+.loadspecies
+ ; Load the species of the Pokemon into the party list.
+ ; The terminator is usually here, but it'll be back.
ld a, [wCurPartySpecies]
ld [de], a
+ ; Load the terminator into the next slot.
inc de
- ld a, $ff
+ ld a, -1
ld [de], a
- ld hl, wPartyMon1OT
+ ; Now let's load the OT name.
+ ld hl, wPartyMonOT
ld a, [wMonType]
and $f
- jr z, .asm_d8c2
+ jr z, .loadOTname
ld hl, wOTPartyMonOT
-.asm_d8c2
- ldh a, [hMoveMon]
+
+.loadOTname
+ ldh a, [hMoveMon] ; Restore index from backup
dec a
call SkipNames
ld d, h
@@ -36,11 +49,12 @@ TryAddMonToParty:: ; d892 (3:5892)
ld hl, wPlayerName
ld bc, NAME_LENGTH
call CopyBytes
+ ; Only initialize the nickname for party mon
ld a, [wMonType]
and a
- jr nz, .asm_d8f6
+ jr nz, .skipnickname
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
ld hl, wPartyMonNicknames
ldh a, [hMoveMon]
@@ -49,74 +63,83 @@ TryAddMonToParty:: ; d892 (3:5892)
ld d, h
ld e, l
ld hl, wStringBuffer1
- ld bc, NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
-.asm_d8f6
+
+.skipnickname
ld hl, wPartyMon1Species
ld a, [wMonType]
and $f
- jr z, .asm_d903
- ld hl, wOTPartyMon1
-.asm_d903
+ jr z, .initializeStats
+ ld hl, wOTPartyMon1Species
+
+.initializeStats
ldh a, [hMoveMon]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
GeneratePartyMonStats:
+; wBattleMode specifies whether it's a wild mon or not.
+; wMonType specifies whether it's an opposing mon or not.
+; wCurPartySpecies/wCurPartyLevel specify the species and level.
+; hl points to the wPartyMon struct to fill.
+
ld e, l
ld d, h
push hl
+
+ ; Initialize the species
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
call GetBaseData
ld a, [wBaseDexNo]
ld [de], a
inc de
+
+ ; Copy the item if it's a wild mon
ld a, [wBattleMode]
and a
ld a, $0
- jr z, .asm_d928
+ jr z, .skipitem
ld a, [wEnemyMonItem]
-.asm_d928
+.skipitem
ld [de], a
inc de
+
+ ; Copy the moves if it's a wild mon
push de
ld h, d
ld l, e
ld a, [wBattleMode]
and a
- jr z, .asm_d949
+ jr z, .randomlygeneratemoves
ld a, [wMonType]
and a
- jr nz, .asm_d949
+ jr nz, .randomlygeneratemoves
ld de, wEnemyMonMoves
+rept NUM_MOVES - 1
ld a, [de]
inc de
ld [hli], a
- ld a, [de]
- inc de
- ld [hli], a
- ld a, [de]
- inc de
- ld [hli], a
+endr
ld a, [de]
ld [hl], a
- jr .asm_d956
+ jr .next
-.asm_d949
+.randomlygeneratemoves
xor a
+rept NUM_MOVES - 1
ld [hli], a
- ld [hli], a
- ld [hli], a
+endr
ld [hl], a
- ld [wBuffer1], a
+ ld [wEvolutionOldSpecies], a
predef FillMoves
-.asm_d956
+
+.next
pop de
+rept NUM_MOVES
inc de
- inc de
- inc de
- inc de
+endr
; Initialize ID.
ld a, [wPlayerID]
@@ -145,47 +168,53 @@ GeneratePartyMonStats:
; Initialize stat experience.
xor a
ld b, MON_DVS - MON_STAT_EXP
-.asm_d980
+.loop
ld [de], a
inc de
dec b
- jr nz, .asm_d980
+ jr nz, .loop
+
pop hl
push hl
ld a, [wMonType]
and $f
- jr z, .asm_d998
+ jr z, .registerpokedex
+
push hl
- farcall GetTrainerDVs ; 9:7271
+ farcall GetTrainerDVs
pop hl
- jr .asm_d9bb
+ jr .initializeDVs
-.asm_d998
+.registerpokedex
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wTempSpecies], a
dec a
push de
call CheckCaughtMon
- ld a, [wd151]
+ ld a, [wTempSpecies]
dec a
call SetSeenAndCaughtMon
pop de
+
pop hl
push hl
ld a, [wBattleMode]
and a
- jr nz, .asm_d9f9
+ jr nz, .copywildmonDVs
+
call Random
ld b, a
call Random
ld c, a
-.asm_d9bb
+.initializeDVs
ld a, b
ld [de], a
inc de
ld a, c
ld [de], a
inc de
+
+ ; Initialize PP.
push hl
push de
inc hl
@@ -193,33 +222,45 @@ GeneratePartyMonStats:
call FillPP
pop de
pop hl
+rept NUM_MOVES
inc de
- inc de
- inc de
- inc de
- ld a, $46
+endr
+
+ ; Initialize happiness.
+ ld a, BASE_HAPPINESS
ld [de], a
inc de
+
xor a
+ ; PokerusStatus
ld [de], a
inc de
+ ; CaughtData/CaughtTime/CaughtLevel
ld [de], a
inc de
+ ; CaughtGender/CaughtLocation
ld [de], a
inc de
+
+ ; Initialize level.
ld a, [wCurPartyLevel]
ld [de], a
inc de
+
xor a
+ ; Status
ld [de], a
inc de
+ ; Unused
ld [de], a
inc de
- ld bc, $a
+
+ ; Initialize HP.
+ ld bc, MON_STAT_EXP - 1
add hl, bc
- ld a, $1
+ ld a, 1
ld c, a
- ld b, $0
+ ld b, FALSE
call CalcMonStatC
ldh a, [hProduct + 2]
ld [de], a
@@ -227,128 +268,147 @@ GeneratePartyMonStats:
ldh a, [hProduct + 3]
ld [de], a
inc de
- jr .asm_da2f
+ jr .initstats
-.asm_d9f9
- ld a, [wEnemyMonMovesEnd]
+.copywildmonDVs
+ ld a, [wEnemyMonDVs]
ld [de], a
inc de
- ld a, [wEnemyMonMovesEnd + 1]
+ ld a, [wEnemyMonDVs + 1]
ld [de], a
inc de
+
push hl
ld hl, wEnemyMonPP
- ld b, $4
-.asm_da09
+ ld b, NUM_MOVES
+.wildmonpploop
ld a, [hli]
ld [de], a
inc de
dec b
- jr nz, .asm_da09
+ jr nz, .wildmonpploop
pop hl
- ld a, $46
+
+ ; Initialize happiness.
+ ld a, BASE_HAPPINESS
ld [de], a
inc de
+
xor a
+ ; PokerusStatus
ld [de], a
inc de
+ ; CaughtData/CaughtTime/CaughtLevel
ld [de], a
inc de
+ ; CaughtGender/CaughtLocation
ld [de], a
inc de
+
+ ; Initialize level.
ld a, [wCurPartyLevel]
ld [de], a
inc de
+
ld hl, wEnemyMonStatus
+ ; Copy wEnemyMonStatus
ld a, [hli]
ld [de], a
inc de
+ ; Copy EnemyMonUnused
ld a, [hli]
ld [de], a
inc de
+ ; Copy wEnemyMonHP
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
inc de
-.asm_da2f
+
+.initstats
ld a, [wBattleMode]
dec a
- jr nz, .asm_da41
+ jr nz, .generatestats
ld hl, wEnemyMonMaxHP
- ld bc, $c
+ ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP
call CopyBytes
pop hl
- jr .asm_da4b
+ jr .registerunowndex
-.asm_da41
+.generatestats
pop hl
- ld bc, $a
+ ld bc, MON_STAT_EXP - 1
add hl, bc
- ld b, $0
+ ld b, FALSE
call CalcMonStats
-.asm_da4b
+
+.registerunowndex
ld a, [wMonType]
and $f
- jr nz, .asm_da71
+ jr nz, .done
ld a, [wCurPartySpecies]
- cp $c9
- jr nz, .asm_da71
+ cp UNOWN
+ jr nz, .done
ld hl, wPartyMon1DVs
- ld a, [wPokemonData]
+ ld a, [wPartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
predef GetUnownLetter
callfar UpdateUnownDex
-.asm_da71
- scf
+
+.done
+ scf ; When this function returns, the carry flag indicates success vs failure.
ret
-FillPP: ; da73 (3:5a73)
+FillPP:
push bc
- ld b, $4
-.asm_da76
+ ld b, NUM_MOVES
+.loop
ld a, [hli]
and a
- jr z, .asm_da95
+ jr z, .next
dec a
push hl
push de
push bc
- ld hl, $5afe
- ld bc, $7
+ ld hl, Moves
+ ld bc, MOVE_LENGTH
call AddNTimes
ld de, wStringBuffer1
- ld a, $10
+ ld a, BANK(Moves)
call FarCopyBytes
pop bc
pop de
pop hl
- ld a, [wStringBuffer1 + 5]
-.asm_da95
+ ld a, [wStringBuffer1 + MOVE_PP]
+
+.next
ld [de], a
inc de
dec b
- jr nz, .asm_da76
+ jr nz, .loop
pop bc
ret
-AddTempmonToParty: ; da9c (3:5a9c)
+AddTempmonToParty:
ld hl, wPartyCount
ld a, [hl]
- cp $6
+ cp PARTY_LENGTH
scf
ret z
+
inc a
ld [hl], a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [wCurPartySpecies]
ld [hli], a
ld [hl], $ff
+
ld hl, wPartyMon1Species
ld a, [wPartyCount]
dec a
@@ -358,17 +418,19 @@ AddTempmonToParty: ; da9c (3:5a9c)
ld d, h
ld hl, wTempMonSpecies
call CopyBytes
- ld hl, wPartyMon6StatsEnd
+
+ ld hl, wPartyMonOT
ld a, [wPartyCount]
dec a
call SkipNames
ld d, h
ld e, l
- ld hl, wOTPartyMon6StatsEnd
+ ld hl, wOTPartyMonOT
ld a, [wCurPartyMon]
call SkipNames
ld bc, NAME_LENGTH
call CopyBytes
+
ld hl, wPartyMonNicknames
ld a, [wPartyCount]
dec a
@@ -378,24 +440,26 @@ AddTempmonToParty: ; da9c (3:5a9c)
ld hl, wOTPartyMonNicknames
ld a, [wCurPartyMon]
call SkipNames
- ld bc, NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
+
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
cp EGG
- jr z, .asm_db18
+ jr z, .egg
dec a
call SetSeenAndCaughtMon
ld hl, wPartyMon1Happiness
- ld a, [wPokemonData]
+ ld a, [wPartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
- ld [hl], 70
-.asm_db18
+ ld [hl], BASE_HAPPINESS
+.egg
+
ld a, [wCurPartySpecies]
cp UNOWN
- jr nz, .asm_db43
+ jr nz, .done
ld hl, wPartyMon1DVs
ld a, [wPartyCount]
dec a
@@ -405,62 +469,76 @@ AddTempmonToParty: ; da9c (3:5a9c)
callfar UpdateUnownDex
ld a, [wFirstUnownSeen]
and a
- jr nz, .asm_db43
+ jr nz, .done
ld a, [wUnownLetter]
ld [wFirstUnownSeen], a
-.asm_db43
+.done
+
and a
ret
-SendGetMonIntoFromBox: ; db45 (3:5b45)
- ld a, $1
+SendGetMonIntoFromBox:
+; Sents/Gets mon into/from Box depending on Parameter
+; wPokemonWithdrawDepositParameter == 0: get mon into Party
+; wPokemonWithdrawDepositParameter == 1: sent mon into Box
+; wPokemonWithdrawDepositParameter == 2: get mon from DayCare
+; wPokemonWithdrawDepositParameter == 3: put mon into DayCare
+
+ ld a, BANK(sBoxCount)
call OpenSRAM
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_db66
- cp $2
- jr z, .asm_db66
- cp $3
+ jr z, .check_IfPartyIsFull
+ cp DAY_CARE_WITHDRAW
+ jr z, .check_IfPartyIsFull
+ cp DAY_CARE_DEPOSIT
ld hl, wBreedMon1Species
- jr z, .asm_dba1
+ jr z, .breedmon
+
+ ; we want to sent a mon into the Box
+ ; so check if there's enough space
ld hl, sBoxCount
ld a, [hl]
cp MONS_PER_BOX
- jr nz, .asm_db6f
- jp Functiondcb7
+ jr nz, .there_is_room
+ jp CloseSRAM_And_SetCarryFlag
-.asm_db66
+.check_IfPartyIsFull
ld hl, wPartyCount
ld a, [hl]
- cp $6
- jp z, Functiondcb7
-.asm_db6f
+ cp PARTY_LENGTH
+ jp z, CloseSRAM_And_SetCarryFlag
+
+.there_is_room
inc a
ld [hl], a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [wPokemonWithdrawDepositParameter]
- cp $2
+ cp DAY_CARE_WITHDRAW
ld a, [wBreedMon1Species]
- jr z, .asm_db82
+ jr z, .okay1
ld a, [wCurPartySpecies]
-.asm_db82
+
+.okay1
ld [hli], a
ld [hl], $ff
ld a, [wPokemonWithdrawDepositParameter]
dec a
- ld hl, wPartyMons
+ ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
- ld a, [wPokemonData]
- jr nz, .asm_db9d
+ ld a, [wPartyCount]
+ jr nz, .okay2
ld hl, sBoxMon1Species
ld bc, BOXMON_STRUCT_LENGTH
ld a, [sBoxCount]
-.asm_db9d
- dec a
+
+.okay2
+ dec a ; wPartyCount - 1
call AddNTimes
-.asm_dba1
+
+.breedmon
push hl
ld e, l
ld d, h
@@ -468,84 +546,96 @@ SendGetMonIntoFromBox: ; db45 (3:5b45)
and a
ld hl, sBoxMon1Species
ld bc, BOXMON_STRUCT_LENGTH
- jr z, .asm_dbbd
- cp $2
+ jr z, .okay3
+ cp DAY_CARE_WITHDRAW
ld hl, wBreedMon1Species
- jr z, .asm_dbc3
+ jr z, .okay4
ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
-.asm_dbbd
+
+.okay3
ld a, [wCurPartyMon]
call AddNTimes
-.asm_dbc3
+
+.okay4
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
ld a, [wPokemonWithdrawDepositParameter]
- cp $3
+ cp DAY_CARE_DEPOSIT
ld de, wBreedMon1OT
- jr z, .asm_dbe8
+ jr z, .okay5
dec a
ld hl, wPartyMonOT
- ld a, [wPokemonData]
- jr nz, .asm_dbe2
+ ld a, [wPartyCount]
+ jr nz, .okay6
ld hl, sBoxMonOT
ld a, [sBoxCount]
-.asm_dbe2
+
+.okay6
dec a
call SkipNames
ld d, h
ld e, l
-.asm_dbe8
+
+.okay5
ld hl, sBoxMonOT
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_dbfb
+ jr z, .okay7
ld hl, wBreedMon1OT
- cp $2
- jr z, .asm_dc01
- ld hl, wPartyMon6StatsEnd
-.asm_dbfb
+ cp DAY_CARE_WITHDRAW
+ jr z, .okay8
+ ld hl, wPartyMonOT
+
+.okay7
ld a, [wCurPartyMon]
call SkipNames
-.asm_dc01
+
+.okay8
ld bc, NAME_LENGTH
call CopyBytes
ld a, [wPokemonWithdrawDepositParameter]
- cp $3
+ cp DAY_CARE_DEPOSIT
ld de, wBreedMon1Nick
- jr z, .asm_dc26
+ jr z, .okay9
dec a
- ld hl, wPartyMon1Nickname
- ld a, [wPokemonData]
- jr nz, .asm_dc20
+ ld hl, wPartyMonNicknames
+ ld a, [wPartyCount]
+ jr nz, .okay10
ld hl, sBoxMonNicknames
ld a, [sBoxCount]
-.asm_dc20
+
+.okay10
dec a
call SkipNames
ld d, h
ld e, l
-.asm_dc26
+
+.okay9
ld hl, sBoxMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_dc39
+ jr z, .okay11
ld hl, wBreedMon1Nick
- cp $2
- jr z, .asm_dc3f
- ld hl, wPartyMon1Nickname
-.asm_dc39
+ cp DAY_CARE_WITHDRAW
+ jr z, .okay12
+ ld hl, wPartyMonNicknames
+
+.okay11
ld a, [wCurPartyMon]
call SkipNames
-.asm_dc3f
- ld bc, NAME_LENGTH
+
+.okay12
+ ld bc, MON_NAME_LENGTH
call CopyBytes
pop hl
+
ld a, [wPokemonWithdrawDepositParameter]
- cp $1
- jr z, .asm_dcaa
- cp $3
- jp z, Functiondcb2
+ cp PC_DEPOSIT
+ jr z, .took_out_of_box
+ cp DAY_CARE_DEPOSIT
+ jp z, .CloseSRAM_And_ClearCarryFlag
+
push hl
srl a
add $2
@@ -555,35 +645,38 @@ SendGetMonIntoFromBox: ; db45 (3:5b45)
ld a, d
ld [wCurPartyLevel], a
pop hl
+
ld b, h
ld c, l
- ld hl, $1f
+ ld hl, MON_LEVEL
add hl, bc
ld [hl], a
- ld hl, $24
+ ld hl, MON_MAXHP
add hl, bc
ld d, h
ld e, l
- ld hl, $a
+ ld hl, MON_STAT_EXP - 1
add hl, bc
+
push bc
- ld b, $1
+ ld b, TRUE
call CalcMonStats
pop bc
+
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr nz, Functiondcb2
- ld hl, $20
+ jr nz, .CloseSRAM_And_ClearCarryFlag
+ ld hl, MON_STATUS
add hl, bc
xor a
ld [hl], a
- ld hl, $22
+ ld hl, MON_HP
add hl, bc
ld d, h
ld e, l
ld a, [wCurPartySpecies]
- cp $fd
- jr z, .asm_dca4
+ cp EGG
+ jr z, .egg
inc hl
inc hl
ld a, [hli]
@@ -591,86 +684,88 @@ SendGetMonIntoFromBox: ; db45 (3:5b45)
ld a, [hl]
inc de
ld [de], a
- jr Functiondcb2
+ jr .CloseSRAM_And_ClearCarryFlag
-.asm_dca4
+.egg
xor a
ld [de], a
inc de
ld [de], a
- jr Functiondcb2
+ jr .CloseSRAM_And_ClearCarryFlag
-.asm_dcaa
+.took_out_of_box
ld a, [sBoxCount]
dec a
ld b, a
call RestorePPOfDepositedPokemon
-Functiondcb2: ; dcb2 (3:5cb2)
+.CloseSRAM_And_ClearCarryFlag:
call CloseSRAM
and a
ret
-Functiondcb7: ; dcb7 (3:5cb7)
+CloseSRAM_And_SetCarryFlag:
call CloseSRAM
scf
ret
RestorePPOfDepositedPokemon:
ld a, b
- ld hl, sBoxMon1Species
+ ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld b, h
ld c, l
- ld hl, $17
+ ld hl, MON_PP
add hl, bc
push hl
push bc
ld de, wTempMonPP
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
pop bc
- ld hl, $2
+ ld hl, MON_MOVES
add hl, bc
push hl
ld de, wTempMonMoves
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
pop hl
pop de
+
ld a, [wMenuCursorY]
push af
ld a, [wMonType]
push af
- ld b, $0
-.asm_dcf2
+ ld b, 0
+.loop
ld a, [hli]
and a
- jr z, .asm_dd1e
+ jr z, .done
ld [wTempMonMoves], a
- ld a, $2
+ ld a, BOXMON
ld [wMonType], a
ld a, b
ld [wMenuCursorY], a
push bc
push hl
push de
- farcall GetMaxPPOfMove ; same bank
+ farcall GetMaxPPOfMove
pop de
pop hl
- ld a, [wd151]
+ ld a, [wTempPP]
ld b, a
ld a, [de]
- and $c0
+ and %11000000
add b
ld [de], a
pop bc
inc de
inc b
ld a, b
- cp $4
- jr c, .asm_dcf2
-.asm_dd1e
+ cp NUM_MOVES
+ jr c, .loop
+
+.done
pop af
ld [wMonType], a
pop af
@@ -685,12 +780,12 @@ RetrieveMonFromDayCareMan:
call WaitSFX
call GetBreedMon1LevelGrowth
ld a, b
- ld [wMovementBufferCount], a
+ ld [wceed], a
ld a, e
ld [wCurPartyLevel], a
xor a
ld [wPokemonWithdrawDepositParameter], a
- jp Functiondd6a
+ jp RetrieveBreedmon
RetrieveMonFromDayCareLady:
ld a, [wBreedMon2Species]
@@ -700,40 +795,41 @@ RetrieveMonFromDayCareLady:
call WaitSFX
call GetBreedMon2LevelGrowth
ld a, b
- ld [wMovementBufferCount], a
+ ld [wceed], a
ld a, e
ld [wCurPartyLevel], a
- ld a, $1
+ ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
- jp Functiondd6a ; super long jump
+ jp RetrieveBreedmon
-Functiondd6a: ; dd6a (3:5d6a)
+RetrieveBreedmon:
ld hl, wPokemonData
ld a, [hl]
- cp $6
- jr nz, .asm_dd74
- scf ; We shouldn't be here if we've come this far.
+ cp PARTY_LENGTH
+ jr nz, .room_in_party
+ scf
ret
-.asm_dd74
+.room_in_party
inc a
ld [hl], a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [wPokemonWithdrawDepositParameter]
and a
ld a, [wBreedMon1Species]
ld de, wBreedMon1Nick
- jr z, .asm_dd8c
+ jr z, .okay
ld a, [wBreedMon2Species]
ld de, wBreedMon2Nick
-.asm_dd8c
+
+.okay
ld [hli], a
ld [wCurSpecies], a
ld a, $ff
ld [hl], a
- ld hl, wPartyMon1Nickname
+ ld hl, wPartyMonNicknames
ld a, [wPartyCount]
dec a
call SkipNames
@@ -752,29 +848,29 @@ Functiondd6a: ; dd6a (3:5d6a)
pop hl
call CopyBytes
push hl
- call Functionde20
+ call GetLastPartyMon
pop hl
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
call GetBaseData
- call Functionde20
+ call GetLastPartyMon
ld b, d
ld c, e
- ld hl, $1f
+ ld hl, MON_LEVEL
add hl, bc
ld a, [wCurPartyLevel]
ld [hl], a
- ld hl, $24
+ ld hl, MON_MAXHP
add hl, bc
ld d, h
ld e, l
ld hl, $a
add hl, bc
push bc
- ld b, $1
+ ld b, TRUE
call CalcMonStats
ld hl, wPartyMon1Moves
- ld a, [wPokemonData]
+ ld a, [wPartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
@@ -786,7 +882,7 @@ Functiondd6a: ; dd6a (3:5d6a)
ld a, [wPartyCount]
dec a
ld [wCurPartyMon], a
- farcall Functionc6bc ; same bank
+ farcall HealPartyMon
ld a, [wCurPartyLevel]
ld d, a
callfar CalcExpAtLevel
@@ -802,10 +898,10 @@ Functiondd6a: ; dd6a (3:5d6a)
and a
ret
-Functionde20: ; de20 (3:5e20)
+GetLastPartyMon:
ld a, [wPartyCount]
dec a
- ld hl, wPartyMon1
+ ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
@@ -814,47 +910,50 @@ Functionde20: ; de20 (3:5e20)
DepositMonWithDayCareMan:
ld de, wBreedMon1Nick
- call Functionde4a
- xor a
+ call DepositBreedmon
+ xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
jp RemoveMonFromPartyOrBox
DepositMonWithDayCareLady:
ld de, wBreedMon2Nick
- call Functionde4a
- xor a
+ call DepositBreedmon
+ xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
jp RemoveMonFromPartyOrBox
-Functionde4a: ; de4a (3:5e4a)
+DepositBreedmon:
ld a, [wCurPartyMon]
ld hl, wPartyMonNicknames
call SkipNames
call CopyBytes
ld a, [wCurPartyMon]
- ld hl, wPartyMon1OT
+ ld hl, wPartyMonOT
call SkipNames
call CopyBytes
ld a, [wCurPartyMon]
- ld hl, wPartyMon1
+ ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld bc, BOXMON_STRUCT_LENGTH
jp CopyBytes
-SendMonIntoBox: ; de74 (3:5e74)
- ld a, $1
+SendMonIntoBox:
+; Sends the mon into one of Bills Boxes
+; the data comes mainly from 'wEnemyMon:'
+ ld a, BANK(sBoxCount)
call OpenSRAM
ld de, sBoxCount
ld a, [de]
- cp $14
- jp nc, Functiondf48
+ cp MONS_PER_BOX
+ jp nc, .full
inc a
ld [de], a
+
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
ld c, a
-.asm_de8b
+.loop
inc de
ld a, [de]
ld b, a
@@ -862,25 +961,31 @@ SendMonIntoBox: ; de74 (3:5e74)
ld c, b
ld [de], a
inc a
- jr nz, .asm_de8b
+ jr nz, .loop
+
call GetBaseData
- call Functiondf4d
+ call ShiftBoxMon
+
ld hl, wPlayerName
ld de, sBoxMonOT
ld bc, NAME_LENGTH
call CopyBytes
+
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
call GetPokemonName
+
ld de, sBoxMonNicknames
ld hl, wStringBuffer1
- ld bc, NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
call CopyBytes
+
ld hl, wEnemyMon
- ld de, sBoxMon1Species
- ld bc, $6
+ ld de, sBoxMon1
+ ld bc, 1 + 1 + NUM_MOVES ; species + item + moves
call CopyBytes
- ld hl, wGameData
+
+ ld hl, wPlayerID
ld a, [hli]
ld [de], a
inc de
@@ -901,22 +1006,26 @@ SendMonIntoBox: ; de74 (3:5e74)
ldh a, [hProduct + 3]
ld [de], a
inc de
+
+ ; Set all 5 Experience Values to 0
xor a
- ld b, $a
-.asm_deeb
+ ld b, 2 * 5
+.loop2
ld [de], a
inc de
dec b
- jr nz, .asm_deeb
- ld hl, wEnemyMonMovesEnd
- ld b, $6
-.asm_def5
+ jr nz, .loop2
+
+ ld hl, wEnemyMonDVs
+ ld b, 2 + NUM_MOVES ; DVs and PP ; wEnemyMonHappiness - wEnemyMonDVs
+.loop3
ld a, [hli]
ld [de], a
inc de
dec b
- jr nz, .asm_def5
- ld a, $46
+ jr nz, .loop3
+
+ ld a, BASE_HAPPINESS
ld [de], a
inc de
xor a
@@ -932,70 +1041,80 @@ SendMonIntoBox: ; de74 (3:5e74)
dec a
call SetSeenAndCaughtMon
ld a, [wCurPartySpecies]
- cp $c9
- jr nz, .asm_df26
+ cp UNOWN
+ jr nz, .not_unown
ld hl, sBoxMon1DVs
predef GetUnownLetter
callfar UpdateUnownDex
-.asm_df26
+
+.not_unown
ld hl, sBoxMon1Moves
ld de, wTempMonMoves
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
+
ld hl, sBoxMon1PP
ld de, wTempMonPP
- ld bc, $4
+ ld bc, NUM_MOVES
call CopyBytes
- ld b, $0
+
+ ld b, 0
call RestorePPOfDepositedPokemon
+
call CloseSRAM
scf
ret
-Functiondf48: ; df48 (3:5f48)
+.full
call CloseSRAM
and a
ret
-Functiondf4d: ; df4d (3:5f4d)
+ShiftBoxMon:
ld hl, sBoxMonOT
ld bc, NAME_LENGTH
- call Functiondf65
+ call .shift
+
ld hl, sBoxMonNicknames
- ld bc, NAME_LENGTH
- call Functiondf65
- ld hl, sBoxMon1Species
+ ld bc, MON_NAME_LENGTH
+ call .shift
+
+ ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
-Functiondf65: ; df65 (3:5f65)
+
+.shift
ld a, [sBoxCount]
- cp $2
+ cp 2
ret c
+
push hl
call AddNTimes
dec hl
ld e, l
ld d, h
pop hl
+
ld a, [sBoxCount]
dec a
call AddNTimes
dec hl
+
push hl
ld a, [sBoxCount]
dec a
- ld hl, $0
+ ld hl, 0
call AddNTimes
ld c, l
ld b, h
pop hl
-.asm_df89
+.loop
ld a, [hld]
ld [de], a
dec de
dec bc
ld a, c
or b
- jr nz, .asm_df89
+ jr nz, .loop
ret
GiveEgg::
@@ -1005,17 +1124,26 @@ GiveEgg::
callfar GetPreEvolution
ld a, [wCurPartySpecies]
dec a
+
+; TryAddMonToParty sets Seen and Caught flags
+; when it is successful. This routine will make
+; sure that we aren't newly setting flags.
push af
call CheckCaughtMon
pop af
push bc
call CheckSeenMon
push bc
+
call TryAddMonToParty
+
+; If we haven't caught this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
pop bc
ld a, c
and a
- jr nz, .asm_dfc9
+ jr nz, .skip_caught_flag
ld a, [wCurPartySpecies]
dec a
ld c, a
@@ -1023,11 +1151,15 @@ GiveEgg::
ld hl, wPokedexCaught
ld b, RESET_FLAG
predef SmallFarFlagAction
-.asm_dfc9
+
+.skip_caught_flag
+; If we haven't seen this Pokemon before receiving
+; the Egg, reset the flag that was just set by
+; TryAddMonToParty.
pop bc
ld a, c
and a
- jr nz, .asm_dfdf
+ jr nz, .skip_seen_flag
ld a, [wCurPartySpecies]
dec a
ld c, a
@@ -1035,26 +1167,27 @@ GiveEgg::
ld hl, wPokedexSeen
ld b, RESET_FLAG
predef SmallFarFlagAction
-.asm_dfdf
+
+.skip_seen_flag
pop af
ld [wCurPartySpecies], a
- ld a, [wPokemonData]
+ ld a, [wPartyCount]
dec a
ld bc, PARTYMON_STRUCT_LENGTH
ld hl, wPartyMon1Species
call AddNTimes
ld a, [wCurPartySpecies]
ld [hl], a
- ld hl, wPokemonData
+ ld hl, wPartyCount
ld a, [hl]
- ld b, $0
+ ld b, 0
ld c, a
add hl, bc
- ld a, $fd
+ ld a, EGG
ld [hl], a
- ld a, [wPokemonData]
+ ld a, [wPartyCount]
dec a
- ld hl, wPartyMon1Nickname
+ ld hl, wPartyMonNicknames
call SkipNames
ld de, String_Egg
call CopyName2
@@ -1064,11 +1197,12 @@ GiveEgg::
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [wDebugFlags]
- bit 1, a
- ld a, $1
- jr nz, .asm_e028
+ bit DEBUG_FIELD_F, a
+ ld a, 1
+ jr nz, .got_init_happiness
ld a, [wBaseEggSteps]
-.asm_e028
+
+.got_init_happiness
ld [hl], a
ld a, [wPartyCount]
dec a
@@ -1084,118 +1218,131 @@ GiveEgg::
String_Egg:
db "EGG@"
-RemoveMonFromPartyOrBox: ; e03f (3:603f)
+RemoveMonFromPartyOrBox:
ld hl, wPartyCount
+
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e050
- ld a, $1
+ jr z, .okay
+
+ ld a, BANK(sBoxCount)
call OpenSRAM
ld hl, sBoxCount
-.asm_e050
+
+.okay
ld a, [hl]
dec a
ld [hli], a
ld a, [wCurPartyMon]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld e, l
ld d, h
inc de
-.asm_e05d
+.loop
ld a, [de]
inc de
ld [hli], a
inc a
- jr nz, .asm_e05d
- ld hl, wPartyMon6StatsEnd
- ld d, $5
+ jr nz, .loop
+ ld hl, wPartyMonOT
+ ld d, PARTY_LENGTH - 1
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e073
+ jr z, .party
ld hl, sBoxMonOT
- ld d, $13
-.asm_e073
+ ld d, MONS_PER_BOX - 1
+
+.party
+ ; If this is the last mon in our party (box),
+ ; shift all the other mons up to close the gap.
ld a, [wCurPartyMon]
call SkipNames
ld a, [wCurPartyMon]
cp d
- jr nz, .asm_e084
- ld [hl], $ff
- jp .asm_e0f6
+ jr nz, .delete_inside
+ ld [hl], -1
+ jp .finish
-.asm_e084
+.delete_inside
+ ; Shift the OT names
ld d, h
ld e, l
- ld bc, NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld bc, wPartyMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e096
+ jr z, .party2
ld bc, sBoxMonNicknames
-.asm_e096
+.party2
call CopyDataUntil
- ld hl, wPartyMon1
+ ; Shift the struct
+ ld hl, wPartyMons
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0ab
- ld hl, sBoxMon1Species
+ jr z, .party4
+ ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
-.asm_e0ab
+.party4
ld a, [wCurPartyMon]
call AddNTimes
ld d, h
ld e, l
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0c2
+ jr z, .party5
ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
ld bc, sBoxMonOT
- jr .asm_e0c9
+ jr .copy
-.asm_e0c2
+.party5
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
ld bc, wPartyMonOT
-.asm_e0c9
+.copy
call CopyDataUntil
+ ; Shift the nicknames
ld hl, wPartyMonNicknames
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0d8
+ jr z, .party6
ld hl, sBoxMonNicknames
-.asm_e0d8
- ld bc, NAME_LENGTH
+.party6
+ ld bc, MON_NAME_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld d, h
ld e, l
- ld bc, NAME_LENGTH
+ ld bc, MON_NAME_LENGTH
add hl, bc
ld bc, wPartyMonNicknamesEnd
ld a, [wPokemonWithdrawDepositParameter]
and a
- jr z, .asm_e0f3
- ld bc, sBoxEnd
-.asm_e0f3
+ jr z, .party7
+ ld bc, sBoxMonNicknamesEnd
+.party7
call CopyDataUntil
-.asm_e0f6
+ ; Mail time!
+.finish
ld a, [wPokemonWithdrawDepositParameter]
and a
jp nz, CloseSRAM
ld a, [wLinkMode]
and a
ret nz
- ld a, $0
+ ; Shift mail
+ ld a, BANK(sPartyMail)
call OpenSRAM
- ld hl, wPokemonData
+ ; If this is the last mon in our party, no need to shift mail.
+ ld hl, wPartyCount
ld a, [wCurPartyMon]
cp [hl]
- jr z, .asm_e137
+ jr z, .close_sram
+ ; Shift our mail messages up.
ld hl, sPartyMail
ld bc, MAIL_STRUCT_LENGTH
call AddNTimes
@@ -1204,7 +1351,7 @@ RemoveMonFromPartyOrBox: ; e03f (3:603f)
pop de
ld a, [wCurPartyMon]
ld b, a
-.asm_e120
+.loop2
push bc
push hl
ld bc, MAIL_STRUCT_LENGTH
@@ -1218,8 +1365,8 @@ RemoveMonFromPartyOrBox: ; e03f (3:603f)
inc b
ld a, [wPartyCount]
cp b
- jr nz, .asm_e120
-.asm_e137
+ jr nz, .loop2
+.close_sram
jp CloseSRAM
ComputeNPCTrademonStats:
@@ -1239,7 +1386,7 @@ ComputeNPCTrademonStats:
push de
ld a, MON_STAT_EXP - 1
call GetPartyParamLocation
- ld b, $1
+ ld b, TRUE
call CalcMonStats
pop de
ld a, MON_HP
@@ -1251,14 +1398,14 @@ ComputeNPCTrademonStats:
ld [hl], a
ret
-CalcMonStats: ; e16d
-; Calculates all 6 Stats of a Pkmn
+CalcMonStats:
+; Calculates all 6 Stats of a mon
; b: Take into account stat EXP if TRUE
-; 'c' counts from 1-6 and points with 'BaseStats' to the base value
+; 'c' counts from 1-6 and points with 'wBaseStats' to the base value
; hl is the path to the Stat EXP
-; results in $ffb7 and $ffb8 are saved in [de]
+; de points to where the final stats will be saved
- ld c, $0
+ ld c, STAT_HP - 1 ; first stat
.loop
inc c
call CalcMonStatC
@@ -1269,12 +1416,11 @@ CalcMonStats: ; e16d
ld [de], a
inc de
ld a, c
- cp STAT_SDEF
+ cp STAT_SDEF ; last stat
jr nz, .loop
ret
-; e17b
-CalcMonStatC: ; e181
+CalcMonStatC:
; 'c' is 1-6 and points to the BaseStat
; 1: HP
; 2: Attack
@@ -1290,14 +1436,14 @@ CalcMonStatC: ; e181
push hl
ld hl, wBaseStats
dec hl ; has to be decreased, because 'c' begins with 1
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
ld e, a
pop hl
push hl
ld a, c
- cp STAT_SDEF
+ cp STAT_SDEF ; last stat
jr nz, .not_spdef
dec hl
dec hl
@@ -1314,7 +1460,7 @@ CalcMonStatC: ; e181
ldh [hMultiplicand + 1], a
inc b
ld a, b
- cp $ff
+ cp -1
jr z, .no_stat_exp
ldh [hMultiplicand + 2], a
ldh [hMultiplier], a
@@ -1346,29 +1492,29 @@ CalcMonStatC: ; e181
jr z, .Special
cp STAT_SDEF
jr z, .Special
-; DV_HP = (DV_ATK & 1) << 3 + (DV_DEF & 1) << 2 + (DV_SPD & 1) << 1 + (DV_SPC & 1)
+; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1)
push bc
ld a, [hl]
swap a
- and $1
+ and 1
add a
add a
add a
ld b, a
ld a, [hli]
- and $1
+ and 1
add a
add a
add b
ld b, a
ld a, [hl]
swap a
- and $1
+ and 1
add a
add b
ld b, a
ld a, [hl]
- and $1
+ and 1
add b
pop bc
jr .GotDV
@@ -1435,7 +1581,7 @@ CalcMonStatC: ; e181
call Divide
ld a, c
cp STAT_HP
- ld a, 5
+ ld a, STAT_MIN_NORMAL
jr nz, .not_hp
ld a, [wCurPartyLevel]
ld b, a
@@ -1448,7 +1594,7 @@ CalcMonStatC: ; e181
ldh [hMultiplicand + 1], a
.no_overflow_3
- ld a, 10
+ ld a, STAT_MIN_HP
.not_hp
ld b, a
@@ -1462,18 +1608,18 @@ CalcMonStatC: ; e181
.no_overflow_4
ldh a, [hQuotient + 2]
- cp (1000 / $100) + 1
+ cp HIGH(MAX_STAT_VALUE + 1) + 1
jr nc, .max_stat
- cp 1000 / $100
+ cp HIGH(MAX_STAT_VALUE + 1)
jr c, .stat_value_okay
ldh a, [hQuotient + 3]
- cp 1000 % $100
+ cp LOW(MAX_STAT_VALUE + 1)
jr c, .stat_value_okay
.max_stat
- ld a, 999 / $100
+ ld a, HIGH(MAX_STAT_VALUE)
ldh [hMultiplicand + 1], a
- ld a, 999 % $100
+ ld a, LOW(MAX_STAT_VALUE)
ldh [hMultiplicand + 2], a
.stat_value_okay
@@ -1485,12 +1631,12 @@ CalcMonStatC: ; e181
GivePoke::
push de
push bc
- xor a
+ xor a ; PARTYMON
ld [wMonType], a
call TryAddMonToParty
- jr nc, .asm_e2c9
- ld hl, wPartyMon1Nickname
- ld a, [wPokemonData]
+ jr nc, .failed
+ ld hl, wPartyMonNicknames
+ ld a, [wPartyCount]
dec a
ld [wCurPartyMon], a
call SkipNames
@@ -1498,27 +1644,27 @@ GivePoke::
ld e, l
pop bc
ld a, b
- ld b, $0
+ ld b, 0
push bc
push de
push af
ld a, [wCurItem]
and a
- jr z, .asm_e2fa
+ jr z, .done
ld a, [wCurPartyMon]
ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [wCurItem]
ld [hl], a
- jr .asm_e2fa
+ jr .done
-.asm_e2c9
+.failed
ld a, [wCurPartySpecies]
ld [wTempEnemyMonSpecies], a
callfar LoadEnemyMon
call SendMonIntoBox
- jp nc, Functione3af
+ jp nc, .FailedToGiveMon
ld a, BOXMON
ld [wMonType], a
xor a
@@ -1526,18 +1672,19 @@ GivePoke::
ld de, wMonOrItemNameBuffer
pop bc
ld a, b
- ld b, $1
+ ld b, 1
push bc
push de
push af
ld a, [wCurItem]
and a
- jr z, .asm_e2fa
+ jr z, .done
ld a, [wCurItem]
ld [sBoxMon1Item], a
-.asm_e2fa
+
+.done
ld a, [wCurPartySpecies]
- ld [wd151], a
+ ld [wNamedObjectIndexBuffer], a
ld [wTempEnemyMonSpecies], a
call GetPokemonName
ld hl, wStringBuffer1
@@ -1546,7 +1693,7 @@ GivePoke::
call CopyBytes
pop af
and a
- jr z, .asm_e381
+ jr z, .set_caught_data
pop de
pop bc
pop hl
@@ -1567,26 +1714,28 @@ GivePoke::
and a
push de
push bc
- jr nz, .asm_e360
+ jr nz, .send_to_box
+
push hl
ld a, [wCurPartyMon]
- ld hl, wPartyMon1OT
+ ld hl, wPartyMonOT
call SkipNames
ld d, h
ld e, l
pop hl
+.otnameloop
ld a, [wScriptBank]
call FarCopyBytes
ld a, [wCurPartyMon]
ld hl, wPartyMon1ID
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
- ld a, 01001 / $100
+ ld a, HIGH(RANDY_OT_ID)
ld [hli], a
- ld [hl], 01001 % $100
- jr .asm_e38d
+ ld [hl], LOW(RANDY_OT_ID)
+ jr .skip_nickname
-.asm_e360
+.send_to_box
ld a, BANK(sBoxMonOT)
call OpenSRAM
ld de, sBoxMonOT
@@ -1599,20 +1748,21 @@ GivePoke::
call Random
ld [hl], a
call CloseSRAM
- jr .asm_e38d
+ jr .skip_nickname
-.asm_e381
+.set_caught_data
callfar Functionc7cd0
pop de
- jr c, .asm_e38d
+ jr c, .skip_nickname
call InitNickname
-.asm_e38d
+
+.skip_nickname
pop bc
pop de
ld a, b
and a
ret z
- ld hl, TextJump_WasSentToBillsPC
+ ld hl, WasSentToBillsPCText
call PrintText
ld a, BANK(sBoxMonNicknames)
call OpenSRAM
@@ -1624,28 +1774,28 @@ GivePoke::
ld b, $1
ret
-Functione3af: ; e3af (3:63af)
+.FailedToGiveMon:
pop bc
pop de
ld b, $2
ret
-TextJump_WasSentToBillsPC:
- text_far Text_WasSentToBillsPC
- db "@"
+WasSentToBillsPCText:
+ text_far _WasSentToBillsPCText
+ text_end
-InitNickname: ; e3b9 (3:63b9)
+InitNickname:
push de
call LoadStandardMenuHeader
call DisableSpriteUpdates
pop de
push de
- ld b, $0
+ ld b, NAME_MON
farcall NamingScreen
pop hl
ld de, wStringBuffer1
call InitName
- ld a, $4 ; XXX could this be in bank 4 in pokered?
+ ld a, $4 ; ExitAllMenus is in bank 0, XXX could this be in bank 4 in pokered?
ld hl, ExitAllMenus
rst FarCall
ret
diff --git a/main.asm b/main.asm
index 4c23e6fe..f8af224d 100644
--- a/main.asm
+++ b/main.asm
@@ -382,7 +382,7 @@ RestorePartyMonMail::
dr $44850, $44870
DeletePartyMonMail::
dr $44870, $4488c
-IsAnyPokemonHoldingMail::
+IsAnyMonHoldingMail::
dr $4488c, $448ab
_PlayerMailBoxMenu::
dr $448ab, $44aa2
@@ -763,14 +763,14 @@ _UnownPuzzle::
_DummyGame::
dr $e2668, $e2b9e
-DepositPokemon_::
+_DepositPKMN::
dr $e2b9e, $e2d71
-WithdrawPokemon_::
+_WithdrawPKMN::
dr $e2d71, $e2f47
-MovePKMNWithoutMail_::
+_MovePKMNWithoutMail::
dr $e2f47, $e3d25
-ChangeBox_::
+_ChangeBox::
dr $e3d25, $e3f74