summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--constants/event_flags.asm48
-rwxr-xr-xdata/items/fruit_trees.asm32
-rw-r--r--data/text/std_text.asm422
-rwxr-xr-xengine/battle/start_battle.asm144
-rwxr-xr-xengine/events/fruit_trees.asm116
-rw-r--r--engine/events/std_scripts.asm774
-rwxr-xr-xengine/gfx/place_graphic.asm55
-rwxr-xr-xengine/pokemon/mail.asm565
-rw-r--r--gfx/pokedex/pokedex.2bppbin928 -> 0 bytes
-rw-r--r--gfx/pokedex/slowpoke.2bppbin880 -> 0 bytes
-rw-r--r--layout.link2
-rw-r--r--main.asm34
-rw-r--r--wram.asm22
14 files changed, 2150 insertions, 66 deletions
diff --git a/.gitignore b/.gitignore
index f7289199..7b6a70e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,3 +56,5 @@ gfx/player/chris_back.2bpp
gfx/trade/game_boy.2bpp
gfx/pokegear/pokegear_sprites.2bpp
gfx/slots/slots_*.2bpp
+gfx/pokedex/pokedex.2bpp
+gfx/pokedex/slowpoke.2bpp
diff --git a/constants/event_flags.asm b/constants/event_flags.asm
index 8e18ffe7..bb1476b1 100644
--- a/constants/event_flags.asm
+++ b/constants/event_flags.asm
@@ -621,7 +621,7 @@
const EVENT_GAVE_KURT_PNK_APRICORN
; Phone events
const EVENT_JACK_ASKED_FOR_PHONE_NUMBER
- const EVENT_JACK_READY_FOR_REMATCH ; 0260
+ const EVENT_JACK_READY_FOR_REMATCH ; 260
const EVENT_BEVERLY_ASKED_FOR_PHONE_NUMBER
const EVENT_BEVERLY_READY_FOR_REMATCH
const EVENT_HUEY_ASKED_FOR_PHONE_NUMBER
@@ -637,7 +637,7 @@
const EVENT_BETH_ASKED_FOR_PHONE_NUMBER
const EVENT_BETH_READY_FOR_REMATCH
const EVENT_JOSE_ASKED_FOR_PHONE_NUMBER
- const EVENT_JOSE_READY_FOR_REMATCH ; 0270
+ const EVENT_JOSE_READY_FOR_REMATCH ; 270
const EVENT_REENA_ASKED_FOR_PHONE_NUMBER
const EVENT_REENA_READY_FOR_REMATCH
const EVENT_JOEY_ASKED_FOR_PHONE_NUMBER
@@ -1669,7 +1669,7 @@
; The map script command macros `disappear` and `appear` set/clear these flags and immediately apply the effect on visibility.
; The map script command macros `setevent` and `clearevent` set/clear these flags, and their effects will be seen when the map is reloaded.
; Johto itemballs
- const EVENT_CYNDAQUIL_POKEBALL_IN_ELMS_LAB
+ const EVENT_CYNDAQUIL_POKEBALL_IN_ELMS_LAB ; 640
const EVENT_TOTODILE_POKEBALL_IN_ELMS_LAB
const EVENT_CHIKORITA_POKEBALL_IN_ELMS_LAB
const EVENT_VIOLET_CITY_PP_UP
@@ -1685,7 +1685,7 @@
const EVENT_TIN_TOWER_4F_PP_UP
const EVENT_TIN_TOWER_4F_ESCAPE_ROPE
const EVENT_TIN_TOWER_5F_RARE_CANDY
- const EVENT_TIN_TOWER_7F_MAX_REVIVE
+ const EVENT_TIN_TOWER_7F_MAX_REVIVE ; 650
const EVENT_TIN_TOWER_8F_NUGGET
const EVENT_TIN_TOWER_8F_MAX_ELIXER
const EVENT_TIN_TOWER_8F_FULL_RESTORE
@@ -1701,7 +1701,7 @@
const EVENT_UNION_CAVE_1F_AWAKENING
const EVENT_UNION_CAVE_B1F_TM_SWIFT
const EVENT_UNION_CAVE_B1F_X_DEFEND
- const EVENT_UNION_CAVE_B2F_ELIXER
+ const EVENT_UNION_CAVE_B2F_ELIXER ; 660
const EVENT_UNION_CAVE_B2F_HYPER_POTION
const EVENT_SLOWPOKE_WELL_B1F_SUPER_POTION
const EVENT_SLOWPOKE_WELL_B2F_TM_RAIN_DANCE
@@ -1717,7 +1717,7 @@
const EVENT_TEAM_ROCKET_BASE_B3F_FULL_HEAL
const EVENT_TEAM_ROCKET_BASE_B3F_DIRE_HIT
const EVENT_TEAM_ROCKET_BASE_B3F_PROTEIN
- const EVENT_TEAM_ROCKET_BASE_B3F_ICE_HEAL
+ const EVENT_TEAM_ROCKET_BASE_B3F_ICE_HEAL ; 670
const EVENT_ILEX_FOREST_REVIVE
const EVENT_GOLDENROD_UNDERGROUND_COIN_CASE
const EVENT_GOLDENROD_UNDERGROUND_SWITCH_ROOM_ENTRANCES_SMOKE_BALL
@@ -1733,7 +1733,7 @@
const EVENT_MOUNT_MORTAR_1F_INSIDE_ESCAPE_ROPE
const EVENT_MOUNT_MORTAR_1F_INSIDE_MAX_REVIVE
const EVENT_MOUNT_MORTAR_1F_INSIDE_HYPER_POTION
- const EVENT_MOUNT_MORTAR_2F_INSIDE_MAX_POTION
+ const EVENT_MOUNT_MORTAR_2F_INSIDE_MAX_POTION ; 680
const EVENT_MOUNT_MORTAR_2F_INSIDE_RARE_CANDY
const EVENT_MOUNT_MORTAR_2F_INSIDE_TM_DEFENSE_CURL
const EVENT_MOUNT_MORTAR_2F_INSIDE_DRAGON_SCALE
@@ -1749,7 +1749,7 @@
const EVENT_ICE_PATH_B2F_BLACKTHORN_SIDE_TM_REST
const EVENT_ICE_PATH_B3F_NEVERMELTICE
const EVENT_WHIRL_ISLAND_NE_ULTRA_BALL
- const EVENT_WHIRL_ISLAND_SW_GUARD_SPEC
+ const EVENT_WHIRL_ISLAND_SW_GUARD_SPEC ; 690
const EVENT_WHIRL_ISLAND_B1F_FULL_RESTORE
const EVENT_WHIRL_ISLAND_B1F_CARBOS
const EVENT_WHIRL_ISLAND_B1F_CALCIUM
@@ -1765,7 +1765,7 @@
const EVENT_SILVER_CAVE_ITEM_ROOMS_FULL_RESTORE
const EVENT_DARK_CAVE_VIOLET_ENTRANCE_POTION
const EVENT_DARK_CAVE_VIOLET_ENTRANCE_FULL_HEAL
- const EVENT_DARK_CAVE_VIOLET_ENTRANCE_HYPER_POTION
+ const EVENT_DARK_CAVE_VIOLET_ENTRANCE_HYPER_POTION ; 6a0
const EVENT_DARK_CAVE_BLACKTHORN_ENTRANCE_REVIVE
const EVENT_DARK_CAVE_BLACKTHORN_ENTRANCE_TM_SNORE
const EVENT_VICTORY_ROAD_TM_EARTHQUAKE
@@ -1781,7 +1781,7 @@
const EVENT_ROUTE_29_POTION
const EVENT_ROUTE_31_ANTIDOTE
const EVENT_ROUTE_31_POKE_BALL
- const EVENT_ROUTE_32_GREAT_BALL
+ const EVENT_ROUTE_32_GREAT_BALL ; 6b0
const EVENT_ROUTE_32_POTION
const EVENT_ROUTE_35_TM_ROLLOUT
const EVENT_ROUTE_42_ULTRA_BALL
@@ -1798,7 +1798,7 @@
const EVENT_RIVAL_NEW_BARK_TOWN
const EVENT_RIVAL_CHERRYGROVE_CITY
const EVENT_RIVAL_AZALEA_TOWN
- const EVENT_RIVAL_TEAM_ROCKET_BASE
+ const EVENT_RIVAL_TEAM_ROCKET_BASE ; 6c0
const EVENT_RIVAL_GOLDENROD_UNDERGROUND
const EVENT_RIVAL_VICTORY_ROAD
const EVENT_RIVAL_OLIVINE_CITY
@@ -1814,7 +1814,7 @@
const EVENT_GOLDENROD_CITY_ROCKET_TAKEOVER
const EVENT_RADIO_TOWER_ROCKET_TAKEOVER
const EVENT_GOLDENROD_CITY_CIVILIANS
- const EVENT_RADIO_TOWER_CIVILIANS_AFTER
+ const EVENT_RADIO_TOWER_CIVILIANS_AFTER ; 6d0
const EVENT_RADIO_TOWER_BLACKBELT_BLOCKS_STAIRS
const EVENT_OLIVINE_LIGHTHOUSE_JASMINE
const EVENT_OLIVINE_GYM_JASMINE
@@ -1830,7 +1830,7 @@
const EVENT_TEAM_ROCKET_BASE_B2F_EXECUTIVE
const EVENT_TEAM_ROCKET_BASE_B2F_GRUNT_WITH_EXECUTIVE
const EVENT_TEAM_ROCKET_BASE_B2F_DRAGONITE
- const EVENT_TEAM_ROCKET_BASE_B2F_ELECTRODE_1
+ const EVENT_TEAM_ROCKET_BASE_B2F_ELECTRODE_1 ; 6e0
const EVENT_TEAM_ROCKET_BASE_B2F_ELECTRODE_2
const EVENT_TEAM_ROCKET_BASE_B2F_ELECTRODE_3
const EVENT_BLACKTHORN_CITY_SUPER_NERD_BLOCKS_GYM
@@ -1846,7 +1846,7 @@
const EVENT_ILEX_FOREST_FARFETCHD5
const EVENT_ILEX_FOREST_FARFETCHD6
const EVENT_ILEX_FOREST_FARFETCHD7
- const EVENT_ILEX_FOREST_FARFETCHD8
+ const EVENT_ILEX_FOREST_FARFETCHD8 ; 6f0
const EVENT_ILEX_FOREST_FARFETCHD9
const EVENT_ILEX_FOREST_FARFETCHD10
const EVENT_ILEX_FOREST_APPRENTICE
@@ -1862,7 +1862,7 @@
const EVENT_KURTS_HOUSE_SLOWPOKE
const EVENT_GUIDE_GENT_IN_HIS_HOUSE
const EVENT_GUIDE_GENT_VISIBLE_IN_CHERRYGROVE
- const EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER
+ const EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER ; 700
const EVENT_ELMS_AIDE_IN_LAB
const EVENT_COP_IN_ELMS_LAB
const EVENT_RUINS_OF_ALPH_OUTSIDE_SCIENTIST
@@ -1878,7 +1878,7 @@
const EVENT_BOULDER_IN_ICE_PATH_1A
const EVENT_BOULDER_IN_ICE_PATH_2A
const EVENT_BOULDER_IN_ICE_PATH_3A
- const EVENT_BOULDER_IN_ICE_PATH_4A
+ const EVENT_BOULDER_IN_ICE_PATH_4A ; 710
const EVENT_MYSTERY_GIFT_DELIVERY_GUY
const EVENT_MET_BILL
const EVENT_ECRUTEAK_POKE_CENTER_BILL
@@ -1894,7 +1894,7 @@
const EVENT_BUG_CATCHING_CONTESTANT_8A
const EVENT_BUG_CATCHING_CONTESTANT_9A
const EVENT_BUG_CATCHING_CONTESTANT_10A
- const EVENT_BUG_CATCHING_CONTESTANT_1B
+ const EVENT_BUG_CATCHING_CONTESTANT_1B ; 720
const EVENT_BUG_CATCHING_CONTESTANT_2B
const EVENT_BUG_CATCHING_CONTESTANT_3B
const EVENT_BUG_CATCHING_CONTESTANT_4B
@@ -1910,7 +1910,7 @@
const EVENT_FAST_SHIP_CABINS_NNW_NNE_NE_SAILOR
const EVENT_FAST_SHIP_B1F_SAILOR_LEFT
const EVENT_FAST_SHIP_B1F_SAILOR_RIGHT
- const EVENT_FAST_SHIP_CABINS_SE_SSE_GENTLEMAN
+ const EVENT_FAST_SHIP_CABINS_SE_SSE_GENTLEMAN ; 730
const EVENT_FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN_TWIN_1
const EVENT_FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN_TWIN_2
const EVENT_OLIVINE_PORT_PASSAGE_POKEFAN_M
@@ -1964,12 +1964,12 @@
const EVENT_GOLDENROD_DEPT_STORE_5F_HAPPINESS_EVENT_LADY
const EVENT_BURNED_TOWER_FIREBREATHER_DICK_NORMAL
const EVENT_BURNED_TOWER_FIREBREATHER_DICK_ASHES
- const EVENT_RANG_CLEAR_BELL_1
- const EVENT_RANG_CLEAR_BELL_2
- const EVENT_FLORIA_AT_FLOWER_SHOP
- const EVENT_FLORIA_AT_SUDOWOODO
- const EVENT_GOLDENROD_CITY_MOVE_TUTOR
- const EVENT_GOLDENROD_GAME_CORNER_MOVE_TUTOR
+ const EVENT_RANG_CLEAR_BELL_1 ; rename?
+ const EVENT_RANG_CLEAR_BELL_2 ; rename?
+ const EVENT_FLORIA_AT_FLOWER_SHOP ; rename?
+ const EVENT_FLORIA_AT_SUDOWOODO ; rename?
+ const EVENT_GOLDENROD_CITY_MOVE_TUTOR ; rename?
+ const EVENT_GOLDENROD_GAME_CORNER_MOVE_TUTOR ; rename?
; Kanto people
const EVENT_ROUTE_24_ROCKET
const EVENT_CERULEAN_GYM_ROCKET
diff --git a/data/items/fruit_trees.asm b/data/items/fruit_trees.asm
new file mode 100755
index 00000000..9c4e4793
--- /dev/null
+++ b/data/items/fruit_trees.asm
@@ -0,0 +1,32 @@
+FruitTreeItems:
+; entries correspond to FRUITTREE_* constants
+ db BERRY ; ROUTE_29
+ db BERRY ; ROUTE_30_1
+ db BERRY ; ROUTE_38
+ db BERRY ; ROUTE_46_1
+ db PSNCUREBERRY ; ROUTE_30_2
+ db PSNCUREBERRY ; ROUTE_33
+ db BITTER_BERRY ; ROUTE_31
+ db BITTER_BERRY ; ROUTE_43
+ db PRZCUREBERRY ; VIOLET_CITY
+ db PRZCUREBERRY ; ROUTE_46_2
+ db MYSTERYBERRY ; ROUTE_35
+ db MYSTERYBERRY ; ROUTE_45
+ db ICE_BERRY ; ROUTE_36
+ db ICE_BERRY ; ROUTE_26
+ db MINT_BERRY ; ROUTE_39
+ db BURNT_BERRY ; ROUTE_44
+ db RED_APRICORN ; ROUTE_37_1
+ db BLU_APRICORN ; ROUTE_37_2
+ db BLK_APRICORN ; ROUTE_37_3
+ db WHT_APRICORN ; AZALEA_TOWN
+ db PNK_APRICORN ; ROUTE_42_1
+ db GRN_APRICORN ; ROUTE_42_2
+ db YLW_APRICORN ; ROUTE_42_3
+ db BERRY ; ROUTE_11
+ db PSNCUREBERRY ; ROUTE_2
+ db BITTER_BERRY ; ROUTE_1
+ db PRZCUREBERRY ; ROUTE_8
+ db ICE_BERRY ; PEWTER_CITY_1
+ db MINT_BERRY ; PEWTER_CITY_2
+ db BURNT_BERRY ; FUCHSIA_CITY
diff --git a/data/text/std_text.asm b/data/text/std_text.asm
new file mode 100644
index 00000000..4c57e2e6
--- /dev/null
+++ b/data/text/std_text.asm
@@ -0,0 +1,422 @@
+NurseMornText:
+ text "Good morning!"
+ line "Welcome to our"
+ cont "#MON CENTER."
+ done
+
+NurseDayText:
+ text "Hello!"
+ line "Welcome to our"
+ cont "#MON CENTER."
+ done
+
+NurseNiteText:
+ text "Good evening!"
+ line "You're out late."
+
+ para "Welcome to our"
+ line "#MON CENTER."
+ done
+
+NurseAskHealText:
+ text "We can heal your"
+ line "#MON to perfect"
+ cont "health."
+
+ para "Shall we heal your"
+ line "#MON?"
+ done
+
+NurseTakePokemonText:
+ text "OK, may I see your"
+ line "#MON?"
+ done
+
+NurseReturnPokemonText:
+ text "Thank you for"
+ line "waiting."
+
+ para "Your #MON are"
+ line "fully healed."
+ done
+
+NurseGoodbyeText:
+ text "We hope to see you"
+ line "again."
+ done
+
+; not used
+ text "We hope to see you"
+ line "again."
+ done
+
+NursePokerusText:
+ text "Your #MON ap-"
+ line "pear to have tiny"
+
+ para "life forms stuck"
+ line "to them."
+
+ para "Your #MON are"
+ line "healthy and seem"
+ cont "to be fine."
+
+ para "But we can't tell"
+ line "you anything more"
+
+ para "at a #MON"
+ line "CENTER."
+ done
+
+DifficultBookshelfText:
+ text "It's full of"
+ line "difficult books."
+ done
+
+PictureBookshelfText:
+ text "A whole collection"
+ line "of #MON picture"
+ cont "books!"
+ done
+
+MagazineBookshelfText:
+ text "#MON magazines…"
+ line "#MON PAL,"
+
+ para "#MON HANDBOOK,"
+ line "#MON GRAPH…"
+ done
+
+TeamRocketOathText:
+ text "TEAM ROCKET OATH"
+
+ para "Steal #MON for"
+ line "profit!"
+
+ para "Exploit #MON"
+ line "for profit!"
+
+ para "All #MON exist"
+ line "for the glory of"
+ cont "TEAM ROCKET!"
+ done
+
+IncenseBurnerText:
+ text "What is this?"
+
+ para "Oh, it's an"
+ line "incense burner!"
+ done
+
+MerchandiseShelfText:
+ text "Lots of #MON"
+ line "merchandise!"
+ done
+
+LookTownMapText:
+ text "It's the TOWN MAP."
+ done
+
+WindowText:
+ text "My reflection!"
+ line "Lookin' good!"
+ done
+
+TVText:
+ text "It's a TV."
+ done
+
+HomepageText:
+ text "#MON JOURNAL"
+ line "HOME PAGE…"
+
+ para "It hasn't been"
+ line "updated…"
+ done
+
+; not used
+ text "#MON RADIO!"
+
+ para "Call in with your"
+ line "requests now!"
+ done
+
+TrashCanText:
+ text "There's nothing in"
+ line "here…"
+ done
+
+; not used
+ text "A #MON may be"
+ line "able to move this."
+ done
+
+; not used
+ text "Maybe a #MON"
+ line "can break this."
+ done
+
+PokecenterSignText:
+ text "Heal Your #MON!"
+ line "#MON CENTER"
+ done
+
+MartSignText:
+ text "For All Your"
+ line "#MON Needs"
+
+ para "#MON MART"
+ done
+
+ContestResults_ReadyToJudgeText:
+ text "We will now judge"
+ line "the #MON you've"
+ cont "caught."
+
+ para "<……>"
+ line "<……>"
+
+ para "We have chosen the"
+ line "winners!"
+
+ para "Are you ready for"
+ line "this?"
+ done
+
+AskNumber1MText:
+ text "Wow! You're pretty"
+ line "tough."
+
+ para "Could I get your"
+ line "phone number?"
+
+ para "I'll call you for"
+ line "a rematch."
+ done
+
+AskNumber2MText:
+ text "Register the phone"
+ line "number?"
+ done
+
+RegisteredNumberMText:
+ text "<PLAYER> registered"
+ line "@"
+ text_ram wStringBuffer3
+ text "'s number."
+ done
+
+NumberAcceptedMText:
+ text "I'll call you if"
+ line "anything comes up."
+ done
+
+NumberDeclinedMText:
+ text "Oh, OK…"
+ line "Just talk to me if"
+
+ para "you want to get my"
+ line "phone number."
+ done
+
+PhoneFullMText:
+ text "Your phone doesn't"
+ line "have enough memory"
+ cont "for more numbers."
+ done
+
+RematchMText:
+ text "I was waiting for"
+ line "you. Let's battle!"
+ done
+
+AskNumber1FText:
+ text "Wow, you're good"
+ line "at battling."
+
+ para "Want to give me"
+ line "your phone number?"
+
+ para "I'll phone you for"
+ line "another battle."
+ done
+
+AskNumber2FText:
+ text "Register the phone"
+ line "number?"
+ done
+
+RegisteredNumberFText:
+ text "<PLAYER> registered"
+ line "@"
+ text_ram wStringBuffer3
+ text "'s number."
+ done
+
+NumberAcceptedFText:
+ text "I'll call you if"
+ line "something's up."
+ done
+
+NumberDeclinedFText:
+ text "Oh, fine then…"
+ line "If you want to get"
+
+ para "my phone number,"
+ line "just tell me."
+ done
+
+PhoneFullFText:
+ text "Your phone doesn't"
+ line "have enough memory"
+ cont "for more numbers."
+ done
+
+RematchFText:
+ text "I waited for you."
+ line "Let's battle!"
+ done
+
+ContestResults_PlayerWonAPrizeText:
+ text "<PLAYER> wins the"
+ line "No. @"
+ text_ram wStringBuffer3
+ text " prize,"
+ cont "a @"
+ text_ram wStringBuffer4
+ text "!"
+ done
+
+ReceivedItemText:
+ text "<PLAYER> received"
+ line "@"
+ text_ram wStringBuffer4
+ text "."
+ done
+
+ContestResults_JoinUsNextTimeText:
+ text "Please join us for"
+ line "the next Contest!"
+ done
+
+ContestResults_ConsolationPrizeText:
+ text "Everyone else gets"
+ line "a BERRY as a con-"
+ cont "solation prize!"
+ done
+
+ContestResults_DidNotWinText:
+ text "We hope you do"
+ line "better next time."
+ done
+
+ContestResults_ReturnPartyText:
+ text "We'll return the"
+ line "#MON we kept"
+
+ para "for you."
+ line "Here you go!"
+ done
+
+ContestResults_PartyFullText:
+ text "Your party's full,"
+ line "so the #MON was"
+
+ para "sent to your BOX"
+ line "in BILL's PC."
+ done
+
+GymStatue_CityGymText:
+ text_ram wStringBuffer3
+ text_start
+ line "#MON GYM"
+ done
+
+GymStatue_WinningTrainersText:
+ text "LEADER: @"
+ text_ram wStringBuffer4
+ text_start
+ para "WINNING TRAINERS:"
+ line "<PLAYER>"
+ done
+
+CoinVendor_WelcomeText:
+ text "Welcome to the"
+ line "GAME CORNER."
+ done
+
+CoinVendor_NoCoinCaseText:
+ text "Do you need game"
+ line "coins?"
+
+ para "Oh, you don't have"
+ line "a COIN CASE for"
+ cont "your coins."
+ done
+
+CoinVendor_IntroText:
+ text "Do you need some"
+ line "game coins?"
+
+ para "It costs ¥1000 for"
+ line "50 coins. Do you"
+ cont "want some?"
+ done
+
+CoinVendor_Buy50CoinsText:
+ text "Thank you!"
+ line "Here are 50 coins."
+ done
+
+CoinVendor_Buy500CoinsText:
+ text "Thank you! Here"
+ line "are 500 coins."
+ done
+
+CoinVendor_NotEnoughMoneyText:
+ text "You don't have"
+ line "enough money."
+ done
+
+CoinVendor_CoinCaseFullText:
+ text "Whoops! Your COIN"
+ line "CASE is full."
+ done
+
+CoinVendor_CancelText:
+ text "No coins for you?"
+ line "Come again!"
+ done
+
+BugContestPrizeNoRoomText:
+ text "Oh? Your PACK is"
+ line "full."
+
+ para "We'll keep this"
+ line "for you today, so"
+
+ para "come back when you"
+ line "make room for it."
+ done
+
+HappinessText3:
+ text "Wow! You and your"
+ line "#MON are really"
+ cont "close!"
+ done
+
+HappinessText2:
+ text "#MON get more"
+ line "friendly if you"
+
+ para "spend time with"
+ line "them."
+ done
+
+HappinessText1:
+ text "You haven't tamed"
+ line "your #MON."
+
+ para "If you aren't"
+ line "nice, it'll pout."
+ done
diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm
new file mode 100755
index 00000000..7627a100
--- /dev/null
+++ b/engine/battle/start_battle.asm
@@ -0,0 +1,144 @@
+PlayBattleMusic:
+ push hl
+ push de
+ push bc
+
+ xor a
+ ld [wMusicFade], a
+ ld de, MUSIC_NONE
+ call PlayMusic
+ call DelayFrame
+ call MaxVolume
+
+ ; Are we fighting a trainer?
+ ld a, [wOtherTrainerClass]
+ and a
+ jr nz, .trainermusic
+
+ farcall RegionCheck
+ ld a, e
+ and a
+ jr nz, .kantowild
+
+ ld de, MUSIC_JOHTO_WILD_BATTLE
+ ld a, [wTimeOfDay]
+ cp NITE_F
+ jr nz, .done
+ ld de, MUSIC_JOHTO_WILD_BATTLE_NIGHT
+ jr .done
+
+.kantowild
+ ld de, MUSIC_KANTO_WILD_BATTLE
+ jr .done
+
+.trainermusic
+ ld de, MUSIC_CHAMPION_BATTLE
+ cp CHAMPION
+ jr z, .done
+ cp RED
+ jr z, .done
+
+ ; They should have included EXECUTIVEM, EXECUTIVEF, and SCIENTIST too...
+ ld de, MUSIC_ROCKET_BATTLE
+ cp GRUNTM
+ jr z, .done
+ cp GRUNTF
+ jr z, .done
+
+ ld de, MUSIC_KANTO_GYM_LEADER_BATTLE
+ farcall IsKantoGymLeader
+ jr c, .done
+
+ ; IsGymLeader also counts CHAMPION, RED, and the Kanto gym leaders
+ ; but they have been taken care of before this
+ ld de, MUSIC_JOHTO_GYM_LEADER_BATTLE
+ farcall IsGymLeader
+ jr c, .done
+
+ ld de, MUSIC_RIVAL_BATTLE
+ ld a, [wOtherTrainerClass]
+ cp RIVAL1
+ jr z, .done
+ cp RIVAL2
+ jr nz, .othertrainer
+
+ ld a, [wOtherTrainerID]
+ cp RIVAL2_2_CHIKORITA ; Rival in Indigo Plateau
+ jr c, .done
+ ld de, MUSIC_CHAMPION_BATTLE
+ jr .done
+
+.othertrainer
+ ld a, [wLinkMode]
+ and a
+ jr nz, .johtotrainer
+
+ farcall RegionCheck
+ ld a, e
+ and a
+ jr nz, .kantotrainer
+
+.johtotrainer
+ ld de, MUSIC_JOHTO_TRAINER_BATTLE
+ jr .done
+
+.kantotrainer
+ ld de, MUSIC_KANTO_TRAINER_BATTLE
+
+.done
+ call PlayMusic
+
+ pop bc
+ pop de
+ pop hl
+ ret
+
+ClearBattleRAM:
+ xor a
+ ld [wBattlePlayerAction], a
+ ld [wBattleResult], a
+
+ ld hl, wPartyMenuCursor
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+
+ ld [wMenuScrollPosition], a
+ ld [wCriticalHit], a
+ ld [wBattleMonSpecies], a
+ ld [wBattleParticipantsNotFainted], a
+ ld [wCurBattleMon], a
+ ld [wForcedSwitch], a
+ ld [wTimeOfDayPal], a
+ ld [wPlayerTurnsTaken], a
+ ld [wEnemyTurnsTaken], a
+ ld [wEvolvableFlags], a
+
+ ld hl, wPlayerHPPal
+ ld [hli], a
+ ld [hl], a
+
+ ld hl, wBattleMonDVs
+ ld [hli], a
+ ld [hl], a
+
+ ld hl, wEnemyMonDVs
+ ld [hli], a
+ ld [hl], a
+
+; Clear the entire BattleMons area
+ ld hl, wBattle
+ ld bc, wBattleEnd - wBattle
+ xor a
+ call ByteFill
+
+ callfar ResetEnemyStatLevels
+
+ call ClearWindowData
+
+ ld hl, hBGMapAddress
+ xor a ; LOW(vBGMap0)
+ ld [hli], a
+ ld [hl], HIGH(vBGMap0)
+ ret
diff --git a/engine/events/fruit_trees.asm b/engine/events/fruit_trees.asm
new file mode 100755
index 00000000..0177eb6f
--- /dev/null
+++ b/engine/events/fruit_trees.asm
@@ -0,0 +1,116 @@
+FruitTreeScript::
+ callasm GetCurTreeFruit
+ opentext
+ readmem wCurFruit
+ getitemname STRING_BUFFER_3, USE_SCRIPT_VAR
+ writetext FruitBearingTreeText
+ promptbutton
+ callasm TryResetFruitTrees
+ callasm CheckFruitTree
+ iffalse .fruit
+ writetext NothingHereText
+ waitbutton
+ sjump .end
+
+.fruit
+ writetext HeyItsFruitText
+ readmem wCurFruit
+ giveitem ITEM_FROM_MEM
+ iffalse .packisfull
+ promptbutton
+ writetext ObtainedFruitText
+ callasm PickedFruitTree
+ specialsound
+ itemnotify
+ sjump .end
+
+.packisfull
+ promptbutton
+ writetext FruitPackIsFullText
+ waitbutton
+
+.end
+ closetext
+ end
+
+GetCurTreeFruit:
+ ld a, [wCurFruitTree]
+ dec a
+ call GetFruitTreeItem
+ ld [wCurFruit], a
+ ret
+
+TryResetFruitTrees:
+ ld hl, wDailyFlags1
+ bit DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl]
+ ret nz
+ jp ResetFruitTrees
+
+CheckFruitTree:
+ ld b, 2
+ call GetFruitTreeFlag
+ ld a, c
+ ld [wScriptVar], a
+ ret
+
+PickedFruitTree:
+ ld b, 1
+ jp GetFruitTreeFlag
+
+ResetFruitTrees:
+ xor a
+ ld hl, wFruitTreeFlags
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld hl, wDailyFlags1
+ set DAILYFLAGS1_ALL_FRUIT_TREES_F, [hl]
+ ret
+
+GetFruitTreeFlag:
+ push hl
+ push de
+ ld a, [wCurFruitTree]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, wFruitTreeFlags
+ call FlagAction
+ pop de
+ pop hl
+ ret
+
+GetFruitTreeItem:
+ push hl
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeItems
+ add hl, de
+ ld a, [hl]
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/items/fruit_trees.asm"
+
+FruitBearingTreeText:
+ text_far _FruitBearingTreeText
+ text_end
+
+HeyItsFruitText:
+ text_far _HeyItsFruitText
+ text_end
+
+ObtainedFruitText:
+ text_far _ObtainedFruitText
+ text_end
+
+FruitPackIsFullText:
+ text_far _FruitPackIsFullText
+ text_end
+
+NothingHereText:
+ text_far _NothingHereText
+ text_end
diff --git a/engine/events/std_scripts.asm b/engine/events/std_scripts.asm
new file mode 100644
index 00000000..bdc90c55
--- /dev/null
+++ b/engine/events/std_scripts.asm
@@ -0,0 +1,774 @@
+StdScripts::
+; entries correspond to constants/std_constants.asm
+ dba PokecenterNurseScript
+ dba DifficultBookshelfScript
+ dba PictureBookshelfScript
+ dba MagazineBookshelfScript
+ dba TeamRocketOathScript
+ dba IncenseBurnerScript
+ dba MerchandiseShelfScript
+ dba TownMapScript
+ dba WindowScript
+ dba TVScript
+ dba HomepageScript
+ dba Radio1Script
+ dba Radio2Script
+ dba TrashCanScript
+ dba StrengthBoulderScript
+ dba SmashRockScript
+ dba PokecenterSignScript
+ dba MartSignScript
+ dba GoldenrodRocketsScript
+ dba RadioTowerRocketsScript
+ dba ElevatorButtonScript
+ dba DayToTextScript
+ dba BugContestResultsWarpScript
+ dba BugContestResultsScript
+ dba InitializeEventsScript
+ dba AskNumber1MScript
+ dba AskNumber2MScript
+ dba RegisteredNumberMScript
+ dba NumberAcceptedMScript
+ dba NumberDeclinedMScript
+ dba PhoneFullMScript
+ dba RematchMScript
+ dba AskNumber1FScript
+ dba AskNumber2FScript
+ dba RegisteredNumberFScript
+ dba NumberAcceptedFScript
+ dba NumberDeclinedFScript
+ dba PhoneFullFScript
+ dba RematchFScript
+ dba GymStatue1Script
+ dba GymStatue2Script
+ dba ReceiveItemScript
+ dba ReceiveTogepiEggScript
+ dba PCScript
+ dba GameCornerCoinVendorScript
+ dba HappinessCheckScript
+
+PokecenterNurseScript:
+ opentext
+ checktime MORN
+ iftrue .morn
+ checktime DAY
+ iftrue .day
+ checktime NITE
+ iftrue .nite
+ sjump .ok
+
+.morn
+ writetext NurseMornText
+ promptbutton
+ sjump .ok
+
+.day
+ writetext NurseDayText
+ promptbutton
+ sjump .ok
+
+.nite
+ writetext NurseNiteText
+ promptbutton
+ sjump .ok
+
+.ok
+ writetext NurseAskHealText
+ yesorno
+ iffalse .done
+
+ writetext NurseTakePokemonText
+ pause 20
+ turnobject LAST_TALKED, LEFT
+ pause 10
+ special HealParty
+ playmusic MUSIC_NONE
+ setval HEALMACHINE_POKECENTER
+ special HealMachineAnim
+ pause 30
+ special RestartMapMusic
+ turnobject LAST_TALKED, DOWN
+ pause 10
+
+ checkphonecall ; elm already called about pokerus
+ iftrue .no
+ checkflag ENGINE_CAUGHT_POKERUS
+ iftrue .no
+ special CheckPokerus
+ iftrue .pokerus
+.no
+ writetext NurseReturnPokemonText
+ pause 20
+
+.done
+ writetext NurseGoodbyeText
+
+ turnobject LAST_TALKED, UP
+ pause 10
+ turnobject LAST_TALKED, DOWN
+ pause 10
+
+ waitbutton
+ closetext
+ end
+
+.pokerus
+ writetext NursePokerusText
+ waitbutton
+ closetext
+ setflag ENGINE_CAUGHT_POKERUS
+ specialphonecall SPECIALCALL_POKERUS
+ end
+
+DifficultBookshelfScript:
+ jumptext DifficultBookshelfText
+
+PictureBookshelfScript:
+ jumptext PictureBookshelfText
+
+MagazineBookshelfScript:
+ jumptext MagazineBookshelfText
+
+TeamRocketOathScript:
+ jumptext TeamRocketOathText
+
+IncenseBurnerScript:
+ jumptext IncenseBurnerText
+
+MerchandiseShelfScript:
+ jumptext MerchandiseShelfText
+
+TownMapScript:
+ opentext
+ writetext LookTownMapText
+ waitbutton
+ special OverworldTownMap
+ closetext
+ end
+
+WindowScript:
+ jumptext WindowText
+
+TVScript:
+ opentext
+ writetext TVText
+ waitbutton
+ closetext
+ end
+
+HomepageScript:
+ jumptext HomepageText
+
+Radio1Script:
+ opentext
+ setval MAPRADIO_POKEMON_CHANNEL
+ special MapRadio
+ closetext
+ end
+
+Radio2Script:
+; Lucky Channel
+ opentext
+ setval MAPRADIO_LUCKY_CHANNEL
+ special MapRadio
+ closetext
+ end
+
+TrashCanScript:
+ jumptext TrashCanText
+
+PCScript:
+ opentext
+ special PokemonCenterPC
+ closetext
+ end
+
+ElevatorButtonScript:
+ playsound SFX_READ_TEXT_2
+ pause 15
+ playsound SFX_ELEVATOR_END
+ end
+
+StrengthBoulderScript:
+ farsjump AskStrengthScript
+
+SmashRockScript:
+ farsjump AskRockSmashScript
+
+PokecenterSignScript:
+ jumptext PokecenterSignText
+
+MartSignScript:
+ jumptext MartSignText
+
+DayToTextScript:
+ readvar VAR_WEEKDAY
+ ifequal MONDAY, .Monday
+ ifequal TUESDAY, .Tuesday
+ ifequal WEDNESDAY, .Wednesday
+ ifequal THURSDAY, .Thursday
+ ifequal FRIDAY, .Friday
+ ifequal SATURDAY, .Saturday
+ getstring STRING_BUFFER_3, .SundayText
+ end
+.Monday:
+ getstring STRING_BUFFER_3, .MondayText
+ end
+.Tuesday:
+ getstring STRING_BUFFER_3, .TuesdayText
+ end
+.Wednesday:
+ getstring STRING_BUFFER_3, .WednesdayText
+ end
+.Thursday:
+ getstring STRING_BUFFER_3, .ThursdayText
+ end
+.Friday:
+ getstring STRING_BUFFER_3, .FridayText
+ end
+.Saturday:
+ getstring STRING_BUFFER_3, .SaturdayText
+ end
+.SundayText:
+ db "SUNDAY@"
+.MondayText:
+ db "MONDAY@"
+.TuesdayText:
+ db "TUESDAY@"
+.WednesdayText:
+ db "WEDNESDAY@"
+.ThursdayText:
+ db "THURSDAY@"
+.FridayText:
+ db "FRIDAY@"
+.SaturdayText:
+ db "SATURDAY@"
+
+GoldenrodRocketsScript:
+ clearevent EVENT_GOLDENROD_CITY_ROCKET_TAKEOVER
+ end
+
+RadioTowerRocketsScript:
+ setflag ENGINE_ROCKETS_IN_RADIO_TOWER
+ setevent EVENT_GOLDENROD_CITY_CIVILIANS
+ setevent EVENT_RADIO_TOWER_BLACKBELT_BLOCKS_STAIRS
+ clearevent EVENT_RADIO_TOWER_ROCKET_TAKEOVER
+ clearevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER
+ setevent EVENT_MAHOGANY_TOWN_POKEFAN_M_BLOCKS_EAST
+ specialphonecall SPECIALCALL_WEIRDBROADCAST
+ setmapscene MAHOGANY_TOWN, SCENE_FINISHED
+ end
+
+BugContestResultsWarpScript:
+ special ClearBGPalettes
+ scall BugContestResults_CopyContestantsToResults
+ setevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_CONTEST_DAY
+ clearevent EVENT_ROUTE_36_NATIONAL_PARK_GATE_OFFICER_NOT_CONTEST_DAY
+ setevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE
+ warp ROUTE_36_NATIONAL_PARK_GATE, 0, 4
+ applymovement PLAYER, Movement_ContestResults_WalkAfterWarp
+
+BugContestResultsScript:
+ clearflag ENGINE_BUG_CONTEST_TIMER
+ clearevent EVENT_WARPED_FROM_ROUTE_35_NATIONAL_PARK_GATE
+ clearevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE
+ clearevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE
+ clearevent EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY
+ clearevent EVENT_CONTEST_OFFICER_HAS_BERRY
+ opentext
+ writetext ContestResults_ReadyToJudgeText
+ waitbutton
+ special BugContestJudging
+ getnum STRING_BUFFER_3
+ ifequal 1, BugContestResults_FirstPlace
+ ifequal 2, BugContestResults_SecondPlace
+ ifequal 3, BugContestResults_ThirdPlace
+ writetext ContestResults_ConsolationPrizeText
+ promptbutton
+ waitsfx
+ verbosegiveitem BERRY
+ iffalse BugContestResults_NoRoomForBerry
+
+BugContestResults_DidNotWin:
+ writetext ContestResults_DidNotWinText
+ promptbutton
+ sjump BugContestResults_FinishUp
+
+BugContestResults_ReturnAfterWinnersPrize:
+ writetext ContestResults_JoinUsNextTimeText
+ promptbutton
+
+BugContestResults_FinishUp:
+ checkevent EVENT_LEFT_MONS_WITH_CONTEST_OFFICER
+ iffalse BugContestResults_DidNotLeaveMons
+ writetext ContestResults_ReturnPartyText
+ waitbutton
+ special ContestReturnMons
+BugContestResults_DidNotLeaveMons:
+ special CheckPartyFullAfterContest
+ ifequal BUGCONTEST_CAUGHT_MON, BugContestResults_CleanUp
+ ifequal BUGCONTEST_NO_CATCH, BugContestResults_CleanUp
+ ; BUGCONTEST_BOXED_MON
+ writetext ContestResults_PartyFullText
+ waitbutton
+BugContestResults_CleanUp:
+ closetext
+ setscene SCENE_ROUTE36NATIONALPARKGATE_NOTHING
+ setmapscene ROUTE_35_NATIONAL_PARK_GATE, SCENE_ROUTE35NATIONALPARKGATE_NOTHING
+ setevent EVENT_BUG_CATCHING_CONTESTANT_1A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_2A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_3A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_4A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_5A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_6A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_7A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_8A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_9A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_10A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_1B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_2B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_3B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_4B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_5B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_6B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_7B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_8B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_9B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_10B
+ setflag ENGINE_DAILY_BUG_CONTEST
+ special PlayMapMusic
+ end
+
+BugContestResults_FirstPlace:
+ setevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_1
+ getitemname STRING_BUFFER_4, SUN_STONE
+ writetext ContestResults_PlayerWonAPrizeText
+ waitbutton
+ verbosegiveitem SUN_STONE
+ iffalse BugContestResults_NoRoomForSunStone
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_SecondPlace:
+ getitemname STRING_BUFFER_4, EVERSTONE
+ writetext ContestResults_PlayerWonAPrizeText
+ waitbutton
+ verbosegiveitem EVERSTONE
+ iffalse BugContestResults_NoRoomForEverstone
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_ThirdPlace:
+ getitemname STRING_BUFFER_4, GOLD_BERRY
+ writetext ContestResults_PlayerWonAPrizeText
+ waitbutton
+ verbosegiveitem GOLD_BERRY
+ iffalse BugContestResults_NoRoomForGoldBerry
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_NoRoomForSunStone:
+ writetext BugContestPrizeNoRoomText
+ promptbutton
+ setevent EVENT_CONTEST_OFFICER_HAS_SUN_STONE
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_NoRoomForEverstone:
+ writetext BugContestPrizeNoRoomText
+ promptbutton
+ setevent EVENT_CONTEST_OFFICER_HAS_EVERSTONE
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_NoRoomForGoldBerry:
+ writetext BugContestPrizeNoRoomText
+ promptbutton
+ setevent EVENT_CONTEST_OFFICER_HAS_GOLD_BERRY
+ sjump BugContestResults_ReturnAfterWinnersPrize
+
+BugContestResults_NoRoomForBerry:
+ writetext BugContestPrizeNoRoomText
+ promptbutton
+ setevent EVENT_CONTEST_OFFICER_HAS_BERRY
+ sjump BugContestResults_DidNotWin
+
+BugContestResults_CopyContestantsToResults:
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_1A
+ iftrue .skip1
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_1B
+.skip1
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_2A
+ iftrue .skip2
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_2B
+.skip2
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_3A
+ iftrue .skip3
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_3B
+.skip3
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_4A
+ iftrue .skip4
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_4B
+.skip4
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_5A
+ iftrue .skip5
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_5B
+.skip5
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_6A
+ iftrue .skip6
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_6B
+.skip6
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_7A
+ iftrue .skip7
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_7B
+.skip7
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_8A
+ iftrue .skip8
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_8B
+.skip8
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_9A
+ iftrue .skip9
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_9B
+.skip9
+ checkevent EVENT_BUG_CATCHING_CONTESTANT_10A
+ iftrue .skip10
+ clearevent EVENT_BUG_CATCHING_CONTESTANT_10B
+.skip10
+ end
+
+InitializeEventsScript:
+ setevent EVENT_EARLS_ACADEMY_EARL
+ setevent EVENT_RADIO_TOWER_ROCKET_TAKEOVER
+ setevent EVENT_GOLDENROD_CITY_ROCKET_TAKEOVER
+ setevent EVENT_RADIO_TOWER_CIVILIANS_AFTER
+ setevent EVENT_ILEX_FOREST_APPRENTICE
+ setevent EVENT_ILEX_FOREST_FARFETCHD1
+ setevent EVENT_ILEX_FOREST_FARFETCHD2
+ setevent EVENT_ILEX_FOREST_FARFETCHD3
+ setevent EVENT_ILEX_FOREST_FARFETCHD4
+ setevent EVENT_ILEX_FOREST_FARFETCHD5
+ setevent EVENT_ILEX_FOREST_FARFETCHD6
+ setevent EVENT_ILEX_FOREST_FARFETCHD7
+ setevent EVENT_ILEX_FOREST_FARFETCHD8
+ setevent EVENT_ILEX_FOREST_FARFETCHD9
+ setevent EVENT_ILEX_FOREST_FARFETCHD10
+ setevent EVENT_ILEX_FOREST_CHARCOAL_MASTER
+ setevent EVENT_MAHOGANY_MART_LANCE_AND_DRAGONITE
+ setevent EVENT_TEAM_ROCKET_BASE_B2F_GRUNT_WITH_EXECUTIVE
+ setevent EVENT_TEAM_ROCKET_BASE_B2F_EXECUTIVE
+ setevent EVENT_TEAM_ROCKET_BASE_B2F_DRAGONITE
+ setevent EVENT_RIVAL_TEAM_ROCKET_BASE
+ setevent EVENT_BLACKTHORN_CITY_SUPER_NERD_DOES_NOT_BLOCK_GYM
+ setevent EVENT_USED_THE_CARD_KEY_IN_THE_RADIO_TOWER
+ setevent EVENT_RIVAL_CHERRYGROVE_CITY
+ setevent EVENT_RIVAL_AZALEA_TOWN
+ setevent EVENT_RIVAL_GOLDENROD_UNDERGROUND
+ setevent EVENT_AZALEA_TOWN_SLOWPOKES
+ setevent EVENT_KURTS_HOUSE_SLOWPOKE
+ setevent EVENT_GUIDE_GENT_VISIBLE_IN_CHERRYGROVE
+ setevent EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER
+ setevent EVENT_COP_IN_ELMS_LAB
+ setevent EVENT_RUINS_OF_ALPH_OUTSIDE_SCIENTIST
+ setevent EVENT_RUINS_OF_ALPH_RESEARCH_CENTER_SCIENTIST
+ setevent EVENT_BOULDER_IN_ICE_PATH_1A
+ setevent EVENT_BOULDER_IN_ICE_PATH_2A
+ setevent EVENT_BOULDER_IN_ICE_PATH_3A
+ setevent EVENT_BOULDER_IN_ICE_PATH_4A
+ setevent EVENT_ROUTE_30_YOUNGSTER_JOEY
+ setevent EVENT_BUG_CATCHING_CONTESTANT_1A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_2A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_3A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_4A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_5A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_6A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_7A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_8A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_9A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_10A
+ setevent EVENT_BUG_CATCHING_CONTESTANT_1B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_2B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_3B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_4B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_5B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_6B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_7B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_8B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_9B
+ setevent EVENT_BUG_CATCHING_CONTESTANT_10B
+ setevent EVENT_FAST_SHIP_1F_GENTLEMAN
+ setevent EVENT_FAST_SHIP_B1F_SAILOR_RIGHT
+ setevent EVENT_FAST_SHIP_CABINS_NNW_NNE_NE_SAILOR
+ setevent EVENT_LAKE_OF_RAGE_CIVILIANS
+ setevent EVENT_MAHOGANY_MART_OWNERS
+ setevent EVENT_TIN_TOWER_ROOF_HO_OH
+ setevent EVENT_WHIRL_ISLAND_LUGIA_CHAMBER_LUGIA
+ setevent EVENT_PLAYERS_HOUSE_2F_CONSOLE
+ setevent EVENT_PLAYERS_HOUSE_2F_DOLL_1
+ setevent EVENT_PLAYERS_HOUSE_2F_DOLL_2
+ setevent EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
+ setevent EVENT_DECO_BED_1
+ setevent EVENT_DECO_POSTER_1
+ setevent EVENT_GOLDENROD_TRAIN_STATION_GENTLEMAN
+ setevent EVENT_OLIVINE_GYM_JASMINE
+ setevent EVENT_BLACKTHORN_CITY_GRAMPS_NOT_BLOCKING_DRAGONS_DEN
+ setevent EVENT_MET_BILL
+ setevent EVENT_ECRUTEAK_POKE_CENTER_BILL
+ setevent EVENT_MYSTERY_GIFT_DELIVERY_GUY
+ setevent EVENT_LAKE_OF_RAGE_LANCE
+ setevent EVENT_GOLDENROD_DEPT_STORE_B1F_LAYOUT_1
+ setevent EVENT_GOLDENROD_UNDERGROUND_WAREHOUSE_BLOCKED_OFF
+ setevent EVENT_DRAGONS_DEN_CLAIR
+ setevent EVENT_RIVAL_OLIVINE_CITY
+ setevent EVENT_RIVAL_VICTORY_ROAD
+ setevent EVENT_RIVAL_DRAGONS_DEN
+ setevent EVENT_LANCES_ROOM_OAK_AND_MARY
+ setevent EVENT_FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN_TWIN_1
+ setevent EVENT_BURNED_TOWER_B1F_BEASTS_1
+ setevent EVENT_RED_IN_MT_SILVER
+ setevent EVENT_OLIVINE_PORT_SPRITES_AFTER_HALL_OF_FAME
+ setevent EVENT_FAST_SHIP_PASSENGERS_EASTBOUND
+ setevent EVENT_FAST_SHIP_PASSENGERS_WESTBOUND
+ setevent EVENT_OLIVINE_PORT_PASSAGE_POKEFAN_M
+ setevent EVENT_KURTS_HOUSE_KURT_2
+ setevent EVENT_BURNED_TOWER_FIREBREATHER_DICK_ASHES
+ setevent EVENT_RANG_CLEAR_BELL_1 ; ?
+ setevent EVENT_PLAYERS_HOUSE_MOM_2
+ setflag ENGINE_ROCKET_SIGNAL_ON_CH20
+ setflag ENGINE_ROCKETS_IN_MAHOGANY
+ variablesprite SPRITE_WEIRD_TREE, SPRITE_SUDOWOODO
+ variablesprite SPRITE_OLIVINE_RIVAL, SPRITE_SILVER
+ variablesprite SPRITE_AZALEA_ROCKET, SPRITE_ROCKET
+ variablesprite SPRITE_FUCHSIA_GYM_1, SPRITE_JANINE
+ variablesprite SPRITE_FUCHSIA_GYM_2, SPRITE_JANINE
+ variablesprite SPRITE_FUCHSIA_GYM_3, SPRITE_JANINE
+ variablesprite SPRITE_FUCHSIA_GYM_4, SPRITE_JANINE
+ variablesprite SPRITE_COPYCAT, SPRITE_LASS
+ variablesprite SPRITE_JANINE_IMPERSONATOR, SPRITE_LASS
+ setevent EVENT_FOUND_MACHINE_PART_IN_CERULEAN_GYM
+ setevent EVENT_CERULEAN_GYM_ROCKET
+ setevent EVENT_ROUTE_24_ROCKET
+ setevent EVENT_ROUTE_25_MISTY_BOYFRIEND
+ setevent EVENT_TRAINERS_IN_CERULEAN_GYM
+ setevent EVENT_COPYCATS_HOUSE_2F_DOLL
+ setevent EVENT_VIRIDIAN_GYM_BLUE
+ setevent EVENT_SEAFOAM_GYM_GYM_GUY
+ setevent EVENT_MT_MOON_SQUARE_CLEFAIRY
+ setevent EVENT_SAFFRON_TRAIN_STATION_POPULATION
+ setevent EVENT_INDIGO_PLATEAU_POKECENTER_RIVAL
+ setevent EVENT_INITIALIZED_EVENTS
+ return
+
+AskNumber1MScript:
+ writetext AskNumber1MText
+ end
+
+AskNumber2MScript:
+ writetext AskNumber2MText
+ end
+
+RegisteredNumberMScript:
+ writetext RegisteredNumberMText
+ playsound SFX_REGISTER_PHONE_NUMBER
+ waitsfx
+ promptbutton
+ end
+
+NumberAcceptedMScript:
+ writetext NumberAcceptedMText
+ waitbutton
+ closetext
+ end
+
+NumberDeclinedMScript:
+ writetext NumberDeclinedMText
+ waitbutton
+ closetext
+ end
+
+PhoneFullMScript:
+ writetext PhoneFullMText
+ waitbutton
+ closetext
+ end
+
+RematchMScript:
+ writetext RematchMText
+ waitbutton
+ closetext
+ end
+
+AskNumber1FScript:
+ writetext AskNumber1FText
+ end
+
+AskNumber2FScript:
+ writetext AskNumber2FText
+ end
+
+RegisteredNumberFScript:
+ writetext RegisteredNumberFText
+ playsound SFX_REGISTER_PHONE_NUMBER
+ waitsfx
+ promptbutton
+ end
+
+NumberAcceptedFScript:
+ writetext NumberAcceptedFText
+ waitbutton
+ closetext
+ end
+
+NumberDeclinedFScript:
+ writetext NumberDeclinedFText
+ waitbutton
+ closetext
+ end
+
+PhoneFullFScript:
+ writetext PhoneFullFText
+ waitbutton
+ closetext
+ end
+
+RematchFScript:
+ writetext RematchFText
+ waitbutton
+ closetext
+ end
+
+GymStatue1Script:
+ getcurlandmarkname STRING_BUFFER_3
+ opentext
+ writetext GymStatue_CityGymText
+ waitbutton
+ closetext
+ end
+
+GymStatue2Script:
+ getcurlandmarkname STRING_BUFFER_3
+ opentext
+ writetext GymStatue_CityGymText
+ promptbutton
+ writetext GymStatue_WinningTrainersText
+ waitbutton
+ closetext
+ end
+
+ReceiveItemScript:
+ waitsfx
+ writetext ReceivedItemText
+ playsound SFX_ITEM
+ waitsfx
+ end
+
+ReceiveTogepiEggScript:
+ waitsfx
+ writetext ReceivedItemText
+ playsound SFX_GET_EGG
+ waitsfx
+ end
+
+GameCornerCoinVendorScript:
+ faceplayer
+ opentext
+ writetext CoinVendor_WelcomeText
+ promptbutton
+ checkitem COIN_CASE
+ iftrue CoinVendor_IntroScript
+ writetext CoinVendor_NoCoinCaseText
+ waitbutton
+ closetext
+ end
+
+CoinVendor_IntroScript:
+ writetext CoinVendor_IntroText
+
+.loop
+ special DisplayMoneyAndCoinBalance
+ loadmenu .MenuHeader
+ verticalmenu
+ closewindow
+ ifequal 1, .Buy50
+ ifequal 2, .Buy500
+ sjump .Cancel
+
+.Buy50:
+ checkcoins MAX_COINS - 50
+ ifequal HAVE_MORE, .CoinCaseFull
+ checkmoney YOUR_MONEY, 1000
+ ifequal HAVE_LESS, .NotEnoughMoney
+ givecoins 50
+ takemoney YOUR_MONEY, 1000
+ waitsfx
+ playsound SFX_TRANSACTION
+ writetext CoinVendor_Buy50CoinsText
+ waitbutton
+ sjump .loop
+
+.Buy500:
+ checkcoins MAX_COINS - 500
+ ifequal HAVE_MORE, .CoinCaseFull
+ checkmoney YOUR_MONEY, 10000
+ ifequal HAVE_LESS, .NotEnoughMoney
+ givecoins 500
+ takemoney YOUR_MONEY, 10000
+ waitsfx
+ playsound SFX_TRANSACTION
+ writetext CoinVendor_Buy500CoinsText
+ waitbutton
+ sjump .loop
+
+.NotEnoughMoney:
+ writetext CoinVendor_NotEnoughMoneyText
+ waitbutton
+ closetext
+ end
+
+.CoinCaseFull:
+ writetext CoinVendor_CoinCaseFullText
+ waitbutton
+ closetext
+ end
+
+.Cancel:
+ writetext CoinVendor_CancelText
+ waitbutton
+ closetext
+ end
+
+.MenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 4, 15, TEXTBOX_Y - 1
+ dw .MenuData
+ db 1 ; default option
+
+.MenuData:
+ db STATICMENU_CURSOR ; flags
+ db 3 ; items
+ db " 50 : ¥1000@"
+ db "500 : ¥10000@"
+ db "CANCEL@"
+
+HappinessCheckScript:
+ faceplayer
+ opentext
+ special GetFirstPokemonHappiness
+ ifless 50, .Unhappy
+ ifless 150, .KindaHappy
+ writetext HappinessText3
+ waitbutton
+ closetext
+ end
+
+.KindaHappy:
+ writetext HappinessText2
+ waitbutton
+ closetext
+ end
+
+.Unhappy:
+ writetext HappinessText1
+ waitbutton
+ closetext
+ end
+
+Movement_ContestResults_WalkAfterWarp:
+ step RIGHT
+ step DOWN
+ turn_head UP
+ step_end
diff --git a/engine/gfx/place_graphic.asm b/engine/gfx/place_graphic.asm
new file mode 100755
index 00000000..4092ad35
--- /dev/null
+++ b/engine/gfx/place_graphic.asm
@@ -0,0 +1,55 @@
+PlaceGraphic:
+; Fill wBoxAlignment-aligned box width b height c
+; with iterating tile starting from hGraphicStartTile at hl.
+
+ ld de, SCREEN_WIDTH
+
+ ld a, [wBoxAlignment]
+ and a
+ jr nz, .right
+
+ ldh a, [hGraphicStartTile]
+.x1
+ push bc
+ push hl
+
+.y1
+ ld [hl], a
+ add hl, de
+ inc a
+ dec c
+ jr nz, .y1
+
+ pop hl
+ inc hl
+ pop bc
+ dec b
+ jr nz, .x1
+ ret
+
+.right
+; Right-aligned.
+ push bc
+ ld b, 0
+ dec c
+ add hl, bc
+ pop bc
+
+ ldh a, [hGraphicStartTile]
+.x2
+ push bc
+ push hl
+
+.y2
+ ld [hl], a
+ add hl, de
+ inc a
+ dec c
+ jr nz, .y2
+
+ pop hl
+ dec hl
+ pop bc
+ dec b
+ jr nz, .x2
+ ret
diff --git a/engine/pokemon/mail.asm b/engine/pokemon/mail.asm
new file mode 100755
index 00000000..9da39149
--- /dev/null
+++ b/engine/pokemon/mail.asm
@@ -0,0 +1,565 @@
+SendMailToPC:
+ ld a, MON_ITEM
+ call GetPartyParamLocation
+ ld d, [hl]
+ farcall ItemIsMail
+ jr nc, .full
+ call GetMailboxCount
+ cp MAILBOX_CAPACITY
+ jr nc, .full
+ ld bc, MAIL_STRUCT_LENGTH
+ ld hl, sMailbox
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld a, [wCurPartyMon]
+ ld bc, MAIL_STRUCT_LENGTH
+ ld hl, sPartyMail
+ call AddNTimes
+ push hl
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ pop hl
+ xor a
+ ld bc, MAIL_STRUCT_LENGTH
+ call ByteFill
+ ld a, MON_ITEM
+ call GetPartyParamLocation
+ ld [hl], 0
+ ld hl, sMailboxCount
+ inc [hl]
+ call CloseSRAM
+ xor a
+ ret
+
+.full
+ scf
+ ret
+
+DeleteMailFromPC:
+; Shift all mail messages in the mailbox
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ ld a, b
+ push bc
+ ld hl, sMailbox
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ push hl
+ add hl, bc
+ pop de
+ pop bc
+.loop
+ ld a, b
+ cp MAILBOX_CAPACITY - 1
+ jr z, .done
+ push bc
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ pop bc
+ inc b
+ jr .loop
+.done
+ ld h, d
+ ld l, e
+ xor a
+ ld bc, MAIL_STRUCT_LENGTH
+ call ByteFill
+ ld hl, sMailboxCount
+ dec [hl]
+ jp CloseSRAM
+
+ReadMailMessage:
+ ld a, b
+ ld hl, sMailbox
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ farcall ReadAnyMail
+ ret
+
+MoveMailFromPCToParty:
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ push bc
+ ld a, b
+ ld bc, MAIL_STRUCT_LENGTH
+ ld hl, sMailbox
+ call AddNTimes
+ push hl
+ ld a, [wCurPartyMon]
+ ld bc, MAIL_STRUCT_LENGTH
+ ld hl, sPartyMail
+ call AddNTimes
+ ld d, h
+ ld e, l
+ pop hl
+ push hl
+ ld bc, MAIL_STRUCT_LENGTH
+ call CopyBytes
+ pop hl
+ ld de, PARTYMON_STRUCT_LENGTH - MON_MOVES
+ add hl, de
+ ld d, [hl]
+ ld a, [wCurPartyMon]
+ ld hl, wPartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld [hl], d
+ call CloseSRAM
+ pop bc
+ jp DeleteMailFromPC
+
+GetMailboxCount:
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ ld a, [sMailboxCount]
+ ld c, a
+ jp CloseSRAM
+
+CheckPokeMail::
+ push bc
+ push de
+ farcall SelectMonFromParty
+ ld a, POKEMAIL_REFUSED
+ jr c, .pop_return
+
+ ld a, [wCurPartyMon]
+ ld hl, wPartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld d, [hl]
+ farcall ItemIsMail
+ ld a, POKEMAIL_NO_MAIL
+ jr nc, .pop_return
+
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ ld a, [wCurPartyMon]
+ ld hl, sPartyMail
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ pop hl
+ pop bc
+
+; Compare the mail message, byte for byte, with the expected message.
+ ld a, MAIL_MSG_LENGTH
+ ld [wTempByteValue], a
+.loop
+ ld a, [de]
+ ld c, a
+ ld a, b
+ call GetFarByte
+ cp "@"
+ jr z, .done
+ cp c
+ ld a, POKEMAIL_WRONG_MAIL
+ jr nz, .close_sram_return
+ inc hl
+ inc de
+ ld a, [wTempByteValue]
+ dec a
+ ld [wTempByteValue], a
+ jr nz, .loop
+
+.done
+ farcall CheckCurPartyMonFainted
+ ld a, POKEMAIL_LAST_MON
+ jr c, .close_sram_return
+ xor a ; REMOVE_PARTY
+ ld [wPokemonWithdrawDepositParameter], a
+ farcall RemoveMonFromPartyOrBox
+ ld a, POKEMAIL_CORRECT
+
+.close_sram_return
+ call CloseSRAM
+ jr .return
+
+.pop_return
+ pop de
+ pop bc
+
+.return
+ ld [wScriptVar], a
+ ret
+
+GivePokeMail::
+ ld a, [wPartyCount]
+ dec a
+ push af
+ push bc
+ ld hl, wPartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld [hl], b
+ pop af
+ push bc
+ push af
+ ld hl, sPartyMail
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld d, h
+ ld e, l
+ ld hl, wceed
+ ld bc, MAIL_MSG_LENGTH + 1
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ call CopyBytes
+ pop af
+ push af
+ ld hl, wPartyMonOT
+ ld bc, NAME_LENGTH
+ call AddNTimes
+ ld bc, NAME_LENGTH - 1
+ call CopyBytes
+ pop af
+ ld hl, wPartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+ ld a, [wCurPartySpecies]
+ ld [de], a
+ inc de
+ pop bc
+ ld a, b
+ ld [de], a
+ jp CloseSRAM
+
+BackupPartyMonMail:
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ ld hl, sPartyMail
+ ld de, sPartyMailBackup
+ ld bc, 6 * MAIL_STRUCT_LENGTH
+ call CopyBytes
+ ld hl, sMailboxCount
+ ld de, sMailboxCountBackup
+ ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
+ call CopyBytes
+ jp CloseSRAM
+
+RestorePartyMonMail:
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ ld hl, sPartyMailBackup
+ ld de, sPartyMail
+ ld bc, 6 * MAIL_STRUCT_LENGTH
+ call CopyBytes
+ ld hl, sMailboxCountBackup
+ ld de, sMailboxCount
+ ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
+ call CopyBytes
+ jp CloseSRAM
+
+DeletePartyMonMail:
+ ld a, BANK(sPartyMail)
+ call OpenSRAM
+ xor a
+ ld hl, sPartyMail
+ ld bc, 6 * MAIL_STRUCT_LENGTH
+ call ByteFill
+ xor a
+ ld hl, sMailboxCount
+ ld bc, 1 + 10 * MAIL_STRUCT_LENGTH
+ call ByteFill
+ jp CloseSRAM
+
+IsAnyMonHoldingMail:
+ ld a, [wPartyCount]
+ and a
+ jr z, .no_mons
+ ld e, a
+ ld hl, wPartyMon1Item
+.loop
+ ld d, [hl]
+ push hl
+ push de
+ farcall ItemIsMail
+ pop de
+ pop hl
+ ret c
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ dec e
+ jr nz, .loop
+
+.no_mons
+ and a
+ ret
+
+_PlayerMailBoxMenu:
+ call InitMail
+ jr z, .nomail
+ call LoadStandardMenuHeader
+ call MailboxPC
+ jp CloseWindow
+
+.nomail
+ ld hl, .EmptyMailboxText
+ jp MenuTextboxBackup
+
+.EmptyMailboxText:
+ text_far _EmptyMailboxText
+ text_end
+
+InitMail:
+; initialize wMailboxCount and beyond with incrementing values, one per mail
+; set z if no mail
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ ld a, [sMailboxCount]
+ call CloseSRAM
+ ld hl, wMailboxCount
+ ld [hli], a
+ and a
+
+ jr z, .done ; if no mail, we're done
+
+ ; load values in memory with incrementing values starting at wMailboxCount
+ ld b, a
+ ld a, 1
+.loop
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .loop
+.done
+ ld [hl], -1 ; terminate
+
+ ld a, [wMailboxCount]
+ and a
+ ret
+
+MailboxPC_GetMailAuthor:
+ dec a
+ ld hl, sMailbox1Author
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ ld de, wStringBuffer2
+ push de
+ ld bc, NAME_LENGTH - 1
+ call CopyBytes
+ ld a, "@"
+ ld [de], a
+ call CloseSRAM
+ pop de
+ ret
+
+MailboxPC_PrintMailAuthor:
+ push de
+ ld a, [wMenuSelection]
+ call MailboxPC_GetMailAuthor
+ pop hl
+ jp PlaceString
+
+MailboxPC:
+ xor a
+ ld [wCurMessageScrollPosition], a
+ ld a, 1
+ ld [wCurMessageIndex], a
+.loop
+ call InitMail
+ ld hl, .TopMenuHeader
+ call CopyMenuHeader
+ xor a
+ ldh [hBGMapMode], a
+ call InitScrollingMenu
+ call UpdateSprites
+
+ ld a, [wCurMessageIndex]
+ ld [wMenuCursorBuffer], a
+ ld a, [wCurMessageScrollPosition]
+ ld [wMenuScrollPosition], a
+ call ScrollingMenu
+ ld a, [wMenuScrollPosition]
+ ld [wCurMessageScrollPosition], a
+ ld a, [wMenuCursorY]
+ ld [wCurMessageIndex], a
+
+ ld a, [wMenuJoypad]
+ cp B_BUTTON
+ jr z, .exit
+ call .Submenu
+ jr .loop
+
+.exit
+ xor a
+ ret
+
+.Submenu:
+ ld hl, .SubMenuHeader
+ call LoadMenuHeader
+ call VerticalMenu
+ call ExitMenu
+ jr c, .subexit
+ ld a, [wMenuCursorY]
+ dec a
+ ld hl, .JumpTable
+ rst JumpTable
+
+.subexit
+ ret
+
+.JumpTable:
+ dw .ReadMail
+ dw .PutInPack
+ dw .AttachMail
+ dw .Cancel
+
+.ReadMail:
+ call FadeToMenu
+ ld a, [wMenuSelection]
+ dec a
+ ld b, a
+ call ReadMailMessage
+ jp CloseSubmenu
+
+.PutInPack:
+ ld hl, .MailMessageLostText
+ call MenuTextbox
+ call YesNoBox
+ call ExitMenu
+ ret c
+ ld a, [wMenuSelection]
+ dec a
+ call .GetMailType
+ ld a, 1
+ ld [wItemQuantityChangeBuffer], a
+ ld hl, wNumItems
+ call ReceiveItem
+ jr c, .put_in_bag
+ ld hl, .MailPackFullText
+ jp MenuTextboxBackup
+
+.put_in_bag
+ ld a, [wMenuSelection]
+ dec a
+ ld b, a
+ call DeleteMailFromPC
+ ld hl, .MailClearedPutAwayText
+ jp MenuTextboxBackup
+
+.MailClearedPutAwayText:
+ text_far _MailClearedPutAwayText
+ text_end
+
+.MailPackFullText:
+ text_far _MailPackFullText
+ text_end
+
+.MailMessageLostText:
+ text_far _MailMessageLostText
+ text_end
+
+.GetMailType:
+ push af
+ ld a, BANK(sMailboxCount)
+ call OpenSRAM
+ pop af
+ ld hl, sMailbox1Type
+ ld bc, MAIL_STRUCT_LENGTH
+ call AddNTimes
+ ld a, [hl]
+ ld [wCurItem], a
+ jp CloseSRAM
+
+.AttachMail:
+ call FadeToMenu
+ xor a
+ ld [wPartyMenuActionText], a
+ call ClearBGPalettes
+.try_again
+ farcall LoadPartyMenuGFX
+ farcall InitPartyMenuWithCancel
+ farcall InitPartyMenuGFX
+ farcall WritePartyMenuTilemap
+ farcall PrintPartyMenuText
+ call WaitBGMap
+ call SetPalettes
+ call DelayFrame
+ farcall PartyMenuSelect
+ jr c, .exit2
+ ld a, [wCurPartySpecies]
+ cp EGG
+ jr z, .egg
+ ld a, MON_ITEM
+ call GetPartyParamLocation
+ ld a, [hl]
+ and a
+ jr z, .attach_mail
+ ld hl, .MailAlreadyHoldingItemText
+ call PrintText
+ jr .try_again
+
+.egg
+ ld hl, .MailEggText
+ call PrintText
+ jr .try_again
+
+.attach_mail
+ ld a, [wMenuSelection]
+ dec a
+ ld b, a
+ call MoveMailFromPCToParty
+ ld hl, .MailMovedFromBoxText
+ call PrintText
+
+.exit2
+ jp CloseSubmenu
+
+.MailAlreadyHoldingItemText:
+ text_far _MailAlreadyHoldingItemText
+ text_end
+
+.MailEggText:
+ text_far _MailEggText
+ text_end
+
+.MailMovedFromBoxText:
+ text_far _MailMovedFromBoxText
+ text_end
+
+.Cancel:
+ ret
+
+.TopMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 8, 1, SCREEN_WIDTH - 2, 10
+ dw .TopMenuData
+ db 1 ; default option
+
+.TopMenuData:
+ db SCROLLINGMENU_DISPLAY_ARROWS ; flags
+ db 4, 0 ; rows, columns
+ db SCROLLINGMENU_ITEMS_NORMAL ; item format
+ dbw 0, wMailboxCount ; text pointer
+ dba MailboxPC_PrintMailAuthor
+ dba NULL
+ dba NULL
+
+.SubMenuHeader:
+ db MENU_BACKUP_TILES ; flags
+ menu_coords 0, 0, 13, 9
+ dw .SubMenuData
+ db 1 ; default option
+
+.SubMenuData:
+ db STATICMENU_CURSOR ; flags
+ db 4 ; items
+ db "READ MAIL@"
+ db "PUT IN PACK@"
+ db "ATTACH MAIL@"
+ db "CANCEL@"
diff --git a/gfx/pokedex/pokedex.2bpp b/gfx/pokedex/pokedex.2bpp
deleted file mode 100644
index ace4e25e..00000000
--- a/gfx/pokedex/pokedex.2bpp
+++ /dev/null
Binary files differ
diff --git a/gfx/pokedex/slowpoke.2bpp b/gfx/pokedex/slowpoke.2bpp
deleted file mode 100644
index 959020dc..00000000
--- a/gfx/pokedex/slowpoke.2bpp
+++ /dev/null
Binary files differ
diff --git a/layout.link b/layout.link
index 28aabaea..a527bdb5 100644
--- a/layout.link
+++ b/layout.link
@@ -154,7 +154,7 @@ ROMX $3e
ROMX $3f
"bank3f"
ROMX $40
- "bank40"
+ "Standard Scripts"
ROMX $41
"Phone Scripts"
ROMX $42
diff --git a/main.asm b/main.asm
index d7379749..3fda5410 100644
--- a/main.asm
+++ b/main.asm
@@ -346,32 +346,12 @@ INCLUDE "engine/pokemon/evolve.asm"
SECTION "bank11", ROMX
-FruitTreeScript::
- dr $44000, $440c8
+INCLUDE "engine/events/fruit_trees.asm"
INCLUDE "engine/battle/ai/move.asm"
INCLUDE "engine/pokedex/pokedex_2.asm"
-PlayBattleMusic::
- dr $44556, $445f2
-ClearBattleRAM::
- dr $445f2, $44648
-PlaceGraphic::
- dr $44648, $44679
-SendMailToPC::
- dr $44679, $4475f
-CheckPokeMail::
- dr $4475f, $447d7
-GivePokeMail::
- dr $447d7, $44830
-BackupPartyMonMail::
- dr $44830, $44850
-RestorePartyMonMail::
- dr $44850, $44870
-DeletePartyMonMail::
- dr $44870, $4488c
-IsAnyMonHoldingMail::
- dr $4488c, $448ab
-_PlayerMailBoxMenu::
- dr $448ab, $44aa2
+INCLUDE "engine/battle/start_battle.asm"
+INCLUDE "engine/gfx/place_graphic.asm"
+INCLUDE "engine/pokemon/mail.asm"
SECTION "bank14", ROMX
@@ -896,10 +876,10 @@ InitMysteryGiftLayout::
dr $fcfb2, $fde20
-SECTION "bank40", ROMX
+SECTION "Standard Scripts", ROMX
-StdScripts::
- dr $100000, $10110c
+INCLUDE "engine/events/std_scripts.asm"
+INCLUDE "data/text/std_text.asm"
INCLUDE "data/text/battle.asm"
diff --git a/wram.asm b/wram.asm
index 9c593d4f..c2b23477 100644
--- a/wram.asm
+++ b/wram.asm
@@ -599,7 +599,7 @@ wBattleAnimOAMPointerLo:: db ; ca18
ds 207
-wBattle: ; cae8
+wBattle:: ; cae8
wEnemyMoveStruct:: move_struct wEnemyMoveStruct
wPlayerMoveStruct:: move_struct wPlayerMoveStruct
@@ -2531,19 +2531,13 @@ wMomItemTriggerBalance:: ds 3 ; d963
wDailyResetTimer:: dw ; d966
wDailyFlags1:: db ; d968
wDailyFlags2:: db ; d969
-wd96a:: ds 1 ; d96a
-wd96b:: ds 1 ; d96b
-wd96c:: ds 1 ; d96c
-wTimerEventStartDay:: db ; d96d
-wd96e:: ds 1 ; d96e
-wd96f:: ds 1 ; d96f
-wd970:: ds 1 ; d970
-wd971:: ds 1 ; d971
-wd972:: ds 1 ; d972
-wd973:: ds 1 ; d973
-wd974:: ds 1 ; d974
-wd975:: ds 1 ; d975
-wd976:: ds 1 ; d976
+ ds 3
+wTimerEventStartDay:: db
+ ds 3
+
+wFruitTreeFlags:: flag_array NUM_FRUIT_TREES ; d971
+
+ ds 2
wLuckyNumberDayBuffer:: dw ; d977
wd979:: ds 1 ; d979