summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--constants/event_flags.asm2
-rw-r--r--constants/sprite_anim_constants.asm3
-rwxr-xr-xdata/growth_rates.asm19
-rwxr-xr-xdata/party_menu_qualities.asm35
-rw-r--r--data/phone/text/bike_shop.asm19
-rw-r--r--data/phone/text/bill.asm101
-rw-r--r--data/phone/text/elm.asm212
-rw-r--r--data/phone/text/landmarks.asm67
-rw-r--r--data/phone/text/mom.asm165
-rw-r--r--data/phone/text/trainers.asm355
-rw-r--r--data/phone/text/unused.asm3
-rwxr-xr-xdata/pokemon/unused_pic_banks.asm17
-rwxr-xr-xdata/text/unused_gen1_trainer_names.asm71
-rwxr-xr-xdata/types/names.asm50
-rwxr-xr-xengine/battle/unreferenced_getgen1trainerclassname.asm21
-rwxr-xr-xengine/events/basement_key.asm32
-rwxr-xr-xengine/events/card_key.asm37
-rwxr-xr-xengine/events/fishing_gfx.asm24
-rwxr-xr-xengine/events/poisonstep.asm154
-rwxr-xr-xengine/events/sacred_ash.asm68
-rwxr-xr-xengine/events/squirtbottle.asm45
-rwxr-xr-xengine/events/sweet_scent.asm65
-rwxr-xr-xengine/link/init_list.asm55
-rw-r--r--engine/movie/gamefreak_presents.asm73
-rw-r--r--engine/movie/title.asm2
-rwxr-xr-xengine/overworld/player_movement.asm2
-rw-r--r--engine/phone/scripts/bike_shop.asm5
-rw-r--r--engine/phone/scripts/bill.asm41
-rw-r--r--engine/phone/scripts/elm.asm101
-rw-r--r--engine/phone/scripts/generic.asm227
-rw-r--r--engine/phone/scripts/mom.asm150
-rw-r--r--engine/phone/scripts/trainers.asm677
-rw-r--r--engine/phone/scripts/unused.asm3
-rwxr-xr-xengine/pokemon/experience.asm162
-rwxr-xr-xengine/pokemon/mon_stats.asm475
-rwxr-xr-xengine/pokemon/party_menu.asm783
-rw-r--r--engine/pokemon/stats_screen.asm868
-rwxr-xr-xengine/pokemon/switchpartymons.asm145
-rwxr-xr-xengine/pokemon/tempmon.asm127
-rwxr-xr-xengine/pokemon/types.asm92
-rwxr-xr-xhome/print_num.asm126
-rw-r--r--layout.link2
-rw-r--r--main.asm243
-rw-r--r--wram.asm7
44 files changed, 5610 insertions, 321 deletions
diff --git a/constants/event_flags.asm b/constants/event_flags.asm
index 58127c6a..bb1476b1 100644
--- a/constants/event_flags.asm
+++ b/constants/event_flags.asm
@@ -669,7 +669,7 @@
const EVENT_DEREK_ASKED_FOR_PHONE_NUMBER
const EVENT_DEREK_READY_FOR_REMATCH
const EVENT_CHRIS_ASKED_FOR_PHONE_NUMBER
- const EVENT_CHRIS_READY_FOR_REMATCH
+ const EVENT_CHRIS_READY_FOR_REMATCH ; 290
const EVENT_BRENT_ASKED_FOR_PHONE_NUMBER
const EVENT_BRENT_READY_FOR_REMATCH
const EVENT_TIFFANY_ASKED_FOR_PHONE_NUMBER
diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm
index 04c01743..1df8c368 100644
--- a/constants/sprite_anim_constants.asm
+++ b/constants/sprite_anim_constants.asm
@@ -23,6 +23,9 @@ NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs
SPRITE_ANIM_INDEX_PARTY_MON EQU $00
SPRITE_ANIM_INDEX_GS_TITLE_TRAIL EQU $0f
SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR EQU $14
+SPRITE_ANIM_INDEX_GAMEFREAK_LOGO EQU $15
+SPRITE_ANIM_INDEX_GS_INTRO_STAR EQU $16
+SPRITE_ANIM_INDEX_GS_INTRO_SPARKLE EQU $17
SPRITE_ANIM_INDEX_SLOTS_GOLEM EQU $18
SPRITE_ANIM_INDEX_SLOTS_CHANSEY EQU $19
SPRITE_ANIM_INDEX_SLOTS_EGG EQU $1a
diff --git a/data/growth_rates.asm b/data/growth_rates.asm
new file mode 100755
index 00000000..aee2a16e
--- /dev/null
+++ b/data/growth_rates.asm
@@ -0,0 +1,19 @@
+growth_rate: MACRO
+; [1]/[2]*n**3 + [3]*n**2 + [4]*n - [5]
+ dn \1, \2
+ if \3 & $80 ; signed
+ db -\3 | $80
+ else
+ db \3
+ endc
+ db \4, \5
+ENDM
+
+GrowthRates:
+; entries correspond to GROWTH_* (see constants/pokemon_data_constants.asm)
+ growth_rate 1, 1, 0, 0, 0 ; Medium Fast
+ growth_rate 3, 4, 10, 0, 30 ; Slightly Fast
+ growth_rate 3, 4, 20, 0, 70 ; Slightly Slow
+ growth_rate 6, 5, -15, 100, 140 ; Medium Slow
+ growth_rate 4, 5, 0, 0, 0 ; Fast
+ growth_rate 5, 4, 0, 0, 0 ; Slow
diff --git a/data/party_menu_qualities.asm b/data/party_menu_qualities.asm
new file mode 100755
index 00000000..0f8b19bf
--- /dev/null
+++ b/data/party_menu_qualities.asm
@@ -0,0 +1,35 @@
+; WritePartyMenuTilemap.Jumptable indexes (see engine/party_menu.asm)
+ const_def
+ const PARTYMENUQUALITY_NICKNAMES
+ const PARTYMENUQUALITY_HP_BAR
+ const PARTYMENUQUALITY_HP_DIGITS
+ const PARTYMENUQUALITY_LEVEL
+ const PARTYMENUQUALITY_STATUS
+ const PARTYMENUQUALITY_TMHM_COMPAT
+ const PARTYMENUQUALITY_EVO_STONE_COMPAT
+ const PARTYMENUQUALITY_GENDER
+
+partymenuqualities: MACRO
+rept _NARG
+ db PARTYMENUQUALITY_\1
+ shift
+endr
+ db -1 ; end
+ENDM
+
+PartyMenuQualityPointers:
+; entries correspond to PARTYMENUACTION_* constants
+ dw .Default ; PARTYMENUACTION_CHOOSE_POKEMON
+ dw .Default ; PARTYMENUACTION_HEALING_ITEM
+ dw .Default ; PARTYMENUACTION_SWITCH
+ dw .TMHM ; PARTYMENUACTION_TEACH_TMHM
+ dw .Default ; PARTYMENUACTION_MOVE
+ dw .EvoStone ; PARTYMENUACTION_EVO_STONE
+ dw .Gender ; PARTYMENUACTION_GIVE_MON
+ dw .Gender ; PARTYMENUACTION_GIVE_MON_FEMALE
+ dw .Default ; PARTYMENUACTION_GIVE_ITEM
+
+.Default: partymenuqualities NICKNAMES, HP_BAR, HP_DIGITS, LEVEL, STATUS
+.TMHM: partymenuqualities NICKNAMES, TMHM_COMPAT, LEVEL, STATUS
+.EvoStone: partymenuqualities NICKNAMES, EVO_STONE_COMPAT, LEVEL, STATUS
+.Gender: partymenuqualities NICKNAMES, GENDER, LEVEL, STATUS
diff --git a/data/phone/text/bike_shop.asm b/data/phone/text/bike_shop.asm
new file mode 100644
index 00000000..ec2ce893
--- /dev/null
+++ b/data/phone/text/bike_shop.asm
@@ -0,0 +1,19 @@
+BikeShopPhoneCallerText:
+ text "Hi, <PLAYER>!"
+ line "Our BICYCLE sales"
+
+ para "have gone through"
+ line "the roof!"
+
+ para "We owe it all to"
+ line "your advertising"
+
+ para "by riding around"
+ line "on our BICYCLE."
+
+ para "As our way of say-"
+ line "ing thanks, please"
+
+ para "keep that BICYCLE."
+ line "Thanks again!"
+ done
diff --git a/data/phone/text/bill.asm b/data/phone/text/bill.asm
new file mode 100644
index 00000000..24f4840d
--- /dev/null
+++ b/data/phone/text/bill.asm
@@ -0,0 +1,101 @@
+BillPhoneMornGreetingText:
+ text "Good morning!"
+
+ para "This is the #-"
+ line "MON STORAGE SYSTEM"
+
+ para "ADMINISTRATION"
+ line "SERVICE."
+ done
+
+BillPhoneDayGreetingText:
+ text "Good day!"
+
+ para "This is the #-"
+ line "MON STORAGE SYSTEM"
+
+ para "ADMINISTRATION"
+ line "SERVICE."
+ done
+
+BillPhoneNiteGreetingText:
+ text "Good evening!"
+
+ para "This is the #-"
+ line "MON STORAGE SYSTEM"
+
+ para "ADMINISTRATION"
+ line "SERVICE."
+ done
+
+BillPhoneGenericText:
+ text "Who's calling?"
+
+ para "<PLAYER>, is it?"
+ line "Hang on a sec…"
+
+ para "<……>"
+ line "<……>"
+ done
+
+BillPhoneNotFullText:
+ text "Thanks for"
+ line "waiting!"
+
+ para "<PLAYER>, your BOX"
+ line "has room for @"
+ text_ram wStringBuffer3
+ text_start
+ cont "more #MON."
+
+ para "Get out there and"
+ line "fill it up!"
+ done
+
+BillPhoneNearlyFullText:
+ text "Thanks for"
+ line "waiting!"
+
+ para "<PLAYER>, your BOX"
+ line "has room for only"
+ cont "@"
+ text_ram wStringBuffer3
+ text " more #MON."
+
+ para "Maybe you should"
+ line "switch your BOX."
+ done
+
+BillPhoneFullText:
+ text "Thanks for"
+ line "waiting!"
+
+ para "<PLAYER>, your BOX"
+ line "is full!"
+
+ para "You'll have to"
+ line "switch BOXES if"
+
+ para "you want to catch"
+ line "more #MON."
+ done
+
+BillPhoneNewlyFullText:
+ text "Hi, <PLAYER>?"
+ line "It's me, BILL!"
+
+ para "Thanks for using"
+ line "my STORAGE SYSTEM."
+
+ para "That last #MON"
+ line "you sent filled"
+ cont "your BOX up."
+
+ para "You'll have to"
+ line "switch BOXES if"
+
+ para "you want to catch"
+ line "more #MON."
+
+ para "Bye now!"
+ done
diff --git a/data/phone/text/elm.asm b/data/phone/text/elm.asm
new file mode 100644
index 00000000..a1450ca2
--- /dev/null
+++ b/data/phone/text/elm.asm
@@ -0,0 +1,212 @@
+ElmPhoneHealYourMonText:
+ text "Hello, <PLAYER>?"
+
+ para "Try not to overdo"
+ line "it."
+
+ para "Be sure to heal"
+ line "your #MON if"
+ cont "they are hurt."
+ done
+
+ElmPhoneSawMrPokemonText:
+ text "Hello, <PLAYER>?"
+
+ para "Did you meet MR."
+ line "#MON? Great!"
+ cont "Come back safely!"
+ done
+
+ElmPhonePokemonStolenText:
+ text "<PLAYER>? I'm very"
+ line "upset now."
+
+ para "We had a #MON"
+ line "stolen from here."
+
+ para "How could anyone"
+ line "do that?"
+ done
+
+ElmPhoneCheckingTheEggText:
+ text "Hello, <PLAYER>?"
+
+ para "We're checking the"
+ line "EGG now. It does"
+
+ para "appear to be a"
+ line "#MON EGG."
+ done
+
+ElmPhoneAssistantText:
+ text "Hello, <PLAYER>?"
+
+ para "Did you see my"
+ line "assistant? He's at"
+
+ para "the #MON CENTER"
+ line "in VIOLET CITY."
+ done
+
+ElmPhoneHowIsTheEggText:
+ text "Hello, <PLAYER>?"
+
+ para "How's the EGG? Has"
+ line "anything changed?"
+
+ para "If anything hap-"
+ line "pens, please call."
+ done
+
+ElmPhoneEggHatchedText:
+ text "Hello, <PLAYER>?"
+ line "How is the EGG?"
+
+ para "What? It hatched?"
+ line "Wow! What kind of"
+ cont "#MON is it?"
+
+ para "Please come show"
+ line "me now!"
+ done
+
+ElmPhoneDiscoveredHatchTimeText:
+ text "Hello, <PLAYER>?"
+
+ para "I just made a new"
+ line "discovery."
+
+ para "The time it takes"
+ line "for an EGG to"
+
+ para "hatch depends on"
+ line "the #MON."
+ done
+
+ElmPhoneInvestigatingEggMovesText:
+ text "Hello, <PLAYER>?"
+
+ para "It's still a"
+ line "mystery what kinds"
+
+ para "of moves hatched"
+ line "#MON have."
+
+ para "We're investigat-"
+ line "ing that now."
+ done
+
+ElmPhoneDiscoveredPokerusText:
+ text "Hello, <PLAYER>?"
+
+ para "I discovered an"
+ line "odd thing."
+
+ para "Apparently there's"
+ line "something called"
+
+ para "#RUS that in-"
+ line "fects #MON."
+
+ para "Yes, it's like a"
+ line "virus, so it's"
+ cont "called #RUS."
+
+ para "It multiplies fast"
+ line "and infects other"
+
+ para "#MON too. But"
+ line "that's all."
+
+ para "It doesn't seem to"
+ line "do anything, and"
+
+ para "it goes away over"
+ line "time."
+
+ para "I guess it's"
+ line "nothing to worry"
+ cont "about. Bye!"
+ done
+
+ElmPhoneDisasterText:
+ text "H-hello? <PLAYER>?"
+ line "It's a disaster!"
+
+ para "Uh, um, it's just"
+ line "terrible!"
+
+ para "What should I do?"
+ line "It… Oh, no…"
+
+ para "Please get back"
+ line "here now!"
+ done
+
+ElmPhoneEggAssistantText:
+ text "Hello, <PLAYER>? We"
+ line "discovered some-"
+
+ para "thing about the"
+ line "EGG!"
+
+ para "My assistant is at"
+ line "the #MON CENTER"
+
+ para "in VIOLET CITY. "
+ line "Could you talk to"
+ cont "him?"
+ done
+
+ElmPhoneRadioTowerRocketTakeoverText:
+ text "<PLAYER>, how are"
+ line "things going?"
+
+ para "I called because"
+ line "something weird is"
+
+ para "happening with the"
+ line "radio broadcasts."
+
+ para "They were talking"
+ line "about TEAM ROCKET."
+
+ para "<PLAYER>, do you"
+ line "know anything"
+ cont "about it?"
+
+ para "Maybe TEAM ROCKET"
+ line "has returned. No,"
+
+ para "that just can't"
+ line "be true."
+
+ para "Sorry to bug you."
+ line "Take care!"
+ done
+
+ElmPhoneGiftText:
+ text "Hello, <PLAYER>?"
+
+ para "I have something"
+ line "here for you."
+
+ para "Could you swing by"
+ line "my LAB?"
+
+ para "See you later!"
+ done
+
+; unused
+ElmPhoneGotAholdOfSomethingNeatText:
+ text "Hello, <PLAYER>?"
+ line "How's it going?"
+
+ para "I got ahold of"
+ line "something neat."
+
+ para "Swing by my LAB"
+ line "and pick it up!"
+
+ para "See you later!"
+ done
diff --git a/data/phone/text/landmarks.asm b/data/phone/text/landmarks.asm
new file mode 100644
index 00000000..175f6111
--- /dev/null
+++ b/data/phone/text/landmarks.asm
@@ -0,0 +1,67 @@
+PhoneNationalParkText:
+ db "NATIONAL PARK@"
+
+PhoneLighthouseText:
+ db "LIGHTHOUSE@"
+
+; unreferenced
+PhoneUndergroundText:
+ db "UNDERGROUND@"
+
+PhoneDarkCaveText:
+ db "DARK CAVE@"
+
+PhoneMtMortarText:
+ db "MT.MORTAR@"
+
+PhoneRoute26Text:
+ db "ROUTE 26@"
+
+PhoneRoute27Text:
+ db "ROUTE 27@"
+
+PhoneRoute30Text:
+ db "ROUTE 30@"
+
+PhoneRoute31Text:
+ db "ROUTE 31@"
+
+PhoneRoute32Text:
+ db "ROUTE 32@"
+
+PhoneRoute33Text:
+ db "ROUTE 33@"
+
+PhoneRoute34Text:
+ db "ROUTE 34@"
+
+PhoneRoute35Text:
+ db "ROUTE 35@"
+
+PhoneRoute36Text:
+ db "ROUTE 36@"
+
+; unreferenced
+PhoneRoute37Text:
+ db "ROUTE 37@"
+
+PhoneRoute38Text:
+ db "ROUTE 38@"
+
+PhoneRoute39Text:
+ db "ROUTE 39@"
+
+PhoneRoute42Text:
+ db "ROUTE 42@"
+
+PhoneRoute43Text:
+ db "ROUTE 43@"
+
+PhoneRoute44Text:
+ db "ROUTE 44@"
+
+PhoneRoute45Text:
+ db "ROUTE 45@"
+
+PhoneRoute46Text:
+ db "ROUTE 46@"
diff --git a/data/phone/text/mom.asm b/data/phone/text/mom.asm
new file mode 100644
index 00000000..75e8dfbb
--- /dev/null
+++ b/data/phone/text/mom.asm
@@ -0,0 +1,165 @@
+MomPhoneGreetingText:
+ text "Hello?"
+
+ para "Oh, hi, <PLAYER>!"
+ line "Working hard?"
+ done
+
+MomPhoneLandmarkText:
+ text "Oh, so you're in"
+ line "@"
+ text_ram wStringBuffer3
+ text "…"
+
+ para "Isn't that where"
+ line "@"
+ text_ram wStringBuffer4
+ text_start
+ para "is? Did you go"
+ line "take a look?"
+ done
+
+MomPhoneGenericAreaText:
+ text "Really, you're in"
+ line "@"
+ text_ram wStringBuffer3
+ text "?"
+
+ para "I've never gone"
+ line "there. That's kind"
+ cont "of neat, <PLAYER>."
+ done
+
+MomPhoneNewBarkText:
+ text "What? You're in"
+ line "@"
+ text_ram wStringBuffer3
+ text "?"
+
+ para "Come see your MOM"
+ line "sometime!"
+ done
+
+MomPhoneCherrygroveText:
+ text "You're visiting"
+ line "@"
+ text_ram wStringBuffer3
+ text "?"
+
+ para "How about coming"
+ line "home for a bit?"
+ done
+
+MomOtherAreaText:
+ text "Wow, you're in"
+ line "@"
+ text_ram wStringBuffer3
+ text "?"
+
+ para "Good luck on your"
+ line "#MON quest!"
+ done
+
+MomDeterminedText:
+ text "That sounds really"
+ line "tough."
+
+ para "But, <PLAYER>, I"
+ line "know you're really"
+
+ para "determined. You'll"
+ line "be OK, right?"
+ done
+
+MomCheckBalanceText:
+ text "By the way, you've"
+ line "saved up ¥@"
+ text_ram wStringBuffer3
+ text "."
+
+ para "Do you want to"
+ line "keep on saving?"
+ done
+
+MomImportantToSaveText:
+ text "It's important to"
+ line "save your money."
+ done
+
+MomYoureNotSavingText:
+ text "Oh, <PLAYER>,"
+ line "you're not saving"
+
+ para "any money. Would"
+ line "you like to save?"
+ done
+
+MomYouveSavedText:
+ text "By the way, you've"
+ line "saved up ¥@"
+ text_ram wStringBuffer3
+ text "."
+
+ para "Want to start"
+ line "saving again?"
+ done
+
+MomOKIllSaveText:
+ text "OK. I'll save your"
+ line "money."
+ done
+
+MomPhoneStopSavingMoneyText:
+ text "OK. I'll stop"
+ line "saving your money."
+ done
+
+MomPhoneHangUpText:
+ text "<PLAYER>, keep it"
+ line "up! I'm rooting"
+ cont "for you, baby!"
+ done
+
+MomPhoneNoPokemonText:
+ text "Hello?"
+
+ para "Oh, hi, <PLAYER>!"
+ line "Wasn't PROF.ELM"
+ cont "waiting for you?"
+ done
+
+MomPhoneNoPokedexText:
+ text "Hello?"
+
+ para "Oh, hi, <PLAYER>!"
+ line "You're on a big"
+
+ para "mission for PROF."
+ line "ELM? Be good!"
+ done
+
+MomPhoneNoGymQuestText:
+ text "Hello?"
+
+ para "Hi, <PLAYER>! If"
+ line "you're done with"
+
+ para "your errand come"
+ line "on home, dear."
+ done
+
+MomPhoneLectureText:
+ text "Hello?"
+
+ para "…… <PLAYER>?"
+ line "I heard from PROF."
+
+ para "ELM that you went"
+ line "on a long trip."
+
+ para "I wish you would"
+ line "have told me…"
+
+ para "What about money?"
+ line "Should I save it?"
+ done
diff --git a/data/phone/text/trainers.asm b/data/phone/text/trainers.asm
new file mode 100644
index 00000000..2a15811c
--- /dev/null
+++ b/data/phone/text/trainers.asm
@@ -0,0 +1,355 @@
+PhoneMaleAnswerMornText:
+ text "Hello. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "…"
+
+ para "Good morning,"
+ line "<PLAYER>!"
+ done
+
+PhoneMaleAnswerDayText:
+ text "Hello. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "…"
+
+ para "How's it going,"
+ line "<PLAYER>?"
+ done
+
+PhoneMaleAnswerNiteText:
+ text "Hello. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "…"
+
+ para "Good evening,"
+ line "<PLAYER>!"
+ done
+
+PhoneFemaleAnswerMornText:
+ text "Hi. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "."
+
+ para "Hi, <PLAYER>!"
+ line "Good morning."
+ done
+
+PhoneFemaleAnswerDayText:
+ text "Hi. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "."
+
+ para "Hi, <PLAYER>!"
+ line "How are you?"
+ done
+
+PhoneFemaleAnswerNiteText:
+ text "Hi. This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "."
+
+ para "Hi, <PLAYER>!"
+ line "Good evening."
+ done
+
+PhoneMaleGreetMornText:
+ text "<PLAYER>, good"
+ line "morning!"
+
+ para "It's me, @"
+ text_ram wStringBuffer3
+ text "."
+ line "How are you doing?"
+ done
+
+PhoneMaleGreetDayText:
+ text "<PLAYER>, howdy!"
+
+ para "It's me, @"
+ text_ram wStringBuffer3
+ text "."
+ line "Isn't it nice out?"
+ done
+
+PhoneMaleGreetNiteText:
+ text "<PLAYER>, good"
+ line "evening!"
+
+ para "It's me, @"
+ text_ram wStringBuffer3
+ text "."
+ line "Got a minute?"
+ done
+
+PhoneFemaleGreetMornText:
+ text "Good morning,"
+ line "<PLAYER>."
+
+ para "This is @"
+ text_ram wStringBuffer3
+ text "."
+ line "Did I wake you?"
+ done
+
+PhoneFemaleGreetDayText:
+ text "Hello, <PLAYER>."
+
+ para "This is @"
+ text_ram wStringBuffer3
+ text "."
+ line "How are things?"
+ done
+
+PhoneFemaleGreetNiteText:
+ text "Good evening,"
+ line "<PLAYER>."
+
+ para "This is @"
+ text_ram wStringBuffer3
+ text "."
+ line "Were you awake?"
+ done
+
+PhoneMaleReallyEnergeticText:
+ text "How are your"
+ line "#MON doing?"
+
+ para "My @"
+ text_ram wStringBuffer4
+ text "'s"
+ line "really energetic."
+ cont "It's a handful!"
+ done
+
+PhoneFemaleTopShapeText:
+ text "How are your"
+ line "#MON doing?"
+
+ para "I always keep my"
+ line "@"
+ text_ram wStringBuffer4
+ text " in top"
+
+ para "shape by going to"
+ line "#MON CENTERS."
+ done
+
+PhoneMaleLookingAwesomeText:
+ text "My @"
+ text_ram wStringBuffer4
+ text "'s"
+ line "looking awesome."
+
+ para "I wish I could"
+ line "show you."
+ done
+
+PhoneFemaleDressedUpText:
+ text "I dressed up my"
+ line "@"
+ text_ram wStringBuffer4
+ text "."
+
+ para "It looks even"
+ line "cuter than before."
+ done
+
+PhoneMaleManagedToBeatText:
+ text "Oh, yeah, I man-"
+ line "aged to beat a"
+ cont "tough @"
+ text_ram wStringBuffer4
+ text "."
+
+ para "I need to make my"
+ line "party stronger."
+ done
+
+PhoneFemaleTypeAdvantageText:
+ text "You have to hear"
+ line "this! I battled"
+
+ para "@"
+ text_ram wStringBuffer4
+ text " the"
+ line "other day."
+
+ para "It was easy! I had"
+ line "a type advantage."
+ done
+
+PhoneMaleAlmostCaughtText:
+ text "Hey, listen!"
+ line "I almost caught"
+
+ para "@"
+ text_ram wStringBuffer4
+ text " the"
+ line "other day."
+
+ para "Oh, it was soooo"
+ line "close too!"
+ done
+
+PhoneFemaleMissedCatchingText:
+ text "Guess what happen-"
+ line "ed the other day."
+
+ para "I missed catching"
+ line "@"
+ text_ram wStringBuffer4
+ text " again."
+
+ para "Maybe I'm not very"
+ line "good at this…"
+ done
+
+PhoneMaleWantsToBattleText:
+ text "Want to battle?"
+ line "It's not going to"
+
+ para "be a repeat of the"
+ line "last time we met."
+
+ para "I'll be around"
+ line "@"
+ text_ram wStringBuffer5
+ text "."
+ done
+
+PhoneFemaleWantsToBattleText:
+ text "Do you want to"
+ line "battle? I'm going"
+ cont "to win this time!"
+
+ para "I'll be waiting"
+ line "for you around"
+
+ para "@"
+ text_ram wStringBuffer5
+ text "."
+ line "Look for me, OK?"
+ done
+
+PhoneWrongNumberKazText:
+ text "Hello? This is"
+ line "@"
+ text_ram wStringBuffer3
+ text "…"
+
+ para "Uh-oh… You're not"
+ line "KAZ! Sorry, wrong"
+ cont "number."
+ done
+
+PhoneWrongNumberAudreyText:
+ text "Hello, this is"
+ line "@"
+ text_ram wStringBuffer3
+ text ". How are"
+ cont "you doing, AUDREY?"
+
+ para "Huh? <PLAYER>?"
+ line "Oops! My mistake!"
+ done
+
+PhoneSeeYouLaterText:
+ text "See you later!"
+ done
+
+PhoneByeByeText:
+ text "Bye-bye!"
+ done
+
+PhoneSwarmGrassText:
+ text "You have to see"
+ line "this! It's wild!"
+
+ para "A whole bunch of"
+ line "@"
+ text_ram wStringBuffer4
+ text " have"
+
+ para "shown up around"
+ line "@"
+ text_ram wStringBuffer5
+ text "!"
+ done
+
+PhoneSwarmFishText:
+ text "It's amazing!"
+
+ para "On @"
+ text_ram wStringBuffer5
+ text ","
+ line "@"
+ text_ram wStringBuffer4
+ text " are"
+
+ para "biting like there"
+ line "is no tomorrow."
+
+ para "<PLAYER>, bring"
+ line "your ROD, buddy!"
+ done
+
+PhoneSwarmCaveText:
+ text "A friend just told"
+ line "me this."
+
+ para "He saw a lot of"
+ line "@"
+ text_ram wStringBuffer4
+ text " in"
+ cont "@"
+ text_ram wStringBuffer5
+ text "."
+
+ para "<PLAYER>, you ought"
+ line "to go look."
+ done
+
+PhoneBugCatchingContestText:
+ text "They're holding"
+ line "the Bug-Catching"
+
+ para "Contest today at"
+ line "the PARK."
+
+ para "<PLAYER>, are you"
+ line "going to go?"
+ done
+
+IrwinRocketTakeoverRumorText:
+ text "<PLAYER>, did you"
+ line "know?"
+
+ para "I hear GOLDENROD's"
+ line "RADIO TOWER was"
+
+ para "taken over by TEAM"
+ line "ROCKET."
+
+ para "But what exactly"
+ line "is TEAM ROCKET?"
+ done
+
+GinaRocketTakeoverRumorText:
+ text "<PLAYER>, did you"
+ line "hear the news?"
+
+ para "TEAM ROCKET has"
+ line "taken over the"
+
+ para "RADIO TOWER in"
+ line "GOLDENROD CITY."
+
+ para "I wonder if the"
+ line "workers are OK…"
+ done
diff --git a/data/phone/text/unused.asm b/data/phone/text/unused.asm
new file mode 100644
index 00000000..cd1cf723
--- /dev/null
+++ b/data/phone/text/unused.asm
@@ -0,0 +1,3 @@
+UnusedPhoneText:
+ text "Good morning."
+ done
diff --git a/data/pokemon/unused_pic_banks.asm b/data/pokemon/unused_pic_banks.asm
new file mode 100755
index 00000000..2ede9c3f
--- /dev/null
+++ b/data/pokemon/unused_pic_banks.asm
@@ -0,0 +1,17 @@
+; This was a table of Pokémon sprite banks in the 1997 G/S prototype.
+; See pokegold-spaceworld's gfx/pokemon/pkmn_pic_banks.asm.
+
+Unreferenced_MonPicBanks:
+ ; last mon in bank, bank #
+ db RAICHU, $15 + 0
+ db DUGTRIO, $15 + 1
+ db GRAVELER, $15 + 2
+ db KRABBY, $15 + 3
+ db STARMIE, $15 + 4
+ db ARTICUNO, $15 + 5
+ db ARIADOS, $15 + 6 ; JARANRA in pokegold-spaceworld
+ db ESPEON, $15 + 7 ; KOUNYA in pokegold-spaceworld
+ db OCTILLERY, $15 + 8 ; BOMBSEEKER in pokegold-spaceworld
+ db LARVITAR, $15 + 9 ; NYULA in pokegold-spaceworld
+ db $ff, $15 + 10
+ db $ff, $15 + 11
diff --git a/data/text/unused_gen1_trainer_names.asm b/data/text/unused_gen1_trainer_names.asm
new file mode 100755
index 00000000..fa839f36
--- /dev/null
+++ b/data/text/unused_gen1_trainer_names.asm
@@ -0,0 +1,71 @@
+Gen1TrainerClassNames:
+; Untranslated trainer class names from Red.
+ dw .Youngster
+ dw .BugCatcher
+ dw .Lass
+ dw wOTClassName ; sailor
+ dw .JrTrainerM
+ dw .JrTrainerF
+ dw .Pokemaniac
+ dw .SuperNerd
+ dw wOTClassName ; hiker
+ dw wOTClassName ; biker
+ dw .Burglar
+ dw .Engineer
+ dw .Jack
+ dw wOTClassName ; fisher
+ dw .Swimmer
+ dw wOTClassName ; cue ball
+ dw wOTClassName ; gambler
+ dw .Beauty
+ dw wOTClassName ; psychic
+ dw .Rocker
+ dw .Juggler
+ dw wOTClassName ; tamer
+ dw wOTClassName ; bird keeper
+ dw .Blackbelt
+ dw wOTClassName ; rival1
+ dw .ProfOak
+ dw .Chief
+ dw .Scientist
+ dw wOTClassName ; giovanni
+ dw .Rocket
+ dw .CooltrainerM
+ dw .CooltrainerF
+ dw wOTClassName ; bruno
+ dw wOTClassName ; brock
+ dw wOTClassName ; misty
+ dw wOTClassName ; lt.surge
+ dw wOTClassName ; erika
+ dw wOTClassName ; koga
+ dw wOTClassName ; blaine
+ dw wOTClassName ; sabrina
+ dw wOTClassName ; gentleman
+ dw wOTClassName ; rival2
+ dw wOTClassName ; rival3
+ dw wOTClassName ; lorelei
+ dw wOTClassName ; channeler
+ dw wOTClassName ; agatha
+ dw wOTClassName ; lance
+
+.Youngster: db "たんパン@"
+.BugCatcher: db "むしとり@"
+.Lass: db "ミニスカ@"
+.JrTrainerM: db "ボーイ@"
+.JrTrainerF: db "ガール@"
+.Pokemaniac: db "マニア@"
+.SuperNerd: db "りかけい@"
+.Burglar: db "どろぼう@"
+.Engineer: db "オヤジ@"
+.Jack: db "ジャック@"
+.Swimmer: db "かいパン@"
+.Beauty: db "おねえさん@"
+.Rocker: db "グループ@"
+.Juggler: db "ジャグラー@"
+.Blackbelt: db "からて@"
+.ProfOak: db "オーキド@"
+.Chief: db "チーフ@"
+.Scientist: db "けんきゅういん@"
+.Rocket: db "だんいん@"
+.CooltrainerM: db "エりート♂@"
+.CooltrainerF: db "エりート♀@"
diff --git a/data/types/names.asm b/data/types/names.asm
new file mode 100755
index 00000000..62d8e13b
--- /dev/null
+++ b/data/types/names.asm
@@ -0,0 +1,50 @@
+TypeNames:
+; entries correspond to types (see constants/type_constants.asm)
+ dw Normal
+ dw Fighting
+ dw Flying
+ dw Poison
+ dw Ground
+ dw Rock
+ dw Bird
+ dw Bug
+ dw Ghost
+ dw Steel
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw CurseType
+ dw Fire
+ dw Water
+ dw Grass
+ dw Electric
+ dw Psychic
+ dw Ice
+ dw Dragon
+ dw Dark
+
+Normal: db "NORMAL@"
+Fighting: db "FIGHTING@"
+Flying: db "FLYING@"
+Poison: db "POISON@"
+CurseType: db "???@"
+Fire: db "FIRE@"
+Water: db "WATER@"
+Grass: db "GRASS@"
+Electric: db "ELECTRIC@"
+Psychic: db "PSYCHIC@"
+Ice: db "ICE@"
+Ground: db "GROUND@"
+Rock: db "ROCK@"
+Bird: db "BIRD@"
+Bug: db "BUG@"
+Ghost: db "GHOST@"
+Steel: db "STEEL@"
+Dragon: db "DRAGON@"
+Dark: db "DARK@"
diff --git a/engine/battle/unreferenced_getgen1trainerclassname.asm b/engine/battle/unreferenced_getgen1trainerclassname.asm
new file mode 100755
index 00000000..04532523
--- /dev/null
+++ b/engine/battle/unreferenced_getgen1trainerclassname.asm
@@ -0,0 +1,21 @@
+Unreferenced_GetGen1TrainerClassName:
+ ld hl, Gen1TrainerClassNames
+ ld a, [wTrainerClass]
+ dec a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wStringBuffer1
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ cp "@"
+ jr nz, .copy
+ ret
+
+INCLUDE "data/text/unused_gen1_trainer_names.asm"
diff --git a/engine/events/basement_key.asm b/engine/events/basement_key.asm
new file mode 100755
index 00000000..ab8c39ce
--- /dev/null
+++ b/engine/events/basement_key.asm
@@ -0,0 +1,32 @@
+_BasementKey:
+; Are we even in the right map to use this?
+ ld a, [wMapGroup]
+ cp GROUP_GOLDENROD_UNDERGROUND
+ jr nz, .nope
+
+ ld a, [wMapNumber]
+ cp MAP_GOLDENROD_UNDERGROUND
+ jr nz, .nope
+; Are we on the tile in front of the door?
+ call GetFacingTileCoord
+ ld a, d
+ cp 22
+ jr nz, .nope
+ ld a, e
+ cp 10
+ jr nz, .nope
+; Let's use the Basement Key
+ ld hl, .BasementKeyScript
+ call QueueScript
+ ld a, TRUE
+ ld [wItemEffectSucceeded], a
+ ret
+
+.nope
+ ld a, FALSE
+ ld [wItemEffectSucceeded], a
+ ret
+
+.BasementKeyScript:
+ closetext
+ farsjump BasementDoorScript
diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm
new file mode 100755
index 00000000..c15b1def
--- /dev/null
+++ b/engine/events/card_key.asm
@@ -0,0 +1,37 @@
+_CardKey:
+; Are we even in the right map to use this?
+ ld a, [wMapGroup]
+ cp GROUP_RADIO_TOWER_3F
+ jr nz, .nope
+
+ ld a, [wMapNumber]
+ cp MAP_RADIO_TOWER_3F
+ jr nz, .nope
+; Are we facing the slot?
+ ld a, [wPlayerDirection]
+ and %1100
+ cp OW_UP
+ jr nz, .nope
+
+ call GetFacingTileCoord
+ ld a, d
+ cp 18
+ jr nz, .nope
+ ld a, e
+ cp 6
+ jr nz, .nope
+; Let's use the Card Key.
+ ld hl, .CardKeyScript
+ call QueueScript
+ ld a, TRUE
+ ld [wItemEffectSucceeded], a
+ ret
+
+.nope
+ ld a, FALSE
+ ld [wItemEffectSucceeded], a
+ ret
+
+.CardKeyScript:
+ closetext
+ farsjump CardKeySlotScript
diff --git a/engine/events/fishing_gfx.asm b/engine/events/fishing_gfx.asm
new file mode 100755
index 00000000..c4a0b9fa
--- /dev/null
+++ b/engine/events/fishing_gfx.asm
@@ -0,0 +1,24 @@
+LoadFishingGFX:
+ ld de, FishingGFX
+ ld hl, vTiles0 tile $02
+ lb bc, BANK(FishingGFX), 2
+ call Get2bpp
+
+ ld de, FishingGFX tile $02
+ ld hl, vTiles0 tile $06
+ lb bc, BANK(FishingGFX), 2
+ call Get2bpp
+
+ ld de, FishingGFX tile $04
+ ld hl, vTiles0 tile $0a
+ lb bc, BANK(FishingGFX), 2
+ call Get2bpp
+
+ ld de, FishingGFX tile $06
+ ld hl, vTiles0 tile $fc
+ lb bc, BANK(FishingGFX), 2
+ call Get2bpp
+ ret
+
+FishingGFX:
+INCBIN "gfx/overworld/chris_fish.2bpp"
diff --git a/engine/events/poisonstep.asm b/engine/events/poisonstep.asm
new file mode 100755
index 00000000..98a6e25a
--- /dev/null
+++ b/engine/events/poisonstep.asm
@@ -0,0 +1,154 @@
+DoPoisonStep::
+ ld a, [wPartyCount]
+ and a
+ jr z, .no_faint
+
+ xor a
+ ld c, wPoisonStepDataEnd - wPoisonStepData
+ ld hl, wPoisonStepData
+.loop_clearPoisonStepData
+ ld [hli], a
+ dec c
+ jr nz, .loop_clearPoisonStepData
+
+ xor a
+ ld [wCurPartyMon], a
+.loop_check_poison
+ call .DamageMonIfPoisoned
+ jr nc, .not_poisoned
+; the output flag is stored in c, copy it to [wPoisonStepPartyFlags + [wCurPartyMon]]
+; and set the corresponding flag in wPoisonStepFlagSum
+ ld a, [wCurPartyMon]
+ ld e, a
+ ld d, 0
+ ld hl, wPoisonStepPartyFlags
+ add hl, de
+ ld [hl], c
+ ld a, [wPoisonStepFlagSum]
+ or c
+ ld [wPoisonStepFlagSum], a
+
+.not_poisoned
+ ld a, [wPartyCount]
+ ld hl, wCurPartyMon
+ inc [hl]
+ cp [hl]
+ jr nz, .loop_check_poison
+
+ ld a, [wPoisonStepFlagSum]
+ and %10
+ jr nz, .someone_has_fainted
+ ld a, [wPoisonStepFlagSum]
+ and %01
+ jr z, .no_faint
+ call .PlayPoisonSFX
+ xor a
+ ret
+
+.someone_has_fainted
+ ld a, BANK(.Script_MonFaintedToPoison)
+ ld hl, .Script_MonFaintedToPoison
+ call CallScript
+ scf
+ ret
+
+.no_faint
+ xor a
+ ret
+
+.DamageMonIfPoisoned:
+; check if mon is poisoned, return if not
+ ld a, MON_STATUS
+ call GetPartyParamLocation
+ ld a, [hl]
+ and 1 << PSN
+ ret z
+
+; check if mon is already fainted, return if so
+ ld a, MON_HP
+ call GetPartyParamLocation
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+ or c
+ ret z
+
+; do 1 HP damage
+ dec bc
+ ld [hl], c
+ dec hl
+ ld [hl], b
+
+; check if mon has fainted as a result of poison damage
+ ld a, b
+ or c
+ jr nz, .not_fainted
+
+; the mon has fainted, reset its status, set carry, and return %10
+ ld a, MON_STATUS
+ call GetPartyParamLocation
+ ld [hl], 0
+ ld c, %10
+ scf
+ ret
+
+.not_fainted
+; set carry and return %01
+ ld c, %01
+ scf
+ ret
+
+.PlayPoisonSFX:
+ ld de, SFX_POISON
+ call PlaySFX
+ ld b, $2
+ predef LoadPoisonBGPals
+ call DelayFrame
+ ret
+
+.Script_MonFaintedToPoison:
+ callasm .PlayPoisonSFX
+ opentext
+ callasm .CheckWhitedOut
+ iffalse .whiteout
+ closetext
+ end
+
+.whiteout
+ farsjump Script_OverworldWhiteout
+
+.CheckWhitedOut:
+ xor a
+ ld [wCurPartyMon], a
+ ld de, wPoisonStepPartyFlags
+.party_loop
+ push de
+ ld a, [de]
+ and %10
+ jr z, .mon_not_fainted
+ ld c, HAPPINESS_POISONFAINT
+ farcall ChangeHappiness
+ farcall GetPartyNick
+ ld hl, .PoisonFaintText
+ call PrintText
+
+.mon_not_fainted
+ pop de
+ inc de
+ ld hl, wCurPartyMon
+ inc [hl]
+ ld a, [wPartyCount]
+ cp [hl]
+ jr nz, .party_loop
+ predef CheckPlayerPartyForFitMon
+ ld a, d
+ ld [wScriptVar], a
+ ret
+
+.PoisonFaintText:
+ text_far _PoisonFaintText
+ text_end
+
+.PoisonWhiteoutText:
+ text_far _PoisonWhiteoutText
+ text_end
diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm
new file mode 100755
index 00000000..d105b2fb
--- /dev/null
+++ b/engine/events/sacred_ash.asm
@@ -0,0 +1,68 @@
+_SacredAsh:
+ ld a, $0
+ ld [wItemEffectSucceeded], a
+ call CheckAnyFaintedMon
+ ret nc
+
+ ld hl, SacredAshScript
+ call QueueScript
+ ld a, $1
+ ld [wItemEffectSucceeded], a
+ ret
+
+CheckAnyFaintedMon:
+ ld de, PARTYMON_STRUCT_LENGTH
+ ld bc, wPartySpecies
+ ld hl, wPartyMon1HP
+ ld a, [wPartyCount]
+ and a
+ ret z
+
+.loop
+ push af
+ push hl
+ ld a, [bc]
+ inc bc
+ cp EGG
+ jr z, .next
+
+ ld a, [hli]
+ or [hl]
+ jr z, .done
+
+.next
+ pop hl
+ add hl, de
+ pop af
+ dec a
+ jr nz, .loop
+ xor a
+ ret
+
+.done
+ pop hl
+ pop af
+ scf
+ ret
+
+SacredAshScript:
+ special HealParty
+ reloadmappart
+ playsound SFX_WARP_TO
+ special FadeOutPalettes
+ special FadeInPalettes
+ special FadeOutPalettes
+ special FadeInPalettes
+ special FadeOutPalettes
+ special FadeInPalettes
+ waitsfx
+ writetext .UseSacredAshText
+ playsound SFX_CAUGHT_MON
+ waitsfx
+ waitbutton
+ closetext
+ end
+
+.UseSacredAshText:
+ text_far _UseSacredAshText
+ text_end
diff --git a/engine/events/squirtbottle.asm b/engine/events/squirtbottle.asm
new file mode 100755
index 00000000..411b5c2e
--- /dev/null
+++ b/engine/events/squirtbottle.asm
@@ -0,0 +1,45 @@
+_Squirtbottle:
+ ld hl, .SquirtbottleScript
+ call QueueScript
+ ld a, $1
+ ld [wItemEffectSucceeded], a
+ ret
+
+.SquirtbottleScript:
+ reloadmappart
+ special UpdateTimePals
+ callasm .CheckCanUseSquirtbottle
+ iffalse .SquirtbottleNothingScript
+ farsjump WateredWeirdTreeScript
+
+.SquirtbottleNothingScript:
+ jumptext .SquirtbottleNothingText
+
+.SquirtbottleNothingText:
+ text_far _SquirtbottleNothingText
+ text_end
+
+.CheckCanUseSquirtbottle:
+ ld a, [wMapGroup]
+ cp GROUP_ROUTE_36
+ jr nz, .nope
+
+ ld a, [wMapNumber]
+ cp MAP_ROUTE_36
+ jr nz, .nope
+
+ farcall GetFacingObject
+ jr c, .nope
+
+ ld a, d
+ cp SPRITEMOVEDATA_SUDOWOODO
+ jr nz, .nope
+
+ ld a, 1
+ ld [wScriptVar], a
+ ret
+
+.nope
+ xor a
+ ld [wScriptVar], a
+ ret
diff --git a/engine/events/sweet_scent.asm b/engine/events/sweet_scent.asm
new file mode 100755
index 00000000..9b99a256
--- /dev/null
+++ b/engine/events/sweet_scent.asm
@@ -0,0 +1,65 @@
+SweetScentFromMenu:
+ ld hl, .SweetScent
+ call QueueScript
+ ld a, $1
+ ld [wFieldMoveSucceeded], a
+ ret
+
+.SweetScent:
+ reloadmappart
+ special UpdateTimePals
+ callasm GetPartyNick
+ writetext UseSweetScentText
+ waitbutton
+ callasm SweetScentEncounter
+ iffalse SweetScentNothing
+ checkflag ENGINE_BUG_CONTEST_TIMER
+ iftrue .BugCatchingContest
+ randomwildmon
+ startbattle
+ reloadmapafterbattle
+ end
+
+.BugCatchingContest:
+ farsjump BugCatchingContestBattleScript
+
+SweetScentNothing:
+ writetext SweetScentNothingText
+ waitbutton
+ closetext
+ end
+
+SweetScentEncounter:
+ farcall CanUseSweetScent
+ jr nc, .no_battle
+ ld hl, wStatusFlags2
+ bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
+ jr nz, .not_in_bug_contest
+ farcall GetMapEncounterRate
+ ld a, b
+ and a
+ jr z, .no_battle
+ farcall ChooseWildEncounter
+ jr nz, .no_battle
+ jr .start_battle
+
+.not_in_bug_contest
+ farcall ChooseWildEncounter_BugContest
+
+.start_battle
+ ld a, $1
+ ld [wScriptVar], a
+ ret
+
+.no_battle
+ xor a
+ ld [wScriptVar], a
+ ret
+
+UseSweetScentText:
+ text_far _UseSweetScentText
+ text_end
+
+SweetScentNothingText:
+ text_far _SweetScentNothingText
+ text_end
diff --git a/engine/link/init_list.asm b/engine/link/init_list.asm
new file mode 100755
index 00000000..b85cf001
--- /dev/null
+++ b/engine/link/init_list.asm
@@ -0,0 +1,55 @@
+InitList:
+; This entire function is useless.
+ ld a, [wInitListType]
+
+ cp INIT_ENEMYOT_LIST
+ jr nz, .check_party_ot_name
+ ld hl, wOTPartyCount
+ ld de, wOTPartyMonOT
+ ld a, ENEMY_OT_NAME
+ jr .done
+
+.check_party_ot_name
+ cp INIT_PLAYEROT_LIST
+ jr nz, .check_mon_name
+ ld hl, wPartyCount
+ ld de, wPartyMonOT
+ ld a, PARTY_OT_NAME
+ jr .done
+
+.check_mon_name
+ cp INIT_MON_LIST
+ jr nz, .check_item_name
+ ld hl, wCurMart
+ ld de, PokemonNames
+ ld a, MON_NAME
+ jr .done
+
+.check_item_name
+ cp INIT_BAG_ITEM_LIST
+ jr nz, .check_ob_item_name
+ ld hl, wNumItems
+ ld de, ItemNames
+ ld a, ITEM_NAME
+ jr .done
+
+.check_ob_item_name
+ ld hl, wCurMart
+ ld de, ItemNames
+ ld a, ITEM_NAME
+.done
+ ld [wNamedObjectTypeBuffer], a
+ ld a, l
+ ld [wListPointer], a
+ ld a, h
+ ld [wListPointer + 1], a
+ ld a, e
+ ld [wUnusedCFFE], a
+ ld a, d
+ ld [wUnusedCFFE + 1], a
+ ld bc, ItemAttributes
+ ld a, c
+ ld [wItemAttributesPtr], a
+ ld a, b
+ ld [wItemAttributesPtr + 1], a
+ ret
diff --git a/engine/movie/gamefreak_presents.asm b/engine/movie/gamefreak_presents.asm
index 2676c9f6..f4c2c5cc 100644
--- a/engine/movie/gamefreak_presents.asm
+++ b/engine/movie/gamefreak_presents.asm
@@ -1,41 +1,30 @@
-Copyright_GFPresents: ; e49a8 (39:49a8)
+Copyright_GFPresents:
; Play the copyright screen and GameFreak Presents sequence.
; Return carry if user cancels animation by pressing a button.
call ClearBGPalettes
call ClearTilemap
-
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
xor a ; LOW(vBGMap0)
ldh [hBGMapAddress], a
-
ldh [hJoyDown], a
ldh [hSCX], a
ldh [hSCY], a
-
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
-
call WaitBGMap
-
ld b, SCGB_GAMEFREAK_LOGO
call GetSGBLayout
-
call SetPalettes
-
ld c, 10
call DelayFrames
-
callfar Copyright
-
call WaitBGMap
-
ld c, 100
call DelayFrames
-
call ClearTilemap
- call GFPresents_Init
+ call .GetGFLogoGFX
.loop
call GFPresents_PlayFrame
@@ -55,7 +44,7 @@ Copyright_GFPresents: ; e49a8 (39:49a8)
scf
ret
-GFPresents_Init: ; e49f3 (39:49f3)
+.GetGFLogoGFX:
; Load gfx and initialize variables
ld de, GFPresentsGFX1
@@ -75,25 +64,21 @@ GFPresents_Init: ; e49f3 (39:49f3)
ld [hli], a
ld a, $8d
ld [hl], a
-
xor a
ld [wJumptableIndex], a
- ld [$ce64], a
+ ld [wIntroSceneFrameCounter], a
ld [wIntroSceneTimer], a
ldh [hSCX], a
ldh [hSCY], a
-
ld a, 1
ldh [hBGMapMode], a
-
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
-
lb de, %00100100, %11111000
call DmgToCgbObjPals
ret
-GFPresents_PlayFrame: ; e4a37 (39:4a37)
+GFPresents_PlayFrame:
; Play one frame of GFPresents sequence.
; Return carry when the sequence completes or is canceled.
@@ -133,7 +118,7 @@ GFPresents_PlayFrame: ; e4a37 (39:4a37)
scf
ret
-GFPresents_HandleFrame: ; e4a6d (39:4a6d)
+GFPresents_HandleFrame:
; Dispatch to the current scene handler
ld a, [wJumptableIndex]
@@ -155,26 +140,26 @@ GFPresents_HandleFrame: ; e4a6d (39:4a6d)
dw GFPresents_WaitForTimer
dw GFPresents_SetDoneFlag
-GFPresents_NextScene: ; e4a88 (39:4a88)
+GFPresents_NextScene:
ld hl, wJumptableIndex
inc [hl]
ret
; unused?
-Func_e4a8d: ; e4a8d (39:4a8d)
+Functione4a8d:
ld c, 64
call DelayFrames
call GFPresents_NextScene
ret
-GFPresents_Star: ; e4a96 (39:4a96)
+GFPresents_Star:
; tell GFPresents_PlaceLogo we haven't finished yet
xor a
- ld [$ce64], a
+ ld [wIntroSceneFrameCounter], a
depixel 10, 11, 4, 0
- ld a, $16
+ ld a, SPRITE_ANIM_INDEX_GS_INTRO_STAR
call InitSpriteAnimStruct
; TODO set some flag in the struct?
@@ -188,17 +173,17 @@ GFPresents_Star: ; e4a96 (39:4a96)
call GFPresents_NextScene
ret
-GFPresents_PlaceLogo: ; e4ab2 (39:4ab2)
+GFPresents_PlaceLogo:
; Draw the Game Freak logo (may be initially invisible due to palette)
; wait until the star animation completed
; TODO this is cleared above, but when is it set?
- ld a, [$ce64]
+ ld a, [wIntroSceneFrameCounter]
and a
ret z
depixel 10, 11, 4, 0
- ld a, $15
+ ld a, SPRITE_ANIM_INDEX_GAMEFREAK_LOGO
call InitSpriteAnimStruct
call GFPresents_NextScene
@@ -208,7 +193,7 @@ GFPresents_PlaceLogo: ; e4ab2 (39:4ab2)
ld [wIntroSceneTimer], a
ret
-GFPresents_LogoSparkles: ; e4ac8 (39:4ac8)
+GFPresents_LogoSparkles:
ld hl, wIntroSceneTimer
ld a, [hl]
@@ -230,16 +215,18 @@ GFPresents_LogoSparkles: ; e4ac8 (39:4ac8)
call GFPresents_NextScene
ret
-GFPresents_PlaceGameFreak: ; e4adf (39:4adf)
+GFPresents_PlaceGameFreak:
hlcoord 5, 12
ld de, .game_freak
call PlaceString
ret
.game_freak
- db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86, "@"
+ db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86
+.end
+ db "@"
-GFPresents_PlacePresents: ; e4af4 (39:4af4)
+GFPresents_PlacePresents:
hlcoord 7, 13
ld de, .presents
call PlaceString
@@ -252,18 +239,18 @@ GFPresents_PlacePresents: ; e4af4 (39:4af4)
ret
.presents
- db $87, $88, $89, $8a, $8b, $8c, "@"
+ db $87, $88, $89, $8a, $8b, $8c
+.end
+ db "@"
-GFPresents_SetDoneFlag: ; e4b0d (39:4b0d)
-; Tell GFPresents_PlayFrame and TitleScreenFrame (01:63da) that we're finished.
+GFPresents_SetDoneFlag:
+; Tell GFPresents_PlayFrame and TitleScreenFrame that we're finished.
ld hl, wJumptableIndex
set 7, [hl]
ret
-GFPresents_WaitForTimer: ; e4b13 (39:4b13)
-; Wait for the timer to elapse
-
+GFPresents_WaitForTimer:
ld hl, wIntroSceneTimer
ld a, [hl]
and a
@@ -274,8 +261,8 @@ GFPresents_WaitForTimer: ; e4b13 (39:4b13)
call GFPresents_NextScene
ret
-GFPresents_UpdateLogoPal: ; e4b20 (39:4b20)
-; called from 29:5928
+GFPresents_UpdateLogoPal:
+; called from 23:5928
; OBP1 was initialized at end of GFPresents_Init
; once we reached the final state, leave it alone
@@ -297,7 +284,7 @@ GFPresents_UpdateLogoPal: ; e4b20 (39:4b20)
call DmgToCgbObjPal1
ret
-GFPresents_Sparkle: ; e4b33 (39:4b33)
+GFPresents_Sparkle:
; Initialize and configure a sparkle sprite.
; TODO unclear how this relates to the actual screen display,
; seems to be called more times than there are visible sparkles?
@@ -314,7 +301,7 @@ GFPresents_Sparkle: ; e4b33 (39:4b33)
; set up a new sparkle sprite
push af
depixel 11, 11
- ld a, $17
+ ld a, SPRITE_ANIM_INDEX_GS_INTRO_SPARKLE
call InitSpriteAnimStruct
pop af
diff --git a/engine/movie/title.asm b/engine/movie/title.asm
index 93345798..0545b8f1 100644
--- a/engine/movie/title.asm
+++ b/engine/movie/title.asm
@@ -55,7 +55,7 @@ TitleScreen:
ld [hli], a ; wIntroSceneFrameCounter
ld [hli], a ; wTitleScreenTimer
ld [hl], a ; wTitleScreenTimer + 1
- ld de, $6058
+ depixel 12, 11
ld a, SPRITE_ANIM_INDEX_GS_INTRO_HO_OH
call InitSpriteAnimStruct
ld hl, wSpriteAnim1
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index bdf23ec4..6747c0ef 100755
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -394,7 +394,7 @@ DoPlayerMovement::
.CheckWarp:
; Bug: Since no case is made for STANDING here, it will check
-; [.edgewarps + $ff]. This resolves to $3e at $8035a.
+; [.edgewarps + $ff]. This resolves to $3e at $1035a.
; This causes wWalkingIntoEdgeWarp to be nonzero when standing on tile $3e,
; making bumps silent.
diff --git a/engine/phone/scripts/bike_shop.asm b/engine/phone/scripts/bike_shop.asm
new file mode 100644
index 00000000..bb10af68
--- /dev/null
+++ b/engine/phone/scripts/bike_shop.asm
@@ -0,0 +1,5 @@
+BikeShopPhoneCallerScript:
+ writetext BikeShopPhoneCallerText
+ clearflag ENGINE_BIKE_SHOP_CALL_ENABLED
+ specialphonecall SPECIALCALL_NONE
+ end
diff --git a/engine/phone/scripts/bill.asm b/engine/phone/scripts/bill.asm
new file mode 100644
index 00000000..7bb2e4d6
--- /dev/null
+++ b/engine/phone/scripts/bill.asm
@@ -0,0 +1,41 @@
+BillPhoneCalleeScript:
+ checktime DAY
+ iftrue .daygreet
+ checktime NITE
+ iftrue .nitegreet
+ writetext BillPhoneMornGreetingText
+ promptbutton
+ sjump .main
+
+.daygreet
+ writetext BillPhoneDayGreetingText
+ promptbutton
+ sjump .main
+
+.nitegreet
+ writetext BillPhoneNiteGreetingText
+ promptbutton
+ sjump .main
+
+.main
+ writetext BillPhoneGenericText
+ promptbutton
+ readvar VAR_BOXSPACE
+ getnum STRING_BUFFER_3
+ ifequal 0, .full
+ ifless PARTY_LENGTH, .nearlyfull
+ writetext BillPhoneNotFullText
+ end
+
+.nearlyfull
+ writetext BillPhoneNearlyFullText
+ end
+
+.full
+ writetext BillPhoneFullText
+ end
+
+BillPhoneCallerScript:
+ writetext BillPhoneNewlyFullText
+ waitbutton
+ end
diff --git a/engine/phone/scripts/elm.asm b/engine/phone/scripts/elm.asm
new file mode 100644
index 00000000..b93bdc22
--- /dev/null
+++ b/engine/phone/scripts/elm.asm
@@ -0,0 +1,101 @@
+ElmPhoneCalleeScript:
+ readvar VAR_SPECIALPHONECALL
+ ifequal SPECIALCALL_POKERUS, .pokerus
+ checkevent EVENT_SHOWED_TOGEPI_TO_ELM
+ iftrue .discovery
+ checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE
+ iffalse .next
+ checkevent EVENT_TOGEPI_HATCHED
+ iftrue .egghatched
+.next
+ checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE
+ iftrue .eggunhatched
+ checkevent EVENT_ELMS_AIDE_IN_LAB
+ iftrue .assistant
+ checkevent EVENT_GAVE_MYSTERY_EGG_TO_ELM
+ iftrue .checkingegg
+ checkevent EVENT_ELM_CALLED_ABOUT_STOLEN_POKEMON
+ iftrue .stolen
+ checkevent EVENT_GOT_MYSTERY_EGG_FROM_MR_POKEMON
+ iftrue .sawmrpokemon
+ writetext ElmPhoneHealYourMonText
+ end
+
+.sawmrpokemon
+ writetext ElmPhoneSawMrPokemonText
+ end
+
+.stolen
+ writetext ElmPhonePokemonStolenText
+ end
+
+.checkingegg
+ writetext ElmPhoneCheckingTheEggText
+ end
+
+.assistant
+ writetext ElmPhoneAssistantText
+ end
+
+.eggunhatched
+ writetext ElmPhoneHowIsTheEggText
+ end
+
+.egghatched
+ writetext ElmPhoneEggHatchedText
+ setevent EVENT_TOLD_ELM_ABOUT_TOGEPI_OVER_THE_PHONE
+ end
+
+.discovery
+ random 2
+ ifequal 0, .nextdiscovery
+ writetext ElmPhoneDiscoveredHatchTimeText
+ end
+
+.nextdiscovery
+ writetext ElmPhoneInvestigatingEggMovesText
+ end
+
+.pokerus
+ writetext ElmPhoneDiscoveredPokerusText
+ specialphonecall SPECIALCALL_NONE
+ end
+
+ElmPhoneCallerScript:
+ readvar VAR_SPECIALPHONECALL
+ ifequal SPECIALCALL_ROBBED, .disaster
+ ifequal SPECIALCALL_ASSISTANT, .assistant
+ ifequal SPECIALCALL_WEIRDBROADCAST, .rocket
+ ifequal SPECIALCALL_SSTICKET, .gift
+ ifequal SPECIALCALL_MASTERBALL, .gift
+ writetext ElmPhoneDiscoveredPokerusText
+ specialphonecall SPECIALCALL_NONE
+ end
+
+.disaster
+ writetext ElmPhoneDisasterText
+ specialphonecall SPECIALCALL_NONE
+ setevent EVENT_ELM_CALLED_ABOUT_STOLEN_POKEMON
+ end
+
+.assistant
+ writetext ElmPhoneEggAssistantText
+ specialphonecall SPECIALCALL_NONE
+ clearevent EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER
+ setevent EVENT_ELMS_AIDE_IN_LAB
+ end
+
+.rocket
+ writetext ElmPhoneRadioTowerRocketTakeoverText
+ specialphonecall SPECIALCALL_NONE
+ end
+
+.gift
+ writetext ElmPhoneGiftText
+ specialphonecall SPECIALCALL_NONE
+ end
+
+.unused
+ writetext ElmPhoneGotAholdOfSomethingNeatText
+ specialphonecall SPECIALCALL_NONE
+ end
diff --git a/engine/phone/scripts/generic.asm b/engine/phone/scripts/generic.asm
new file mode 100644
index 00000000..4587c739
--- /dev/null
+++ b/engine/phone/scripts/generic.asm
@@ -0,0 +1,227 @@
+PhoneScript_Random2:
+ random 2
+ end
+
+PhoneScript_Random4:
+ random 4
+ end
+
+PhoneScript_AnswerPhone_Male:
+ checktime DAY
+ iftrue .day
+ checktime NITE
+ iftrue .nite
+ writetext PhoneMaleAnswerMornText
+ promptbutton
+ end
+.day
+ writetext PhoneMaleAnswerDayText
+ promptbutton
+ end
+.nite
+ writetext PhoneMaleAnswerNiteText
+ promptbutton
+ end
+
+PhoneScript_AnswerPhone_Female:
+ checktime DAY
+ iftrue .day
+ checktime NITE
+ iftrue .nite
+ writetext PhoneFemaleAnswerMornText
+ promptbutton
+ end
+.day
+ writetext PhoneFemaleAnswerDayText
+ promptbutton
+ end
+.nite
+ writetext PhoneFemaleAnswerNiteText
+ promptbutton
+ end
+
+PhoneScript_GreetPhone_Male:
+ checktime DAY
+ iftrue .day
+ checktime NITE
+ iftrue .nite
+ writetext PhoneMaleGreetMornText
+ promptbutton
+ end
+.day
+ writetext PhoneMaleGreetDayText
+ promptbutton
+ end
+.nite
+ writetext PhoneMaleGreetNiteText
+ promptbutton
+ end
+
+PhoneScript_GreetPhone_Female:
+ checktime DAY
+ iftrue .day
+ checktime NITE
+ iftrue .nite
+ writetext PhoneFemaleGreetMornText
+ promptbutton
+ end
+.day
+ writetext PhoneFemaleGreetDayText
+ promptbutton
+ end
+.nite
+ writetext PhoneFemaleGreetNiteText
+ promptbutton
+ end
+
+; Huey
+Phone_GenericCall_Male_SkipMon:
+ special RandomPhoneMon
+ scall PhoneScript_Random2
+ ifequal 0, Phone_LookingAwesome_Male_SkipMon
+ writetext PhoneMaleReallyEnergeticText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+; unused
+Phone_GenericCall_Female_SkipMon:
+ special RandomPhoneMon
+ scall PhoneScript_Random2
+ ifequal 0, Phone_DressedUp_Female_SkipMon
+ writetext PhoneFemaleTopShapeText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+; Huey
+Phone_LookingAwesome_Male_SkipMon:
+ writetext PhoneMaleLookingAwesomeText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+; unused
+Phone_DressedUp_Female_SkipMon:
+ writetext PhoneFemaleDressedUpText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+Phone_GenericCall_Male:
+ special RandomPhoneMon
+ scall PhoneScript_Random2
+ ifequal 0, Phone_LookingAwesome_Male
+ writetext PhoneMaleReallyEnergeticText
+ promptbutton
+ sjump Phone_FoundAMon_Male
+
+Phone_GenericCall_Female:
+ special RandomPhoneMon
+ scall PhoneScript_Random2
+ ifequal 0, Phone_DressedUp_Female
+ writetext PhoneFemaleTopShapeText
+ promptbutton
+ sjump Phone_FoundAMon_Female
+
+Phone_LookingAwesome_Male:
+ writetext PhoneMaleLookingAwesomeText
+ promptbutton
+ sjump Phone_FoundAMon_Male
+
+Phone_DressedUp_Female:
+ writetext PhoneFemaleDressedUpText
+ promptbutton
+ sjump Phone_FoundAMon_Female
+
+Phone_FoundAMon_Male:
+ special RandomPhoneWildMon
+ scall PhoneScript_Random2
+ ifequal 0, PhoneScript_AlmostCaught_Male
+ writetext PhoneMaleManagedToBeatText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+Phone_FoundAMon_Female:
+ special RandomPhoneWildMon
+ scall PhoneScript_Random2
+ ifequal 0, PhoneScript_MissedCatching_Female
+ writetext PhoneFemaleTypeAdvantageText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+PhoneScript_AlmostCaught_Male:
+ writetext PhoneMaleAlmostCaughtText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+PhoneScript_MissedCatching_Female:
+ writetext PhoneFemaleMissedCatchingText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+PhoneScript_WantsToBattle_Male:
+ writetext PhoneMaleWantsToBattleText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+PhoneScript_WantsToBattle_Female:
+ writetext PhoneFemaleWantsToBattleText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+Phone_WrongNumber_JoseBrent:
+ writetext PhoneWrongNumberKazText
+ end
+
+Phone_WrongNumber_Tiffany:
+ writetext PhoneWrongNumberAudreyText
+ end
+
+PhoneScript_SeeYouLater:
+ writetext PhoneSeeYouLaterText
+ end
+
+PhoneScript_ByeBye:
+ writetext PhoneByeByeText
+ end
+
+PhoneScript_SwarmGrass:
+ writetext PhoneSwarmGrassText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+PhoneScript_SwarmFish:
+ writetext PhoneSwarmFishText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+PhoneScript_SwarmCave:
+ writetext PhoneSwarmCaveText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+PhoneScript_BugCatchingContest:
+ writetext PhoneBugCatchingContestText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+IrwinRocketRumorScript:
+ writetext IrwinRocketTakeoverRumorText
+ promptbutton
+ sjump PhoneScript_SeeYouLater
+
+GinaRocketRumorScript:
+ writetext GinaRocketTakeoverRumorText
+ promptbutton
+ sjump PhoneScript_ByeBye
+
+Phone_CheckIfUnseenRare_Male:
+ scall PhoneScriptRareWildMon
+ iffalse PhoneScript_SeeYouLater
+ sjump Phone_GenericCall_Male
+
+Phone_CheckIfUnseenRare_Female:
+ scall PhoneScriptRareWildMon
+ iffalse PhoneScript_ByeBye
+ sjump Phone_GenericCall_Female
+
+PhoneScriptRareWildMon:
+ special RandomUnseenWildMon
+ end
diff --git a/engine/phone/scripts/mom.asm b/engine/phone/scripts/mom.asm
new file mode 100644
index 00000000..ec0e5113
--- /dev/null
+++ b/engine/phone/scripts/mom.asm
@@ -0,0 +1,150 @@
+MomPhoneCalleeScript:
+ checkevent EVENT_TALKED_TO_MOM_AFTER_MYSTERY_EGG_QUEST
+ iftrue .script_10401f
+ checkevent EVENT_DUDE_TALKED_TO_YOU
+ iftrue MomPhoneLectureScript
+ checkevent EVENT_GAVE_MYSTERY_EGG_TO_ELM
+ iftrue MomPhoneNoGymQuestScript
+ checkevent EVENT_GOT_A_POKEMON_FROM_ELM
+ iftrue MomPhoneNoPokedexScript
+ sjump MomPhoneNoPokemonScript
+
+.script_10401f
+ checkevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_8
+ iftrue MomPhoneHangUpScript
+ writetext MomPhoneGreetingText
+ promptbutton
+ getcurlandmarkname STRING_BUFFER_3
+ readvar VAR_ROOFPALETTE
+ ifequal 1, MomPhonePalette1
+ ifequal 2, MomPhonePalette2
+ sjump MomPhoneOther
+
+MomPhoneLandmark:
+ writetext MomPhoneLandmarkText
+ promptbutton
+ sjump MomSavingMoney
+
+MomPhonePalette1:
+ readvar VAR_MAPGROUP
+ ifequal GROUP_NEW_BARK_TOWN, .newbark
+ ifequal GROUP_CHERRYGROVE_CITY, .cherrygrove
+ ifequal GROUP_VIOLET_CITY, .violet
+ ifequal GROUP_AZALEA_TOWN, .azalea
+ ifequal GROUP_GOLDENROD_CITY, .goldenrod
+ writetext MomPhoneGenericAreaText
+ promptbutton
+ sjump MomSavingMoney
+
+.newbark
+ writetext MomPhoneNewBarkText
+ promptbutton
+ sjump MomSavingMoney
+
+.cherrygrove
+ writetext MomPhoneCherrygroveText
+ promptbutton
+ sjump MomSavingMoney
+
+.violet
+ getstring STRING_BUFFER_4, .text_sprout_tower
+ sjump MomPhoneLandmark
+.text_sprout_tower
+ db "SPROUT TOWER@"
+
+.azalea
+ getstring STRING_BUFFER_4, .text_slowpoke_well
+ sjump MomPhoneLandmark
+.text_slowpoke_well
+ db "SLOWPOKE WELL@"
+
+.goldenrod
+ getstring STRING_BUFFER_4, .text_radio_tower
+ sjump MomPhoneLandmark
+.text_radio_tower
+ db "RADIO TOWER@"
+
+MomPhonePalette2:
+ writetext MomOtherAreaText
+ promptbutton
+ sjump MomSavingMoney
+
+MomPhoneOther:
+ writetext MomDeterminedText
+ promptbutton
+ sjump MomSavingMoney
+
+MomSavingMoney:
+ checkflag ENGINE_MOM_SAVING_MONEY
+ iffalse .NotSaving
+ checkmoney MOMS_MONEY, 0
+ ifequal HAVE_MORE, .SavingHasMoney
+ sjump .SavingNoMoney
+
+.NotSaving:
+ checkmoney MOMS_MONEY, 0
+ ifequal HAVE_MORE, .HasMoney
+ sjump .NoMoney
+
+.SavingHasMoney:
+ getmoney STRING_BUFFER_3, MOMS_MONEY
+ writetext MomCheckBalanceText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ sjump MomPhoneStopSavingMoneyScript
+
+.SavingNoMoney:
+ writetext MomImportantToSaveText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ sjump MomPhoneStopSavingMoneyScript
+
+.NoMoney:
+ writetext MomYoureNotSavingText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ sjump MomPhoneStopSavingMoneyScript
+
+.HasMoney:
+ getmoney STRING_BUFFER_3, MOMS_MONEY
+ writetext MomYouveSavedText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ sjump MomPhoneStopSavingMoneyScript
+
+MomPhoneSaveMoneyScript:
+ setflag ENGINE_MOM_SAVING_MONEY
+ writetext MomOKIllSaveText
+ promptbutton
+ sjump MomPhoneHangUpScript
+
+MomPhoneStopSavingMoneyScript:
+ clearflag ENGINE_MOM_SAVING_MONEY
+ writetext MomPhoneStopSavingMoneyText
+ promptbutton
+ sjump MomPhoneHangUpScript
+
+MomPhoneHangUpScript:
+ writetext MomPhoneHangUpText
+ end
+
+MomPhoneNoPokemonScript:
+ writetext MomPhoneNoPokemonText
+ end
+
+MomPhoneNoPokedexScript:
+ writetext MomPhoneNoPokedexText
+ end
+
+MomPhoneNoGymQuestScript:
+ writetext MomPhoneNoGymQuestText
+ end
+
+MomPhoneLectureScript:
+ setevent EVENT_TALKED_TO_MOM_AFTER_MYSTERY_EGG_QUEST
+ setflag ENGINE_MOM_ACTIVE
+ specialphonecall SPECIALCALL_NONE
+ writetext MomPhoneLectureText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ sjump MomPhoneStopSavingMoneyScript
diff --git a/engine/phone/scripts/trainers.asm b/engine/phone/scripts/trainers.asm
new file mode 100644
index 00000000..8c22df62
--- /dev/null
+++ b/engine/phone/scripts/trainers.asm
@@ -0,0 +1,677 @@
+JackPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, JACK1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+JackPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, JACK1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneNationalParkText
+ setevent EVENT_JACK_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+BeverlyPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, POKEFANF, BEVERLY1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+BeverlyPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, POKEFANF, BEVERLY1
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneNationalParkText
+ setevent EVENT_BEVERLY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+HueyPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, SAILOR, HUEY1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male_SkipMon
+
+HueyPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, SAILOR, HUEY1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ sjump Phone_GenericCall_Male_SkipMon
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneLighthouseText
+ setevent EVENT_HUEY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+GavenPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERM, GAVEN3
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+GavenPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERM, GAVEN3
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute26Text
+ setevent EVENT_GAVEN_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+BethPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERF, BETH1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+BethPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERF, BETH1
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute26Text
+ setevent EVENT_BETH_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+JosePhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, BIRD_KEEPER, JOSE2
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+JosePhoneCallerScript:
+ gettrainername STRING_BUFFER_3, BIRD_KEEPER, JOSE2
+ scall PhoneScript_Random4
+ ifequal 0, Phone_WrongNumber_JoseBrent
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute27Text
+ setevent EVENT_JOSE_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+ReenaPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERF, REENA1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+ReenaPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, COOLTRAINERF, REENA1
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute27Text
+ setevent EVENT_REENA_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+JoeyPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, YOUNGSTER, JOEY1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+JoeyPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, YOUNGSTER, JOEY1
+ scall PhoneScript_GreetPhone_Male
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute30Text
+ setevent EVENT_JOEY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+WadePhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, BUG_CATCHER, WADE1
+ scall PhoneScript_AnswerPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .Generic
+ checkflag ENGINE_DAILY_BUG_CONTEST
+ iftrue .Generic
+ readvar VAR_WEEKDAY
+ ifequal TUESDAY, PhoneScript_BugCatchingContest
+ ifequal THURSDAY, PhoneScript_BugCatchingContest
+ ifequal SATURDAY, PhoneScript_BugCatchingContest
+
+.Generic:
+ sjump Phone_GenericCall_Male
+
+WadePhoneCallerScript:
+ gettrainername STRING_BUFFER_3, BUG_CATCHER, WADE1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .NoContest
+ checkflag ENGINE_DAILY_BUG_CONTEST
+ iftrue .NoContest
+ readvar VAR_WEEKDAY
+ ifequal TUESDAY, PhoneScript_BugCatchingContest
+ ifequal THURSDAY, PhoneScript_BugCatchingContest
+ ifequal SATURDAY, PhoneScript_BugCatchingContest
+
+.NoContest:
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute31Text
+ setevent EVENT_WADE_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+RalphPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, FISHER, RALPH1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+RalphPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, FISHER, RALPH1
+ scall PhoneScript_GreetPhone_Male
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, .QwilfishSwarm
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute32Text
+ setevent EVENT_RALPH_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+.QwilfishSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, QWILFISH
+ getstring STRING_BUFFER_5, PhoneRoute32Text
+ setval FISHSWARM_QWILFISH
+ special ActivateFishingSwarm
+ sjump PhoneScript_SwarmFish
+
+LizPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, LIZ1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+LizPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, LIZ1
+ scall PhoneScript_GreetPhone_Female
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute32Text
+ setevent EVENT_LIZ_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+AnthonyPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, HIKER, ANTHONY2
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+AnthonyPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, HIKER, ANTHONY2
+ scall PhoneScript_GreetPhone_Male
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, .DunsparceSwarm
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute33Text
+ setevent EVENT_ANTHONY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+.DunsparceSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, DUNSPARCE
+ getstring STRING_BUFFER_5, PhoneDarkCaveText
+ swarm DARK_CAVE_VIOLET_ENTRANCE
+ sjump PhoneScript_SwarmCave
+
+ToddPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, CAMPER, TODD1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+ToddPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, CAMPER, TODD1
+ scall PhoneScript_GreetPhone_Male
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute34Text
+ setevent EVENT_TODD_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+GinaPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, GINA1
+ scall PhoneScript_AnswerPhone_Female
+ checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
+ iftrue GinaRocketRumorScript
+ sjump Phone_GenericCall_Female
+
+GinaPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, GINA1
+ scall PhoneScript_GreetPhone_Female
+ checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
+ iftrue GinaRocketRumorScript
+ checkflag ENGINE_FLYPOINT_GOLDENROD
+ iffalse .NoBattle
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+
+.NoBattle:
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute34Text
+ setevent EVENT_GINA_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+IrwinPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, JUGGLER, IRWIN1
+ scall PhoneScript_AnswerPhone_Male
+ checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
+ iftrue IrwinRocketRumorScript
+ sjump Phone_GenericCall_Male
+
+IrwinPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, JUGGLER, IRWIN1
+ scall PhoneScript_GreetPhone_Male
+ checkflag ENGINE_ROCKETS_IN_RADIO_TOWER
+ iftrue IrwinRocketRumorScript
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute35Text
+ setevent EVENT_IRWIN_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+ArniePhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, BUG_CATCHER, ARNIE1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+ArniePhoneCallerScript:
+ gettrainername STRING_BUFFER_3, BUG_CATCHER, ARNIE1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, .YanmaSwarm
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute35Text
+ setevent EVENT_ARNIE_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+.YanmaSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, YANMA
+ getstring STRING_BUFFER_5, PhoneRoute35Text
+ swarm ROUTE_35
+ sjump PhoneScript_SwarmGrass
+
+AlanPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, ALAN1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+AlanPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, ALAN1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute36Text
+ setevent EVENT_ALAN_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+DanaPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, LASS, DANA1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+DanaPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, LASS, DANA1
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute38Text
+ setevent EVENT_DANA_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+ChadPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, CHAD1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+ChadPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, SCHOOLBOY, CHAD1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .SnubbullSwarm
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.SnubbullSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, SNUBBULL
+ getstring STRING_BUFFER_5, PhoneRoute38Text
+ swarm ROUTE_38
+ sjump PhoneScript_SwarmGrass
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute38Text
+ setevent EVENT_CHAD_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+DerekPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, POKEFANM, DEREK1
+ scall PhoneScript_AnswerPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .Generic
+ checkflag ENGINE_DAILY_BUG_CONTEST
+ iftrue .Generic
+ readvar VAR_WEEKDAY
+ ifequal TUESDAY, PhoneScript_BugCatchingContest
+ ifequal THURSDAY, PhoneScript_BugCatchingContest
+ ifequal SATURDAY, PhoneScript_BugCatchingContest
+
+.Generic:
+ sjump Phone_GenericCall_Male
+
+DerekPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, POKEFANM, DEREK1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .NoContest
+ checkflag ENGINE_DAILY_BUG_CONTEST
+ iftrue .NoContest
+ readvar VAR_WEEKDAY
+ ifequal TUESDAY, PhoneScript_BugCatchingContest
+ ifequal THURSDAY, PhoneScript_BugCatchingContest
+ ifequal SATURDAY, PhoneScript_BugCatchingContest
+
+.NoContest:
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute39Text
+ setevent EVENT_DEREK_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+ChrisPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, FISHER, CHRIS1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+ChrisPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, FISHER, CHRIS1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute42Text
+ setevent EVENT_CHRIS_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+BrentPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, POKEMANIAC, BRENT1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+BrentPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, POKEMANIAC, BRENT1
+ scall PhoneScript_Random4
+ ifequal 0, Phone_WrongNumber_JoseBrent
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute43Text
+ setevent EVENT_BRENT_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+TiffanyPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, TIFFANY3
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+TiffanyPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, TIFFANY3
+ scall PhoneScript_Random4
+ ifequal 0, Phone_WrongNumber_Tiffany
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute43Text
+ setevent EVENT_TIFFANY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+VancePhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, BIRD_KEEPER, VANCE1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+VancePhoneCallerScript:
+ gettrainername STRING_BUFFER_3, BIRD_KEEPER, VANCE1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute44Text
+ setevent EVENT_VANCE_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+WiltonPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, FISHER, WILTON1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+WiltonPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, FISHER, WILTON1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .RemoraidSwarm
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.RemoraidSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, REMORAID
+ getstring STRING_BUFFER_5, PhoneRoute44Text
+ setval FISHSWARM_REMORAID
+ special ActivateFishingSwarm
+ sjump PhoneScript_SwarmFish
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute44Text
+ setevent EVENT_WILTON_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+KenjiPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, BLACKBELT_T, KENJI3
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+KenjiPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, BLACKBELT_T, KENJI3
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute45Text
+ setevent EVENT_KENJI_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+ParryPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, HIKER, PARRY1
+ scall PhoneScript_AnswerPhone_Male
+ sjump Phone_GenericCall_Male
+
+ParryPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, HIKER, PARRY1
+ scall PhoneScript_GreetPhone_Male
+ scall PhoneScript_Random2
+ ifequal 0, .MarillSwarm
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Male
+ sjump Phone_GenericCall_Male
+
+.MarillSwarm:
+ checkflag ENGINE_SWARM
+ iftrue Phone_GenericCall_Male
+ getmonname STRING_BUFFER_4, MARILL
+ getstring STRING_BUFFER_5, PhoneMtMortarText
+ swarm MOUNT_MORTAR_1F_OUTSIDE
+ sjump PhoneScript_SwarmCave
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute45Text
+ setevent EVENT_PARRY_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Male
+
+ErinPhoneCalleeScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, ERIN1
+ scall PhoneScript_AnswerPhone_Female
+ sjump Phone_GenericCall_Female
+
+ErinPhoneCallerScript:
+ gettrainername STRING_BUFFER_3, PICNICKER, ERIN1
+ scall PhoneScript_GreetPhone_Female
+ scall PhoneScript_Random2
+ ifequal 0, .WantsBattle
+ scall PhoneScript_Random2
+ ifequal 0, Phone_CheckIfUnseenRare_Female
+ sjump Phone_GenericCall_Female
+
+.WantsBattle:
+ getstring STRING_BUFFER_5, PhoneRoute46Text
+ setevent EVENT_ERIN_READY_FOR_REMATCH
+ sjump PhoneScript_WantsToBattle_Female
+
+INCLUDE "engine/phone/scripts/generic.asm"
+
+INCLUDE "data/phone/text/landmarks.asm"
diff --git a/engine/phone/scripts/unused.asm b/engine/phone/scripts/unused.asm
new file mode 100644
index 00000000..08d67f60
--- /dev/null
+++ b/engine/phone/scripts/unused.asm
@@ -0,0 +1,3 @@
+UnusedPhoneScript:
+ writetext UnusedPhoneText
+ end
diff --git a/engine/pokemon/experience.asm b/engine/pokemon/experience.asm
new file mode 100755
index 00000000..7d026704
--- /dev/null
+++ b/engine/pokemon/experience.asm
@@ -0,0 +1,162 @@
+CalcLevel:
+ ld a, [wTempMonSpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld d, 1
+.next_level
+ inc d
+ ld a, d
+ cp LOW(MAX_LEVEL + 1)
+ jr z, .got_level
+ call CalcExpAtLevel
+ push hl
+ ld hl, wTempMonExp + 2
+ ldh a, [hProduct + 3]
+ ld c, a
+ ld a, [hld]
+ sub c
+ ldh a, [hProduct + 2]
+ ld c, a
+ ld a, [hld]
+ sbc c
+ ldh a, [hProduct + 1]
+ ld c, a
+ ld a, [hl]
+ sbc c
+ pop hl
+ jr nc, .next_level
+
+.got_level
+ dec d
+ ret
+
+CalcExpAtLevel:
+; (a/b)*n**3 + c*n**2 + d*n - e
+ ld a, [wBaseGrowthRate]
+ add a
+ add a
+ ld c, a
+ ld b, 0
+ ld hl, GrowthRates
+ add hl, bc
+; Cube the level
+ call .LevelSquared
+ ld a, d
+ ldh [hMultiplier], a
+ call Multiply
+
+; Multiply by a
+ ld a, [hl]
+ and $f0
+ swap a
+ ldh [hMultiplier], a
+ call Multiply
+; Divide by b
+ ld a, [hli]
+ and $f
+ ldh [hDivisor], a
+ ld b, 4
+ call Divide
+; Push the cubic term to the stack
+ ldh a, [hQuotient + 1]
+ push af
+ ldh a, [hQuotient + 2]
+ push af
+ ldh a, [hQuotient + 3]
+ push af
+; Square the level and multiply by the lower 7 bits of c
+ call .LevelSquared
+ ld a, [hl]
+ and $7f
+ ldh [hMultiplier], a
+ call Multiply
+; Push the absolute value of the quadratic term to the stack
+ ldh a, [hProduct + 1]
+ push af
+ ldh a, [hProduct + 2]
+ push af
+ ldh a, [hProduct + 3]
+ push af
+ ld a, [hli]
+ push af
+; Multiply the level by d
+ xor a
+ ldh [hMultiplicand + 0], a
+ ldh [hMultiplicand + 1], a
+ ld a, d
+ ldh [hMultiplicand + 2], a
+ ld a, [hli]
+ ldh [hMultiplier], a
+ call Multiply
+; Subtract e
+ ld b, [hl]
+ ldh a, [hProduct + 3]
+ sub b
+ ldh [hMultiplicand + 2], a
+ ld b, 0
+ ldh a, [hProduct + 2]
+ sbc b
+ ldh [hMultiplicand + 1], a
+ ldh a, [hProduct + 1]
+ sbc b
+ ldh [hMultiplicand], a
+; If bit 7 of c is set, c is negative; otherwise, it's positive
+ pop af
+ and $80
+ jr nz, .subtract
+; Add c*n**2 to (d*n - e)
+ pop bc
+ ldh a, [hProduct + 3]
+ add b
+ ldh [hMultiplicand + 2], a
+ pop bc
+ ldh a, [hProduct + 2]
+ adc b
+ ldh [hMultiplicand + 1], a
+ pop bc
+ ldh a, [hProduct + 1]
+ adc b
+ ldh [hMultiplicand], a
+ jr .done_quadratic
+
+.subtract
+; Subtract c*n**2 from (d*n - e)
+ pop bc
+ ldh a, [hProduct + 3]
+ sub b
+ ldh [hMultiplicand + 2], a
+ pop bc
+ ldh a, [hProduct + 2]
+ sbc b
+ ldh [hMultiplicand + 1], a
+ pop bc
+ ldh a, [hProduct + 1]
+ sbc b
+ ldh [hMultiplicand], a
+
+.done_quadratic
+; Add (a/b)*n**3 to (d*n - e +/- c*n**2)
+ pop bc
+ ldh a, [hProduct + 3]
+ add b
+ ldh [hMultiplicand + 2], a
+ pop bc
+ ldh a, [hProduct + 2]
+ adc b
+ ldh [hMultiplicand + 1], a
+ pop bc
+ ldh a, [hProduct + 1]
+ adc b
+ ldh [hMultiplicand], a
+ ret
+
+.LevelSquared:
+ xor a
+ ldh [hMultiplicand + 0], a
+ ldh [hMultiplicand + 1], a
+ ld a, d
+ ldh [hMultiplicand + 2], a
+ ldh [hMultiplier], a
+ jp Multiply
+
+INCLUDE "data/growth_rates.asm"
diff --git a/engine/pokemon/mon_stats.asm b/engine/pokemon/mon_stats.asm
new file mode 100755
index 00000000..04285f87
--- /dev/null
+++ b/engine/pokemon/mon_stats.asm
@@ -0,0 +1,475 @@
+DrawPlayerHP:
+ ld a, 1
+ jr DrawHP
+
+DrawEnemyHP:
+ ld a, 2
+
+DrawHP:
+ ld [wWhichHPBar], a
+ push hl
+ push bc
+ ; box mons have full HP
+ ld a, [wMonType]
+ cp BOXMON
+ jr z, .at_least_1_hp
+
+ ld a, [wTempMonHP]
+ ld b, a
+ ld a, [wTempMonHP + 1]
+ ld c, a
+
+; Any HP?
+ or b
+ jr nz, .at_least_1_hp
+
+ xor a
+ ld c, a
+ ld e, a
+ ld a, 6
+ ld d, a
+ jp .fainted
+
+.at_least_1_hp
+ ld a, [wTempMonMaxHP]
+ ld d, a
+ ld a, [wTempMonMaxHP + 1]
+ ld e, a
+ ld a, [wMonType]
+ cp BOXMON
+ jr nz, .not_boxmon
+
+ ld b, d
+ ld c, e
+
+.not_boxmon
+ predef ComputeHPBarPixels
+ ld a, 6
+ ld d, a
+ ld c, a
+
+.fainted
+ ld a, c
+ pop bc
+ ld c, a
+ pop hl
+ push de
+ push hl
+ push hl
+ call DrawBattleHPBar
+ pop hl
+
+; Print HP
+ bccoord 1, 1, 0
+ add hl, bc
+ ld de, wTempMonHP
+ ld a, [wMonType]
+ cp BOXMON
+ jr nz, .not_boxmon_2
+ ld de, wTempMonMaxHP
+.not_boxmon_2
+ lb bc, 2, 3
+ call PrintNum
+
+ ld a, "/"
+ ld [hli], a
+
+; Print max HP
+ ld de, wTempMonMaxHP
+ lb bc, 2, 3
+ call PrintNum
+ pop hl
+ pop de
+ ret
+
+INCLUDE "engine/pokemon/stats_screen.asm"
+
+PrintTempMonStats:
+; Print wTempMon's stats at hl, with spacing bc.
+ push bc
+ push hl
+ ld de, .StatNames
+ call PlaceString
+ pop hl
+ pop bc
+ add hl, bc
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ ld de, wTempMonAttack
+ lb bc, 2, 3
+ call .PrintStat
+ ld de, wTempMonDefense
+ call .PrintStat
+ ld de, wTempMonSpclAtk
+ call .PrintStat
+ ld de, wTempMonSpclDef
+ call .PrintStat
+ ld de, wTempMonSpeed
+ jp PrintNum
+
+.PrintStat:
+ push hl
+ call PrintNum
+ pop hl
+ ld de, SCREEN_WIDTH * 2
+ add hl, de
+ ret
+
+.StatNames:
+ db "ATTACK"
+ next "DEFENSE"
+ next "SPCL.ATK"
+ next "SPCL.DEF"
+ next "SPEED"
+ next "@"
+
+GetGender:
+; Return the gender of a given monster (wCurPartyMon/wCurOTMon/wCurWildMon).
+; When calling this function, a should be set to an appropriate wMonType value.
+
+; return values:
+; a = 1: f = nc|nz; male
+; a = 0: f = nc|z; female
+; f = c: genderless
+
+; This is determined by comparing the Attack and Speed DVs
+; with the species' gender ratio.
+
+; Figure out what type of monster struct we're looking at.
+
+; 0: PartyMon
+ ld hl, wPartyMon1DVs
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld a, [wMonType]
+ and a
+ jr z, .PartyMon
+
+; 1: OTPartyMon
+ ld hl, wOTPartyMon1DVs
+ dec a
+ jr z, .PartyMon
+
+; 2: sBoxMon
+ ld hl, sBoxMon1DVs
+ ld bc, BOXMON_STRUCT_LENGTH
+ dec a
+ jr z, .sBoxMon
+
+; 3: Unknown
+ ld hl, wTempMonDVs
+ dec a
+ jr z, .DVs
+
+; else: WildMon
+ ld hl, wEnemyMonDVs
+ jr .DVs
+
+; Get our place in the party/box.
+
+.PartyMon:
+.sBoxMon
+ ld a, [wCurPartyMon]
+ call AddNTimes
+
+.DVs:
+; sBoxMon data is read directly from SRAM.
+ ld a, [wMonType]
+ cp BOXMON
+ ld a, BANK(sBox)
+ call z, OpenSRAM
+
+; Attack DV
+ ld a, [hli]
+ and $f0
+ ld b, a
+; Speed DV
+ ld a, [hl]
+ and $f0
+ swap a
+
+; Put our DVs together.
+ or b
+ ld b, a
+
+; Close SRAM if we were dealing with a sBoxMon.
+ ld a, [wMonType]
+ cp BOXMON
+ call z, CloseSRAM
+
+; We need the gender ratio to do anything with this.
+ push bc
+ ld a, [wCurPartySpecies]
+ dec a
+ ld hl, BaseData + BASE_GENDER
+ ld bc, BASE_DATA_SIZE
+ call AddNTimes
+ pop bc
+
+ ld a, BANK(BaseData)
+ call GetFarByte
+
+; The higher the ratio, the more likely the monster is to be female.
+
+ cp GENDER_UNKNOWN
+ jr z, .Genderless
+
+ and a ; GENDER_F0?
+ jr z, .Male
+
+ cp GENDER_F100
+ jr z, .Female
+
+; Values below the ratio are male, and vice versa.
+ cp b
+ jr c, .Male
+
+.Female:
+ xor a
+ ret
+
+.Male:
+ ld a, 1
+ and a
+ ret
+
+.Genderless:
+ scf
+ ret
+
+ListMovePP:
+ ld a, [wNumMoves]
+ inc a
+ ld c, a
+ ld a, NUM_MOVES
+ sub c
+ ld b, a
+ push hl
+ ld a, [wBuffer1]
+ ld e, a
+ ld d, $0
+ ld a, $3e ; P
+ call .load_loop
+ ld a, b
+ and a
+ jr z, .skip
+ ld c, a
+ ld a, "-"
+ call .load_loop
+
+.skip
+ pop hl
+ inc hl
+ inc hl
+ inc hl
+ ld d, h
+ ld e, l
+ ld hl, wTempMonMoves
+ ld b, 0
+.loop
+ ld a, [hli]
+ and a
+ jr z, .done
+ push bc
+ push hl
+ push de
+ ld hl, wMenuCursorY
+ ld a, [hl]
+ push af
+ ld [hl], b
+ push hl
+ callfar GetMaxPPOfMove
+ pop hl
+ pop af
+ ld [hl], a
+ pop de
+ pop hl
+ push hl
+ ld bc, wTempMonPP - (wTempMonMoves + 1)
+ add hl, bc
+ ld a, [hl]
+ and $3f
+ ld [wStringBuffer1 + 4], a
+ ld h, d
+ ld l, e
+ push hl
+ ld de, wStringBuffer1 + 4
+ lb bc, 1, 2
+ call PrintNum
+ ld a, "/"
+ ld [hli], a
+ ld de, wTempPP
+ lb bc, 1, 2
+ call PrintNum
+ pop hl
+ ld a, [wBuffer1]
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld d, h
+ ld e, l
+ pop hl
+ pop bc
+ inc b
+ ld a, b
+ cp NUM_MOVES
+ jr nz, .loop
+
+.done
+ ret
+
+.load_loop
+ ld [hli], a
+ ld [hld], a
+ add hl, de
+ dec c
+ jr nz, .load_loop
+ ret
+
+Unused_PlaceEnemyHPLevel:
+ push hl
+ push hl
+ ld hl, wPartyMonNicknames
+ ld a, [wCurPartyMon]
+ call GetNick
+ pop hl
+ call PlaceString
+ call CopyMonToTempMon
+ pop hl
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jr z, .egg
+ push hl
+ ld bc, -12
+ add hl, bc
+ ld b, $0
+ call DrawEnemyHP
+ pop hl
+ ld bc, 5
+ add hl, bc
+ push de
+ call PrintLevel
+ pop de
+
+.egg
+ ret
+
+PlaceStatusString:
+ push de
+ inc de
+ inc de
+ ld a, [de]
+ ld b, a
+ inc de
+ ld a, [de]
+ or b
+ pop de
+ jr nz, PlaceNonFaintStatus
+ push de
+ ld de, FntString
+ call CopyStatusString
+ pop de
+ ld a, $1
+ and a
+ ret
+
+FntString:
+ db "FNT@"
+
+CopyStatusString:
+ ld a, [de]
+ inc de
+ ld [hli], a
+ ld a, [de]
+ inc de
+ ld [hli], a
+ ld a, [de]
+ ld [hl], a
+ ret
+
+PlaceNonFaintStatus:
+ push de
+ ld a, [de]
+ ld de, PsnString
+ bit PSN, a
+ jr nz, .place
+ ld de, BrnString
+ bit BRN, a
+ jr nz, .place
+ ld de, FrzString
+ bit FRZ, a
+ jr nz, .place
+ ld de, ParString
+ bit PAR, a
+ jr nz, .place
+ ld de, SlpString
+ and SLP
+ jr z, .no_status
+
+.place
+ call CopyStatusString
+ ld a, $1
+ and a
+
+.no_status
+ pop de
+ ret
+
+SlpString: db "SLP@"
+PsnString: db "PSN@"
+BrnString: db "BRN@"
+FrzString: db "FRZ@"
+ParString: db "PAR@"
+
+ListMoves:
+; List moves at hl, spaced every [wBuffer1] tiles.
+ ld de, wListMoves_MoveIndicesBuffer
+ ld b, $0
+.moves_loop
+ ld a, [de]
+ inc de
+ and a
+ jr z, .no_more_moves
+ push de
+ push hl
+ push hl
+ ld [wCurSpecies], a
+ ld a, MOVE_NAME
+ ld [wNamedObjectTypeBuffer], a
+ call GetName
+ ld de, wStringBuffer1
+ pop hl
+ push bc
+ call PlaceString
+ pop bc
+ ld a, b
+ ld [wNumMoves], a
+ inc b
+ pop hl
+ push bc
+ ld a, [wBuffer1]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ pop bc
+ pop de
+ ld a, b
+ cp NUM_MOVES
+ jr z, .done
+ jr .moves_loop
+
+.no_more_moves
+ ld a, b
+.nonmove_loop
+ push af
+ ld [hl], "-"
+ ld a, [wBuffer1]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ pop af
+ inc a
+ cp NUM_MOVES
+ jr nz, .nonmove_loop
+
+.done
+ ret
diff --git a/engine/pokemon/party_menu.asm b/engine/pokemon/party_menu.asm
new file mode 100755
index 00000000..93f9b93b
--- /dev/null
+++ b/engine/pokemon/party_menu.asm
@@ -0,0 +1,783 @@
+SelectMonFromParty:
+ call DisableSpriteUpdates
+ xor a
+ ld [wPartyMenuActionText], a
+ call ClearBGPalettes
+ call InitPartyMenuLayout
+ call WaitBGMap
+ call SetPalettes
+ call DelayFrame
+ call PartyMenuSelect
+ call ReturnToMapWithSpeechTextbox
+ ret
+
+SelectTradeOrDayCareMon:
+ ld a, b
+ ld [wPartyMenuActionText], a
+ call DisableSpriteUpdates
+ call ClearBGPalettes
+ call InitPartyMenuLayout
+ call WaitBGMap
+ ld b, SCGB_PARTY_MENU
+ call GetSGBLayout
+ call SetPalettes
+ call DelayFrame
+ call PartyMenuSelect
+ call ReturnToMapWithSpeechTextbox
+ ret
+
+InitPartyMenuLayout:
+ call LoadPartyMenuGFX
+ call InitPartyMenuWithCancel
+ call InitPartyMenuGFX
+ call WritePartyMenuTilemap
+ call PrintPartyMenuText
+ ret
+
+LoadPartyMenuGFX:
+ call LoadFontsBattleExtra
+ callfar InitPartyMenuPalettes ; engine/color.asm
+ callfar ClearSpriteAnims2
+ ret
+
+WritePartyMenuTilemap:
+ ld hl, wOptions
+ ld a, [hl]
+ push af
+ set NO_TEXT_SCROLL, [hl]
+ xor a
+ ldh [hBGMapMode], a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ call ByteFill ; blank the tilemap
+ call GetPartyMenuQualityIndexes
+.loop
+ ld a, [hli]
+ cp -1
+ jr z, .end
+ push hl
+ ld hl, .Jumptable
+ rst JumpTable
+ pop hl
+ jr .loop
+.end
+ pop af
+ ld [wOptions], a
+ ret
+
+.Jumptable:
+; entries correspond to PARTYMENUQUALITY_* constants
+ dw PlacePartyNicknames
+ dw PlacePartyHPBar
+ dw PlacePartyMenuHPDigits
+ dw PlacePartyMonLevel
+ dw PlacePartyMonStatus
+ dw PlacePartyMonTMHMCompatibility
+ dw PlacePartyMonEvoStoneCompatibility
+ dw PlacePartyMonGender
+
+PlacePartyNicknames:
+ hlcoord 3, 1
+ ld a, [wPartyCount]
+ and a
+ jr z, .end
+ ld c, a
+ ld b, 0
+.loop
+ push bc
+ push hl
+ push hl
+ ld hl, wPartyMonNicknames
+ ld a, b
+ call GetNick
+ pop hl
+ call PlaceString
+ pop hl
+ ld de, 2 * SCREEN_WIDTH
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+
+.end
+ dec hl
+ dec hl
+ ld de, .CANCEL
+ call PlaceString
+ ret
+
+.CANCEL:
+ db "CANCEL@"
+
+PlacePartyHPBar:
+ xor a
+ ld [wSGBPals], a
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 11, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .skip
+ push hl
+ call PlacePartymonHPBar
+ pop hl
+ ld d, $6
+ ld b, $0
+ call DrawBattleHPBar
+ ld hl, wHPPals
+ ld a, [wSGBPals]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ call SetHPPal
+ ld b, SCGB_PARTY_MENU_HP_PALS
+ call GetSGBLayout
+.skip
+ ld hl, wSGBPals
+ inc [hl]
+ pop hl
+ ld de, 2 * SCREEN_WIDTH
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ld b, SCGB_PARTY_MENU
+ call GetSGBLayout
+ ret
+
+PlacePartymonHPBar:
+ ld a, b
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wPartyMon1HP
+ call AddNTimes
+ ld a, [hli]
+ or [hl]
+ jr nz, .not_fainted
+ xor a
+ ld e, a
+ ld c, a
+ ret
+
+.not_fainted
+ dec hl
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ ld e, a
+ predef ComputeHPBarPixels
+ ret
+
+PlacePartyMenuHPDigits:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 13, 1
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ push hl
+ ld a, b
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wPartyMon1HP
+ call AddNTimes
+ ld e, l
+ ld d, h
+ pop hl
+ push de
+ lb bc, 2, 3
+ call PrintNum
+ pop de
+ ld a, "/"
+ ld [hli], a
+ inc de
+ inc de
+ lb bc, 2, 3
+ call PrintNum
+
+.next
+ pop hl
+ ld de, 2 * SCREEN_WIDTH
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+PlacePartyMonLevel:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 8, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ push hl
+ ld a, b
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wPartyMon1Level
+ call AddNTimes
+ ld e, l
+ ld d, h
+ pop hl
+ ld a, [de]
+ cp 100 ; This is distinct from MAX_LEVEL.
+ jr nc, .ThreeDigits
+ ld a, "<LV>"
+ ld [hli], a
+ lb bc, PRINTNUM_LEFTALIGN | 1, 2
+ ; jr .okay
+.ThreeDigits:
+ lb bc, PRINTNUM_LEFTALIGN | 1, 3
+; .okay
+ call PrintNum
+
+.next
+ pop hl
+ ld de, SCREEN_WIDTH * 2
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+PlacePartyMonStatus:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 5, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ push hl
+ ld a, b
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wPartyMon1Status
+ call AddNTimes
+ ld e, l
+ ld d, h
+ pop hl
+ call PlaceStatusString
+
+.next
+ pop hl
+ ld de, SCREEN_WIDTH * 2
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+PlacePartyMonTMHMCompatibility:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 12, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ push hl
+ ld hl, wPartySpecies
+ ld e, b
+ ld d, 0
+ add hl, de
+ ld a, [hl]
+ ld [wCurPartySpecies], a
+ predef CanLearnTMHMMove
+ pop hl
+ call .PlaceAbleNotAble
+ call PlaceString
+
+.next
+ pop hl
+ ld de, SCREEN_WIDTH * 2
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+.PlaceAbleNotAble:
+ ld a, c
+ and a
+ jr nz, .able
+ ld de, .string_not_able
+ ret
+
+.able
+ ld de, .string_able
+ ret
+
+.string_able
+ db "ABLE@"
+
+.string_not_able
+ db "NOT ABLE@"
+
+PlacePartyMonEvoStoneCompatibility:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 12, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ push hl
+ ld a, b
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wPartyMon1Species
+ call AddNTimes
+ ld a, [hl]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, EvosAttacksPointers
+ add hl, de
+ add hl, de
+ call .DetermineCompatibility
+ pop hl
+ call PlaceString
+
+.next
+ pop hl
+ ld de, 2 * SCREEN_WIDTH
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+.DetermineCompatibility:
+ ld de, wStringBuffer1
+ ld a, BANK(EvosAttacksPointers)
+ ld bc, 2
+ call FarCopyBytes
+ ld hl, wStringBuffer1
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wStringBuffer1
+ ld a, BANK("Evolutions and Attacks")
+ ld bc, 10
+ call FarCopyBytes
+ ld hl, wStringBuffer1
+.loop2
+ ld a, [hli]
+ and a
+ jr z, .nope
+ inc hl
+ inc hl
+ cp EVOLVE_ITEM
+ jr nz, .loop2
+ dec hl
+ dec hl
+ ld a, [wCurItem]
+ cp [hl]
+ inc hl
+ inc hl
+ jr nz, .loop2
+ ld de, .string_able
+ ret
+
+.nope
+ ld de, .string_not_able
+ ret
+
+.string_able
+ db "ABLE@"
+.string_not_able
+ db "NOT ABLE@"
+
+PlacePartyMonGender:
+ ld a, [wPartyCount]
+ and a
+ ret z
+ ld c, a
+ ld b, 0
+ hlcoord 12, 2
+.loop
+ push bc
+ push hl
+ call PartyMenuCheckEgg
+ jr z, .next
+ ld [wCurPartySpecies], a
+ push hl
+ ld a, b
+ ld [wCurPartyMon], a
+ xor a
+ ld [wMonType], a
+ call GetGender
+ ld de, .unknown
+ jr c, .got_gender
+ ld de, .male
+ jr nz, .got_gender
+ ld de, .female
+
+.got_gender
+ pop hl
+ call PlaceString
+
+.next
+ pop hl
+ ld de, 2 * SCREEN_WIDTH
+ add hl, de
+ pop bc
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+
+.male
+ db "♂…MALE@"
+
+.female
+ db "♀…FEMALE@"
+
+.unknown
+ db "…UNKNOWN@"
+
+PartyMenuCheckEgg:
+ ld a, LOW(wPartySpecies)
+ add b
+ ld e, a
+ ld a, HIGH(wPartySpecies)
+ adc 0
+ ld d, a
+ ld a, [de]
+ cp EGG
+ ret
+
+GetPartyMenuQualityIndexes:
+ ld a, [wPartyMenuActionText]
+ and $f0
+ jr nz, .skip
+ ld a, [wPartyMenuActionText]
+ and $f
+ ld e, a
+ ld d, 0
+ ld hl, PartyMenuQualityPointers
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+
+.skip
+ ld hl, PartyMenuQualityPointers.Default
+ ret
+
+INCLUDE "data/party_menu_qualities.asm"
+
+InitPartyMenuGFX:
+ ld hl, wPartyCount
+ ld a, [hli]
+ and a
+ ret z
+ ld c, a
+ xor a
+ ldh [hObjectStructIndexBuffer], a
+.loop
+ push bc
+ push hl
+ ld hl, LoadMenuMonIcon
+ ld a, BANK(LoadMenuMonIcon)
+ ld e, MONICON_PARTYMENU
+ rst FarCall
+ ldh a, [hObjectStructIndexBuffer]
+ inc a
+ ldh [hObjectStructIndexBuffer], a
+ pop hl
+ pop bc
+ dec c
+ jr nz, .loop
+ callfar PlaySpriteAnimations
+ ret
+
+InitPartyMenuWithCancel:
+; with cancel
+ xor a
+ ld [wSwitchMon], a
+ ld de, PartyMenuAttributes
+ call SetMenuAttributes
+ ld a, [wPartyCount]
+ inc a
+ ld [w2DMenuNumRows], a ; list length
+ dec a
+ ld b, a
+ ld a, [wPartyMenuCursor]
+ and a
+ jr z, .skip
+ inc b
+ cp b
+ jr c, .done
+
+.skip
+ ld a, 1
+
+.done
+ ld [wMenuCursorY], a
+ ld a, A_BUTTON | B_BUTTON
+ ld [wMenuJoypadFilter], a
+ ret
+
+InitPartyMenuNoCancel:
+; no cancel
+ ld de, PartyMenuAttributes
+ call SetMenuAttributes
+ ld a, [wPartyCount]
+ ld [w2DMenuNumRows], a ; list length
+ ld b, a
+ ld a, [wPartyMenuCursor]
+ and a
+ jr z, .skip
+ inc b
+ cp b
+ jr c, .done
+.skip
+ ld a, 1
+.done
+ ld [wMenuCursorY], a
+ ld a, A_BUTTON | B_BUTTON
+ ld [wMenuJoypadFilter], a
+ ret
+
+PartyMenuAttributes:
+; cursor y
+; cursor x
+; num rows
+; num cols
+; bit 6: animate sprites bit 5: wrap around
+; ?
+; distance between items (hi: y, lo: x)
+; allowed buttons (mask)
+ db 1, 0
+ db 0, 1
+ db $60, $00
+ dn 2, 0
+ db 0
+
+PartyMenuSelect:
+; sets carry if exitted menu.
+ call StaticMenuJoypad
+ call PlaceHollowCursor
+ ld a, [wPartyCount]
+ inc a
+ ld b, a
+ ld a, [wMenuCursorY] ; menu selection?
+ cp b
+ jr z, .exitmenu ; CANCEL
+ ld [wPartyMenuCursor], a
+ ldh a, [hJoyLast]
+ ld b, a
+ bit B_BUTTON_F, b
+ jr nz, .exitmenu ; B button
+ ld a, [wMenuCursorY]
+ dec a
+ ld [wCurPartyMon], a
+ ld c, a
+ ld b, $0
+ ld hl, wPartySpecies
+ add hl, bc
+ ld a, [hl]
+ ld [wCurPartySpecies], a
+
+ ld de, SFX_READ_TEXT_2
+ call PlaySFX
+ call WaitSFX
+ and a
+ ret
+
+.exitmenu
+ ld de, SFX_READ_TEXT_2
+ call PlaySFX
+ call WaitSFX
+ scf
+ ret
+
+PrintPartyMenuText:
+ hlcoord 0, 14
+ lb bc, 2, 18
+ call Textbox
+ ld a, [wPartyCount]
+ and a
+ jr nz, .haspokemon
+ ld de, YouHaveNoPKMNString
+ jr .gotstring
+.haspokemon
+ ld a, [wPartyMenuActionText]
+ and $f ; drop high nibble
+ ld hl, PartyMenuStrings
+ ld e, a
+ ld d, $0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+.gotstring
+ ld a, [wOptions]
+ push af
+ set NO_TEXT_SCROLL, a
+ ld [wOptions], a
+ hlcoord 1, 16 ; Coord
+ call PlaceString
+ pop af
+ ld [wOptions], a
+ ret
+
+PartyMenuStrings:
+ dw ChooseAMonString
+ dw UseOnWhichPKMNString
+ dw WhichPKMNString
+ dw TeachWhichPKMNString
+ dw MoveToWhereString
+ dw UseOnWhichPKMNString
+ dw ChooseAMonString ; Probably used to be ChooseAFemalePKMNString
+ dw ChooseAMonString ; Probably used to be ChooseAMalePKMNString
+ dw ToWhichPKMNString
+
+ChooseAMonString:
+ db "Choose a #MON.@"
+
+UseOnWhichPKMNString:
+ db "Use on which <PK><MN>?@"
+
+WhichPKMNString:
+ db "Which <PK><MN>?@"
+
+TeachWhichPKMNString:
+ db "Teach which <PK><MN>?@"
+
+MoveToWhereString:
+ db "Move to where?@"
+
+ChooseAFemalePKMNString:
+; unused
+ db "Choose a ♀<PK><MN>.@"
+
+ChooseAMalePKMNString:
+; unused
+ db "Choose a ♂<PK><MN>.@"
+
+ToWhichPKMNString:
+ db "To which <PK><MN>?@"
+
+YouHaveNoPKMNString:
+ db "You have no <PK><MN>!@"
+
+PrintPartyMenuActionText:
+ ld a, [wCurPartyMon]
+ ld hl, wPartyMonNicknames
+ call GetNick
+ ld a, [wPartyMenuActionText]
+ and $f
+ ld hl, .MenuActionTexts
+ call .PrintText
+ ret
+
+.MenuActionTexts:
+; entries correspond to PARTYMENUTEXT_* constants
+ dw .CuredOfPoisonText
+ dw .BurnWasHealedText
+ dw .WasDefrostedText
+ dw .WokeUpText
+ dw .RidOfParalysisText
+ dw .RecoveredSomeHPText
+ dw .HealthReturnedText
+ dw .RevitalizedText
+ dw .GrewToLevelText
+ dw .CameToItsSensesText
+
+.RecoveredSomeHPText:
+ text_far _RecoveredSomeHPText
+ text_end
+
+.CuredOfPoisonText:
+ text_far _CuredOfPoisonText
+ text_end
+
+.RidOfParalysisText:
+ text_far _RidOfParalysisText
+ text_end
+
+.BurnWasHealedText:
+ text_far _BurnWasHealedText
+ text_end
+
+.WasDefrostedText:
+ text_far _WasDefrostedText
+ text_end
+
+.WokeUpText:
+ text_far _WokeUpText
+ text_end
+
+.HealthReturnedText:
+ text_far _HealthReturnedText
+ text_end
+
+.RevitalizedText:
+ text_far _RevitalizedText
+ text_end
+
+.GrewToLevelText:
+ text_far _GrewToLevelText
+ text_end
+
+.CameToItsSensesText:
+ text_far _CameToItsSensesText
+ text_end
+
+.PrintText:
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wOptions]
+ push af
+ set NO_TEXT_SCROLL, a
+ ld [wOptions], a
+ call PrintText
+ pop af
+ ld [wOptions], a
+ ret
diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm
new file mode 100644
index 00000000..a2345f37
--- /dev/null
+++ b/engine/pokemon/stats_screen.asm
@@ -0,0 +1,868 @@
+ const_def 1
+ const PINK_PAGE ; 1
+ const GREEN_PAGE ; 2
+ const BLUE_PAGE ; 3
+
+StatsScreenInit:
+ ldh a, [hMapAnims]
+ push af
+ xor a
+ ldh [hMapAnims], a ; disable overworld tile animations
+
+ ld c, 1
+ call StatsScreenMain
+
+ ; restore old values
+ pop af
+ ldh [hMapAnims], a
+ ret
+
+StatsScreenMain:
+ push bc
+ ld a, [wMonType]
+ cp TEMPMON
+ jr nz, .not_tempmon
+ ld a, [wBufferMonSpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+ ld hl, wBufferMon
+ ld de, wTempMon
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ jr .got_stats
+
+.not_tempmon
+ call CopyMonToTempMon
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jp z, .got_stats
+ ld a, [wMonType]
+ cp BOXMON
+ jr c, .got_stats
+ call CalcTempmonStats
+
+.got_stats
+ call ClearBGPalettes
+ call ClearTilemap
+ call UpdateSprites
+ callfar StatsScreen_LoadFont
+
+ pop bc
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jp z, EggStatsInit
+ call StatsScreen_InitUpperHalf
+ ld b, 0
+ jp StatsScreen_JumpToLoadPageFunction
+
+StatsScreen_LoadPage:
+ push bc
+ ld de, .done_loading
+ push de
+; first jump to LoadPage function in jumptable
+ jp hl
+
+; return here after LoadPage function finishes
+.done_loading
+ pop bc
+ ld b, 1
+
+.joypad_loop
+ call GetJoypad
+ ld a, [wMonType]
+ cp TEMPMON
+ jr nz, .not_tempmon
+ push hl
+ push de
+ push bc
+ farcall StatsScreenDPad
+ pop bc
+ pop de
+ pop hl
+ ld a, [wMenuJoypad]
+ and D_DOWN | D_UP
+ jr nz, StatsScreenMain
+ ld a, [wMenuJoypad]
+ jr .joypad_action
+
+.not_tempmon
+ ldh a, [hJoyPressed]
+
+.joypad_action
+ and D_DOWN | D_UP | D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON
+ jr z, .joypad_loop
+ bit B_BUTTON_F, a
+ jp nz, StatsScreen_Exit
+ bit D_LEFT_F, a
+ jr nz, .d_left
+ bit D_RIGHT_F, a
+ jr nz, .d_right
+ bit A_BUTTON_F, a
+ jr nz, .a_button
+ bit D_UP_F, a
+ jr nz, .d_up
+
+; .d_down
+ ld a, [wMonType]
+ cp BOXMON
+ jr nc, .joypad_loop
+ and a
+ ld a, [wPartyCount]
+ jr z, .next_mon
+ ld a, [wOTPartyCount]
+.next_mon
+ ld b, a
+ ld a, [wCurPartyMon]
+ inc a
+ cp b
+ jr z, .joypad_loop
+ ld [wCurPartyMon], a
+ ld b, a
+ ld a, [wMonType]
+ and a
+ jr nz, .load_mon
+ ld a, b
+ inc a
+ ld [wPartyMenuCursor], a
+ jr .load_mon
+
+.d_up
+ ld a, [wCurPartyMon]
+ and a
+ jr z, .joypad_loop
+ dec a
+ ld [wCurPartyMon], a
+ ld b, a
+ ld a, [wMonType]
+ and a
+ jr nz, .load_mon
+ ld a, b
+ inc a
+ ld [wPartyMenuCursor], a
+; fall through
+.load_mon
+ jp StatsScreenMain
+
+.a_button
+ ld a, c
+ cp BLUE_PAGE ; last page
+ jr z, StatsScreen_Exit
+
+.d_right
+ inc c
+ ld a, BLUE_PAGE ; last page
+ cp c
+ jr nc, StatsScreen_JumpToLoadPageFunction
+ ld c, PINK_PAGE ; first page
+ jr StatsScreen_JumpToLoadPageFunction
+
+.d_left
+ dec c
+ jr nz, StatsScreen_JumpToLoadPageFunction
+ ld c, BLUE_PAGE ; last page
+; fall through
+
+StatsScreen_JumpToLoadPageFunction:
+ ld hl, StatsScreen_LoadPageJumptable
+ push bc
+ dec c
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop bc
+ jp StatsScreen_LoadPage
+
+EggStatsInit:
+ push bc
+ call EggStatsScreen
+ pop bc
+; fall through
+
+EggStats_JoypadLoop:
+ call GetJoypad
+ ld a, [wMonType]
+ cp TEMPMON
+ jr nz, .not_tempmon
+; .tempmon
+ push hl
+ push de
+ push bc
+ farcall StatsScreenDPad
+ pop bc
+ pop de
+ pop hl
+ ld a, [wMenuJoypad]
+ and D_DOWN | D_UP
+ jp nz, StatsScreenMain
+ ld a, [wMenuJoypad]
+ jr .joypad_action
+
+.not_tempmon
+ ldh a, [hJoyPressed]
+.joypad_action
+ and D_DOWN | D_UP | A_BUTTON | B_BUTTON
+ jr z, EggStats_JoypadLoop
+ bit A_BUTTON_F, a
+ jr nz, StatsScreen_Exit
+ bit B_BUTTON_F, a
+ jr nz, StatsScreen_Exit
+ bit D_UP_F, a
+ jr nz, EggStats_UpAction
+ bit D_DOWN_F, a
+ jp EggStats_DownAction
+
+StatsScreen_Exit:
+ call ClearBGPalettes
+ call ClearTilemap
+ ret
+
+EggStats_DownAction:
+ ld a, [wMonType]
+ cp BOXMON
+ jr nc, EggStats_JoypadLoop
+ and a
+ ld a, [wPartyCount]
+ jr z, .next_mon
+ ld a, [wOTPartyCount]
+.next_mon
+ ld b, a
+ ld a, [wCurPartyMon]
+ inc a
+ cp b
+ jr z, EggStats_JoypadLoop
+ ld [wCurPartyMon], a
+ ld b, a
+ ld a, [wMonType]
+ and a
+ jr nz, EggStats_ScrollToLoadMon
+ ld a, b
+ inc a
+ ld [wPartyMenuCursor], a
+ jr EggStats_ScrollToLoadMon
+
+EggStats_UpAction:
+ ld a, [wCurPartyMon]
+ and a
+ jr z, EggStats_JoypadLoop
+ dec a
+ ld [wCurPartyMon], a
+ ld b, a
+ ld a, [wMonType]
+ and a
+ jr nz, EggStats_ScrollToLoadMon
+ ld a, b
+ inc a
+ ld [wPartyMenuCursor], a
+; fall through
+
+EggStats_ScrollToLoadMon:
+ jp StatsScreenMain
+
+StatsScreen_LoadPageJumptable:
+; entries correspond to *_PAGE constants
+ dw LoadPinkPage
+ dw LoadGreenPage
+ dw LoadBluePage
+
+StatsScreen_InitUpperHalf:
+ push bc
+ xor a
+ ldh [hBGMapMode], a
+ ld a, [wBaseDexNo]
+ ld [wDeciramBuffer], a
+ ld [wCurSpecies], a
+ hlcoord 8, 0
+ ld [hl], "№"
+ inc hl
+ ld [hl], "."
+ inc hl
+ ld de, wDeciramBuffer
+ lb bc, PRINTNUM_LEADINGZEROS | 1, 3
+ call PrintNum
+ hlcoord 14, 0
+ call PrintLevel
+ ld hl, .NicknamePointers
+ call GetNicknamePointer
+; Nickname
+ ld a, [wMonType]
+ cp BOXMON
+ ld a, BANK(sBoxMonNicknames)
+ call z, OpenSRAM
+ ld d, h
+ ld e, l
+ hlcoord 8, 2
+ call PlaceString
+ ld a, [wMonType]
+ cp BOXMON
+ call z, CloseSRAM
+; Gender character
+ call GetGender
+ jr c, .next
+ ld a, "♂"
+ jr nz, .got_gender
+ ld a, "♀"
+.got_gender
+ hlcoord 18, 0
+ ld [hl], a
+.next
+ hlcoord 9, 4
+ ld a, "/"
+ ld [hli], a
+ ld a, [wBaseDexNo]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ call PlaceString
+ call StatsScreen_PlaceHorizontalDivider
+ call StatsScreen_PlacePageSwitchArrows
+ call StatsScreen_PlaceShinyIcon
+; Place HP bar
+ ld hl, wTempMonHP
+ ld a, [hli]
+ ld b, a
+ ld c, [hl]
+ ld hl, wTempMonMaxHP
+ ld a, [hli]
+ ld d, a
+ ld e, [hl]
+ callfar ComputeHPBarPixels
+ ld hl, wCurHPPal
+ call SetHPPal
+ ld b, SCGB_STATS_SCREEN_HP_PALS
+ call GetSGBLayout
+ pop bc
+ ret
+
+.NicknamePointers:
+ dw wPartyMonNicknames
+ dw wOTPartyMonNicknames
+ dw sBoxMonNicknames
+ dw wBufferMonNick
+
+LoadPinkPage:
+ push bc
+ push bc
+ xor a
+ ldh [hBGMapMode], a
+ ld a, [wBaseDexNo]
+ ld [wDeciramBuffer], a
+ ld [wCurSpecies], a
+ ld b, PINK_PAGE
+ call StatsScreen_LoadPageIndicators
+
+; Load graphics
+ hlcoord 0, 8
+ lb bc, 10, 20
+ call ClearBox
+ hlcoord 0, 9
+ ld b, 0
+ call DrawPlayerHP
+ hlcoord 8, 9
+ ld [hl], $41 ; right HP/exp bar end cap
+ hlcoord 0, 12
+ ld de, .Status_Type
+ call PlaceString
+ ld a, [wTempMonPokerusStatus]
+ ld b, a
+ and $f
+ jr nz, .HasPokerus
+ ld a, b
+ and $f0
+ jr z, .NotImmuneToPkrs
+ hlcoord 8, 8
+ ld [hl], "." ; Pokérus immunity dot
+.NotImmuneToPkrs:
+ ld a, [wMonType]
+ cp BOXMON
+ jr z, .StatusOK
+ hlcoord 6, 13
+ push hl
+ ld de, wTempMonStatus
+ call PlaceStatusString
+ pop hl
+ jr .StatusOK
+.HasPokerus:
+ ld de, .PkrsStr
+ hlcoord 1, 13
+ call PlaceString
+ jr .done_status
+.StatusOK:
+ ld de, .OK_str
+ call z, PlaceString
+.done_status
+ hlcoord 1, 15
+ call PrintMonTypes
+ ld bc, 9
+ decoord 0, 16
+ hlcoord 0, 17
+ call CopyBytes
+ ld a, " "
+ ld bc, 9
+ hlcoord 0, 17
+ call ByteFill
+ hlcoord 9, 8
+ ld de, SCREEN_WIDTH
+ ld b, 10
+ ld a, $31 ; vertical divider
+.vertical_divider
+ ld [hl], a
+ add hl, de
+ dec b
+ jr nz, .vertical_divider
+ hlcoord 10, 9
+ ld de, .ExpPointStr
+ call PlaceString
+; print next level
+ ld a, [wTempMonLevel]
+ push af
+ cp MAX_LEVEL
+ jr z, .got_level
+ inc a
+ ld [wTempMonLevel], a
+.got_level
+ hlcoord 17, 14
+ call PrintLevel
+ pop af
+ ld [wTempMonLevel], a
+ ld de, wTempMonExp
+ hlcoord 13, 10
+ lb bc, 3, 7
+ call PrintNum
+; level-up graphics and strings
+ call .CalcExpToNextLevel
+ ld de, wBuffer1
+ hlcoord 13, 13
+ lb bc, 3, 7
+ call PrintNum
+ hlcoord 10, 12
+ ld de, .LevelUpStr
+ call PlaceString
+ hlcoord 14, 14
+ ld de, .ToStr
+ call PlaceString
+ ld a, [wTempMonLevel]
+ ld b, a
+ ld de, wTempMonExp + 2
+ hlcoord 11, 16
+ predef FillInExpBar
+ hlcoord 10, 16
+ ld [hl], $40 ; left exp bar end cap
+ hlcoord 19, 16
+ ld [hl], $41 ; right exp bar end cap
+
+; Load palettes / place frontpic
+ pop bc
+ farcall LoadStatsScreenPals
+ call WaitBGMap
+ ld a, 1
+ ldh [hBGMapMode], a
+ pop bc
+ ld a, b
+ and a
+ jp z, StatsScreen_PlaceFrontpic
+ ret
+
+.CalcExpToNextLevel:
+ ld a, [wTempMonLevel]
+ cp MAX_LEVEL
+ jr z, .AlreadyAtMaxLevel
+ inc a
+ ld d, a
+ call CalcExpAtLevel
+ ld hl, wTempMonExp + 2
+ ld hl, wTempMonExp + 2
+ ldh a, [hQuotient + 3]
+ sub [hl]
+ dec hl
+ ld [wBuffer3], a
+ ldh a, [hQuotient + 2]
+ sbc [hl]
+ dec hl
+ ld [wBuffer2], a
+ ldh a, [hQuotient + 1]
+ sbc [hl]
+ ld [wBuffer1], a
+ ret
+
+.AlreadyAtMaxLevel:
+ ld hl, wBuffer1
+ xor a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ret
+
+.Status_Type:
+ db "STATUS/"
+ next "TYPE/@"
+
+.OK_str:
+ db "OK @"
+
+.ExpPointStr:
+ db "EXP POINTS@"
+
+.LevelUpStr:
+ db "LEVEL UP@"
+
+.ToStr:
+ db "TO@"
+
+.PkrsStr:
+ db "#RUS@"
+
+Unreferenced_Function50f4d:
+ hlcoord 7, 0
+ ld bc, SCREEN_WIDTH
+ ld d, SCREEN_HEIGHT
+.loop
+ ld a, $31 ; vertical divider
+ ld [hl], a
+ add hl, bc
+ dec d
+ jr nz, .loop
+ ret
+
+StatsScreen_PlaceHorizontalDivider:
+ hlcoord 0, 7
+ ld b, SCREEN_WIDTH
+ ld a, $62 ; horizontal divider (empty HP/exp bar)
+.loop
+ ld [hli], a
+ dec b
+ jr nz, .loop
+ ret
+
+StatsScreen_PlacePageSwitchArrows:
+ hlcoord 12, 6
+ ld [hl], "◀"
+ hlcoord 19, 6
+ ld [hl], "▶"
+ ret
+
+StatsScreen_PlaceShinyIcon:
+ ld bc, wTempMonDVs
+ callfar CheckShininess
+ ret nc
+ hlcoord 19, 0
+ ld [hl], "⁂"
+ ret
+
+LoadGreenPage:
+ push bc
+ push bc
+ xor a
+ ldh [hBGMapMode], a
+ ld b, GREEN_PAGE
+ call StatsScreen_LoadPageIndicators
+
+; Load graphics
+ hlcoord 0, 8
+ lb bc, 10, 20
+ call ClearBox
+; item info
+ hlcoord 0, 8
+ ld de, .Item
+ call PlaceString
+ ld a, [wTempMonItem]
+ and a
+ ld de, .ThreeDashes
+ jr z, .got_item_name
+ ld b, a
+ farcall TimeCapsule_ReplaceTeruSama
+ ld a, b
+ ld [wNamedObjectIndexBuffer], a
+ call GetItemName
+.got_item_name
+ hlcoord 6, 8
+ call PlaceString
+; move info
+ ld hl, wTempMonMoves
+ ld de, wListMoves_MoveIndicesBuffer
+ ld bc, NUM_MOVES
+ call CopyBytes
+ hlcoord 0, 10
+ ld de, .Move
+ call PlaceString
+ hlcoord 8, 10
+ ld a, SCREEN_WIDTH * 2
+ ld [wBuffer1], a
+ call ListMoves
+ hlcoord 12, 11
+ ld a, SCREEN_WIDTH * 2
+ ld [wBuffer1], a
+ call ListMovePP
+
+; Load palettes / place frontpic
+ pop bc
+ farcall LoadStatsScreenPals
+ call WaitBGMap
+ ld a, 1
+ ldh [hBGMapMode], a
+ pop bc
+ ld a, b
+ and a
+ jp z, StatsScreen_PlaceFrontpic
+ ret
+
+.Item:
+ db "ITEM@"
+
+.ThreeDashes:
+ db "---@"
+
+.Move:
+ db "MOVE@"
+
+LoadBluePage:
+ push bc
+ push bc
+ xor a
+ ldh [hBGMapMode], a
+ ld b, BLUE_PAGE
+ call StatsScreen_LoadPageIndicators
+
+; Load graphics
+ hlcoord 0, 8
+ lb bc, 10, 20
+ call ClearBox
+ call .PlaceOTInfo
+ hlcoord 10, 8
+ ld de, SCREEN_WIDTH
+ ld b, 10
+ ld a, $31 ; vertical divider
+.vertical_divider
+ ld [hl], a
+ add hl, de
+ dec b
+ jr nz, .vertical_divider
+ hlcoord 11, 8
+ ld bc, 6
+ call PrintTempMonStats
+
+; Load palettes / place frontpic
+ pop bc
+ farcall LoadStatsScreenPals
+ call WaitBGMap
+ ld a, 1
+ ldh [hBGMapMode], a
+ pop bc
+ ld a, b
+ and a
+ jp z, StatsScreen_PlaceFrontpic
+ ret
+
+.PlaceOTInfo:
+ hlcoord 0, 9
+ ld de, IDNoString
+ call PlaceString
+ hlcoord 0, 12
+ ld de, OTString
+ call PlaceString
+ hlcoord 2, 10
+ ld de, wTempMonID
+ lb bc, PRINTNUM_LEADINGZEROS | 2, 5
+ call PrintNum
+ ld hl, .OTNamePointers
+ call GetNicknamePointer
+; OT name
+ ld a, [wMonType]
+ cp BOXMON
+ ld a, BANK(sBoxMonOT)
+ call z, OpenSRAM
+ ld de, wStringBuffer1
+ push de
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ pop de
+ ld a, [wMonType]
+ cp BOXMON
+ call z, CloseSRAM
+ callfar CorrectNickErrors
+ push de
+
+; Adjust coordinate of OT name based on index of nickname terminator
+ lb bc, 0, -1
+.loop
+ inc c
+ ld a, [de]
+ inc de
+ cp "@"
+ jr nz, .loop
+; remove left padding if name was 8-10 chars (somehow?)
+ ld a, NAME_LENGTH - 1
+ sub c
+ cp 3 ; NAME_LENGTH - PLAYER_NAME_LENGTH
+; otherwise, use 2 spaces of left padding
+ jr c, .ok
+ ld a, 2 ; NAME_LENGTH - PLAYER_NAME_LENGTH - 1
+.ok
+ ld c, a
+ hlcoord 0, 13
+ add hl, bc
+; that's finally over ... place string, quit forever
+ pop de
+ call PlaceString
+ ret
+
+.OTNamePointers:
+ dw wPartyMonOT
+ dw wOTPartyMonOT
+ dw sBoxMonOT
+ dw wBufferMonOT
+
+IDNoString:
+ db "<ID>№.@"
+
+OTString:
+ db "OT/@"
+
+StatsScreen_PlaceFrontpic:
+ push bc
+ call SetPalettes
+ ld hl, wTempMonDVs
+ call GetUnownLetter
+ hlcoord 0, 0
+ ld a, [wCurPartySpecies]
+ cp UNOWN
+ jr z, .unown
+
+ call PrepMonFrontpic
+ jr .play_cry
+
+.unown
+ xor a
+ ld [wBoxAlignment], a
+ call _PrepMonFrontpic
+
+.play_cry
+ ld a, [wCurPartySpecies]
+ call PlayMonCry
+ pop bc
+ ld b, 1
+ ret
+
+EggStatsScreen:
+ ld hl, wCurHPPal
+ call SetHPPal
+ ld b, SCGB_STATS_SCREEN_HP_PALS
+ call GetSGBLayout
+ call StatsScreen_PlaceHorizontalDivider
+ hlcoord 8, 1
+ ld de, EggString
+ call PlaceString
+ hlcoord 8, 3
+ ld de, IDNoString
+ call PlaceString
+ hlcoord 8, 5
+ ld de, OTString
+ call PlaceString
+ hlcoord 11, 3
+ ld de, FiveQMarkString
+ call PlaceString
+ hlcoord 11, 5
+ ld de, FiveQMarkString
+ call PlaceString
+ ld a, [wTempMonHappiness] ; egg status
+ ld de, EggSoonString
+ cp $6
+ jr c, .picked
+ ld de, EggCloseString
+ cp $b
+ jr c, .picked
+ ld de, EggMoreTimeString
+ cp $29
+ jr c, .picked
+ ld de, EggALotMoreTimeString
+.picked
+ hlcoord 1, 9
+ call PlaceString
+ call WaitBGMap
+ ld a, 1
+ ldh [hBGMapMode], a
+ call SetPalettes ; pals
+ hlcoord 0, 0
+ call PrepMonFrontpic
+ ld a, [wTempMonHappiness]
+ cp 6
+ ret nc
+ ld de, SFX_2_BOOPS
+ call PlaySFX
+ call WaitSFX
+ ret
+
+EggString:
+ db "EGG@"
+
+FiveQMarkString:
+ db "?????@"
+
+EggSoonString:
+ db "It's making sounds"
+ next "inside. It's going"
+ next "to hatch soon!@"
+
+EggCloseString:
+ db "It moves around"
+ next "inside sometimes."
+ next "It must be close"
+ next "to hatching.@"
+
+EggMoreTimeString:
+ db "Wonder what's"
+ next "inside? It needs"
+ next "more time, though.@"
+
+EggALotMoreTimeString:
+ db "This EGG needs a"
+ next "lot more time to"
+ next "hatch.@"
+
+StatsScreen_LoadPageIndicators:
+ hlcoord 13, 5
+ ld a, $36 ; first of 4 small square tiles
+ call .load_square
+ hlcoord 15, 5
+ ld a, $36 ; " " " "
+ call .load_square
+ hlcoord 17, 5
+ ld a, $36 ; " " " "
+ call .load_square
+ ld a, b
+ cp GREEN_PAGE
+ ld a, $3a ; first of 4 large square tiles
+ hlcoord 13, 5 ; PINK_PAGE (< GREEN_PAGE)
+ jr c, .load_square
+ hlcoord 15, 5 ; GREEN_PAGE (= GREEN_PAGE)
+ jr z, .load_square
+ hlcoord 17, 5 ; BLUE_PAGE (> GREEN_PAGE)
+.load_square
+ ld [hli], a
+ inc a
+ ld [hld], a
+ push bc
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ inc a
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ret
+
+GetNicknamePointer:
+ ld a, [wMonType]
+ add a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wMonType]
+ cp TEMPMON
+ ret z
+ ld a, [wCurPartyMon]
+ jp SkipNames
diff --git a/engine/pokemon/switchpartymons.asm b/engine/pokemon/switchpartymons.asm
new file mode 100755
index 00000000..24d19df6
--- /dev/null
+++ b/engine/pokemon/switchpartymons.asm
@@ -0,0 +1,145 @@
+_SwitchPartyMons:
+ ld a, [wSwitchMon]
+ dec a
+ ld [wBuffer3], a
+ ld b, a
+ ld a, [wMenuCursorY]
+ dec a
+ ld [wBuffer2], a
+ cp b
+ jr z, .skip
+ call .SwapMonAndMail
+ ld a, [wBuffer3]
+ call .ClearSprite
+ ld a, [wBuffer2]
+ call .ClearSprite
+.skip
+ ret
+
+.ClearSprite:
+ push af
+ hlcoord 0, 1
+ ld bc, 2 * SCREEN_WIDTH
+ call AddNTimes
+ ld bc, 2 * SCREEN_WIDTH
+ ld a, " "
+ call ByteFill
+ pop af
+ ld hl, wVirtualOAMSprite00
+ ld bc, 4 * SPRITEOAMSTRUCT_LENGTH
+ call AddNTimes
+ ld de, SPRITEOAMSTRUCT_LENGTH
+ ld c, 4
+.gfx_loop
+ ld [hl], SCREEN_WIDTH_PX ; y (off-screen)
+ add hl, de
+ dec c
+ jr nz, .gfx_loop
+ ld de, SFX_SWITCH_POKEMON
+ call WaitPlaySFX
+ ret
+
+.SwapMonAndMail:
+ push hl
+ push de
+ push bc
+ ld bc, wPartySpecies
+ ld a, [wBuffer2]
+ ld l, a
+ ld h, $0
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld a, [wBuffer3]
+ ld l, a
+ ld h, $0
+ add hl, bc
+ ld a, [hl]
+ push af
+ ld a, [de]
+ ld [hl], a
+ pop af
+ ld [de], a
+ ld a, [wBuffer2]
+ ld hl, wPartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ push hl
+ ld de, wceed
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ ld a, [wBuffer3]
+ ld hl, wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop de
+ push hl
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ pop de
+ ld hl, wceed
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ ld a, [wBuffer2]
+ ld hl, wPartyMonOT
+ call SkipNames
+ push hl
+ call .CopyNameTowceed
+ ld a, [wBuffer3]
+ ld hl, wPartyMonOT
+ call SkipNames
+ pop de
+ push hl
+ call .CopyName
+ pop de
+ ld hl, wceed
+ call .CopyName
+ ld hl, wPartyMonNicknames
+ ld a, [wBuffer2]
+ call SkipNames
+ push hl
+ call .CopyNameTowceed
+ ld hl, wPartyMonNicknames
+ ld a, [wBuffer3]
+ call SkipNames
+ pop de
+ push hl
+ call .CopyName
+ pop de
+ ld hl, wceed
+ call .CopyName
+ ld hl, sPartyMail
+ ld a, [wBuffer2]
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ push hl
+ ld de, wceed
+ ld bc, MAIL_STRUCT_LENGTH
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ call CopyBytes
+ ld hl, sPartyMail
+ ld a, [wBuffer3]
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ pop de
+ push hl
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ pop de
+ ld hl, wceed
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ call CloseSRAM
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.CopyNameTowceed:
+ ld de, wceed
+
+.CopyName:
+ ld bc, NAME_LENGTH
+ call CopyBytes
+ ret
diff --git a/engine/pokemon/tempmon.asm b/engine/pokemon/tempmon.asm
new file mode 100755
index 00000000..97ce1ee7
--- /dev/null
+++ b/engine/pokemon/tempmon.asm
@@ -0,0 +1,127 @@
+CopyMonToTempMon:
+; gets the BaseData of a mon
+; and copies the party_struct to wTempMon
+
+ ld a, [wCurPartyMon]
+ ld e, a
+ call GetMonSpecies
+ ld a, [wCurPartySpecies]
+ ld [wCurSpecies], a
+ call GetBaseData
+
+ ld a, [wMonType]
+ ld hl, wPartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ and a
+ jr z, .copywholestruct
+ ld hl, wOTPartyMon1Species
+ ld bc, PARTYMON_STRUCT_LENGTH
+ cp OTPARTYMON
+ jr z, .copywholestruct
+ ld bc, BOXMON_STRUCT_LENGTH
+ callfar CopyBoxmonToTempMon
+ jr .done
+
+.copywholestruct
+ ld a, [wCurPartyMon]
+ call AddNTimes
+ ld de, wTempMon
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+
+.done
+ ret
+
+CalcBufferMonStats:
+ ld bc, wBufferMon
+ jr _TempMonStatsCalculation
+
+CalcTempmonStats:
+ ld bc, wTempMon
+_TempMonStatsCalculation:
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ ld [wCurPartyLevel], a
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+ push bc
+ ld b, TRUE
+ predef CalcMonStats
+ pop bc
+ ld hl, MON_HP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jr nz, .not_egg
+ xor a
+ ld [de], a
+ inc de
+ ld [de], a
+ jr .zero_status
+
+.not_egg
+ push bc
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld bc, 2
+ call CopyBytes
+ pop bc
+
+.zero_status
+ ld hl, MON_STATUS
+ add hl, bc
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ret
+
+GetMonSpecies:
+; [wMonType] has the type of the mon
+; e = Nr. of mon (i.e. [wCurPartyMon])
+
+ ld a, [wMonType]
+ and a ; PARTYMON
+ jr z, .partymon
+ cp OTPARTYMON
+ jr z, .otpartymon
+ cp BOXMON
+ jr z, .boxmon
+ cp TEMPMON
+ jr z, .breedmon
+ ; WILDMON
+
+.partymon
+ ld hl, wPartySpecies
+ jr .done
+
+.otpartymon
+ ld hl, wOTPartySpecies
+ jr .done
+
+.boxmon
+ ld a, BANK(sBoxSpecies)
+ call OpenSRAM
+ ld hl, sBoxSpecies
+ call .done
+ call CloseSRAM
+ ret
+
+.breedmon
+ ld a, [wBreedMon1Species]
+ jr .done2
+
+.done
+ ld d, 0
+ add hl, de
+ ld a, [hl]
+
+.done2
+ ld [wCurPartySpecies], a
+ ret
diff --git a/engine/pokemon/types.asm b/engine/pokemon/types.asm
new file mode 100755
index 00000000..3c9d28cd
--- /dev/null
+++ b/engine/pokemon/types.asm
@@ -0,0 +1,92 @@
+PrintMonTypes:
+; Print one or both types of [wCurSpecies]
+; on the stats screen at hl.
+
+ push hl
+ call GetBaseData
+ pop hl
+
+ push hl
+ ld a, [wBaseType1]
+ call .Print
+
+ ; Single-typed monsters really
+ ; have two of the same type.
+ ld a, [wBaseType1]
+ ld b, a
+ ld a, [wBaseType2]
+ cp b
+ pop hl
+ jr z, .hide_type_2
+
+ ld bc, $28
+ add hl, bc
+
+.Print:
+ ld b, a
+ jr PrintType
+
+.hide_type_2
+ ; Erase any type name that was here before.
+ ; Seems to be pointless in localized versions.
+ ld a, " "
+ ld bc, SCREEN_WIDTH - 3
+ add hl, bc
+ ld [hl], a
+ inc bc
+ add hl, bc
+ ld bc, NAME_LENGTH_JAPANESE - 1
+ jp ByteFill
+
+PrintMoveType:
+; Print the type of move b at hl.
+
+ push hl
+ ld a, b
+ dec a
+ ld bc, MOVE_LENGTH
+ ld hl, Moves
+ call AddNTimes
+ ld de, wStringBuffer1
+ ld a, BANK(Moves)
+ call FarCopyBytes
+ ld a, [wStringBuffer1 + MOVE_TYPE]
+ pop hl
+
+ ld b, a
+
+PrintType:
+; Print type b at hl.
+
+ ld a, b
+
+ push hl
+ add a
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+
+ jp PlaceString
+
+GetTypeName:
+; Copy the name of type [wNamedObjectIndexBuffer] to wStringBuffer1.
+
+ ld a, [wNamedObjectIndexBuffer]
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wStringBuffer1
+ ld bc, MOVE_NAME_LENGTH
+ jp CopyBytes
+
+INCLUDE "data/types/names.asm"
diff --git a/home/print_num.asm b/home/print_num.asm
index d37ebe1d..5bea7696 100755
--- a/home/print_num.asm
+++ b/home/print_num.asm
@@ -25,39 +25,38 @@ PrintNum::
.main
xor a
- ldh [$ffb5], a
- ldh [$ffb6], a
- ldh [$ffb7], a
+ ldh [hPrintNumBuffer + 0], a
+ ldh [hPrintNumBuffer + 1], a
+ ldh [hPrintNumBuffer + 2], a
ld a, b
and $f
cp 1
jr z, .byte
cp 2
jr z, .word
-
; maximum 3 bytes
.long
ld a, [de]
- ldh [$ffb6], a
+ ldh [hPrintNumBuffer + 1], a
inc de
ld a, [de]
- ldh [$ffb7], a
+ ldh [hPrintNumBuffer + 2], a
inc de
ld a, [de]
- ldh [$ffb8], a
+ ldh [hPrintNumBuffer + 3], a
jr .start
.word
ld a, [de]
- ldh [$ffb7], a
+ ldh [hPrintNumBuffer + 2], a
inc de
ld a, [de]
- ldh [$ffb8], a
+ ldh [hPrintNumBuffer + 3], a
jr .start
.byte
ld a, [de]
- ldh [$ffb8], a
+ ldh [hPrintNumBuffer + 3], a
.start
push de
@@ -84,51 +83,51 @@ PrintNum::
.seven
ld a, HIGH(1000000 >> 8)
- ldh [$ffb9], a
+ ldh [hPrintNumBuffer + 4], a
ld a, HIGH(1000000) ; mid
- ldh [$ffba], a
+ ldh [hPrintNumBuffer + 5], a
ld a, LOW(1000000)
- ldh [$ffbb], a
+ ldh [hPrintNumBuffer + 6], a
call .PrintDigit
call .AdvancePointer
.six
ld a, HIGH(100000 >> 8)
- ldh [$ffb9], a
+ ldh [hPrintNumBuffer + 4], a
ld a, HIGH(100000) ; mid
- ldh [$ffba], a
+ ldh [hPrintNumBuffer + 5], a
ld a, LOW(100000)
- ldh [$ffbb], a
+ ldh [hPrintNumBuffer + 6], a
call .PrintDigit
call .AdvancePointer
.five
xor a ; HIGH(10000 >> 8)
- ldh [$ffb9], a
+ ldh [hPrintNumBuffer + 4], a
ld a, HIGH(10000) ; mid
- ldh [$ffba], a
+ ldh [hPrintNumBuffer + 5], a
ld a, LOW(10000)
- ldh [$ffbb], a
+ ldh [hPrintNumBuffer + 6], a
call .PrintDigit
call .AdvancePointer
.four
xor a ; HIGH(1000 >> 8)
- ldh [$ffb9], a
+ ldh [hPrintNumBuffer + 4], a
ld a, HIGH(1000) ; mid
- ldh [$ffba], a
+ ldh [hPrintNumBuffer + 5], a
ld a, LOW(1000)
- ldh [$ffbb], a
+ ldh [hPrintNumBuffer + 6], a
call .PrintDigit
call .AdvancePointer
.three
xor a ; HIGH(100 >> 8)
- ldh [$ffb9], a
+ ldh [hPrintNumBuffer + 4], a
xor a ; HIGH(100) ; mid
- ldh [$ffba], a
+ ldh [hPrintNumBuffer + 5], a
ld a, LOW(100)
- ldh [$ffbb], a
+ ldh [hPrintNumBuffer + 6], a
call .PrintDigit
call .AdvancePointer
@@ -136,22 +135,21 @@ PrintNum::
dec e
jr nz, .two_skip
ld a, "0"
- ldh [$ffb5], a
-
+ ldh [hPrintNumBuffer + 0], a
.two_skip
- ld c, 0
- ldh a, [$ffb8]
+ ld c, 0
+ ldh a, [hPrintNumBuffer + 3]
.mod_10
cp 10
jr c, .modded_10
sub 10
inc c
jr .mod_10
-
.modded_10
+
ld b, a
- ldh a, [$ffb5]
+ ldh a, [hPrintNumBuffer + 0]
or c
jr nz, .money
call .PrintLeadingZero
@@ -164,12 +162,12 @@ PrintNum::
add c
ld [hl], a
pop af
- ldh [$ffb5], a
+ ldh [hPrintNumBuffer + 0], a
inc e
dec e
jr nz, .money_leading_zero
inc hl
- ld [hl], $e8
+ ld [hl], "."
.money_leading_zero
call .AdvancePointer
@@ -184,7 +182,7 @@ PrintNum::
.PrintYen:
push af
- ldh a, [$ffb5]
+ ldh a, [hPrintNumBuffer + 0]
and a
jr nz, .stop
bit 5, d
@@ -201,68 +199,68 @@ PrintNum::
dec e
jr nz, .ok
ld a, "0"
- ldh [$ffb5], a
+ ldh [hPrintNumBuffer + 0], a
.ok
ld c, 0
.loop
- ldh a, [$ffb9]
+ ldh a, [hPrintNumBuffer + 4]
ld b, a
- ldh a, [$ffb6]
- ldh [$ffbc], a
+ ldh a, [hPrintNumBuffer + 1]
+ ldh [hPrintNumBuffer + 7], a
cp b
jr c, .skip1
sub b
- ldh [$ffb6], a
- ldh a, [$ffba]
+ ldh [hPrintNumBuffer + 1], a
+ ldh a, [hPrintNumBuffer + 5]
ld b, a
- ldh a, [$ffb7]
- ldh [$ffbd], a
+ ldh a, [hPrintNumBuffer + 2]
+ ldh [hPrintNumBuffer + 8], a
cp b
jr nc, .skip2
- ldh a, [$ffb6]
+ ldh a, [hPrintNumBuffer + 1]
or 0
jr z, .skip3
dec a
- ldh [$ffb6], a
- ldh a, [$ffb7]
+ ldh [hPrintNumBuffer + 1], a
+ ldh a, [hPrintNumBuffer + 2]
.skip2
sub b
- ldh [$ffb7], a
- ldh a, [$ffbb]
+ ldh [hPrintNumBuffer + 2], a
+ ldh a, [hPrintNumBuffer + 6]
ld b, a
- ldh a, [$ffb8]
- ldh [$ffbe], a
+ ldh a, [hPrintNumBuffer + 3]
+ ldh [hPrintNumBuffer + 9], a
cp b
jr nc, .skip4
- ldh a, [$ffb7]
+ ldh a, [hPrintNumBuffer + 2]
and a
jr nz, .skip5
- ldh a, [$ffb6]
+ ldh a, [hPrintNumBuffer + 1]
and a
jr z, .skip6
dec a
- ldh [$ffb6], a
+ ldh [hPrintNumBuffer + 1], a
xor a
.skip5
dec a
- ldh [$ffb7], a
- ldh a, [$ffb8]
+ ldh [hPrintNumBuffer + 2], a
+ ldh a, [hPrintNumBuffer + 3]
.skip4
sub b
- ldh [$ffb8], a
+ ldh [hPrintNumBuffer + 3], a
inc c
jr .loop
.skip6
- ldh a, [$ffbd]
- ldh [$ffb7], a
+ ldh a, [hPrintNumBuffer + 8]
+ ldh [hPrintNumBuffer + 2], a
.skip3
- ldh a, [$ffbc]
- ldh [$ffb6], a
+ ldh a, [hPrintNumBuffer + 7]
+ ldh [hPrintNumBuffer + 1], a
.skip1
- ldh a, [$ffb5]
+ ldh a, [hPrintNumBuffer + 0]
or c
jr z, .PrintLeadingZero
- ldh a, [$ffb5]
+ ldh a, [hPrintNumBuffer + 0]
and a
jr nz, .done
bit 5, d
@@ -274,12 +272,12 @@ PrintNum::
ld a, "0"
add c
ld [hl], a
- ldh [$ffb5], a
+ ldh [hPrintNumBuffer + 0], a
inc e
dec e
ret nz
inc hl
- ld [hl], $e8
+ ld [hl], "."
ret
.PrintLeadingZero:
@@ -296,7 +294,7 @@ PrintNum::
jr nz, .inc
bit 6, d ; left alignment or right alignment?
jr z, .inc
- ldh a, [$ffb5]
+ ldh a, [hPrintNumBuffer + 0]
and a
ret z
.inc
diff --git a/layout.link b/layout.link
index 2fb42996..d9a33677 100644
--- a/layout.link
+++ b/layout.link
@@ -159,7 +159,7 @@ ROMX $3f
ROMX $40
"Standard Scripts"
ROMX $41
- "bank41"
+ "Phone Scripts"
ROMX $42
"Map Scripts 1"
ROMX $43
diff --git a/main.asm b/main.asm
index dbf8b350..66eca040 100644
--- a/main.asm
+++ b/main.asm
@@ -194,83 +194,27 @@ INCLUDE "engine/pokemon/mail.asm"
SECTION "bank14", ROMX
-SelectMonFromParty::
- dr $50000, $5001d
-SelectTradeOrDayCareMon::
- dr $5001d, $5004f
-LoadPartyMenuGFX::
- dr $5004f, $5005f
-WritePartyMenuTilemap::
- dr $5005f, $50355
-InitPartyMenuGFX::
- dr $50355, $5037a
-InitPartyMenuWithCancel::
- dr $5037a, $503a2
-InitPartyMenuNoCancel::
- dr $503a2, $503cc
-PartyMenuSelect::
- dr $503cc, $5040f
-PrintPartyMenuText::
- dr $5040f, $504db
-PrintPartyMenuActionText::
- dr $504db, $5054f
-LoadFishingGFX::
- dr $5054f, $50610
-DoPoisonStep::
- dr $50610, $506f2
-SweetScentFromMenu::
- dr $506f2, $50763
-_Squirtbottle::
- dr $50763, $507ac
-_CardKey::
- dr $507ac, $507e7
-_BasementKey::
- dr $507e7, $50819
-_SacredAsh::
- dr $50819, $5087d
-CopyMonToTempMon::
- dr $5087d, $50940
-PrintMonTypes::
- dr $50940, $5096d
-PrintMoveType::
- dr $5096d, $50986
-PrintType::
- dr $50986, $50997
-GetTypeName::
- dr $50997, $50b3d
-DrawPlayerHP::
- dr $50b3d, $50b41
-DrawEnemyHP::
- dr $50b41, $50bae
-StatsScreenInit::
- dr $50bae, $5128f
-
-PrintTempMonStats::
- dr $5128f, $512f1
-GetGender::
- dr $512f1, $51364
-ListMovePP::
- dr $51364, $513e4
-Unused_PlaceEnemyHPLevel::
- dr $513e4, $51437
-PlaceNonFaintStatus::
- dr $51437, $51478
-ListMoves::
- dr $51478, $514c2
-InitList::
- dr $514c2, $51524
-CalcLevel::
- dr $51524, $51550
-CalcExpAtLevel::
- dr $51550, $5161b
-_SwitchPartyMons::
- dr $5161b, $51749
+
+INCLUDE "engine/pokemon/party_menu.asm"
+INCLUDE "engine/events/fishing_gfx.asm"
+INCLUDE "engine/events/poisonstep.asm"
+INCLUDE "engine/events/sweet_scent.asm"
+INCLUDE "engine/events/squirtbottle.asm"
+INCLUDE "engine/events/card_key.asm"
+INCLUDE "engine/events/basement_key.asm"
+INCLUDE "engine/events/sacred_ash.asm"
+INCLUDE "engine/pokemon/tempmon.asm"
+INCLUDE "engine/pokemon/types.asm"
+INCLUDE "engine/battle/unreferenced_getgen1trainerclassname.asm"
+INCLUDE "engine/pokemon/mon_stats.asm"
+INCLUDE "engine/link/init_list.asm"
+INCLUDE "engine/pokemon/experience.asm"
+INCLUDE "engine/pokemon/switchpartymons.asm"
INCLUDE "engine/gfx/load_pics.asm"
INCLUDE "engine/pokemon/move_mon_wo_mail.asm"
INCLUDE "data/pokemon/base_stats.asm"
+INCLUDE "data/pokemon/unused_pic_banks.asm"
-Unknown53a6b::
- dr $53a6b, $53a83
EggPic::
INCBIN "gfx/pokemon/egg/front.2bpp.lz"
@@ -514,8 +458,10 @@ _DepositPKMN::
_WithdrawPKMN::
dr $e2d71, $e2f47
_MovePKMNWithoutMail::
- dr $e2f47, $e3d25
+ dr $e2f47, $e3773
+StatsScreenDPad::
+ dr $e3773, $e3d25
_ChangeBox::
dr $e3d25, $e3f74
@@ -565,7 +511,9 @@ _LoadFontsBattleExtra::
LoadBattleFontsHPBar::
dr $f8066, $f8081
LoadHPBar::
- dr $f8081, $f80d9
+ dr $f8081, $f80a6
+StatsScreen_LoadFont::
+ dr $f80a6, $f80d9
LoadStatsScreenPageTilesGFX::
dr $f80d9, $f8aa2
StatsScreenPageTilesGFX::
@@ -647,137 +595,20 @@ INCLUDE "data/text/std_text.asm"
INCLUDE "data/text/battle.asm"
-SECTION "bank41", ROMX
-
-; Phone scripts and text
-UnusedPhoneScript::
- dr $104000, $104004
-MomPhoneCalleeScript::
- dr $104004, $104124
-MomPhoneLectureScript::
- dr $104124, $104137
-BillPhoneCalleeScript::
- dr $104137, $104172
-BillPhoneCallerScript::
- dr $104172, $104177
-ElmPhoneCalleeScript::
- dr $104177, $1041e1
-ElmPhoneCallerScript::
- dr $1041e1, $10422a
-JackPhoneCalleeScript::
- dr $10422a, $104234
-JackPhoneCallerScript::
- dr $104234, $104256
-BeverlyPhoneCalleeScript::
- dr $104256, $104260
-BeverlyPhoneCallerScript::
- dr $104260, $104282
-HueyPhoneCalleeScript::
- dr $104282, $10428c
-HueyPhoneCallerScript::
- dr $10428c, $1042a7
-GavenPhoneCalleeScript::
- dr $1042a7, $1042b1
-GavenPhoneCallerScript::
- dr $1042b1, $1042d3
-BethPhoneCalleeScript::
- dr $1042d3, $1042dd
-BethPhoneCallerScript::
- dr $1042dd, $1042ff
-JosePhoneCalleeScript::
- dr $1042ff, $104309
-JosePhoneCallerScript::
- dr $104309, $104332
-ReenaPhoneCalleeScript::
- dr $104332, $10433c
-ReenaPhoneCallerScript::
- dr $10433c, $10435e
-JoeyPhoneCalleeScript::
- dr $10435e, $104368
-JoeyPhoneCallerScript::
- dr $104368, $104390
-WadePhoneCalleeScript::
- dr $104390, $1043b5
-WadePhoneCallerScript::
- dr $1043b5, $1043f8
-RalphPhoneCalleeScript::
- dr $1043f8, $104402
-RalphPhoneCallerScript::
- dr $104402, $104446
-LizPhoneCalleeScript::
- dr $104446, $104450
-LizPhoneCallerScript::
- dr $104450, $104478
-AnthonyPhoneCalleeScript::
- dr $104478, $104482
-AnthonyPhoneCallerScript::
- dr $104482, $1044c4
-ToddPhoneCalleeScript::
- dr $1044c4, $1044ce
-ToddPhoneCallerScript::
- dr $1044ce, $1044f6
-GinaPhoneCalleeScript::
- dr $1044f6, $104506
-GinaPhoneCallerScript::
- dr $104506, $104534
-IrwinPhoneCalleeScript::
- dr $104534, $104544
-IrwinPhoneCallerScript::
- dr $104544, $10456c
-ArniePhoneCalleeScript::
- dr $10456c, $104576
-ArniePhoneCallerScript::
- dr $104576, $1045b2
-AlanPhoneCalleeScript::
- dr $1045b2, $1045bc
-AlanPhoneCallerScript::
- dr $1045bc, $1045de
-DanaPhoneCalleeScript::
- dr $1045de, $1045e8
-DanaPhoneCallerScript::
- dr $1045e8, $10460a
-ChadPhoneCalleeScript::
- dr $10460a, $104614
-ChadPhoneCallerScript::
- dr $104614, $104650
-DerekPhoneCalleeScript::
- dr $104650, $104675
-DerekPhoneCallerScript::
- dr $104675, $1046b2
-ChrisPhoneCalleeScript::
- dr $1046b2, $1046bc
-ChrisPhoneCallerScript::
- dr $1046bc, $1046de
-BrentPhoneCalleeScript::
- dr $1046de, $1046e8
-BrentPhoneCallerScript::
- dr $1046e8, $104711
-TiffanyPhoneCalleeScript::
- dr $104711, $10471b
-TiffanyPhoneCallerScript::
- dr $10471b, $104744
-VancePhoneCalleeScript::
- dr $104744, $10474e
-VancePhoneCallerScript::
- dr $10474e, $104770
-WiltonPhoneCalleeScript::
- dr $104770, $10477a
-WiltonPhoneCallerScript::
- dr $10477a, $1047b8
-KenjiPhoneCalleeScript::
- dr $1047b8, $1047c2
-KenjiPhoneCallerScript::
- dr $1047c2, $1047e4
-ParryPhoneCalleeScript::
- dr $1047e4, $1047ee
-ParryPhoneCallerScript::
- dr $1047ee, $10482a
-ErinPhoneCalleeScript::
- dr $10482a, $104834
-ErinPhoneCallerScript::
- dr $104834, $104a80
-BikeShopPhoneCallerScript::
- dr $104a80, $10614d
+SECTION "Phone Scripts", ROMX
+
+INCLUDE "engine/phone/scripts/unused.asm"
+INCLUDE "engine/phone/scripts/mom.asm"
+INCLUDE "engine/phone/scripts/bill.asm"
+INCLUDE "engine/phone/scripts/elm.asm"
+INCLUDE "engine/phone/scripts/trainers.asm"
+INCLUDE "engine/phone/scripts/bike_shop.asm"
+INCLUDE "data/phone/text/unused.asm"
+INCLUDE "data/phone/text/mom.asm"
+INCLUDE "data/phone/text/bill.asm"
+INCLUDE "data/phone/text/elm.asm"
+INCLUDE "data/phone/text/trainers.asm"
+INCLUDE "data/phone/text/bike_shop.asm"
SECTION "Names", ROMX
diff --git a/wram.asm b/wram.asm
index f8518028..8d64f3c5 100644
--- a/wram.asm
+++ b/wram.asm
@@ -1568,15 +1568,14 @@ wMailboxItems:: ds MAILBOX_CAPACITY
wMailboxEnd::
ENDU ; cffc
-wcffc:: ds 1 ; cffc
-wcffd:: ds 1 ; cffd
+wListPointer:: dw ; cffc
wUnusedCFFE:: dw ; cffe
SECTION "WRAM 1", WRAMX
-wd000:: ds 1 ; d000
-wd001:: ds 1 ; d001
+wItemAttributesPtr:: dw ; d000
+
wCurItem:: db ; d002
wCurItemQuantity:: ; d003
wMartItemID::