summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorentrpntr <entrpntr@gmail.com>2020-04-26 19:00:07 -0400
committerentrpntr <entrpntr@gmail.com>2020-04-26 19:11:18 -0400
commit0b33dabae2d43591a964774154f8bec5bf7194b1 (patch)
treeb51d8de7de034c38081a679abf8c9a14efd8bfaa
parent9ce922493398842b2e91383a08098f20249d44c7 (diff)
Disassemble map scenes and events.
-rw-r--r--Makefile2
-rw-r--r--constants/map_constants.asm890
-rw-r--r--constants/misc_constants.asm4
-rw-r--r--constants/script_constants.asm23
-rw-r--r--constants/wram_constants.asm19
-rw-r--r--data/items/pocket_names.asm11
-rw-r--r--data/maps/map_data.asm14
-rw-r--r--data/maps/scenes.asm67
-rw-r--r--data/maps/scripts.asm62
-rw-r--r--data/text/common_2.asm6
-rw-r--r--data/wild/bug_contest_mons.asm13
-rwxr-xr-xengine/events/happiness_egg.asm2
-rwxr-xr-xengine/events/overworld.asm8
-rwxr-xr-xengine/events/specials.asm13
-rw-r--r--engine/events/trainer_scripts.asm31
-rwxr-xr-xengine/items/item_effects.asm4
-rwxr-xr-xengine/items/items.asm2
-rw-r--r--engine/overworld/events.asm1585
-rwxr-xr-xengine/overworld/map_objects.asm8
-rwxr-xr-xengine/overworld/npc_movement.asm2
-rwxr-xr-xengine/overworld/player_movement.asm4
-rwxr-xr-xengine/overworld/player_object.asm14
-rwxr-xr-xengine/overworld/player_step.asm2
-rw-r--r--engine/overworld/scripting.asm2673
-rwxr-xr-xengine/overworld/time.asm10
-rwxr-xr-xengine/overworld/variables.asm2
-rwxr-xr-xengine/pokemon/move_mon.asm4
-rwxr-xr-xhome/region.asm4
-rwxr-xr-xhram.asm2
-rw-r--r--layout.link5
-rw-r--r--macros/legacy.asm1
-rw-r--r--macros/scripts/events.asm42
-rw-r--r--main.asm90
-rw-r--r--wram.asm168
34 files changed, 5127 insertions, 660 deletions
diff --git a/Makefile b/Makefile
index 33ba7f5e..88ed3f9b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,9 @@ home.o \
main.o \
wram.o \
data/text/common.o \
+data/maps/map_data.o \
data/pokemon/dex_entries.o \
+engine/overworld/events.o \
gfx/sprites.o
# Distinguish asm files which are game-exclusive for building (*_[gold|silver].asm)
diff --git a/constants/map_constants.asm b/constants/map_constants.asm
index 8d9762d9..c6df95c8 100644
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -28,448 +28,448 @@ ENDM
; map group ids
const_def
- newgroup ; 1
-
- map_const OLIVINE_POKECENTER_1F, 5, 4 ; 1
- map_const OLIVINE_GYM, 5, 8 ; 2
- map_const OLIVINE_TIMS_HOUSE, 4, 4 ; 3
- map_const OLIVINE_HOUSE_BETA, 4, 4 ; 4
- map_const OLIVINE_PUNISHMENT_SPEECH_HOUSE, 4, 4 ; 5
- map_const OLIVINE_GOOD_ROD_HOUSE, 4, 4 ; 6
- map_const OLIVINE_CAFE, 4, 4 ; 7
- map_const OLIVINE_MART, 6, 4 ; 8
- map_const ROUTE_38_ECRUTEAK_GATE, 5, 4 ; 9
- map_const ROUTE_39_BARN, 4, 4 ; 10
- map_const ROUTE_39_FARMHOUSE, 4, 4 ; 11
- map_const ROUTE_38, 20, 9 ; 12
- map_const ROUTE_39, 10, 18 ; 13
- map_const OLIVINE_CITY, 20, 18 ; 14
-
- newgroup ; 2
-
- map_const MAHOGANY_RED_GYARADOS_SPEECH_HOUSE, 4, 4 ; 1
- map_const MAHOGANY_GYM, 5, 9 ; 2
- map_const MAHOGANY_POKECENTER_1F, 5, 4 ; 3
- map_const ROUTE_42_ECRUTEAK_GATE, 5, 4 ; 4
- map_const ROUTE_42, 30, 9 ; 5
- map_const ROUTE_44, 30, 9 ; 6
- map_const MAHOGANY_TOWN, 10, 9 ; 7
-
- newgroup ; 3
-
- map_const SPROUT_TOWER_1F, 10, 8 ; 1
- map_const SPROUT_TOWER_2F, 10, 8 ; 2
- map_const SPROUT_TOWER_3F, 10, 8 ; 3
- map_const TIN_TOWER_1F, 10, 9 ; 4
- map_const TIN_TOWER_2F, 10, 9 ; 5
- map_const TIN_TOWER_3F, 10, 9 ; 6
- map_const TIN_TOWER_4F, 10, 9 ; 7
- map_const TIN_TOWER_5F, 10, 9 ; 8
- map_const TIN_TOWER_6F, 10, 9 ; 9
- map_const TIN_TOWER_7F, 10, 9 ; 10
- map_const TIN_TOWER_8F, 10, 9 ; 11
- map_const TIN_TOWER_9F, 10, 9 ; 12
- map_const BURNED_TOWER_1F, 10, 9 ; 13
- map_const BURNED_TOWER_B1F, 10, 9 ; 14
- map_const NATIONAL_PARK, 20, 27 ; 15
- map_const NATIONAL_PARK_BUG_CONTEST, 20, 27 ; 16
- map_const RADIO_TOWER_1F, 9, 4 ; 17
- map_const RADIO_TOWER_2F, 9, 4 ; 18
- map_const RADIO_TOWER_3F, 9, 4 ; 19
- map_const RADIO_TOWER_4F, 9, 4 ; 20
- map_const RADIO_TOWER_5F, 9, 4 ; 21
- map_const RUINS_OF_ALPH_OUTSIDE, 10, 18 ; 22
- map_const RUINS_OF_ALPH_HO_OH_CHAMBER, 4, 5 ; 23
- map_const RUINS_OF_ALPH_KABUTO_CHAMBER, 4, 5 ; 24
- map_const RUINS_OF_ALPH_OMANYTE_CHAMBER, 4, 5 ; 25
- map_const RUINS_OF_ALPH_AERODACTYL_CHAMBER, 4, 5 ; 26
- map_const RUINS_OF_ALPH_INNER_CHAMBER, 10, 14 ; 27
- map_const RUINS_OF_ALPH_RESEARCH_CENTER, 4, 4 ; 28
- map_const UNION_CAVE_1F, 10, 18 ; 37
- map_const UNION_CAVE_B1F, 10, 18 ; 38
- map_const UNION_CAVE_B2F, 10, 18 ; 39
- map_const SLOWPOKE_WELL_B1F, 10, 9 ; 40
- map_const SLOWPOKE_WELL_B2F, 10, 9 ; 41
- map_const OLIVINE_LIGHTHOUSE_1F, 10, 9 ; 42
- map_const OLIVINE_LIGHTHOUSE_2F, 10, 9 ; 43
- map_const OLIVINE_LIGHTHOUSE_3F, 10, 9 ; 44
- map_const OLIVINE_LIGHTHOUSE_4F, 10, 9 ; 45
- map_const OLIVINE_LIGHTHOUSE_5F, 10, 9 ; 46
- map_const OLIVINE_LIGHTHOUSE_6F, 10, 9 ; 47
- map_const MAHOGANY_MART_1F, 4, 4 ; 48
- map_const TEAM_ROCKET_BASE_B1F, 15, 9 ; 49
- map_const TEAM_ROCKET_BASE_B2F, 15, 9 ; 50
- map_const TEAM_ROCKET_BASE_B3F, 15, 9 ; 51
- map_const ILEX_FOREST, 15, 27 ; 52
- map_const GOLDENROD_UNDERGROUND, 15, 18 ; 53
- map_const GOLDENROD_UNDERGROUND_SWITCH_ROOM_ENTRANCES,15, 18 ; 54
- map_const GOLDENROD_DEPT_STORE_B1F, 10, 9 ; 55
- map_const GOLDENROD_UNDERGROUND_WAREHOUSE, 10, 9 ; 56
- map_const MOUNT_MORTAR_1F_OUTSIDE, 20, 18 ; 57
- map_const MOUNT_MORTAR_1F_INSIDE, 20, 27 ; 58
- map_const MOUNT_MORTAR_2F_INSIDE, 20, 18 ; 59
- map_const MOUNT_MORTAR_B1F, 20, 18 ; 60
- map_const ICE_PATH_1F, 20, 18 ; 61
- map_const ICE_PATH_B1F, 10, 18 ; 62
- map_const ICE_PATH_B2F_MAHOGANY_SIDE, 10, 9 ; 63
- map_const ICE_PATH_B2F_BLACKTHORN_SIDE, 5, 9 ; 64
- map_const ICE_PATH_B3F, 10, 9 ; 65
- map_const WHIRL_ISLAND_NW, 5, 9 ; 66
- map_const WHIRL_ISLAND_NE, 10, 9 ; 67
- map_const WHIRL_ISLAND_SW, 10, 9 ; 68
- map_const WHIRL_ISLAND_CAVE, 5, 9 ; 69
- map_const WHIRL_ISLAND_SE, 5, 9 ; 70
- map_const WHIRL_ISLAND_B1F, 20, 18 ; 71
- map_const WHIRL_ISLAND_B2F, 10, 18 ; 72
- map_const WHIRL_ISLAND_LUGIA_CHAMBER, 10, 9 ; 73
- map_const SILVER_CAVE_ROOM_1, 10, 18 ; 74
- map_const SILVER_CAVE_ROOM_2, 15, 18 ; 75
- map_const SILVER_CAVE_ROOM_3, 10, 18 ; 76
- map_const SILVER_CAVE_ITEM_ROOMS, 10, 9 ; 77
- map_const DARK_CAVE_VIOLET_ENTRANCE, 20, 18 ; 78
- map_const DARK_CAVE_BLACKTHORN_ENTRANCE, 15, 18 ; 79
- map_const DRAGONS_DEN_1F, 5, 9 ; 80
- map_const DRAGONS_DEN_B1F, 20, 18 ; 81
- map_const TOHJO_FALLS, 15, 9 ; 83
- map_const DIGLETTS_CAVE, 10, 18 ; 84
- map_const MOUNT_MOON, 15, 9 ; 85
- map_const UNDERGROUND_PATH, 3, 14 ; 86
- map_const ROCK_TUNNEL_1F, 15, 18 ; 87
- map_const ROCK_TUNNEL_B1F, 15, 18 ; 88
- map_const SAFARI_ZONE_FUCHSIA_GATE_BETA, 5, 4 ; 89
- map_const SAFARI_ZONE_BETA, 10, 18 ; 90
- map_const VICTORY_ROAD, 10, 36 ; 91
-
- newgroup ; 4
-
- map_const ECRUTEAK_TIN_TOWER_ENTRANCE, 10, 9 ; 1
- map_const WISE_TRIOS_ROOM, 4, 4 ; 2
- map_const ECRUTEAK_POKECENTER_1F, 5, 4 ; 3
- map_const ECRUTEAK_LUGIA_SPEECH_HOUSE, 4, 4 ; 4
- map_const DANCE_THEATRE, 6, 7 ; 5
- map_const ECRUTEAK_MART, 6, 4 ; 6
- map_const ECRUTEAK_GYM, 5, 9 ; 7
- map_const ECRUTEAK_ITEMFINDER_HOUSE, 4, 4 ; 8
- map_const ECRUTEAK_CITY, 20, 18 ; 9
-
- newgroup ; 5
-
- map_const BLACKTHORN_GYM_1F, 5, 9 ; 1
- map_const BLACKTHORN_GYM_2F, 5, 9 ; 2
- map_const BLACKTHORN_DRAGON_SPEECH_HOUSE, 4, 4 ; 3
- map_const BLACKTHORN_EMYS_HOUSE, 4, 4 ; 4
- map_const BLACKTHORN_MART, 6, 4 ; 5
- map_const BLACKTHORN_POKECENTER_1F, 5, 4 ; 6
- map_const MOVE_DELETERS_HOUSE, 4, 4 ; 7
- map_const ROUTE_45, 10, 45 ; 8
- map_const ROUTE_46, 10, 18 ; 9
- map_const BLACKTHORN_CITY, 20, 18 ; 10
-
- newgroup ; 6
-
- map_const CINNABAR_POKECENTER_1F, 5, 4 ; 1
- map_const CINNABAR_POKECENTER_2F_BETA, 8, 4 ; 2
- map_const ROUTE_19_FUCHSIA_GATE, 5, 4 ; 3
- map_const SEAFOAM_GYM, 5, 4 ; 4
- map_const ROUTE_19, 10, 18 ; 5
- map_const ROUTE_20, 30, 9 ; 6
- map_const ROUTE_21, 10, 18 ; 7
- map_const CINNABAR_ISLAND, 10, 9 ; 8
-
- newgroup ; 7
-
- map_const CERULEAN_GYM_BADGE_SPEECH_HOUSE, 4, 4 ; 1
- map_const CERULEAN_POLICE_STATION, 4, 4 ; 2
- map_const CERULEAN_TRADE_SPEECH_HOUSE, 4, 4 ; 3
- map_const CERULEAN_POKECENTER_1F, 5, 4 ; 4
- map_const CERULEAN_POKECENTER_2F_BETA, 8, 4 ; 5
- map_const CERULEAN_GYM, 5, 8 ; 6
- map_const CERULEAN_MART, 6, 4 ; 7
- map_const ROUTE_10_POKECENTER_1F, 5, 4 ; 8
- map_const ROUTE_10_POKECENTER_2F_BETA, 8, 4 ; 9
- map_const POWER_PLANT, 10, 9 ; 10
- map_const BILLS_HOUSE, 4, 4 ; 11
- map_const ROUTE_4, 20, 9 ; 12
- map_const ROUTE_9, 30, 9 ; 13
- map_const ROUTE_10_NORTH, 10, 9 ; 14
- map_const ROUTE_24, 10, 9 ; 15
- map_const ROUTE_25, 30, 9 ; 16
- map_const CERULEAN_CITY, 20, 18 ; 17
-
- newgroup ; 8
-
- map_const AZALEA_POKECENTER_1F, 5, 4 ; 1
- map_const CHARCOAL_KILN, 4, 4 ; 2
- map_const AZALEA_MART, 6, 4 ; 3
- map_const KURTS_HOUSE, 8, 4 ; 4
- map_const AZALEA_GYM, 5, 8 ; 5
- map_const ROUTE_33, 10, 9 ; 6
- map_const AZALEA_TOWN, 20, 9 ; 7
-
- newgroup ; 9
-
- map_const LAKE_OF_RAGE_HIDDEN_POWER_HOUSE, 4, 4 ; 1
- map_const LAKE_OF_RAGE_MAGIKARP_HOUSE, 4, 4 ; 2
- map_const ROUTE_43_MAHOGANY_GATE, 5, 4 ; 3
- map_const ROUTE_43_GATE, 5, 4 ; 4
- map_const ROUTE_43, 10, 27 ; 5
- map_const LAKE_OF_RAGE, 20, 18 ; 6
-
- newgroup ; 10
-
- map_const ROUTE_32, 10, 45 ; 1
- map_const ROUTE_35, 10, 18 ; 2
- map_const ROUTE_36, 30, 9 ; 3
- map_const ROUTE_37, 10, 9 ; 4
- map_const VIOLET_CITY, 20, 18 ; 5
- map_const VIOLET_MART, 6, 4 ; 6
- map_const VIOLET_GYM, 5, 8 ; 7
- map_const EARLS_POKEMON_ACADEMY, 4, 8 ; 8
- map_const VIOLET_NICKNAME_SPEECH_HOUSE, 4, 4 ; 9
- map_const VIOLET_POKECENTER_1F, 5, 4 ; 10
- map_const VIOLET_KYLES_HOUSE, 4, 4 ; 11
- map_const ROUTE_32_RUINS_OF_ALPH_GATE, 5, 4 ; 12
- map_const ROUTE_32_POKECENTER_1F, 5, 4 ; 13
- map_const ROUTE_35_GOLDENROD_GATE, 5, 4 ; 14
- map_const ROUTE_35_NATIONAL_PARK_GATE, 4, 4 ; 15
- map_const ROUTE_36_RUINS_OF_ALPH_GATE, 5, 4 ; 16
- map_const ROUTE_36_NATIONAL_PARK_GATE, 5, 4 ; 17
-
- newgroup ; 11
-
- map_const ROUTE_34, 10, 27 ; 1
- map_const GOLDENROD_CITY, 20, 18 ; 2
- map_const GOLDENROD_GYM, 10, 9 ; 3
- map_const GOLDENROD_BIKE_SHOP, 4, 4 ; 4
- map_const GOLDENROD_HAPPINESS_RATER, 4, 4 ; 5
- map_const BILLS_FAMILYS_HOUSE, 4, 4 ; 6
- map_const GOLDENROD_MAGNET_TRAIN_STATION, 10, 9 ; 7
- map_const GOLDENROD_FLOWER_SHOP, 4, 4 ; 8
- map_const GOLDENROD_POKECENTER_1F, 5, 4 ; 9
- map_const GOLDENROD_PP_SPEECH_HOUSE, 4, 4 ; 10
- map_const GOLDENROD_NAME_RATER, 4, 4 ; 11
- map_const GOLDENROD_DEPT_STORE_1F, 8, 4 ; 12
- map_const GOLDENROD_DEPT_STORE_2F, 8, 4 ; 13
- map_const GOLDENROD_DEPT_STORE_3F, 8, 4 ; 14
- map_const GOLDENROD_DEPT_STORE_4F, 8, 4 ; 15
- map_const GOLDENROD_DEPT_STORE_5F, 8, 4 ; 16
- map_const GOLDENROD_DEPT_STORE_6F, 8, 4 ; 17
- map_const GOLDENROD_DEPT_STORE_ELEVATOR, 2, 2 ; 18
- map_const GOLDENROD_GAME_CORNER, 10, 7 ; 19
- map_const ILEX_FOREST_AZALEA_GATE, 5, 4 ; 20
- map_const ROUTE_34_ILEX_FOREST_GATE, 5, 4 ; 21
- map_const DAY_CARE, 5, 4 ; 22
-
- newgroup ; 12
-
- map_const ROUTE_6, 10, 9 ; 1
- map_const ROUTE_11, 20, 9 ; 2
- map_const VERMILION_CITY, 20, 18 ; 3
- map_const VERMILION_FISHING_SPEECH_HOUSE, 4, 4 ; 4
- map_const VERMILION_POKECENTER_1F, 5, 4 ; 5
- map_const VERMILION_POKECENTER_2F_BETA, 8, 4 ; 6
- map_const POKEMON_FAN_CLUB, 5, 4 ; 7
- map_const VERMILION_MAGNET_TRAIN_SPEECH_HOUSE, 4, 4 ; 8
- map_const VERMILION_MART, 6, 4 ; 9
- map_const VERMILION_DIGLETTS_CAVE_SPEECH_HOUSE, 4, 4 ; 10
- map_const VERMILION_GYM, 5, 9 ; 11
- map_const ROUTE_6_SAFFRON_GATE, 5, 4 ; 12
- map_const ROUTE_6_UNDERGROUND_PATH_ENTRANCE, 4, 4 ; 13
-
- newgroup ; 13
-
- map_const ROUTE_1, 10, 18 ; 1
- map_const PALLET_TOWN, 10, 9 ; 2
- map_const REDS_HOUSE_1F, 4, 4 ; 3
- map_const REDS_HOUSE_2F, 4, 4 ; 4
- map_const BLUES_HOUSE, 4, 4 ; 5
- map_const OAKS_LAB, 5, 6 ; 6
-
- newgroup ; 14
-
- map_const ROUTE_3, 30, 9 ; 1
- map_const PEWTER_CITY, 20, 18 ; 2
- map_const PEWTER_NIDORAN_SPEECH_HOUSE, 4, 4 ; 3
- map_const PEWTER_GYM, 5, 7 ; 4
- map_const PEWTER_MART, 6, 4 ; 5
- map_const PEWTER_POKECENTER_1F, 5, 4 ; 6
- map_const PEWTER_POKECENTER_2F_BETA, 8, 4 ; 7
- map_const PEWTER_SNOOZE_SPEECH_HOUSE, 4, 4 ; 8
-
- newgroup ; 15
-
- map_const OLIVINE_PORT, 10, 18 ; 1
- map_const VERMILION_PORT, 10, 18 ; 2
- map_const FAST_SHIP_1F, 16, 9 ; 3
- map_const FAST_SHIP_CABINS_NNW_NNE_NE, 4, 16 ; 4
- map_const FAST_SHIP_CABINS_SW_SSW_NW, 4, 16 ; 5
- map_const FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN, 5, 17 ; 6
- map_const FAST_SHIP_B1F, 16, 8 ; 7
- map_const OLIVINE_PORT_PASSAGE, 10, 9 ; 8
- map_const VERMILION_PORT_PASSAGE, 10, 9 ; 9
- map_const MOUNT_MOON_SQUARE, 15, 9 ; 10
- map_const MOUNT_MOON_GIFT_SHOP, 4, 4 ; 11
- map_const TIN_TOWER_ROOF, 10, 9 ; 12
-
- newgroup ; 16
-
- map_const ROUTE_23, 10, 9 ; 1
- map_const INDIGO_PLATEAU_POKECENTER_1F, 9, 7 ; 2
- map_const WILLS_ROOM, 5, 9 ; 3
- map_const KOGAS_ROOM, 5, 9 ; 4
- map_const BRUNOS_ROOM, 5, 9 ; 5
- map_const KARENS_ROOM, 5, 9 ; 6
- map_const LANCES_ROOM, 5, 12 ; 7
- map_const HALL_OF_FAME, 5, 7 ; 8
-
- newgroup ; 17
-
- map_const ROUTE_13, 30, 9 ; 1
- map_const ROUTE_14, 10, 18 ; 2
- map_const ROUTE_15, 20, 9 ; 3
- map_const ROUTE_18, 10, 9 ; 4
- map_const FUCHSIA_CITY, 20, 18 ; 5
- map_const FUCHSIA_MART, 6, 4 ; 6
- map_const SAFARI_ZONE_MAIN_OFFICE, 4, 4 ; 7
- map_const FUCHSIA_GYM, 5, 9 ; 8
- map_const BILLS_BROTHERS_HOUSE, 4, 4 ; 9
- map_const FUCHSIA_POKECENTER_1F, 5, 4 ; 10
- map_const FUCHSIA_POKECENTER_2F_BETA, 8, 4 ; 11
- map_const SAFARI_ZONE_WARDENS_HOME, 5, 4 ; 12
- map_const ROUTE_15_FUCHSIA_GATE, 5, 4 ; 13
-
- newgroup ; 18
-
- map_const ROUTE_8, 20, 9 ; 1
- map_const ROUTE_12, 10, 27 ; 2
- map_const ROUTE_10_SOUTH, 10, 9 ; 3
- map_const LAVENDER_TOWN, 10, 9 ; 4
- map_const LAVENDER_POKECENTER_1F, 5, 4 ; 5
- map_const LAVENDER_POKECENTER_2F_BETA, 8, 4 ; 6
- map_const MR_FUJIS_HOUSE, 5, 4 ; 7
- map_const LAVENDER_SPEECH_HOUSE, 4, 4 ; 8
- map_const LAVENDER_NAME_RATER, 4, 4 ; 9
- map_const LAVENDER_MART, 6, 4 ; 10
- map_const SOUL_HOUSE, 5, 4 ; 11
- map_const LAV_RADIO_TOWER_1F, 10, 4 ; 12
- map_const ROUTE_8_SAFFRON_GATE, 5, 4 ; 13
- map_const ROUTE_12_SUPER_ROD_HOUSE, 4, 4 ; 14
-
- newgroup ; 19
-
- map_const ROUTE_28, 20, 9 ; 1
- map_const SILVER_CAVE_OUTSIDE, 20, 18 ; 2
- map_const SILVER_CAVE_POKECENTER_1F, 5, 4 ; 3
- map_const ROUTE_28_STEEL_WING_HOUSE, 4, 4 ; 4
-
- newgroup ; 20
-
- map_const POKECENTER_2F, 8, 4 ; 1
- map_const TRADE_CENTER, 5, 4 ; 2
- map_const COLOSSEUM, 5, 4 ; 3
- map_const TIME_CAPSULE, 5, 4 ; 4
-
- newgroup ; 21
-
- map_const ROUTE_7, 10, 9 ; 1
- map_const ROUTE_16, 10, 9 ; 2
- map_const ROUTE_17, 10, 45 ; 3
- map_const CELADON_CITY, 20, 18 ; 4
- map_const CELADON_DEPT_STORE_1F, 8, 4 ; 5
- map_const CELADON_DEPT_STORE_2F, 8, 4 ; 6
- map_const CELADON_DEPT_STORE_3F, 8, 4 ; 7
- map_const CELADON_DEPT_STORE_4F, 8, 4 ; 8
- map_const CELADON_DEPT_STORE_5F, 8, 4 ; 9
- map_const CELADON_DEPT_STORE_6F, 8, 4 ; 10
- map_const CELADON_DEPT_STORE_ELEVATOR, 2, 2 ; 11
- map_const CELADON_MANSION_1F, 4, 5 ; 12
- map_const CELADON_MANSION_2F, 4, 5 ; 13
- map_const CELADON_MANSION_3F, 4, 5 ; 14
- map_const CELADON_MANSION_ROOF, 4, 5 ; 15
- map_const CELADON_MANSION_ROOF_HOUSE, 4, 4 ; 16
- map_const CELADON_POKECENTER_1F, 5, 4 ; 17
- map_const CELADON_POKECENTER_2F_BETA, 8, 4 ; 18
- map_const CELADON_GAME_CORNER, 10, 7 ; 19
- map_const CELADON_GAME_CORNER_PRIZE_ROOM, 3, 3 ; 20
- map_const CELADON_GYM, 5, 9 ; 21
- map_const CELADON_CAFE, 6, 4 ; 22
- map_const ROUTE_16_FUCHSIA_SPEECH_HOUSE, 4, 4 ; 23
- map_const ROUTE_16_GATE, 5, 4 ; 24
- map_const ROUTE_7_SAFFRON_GATE, 5, 4 ; 25
- map_const ROUTE_17_ROUTE_18_GATE, 5, 4 ; 26
-
- newgroup ; 22
-
- map_const ROUTE_40, 10, 18 ; 1
- map_const ROUTE_41, 25, 27 ; 2
- map_const CIANWOOD_CITY, 15, 27 ; 3
- map_const MANIAS_HOUSE, 4, 4 ; 4
- map_const CIANWOOD_GYM, 5, 9 ; 5
- map_const CIANWOOD_POKECENTER_1F, 5, 4 ; 6
- map_const CIANWOOD_PHARMACY, 4, 4 ; 7
- map_const CIANWOOD_PHOTO_STUDIO, 4, 4 ; 8
- map_const CIANWOOD_LUGIA_SPEECH_HOUSE, 4, 4 ; 9
-
- newgroup ; 23
-
- map_const ROUTE_2, 10, 27 ; 1
- map_const ROUTE_22, 20, 9 ; 2
- map_const VIRIDIAN_CITY, 20, 18 ; 3
- map_const VIRIDIAN_GYM, 5, 9 ; 4
- map_const VIRIDIAN_NICKNAME_SPEECH_HOUSE, 4, 4 ; 5
- map_const TRAINER_HOUSE_1F, 5, 7 ; 6
- map_const TRAINER_HOUSE_B1F, 5, 8 ; 7
- map_const VIRIDIAN_MART, 6, 4 ; 8
- map_const VIRIDIAN_POKECENTER_1F, 5, 4 ; 9
- map_const VIRIDIAN_POKECENTER_2F_BETA, 8, 4 ; 10
- map_const ROUTE_2_NUGGET_HOUSE, 4, 4 ; 11
- map_const ROUTE_2_GATE, 5, 4 ; 12
- map_const VICTORY_ROAD_GATE, 10, 9 ; 13
-
- newgroup ; 24
-
- map_const ROUTE_26, 10, 54 ; 1
- map_const ROUTE_27, 40, 9 ; 2
- map_const ROUTE_29, 30, 9 ; 3
- map_const NEW_BARK_TOWN, 10, 9 ; 4
- map_const ELMS_LAB, 5, 6 ; 5
- map_const PLAYERS_HOUSE_1F, 5, 4 ; 6
- map_const PLAYERS_HOUSE_2F, 4, 3 ; 7
- map_const PLAYERS_NEIGHBORS_HOUSE, 4, 4 ; 8
- map_const ELMS_HOUSE, 4, 4 ; 9
- map_const ROUTE_26_HEAL_HOUSE, 4, 4 ; 10
- map_const DAY_OF_WEEK_SIBLINGS_HOUSE, 4, 4 ; 11
- map_const ROUTE_27_SANDSTORM_HOUSE, 4, 4 ; 12
- map_const ROUTE_29_ROUTE_46_GATE, 5, 4 ; 13
-
- newgroup ; 25
-
- map_const ROUTE_5, 10, 9 ; 1
- map_const SAFFRON_CITY, 20, 18 ; 2
- map_const FIGHTING_DOJO, 5, 6 ; 3
- map_const SAFFRON_GYM, 10, 9 ; 4
- map_const SAFFRON_MART, 6, 4 ; 5
- map_const SAFFRON_POKECENTER_1F, 5, 4 ; 6
- map_const SAFFRON_POKECENTER_2F_BETA, 8, 4 ; 7
- map_const MR_PSYCHICS_HOUSE, 4, 4 ; 8
- map_const SAFFRON_MAGNET_TRAIN_STATION, 10, 9 ; 9
- map_const SILPH_CO_1F, 8, 4 ; 10
- map_const COPYCATS_HOUSE_1F, 4, 4 ; 11
- map_const COPYCATS_HOUSE_2F, 5, 3 ; 12
- map_const ROUTE_5_UNDERGROUND_PATH_ENTRANCE, 4, 4 ; 13
- map_const ROUTE_5_SAFFRON_GATE, 5, 4 ; 14
- map_const ROUTE_5_CLEANSE_TAG_HOUSE, 4, 4 ; 15
-
- newgroup ; 26
-
- map_const ROUTE_30, 10, 27 ; 1
- map_const ROUTE_31, 20, 9 ; 2
- map_const CHERRYGROVE_CITY, 20, 9 ; 3
- map_const CHERRYGROVE_MART, 6, 4 ; 4
- map_const CHERRYGROVE_POKECENTER_1F, 5, 4 ; 5
- map_const CHERRYGROVE_GYM_SPEECH_HOUSE, 4, 4 ; 6
- map_const GUIDE_GENTS_HOUSE, 4, 4 ; 7
- map_const CHERRYGROVE_EVOLUTION_SPEECH_HOUSE, 4, 4 ; 8
- map_const ROUTE_30_BERRY_HOUSE, 4, 4 ; 9
- map_const MR_POKEMONS_HOUSE, 4, 4 ; 10
- map_const ROUTE_31_VIOLET_GATE, 5, 4 ; 11
+ newgroup ; 1
+
+ map_const OLIVINE_POKECENTER_1F, 5, 4 ; 1
+ map_const OLIVINE_GYM, 5, 8 ; 2
+ map_const OLIVINE_TIMS_HOUSE, 4, 4 ; 3
+ map_const OLIVINE_HOUSE_BETA, 4, 4 ; 4
+ map_const OLIVINE_PUNISHMENT_SPEECH_HOUSE, 4, 4 ; 5
+ map_const OLIVINE_GOOD_ROD_HOUSE, 4, 4 ; 6
+ map_const OLIVINE_CAFE, 4, 4 ; 7
+ map_const OLIVINE_MART, 6, 4 ; 8
+ map_const ROUTE_38_ECRUTEAK_GATE, 5, 4 ; 9
+ map_const ROUTE_39_BARN, 4, 4 ; 10
+ map_const ROUTE_39_FARMHOUSE, 4, 4 ; 11
+ map_const ROUTE_38, 20, 9 ; 12
+ map_const ROUTE_39, 10, 18 ; 13
+ map_const OLIVINE_CITY, 20, 18 ; 14
+
+ newgroup ; 2
+
+ map_const MAHOGANY_RED_GYARADOS_SPEECH_HOUSE, 4, 4 ; 1
+ map_const MAHOGANY_GYM, 5, 9 ; 2
+ map_const MAHOGANY_POKECENTER_1F, 5, 4 ; 3
+ map_const ROUTE_42_ECRUTEAK_GATE, 5, 4 ; 4
+ map_const ROUTE_42, 30, 9 ; 5
+ map_const ROUTE_44, 30, 9 ; 6
+ map_const MAHOGANY_TOWN, 10, 9 ; 7
+
+ newgroup ; 3
+
+ map_const SPROUT_TOWER_1F, 10, 8 ; 1
+ map_const SPROUT_TOWER_2F, 10, 8 ; 2
+ map_const SPROUT_TOWER_3F, 10, 8 ; 3
+ map_const TIN_TOWER_1F, 10, 9 ; 4
+ map_const TIN_TOWER_2F, 10, 9 ; 5
+ map_const TIN_TOWER_3F, 10, 9 ; 6
+ map_const TIN_TOWER_4F, 10, 9 ; 7
+ map_const TIN_TOWER_5F, 10, 9 ; 8
+ map_const TIN_TOWER_6F, 10, 9 ; 9
+ map_const TIN_TOWER_7F, 10, 9 ; 10
+ map_const TIN_TOWER_8F, 10, 9 ; 11
+ map_const TIN_TOWER_9F, 10, 9 ; 12
+ map_const BURNED_TOWER_1F, 10, 9 ; 13
+ map_const BURNED_TOWER_B1F, 10, 9 ; 14
+ map_const NATIONAL_PARK, 20, 27 ; 15
+ map_const NATIONAL_PARK_BUG_CONTEST, 20, 27 ; 16
+ map_const RADIO_TOWER_1F, 9, 4 ; 17
+ map_const RADIO_TOWER_2F, 9, 4 ; 18
+ map_const RADIO_TOWER_3F, 9, 4 ; 19
+ map_const RADIO_TOWER_4F, 9, 4 ; 20
+ map_const RADIO_TOWER_5F, 9, 4 ; 21
+ map_const RUINS_OF_ALPH_OUTSIDE, 10, 18 ; 22
+ map_const RUINS_OF_ALPH_HO_OH_CHAMBER, 4, 5 ; 23
+ map_const RUINS_OF_ALPH_KABUTO_CHAMBER, 4, 5 ; 24
+ map_const RUINS_OF_ALPH_OMANYTE_CHAMBER, 4, 5 ; 25
+ map_const RUINS_OF_ALPH_AERODACTYL_CHAMBER, 4, 5 ; 26
+ map_const RUINS_OF_ALPH_INNER_CHAMBER, 10, 14 ; 27
+ map_const RUINS_OF_ALPH_RESEARCH_CENTER, 4, 4 ; 28
+ map_const UNION_CAVE_1F, 10, 18 ; 29
+ map_const UNION_CAVE_B1F, 10, 18 ; 30
+ map_const UNION_CAVE_B2F, 10, 18 ; 31
+ map_const SLOWPOKE_WELL_B1F, 10, 9 ; 32
+ map_const SLOWPOKE_WELL_B2F, 10, 9 ; 33
+ map_const OLIVINE_LIGHTHOUSE_1F, 10, 9 ; 34
+ map_const OLIVINE_LIGHTHOUSE_2F, 10, 9 ; 35
+ map_const OLIVINE_LIGHTHOUSE_3F, 10, 9 ; 36
+ map_const OLIVINE_LIGHTHOUSE_4F, 10, 9 ; 37
+ map_const OLIVINE_LIGHTHOUSE_5F, 10, 9 ; 38
+ map_const OLIVINE_LIGHTHOUSE_6F, 10, 9 ; 39
+ map_const MAHOGANY_MART_1F, 4, 4 ; 40
+ map_const TEAM_ROCKET_BASE_B1F, 15, 9 ; 41
+ map_const TEAM_ROCKET_BASE_B2F, 15, 9 ; 42
+ map_const TEAM_ROCKET_BASE_B3F, 15, 9 ; 43
+ map_const ILEX_FOREST, 15, 27 ; 44
+ map_const GOLDENROD_UNDERGROUND, 15, 18 ; 45
+ map_const GOLDENROD_UNDERGROUND_SWITCH_ROOM_ENTRANCES, 15, 18 ; 46
+ map_const GOLDENROD_DEPT_STORE_B1F, 10, 9 ; 47
+ map_const GOLDENROD_UNDERGROUND_WAREHOUSE, 10, 9 ; 48
+ map_const MOUNT_MORTAR_1F_OUTSIDE, 20, 18 ; 49
+ map_const MOUNT_MORTAR_1F_INSIDE, 20, 27 ; 50
+ map_const MOUNT_MORTAR_2F_INSIDE, 20, 18 ; 51
+ map_const MOUNT_MORTAR_B1F, 20, 18 ; 52
+ map_const ICE_PATH_1F, 20, 18 ; 53
+ map_const ICE_PATH_B1F, 10, 18 ; 54
+ map_const ICE_PATH_B2F_MAHOGANY_SIDE, 10, 9 ; 55
+ map_const ICE_PATH_B2F_BLACKTHORN_SIDE, 5, 9 ; 56
+ map_const ICE_PATH_B3F, 10, 9 ; 57
+ map_const WHIRL_ISLAND_NW, 5, 9 ; 58
+ map_const WHIRL_ISLAND_NE, 10, 9 ; 59
+ map_const WHIRL_ISLAND_SW, 10, 9 ; 60
+ map_const WHIRL_ISLAND_CAVE, 5, 9 ; 61
+ map_const WHIRL_ISLAND_SE, 5, 9 ; 62
+ map_const WHIRL_ISLAND_B1F, 20, 18 ; 63
+ map_const WHIRL_ISLAND_B2F, 10, 18 ; 64
+ map_const WHIRL_ISLAND_LUGIA_CHAMBER, 10, 9 ; 65
+ map_const SILVER_CAVE_ROOM_1, 10, 18 ; 66
+ map_const SILVER_CAVE_ROOM_2, 15, 18 ; 67
+ map_const SILVER_CAVE_ROOM_3, 10, 18 ; 68
+ map_const SILVER_CAVE_ITEM_ROOMS, 10, 9 ; 69
+ map_const DARK_CAVE_VIOLET_ENTRANCE, 20, 18 ; 70
+ map_const DARK_CAVE_BLACKTHORN_ENTRANCE, 15, 18 ; 71
+ map_const DRAGONS_DEN_1F, 5, 9 ; 72
+ map_const DRAGONS_DEN_B1F, 20, 18 ; 73
+ map_const TOHJO_FALLS, 15, 9 ; 74
+ map_const DIGLETTS_CAVE, 10, 18 ; 75
+ map_const MOUNT_MOON, 15, 9 ; 76
+ map_const UNDERGROUND_PATH, 3, 14 ; 77
+ map_const ROCK_TUNNEL_1F, 15, 18 ; 78
+ map_const ROCK_TUNNEL_B1F, 15, 18 ; 79
+ map_const SAFARI_ZONE_FUCHSIA_GATE_BETA, 5, 4 ; 80
+ map_const SAFARI_ZONE_BETA, 10, 18 ; 81
+ map_const VICTORY_ROAD, 10, 36 ; 82
+
+ newgroup ; 4
+
+ map_const ECRUTEAK_TIN_TOWER_ENTRANCE, 10, 9 ; 1
+ map_const WISE_TRIOS_ROOM, 4, 4 ; 2
+ map_const ECRUTEAK_POKECENTER_1F, 5, 4 ; 3
+ map_const ECRUTEAK_LUGIA_SPEECH_HOUSE, 4, 4 ; 4
+ map_const DANCE_THEATRE, 6, 7 ; 5
+ map_const ECRUTEAK_MART, 6, 4 ; 6
+ map_const ECRUTEAK_GYM, 5, 9 ; 7
+ map_const ECRUTEAK_ITEMFINDER_HOUSE, 4, 4 ; 8
+ map_const ECRUTEAK_CITY, 20, 18 ; 9
+
+ newgroup ; 5
+
+ map_const BLACKTHORN_GYM_1F, 5, 9 ; 1
+ map_const BLACKTHORN_GYM_2F, 5, 9 ; 2
+ map_const BLACKTHORN_DRAGON_SPEECH_HOUSE, 4, 4 ; 3
+ map_const BLACKTHORN_EMYS_HOUSE, 4, 4 ; 4
+ map_const BLACKTHORN_MART, 6, 4 ; 5
+ map_const BLACKTHORN_POKECENTER_1F, 5, 4 ; 6
+ map_const MOVE_DELETERS_HOUSE, 4, 4 ; 7
+ map_const ROUTE_45, 10, 45 ; 8
+ map_const ROUTE_46, 10, 18 ; 9
+ map_const BLACKTHORN_CITY, 20, 18 ; 10
+
+ newgroup ; 6
+
+ map_const CINNABAR_POKECENTER_1F, 5, 4 ; 1
+ map_const CINNABAR_POKECENTER_2F_BETA, 8, 4 ; 2
+ map_const ROUTE_19_FUCHSIA_GATE, 5, 4 ; 3
+ map_const SEAFOAM_GYM, 5, 4 ; 4
+ map_const ROUTE_19, 10, 18 ; 5
+ map_const ROUTE_20, 30, 9 ; 6
+ map_const ROUTE_21, 10, 18 ; 7
+ map_const CINNABAR_ISLAND, 10, 9 ; 8
+
+ newgroup ; 7
+
+ map_const CERULEAN_GYM_BADGE_SPEECH_HOUSE, 4, 4 ; 1
+ map_const CERULEAN_POLICE_STATION, 4, 4 ; 2
+ map_const CERULEAN_TRADE_SPEECH_HOUSE, 4, 4 ; 3
+ map_const CERULEAN_POKECENTER_1F, 5, 4 ; 4
+ map_const CERULEAN_POKECENTER_2F_BETA, 8, 4 ; 5
+ map_const CERULEAN_GYM, 5, 8 ; 6
+ map_const CERULEAN_MART, 6, 4 ; 7
+ map_const ROUTE_10_POKECENTER_1F, 5, 4 ; 8
+ map_const ROUTE_10_POKECENTER_2F_BETA, 8, 4 ; 9
+ map_const POWER_PLANT, 10, 9 ; 10
+ map_const BILLS_HOUSE, 4, 4 ; 11
+ map_const ROUTE_4, 20, 9 ; 12
+ map_const ROUTE_9, 30, 9 ; 13
+ map_const ROUTE_10_NORTH, 10, 9 ; 14
+ map_const ROUTE_24, 10, 9 ; 15
+ map_const ROUTE_25, 30, 9 ; 16
+ map_const CERULEAN_CITY, 20, 18 ; 17
+
+ newgroup ; 8
+
+ map_const AZALEA_POKECENTER_1F, 5, 4 ; 1
+ map_const CHARCOAL_KILN, 4, 4 ; 2
+ map_const AZALEA_MART, 6, 4 ; 3
+ map_const KURTS_HOUSE, 8, 4 ; 4
+ map_const AZALEA_GYM, 5, 8 ; 5
+ map_const ROUTE_33, 10, 9 ; 6
+ map_const AZALEA_TOWN, 20, 9 ; 7
+
+ newgroup ; 9
+
+ map_const LAKE_OF_RAGE_HIDDEN_POWER_HOUSE, 4, 4 ; 1
+ map_const LAKE_OF_RAGE_MAGIKARP_HOUSE, 4, 4 ; 2
+ map_const ROUTE_43_MAHOGANY_GATE, 5, 4 ; 3
+ map_const ROUTE_43_GATE, 5, 4 ; 4
+ map_const ROUTE_43, 10, 27 ; 5
+ map_const LAKE_OF_RAGE, 20, 18 ; 6
+
+ newgroup ; 10
+
+ map_const ROUTE_32, 10, 45 ; 1
+ map_const ROUTE_35, 10, 18 ; 2
+ map_const ROUTE_36, 30, 9 ; 3
+ map_const ROUTE_37, 10, 9 ; 4
+ map_const VIOLET_CITY, 20, 18 ; 5
+ map_const VIOLET_MART, 6, 4 ; 6
+ map_const VIOLET_GYM, 5, 8 ; 7
+ map_const EARLS_POKEMON_ACADEMY, 4, 8 ; 8
+ map_const VIOLET_NICKNAME_SPEECH_HOUSE, 4, 4 ; 9
+ map_const VIOLET_POKECENTER_1F, 5, 4 ; 10
+ map_const VIOLET_KYLES_HOUSE, 4, 4 ; 11
+ map_const ROUTE_32_RUINS_OF_ALPH_GATE, 5, 4 ; 12
+ map_const ROUTE_32_POKECENTER_1F, 5, 4 ; 13
+ map_const ROUTE_35_GOLDENROD_GATE, 5, 4 ; 14
+ map_const ROUTE_35_NATIONAL_PARK_GATE, 4, 4 ; 15
+ map_const ROUTE_36_RUINS_OF_ALPH_GATE, 5, 4 ; 16
+ map_const ROUTE_36_NATIONAL_PARK_GATE, 5, 4 ; 17
+
+ newgroup ; 11
+
+ map_const ROUTE_34, 10, 27 ; 1
+ map_const GOLDENROD_CITY, 20, 18 ; 2
+ map_const GOLDENROD_GYM, 10, 9 ; 3
+ map_const GOLDENROD_BIKE_SHOP, 4, 4 ; 4
+ map_const GOLDENROD_HAPPINESS_RATER, 4, 4 ; 5
+ map_const BILLS_FAMILYS_HOUSE, 4, 4 ; 6
+ map_const GOLDENROD_MAGNET_TRAIN_STATION, 10, 9 ; 7
+ map_const GOLDENROD_FLOWER_SHOP, 4, 4 ; 8
+ map_const GOLDENROD_POKECENTER_1F, 5, 4 ; 9
+ map_const GOLDENROD_PP_SPEECH_HOUSE, 4, 4 ; 10
+ map_const GOLDENROD_NAME_RATER, 4, 4 ; 11
+ map_const GOLDENROD_DEPT_STORE_1F, 8, 4 ; 12
+ map_const GOLDENROD_DEPT_STORE_2F, 8, 4 ; 13
+ map_const GOLDENROD_DEPT_STORE_3F, 8, 4 ; 14
+ map_const GOLDENROD_DEPT_STORE_4F, 8, 4 ; 15
+ map_const GOLDENROD_DEPT_STORE_5F, 8, 4 ; 16
+ map_const GOLDENROD_DEPT_STORE_6F, 8, 4 ; 17
+ map_const GOLDENROD_DEPT_STORE_ELEVATOR, 2, 2 ; 18
+ map_const GOLDENROD_GAME_CORNER, 10, 7 ; 19
+ map_const ILEX_FOREST_AZALEA_GATE, 5, 4 ; 20
+ map_const ROUTE_34_ILEX_FOREST_GATE, 5, 4 ; 21
+ map_const DAY_CARE, 5, 4 ; 22
+
+ newgroup ; 12
+
+ map_const ROUTE_6, 10, 9 ; 1
+ map_const ROUTE_11, 20, 9 ; 2
+ map_const VERMILION_CITY, 20, 18 ; 3
+ map_const VERMILION_FISHING_SPEECH_HOUSE, 4, 4 ; 4
+ map_const VERMILION_POKECENTER_1F, 5, 4 ; 5
+ map_const VERMILION_POKECENTER_2F_BETA, 8, 4 ; 6
+ map_const POKEMON_FAN_CLUB, 5, 4 ; 7
+ map_const VERMILION_MAGNET_TRAIN_SPEECH_HOUSE, 4, 4 ; 8
+ map_const VERMILION_MART, 6, 4 ; 9
+ map_const VERMILION_DIGLETTS_CAVE_SPEECH_HOUSE, 4, 4 ; 10
+ map_const VERMILION_GYM, 5, 9 ; 11
+ map_const ROUTE_6_SAFFRON_GATE, 5, 4 ; 12
+ map_const ROUTE_6_UNDERGROUND_PATH_ENTRANCE, 4, 4 ; 13
+
+ newgroup ; 13
+
+ map_const ROUTE_1, 10, 18 ; 1
+ map_const PALLET_TOWN, 10, 9 ; 2
+ map_const REDS_HOUSE_1F, 4, 4 ; 3
+ map_const REDS_HOUSE_2F, 4, 4 ; 4
+ map_const BLUES_HOUSE, 4, 4 ; 5
+ map_const OAKS_LAB, 5, 6 ; 6
+
+ newgroup ; 14
+
+ map_const ROUTE_3, 30, 9 ; 1
+ map_const PEWTER_CITY, 20, 18 ; 2
+ map_const PEWTER_NIDORAN_SPEECH_HOUSE, 4, 4 ; 3
+ map_const PEWTER_GYM, 5, 7 ; 4
+ map_const PEWTER_MART, 6, 4 ; 5
+ map_const PEWTER_POKECENTER_1F, 5, 4 ; 6
+ map_const PEWTER_POKECENTER_2F_BETA, 8, 4 ; 7
+ map_const PEWTER_SNOOZE_SPEECH_HOUSE, 4, 4 ; 8
+
+ newgroup ; 15
+
+ map_const OLIVINE_PORT, 10, 18 ; 1
+ map_const VERMILION_PORT, 10, 18 ; 2
+ map_const FAST_SHIP_1F, 16, 9 ; 3
+ map_const FAST_SHIP_CABINS_NNW_NNE_NE, 4, 16 ; 4
+ map_const FAST_SHIP_CABINS_SW_SSW_NW, 4, 16 ; 5
+ map_const FAST_SHIP_CABINS_SE_SSE_CAPTAINS_CABIN, 5, 17 ; 6
+ map_const FAST_SHIP_B1F, 16, 8 ; 7
+ map_const OLIVINE_PORT_PASSAGE, 10, 9 ; 8
+ map_const VERMILION_PORT_PASSAGE, 10, 9 ; 9
+ map_const MOUNT_MOON_SQUARE, 15, 9 ; 10
+ map_const MOUNT_MOON_GIFT_SHOP, 4, 4 ; 11
+ map_const TIN_TOWER_ROOF, 10, 9 ; 12
+
+ newgroup ; 16
+
+ map_const ROUTE_23, 10, 9 ; 1
+ map_const INDIGO_PLATEAU_POKECENTER_1F, 9, 7 ; 2
+ map_const WILLS_ROOM, 5, 9 ; 3
+ map_const KOGAS_ROOM, 5, 9 ; 4
+ map_const BRUNOS_ROOM, 5, 9 ; 5
+ map_const KARENS_ROOM, 5, 9 ; 6
+ map_const LANCES_ROOM, 5, 12 ; 7
+ map_const HALL_OF_FAME, 5, 7 ; 8
+
+ newgroup ; 17
+
+ map_const ROUTE_13, 30, 9 ; 1
+ map_const ROUTE_14, 10, 18 ; 2
+ map_const ROUTE_15, 20, 9 ; 3
+ map_const ROUTE_18, 10, 9 ; 4
+ map_const FUCHSIA_CITY, 20, 18 ; 5
+ map_const FUCHSIA_MART, 6, 4 ; 6
+ map_const SAFARI_ZONE_MAIN_OFFICE, 4, 4 ; 7
+ map_const FUCHSIA_GYM, 5, 9 ; 8
+ map_const BILLS_BROTHERS_HOUSE, 4, 4 ; 9
+ map_const FUCHSIA_POKECENTER_1F, 5, 4 ; 10
+ map_const FUCHSIA_POKECENTER_2F_BETA, 8, 4 ; 11
+ map_const SAFARI_ZONE_WARDENS_HOME, 5, 4 ; 12
+ map_const ROUTE_15_FUCHSIA_GATE, 5, 4 ; 13
+
+ newgroup ; 18
+
+ map_const ROUTE_8, 20, 9 ; 1
+ map_const ROUTE_12, 10, 27 ; 2
+ map_const ROUTE_10_SOUTH, 10, 9 ; 3
+ map_const LAVENDER_TOWN, 10, 9 ; 4
+ map_const LAVENDER_POKECENTER_1F, 5, 4 ; 5
+ map_const LAVENDER_POKECENTER_2F_BETA, 8, 4 ; 6
+ map_const MR_FUJIS_HOUSE, 5, 4 ; 7
+ map_const LAVENDER_SPEECH_HOUSE, 4, 4 ; 8
+ map_const LAVENDER_NAME_RATER, 4, 4 ; 9
+ map_const LAVENDER_MART, 6, 4 ; 10
+ map_const SOUL_HOUSE, 5, 4 ; 11
+ map_const LAV_RADIO_TOWER_1F, 10, 4 ; 12
+ map_const ROUTE_8_SAFFRON_GATE, 5, 4 ; 13
+ map_const ROUTE_12_SUPER_ROD_HOUSE, 4, 4 ; 14
+
+ newgroup ; 19
+
+ map_const ROUTE_28, 20, 9 ; 1
+ map_const SILVER_CAVE_OUTSIDE, 20, 18 ; 2
+ map_const SILVER_CAVE_POKECENTER_1F, 5, 4 ; 3
+ map_const ROUTE_28_STEEL_WING_HOUSE, 4, 4 ; 4
+
+ newgroup ; 20
+
+ map_const POKECENTER_2F, 8, 4 ; 1
+ map_const TRADE_CENTER, 5, 4 ; 2
+ map_const COLOSSEUM, 5, 4 ; 3
+ map_const TIME_CAPSULE, 5, 4 ; 4
+
+ newgroup ; 21
+
+ map_const ROUTE_7, 10, 9 ; 1
+ map_const ROUTE_16, 10, 9 ; 2
+ map_const ROUTE_17, 10, 45 ; 3
+ map_const CELADON_CITY, 20, 18 ; 4
+ map_const CELADON_DEPT_STORE_1F, 8, 4 ; 5
+ map_const CELADON_DEPT_STORE_2F, 8, 4 ; 6
+ map_const CELADON_DEPT_STORE_3F, 8, 4 ; 7
+ map_const CELADON_DEPT_STORE_4F, 8, 4 ; 8
+ map_const CELADON_DEPT_STORE_5F, 8, 4 ; 9
+ map_const CELADON_DEPT_STORE_6F, 8, 4 ; 10
+ map_const CELADON_DEPT_STORE_ELEVATOR, 2, 2 ; 11
+ map_const CELADON_MANSION_1F, 4, 5 ; 12
+ map_const CELADON_MANSION_2F, 4, 5 ; 13
+ map_const CELADON_MANSION_3F, 4, 5 ; 14
+ map_const CELADON_MANSION_ROOF, 4, 5 ; 15
+ map_const CELADON_MANSION_ROOF_HOUSE, 4, 4 ; 16
+ map_const CELADON_POKECENTER_1F, 5, 4 ; 17
+ map_const CELADON_POKECENTER_2F_BETA, 8, 4 ; 18
+ map_const CELADON_GAME_CORNER, 10, 7 ; 19
+ map_const CELADON_GAME_CORNER_PRIZE_ROOM, 3, 3 ; 20
+ map_const CELADON_GYM, 5, 9 ; 21
+ map_const CELADON_CAFE, 6, 4 ; 22
+ map_const ROUTE_16_FUCHSIA_SPEECH_HOUSE, 4, 4 ; 23
+ map_const ROUTE_16_GATE, 5, 4 ; 24
+ map_const ROUTE_7_SAFFRON_GATE, 5, 4 ; 25
+ map_const ROUTE_17_ROUTE_18_GATE, 5, 4 ; 26
+
+ newgroup ; 22
+
+ map_const ROUTE_40, 10, 18 ; 1
+ map_const ROUTE_41, 25, 27 ; 2
+ map_const CIANWOOD_CITY, 15, 27 ; 3
+ map_const MANIAS_HOUSE, 4, 4 ; 4
+ map_const CIANWOOD_GYM, 5, 9 ; 5
+ map_const CIANWOOD_POKECENTER_1F, 5, 4 ; 6
+ map_const CIANWOOD_PHARMACY, 4, 4 ; 7
+ map_const CIANWOOD_PHOTO_STUDIO, 4, 4 ; 8
+ map_const CIANWOOD_LUGIA_SPEECH_HOUSE, 4, 4 ; 9
+
+ newgroup ; 23
+
+ map_const ROUTE_2, 10, 27 ; 1
+ map_const ROUTE_22, 20, 9 ; 2
+ map_const VIRIDIAN_CITY, 20, 18 ; 3
+ map_const VIRIDIAN_GYM, 5, 9 ; 4
+ map_const VIRIDIAN_NICKNAME_SPEECH_HOUSE, 4, 4 ; 5
+ map_const TRAINER_HOUSE_1F, 5, 7 ; 6
+ map_const TRAINER_HOUSE_B1F, 5, 8 ; 7
+ map_const VIRIDIAN_MART, 6, 4 ; 8
+ map_const VIRIDIAN_POKECENTER_1F, 5, 4 ; 9
+ map_const VIRIDIAN_POKECENTER_2F_BETA, 8, 4 ; 10
+ map_const ROUTE_2_NUGGET_HOUSE, 4, 4 ; 11
+ map_const ROUTE_2_GATE, 5, 4 ; 12
+ map_const VICTORY_ROAD_GATE, 10, 9 ; 13
+
+ newgroup ; 24
+
+ map_const ROUTE_26, 10, 54 ; 1
+ map_const ROUTE_27, 40, 9 ; 2
+ map_const ROUTE_29, 30, 9 ; 3
+ map_const NEW_BARK_TOWN, 10, 9 ; 4
+ map_const ELMS_LAB, 5, 6 ; 5
+ map_const PLAYERS_HOUSE_1F, 5, 4 ; 6
+ map_const PLAYERS_HOUSE_2F, 4, 3 ; 7
+ map_const PLAYERS_NEIGHBORS_HOUSE, 4, 4 ; 8
+ map_const ELMS_HOUSE, 4, 4 ; 9
+ map_const ROUTE_26_HEAL_HOUSE, 4, 4 ; 10
+ map_const DAY_OF_WEEK_SIBLINGS_HOUSE, 4, 4 ; 11
+ map_const ROUTE_27_SANDSTORM_HOUSE, 4, 4 ; 12
+ map_const ROUTE_29_ROUTE_46_GATE, 5, 4 ; 13
+
+ newgroup ; 25
+
+ map_const ROUTE_5, 10, 9 ; 1
+ map_const SAFFRON_CITY, 20, 18 ; 2
+ map_const FIGHTING_DOJO, 5, 6 ; 3
+ map_const SAFFRON_GYM, 10, 9 ; 4
+ map_const SAFFRON_MART, 6, 4 ; 5
+ map_const SAFFRON_POKECENTER_1F, 5, 4 ; 6
+ map_const SAFFRON_POKECENTER_2F_BETA, 8, 4 ; 7
+ map_const MR_PSYCHICS_HOUSE, 4, 4 ; 8
+ map_const SAFFRON_MAGNET_TRAIN_STATION, 10, 9 ; 9
+ map_const SILPH_CO_1F, 8, 4 ; 10
+ map_const COPYCATS_HOUSE_1F, 4, 4 ; 11
+ map_const COPYCATS_HOUSE_2F, 5, 3 ; 12
+ map_const ROUTE_5_UNDERGROUND_PATH_ENTRANCE, 4, 4 ; 13
+ map_const ROUTE_5_SAFFRON_GATE, 5, 4 ; 14
+ map_const ROUTE_5_CLEANSE_TAG_HOUSE, 4, 4 ; 15
+
+ newgroup ; 26
+
+ map_const ROUTE_30, 10, 27 ; 1
+ map_const ROUTE_31, 20, 9 ; 2
+ map_const CHERRYGROVE_CITY, 20, 9 ; 3
+ map_const CHERRYGROVE_MART, 6, 4 ; 4
+ map_const CHERRYGROVE_POKECENTER_1F, 5, 4 ; 5
+ map_const CHERRYGROVE_GYM_SPEECH_HOUSE, 4, 4 ; 6
+ map_const GUIDE_GENTS_HOUSE, 4, 4 ; 7
+ map_const CHERRYGROVE_EVOLUTION_SPEECH_HOUSE, 4, 4 ; 8
+ map_const ROUTE_30_BERRY_HOUSE, 4, 4 ; 9
+ map_const MR_POKEMONS_HOUSE, 4, 4 ; 10
+ map_const ROUTE_31_VIOLET_GATE, 5, 4 ; 11
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index 03911c50..37cee638 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -12,7 +12,11 @@ SET_FLAG EQU 1
CHECK_FLAG EQU 2
; G/S version ID: 0 = Gold, 1 = Silver (used by checkver)
+IF DEF(_GOLD)
GS_VERSION EQU 0
+ELIF DEF(_SILVER)
+GS_VERSION EQU 1
+ENDC
; save file corruption check values
SAVE_CHECK_VALUE_1 EQU 99
diff --git a/constants/script_constants.asm b/constants/script_constants.asm
index f05c44fd..f8673936 100644
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -34,6 +34,12 @@ NUM_STRING_BUFFERS EQU const_value
const PHONE_CONTACTS_FULL ; 1
const PHONE_CONTACT_REFUSED ; 2
+; trainertext arguments
+ const_def
+ const TRAINERTEXT_SEEN
+ const TRAINERTEXT_WIN
+ const TRAINERTEXT_LOSS
+
; writecode/checkcode arguments
; _GetVarAction.VarActionTable indexes (see engine/overworld/variables.asm)
const_def
@@ -115,6 +121,7 @@ OBJECT_EVENT_SIZE EQU 13 ; object_event
; command queue members
CMDQUEUE_TYPE EQU 0
CMDQUEUE_ADDR EQU 1
+CMDQUEUE_02 EQU 2
CMDQUEUE_03 EQU 3
CMDQUEUE_04 EQU 4
CMDQUEUE_05 EQU 5
@@ -165,7 +172,7 @@ NUM_CMDQUEUE_TYPES EQU const_value
const EMOTE_ROD ; 9
const EMOTE_BOULDER_DUST ; 10
const EMOTE_GRASS_RUSTLE ; 11
-EMOTE_MEM EQU -1
+EMOTE_FROM_MEM EQU -1
; fruittree arguments
; FruitTreeItems indexes (see data/items/fruit_trees.asm)
@@ -265,17 +272,3 @@ NUM_FRUIT_TREES EQU const_value + -1
const UNOWNPUZZLE_AERODACTYL ; 2
const UNOWNPUZZLE_HO_OH ; 3
NUM_UNOWN_PUZZLES EQU const_value
-
-; DisplayUnownWords writebyte arguments
-; UnownWalls and MenuHeaders_UnownWalls indexes (see data/events/unown_walls.asm)
- const_def
- const UNOWNWORDS_ESCAPE ; 0
- const UNOWNWORDS_LIGHT ; 1
- const UNOWNWORDS_WATER ; 2
- const UNOWNWORDS_HO_OH ; 3
-
-; MoveTutor writebyte arguments
- const_def 1
- const MOVETUTOR_FLAMETHROWER ; 1
- const MOVETUTOR_THUNDERBOLT ; 2
- const MOVETUTOR_ICE_BEAM ; 3
diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm
index f2d67488..13d716b6 100644
--- a/constants/wram_constants.asm
+++ b/constants/wram_constants.asm
@@ -91,6 +91,13 @@ PC_DEPOSIT EQU 1
DAY_CARE_WITHDRAW EQU 2
DAY_CARE_DEPOSIT EQU 3
+; wPlayerStepFlags::
+ const_def 4
+ const PLAYERSTEP_MIDAIR_F ; 4
+ const PLAYERSTEP_CONTINUE_F ; 5
+ const PLAYERSTEP_STOP_F ; 6
+ const PLAYERSTEP_START_F ; 7
+
; wTimeOfDay:: ; d157
const_def
const MORN_F ; 0
@@ -111,6 +118,18 @@ PLAYERSPRITESETUP_CUSTOM_FACING_F EQU 5
PLAYERSPRITESETUP_SKIP_RELOAD_GFX_F EQU 6
PLAYERSPRITESETUP_RESET_ACTION_F EQU 7
+; wMapStatus::
+ const_def
+ const MAPSTATUS_START ; 0
+ const MAPSTATUS_ENTER ; 1
+ const MAPSTATUS_HANDLE ; 2
+ const MAPSTATUS_DONE ; 3
+
+; wMapEventStatus::
+ const_def
+ const MAPEVENTS_ON ; 0
+ const MAPEVENTS_OFF ; 1
+
; wScriptFlags::
SCRIPT_RUNNING EQU 2
diff --git a/data/items/pocket_names.asm b/data/items/pocket_names.asm
new file mode 100644
index 00000000..880e08fe
--- /dev/null
+++ b/data/items/pocket_names.asm
@@ -0,0 +1,11 @@
+ItemPocketNames:
+; entries correspond to item type constants
+ dw .Item
+ dw .Key
+ dw .Ball
+ dw .TM
+
+.Item: db "ITEM POCKET@"
+.Key: db "KEY POCKET@"
+.Ball: db "BALL POCKET@"
+.TM: db "TM POCKET@"
diff --git a/data/maps/map_data.asm b/data/maps/map_data.asm
new file mode 100644
index 00000000..125f4474
--- /dev/null
+++ b/data/maps/map_data.asm
@@ -0,0 +1,14 @@
+INCLUDE "constants.asm"
+
+
+SECTION "Maps", ROMX
+
+INCLUDE "data/maps/scenes.asm"
+INCLUDE "data/maps/maps.asm"
+INCLUDE "data/maps/attributes.asm"
+
+
+INCLUDE "data/maps/blocks.asm"
+
+
+INCLUDE "data/maps/scripts.asm"
diff --git a/data/maps/scenes.asm b/data/maps/scenes.asm
new file mode 100644
index 00000000..13ce4dcd
--- /dev/null
+++ b/data/maps/scenes.asm
@@ -0,0 +1,67 @@
+scene_var: MACRO
+; map, variable
+ map_id \1
+ dw \2
+ENDM
+
+MapScenes::
+ scene_var POKECENTER_2F, wPokecenter2FSceneID
+ scene_var TRADE_CENTER, wTradeCenterSceneID
+ scene_var COLOSSEUM, wColosseumSceneID
+ scene_var TIME_CAPSULE, wTimeCapsuleSceneID
+ scene_var POWER_PLANT, wPowerPlantSceneID
+ scene_var CERULEAN_GYM, wCeruleanGymSceneID
+ scene_var ROUTE_25, wRoute25SceneID
+ scene_var TRAINER_HOUSE_B1F, wTrainerHouseB1FSceneID
+ scene_var VICTORY_ROAD_GATE, wVictoryRoadGateSceneID
+ scene_var SAFFRON_MAGNET_TRAIN_STATION, wSaffronMagnetTrainStationSceneID
+ scene_var ROUTE_16_GATE, wRoute16GateSceneID
+ scene_var ROUTE_17_ROUTE_18_GATE, wRoute17Route18GateSceneID
+ scene_var INDIGO_PLATEAU_POKECENTER_1F, wIndigoPlateauPokecenter1FSceneID
+ scene_var WILLS_ROOM, wWillsRoomSceneID
+ scene_var KOGAS_ROOM, wKogasRoomSceneID
+ scene_var BRUNOS_ROOM, wBrunosRoomSceneID
+ scene_var KARENS_ROOM, wKarensRoomSceneID
+ scene_var LANCES_ROOM, wLancesRoomSceneID
+ scene_var HALL_OF_FAME, wHallOfFameSceneID
+ scene_var ROUTE_27, wRoute27SceneID
+ scene_var NEW_BARK_TOWN, wNewBarkTownSceneID
+ scene_var ELMS_LAB, wElmsLabSceneID
+ scene_var PLAYERS_HOUSE_1F, wPlayersHouse1FSceneID
+ scene_var ROUTE_29, wRoute29SceneID
+ scene_var CHERRYGROVE_CITY, wCherrygroveCitySceneID
+ scene_var MR_POKEMONS_HOUSE, wMrPokemonsHouseSceneID
+ scene_var ROUTE_32, wRoute32SceneID
+ scene_var ROUTE_35_NATIONAL_PARK_GATE, wRoute35NationalParkGateSceneID
+ scene_var ROUTE_36_NATIONAL_PARK_GATE, wRoute36NationalParkGateSceneID
+ scene_var AZALEA_TOWN, wAzaleaTownSceneID
+ scene_var GOLDENROD_GYM, wGoldenrodGymSceneID
+ scene_var GOLDENROD_MAGNET_TRAIN_STATION, wGoldenrodMagnetTrainStationSceneID
+ scene_var OLIVINE_CITY, wOlivineCitySceneID
+ scene_var ROUTE_34, wRoute34SceneID ; unused
+ scene_var ECRUTEAK_TIN_TOWER_ENTRANCE, wEcruteakTinTowerEntranceSceneID
+ scene_var ECRUTEAK_POKECENTER_1F, wEcruteakPokecenter1FSceneID
+ scene_var MAHOGANY_TOWN, wMahoganyTownSceneID
+ scene_var ROUTE_43_GATE, wRoute43GateSceneID
+ scene_var MOUNT_MOON, wMountMoonSceneID
+ scene_var SPROUT_TOWER_3F, wSproutTower3FSceneID
+ scene_var BURNED_TOWER_1F, wBurnedTower1FSceneID
+ scene_var BURNED_TOWER_B1F, wBurnedTowerB1FSceneID
+ scene_var RADIO_TOWER_5F, wRadioTower5FSceneID
+ scene_var RUINS_OF_ALPH_OUTSIDE, wRuinsOfAlphOutsideSceneID
+ scene_var RUINS_OF_ALPH_RESEARCH_CENTER, wRuinsOfAlphResearchCenterSceneID
+ scene_var RUINS_OF_ALPH_INNER_CHAMBER, wRuinsOfAlphInnerChamberSceneID
+ scene_var MAHOGANY_MART_1F, wMahoganyMart1FSceneID
+ scene_var TEAM_ROCKET_BASE_B1F, wTeamRocketBaseB1FSceneID
+ scene_var TEAM_ROCKET_BASE_B2F, wTeamRocketBaseB2FSceneID
+ scene_var TEAM_ROCKET_BASE_B3F, wTeamRocketBaseB3FSceneID
+ scene_var GOLDENROD_UNDERGROUND_SWITCH_ROOM_ENTRANCES, wGoldenrodUndergroundSwitchRoomEntrancesSceneID
+ scene_var SILVER_CAVE_ROOM_3, wSilverCaveRoom3SceneID ; unused
+ scene_var VICTORY_ROAD, wVictoryRoadSceneID
+ scene_var DRAGONS_DEN_B1F, wDragonsDenB1FSceneID
+ scene_var OLIVINE_PORT, wOlivinePortSceneID
+ scene_var VERMILION_PORT, wVermilionPortSceneID
+ scene_var FAST_SHIP_1F, wFastShip1FSceneID
+ scene_var FAST_SHIP_B1F, wFastShipB1FSceneID
+ scene_var MOUNT_MOON_SQUARE, wMountMoonSquareSceneID
+ db -1 ; end
diff --git a/data/maps/scripts.asm b/data/maps/scripts.asm
index 160ef64e..54c71ab9 100644
--- a/data/maps/scripts.asm
+++ b/data/maps/scripts.asm
@@ -1,4 +1,5 @@
SECTION "Map Scripts 1", ROMX
+
INCLUDE "maps/SproutTower1F.asm"
INCLUDE "maps/SproutTower2F.asm"
INCLUDE "maps/SproutTower3F.asm"
@@ -22,7 +23,9 @@ INCLUDE "maps/SafariZoneFuchsiaGateBeta.asm"
INCLUDE "maps/SafariZoneBeta.asm"
INCLUDE "maps/VictoryRoad.asm"
+
SECTION "Map Scripts 2", ROMX
+
INCLUDE "maps/NationalPark.asm"
INCLUDE "maps/NationalParkBugContest.asm"
INCLUDE "maps/RadioTower1F.asm"
@@ -31,7 +34,9 @@ INCLUDE "maps/RadioTower3F.asm"
INCLUDE "maps/RadioTower4F.asm"
INCLUDE "maps/RadioTower5F.asm"
+
SECTION "Map Scripts 3", ROMX
+
INCLUDE "maps/RuinsOfAlphOutside.asm"
INCLUDE "maps/RuinsOfAlphHoOhChamber.asm"
INCLUDE "maps/RuinsOfAlphKabutoChamber.asm"
@@ -51,14 +56,18 @@ INCLUDE "maps/OlivineLighthouse4F.asm"
INCLUDE "maps/OlivineLighthouse5F.asm"
INCLUDE "maps/OlivineLighthouse6F.asm"
+
SECTION "Map Scripts 4", ROMX
+
INCLUDE "maps/MahoganyMart1F.asm"
INCLUDE "maps/TeamRocketBaseB1F.asm"
INCLUDE "maps/TeamRocketBaseB2F.asm"
INCLUDE "maps/TeamRocketBaseB3F.asm"
INCLUDE "maps/IlexForest.asm"
+
SECTION "Map Scripts 5", ROMX
+
INCLUDE "maps/GoldenrodUnderground.asm"
INCLUDE "maps/GoldenrodUndergroundSwitchRoomEntrances.asm"
INCLUDE "maps/GoldenrodDeptStoreB1F.asm"
@@ -73,7 +82,9 @@ INCLUDE "maps/IcePathB2FMahoganySide.asm"
INCLUDE "maps/IcePathB2FBlackthornSide.asm"
INCLUDE "maps/IcePathB3F.asm"
+
SECTION "Map Scripts 6", ROMX
+
INCLUDE "maps/WhirlIslandNW.asm"
INCLUDE "maps/WhirlIslandNE.asm"
INCLUDE "maps/WhirlIslandSW.asm"
@@ -92,7 +103,9 @@ INCLUDE "maps/DragonsDen1F.asm"
INCLUDE "maps/DragonsDenB1F.asm"
INCLUDE "maps/TohjoFalls.asm"
+
SECTION "Map Scripts 7", ROMX
+
INCLUDE "maps/NewBarkTown.asm"
INCLUDE "maps/CherrygroveCity.asm"
INCLUDE "maps/VioletCity.asm"
@@ -100,7 +113,9 @@ INCLUDE "maps/AzaleaTown.asm"
INCLUDE "maps/CianwoodCity.asm"
INCLUDE "maps/GoldenrodCity.asm"
+
SECTION "Map Scripts 8", ROMX
+
INCLUDE "maps/OlivineCity.asm"
INCLUDE "maps/EcruteakCity.asm"
INCLUDE "maps/MahoganyTown.asm"
@@ -108,7 +123,9 @@ INCLUDE "maps/LakeOfRage.asm"
INCLUDE "maps/BlackthornCity.asm"
INCLUDE "maps/SilverCaveOutside.asm"
+
SECTION "Map Scripts 9", ROMX
+
INCLUDE "maps/Route26.asm"
INCLUDE "maps/Route27.asm"
INCLUDE "maps/Route28.asm"
@@ -116,14 +133,18 @@ INCLUDE "maps/Route29.asm"
INCLUDE "maps/Route30.asm"
INCLUDE "maps/Route31.asm"
+
SECTION "Map Scripts 10", ROMX
+
INCLUDE "maps/Route32.asm"
INCLUDE "maps/Route33.asm"
INCLUDE "maps/Route34.asm"
INCLUDE "maps/Route35.asm"
INCLUDE "maps/Route36.asm"
+
SECTION "Map Scripts 11", ROMX
+
INCLUDE "maps/Route37.asm"
INCLUDE "maps/Route38.asm"
INCLUDE "maps/Route39.asm"
@@ -131,7 +152,9 @@ INCLUDE "maps/Route40.asm"
INCLUDE "maps/Route41.asm"
INCLUDE "maps/Route42.asm"
+
SECTION "Map Scripts 12", ROMX
+
INCLUDE "maps/Route43.asm"
INCLUDE "maps/Route44.asm"
INCLUDE "maps/Route45.asm"
@@ -139,7 +162,9 @@ INCLUDE "maps/Route46.asm"
INCLUDE "maps/PewterCity.asm"
INCLUDE "maps/Route2.asm"
+
SECTION "Map Scripts 13", ROMX
+
INCLUDE "maps/ViridianCity.asm"
INCLUDE "maps/Route22.asm"
INCLUDE "maps/Route1.asm"
@@ -155,7 +180,9 @@ INCLUDE "maps/Route16.asm"
INCLUDE "maps/CeladonCity.asm"
INCLUDE "maps/Route7.asm"
+
SECTION "Map Scripts 14", ROMX
+
INCLUDE "maps/Route15.asm"
INCLUDE "maps/Route14.asm"
INCLUDE "maps/Route13.asm"
@@ -168,7 +195,9 @@ INCLUDE "maps/SaffronCity.asm"
INCLUDE "maps/Route5.asm"
INCLUDE "maps/CeruleanCity.asm"
+
SECTION "Map Scripts 15", ROMX
+
INCLUDE "maps/Route9.asm"
INCLUDE "maps/Route24.asm"
INCLUDE "maps/Route25.asm"
@@ -179,7 +208,9 @@ INCLUDE "maps/Route10North.asm"
INCLUDE "maps/Route10South.asm"
INCLUDE "maps/Route23.asm"
+
SECTION "Map Scripts 16", ROMX
+
INCLUDE "maps/OlivinePokecenter1F.asm"
INCLUDE "maps/OlivineGym.asm"
INCLUDE "maps/OlivineTimsHouse.asm"
@@ -196,7 +227,9 @@ INCLUDE "maps/MahoganyGym.asm"
INCLUDE "maps/MahoganyPokecenter1F.asm"
INCLUDE "maps/Route42EcruteakGate.asm"
+
SECTION "Map Scripts 17", ROMX
+
INCLUDE "maps/EcruteakTinTowerEntrance.asm"
INCLUDE "maps/WiseTriosRoom.asm"
INCLUDE "maps/EcruteakPokecenter1F.asm"
@@ -206,7 +239,9 @@ INCLUDE "maps/EcruteakMart.asm"
INCLUDE "maps/EcruteakGym.asm"
INCLUDE "maps/EcruteakItemfinderHouse.asm"
+
SECTION "Map Scripts 18", ROMX
+
INCLUDE "maps/BlackthornGym1F.asm"
INCLUDE "maps/BlackthornGym2F.asm"
INCLUDE "maps/BlackthornDragonSpeechHouse.asm"
@@ -223,7 +258,9 @@ INCLUDE "maps/LakeOfRageMagikarpHouse.asm"
INCLUDE "maps/Route43MahoganyGate.asm"
INCLUDE "maps/Route43Gate.asm"
+
SECTION "Map Scripts 19", ROMX
+
INCLUDE "maps/CeruleanGymBadgeSpeechHouse.asm"
INCLUDE "maps/CeruleanPoliceStation.asm"
INCLUDE "maps/CeruleanTradeSpeechHouse.asm"
@@ -236,14 +273,18 @@ INCLUDE "maps/Route10Pokecenter2FBeta.asm"
INCLUDE "maps/PowerPlant.asm"
INCLUDE "maps/BillsHouse.asm"
+
SECTION "Map Scripts 20", ROMX
+
INCLUDE "maps/AzaleaPokecenter1F.asm"
INCLUDE "maps/CharcoalKiln.asm"
INCLUDE "maps/AzaleaMart.asm"
INCLUDE "maps/KurtsHouse.asm"
INCLUDE "maps/AzaleaGym.asm"
+
SECTION "Map Scripts 21", ROMX
+
INCLUDE "maps/VioletMart.asm"
INCLUDE "maps/VioletGym.asm"
INCLUDE "maps/EarlsPokemonAcademy.asm"
@@ -257,6 +298,7 @@ INCLUDE "maps/Route35NationalParkGate.asm"
INCLUDE "maps/Route36RuinsOfAlphGate.asm"
INCLUDE "maps/Route36NationalParkGate.asm"
+
SECTION "Map Scripts 22", ROMX
INCLUDE "maps/GoldenrodGym.asm"
@@ -280,7 +322,9 @@ INCLUDE "maps/IlexForestAzaleaGate.asm"
INCLUDE "maps/Route34IlexForestGate.asm"
INCLUDE "maps/DayCare.asm"
+
SECTION "Map Scripts 23", ROMX
+
INCLUDE "maps/VermilionFishingSpeechHouse.asm"
INCLUDE "maps/VermilionPokecenter1F.asm"
INCLUDE "maps/VermilionPokecenter2FBeta.asm"
@@ -296,7 +340,9 @@ INCLUDE "maps/RedsHouse2F.asm"
INCLUDE "maps/BluesHouse.asm"
INCLUDE "maps/OaksLab.asm"
+
SECTION "Map Scripts 24", ROMX
+
INCLUDE "maps/PewterNidoranSpeechHouse.asm"
INCLUDE "maps/PewterGym.asm"
INCLUDE "maps/PewterMart.asm"
@@ -311,7 +357,9 @@ INCLUDE "maps/KarensRoom.asm"
INCLUDE "maps/LancesRoom.asm"
INCLUDE "maps/HallOfFame.asm"
+
SECTION "Map Scripts 25", ROMX
+
INCLUDE "maps/OlivinePort.asm"
INCLUDE "maps/VermilionPort.asm"
INCLUDE "maps/FastShip1F.asm"
@@ -325,7 +373,9 @@ INCLUDE "maps/MountMoonSquare.asm"
INCLUDE "maps/MountMoonGiftShop.asm"
INCLUDE "maps/TinTowerRoof.asm"
+
SECTION "Map Scripts 26", ROMX
+
INCLUDE "maps/FuchsiaMart.asm"
INCLUDE "maps/SafariZoneMainOffice.asm"
INCLUDE "maps/FuchsiaGym.asm"
@@ -341,7 +391,9 @@ INCLUDE "maps/TradeCenter.asm"
INCLUDE "maps/Colosseum.asm"
INCLUDE "maps/TimeCapsule.asm"
+
SECTION "Map Scripts 27", ROMX
+
INCLUDE "maps/LavenderPokecenter1F.asm"
INCLUDE "maps/LavenderPokecenter2FBeta.asm"
INCLUDE "maps/MrFujisHouse.asm"
@@ -359,7 +411,9 @@ INCLUDE "maps/CianwoodPharmacy.asm"
INCLUDE "maps/CianwoodPhotoStudio.asm"
INCLUDE "maps/CianwoodLugiaSpeechHouse.asm"
+
SECTION "Map Scripts 28", ROMX
+
INCLUDE "maps/CeladonDeptStore1F.asm"
INCLUDE "maps/CeladonDeptStore2F.asm"
INCLUDE "maps/CeladonDeptStore3F.asm"
@@ -383,7 +437,9 @@ INCLUDE "maps/Route16Gate.asm"
INCLUDE "maps/Route7SaffronGate.asm"
INCLUDE "maps/Route17Route18Gate.asm"
+
SECTION "Map Scripts 29", ROMX
+
INCLUDE "maps/ViridianGym.asm"
INCLUDE "maps/ViridianNicknameSpeechHouse.asm"
INCLUDE "maps/TrainerHouse1F.asm"
@@ -395,7 +451,9 @@ INCLUDE "maps/Route2NuggetHouse.asm"
INCLUDE "maps/Route2Gate.asm"
INCLUDE "maps/VictoryRoadGate.asm"
+
SECTION "Map Scripts 30", ROMX
+
INCLUDE "maps/ElmsLab.asm"
INCLUDE "maps/PlayersHouse1F.asm"
INCLUDE "maps/PlayersHouse2F.asm"
@@ -406,7 +464,9 @@ INCLUDE "maps/DayOfWeekSiblingsHouse.asm"
INCLUDE "maps/Route27SandstormHouse.asm"
INCLUDE "maps/Route29Route46Gate.asm"
+
SECTION "Map Scripts 31", ROMX
+
INCLUDE "maps/FightingDojo.asm"
INCLUDE "maps/SaffronGym.asm"
INCLUDE "maps/SaffronMart.asm"
@@ -421,7 +481,9 @@ INCLUDE "maps/Route5UndergroundPathEntrance.asm"
INCLUDE "maps/Route5SaffronGate.asm"
INCLUDE "maps/Route5CleanseTagHouse.asm"
+
SECTION "Map Scripts 32", ROMX
+
INCLUDE "maps/CherrygroveMart.asm"
INCLUDE "maps/CherrygrovePokecenter1F.asm"
INCLUDE "maps/CherrygroveGymSpeechHouse.asm"
diff --git a/data/text/common_2.asm b/data/text/common_2.asm
index d82fdccd..78c3d703 100644
--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -1331,14 +1331,14 @@ _CoordinatesEventText::
text "Coordinates event"
done
-UnknownText_0x1c4719::
+_ReceivedItemText::
text "<PLAYER> received"
line "@"
text_ram wStringBuffer4
text "."
done
-UnknownText_0x1c472c::
+_PutItemInPocketText::
text "<PLAYER> put the"
line "@"
text_ram wStringBuffer1
@@ -1348,7 +1348,7 @@ UnknownText_0x1c472c::
text "."
prompt
-UnknownText_0x1c474b::
+_PocketIsFullText::
text "The @"
text_ram wStringBuffer3
text_start
diff --git a/data/wild/bug_contest_mons.asm b/data/wild/bug_contest_mons.asm
new file mode 100644
index 00000000..79712703
--- /dev/null
+++ b/data/wild/bug_contest_mons.asm
@@ -0,0 +1,13 @@
+ContestMons:
+ ; %, species, min, max
+ db 20, CATERPIE, 7, 18
+ db 20, WEEDLE, 7, 18
+ db 10, METAPOD, 9, 18
+ db 10, KAKUNA, 9, 18
+ db 5, BUTTERFREE, 12, 15
+ db 5, BEEDRILL, 12, 15
+ db 10, VENONAT, 10, 16
+ db 10, PARAS, 10, 17
+ db 5, SCYTHER, 13, 14
+ db 5, PINSIR, 13, 14
+ db -1, VENOMOTH, 30, 40
diff --git a/engine/events/happiness_egg.asm b/engine/events/happiness_egg.asm
index 6c8b918c..6563c878 100755
--- a/engine/events/happiness_egg.asm
+++ b/engine/events/happiness_egg.asm
@@ -145,7 +145,7 @@ StepHappiness::
MAX_EXP EQU 5242880
-DaycareStep::
+DayCareStep::
CheckFlag ENGINE_DAY_CARE_MAN_HAS_MON
jr z, .daycare_lady
ld a, [wBreedMon1Level]
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
index 179e8227..28b7c895 100755
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -672,7 +672,7 @@ Text_UsedWaterfall:
text_far Text_UsedWaterfall_
db "@"
-TryWaterfallOW:
+TryWaterfallOW::
ld d, WATERFALL
call FieldMovePartyCheck
jr c, .asm_cb7d
@@ -1146,7 +1146,7 @@ DisappearWhirlpool: ; 4e20
call GetMovementPermissions
ret
-TryWhirlpoolOW:
+TryWhirlpoolOW::
ld d, WHIRLPOOL
call FieldMovePartyCheck
jr c, .asm_ce5f
@@ -1238,7 +1238,7 @@ HeadbuttScript:
closetext
end
-TryHeadbuttOW: ; cecc
+TryHeadbuttOW::
ld d, HEADBUTT
call FieldMovePartyCheck
jr c, .asm_cedd
@@ -1711,7 +1711,7 @@ GotOffBikeText:
text_end
-TryCutOW: ; d193
+TryCutOW::
ld d, CUT
call FieldMovePartyCheck
jr c, .asm_d1ac
diff --git a/engine/events/specials.asm b/engine/events/specials.asm
index e030f68a..53b8ee5b 100755
--- a/engine/events/specials.asm
+++ b/engine/events/specials.asm
@@ -25,7 +25,7 @@ ELSE
ENDC
ENDM
-SpecialsPointers:
+SpecialsPointers::
add_special WarpToSpawnPoint
; Communications
@@ -409,21 +409,22 @@ UnusedCheckUnusedTwoDayTimer: ; c549 (3:4549)
ld [wScriptVar], a
ret
-ActivateFishingSwarm: ; c556 (3:4556)
+ActivateFishingSwarm:
ld a, [wScriptVar]
ld [wFishingSwarmFlag], a
- jr .asm_c566
+ jr SetSwarmFlag
-.asm_c55e
+StoreSwarmMapIndices::
ld a, d
ld [wDunsparceMapGroup], a
ld a, e
ld [wDunsparceMapNumber], a
-.asm_c566
+ ; fallthrough
+SetSwarmFlag:
SetFlag ENGINE_SPECIAL_WILDDATA
ret
-Functionc56c:
+CheckSwarmFlag::
CheckFlagHL ENGINE_SPECIAL_WILDDATA
jr z, .asm_c578
xor a
diff --git a/engine/events/trainer_scripts.asm b/engine/events/trainer_scripts.asm
new file mode 100644
index 00000000..1fb0d291
--- /dev/null
+++ b/engine/events/trainer_scripts.asm
@@ -0,0 +1,31 @@
+TalkToTrainerScript::
+ faceplayer
+ trainerflagaction CHECK_FLAG
+ iftrue AlreadyBeatenTrainerScript
+ loadtemptrainer
+ encountermusic
+ sjump StartBattleWithMapTrainerScript
+
+SeenByTrainerScript::
+ loadtemptrainer
+ encountermusic
+ showemote EMOTE_SHOCK, LAST_TALKED, 30
+ callasm TrainerWalkToPlayer
+ applymovementlasttalked wMovementBuffer
+ writeobjectxy LAST_TALKED
+ faceobject PLAYER, LAST_TALKED
+ sjump StartBattleWithMapTrainerScript
+
+StartBattleWithMapTrainerScript:
+ opentext
+ trainertext TRAINERTEXT_SEEN
+ waitbutton
+ closetext
+ loadtemptrainer
+ startbattle
+ reloadmapafterbattle
+ trainerflagaction SET_FLAG
+ loadmem wRunningTrainerBattleScript, -1
+
+AlreadyBeatenTrainerScript:
+ scripttalkafter
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index ac360409..dccbd51b 100755
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -1951,12 +1951,12 @@ MaxRepel: ; f4bc (3:74bc)
Repel: ; f4c0 (3:74c0)
ld b, 100
asm_f4c2:
- ld a, [wRepelSteps]
+ ld a, [wRepelEffect]
and a
ld hl, Text_RepelsEffectsStillLinger
jp nz, PrintText
ld a, b
- ld [wRepelSteps], a
+ ld [wRepelEffect], a
jp Functionf7d0
Text_RepelsEffectsStillLinger:
diff --git a/engine/items/items.asm b/engine/items/items.asm
index c24d580b..748b3d46 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -489,7 +489,7 @@ CheckSelectableItem:
and a
ret
-CheckItemPocket: ; d44a (3:544a)
+CheckItemPocket::
ld a, $5
call GetItemAttr
and $f
diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm
new file mode 100644
index 00000000..ba50fb25
--- /dev/null
+++ b/engine/overworld/events.asm
@@ -0,0 +1,1585 @@
+INCLUDE "constants.asm"
+
+
+SECTION "Events", ROMX
+
+OverworldLoop::
+ xor a ; MAPSTATUS_START
+ ld [wMapStatus], a
+.loop
+ ld a, [wMapStatus]
+ ld hl, .jumps
+ rst JumpTable
+ ld a, [wMapStatus]
+ cp MAPSTATUS_DONE
+ jr nz, .loop
+.done
+ ret
+
+.jumps
+; entries correspond to MAPSTATUS_* constants
+ dw StartMap
+ dw EnterMap
+ dw HandleMap
+ dw .done
+
+DisableEvents:
+ xor a
+ ld [wScriptFlags3], a
+ ret
+
+EnableEvents::
+ ld a, $ff
+ ld [wScriptFlags3], a
+ ret
+
+CheckBit5_ScriptFlags3:
+ ld hl, wScriptFlags3
+ bit 5, [hl]
+ ret
+
+DisableWarpsConnxns:
+ ld hl, wScriptFlags3
+ res 2, [hl]
+ ret
+
+DisableCoordEvents:
+ ld hl, wScriptFlags3
+ res 1, [hl]
+ ret
+
+DisableStepCount:
+ ld hl, wScriptFlags3
+ res 0, [hl]
+ ret
+
+DisableWildEncounters:
+ ld hl, wScriptFlags3
+ res 4, [hl]
+ ret
+
+EnableWarpsConnxns:
+ ld hl, wScriptFlags3
+ set 2, [hl]
+ ret
+
+EnableCoordEvents:
+ ld hl, wScriptFlags3
+ set 1, [hl]
+ ret
+
+EnableStepCount:
+ ld hl, wScriptFlags3
+ set 0, [hl]
+ ret
+
+EnableWildEncounters:
+ ld hl, wScriptFlags3
+ set 4, [hl]
+ ret
+
+CheckWarpConnxnScriptFlag:
+ ld hl, wScriptFlags3
+ bit 2, [hl]
+ ret
+
+CheckCoordEventScriptFlag:
+ ld hl, wScriptFlags3
+ bit 1, [hl]
+ ret
+
+CheckStepCountScriptFlag:
+ ld hl, wScriptFlags3
+ bit 0, [hl]
+ ret
+
+CheckWildEncountersScriptFlag:
+ ld hl, wScriptFlags3
+ bit 4, [hl]
+ ret
+
+StartMap:
+ xor a
+ ld [wScriptRunning], a
+ ld hl, wMapStatus
+ ld bc, wMapStatusEnd - wMapStatus
+ call ByteFill
+ farcall InitCallReceiveDelay
+ call ClearJoypad
+EnterMap:
+ xor a
+ ld [wXYComparePointer], a
+ ld [wXYComparePointer + 1], a
+ call SetUpFiveStepWildEncounterCooldown
+ farcall RunMapSetupScript
+ call DisableEvents
+
+ ldh a, [hMapEntryMethod]
+ cp MAPSETUP_CONNECTION
+ jr nz, .dont_enable
+ call EnableEvents
+.dont_enable
+
+ ldh a, [hMapEntryMethod]
+ cp MAPSETUP_RELOADMAP
+ jr nz, .dontresetpoison
+ xor a
+ ld [wPoisonStepCount], a
+.dontresetpoison
+
+ xor a ; end map entry
+ ldh [hMapEntryMethod], a
+ ld a, MAPSTATUS_HANDLE
+ ld [wMapStatus], a
+ ret
+
+UnusedWait30Frames:
+ ld c, 30
+ call DelayFrames
+ ret
+
+HandleMap:
+ call ResetOverworldDelay
+ call HandleMapTimeAndJoypad
+ farcall HandleCmdQueue ; no need to farcall
+ call MapEvents
+
+; Not immediately entering a connected map will cause problems.
+ ld a, [wMapStatus]
+ cp MAPSTATUS_HANDLE
+ ret nz
+
+ call HandleMapObjects
+ call NextOverworldFrame
+ call HandleMapBackground
+ call CheckPlayerState
+ ret
+
+MapEvents:
+ ld a, [wMapEventStatus]
+ ld hl, .jumps
+ rst JumpTable
+ ret
+
+.jumps
+; entries correspond to MAPEVENTS_* constants
+ dw .events
+ dw .no_events
+
+.events
+ call PlayerEvents
+ call DisableEvents
+ farcall ScriptEvents
+ ret
+
+.no_events
+ ret
+
+MaxOverworldDelay:
+ db 2
+
+ResetOverworldDelay:
+ ld a, [MaxOverworldDelay]
+ ld [wOverworldDelay], a
+ ret
+
+NextOverworldFrame:
+ ld a, [wOverworldDelay]
+ and a
+ ret z
+ ld c, a
+ call DelayFrames
+ ret
+
+HandleMapTimeAndJoypad:
+ ld a, [wMapEventStatus]
+ cp MAPEVENTS_OFF
+ ret z
+
+ call UpdateTime
+ call GetJoypad
+ call TimeOfDayPals
+ ret
+
+HandleMapObjects:
+ farcall HandleNPCStep ; engine/map_objects.asm
+ farcall _HandlePlayerStep
+ call _CheckObjectEnteringVisibleRange
+ ret
+
+HandleMapBackground:
+ farcall _UpdateSprites
+ farcall ScrollScreen
+ ret
+
+CheckPlayerState:
+ ld a, [wPlayerStepFlags]
+ bit PLAYERSTEP_CONTINUE_F, a
+ jr z, .events
+ bit PLAYERSTEP_STOP_F, a
+ jr z, .noevents
+ bit PLAYERSTEP_MIDAIR_F, a
+ jr nz, .noevents
+ call EnableEvents
+.events
+ ld a, MAPEVENTS_ON
+ ld [wMapEventStatus], a
+ ret
+
+.noevents
+ ld a, MAPEVENTS_OFF
+ ld [wMapEventStatus], a
+ ret
+
+_CheckObjectEnteringVisibleRange:
+ ld hl, wPlayerStepFlags
+ bit PLAYERSTEP_STOP_F, [hl]
+ ret z
+ farcall CheckObjectEnteringVisibleRange
+ ret
+
+PlayerEvents:
+ xor a
+; If there's already a player event, don't interrupt it.
+ ld a, [wScriptRunning]
+ and a
+ ret nz
+
+ call Dummy_CheckScriptFlags3Bit5 ; This is a waste of time
+
+ call CheckTrainerBattle_GetPlayerEvent
+ jr c, .ok
+
+ call CheckTileEvent
+ jr c, .ok
+
+ call RunMemScript
+ jr c, .ok
+
+ call RunSceneScript
+ jr c, .ok
+
+ call CheckTimeEvents
+ jr c, .ok
+
+ call OWPlayerInput
+ jr c, .ok
+
+ xor a
+ ret
+
+.ok
+ push af
+ farcall EnableScriptMode
+ pop af
+ ld [wScriptRunning], a
+ call DoPlayerEvent
+ scf
+ ret
+
+CheckTrainerBattle_GetPlayerEvent:
+ nop
+ nop
+ call CheckTrainerBattle
+ jr nc, .nope
+
+ ld a, PLAYEREVENT_SEENBYTRAINER
+ scf
+ ret
+
+.nope
+ xor a
+ ret
+
+CheckTileEvent:
+; Check for warps, coord events, or wild battles.
+
+ call CheckWarpConnxnScriptFlag
+ jr z, .connections_disabled
+
+ call CheckMovingOffEdgeOfMap
+ jr c, .map_connection
+
+ call CheckWarpTile
+ jr c, .warp_tile
+
+.connections_disabled
+ call CheckCoordEventScriptFlag
+ jr z, .coord_events_disabled
+
+ call CheckCurrentMapCoordEvents
+ jr c, .coord_event
+
+.coord_events_disabled
+ call CheckStepCountScriptFlag
+ jr z, .step_count_disabled
+
+ call CountStep
+ ret c
+
+.step_count_disabled
+ call CheckWildEncountersScriptFlag
+ jr z, .ok
+
+ call RandomEncounter
+ ret c
+ jr .ok ; pointless
+
+.ok
+ xor a
+ ret
+
+.map_connection
+ ld a, PLAYEREVENT_CONNECTION
+ scf
+ ret
+
+.warp_tile
+ ld a, [wPlayerStandingTile]
+ call CheckPitTile
+ jr nz, .not_pit
+ ld a, PLAYEREVENT_FALL
+ scf
+ ret
+
+.not_pit
+ ld a, PLAYEREVENT_WARP
+ scf
+ ret
+
+.coord_event
+ ld hl, wCurCoordEventScriptAddr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptsBank
+ call CallScript
+ ret
+
+CheckWildEncounterCooldown::
+ ld hl, wWildEncounterCooldown
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+ ret z
+ scf
+ ret
+
+SetUpFiveStepWildEncounterCooldown:
+ ld a, 5
+ ld [wWildEncounterCooldown], a
+ ret
+
+ret_968d7:
+ ret
+
+SetMinTwoStepWildEncounterCooldown:
+ ld a, [wWildEncounterCooldown]
+ cp 2
+ ret nc
+ ld a, 2
+ ld [wWildEncounterCooldown], a
+ ret
+
+Dummy_CheckScriptFlags3Bit5:
+ call CheckBit5_ScriptFlags3
+ ret z
+ call Function2ffe
+ ret
+
+RunSceneScript:
+ ld a, [wCurMapSceneScriptCount]
+ and a
+ jr z, .nope
+
+ ld c, a
+ call CheckScenes
+ cp c
+ jr nc, .nope
+
+ ld e, a
+ ld d, 0
+ ld hl, wCurMapSceneScriptsPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+rept SCENE_SCRIPT_SIZE
+ add hl, de
+endr
+
+ call GetMapScriptsBank
+ call GetFarHalfword
+ call GetMapScriptsBank
+ call CallScript
+
+ ld hl, wScriptFlags
+ res 3, [hl]
+
+ farcall EnableScriptMode
+ farcall ScriptEvents
+
+ ld hl, wScriptFlags
+ bit 3, [hl]
+ jr z, .nope
+
+ ld hl, wPriorityScriptAddr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wPriorityScriptBank]
+ call CallScript
+ scf
+ ret
+
+.nope
+ xor a
+ ret
+
+CheckTimeEvents:
+ ld a, [wLinkMode]
+ and a
+ jr nz, .nothing
+
+ ld hl, wStatusFlags2
+ bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
+ jr z, .do_daily
+
+ farcall CheckBugContestTimer
+ jr c, .end_bug_contest
+ xor a
+ ret
+
+.do_daily
+ farcall CheckDailyResetTimer
+ farcall CheckSwarmFlag
+ farcall CheckPokerusTick
+ farcall CheckPhoneCall
+ ret c
+
+.nothing
+ xor a
+ ret
+
+.end_bug_contest
+ ld a, BANK(BugCatchingContestOverScript)
+ ld hl, BugCatchingContestOverScript
+ call CallScript
+ scf
+ ret
+
+.unused
+ ld a, 8
+ scf
+ ret
+
+OWPlayerInput:
+ call PlayerMovement
+ ret c
+ and a
+ jr nz, .NoAction
+
+; Can't perform button actions while sliding on ice.
+ farcall CheckStandingOnIce
+ jr c, .NoAction
+
+ call CheckAPressOW
+ jr c, .Action
+
+ call CheckMenuOW
+ jr c, .Action
+
+.NoAction:
+ xor a
+ ret
+
+.Action:
+ push af
+ farcall StopPlayerForEvent
+ pop af
+ scf
+ ret
+
+CheckAPressOW:
+ ldh a, [hJoyPressed]
+ and A_BUTTON
+ ret z
+ call TryObjectEvent
+ ret c
+ call TryBGEvent
+ ret c
+ call TryTileCollisionEvent
+ ret c
+ xor a
+ ret
+
+PlayTalkObject:
+ push de
+ ld de, SFX_READ_TEXT_2
+ call PlaySFX
+ pop de
+ ret
+
+TryObjectEvent:
+ farcall CheckFacingObject
+ jr c, .IsObject
+ xor a
+ ret
+
+.IsObject:
+ call PlayTalkObject
+ ldh a, [hObjectStructIndexBuffer]
+ call GetObjectStruct
+ ld hl, OBJECT_MAP_OBJECT_INDEX
+ add hl, bc
+ ld a, [hl]
+ ldh [hLastTalked], a
+
+ ldh a, [hLastTalked]
+ call GetMapObject
+ ld hl, MAPOBJECT_COLOR
+ add hl, bc
+ ld a, [hl]
+ and %00001111
+
+; Bug: If IsInArray returns nc, data at bc will be executed as code.
+ push bc
+ ld de, 3
+ ld hl, .pointers
+ call IsInArray
+ jr nc, .nope
+ pop bc
+
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.nope
+ ; pop bc
+ xor a
+ ret
+
+.pointers
+ dbw OBJECTTYPE_SCRIPT, .script
+ dbw OBJECTTYPE_ITEMBALL, .itemball
+ dbw OBJECTTYPE_TRAINER, .trainer
+ ; the remaining four are dummy events
+ dbw OBJECTTYPE_3, .three
+ dbw OBJECTTYPE_4, .four
+ dbw OBJECTTYPE_5, .five
+ dbw OBJECTTYPE_6, .six
+ db -1
+
+.script
+ ld hl, MAPOBJECT_SCRIPT_POINTER
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptsBank
+ call CallScript
+ ret
+
+.itemball
+ ld hl, MAPOBJECT_SCRIPT_POINTER
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptsBank
+ ld de, wItemBallData
+ ld bc, wItemBallDataEnd - wItemBallData
+ call FarCopyBytes
+ ld a, PLAYEREVENT_ITEMBALL
+ scf
+ ret
+
+.trainer
+ call TalkToTrainer
+ ld a, PLAYEREVENT_TALKTOTRAINER
+ scf
+ ret
+
+.three
+ xor a
+ ret
+
+.four
+ xor a
+ ret
+
+.five
+ xor a
+ ret
+
+.six
+ xor a
+ ret
+
+TryBGEvent:
+ call CheckFacingBGEvent
+ jr c, .is_bg_event
+ xor a
+ ret
+
+.is_bg_event:
+ ld a, [wCurBGEventType]
+ ld hl, .bg_events
+ rst JumpTable
+ ret
+
+.bg_events
+ dw .read
+ dw .up
+ dw .down
+ dw .right
+ dw .left
+ dw .ifset
+ dw .ifnotset
+ dw .itemifset
+ dw .copy
+
+.up
+ ld b, OW_UP
+ jr .checkdir
+.down
+ ld b, OW_DOWN
+ jr .checkdir
+.right
+ ld b, OW_RIGHT
+ jr .checkdir
+.left
+ ld b, OW_LEFT
+ jr .checkdir
+
+.checkdir
+ ld a, [wPlayerDirection]
+ and %1100
+ cp b
+ jp nz, .dontread
+
+.read
+ call PlayTalkObject
+ ld hl, wCurBGEventScriptAddr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call GetMapScriptsBank
+ call CallScript
+ scf
+ ret
+
+.itemifset
+ call CheckBGEventFlag
+ jp nz, .dontread
+ call PlayTalkObject
+ call GetMapScriptsBank
+ ld de, wHiddenItemData
+ ld bc, wHiddenItemDataEnd - wHiddenItemData
+ call FarCopyBytes
+ ld a, BANK(HiddenItemScript)
+ ld hl, HiddenItemScript
+ call CallScript
+ scf
+ ret
+
+.copy
+ call CheckBGEventFlag
+ jr nz, .dontread
+ call GetMapScriptsBank
+ ld de, wHiddenItemData
+ ld bc, wHiddenItemDataEnd - wHiddenItemData
+ call FarCopyBytes
+ jr .dontread
+
+.ifset
+ call CheckBGEventFlag
+ jr z, .dontread
+ jr .thenread
+
+.ifnotset
+ call CheckBGEventFlag
+ jr nz, .dontread
+
+.thenread
+ push hl
+ call PlayTalkObject
+ pop hl
+ inc hl
+ inc hl
+ call GetMapScriptsBank
+ call GetFarHalfword
+ call GetMapScriptsBank
+ call CallScript
+ scf
+ ret
+
+.dontread
+ xor a
+ ret
+
+CheckBGEventFlag:
+ ld hl, wCurBGEventScriptAddr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ push hl
+ call GetMapScriptsBank
+ call GetFarHalfword
+ ld e, l
+ ld d, h
+ ld b, CHECK_FLAG
+ call EventFlagAction
+ ld a, c
+ and a
+ pop hl
+ ret
+
+PlayerMovement:
+ farcall DoPlayerMovement
+ ld a, c
+ ld hl, .pointers
+ rst JumpTable
+ ld a, c
+ ret
+
+.pointers
+; entries correspond to PLAYERMOVEMENT_* constants
+ dw .normal
+ dw .warp
+ dw .turn
+ dw .force_turn
+ dw .finish
+ dw .continue
+ dw .exit_water
+ dw .jump
+
+.normal:
+.finish:
+ xor a
+ ld c, a
+ ret
+
+.jump:
+ call ret_968d7 ; mobile
+ xor a
+ ld c, a
+ ret
+
+.warp:
+ ld a, PLAYEREVENT_WARP
+ ld c, a
+ scf
+ ret
+
+.turn:
+ ld a, PLAYEREVENT_JOYCHANGEFACING
+ ld c, a
+ scf
+ ret
+
+.force_turn:
+; force the player to move in some direction
+ ld a, BANK(Script_ForcedMovement)
+ ld hl, Script_ForcedMovement
+ call CallScript
+; ld a, -1
+ ld c, a
+ scf
+ ret
+
+.continue:
+.exit_water:
+ ld a, -1
+ ld c, a
+ and a
+ ret
+
+CheckMenuOW:
+ xor a
+ ldh [hMenuReturn], a
+ ldh [hUnusedFFA3], a
+ ldh a, [hJoyPressed]
+
+ bit SELECT_F, a
+ jr nz, .Select
+
+ bit START_F, a
+ jr z, .NoMenu
+
+ ld a, BANK(StartMenuScript)
+ ld hl, StartMenuScript
+ call CallScript
+ scf
+ ret
+
+.NoMenu:
+ xor a
+ ret
+
+.Select:
+ call PlayTalkObject
+ ld a, BANK(SelectMenuScript)
+ ld hl, SelectMenuScript
+ call CallScript
+ scf
+ ret
+
+StartMenuScript:
+ callasm StartMenu
+ sjump StartMenuCallback
+
+SelectMenuScript:
+ callasm SelectMenu
+ sjump SelectMenuCallback
+
+StartMenuCallback:
+SelectMenuCallback:
+ readmem hMenuReturn
+ ifequal HMENURETURN_SCRIPT, .Script
+ ifequal HMENURETURN_ASM, .Asm
+ end
+
+.Script:
+ memjump wQueuedScriptBank
+
+.Asm:
+ memcallasm wQueuedScriptBank
+ end
+
+CountStep:
+ ; Don't count steps in link communication rooms.
+ ld a, [wLinkMode]
+ and a
+ jr nz, .done
+
+ ; If there is a special phone call, don't count the step.
+ farcall CheckSpecialPhoneCall
+ jr c, .doscript
+
+ ; If Repel wore off, don't count the step.
+ call DoRepelStep
+ jr c, .doscript
+
+ ; Count the step for poison and total steps
+ ld hl, wPoisonStepCount
+ inc [hl]
+ ld hl, wStepCount
+ inc [hl]
+ ; Every 256 steps, increase the happiness of all your Pokemon.
+ jr nz, .skip_happiness
+
+ farcall StepHappiness
+
+.skip_happiness
+ ; Every 256 steps, offset from the happiness incrementor by 128 steps,
+ ; decrease the hatch counter of all your eggs until you reach the first
+ ; one that is ready to hatch.
+ ld a, [wStepCount]
+ cp $80
+ jr nz, .skip_egg
+
+ farcall DoEggStep
+ jr nz, .hatch
+
+.skip_egg
+ ; Increase the EXP of (both) DayCare Pokemon by 1.
+ farcall DayCareStep
+
+ ; Every four steps, deal damage to all Poisoned Pokemon
+ ld hl, wPoisonStepCount
+ ld a, [hl]
+ cp 4
+ jr c, .skip_poison
+ ld [hl], 0
+
+ farcall DoPoisonStep
+ jr c, .doscript
+
+.skip_poison
+ farcall DoBikeStep
+
+.done
+ xor a
+ ret
+
+.doscript
+ ld a, -1
+ scf
+ ret
+
+.hatch
+ ld a, PLAYEREVENT_HATCH
+ scf
+ ret
+
+; unused
+.unreferenced
+ ld a, PLAYEREVENT_WHITEOUT
+ scf
+ ret
+
+DoRepelStep:
+ ld a, [wRepelEffect]
+ and a
+ ret z
+
+ dec a
+ ld [wRepelEffect], a
+ ret nz
+
+ ld a, BANK(RepelWoreOffScript)
+ ld hl, RepelWoreOffScript
+ call CallScript
+ scf
+ ret
+
+DoPlayerEvent:
+ ld a, [wScriptRunning]
+ and a
+ ret z
+
+ cp PLAYEREVENT_MAPSCRIPT ; run script
+ ret z
+
+ cp NUM_PLAYER_EVENTS
+ ret nc
+
+ ld c, a
+ ld b, 0
+ ld hl, PlayerEventScriptPointers
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld [wScriptBank], a
+ ld a, [hli]
+ ld [wScriptPos], a
+ ld a, [hl]
+ ld [wScriptPos + 1], a
+ ret
+
+PlayerEventScriptPointers:
+; entries correspond to PLAYEREVENT_* constants
+ dba Invalid_0x96c2d ; PLAYEREVENT_NONE
+ dba SeenByTrainerScript ; PLAYEREVENT_SEENBYTRAINER
+ dba TalkToTrainerScript ; PLAYEREVENT_TALKTOTRAINER
+ dba FindItemInBallScript ; PLAYEREVENT_ITEMBALL
+ dba EdgeWarpScript ; PLAYEREVENT_CONNECTION
+ dba WarpToNewMapScript ; PLAYEREVENT_WARP
+ dba FallIntoMapScript ; PLAYEREVENT_FALL
+ dba Script_OverworldWhiteout ; PLAYEREVENT_WHITEOUT
+ dba HatchEggScript ; PLAYEREVENT_HATCH
+ dba ChangeDirectionScript ; PLAYEREVENT_JOYCHANGEFACING
+ dba Invalid_0x96c2d ; (NUM_PLAYER_EVENTS)
+
+Invalid_0x96c2d:
+ end
+
+; unused
+ end
+
+HatchEggScript:
+ callasm OverworldHatchEgg
+ end
+
+WarpToNewMapScript:
+ warpsound
+ newloadmap MAPSETUP_DOOR
+ end
+
+FallIntoMapScript:
+ newloadmap MAPSETUP_FALL
+ playsound SFX_KINESIS
+ applymovement PLAYER, MovementData_0x96c48
+ playsound SFX_STRENGTH
+ scall LandAfterPitfallScript
+ end
+
+MovementData_0x96c48:
+ skyfall
+ step_end
+
+LandAfterPitfallScript:
+ earthquake 16
+ end
+
+EdgeWarpScript: ; 4
+ reloadandreturn MAPSETUP_CONNECTION
+
+ChangeDirectionScript: ; 9
+ deactivatefacing 3
+ callasm EnableWildEncounters
+ end
+
+INCLUDE "engine/overworld/scripting.asm"
+
+WarpToSpawnPoint::
+ ld hl, wStatusFlags2
+ res STATUSFLAGS2_SAFARI_GAME_F, [hl]
+ res STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
+ ret
+
+RunMemScript::
+; If there is no script here, we don't need to be here.
+ ld a, [wMapReentryScriptQueueFlag]
+ and a
+ ret z
+; Execute the script at (wMapReentryScriptBank):(wMapReentryScriptAddress).
+ ld hl, wMapReentryScriptAddress
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wMapReentryScriptBank]
+ call CallScript
+ scf
+; Clear the buffer for the next script.
+ push af
+ xor a
+ ld hl, wMapReentryScriptQueueFlag
+ ld bc, 8
+ call ByteFill
+ pop af
+ ret
+
+LoadScriptBDE::
+; If there's already a script here, don't overwrite.
+ ld hl, wMapReentryScriptQueueFlag
+ ld a, [hl]
+ and a
+ ret nz
+; Set the flag
+ ld [hl], 1
+ inc hl
+; Load the script pointer b:de into (wMapReentryScriptBank):(wMapReentryScriptAddress)
+ ld [hl], b
+ inc hl
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ scf
+ ret
+
+TryTileCollisionEvent::
+ call GetFacingTileCoord
+ ld [wFacingTileID], a
+ ld c, a
+ farcall CheckFacingTileForStdScript
+ jr c, .done
+
+ call CheckCutTreeTile
+ jr nz, .whirlpool
+ farcall TryCutOW
+ jr .done
+
+.whirlpool
+ ld a, [wFacingTileID]
+ call CheckWhirlpoolTile
+ jr nz, .waterfall
+ farcall TryWhirlpoolOW
+ jr .done
+
+.waterfall
+ ld a, [wFacingTileID]
+ call CheckWaterfallTile
+ jr nz, .headbutt
+ farcall TryWaterfallOW
+ jr .done
+
+.headbutt
+ ld a, [wFacingTileID]
+ call CheckHeadbuttTreeTile
+ jr nz, .surf
+ farcall TryHeadbuttOW
+ jr c, .done
+ jr .noevent
+
+.surf
+ farcall TrySurfOW
+ jr nc, .noevent
+ jr .done
+
+.noevent
+ xor a
+ ret
+
+.done
+ call PlayClickSFX
+ ld a, $ff
+ scf
+ ret
+
+RandomEncounter::
+; Random encounter
+
+ call CheckWildEncounterCooldown
+ jr c, .nope
+ call CanUseSweetScent
+ jr nc, .nope
+ ld hl, wStatusFlags2
+ bit STATUSFLAGS2_BUG_CONTEST_TIMER_F, [hl]
+ jr nz, .bug_contest
+ farcall TryWildEncounter
+ jr nz, .nope
+ jr .ok
+
+.bug_contest
+ call _TryWildEncounter_BugContest
+ jr nc, .nope
+ jr .ok_bug_contest
+
+.nope
+ ld a, 1
+ and a
+ ret
+
+.ok
+ ld a, BANK(WildBattleScript)
+ ld hl, WildBattleScript
+ jr .done
+
+.ok_bug_contest
+ ld a, BANK(BugCatchingContestBattleScript)
+ ld hl, BugCatchingContestBattleScript
+ jr .done
+
+.done
+ call CallScript
+ scf
+ ret
+
+WildBattleScript:
+ randomwildmon
+ startbattle
+ reloadmapafterbattle
+ end
+
+CanUseSweetScent::
+ ld hl, wStatusFlags
+ bit STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl]
+ jr nz, .no
+ ld a, [wEnvironment]
+ cp CAVE
+ jr z, .ice_check
+ cp DUNGEON
+ jr z, .ice_check
+ farcall CheckGrassCollision
+ jr nc, .no
+
+.ice_check
+ ld a, [wPlayerStandingTile]
+ call CheckIceTile
+ jr z, .no
+ scf
+ ret
+
+.no
+ and a
+ ret
+
+_TryWildEncounter_BugContest:
+ call TryWildEncounter_BugContest
+ ret nc
+ call ChooseWildEncounter_BugContest
+ farcall CheckRepelEffect
+ ret
+
+ChooseWildEncounter_BugContest::
+; Pick a random mon out of ContestMons.
+
+.loop
+ call Random
+ cp 100 << 1
+ jr nc, .loop
+ srl a
+
+ ld hl, ContestMons
+ ld de, 4
+.CheckMon:
+ sub [hl]
+ jr c, .GotMon
+ add hl, de
+ jr .CheckMon
+
+.GotMon:
+ inc hl
+
+; Species
+ ld a, [hli]
+ ld [wTempWildMonSpecies], a
+
+; Min level
+ ld a, [hli]
+ ld d, a
+
+; Max level
+ ld a, [hl]
+
+ sub d
+ jr nz, .RandomLevel
+
+; If min and max are the same.
+ ld a, d
+ jr .GotLevel
+
+.RandomLevel:
+; Get a random level between the min and max.
+ ld c, a
+ inc c
+ call Random
+ ldh a, [hRandomAdd]
+ call SimpleDivide
+ add d
+
+.GotLevel:
+ ld [wCurPartyLevel], a
+
+ xor a
+ ret
+
+TryWildEncounter_BugContest:
+ ld a, [wPlayerStandingTile]
+ call CheckSuperTallGrassTile
+ ld b, 40 percent
+ jr z, .ok
+ ld b, 20 percent
+
+.ok
+ farcall ApplyMusicEffectOnEncounterRate
+ farcall ApplyCleanseTagEffectOnEncounterRate
+ call Random
+ ldh a, [hRandomAdd]
+ cp b
+ ret c
+ ld a, 1
+ and a
+ ret
+
+INCLUDE "data/wild/bug_contest_mons.asm"
+
+DoBikeStep::
+ nop
+ nop
+ ; If the bike shop owner doesn't have our number, or
+ ; if we've already gotten the call, we don't have to
+ ; be here.
+ ld hl, wStatusFlags2
+ bit STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl]
+ jr z, .NoCall
+
+ ; If we're not on the bike, we don't have to be here.
+ ld a, [wPlayerState]
+ cp PLAYER_BIKE
+ jr nz, .NoCall
+
+ ; If we're not in an area of phone service, we don't
+ ; have to be here.
+ call GetMapPhoneService
+ and a
+ jr nz, .NoCall
+
+ ; Check the bike step count and check whether we've
+ ; taken 65536 of them yet.
+ ld hl, wBikeStep
+ ld a, [hli]
+ ld d, a
+ ld e, [hl]
+ cp 255
+ jr nz, .increment
+ ld a, e
+ cp 255
+ jr z, .dont_increment
+
+.increment
+ inc de
+ ld [hl], e
+ dec hl
+ ld [hl], d
+
+.dont_increment
+ ; If we've taken at least 1024 steps, have the bike
+ ; shop owner try to call us.
+ ld a, d
+ cp HIGH(1024)
+ jr c, .NoCall
+
+ ; If a call has already been queued, don't overwrite
+ ; that call.
+ ld a, [wSpecialPhoneCallID]
+ and a
+ jr nz, .NoCall
+
+ ; Queue the call.
+ ld a, SPECIALCALL_BIKESHOP
+ ld [wSpecialPhoneCallID], a
+ xor a
+ ld [wSpecialPhoneCallID + 1], a
+ ld hl, wStatusFlags2
+ res STATUSFLAGS2_BIKE_SHOP_CALL_F, [hl]
+ scf
+ ret
+
+.NoCall:
+ xor a
+ ret
+
+ClearCmdQueue::
+ ld hl, wCmdQueue
+ ld de, CMDQUEUE_ENTRY_SIZE
+ ld c, CMDQUEUE_CAPACITY
+ xor a
+.loop
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .loop
+ ret
+
+HandleCmdQueue::
+ ld hl, wCmdQueue
+ xor a
+.loop
+ ldh [hMapObjectIndexBuffer], a
+ ld a, [hl]
+ and a
+ jr z, .skip
+ push hl
+ ld b, h
+ ld c, l
+ call HandleQueuedCommand
+ pop hl
+
+.skip
+ ld de, CMDQUEUE_ENTRY_SIZE
+ add hl, de
+ ldh a, [hMapObjectIndexBuffer]
+ inc a
+ cp CMDQUEUE_CAPACITY
+ jr nz, .loop
+ ret
+
+Unreferenced_GetNthCmdQueueEntry:
+ ld hl, wCmdQueue
+ ld bc, CMDQUEUE_ENTRY_SIZE
+ call AddNTimes
+ ld b, h
+ ld c, l
+ ret
+
+WriteCmdQueue::
+ push bc
+ push de
+ call .GetNextEmptyEntry
+ ld d, h
+ ld e, l
+ pop hl
+ pop bc
+ ret c
+ ld a, b
+ ld bc, CMDQUEUE_ENTRY_SIZE - 1
+ call FarCopyBytes
+ xor a
+ ld [hl], a
+ ret
+
+.GetNextEmptyEntry:
+ ld hl, wCmdQueue
+ ld de, CMDQUEUE_ENTRY_SIZE
+ ld c, CMDQUEUE_CAPACITY
+.loop
+ ld a, [hl]
+ and a
+ jr z, .done
+ add hl, de
+ dec c
+ jr nz, .loop
+ scf
+ ret
+
+.done
+ ld a, CMDQUEUE_CAPACITY
+ sub c
+ and a
+ ret
+
+DelCmdQueue::
+ ld hl, wCmdQueue
+ ld de, CMDQUEUE_ENTRY_SIZE
+ ld c, CMDQUEUE_CAPACITY
+.loop
+ ld a, [hl]
+ cp b
+ jr z, .done
+ add hl, de
+ dec c
+ jr nz, .loop
+ and a
+ ret
+
+.done
+ xor a
+ ld [hl], a
+ scf
+ ret
+
+_DelCmdQueue:
+ ld hl, CMDQUEUE_TYPE
+ add hl, bc
+ ld [hl], 0
+ ret
+
+HandleQueuedCommand:
+ ld hl, CMDQUEUE_TYPE
+ add hl, bc
+ ld a, [hl]
+ cp NUM_CMDQUEUE_TYPES
+ jr c, .okay
+ xor a
+
+.okay
+ ld e, a
+ ld d, 0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ push af
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop af
+ rst FarCall
+ ret
+
+.Jumptable:
+ dba CmdQueue_Null
+ dba CmdQueue_Type2
+ dba CmdQueue_StoneTable
+ dba CmdQueue_Null2
+ dba CmdQueue_Type4
+
+CmdQueueAnonymousJumptable:
+ ld hl, CMDQUEUE_05
+ add hl, bc
+ ld a, [hl]
+ pop hl
+ rst JumpTable
+ ret
+
+CmdQueueAnonJT_Increment:
+ ld hl, CMDQUEUE_05
+ add hl, bc
+ inc [hl]
+ ret
+
+CmdQueueAnonJT_Decrement:
+ ld hl, CMDQUEUE_05
+ add hl, bc
+ dec [hl]
+ ret
+
+CmdQueue_Null:
+ ret
+
+CmdQueue_Type2:
+ call Function2ffe
+ ret
+
+CmdQueue_Type4:
+ call CmdQueueAnonymousJumptable
+ ; anonymous dw
+ dw .zero
+ dw .one
+
+.zero
+ ldh a, [hSCY]
+ ld hl, CMDQUEUE_04
+ add hl, bc
+ ld [hl], a
+ call CmdQueueAnonJT_Increment
+.one
+ ld hl, CMDQUEUE_ADDR
+ add hl, bc
+ ld a, [hl]
+ dec a
+ ld [hl], a
+ jr z, .finish
+ and 1
+ jr z, .add
+ ld hl, CMDQUEUE_02
+ add hl, bc
+ ldh a, [hSCY]
+ sub [hl]
+ ldh [hSCY], a
+ ret
+
+.add
+ ld hl, CMDQUEUE_02
+ add hl, bc
+ ldh a, [hSCY]
+ add [hl]
+ ldh [hSCY], a
+ ret
+
+.finish
+ ld hl, CMDQUEUE_04
+ add hl, bc
+ ld a, [hl]
+ ldh [hSCY], a
+ call _DelCmdQueue
+ ret
+
+CmdQueue_Null2:
+ ret
+
+CmdQueue_StoneTable:
+ ld de, wPlayerStruct
+ ld a, NUM_OBJECT_STRUCTS
+.loop
+ push af
+
+ ld hl, OBJECT_SPRITE
+ add hl, de
+ ld a, [hl]
+ and a
+ jr z, .next
+
+ ld hl, OBJECT_MOVEMENTTYPE
+ add hl, de
+ ld a, [hl]
+ cp SPRITEMOVEDATA_STRENGTH_BOULDER
+ jr nz, .next
+
+ ld hl, OBJECT_NEXT_TILE
+ add hl, de
+ ld a, [hl]
+ call CheckPitTile
+ jr nz, .next
+
+ ld hl, OBJECT_DIRECTION_WALKING
+ add hl, de
+ ld a, [hl]
+ cp STANDING
+ jr nz, .next
+ call HandleStoneQueue
+ jr c, .fall_down_hole
+
+.next
+ ld hl, OBJECT_LENGTH
+ add hl, de
+ ld d, h
+ ld e, l
+
+ pop af
+ dec a
+ jr nz, .loop
+ ret
+
+.fall_down_hole
+ pop af
+ ret
+
+INCLUDE "engine/events/trainer_scripts.asm"
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index 07b53007..a59be34f 100755
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -666,7 +666,7 @@ Function55a1:
call Function55d8
ld a, $0
call Function55bc
- ld a, [wd180]
+ ld a, [wBattleScriptFlags]
bit 7, a
jr z, .asm_55b8
ldh a, [hLastTalked]
@@ -1021,7 +1021,7 @@ Function57bd: ; 57bd (1:57bd)
ld [wObjectFollow_Follower], a
ret
-Function57d2:
+SetFlagsForMovement_1::
ld a, c
call CheckObjectVisibility
ret c
@@ -1064,7 +1064,7 @@ Function57f0: ; 57f0 (1:57f0)
jr nz, .asm_57f4
ret
-Function580d:
+_SetFlagsForMovement_2::
ld a, [wObjectFollow_Leader]
cp $ff
ret z
@@ -1085,7 +1085,7 @@ Function580d:
res 5, [hl]
ret
-Function582f:
+Function582f::
push bc
ld bc, wPlayerSprite
xor a
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 38fe15d0..e40f2b1c 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -205,7 +205,7 @@ Function7080: ; 7080 (1:7080)
scf
ret
-CheckFacingObject:
+CheckFacingObject::
call GetFacingTileCoord
call CheckCounterTile
jr nz, .asm_70d0
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index 5fdca29c..98cce97d 100755
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -483,7 +483,7 @@ Function102bf: ; 102bf (4:42bf)
ret
Function102cb: ; 102cb (4:42cb)
- call Function10404
+ call CheckStandingOnIce
ret nc
ld a, [wPlayerTurningDirection]
.asm_102d2
@@ -704,7 +704,7 @@ Function103f9: ; 103f9 (4:43f9)
pop bc
ret
-Function10404: ; 10404 (4:4404)
+CheckStandingOnIce::
ld a, [wPlayerTurningDirection]
cp $0
jr z, .asm_10420
diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm
index 1ea552b5..ee8ebe1b 100755
--- a/engine/overworld/player_object.asm
+++ b/engine/overworld/player_object.asm
@@ -42,7 +42,7 @@ SpawnPlayer: ; 861a (2:461a)
; Said bytes seem to be unused.
object_event -4, -4, SPRITE_CHRIS, SPRITEMOVEDATA_PLAYER, 15, 15, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, 0, -1
-CopyDECoordsToMapObject: ; 8653 (2:4653)
+CopyDECoordsToMapObject::
push de
ld a, b
call GetMapObject
@@ -55,7 +55,7 @@ CopyDECoordsToMapObject: ; 8653 (2:4653)
ld [hl], e
ret
-PlayerSpawn_ConvertCoords: ; 8664 (2:4664)
+PlayerSpawn_ConvertCoords:
push bc
ld a, [wXCoord]
add $4
@@ -67,7 +67,7 @@ PlayerSpawn_ConvertCoords: ; 8664 (2:4664)
call CopyDECoordsToMapObject
ret
-WritePersonXY:
+WriteObjectXY::
ld a, b
call CheckObjectVisibility
ret c
@@ -259,7 +259,7 @@ InitializeVisibleSprites:
Function87b9: ; 87b9 (2:47b9)
ret
-CheckObjectEnteringVisibleRange:
+CheckObjectEnteringVisibleRange::
nop
ld a, [wPlayerStepDirection]
cp $ff
@@ -473,7 +473,7 @@ InitTempObjectRadius: ; 88fd (2:48fd)
ld [hl], a
ret
-TrainerWalkToPlayer:
+TrainerWalkToPlayer::
ldh a, [hLastTalked]
call InitMovementBuffer
ld a, movement_step_sleep
@@ -554,7 +554,7 @@ GetInitialSurfStep: ; 8978 (2:4978)
slow_step LEFT
slow_step RIGHT
-FollowNotExact:
+FollowNotExact::
push bc
ld a, c
call CheckObjectVisibility
@@ -636,7 +636,7 @@ FollowNotExact:
ld [hl], $0
ret
-GetRelativeFacing:
+GetRelativeFacing::
ld a, d
call GetMapObject
ld hl, $0
diff --git a/engine/overworld/player_step.asm b/engine/overworld/player_step.asm
index 8e250295..e55fc4e7 100755
--- a/engine/overworld/player_step.asm
+++ b/engine/overworld/player_step.asm
@@ -1,4 +1,4 @@
-HandlePlayerStep_::
+_HandlePlayerStep::
ld a, [wPlayerStepFlags]
and a
ret z
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
new file mode 100644
index 00000000..7c5bfe55
--- /dev/null
+++ b/engine/overworld/scripting.asm
@@ -0,0 +1,2673 @@
+; Event scripting commands.
+
+EnableScriptMode::
+ push af
+ ld a, SCRIPT_READ
+ ld [wScriptMode], a
+ pop af
+ ret
+
+ScriptEvents::
+ call StartScript
+.loop
+ ld a, [wScriptMode]
+ ld hl, .modes
+ rst JumpTable
+ call CheckScript
+ jr nz, .loop
+ ret
+
+.modes
+ dw EndScript
+ dw RunScriptCommand
+ dw WaitScriptMovement
+ dw WaitScript
+
+EndScript:
+ call StopScript
+ ret
+
+WaitScript:
+ call StopScript
+
+ ld hl, wScriptDelay
+ dec [hl]
+ ret nz
+
+ farcall Function582f
+
+ ld a, SCRIPT_READ
+ ld [wScriptMode], a
+ call StartScript
+ ret
+
+WaitScriptMovement:
+ call StopScript
+
+ ld hl, wVramState
+ bit 7, [hl]
+ ret nz
+
+ farcall Function582f
+
+ ld a, SCRIPT_READ
+ ld [wScriptMode], a
+ call StartScript
+ ret
+
+RunScriptCommand:
+ call GetScriptByte
+ ld hl, ScriptCommandTable
+ rst JumpTable
+ ret
+
+ScriptCommandTable:
+; entries correspond to macros/scripts/events.asm enumeration
+ dw Script_scall ; 00
+ dw Script_farscall ; 01
+ dw Script_memcall ; 02
+ dw Script_sjump ; 03
+ dw Script_farsjump ; 04
+ dw Script_memjump ; 05
+ dw Script_ifequal ; 06
+ dw Script_ifnotequal ; 07
+ dw Script_iffalse ; 08
+ dw Script_iftrue ; 09
+ dw Script_ifgreater ; 0a
+ dw Script_ifless ; 0b
+ dw Script_jumpstd ; 0c
+ dw Script_callstd ; 0d
+ dw Script_callasm ; 0e
+ dw Script_special ; 0f
+ dw Script_memcallasm ; 10
+ dw Script_checkmapscene ; 11
+ dw Script_setmapscene ; 12
+ dw Script_checkscene ; 13
+ dw Script_setscene ; 14
+ dw Script_setval ; 15
+ dw Script_addval ; 16
+ dw Script_random ; 17
+ dw Script_checkver ; 18
+ dw Script_readmem ; 19
+ dw Script_writemem ; 1a
+ dw Script_loadmem ; 1b
+ dw Script_readvar ; 1c
+ dw Script_writevar ; 1d
+ dw Script_loadvar ; 1e
+ dw Script_giveitem ; 1f
+ dw Script_takeitem ; 20
+ dw Script_checkitem ; 21
+ dw Script_givemoney ; 22
+ dw Script_takemoney ; 23
+ dw Script_checkmoney ; 24
+ dw Script_givecoins ; 25
+ dw Script_takecoins ; 26
+ dw Script_checkcoins ; 27
+ dw Script_addcellnum ; 28
+ dw Script_delcellnum ; 29
+ dw Script_checkcellnum ; 2a
+ dw Script_checktime ; 2b
+ dw Script_checkpoke ; 2c
+ dw Script_givepoke ; 2d
+ dw Script_giveegg ; 2e
+ dw Script_givepokemail ; 2f
+ dw Script_checkpokemail ; 30
+ dw Script_checkevent ; 31
+ dw Script_clearevent ; 32
+ dw Script_setevent ; 33
+ dw Script_checkflag ; 34
+ dw Script_clearflag ; 35
+ dw Script_setflag ; 36
+ dw Script_wildon ; 37
+ dw Script_wildoff ; 38
+ dw Script_xycompare ; 39
+ dw Script_warpmod ; 3a
+ dw Script_blackoutmod ; 3b
+ dw Script_warp ; 3c
+ dw Script_getmoney ; 3d
+ dw Script_getcoins ; 3e
+ dw Script_getnum ; 3f
+ dw Script_getmonname ; 40
+ dw Script_getitemname ; 41
+ dw Script_getcurlandmarkname ; 42
+ dw Script_gettrainername ; 43
+ dw Script_getstring ; 44
+ dw Script_itemnotify ; 45
+ dw Script_pocketisfull ; 46
+ dw Script_opentext ; 47
+ dw Script_refreshscreen ; 48
+ dw Script_closetext ; 49
+ dw Script_writeunusedbytebuffer ; 4a
+ dw Script_farwritetext ; 4b
+ dw Script_writetext ; 4c
+ dw Script_repeattext ; 4d
+ dw Script_yesorno ; 4e
+ dw Script_loadmenu ; 4f
+ dw Script_closewindow ; 50
+ dw Script_jumptextfaceplayer ; 51
+ dw Script_jumptext ; 52
+ dw Script_waitbutton ; 53
+ dw Script_promptbutton ; 54
+ dw Script_pokepic ; 55
+ dw Script_closepokepic ; 56
+ dw Script__2dmenu ; 57
+ dw Script_verticalmenu ; 58
+ dw Script_loadpikachudata ; 59
+ dw Script_randomwildmon ; 5a
+ dw Script_loadtemptrainer ; 5b
+ dw Script_loadwildmon ; 5c
+ dw Script_loadtrainer ; 5d
+ dw Script_startbattle ; 5e
+ dw Script_reloadmapafterbattle ; 5f
+ dw Script_catchtutorial ; 60
+ dw Script_trainertext ; 61
+ dw Script_trainerflagaction ; 62
+ dw Script_winlosstext ; 63
+ dw Script_scripttalkafter ; 64
+ dw Script_endifjustbattled ; 65
+ dw Script_checkjustbattled ; 66
+ dw Script_setlasttalked ; 67
+ dw Script_applymovement ; 68
+ dw Script_applymovementlasttalked ; 69
+ dw Script_faceplayer ; 6a
+ dw Script_faceobject ; 6b
+ dw Script_variablesprite ; 6c
+ dw Script_disappear ; 6d
+ dw Script_appear ; 6e
+ dw Script_follow ; 6f
+ dw Script_stopfollow ; 70
+ dw Script_moveobject ; 71
+ dw Script_writeobjectxy ; 72
+ dw Script_loademote ; 73
+ dw Script_showemote ; 74
+ dw Script_turnobject ; 75
+ dw Script_follownotexact ; 76
+ dw Script_earthquake ; 77
+ dw Script_changemapblocks ; 78
+ dw Script_changeblock ; 79
+ dw Script_reloadmap ; 7a
+ dw Script_reloadmappart ; 7b
+ dw Script_writecmdqueue ; 7c
+ dw Script_delcmdqueue ; 7d
+ dw Script_playmusic ; 7e
+ dw Script_encountermusic ; 7f
+ dw Script_musicfadeout ; 80
+ dw Script_playmapmusic ; 81
+ dw Script_dontrestartmapmusic ; 82
+ dw Script_cry ; 83
+ dw Script_playsound ; 84
+ dw Script_waitsfx ; 85
+ dw Script_warpsound ; 86
+ dw Script_specialsound ; 87
+ dw Script_autoinput ; 88
+ dw Script_newloadmap ; 89
+ dw Script_pause ; 8a
+ dw Script_deactivatefacing ; 8b
+ dw Script_prioritysjump ; 8c
+ dw Script_warpcheck ; 8d
+ dw Script_stopandsjump ; 8e
+ dw Script_return ; 8f
+ dw Script_end ; 90
+ dw Script_reloadandreturn ; 91
+ dw Script_endall ; 92
+ dw Script_pokemart ; 93
+ dw Script_elevator ; 94
+ dw Script_trade ; 95
+ dw Script_askforphonenumber ; 96
+ dw Script_phonecall ; 97
+ dw Script_hangup ; 98
+ dw Script_describedecoration ; 99
+ dw Script_fruittree ; 9a
+ dw Script_specialphonecall ; 9b
+ dw Script_checkphonecall ; 9c
+ dw Script_verbosegiveitem ; 9d
+ dw Script_swarm ; 9e
+ dw Script_halloffame ; 9f
+ dw Script_credits ; a0
+ dw Script_warpfacing ; a1
+
+StartScript:
+ ld hl, wScriptFlags
+ set SCRIPT_RUNNING, [hl]
+ ret
+
+CheckScript:
+ ld hl, wScriptFlags
+ bit SCRIPT_RUNNING, [hl]
+ ret
+
+StopScript:
+ ld hl, wScriptFlags
+ res SCRIPT_RUNNING, [hl]
+ ret
+
+Script_callasm:
+; script command 0xe
+; parameters: asm
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, b
+ rst FarCall
+ ret
+
+Script_special:
+; script command 0xf
+; parameters: predefined_script
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ farcall Special
+ ret
+
+Script_memcallasm:
+; script command 0x10
+; parameters: asm
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld b, [hl]
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, b
+ rst FarCall
+ ret
+
+Script_jumptextfaceplayer:
+; script command 0x51
+; parameters: text_pointer
+
+ ld a, [wScriptBank]
+ ld [wScriptTextBank], a
+ call GetScriptByte
+ ld [wScriptTextAddr], a
+ call GetScriptByte
+ ld [wScriptTextAddr + 1], a
+ ld b, BANK(JumpTextFacePlayerScript)
+ ld hl, JumpTextFacePlayerScript
+ jp ScriptJump
+
+Script_jumptext:
+; script command 0x52
+; parameters: text_pointer
+
+ ld a, [wScriptBank]
+ ld [wScriptTextBank], a
+ call GetScriptByte
+ ld [wScriptTextAddr], a
+ call GetScriptByte
+ ld [wScriptTextAddr + 1], a
+ ld b, BANK(JumpTextScript)
+ ld hl, JumpTextScript
+ jp ScriptJump
+
+JumpTextFacePlayerScript:
+ faceplayer
+JumpTextScript:
+ opentext
+ repeattext -1, -1
+ waitbutton
+ closetext
+ end
+
+Script_writetext:
+; script command 0x4c
+; parameters: text_pointer
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [wScriptBank]
+ ld b, a
+ call MapTextbox
+ ret
+
+Script_farwritetext:
+; script command 0x4b
+; parameters: text_pointer
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ call MapTextbox
+ ret
+
+Script_repeattext:
+; script command 0x4d
+; parameters: byte, byte
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ cp -1
+ jr nz, .done
+ ld a, l
+ cp -1
+ jr nz, .done
+ ld hl, wScriptTextBank
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call MapTextbox
+ ret
+
+.done
+ ret
+
+Script_waitbutton:
+; script command 0x53
+
+ jp WaitButton
+
+Script_promptbutton:
+; script command 0x54
+
+ ldh a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ldh [hOAMUpdate], a
+ call WaitBGMap
+ call PromptButton
+ pop af
+ ldh [hOAMUpdate], a
+ ret
+
+Script_yesorno:
+; script command 0x4e
+
+ call YesNoBox
+ ld a, FALSE
+ jr c, .no
+ ld a, TRUE
+.no
+ ld [wScriptVar], a
+ ret
+
+Script_loadmenu:
+; script command 0x4f
+; parameters: menu_header
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld de, LoadMenuHeader
+ ld a, [wScriptBank]
+ call Call_a_de
+ call UpdateSprites
+ ret
+
+Script_closewindow:
+; script command 0x50
+
+ call CloseWindow
+ call UpdateSprites
+ ret
+
+Script_pokepic:
+; script command 0x55
+; parameters: pokemon
+
+ call GetScriptByte
+ and a
+ jr nz, .ok
+ ld a, [wScriptVar]
+.ok
+ ld [wCurPartySpecies], a
+ farcall Pokepic
+ ret
+
+Script_closepokepic:
+; script command 0x56
+
+ farcall ClosePokepic
+ ret
+
+Script_verticalmenu:
+; script command 0x58
+
+ ld a, [wScriptBank]
+ ld hl, VerticalMenu
+ rst FarCall
+ ld a, [wMenuCursorY]
+ jr nc, .ok
+ xor a
+.ok
+ ld [wScriptVar], a
+ ret
+
+Script__2dmenu:
+; script command 0x57
+
+ ld a, [wScriptBank]
+ ld hl, _2DMenu
+ rst FarCall
+ ld a, [wMenuCursorBuffer]
+ jr nc, .ok
+ xor a
+.ok
+ ld [wScriptVar], a
+ ret
+
+Script_verbosegiveitem:
+; script command 0x9d
+; parameters: item, quantity
+
+ call Script_giveitem
+ call CurItemName
+ ld de, wStringBuffer1
+ ld a, STRING_BUFFER_4
+ call CopyConvertedText
+ ld b, BANK(GiveItemScript)
+ ld de, GiveItemScript
+ jp ScriptCall
+
+ret_96f76:
+ ret
+
+GiveItemScript:
+ callasm ret_96f76
+ writetext ReceivedItemText
+ iffalse .Full
+ waitsfx
+ specialsound
+ waitbutton
+ itemnotify
+ end
+
+.Full:
+ promptbutton
+ pocketisfull
+ end
+
+ReceivedItemText:
+ text_far _ReceivedItemText
+ text_end
+
+Script_itemnotify:
+; script command 0x45
+
+ call GetPocketName
+ call CurItemName
+ ld b, BANK(PutItemInPocketText)
+ ld hl, PutItemInPocketText
+ call MapTextbox
+ ret
+
+Script_pocketisfull:
+; script command 0x46
+
+ call GetPocketName
+ call CurItemName
+ ld b, BANK(PocketIsFullText)
+ ld hl, PocketIsFullText
+ call MapTextbox
+ ret
+
+Script_specialsound:
+; script command 0x87
+
+ farcall CheckItemPocket
+ ld a, [wItemAttributeParamBuffer]
+ cp TM_HM
+ ld de, SFX_GET_TM
+ jr z, .play
+ ld de, SFX_ITEM
+.play
+ call PlaySFX
+ call WaitSFX
+ ret
+
+GetPocketName:
+ farcall CheckItemPocket
+ ld a, [wItemAttributeParamBuffer]
+ dec a
+ ld hl, ItemPocketNames
+ maskbits NUM_POCKETS
+ add a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ ld hl, wStringBuffer3
+ call CopyName2
+ ret
+
+INCLUDE "data/items/pocket_names.asm"
+
+CurItemName:
+ ld a, [wCurItem]
+ ld [wNamedObjectIndexBuffer], a
+ call GetItemName
+ ret
+
+PutItemInPocketText:
+ text_far _PutItemInPocketText
+ text_end
+
+PocketIsFullText:
+ text_far _PocketIsFullText
+ text_end
+
+Script_pokemart:
+; script command 0x93
+; parameters: mart_type, mart_id
+
+ call GetScriptByte
+ ld c, a
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld b, a
+ farcall OpenMartDialog
+ ret
+
+Script_elevator:
+; script command 0x94
+; parameters: floor_list_pointer
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld b, a
+ farcall Elevator
+ ret c
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_trade:
+; script command 0x95
+; parameters: trade_id
+
+ call GetScriptByte
+ ld e, a
+ farcall NPCTrade
+ ret
+
+Script_phonecall:
+; script command 0x97
+; parameters: caller_name
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld b, a
+ farcall PhoneCall
+ ret
+
+Script_hangup:
+; script command 0x98
+
+ farcall HangUp
+ ret
+
+Script_askforphonenumber:
+; script command 0x96
+; parameters: number
+
+ call YesNoBox
+ jr c, .refused
+ call GetScriptByte
+ ld c, a
+ farcall AddPhoneNumber
+ jr c, .phonefull
+ xor a ; PHONE_CONTACT_GOT
+ jr .done
+.phonefull
+ ld a, PHONE_CONTACTS_FULL
+ jr .done
+.refused
+ call GetScriptByte
+ ld a, PHONE_CONTACT_REFUSED
+.done
+ ld [wScriptVar], a
+ ret
+
+Script_describedecoration:
+; script command 0x99
+; parameters: byte
+
+ call GetScriptByte
+ ld b, a
+ farcall DescribeDecoration
+ ld h, d
+ ld l, e
+ jp ScriptJump
+
+Script_fruittree:
+; script command 0x9a
+; parameters: tree_id
+
+ call GetScriptByte
+ ld [wCurFruitTree], a
+ ld b, BANK(FruitTreeScript)
+ ld hl, FruitTreeScript
+ jp ScriptJump
+
+Script_swarm:
+; script command 0x9e
+; parameters: map_group, map_id
+
+ call GetScriptByte
+ ld d, a
+ call GetScriptByte
+ ld e, a
+ farcall StoreSwarmMapIndices
+ ret
+
+Script_trainertext:
+; script command 0x61
+; parameters: text_id
+
+ call GetScriptByte
+ ld c, a
+ ld b, 0
+ ld hl, wSeenTextPointer
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wSeenTrainerBank]
+ ld b, a
+ call MapTextbox
+ ret
+
+Script_scripttalkafter:
+; script command 0x64
+
+ ld hl, wScriptAfterPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wSeenTrainerBank]
+ ld b, a
+ jp ScriptJump
+
+Script_trainerflagaction:
+; script command 0x62
+; parameters: action
+
+ xor a
+ ld [wScriptVar], a
+ ld hl, wTempTrainerEventFlag
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call GetScriptByte
+ ld b, a
+ call EventFlagAction
+ ld a, c
+ and a
+ ret z
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_winlosstext:
+; script command 0x63
+; parameters: win_text_pointer, loss_text_pointer
+
+ ld hl, wWinTextPointer
+ call GetScriptByte
+ ld [hli], a
+ call GetScriptByte
+ ld [hli], a
+ ld hl, wLossTextPointer
+ call GetScriptByte
+ ld [hli], a
+ call GetScriptByte
+ ld [hli], a
+ ret
+
+Script_endifjustbattled:
+; script command 0x65
+
+ ld a, [wRunningTrainerBattleScript]
+ and a
+ ret z
+ jp Script_end
+
+Script_checkjustbattled:
+; script command 0x66
+
+ ld a, TRUE
+ ld [wScriptVar], a
+ ld a, [wRunningTrainerBattleScript]
+ and a
+ ret nz
+ xor a
+ ld [wScriptVar], a
+ ret
+
+Script_encountermusic:
+; script command 0x7f
+
+ ld a, [wOtherTrainerClass]
+ ld e, a
+ farcall PlayTrainerEncounterMusic
+ ret
+
+Script_playmapmusic:
+; script command 0x81
+
+ call PlayMapMusic
+ ret
+
+Script_playmusic:
+; script command 0x7e
+; parameters: music_pointer
+
+ ld de, MUSIC_NONE
+ call PlayMusic
+ xor a
+ ld [wMusicFade], a
+ call MaxVolume
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ call PlayMusic
+ ret
+
+Script_musicfadeout:
+; script command 0x80
+; parameters: music, fadetime
+
+ call GetScriptByte
+ ld [wMusicFadeID], a
+ call GetScriptByte
+ ld [wMusicFadeID + 1], a
+ call GetScriptByte
+ and $ff ^ (1 << MUSIC_FADE_IN_F)
+ ld [wMusicFade], a
+ ret
+
+Script_playsound:
+; script command 0x84
+; parameters: sound_pointer
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ call PlaySFX
+ ret
+
+Script_waitsfx:
+; script command 0x85
+
+ call WaitSFX
+ ret
+
+Script_warpsound:
+; script command 0x86
+
+ farcall GetWarpSFX
+ call PlaySFX
+ ret
+
+Script_cry:
+; script command 0x83
+; parameters: cry_id
+
+ call GetScriptByte
+ push af
+ call GetScriptByte
+ pop af
+ and a
+ jr nz, .ok
+ ld a, [wScriptVar]
+.ok
+ call PlayMonCry
+ ret
+
+Script_setlasttalked:
+; script command 0x67
+; parameters: object_id
+
+ call GetScriptByte
+ ldh [hLastTalked], a
+ ret
+
+Script_applymovement:
+; script command 0x68
+; parameters: object_id, data
+
+ call GetScriptByte
+ ld c, a
+
+ApplyMovement:
+ push bc
+ ld a, c
+ farcall SetFlagsForMovement_1
+ pop bc
+
+ push bc
+ call SetFlagsForMovement_2
+ pop bc
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [wScriptBank]
+ ld b, a
+ call GetMovementData
+ ret c
+
+ ld a, SCRIPT_WAIT_MOVEMENT
+ ld [wScriptMode], a
+ call StopScript
+ ret
+
+SetFlagsForMovement_2:
+ farcall _SetFlagsForMovement_2
+ ret
+
+Script_applymovementlasttalked:
+; script command 0x69
+; parameters: data
+; apply movement to last talked
+
+ ldh a, [hLastTalked]
+ ld c, a
+ jp ApplyMovement
+
+Script_faceplayer:
+; script command 0x6a
+
+ ldh a, [hLastTalked]
+ and a
+ ret z
+ ld d, $0
+ ldh a, [hLastTalked]
+ ld e, a
+ farcall GetRelativeFacing
+ ld a, d
+ add a
+ add a
+ ld e, a
+ ldh a, [hLastTalked]
+ ld d, a
+ call ApplyObjectFacing
+ ret
+
+Script_faceobject:
+; script command 0x6b
+; parameters: object1, object2
+
+ call GetScriptByte
+ cp LAST_TALKED
+ jr c, .ok
+ ldh a, [hLastTalked]
+.ok
+ ld e, a
+ call GetScriptByte
+ cp LAST_TALKED
+ jr nz, .ok2
+ ldh a, [hLastTalked]
+.ok2
+ ld d, a
+ push de
+ farcall GetRelativeFacing
+ pop bc
+ ret c
+ ld a, d
+ add a
+ add a
+ ld e, a
+ ld d, c
+ call ApplyObjectFacing
+ ret
+
+Script_turnobject:
+; script command 0x75
+; parameters: object_id, facing
+
+ call GetScriptByte
+ cp LAST_TALKED
+ jr nz, .ok
+ ldh a, [hLastTalked]
+.ok
+ ld d, a
+ call GetScriptByte
+ add a
+ add a
+ ld e, a
+ call ApplyObjectFacing
+ ret
+
+ApplyObjectFacing:
+ ld a, d
+ push de
+ call CheckObjectVisibility
+ jr c, .not_visible
+ ld hl, OBJECT_SPRITE
+ add hl, bc
+ ld a, [hl]
+ push bc
+ call DoesSpriteHaveFacings
+ pop bc
+ jr c, .not_visible ; STILL_SPRITE
+ ld hl, OBJECT_FLAGS1
+ add hl, bc
+ bit FIXED_FACING_F, [hl]
+ jr nz, .not_visible
+ pop de
+ ld a, e
+ call SetSpriteDirection
+ call UpdateSprites
+ ret
+
+.not_visible
+ pop de
+ scf
+ ret
+
+Script_variablesprite:
+; script command 0x6c
+; parameters: byte, sprite
+
+ call GetScriptByte
+ ld e, a
+ ld d, $0
+ ld hl, wVariableSprites
+ add hl, de
+ call GetScriptByte
+ ld [hl], a
+ ret
+
+Script_appear:
+; script command 0x6e
+; parameters: object_id
+
+ call GetScriptByte
+ call _CopyObjectStruct
+ ldh a, [hMapObjectIndexBuffer]
+ ld b, 0 ; clear
+ call ApplyEventActionAppearDisappear
+ ret
+
+Script_disappear:
+; script command 0x6d
+; parameters: object_id
+
+ call GetScriptByte
+ cp LAST_TALKED
+ jr nz, .ok
+ ldh a, [hLastTalked]
+.ok
+ call DeleteObjectStruct
+ ldh a, [hMapObjectIndexBuffer]
+ ld b, 1 ; set
+ call ApplyEventActionAppearDisappear
+ farcall _UpdateSprites
+ ret
+
+ApplyEventActionAppearDisappear:
+ push bc
+ call GetMapObject
+ ld hl, MAPOBJECT_EVENT_FLAG
+ add hl, bc
+ pop bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld a, -1
+ cp e
+ jr nz, .okay
+ cp d
+ jr nz, .okay
+ xor a
+ ret
+.okay
+ call EventFlagAction
+ ret
+
+Script_follow:
+; script command 0x6f
+; parameters: object2, object1
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld c, a
+ farcall StartFollow
+ ret
+
+Script_stopfollow:
+; script command 0x70
+
+ farcall StopFollow
+ ret
+
+Script_moveobject:
+; script command 0x71
+; parameters: object id, x, y
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ add 4
+ ld d, a
+ call GetScriptByte
+ add 4
+ ld e, a
+ farcall CopyDECoordsToMapObject
+ ret
+
+Script_writeobjectxy:
+; script command 0x72
+; parameters: object_id
+
+ call GetScriptByte
+ cp LAST_TALKED
+ jr nz, .ok
+ ldh a, [hLastTalked]
+.ok
+ ld b, a
+ farcall WriteObjectXY
+ ret
+
+Script_follownotexact:
+; script command 0x76
+; parameters: object2, object1
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld c, a
+ farcall FollowNotExact
+ ret
+
+Script_loademote:
+; script command 0x73
+; parameters: bubble
+
+ call GetScriptByte
+ cp EMOTE_FROM_MEM
+ jr nz, .not_var_emote
+ ld a, [wScriptVar]
+.not_var_emote
+ ld c, a
+ farcall LoadEmote
+ ret
+
+Script_showemote:
+; script command 0x74
+; parameters: bubble, object_id, time
+
+ call GetScriptByte
+ ld [wScriptVar], a
+ call GetScriptByte
+ cp LAST_TALKED
+ jr z, .ok
+ ldh [hLastTalked], a
+.ok
+ call GetScriptByte
+ ld [wScriptDelay], a
+ ld b, BANK(ShowEmoteScript)
+ ld de, ShowEmoteScript
+ jp ScriptCall
+
+ShowEmoteScript:
+ loademote EMOTE_FROM_MEM
+ applymovementlasttalked .Show
+ pause 0
+ applymovementlasttalked .Hide
+ end
+
+.Show:
+ show_emote
+ step_sleep 1
+ step_end
+
+.Hide:
+ hide_emote
+ step_sleep 1
+ step_end
+
+Script_earthquake:
+; script command 0x77
+; parameters: param
+
+ ld hl, EarthquakeMovement
+ ld de, wEarthquakeMovementDataBuffer
+ ld bc, EarthquakeMovement.End - EarthquakeMovement
+ call CopyBytes
+ call GetScriptByte
+ ld [wEarthquakeMovementDataBuffer + 1], a
+ and %00111111
+ ld [wEarthquakeMovementDataBuffer + 3], a
+ ld b, BANK(.script)
+ ld de, .script
+ jp ScriptCall
+
+.script
+ applymovement PLAYER, wEarthquakeMovementDataBuffer
+ end
+
+EarthquakeMovement:
+ step_shake 16 ; the 16 gets overwritten with the script byte
+ step_sleep 16 ; the 16 gets overwritten with the lower 6 bits of the script byte
+ step_end
+.End
+
+Script_loadpikachudata:
+; script command 0x59
+
+ ld a, PIKACHU
+ ld [wTempWildMonSpecies], a
+ ld a, 5
+ ld [wCurPartyLevel], a
+ ret
+
+Script_randomwildmon:
+; script command 0x5a
+
+ xor a
+ ld [wBattleScriptFlags], a
+ ret
+
+Script_loadtemptrainer:
+; script command 0x5b
+
+ ld a, (1 << 7) | 1
+ ld [wBattleScriptFlags], a
+ ld a, [wTempTrainerClass]
+ ld [wOtherTrainerClass], a
+ ld a, [wTempTrainerID]
+ ld [wOtherTrainerID], a
+ ret
+
+Script_loadwildmon:
+; script command 0x5c
+; parameters: pokemon, level
+
+ ld a, (1 << 7)
+ ld [wBattleScriptFlags], a
+ call GetScriptByte
+ ld [wTempWildMonSpecies], a
+ call GetScriptByte
+ ld [wCurPartyLevel], a
+ ret
+
+Script_loadtrainer:
+; script command 0x5d
+; parameters: trainer_group, trainer_id
+
+ ld a, (1 << 7) | 1
+ ld [wBattleScriptFlags], a
+ call GetScriptByte
+ ld [wOtherTrainerClass], a
+ call GetScriptByte
+ ld [wOtherTrainerID], a
+ ret
+
+Script_startbattle:
+; script command 0x5e
+
+ call BufferScreen
+ predef StartBattle
+ ld a, [wBattleResult]
+ and $ff ^ BATTLERESULT_BITMASK
+ ld [wScriptVar], a
+ ret
+
+Script_catchtutorial:
+; script command 0x60
+; parameters: byte
+
+ call GetScriptByte
+ ld [wBattleType], a
+ call BufferScreen
+ farcall CatchTutorial
+ jp Script_reloadmap
+
+Script_reloadmapafterbattle:
+; script command 0x5f
+
+ ld hl, wBattleScriptFlags
+ ld d, [hl]
+ ld [hl], 0
+ ld a, [wBattleResult]
+ and $ff ^ BATTLERESULT_BITMASK
+ cp LOSE
+ jr nz, .notblackedout
+ ld b, BANK(Script_BattleWhiteout)
+ ld hl, Script_BattleWhiteout
+ jp ScriptJump
+
+.notblackedout
+ bit 0, d
+ jr z, .was_wild
+ farcall MomTriesToBuySomething
+ jr .done
+
+.was_wild
+ ld a, [wBattleResult]
+ bit BATTLERESULT_BOX_FULL, a
+ jr z, .done
+ ld b, BANK(Script_SpecialBillCall)
+ ld de, Script_SpecialBillCall
+ farcall LoadScriptBDE
+.done
+ jp Script_reloadmap
+
+Script_reloadmap:
+; script command 0x7a
+
+ xor a
+ ld [wBattleScriptFlags], a
+ ld a, MAPSETUP_RELOADMAP
+ ldh [hMapEntryMethod], a
+ ld a, MAPSTATUS_ENTER
+ call LoadMapStatus
+ call StopScript
+ ret
+
+Script_scall:
+; script command 0x0
+; parameters: pointer
+
+ ld a, [wScriptBank]
+ ld b, a
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ jr ScriptCall
+
+Script_farscall:
+; script command 0x1
+; parameters: pointer
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ jr ScriptCall
+
+Script_memcall:
+; script command 0x2
+; parameters: pointer
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld b, [hl]
+ inc hl
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ; fallthrough
+
+ScriptCall:
+; Bug: The script stack has a capacity of 5 scripts, yet there is
+; nothing to stop you from pushing a sixth script. The high part
+; of the script address can then be overwritten by modifications
+; to wScriptDelay, causing the script to return to the rst/interrupt
+; space.
+
+ push de
+ ld hl, wScriptStackSize
+ ld e, [hl]
+ inc [hl]
+ ld d, 0
+ ld hl, wScriptStack
+ add hl, de
+ add hl, de
+ add hl, de
+ pop de
+ ld a, [wScriptBank]
+ ld [hli], a
+ ld a, [wScriptPos]
+ ld [hli], a
+ ld a, [wScriptPos + 1]
+ ld [hl], a
+ ld a, b
+ ld [wScriptBank], a
+ ld a, e
+ ld [wScriptPos], a
+ ld a, d
+ ld [wScriptPos + 1], a
+ ret
+
+CallCallback::
+ ld a, [wScriptBank]
+ or $80
+ ld [wScriptBank], a
+ jp ScriptCall
+
+Script_sjump:
+; script command 0x3
+; parameters: pointer
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [wScriptBank]
+ ld b, a
+ jp ScriptJump
+
+Script_farsjump:
+; script command 0x4
+; parameters: pointer
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ jp ScriptJump
+
+Script_memjump:
+; script command 0x5
+; parameters: pointer
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld b, [hl]
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp ScriptJump
+
+Script_iffalse:
+; script command 0x8
+; parameters: pointer
+
+ ld a, [wScriptVar]
+ and a
+ jp nz, SkipTwoScriptBytes
+ jp Script_sjump
+
+Script_iftrue:
+; script command 0x9
+; parameters: pointer
+
+ ld a, [wScriptVar]
+ and a
+ jp nz, Script_sjump
+ jp SkipTwoScriptBytes
+
+Script_ifequal:
+; script command 0x6
+; parameters: byte, pointer
+
+ call GetScriptByte
+ ld hl, wScriptVar
+ cp [hl]
+ jr z, Script_sjump
+ jr SkipTwoScriptBytes
+
+Script_ifnotequal:
+; script command 0x7
+; parameters: byte, pointer
+
+ call GetScriptByte
+ ld hl, wScriptVar
+ cp [hl]
+ jr nz, Script_sjump
+ jr SkipTwoScriptBytes
+
+Script_ifgreater:
+; script command 0xa
+; parameters: byte, pointer
+
+ ld a, [wScriptVar]
+ ld b, a
+ call GetScriptByte
+ cp b
+ jr c, Script_sjump
+ jr SkipTwoScriptBytes
+
+Script_ifless:
+; script command 0xb
+; parameters: byte, pointer
+
+ call GetScriptByte
+ ld b, a
+ ld a, [wScriptVar]
+ cp b
+ jr c, Script_sjump
+ jr SkipTwoScriptBytes
+
+Script_jumpstd:
+; script command 0xc
+; parameters: predefined_script
+
+ call StdScript
+ jr ScriptJump
+
+Script_callstd:
+; script command 0xd
+; parameters: predefined_script
+
+ call StdScript
+ ld d, h
+ ld e, l
+ jp ScriptCall
+
+StdScript:
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld hl, StdScripts
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, BANK(StdScripts)
+ call GetFarByte
+ ld b, a
+ inc hl
+ ld a, BANK(StdScripts)
+ call GetFarHalfword
+ ret
+
+SkipTwoScriptBytes:
+ call GetScriptByte
+ call GetScriptByte
+ ret
+
+ScriptJump:
+ ld a, b
+ ld [wScriptBank], a
+ ld a, l
+ ld [wScriptPos], a
+ ld a, h
+ ld [wScriptPos + 1], a
+ ret
+
+Script_prioritysjump:
+; script command 0x8c
+; parameters: pointer
+
+ ld a, [wScriptBank]
+ ld [wPriorityScriptBank], a
+ call GetScriptByte
+ ld [wPriorityScriptAddr], a
+ call GetScriptByte
+ ld [wPriorityScriptAddr + 1], a
+ ld hl, wScriptFlags
+ set 3, [hl]
+ ret
+
+Script_checkscene:
+; script command 0x13
+
+ call CheckScenes
+ jr z, .no_scene
+ ld [wScriptVar], a
+ ret
+
+.no_scene
+ ld a, $ff
+ ld [wScriptVar], a
+ ret
+
+Script_checkmapscene:
+; script command 0x11
+; parameters: map_group, map_id
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld c, a
+ call GetMapSceneID
+ ld a, d
+ or e
+ jr z, .no_scene
+ ld a, [de]
+ ld [wScriptVar], a
+ ret
+
+.no_scene
+ ld a, $ff
+ ld [wScriptVar], a
+ ret
+
+Script_setscene:
+; script command 0x14
+; parameters: scene_id
+
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapNumber]
+ ld c, a
+ jr DoScene
+
+Script_setmapscene:
+; script command 0x12
+; parameters: map_group, map_id, scene_id
+
+ call GetScriptByte
+ ld b, a
+ call GetScriptByte
+ ld c, a
+DoScene:
+ call GetMapSceneID
+ ld a, d
+ or e
+ jr z, .no_scene
+ call GetScriptByte
+ ld [de], a
+.no_scene
+ ret
+
+Script_readmem:
+; script command 0x19
+; parameters: address
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [hl]
+ ld [wScriptVar], a
+ ret
+
+Script_writemem:
+; script command 0x1a
+; parameters: address
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [wScriptVar]
+ ld [hl], a
+ ret
+
+Script_loadmem:
+; script command 0x1b
+; parameters: address, value
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ call GetScriptByte
+ ld [hl], a
+ ret
+
+Script_setval:
+; script command 0x15
+; parameters: value
+
+ call GetScriptByte
+ ld [wScriptVar], a
+ ret
+
+Script_addval:
+; script command 0x16
+; parameters: value
+
+ call GetScriptByte
+ ld hl, wScriptVar
+ add [hl]
+ ld [hl], a
+ ret
+
+Script_random:
+; script command 0x17
+; parameters: input
+
+ call GetScriptByte
+ ld [wScriptVar], a
+ and a
+ ret z
+
+ ld c, a
+ call .Divide256byC
+ and a
+ jr z, .no_restriction ; 256 % b == 0
+ ld b, a
+ xor a
+ sub b
+ ld b, a
+.loop
+ push bc
+ call Random
+ pop bc
+ ldh a, [hRandomAdd]
+ cp b
+ jr nc, .loop
+ jr .finish
+
+.no_restriction
+ push bc
+ call Random
+ pop bc
+ ldh a, [hRandomAdd]
+
+.finish
+ push af
+ ld a, [wScriptVar]
+ ld c, a
+ pop af
+ call SimpleDivide
+ ld [wScriptVar], a
+ ret
+
+.Divide256byC:
+ xor a
+ ld b, a
+ sub c
+.mod_loop
+ inc b
+ sub c
+ jr nc, .mod_loop
+ dec b
+ add c
+ ret
+
+Script_readvar:
+; script command 0x1c
+; parameters: variable_id
+
+ call GetScriptByte
+ call GetVarAction
+ ld a, [de]
+ ld [wScriptVar], a
+ ret
+
+Script_writevar:
+; script command 0x1d
+; parameters: variable_id
+
+ call GetScriptByte
+ call GetVarAction
+ ld a, [wScriptVar]
+ ld [de], a
+ ret
+
+Script_loadvar:
+; script command 0x1e
+; parameters: variable_id, value
+
+ call GetScriptByte
+ call GetVarAction
+ call GetScriptByte
+ ld [de], a
+ ret
+
+GetVarAction:
+ ld c, a
+ farcall _GetVarAction
+ ret
+
+Script_checkver:
+; script command 0x18
+
+ ld a, [.gs_version]
+ ld [wScriptVar], a
+ ret
+
+.gs_version:
+ db GS_VERSION
+
+Script_getmonname:
+; script command 0x40
+; parameters: string_buffer, mon_id (0 aka USE_SCRIPT_VAR to use wScriptVar)
+
+ call GetScriptByte
+ and a
+ jr nz, .gotit
+ ld a, [wScriptVar]
+.gotit
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld de, wStringBuffer1
+
+GetStringBuffer:
+ call GetScriptByte
+ cp NUM_STRING_BUFFERS
+ jr c, .ok
+ xor a
+.ok
+
+CopyConvertedText:
+ ld hl, wStringBuffer3
+ ld bc, wStringBuffer4 - wStringBuffer3
+ call AddNTimes
+ call CopyName2
+ ret
+
+Script_getitemname:
+; script command 0x41
+; parameters: string_buffer, item_id (0 aka USE_SCRIPT_VAR to use wScriptVar)
+
+ call GetScriptByte
+ and a ; USE_SCRIPT_VAR
+ jr nz, .ok
+ ld a, [wScriptVar]
+.ok
+ ld [wNamedObjectIndexBuffer], a
+ call GetItemName
+ ld de, wStringBuffer1
+ jr GetStringBuffer
+
+Script_getcurlandmarkname:
+; script command 0x42
+; parameters: string_buffer
+
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapNumber]
+ ld c, a
+ call GetWorldMapLocation
+
+ConvertLandmarkToText:
+ ld e, a
+ farcall GetLandmarkName
+ ld de, wStringBuffer1
+ jp GetStringBuffer
+
+Script_gettrainername:
+; script command 0x43
+; parameters: string_buffer, trainer_group, trainer_id
+
+ call GetScriptByte
+ ld c, a
+ call GetScriptByte
+ ld b, a
+ farcall GetTrainerName
+ jr GetStringBuffer
+
+Script_getmoney:
+; script command 0x3d
+; parameters: string_buffer, account
+
+ call ResetStringBuffer1
+ call GetMoneyAccount
+ ld hl, wStringBuffer1
+ lb bc, PRINTNUM_LEFTALIGN | 3, 6
+ call PrintNum
+ ld de, wStringBuffer1
+ jp GetStringBuffer
+
+Script_getcoins:
+; script command 0x3e
+; parameters: string_buffer
+
+ call ResetStringBuffer1
+ ld hl, wStringBuffer1
+ ld de, wCoins
+ lb bc, PRINTNUM_LEFTALIGN | 2, 6
+ call PrintNum
+ ld de, wStringBuffer1
+ jp GetStringBuffer
+
+Script_getnum:
+; script command 0x3f
+; parameters: string_buffer
+
+ call ResetStringBuffer1
+ ld de, wScriptVar
+ ld hl, wStringBuffer1
+ lb bc, PRINTNUM_LEFTALIGN | 1, 3
+ call PrintNum
+ ld de, wStringBuffer1
+ jp GetStringBuffer
+
+ResetStringBuffer1:
+ ld hl, wStringBuffer1
+ ld bc, NAME_LENGTH + 2
+ ld a, "@"
+ call ByteFill
+ ret
+
+Script_getstring:
+; script command 0x44
+; parameters: string_buffer, text_pointer
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld hl, CopyName1
+ rst FarCall
+ ld de, wStringBuffer2
+ jp GetStringBuffer
+
+Script_givepokemail:
+; script command 0x2f
+; parameters: pointer
+
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ ld a, [wScriptBank]
+ call GetFarByte
+ ld b, a
+ push bc
+ inc hl
+ ld bc, MAIL_MSG_LENGTH
+ ld de, wceed
+ ld a, [wScriptBank]
+ call FarCopyBytes
+ pop bc
+ farcall GivePokeMail
+ ret
+
+Script_checkpokemail:
+; script command 0x30
+; parameters: pointer
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld b, a
+ farcall CheckPokeMail
+ ret
+
+Script_giveitem:
+; script command 0x1f
+; parameters: item, quantity
+
+ call GetScriptByte
+ cp ITEM_FROM_MEM
+ jr nz, .ok
+ ld a, [wScriptVar]
+.ok
+ ld [wCurItem], a
+ call GetScriptByte
+ ld [wItemQuantityChangeBuffer], a
+ ld hl, wNumItems
+ call ReceiveItem
+ jr nc, .full
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+.full
+ xor a
+ ld [wScriptVar], a
+ ret
+
+Script_takeitem:
+; script command 0x20
+; parameters: item, quantity
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld [wCurItem], a
+ call GetScriptByte
+ ld [wItemQuantityChangeBuffer], a
+ ld a, -1
+ ld [wCurItemQuantity], a
+ ld hl, wNumItems
+ call TossItem
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_checkitem:
+; script command 0x21
+; parameters: item
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld [wCurItem], a
+ ld hl, wNumItems
+ call CheckItem
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_givemoney:
+; script command 0x22
+; parameters: account, money
+
+ call GetMoneyAccount
+ call LoadMoneyAmountToMem
+ farcall GiveMoney
+ ret
+
+Script_takemoney:
+; script command 0x23
+; parameters: account, money
+
+ call GetMoneyAccount
+ call LoadMoneyAmountToMem
+ farcall TakeMoney
+ ret
+
+Script_checkmoney:
+; script command 0x24
+; parameters: account, money
+
+ call GetMoneyAccount
+ call LoadMoneyAmountToMem
+ farcall CompareMoney
+
+CompareMoneyAction:
+ jr c, .less
+ jr z, .exact
+ ld a, HAVE_MORE
+ jr .done
+.exact
+ ld a, HAVE_AMOUNT
+ jr .done
+.less
+ ld a, HAVE_LESS
+.done
+ ld [wScriptVar], a
+ ret
+
+GetMoneyAccount:
+ call GetScriptByte
+ and a
+ ld de, wMoney ; YOUR_MONEY
+ ret z
+ ld de, wMomsMoney ; MOMS_MONEY
+ ret
+
+LoadMoneyAmountToMem:
+ ld bc, hMoneyTemp
+ push bc
+ call GetScriptByte
+ ld [bc], a
+ inc bc
+ call GetScriptByte
+ ld [bc], a
+ inc bc
+ call GetScriptByte
+ ld [bc], a
+ pop bc
+ ret
+
+Script_givecoins:
+; script command 0x25
+; parameters: coins
+
+ call LoadCoinAmountToMem
+ farcall GiveCoins
+ ret
+
+Script_takecoins:
+; script command 0x26
+; parameters: coins
+
+ call LoadCoinAmountToMem
+ farcall TakeCoins
+ ret
+
+Script_checkcoins:
+; script command 0x27
+; parameters: coins
+
+ call LoadCoinAmountToMem
+ farcall CheckCoins
+ jr CompareMoneyAction
+
+LoadCoinAmountToMem:
+ call GetScriptByte
+ ldh [hMoneyTemp + 1], a
+ call GetScriptByte
+ ldh [hMoneyTemp], a
+ ld bc, hMoneyTemp
+ ret
+
+Script_checktime:
+; script command 0x2b
+; parameters: time
+
+ xor a
+ ld [wScriptVar], a
+ farcall CheckTime
+ call GetScriptByte
+ and c
+ ret z
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_checkpoke:
+; script command 0x2c
+; parameters: pokemon
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld hl, wPartySpecies
+ ld de, 1
+ call IsInArray
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_addcellnum:
+; script command 0x28
+; parameters: person
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld c, a
+ farcall AddPhoneNumber
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_delcellnum:
+; script command 0x29
+; parameters: person
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld c, a
+ farcall DelCellNum
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_checkcellnum:
+; script command 0x2a
+; parameters: person
+; returns false if the cell number is not in your phone
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld c, a
+ farcall CheckCellNum
+ ret nc
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_specialphonecall:
+; script command 0x9b
+; parameters: call_id
+
+ call GetScriptByte
+ ld [wSpecialPhoneCallID], a
+ call GetScriptByte
+ ld [wSpecialPhoneCallID + 1], a
+ ret
+
+Script_checkphonecall:
+; script command 0x9c
+; returns false if no special phone call is stored
+
+ ld a, [wSpecialPhoneCallID]
+ and a
+ jr z, .ok
+ ld a, TRUE
+.ok
+ ld [wScriptVar], a
+ ret
+
+Script_givepoke:
+; script command 0x2d
+; parameters: pokemon, level, item, trainer, trainer_name_pointer, pkmn_nickname
+
+ call GetScriptByte
+ ld [wCurPartySpecies], a
+ call GetScriptByte
+ ld [wCurPartyLevel], a
+ call GetScriptByte
+ ld [wCurItem], a
+ call GetScriptByte
+ and a
+ ld b, a
+ jr z, .ok
+ ld hl, wScriptPos
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call GetScriptByte
+ call GetScriptByte
+ call GetScriptByte
+ call GetScriptByte
+.ok
+ farcall GivePoke
+ ld a, b
+ ld [wScriptVar], a
+ ret
+
+Script_giveegg:
+; script command 0x2e
+; parameters: pokemon, level
+; if no room in the party, return 0 in wScriptVar; else, return 2
+
+ xor a ; PARTYMON
+ ld [wScriptVar], a
+ ld [wMonType], a
+ call GetScriptByte
+ ld [wCurPartySpecies], a
+ call GetScriptByte
+ ld [wCurPartyLevel], a
+ farcall GiveEgg
+ ret nc
+ ld a, 2
+ ld [wScriptVar], a
+ ret
+
+Script_setevent:
+; script command 0x33
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, SET_FLAG
+ call EventFlagAction
+ ret
+
+Script_clearevent:
+; script command 0x32
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, RESET_FLAG
+ call EventFlagAction
+ ret
+
+Script_checkevent:
+; script command 0x31
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, CHECK_FLAG
+ call EventFlagAction
+ ld a, c
+ and a
+ jr z, .false
+ ld a, TRUE
+.false
+ ld [wScriptVar], a
+ ret
+
+Script_setflag:
+; script command 0x36
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, SET_FLAG
+ call _EngineFlagAction
+ ret
+
+Script_clearflag:
+; script command 0x35
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, RESET_FLAG
+ call _EngineFlagAction
+ ret
+
+Script_checkflag:
+; script command 0x34
+; parameters: bit_number
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld b, CHECK_FLAG
+ call _EngineFlagAction
+ ld a, c
+ and a
+ jr z, .false
+ ld a, TRUE
+.false
+ ld [wScriptVar], a
+ ret
+
+_EngineFlagAction:
+ farcall EngineFlagAction
+ ret
+
+Script_wildoff:
+; script command 0x38
+
+ ld hl, wStatusFlags
+ set STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl]
+ ret
+
+Script_wildon:
+; script command 0x37
+
+ ld hl, wStatusFlags
+ res STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl]
+ ret
+
+Script_xycompare:
+; script command 0x39
+; parameters: pointer
+
+ call GetScriptByte
+ ld [wXYComparePointer], a
+ call GetScriptByte
+ ld [wXYComparePointer + 1], a
+ ret
+
+Script_warpfacing:
+; script command 0xa1
+; parameters: facing, map_group, map_id, x, y
+
+ call GetScriptByte
+ maskbits NUM_DIRECTIONS
+ ld c, a
+ ld a, [wPlayerSpriteSetupFlags]
+ set PLAYERSPRITESETUP_CUSTOM_FACING_F, a
+ or c
+ ld [wPlayerSpriteSetupFlags], a
+; fall through
+
+Script_warp:
+; script command 0x3c
+; parameters: map_group, map_id, x, y
+
+; This seems to be some sort of error handling case.
+ call GetScriptByte
+ and a
+ jr z, .not_ok
+ ld [wMapGroup], a
+ call GetScriptByte
+ ld [wMapNumber], a
+ call GetScriptByte
+ ld [wXCoord], a
+ call GetScriptByte
+ ld [wYCoord], a
+ ld a, SPAWN_N_A
+ ld [wDefaultSpawnpoint], a
+ ld a, MAPSETUP_WARP
+ ldh [hMapEntryMethod], a
+ ld a, MAPSTATUS_ENTER
+ call LoadMapStatus
+ call StopScript
+ ret
+
+.not_ok
+ call GetScriptByte
+ call GetScriptByte
+ call GetScriptByte
+ ld a, SPAWN_N_A
+ ld [wDefaultSpawnpoint], a
+ ld a, MAPSETUP_BADWARP
+ ldh [hMapEntryMethod], a
+ ld a, MAPSTATUS_ENTER
+ call LoadMapStatus
+ call StopScript
+ ret
+
+Script_warpmod:
+; script command 0x3a
+; parameters: warp_id, map_group, map_id
+
+ call GetScriptByte
+ ld [wBackupWarpNumber], a
+ call GetScriptByte
+ ld [wBackupMapGroup], a
+ call GetScriptByte
+ ld [wBackupMapNumber], a
+ ret
+
+Script_blackoutmod:
+; script command 0x3b
+; parameters: map_group, map_id
+
+ call GetScriptByte
+ ld [wLastSpawnMapGroup], a
+ call GetScriptByte
+ ld [wLastSpawnMapNumber], a
+ ret
+
+Script_dontrestartmapmusic:
+; script command 0x82
+
+ ld a, TRUE
+ ld [wDontPlayMapMusicOnReload], a
+ ret
+
+Script_writecmdqueue:
+; script command 0x7c
+; parameters: queue_pointer
+
+ call GetScriptByte
+ ld e, a
+ call GetScriptByte
+ ld d, a
+ ld a, [wScriptBank]
+ ld b, a
+ farcall WriteCmdQueue ; no need to farcall
+ ret
+
+Script_delcmdqueue:
+; script command 0x7d
+; parameters: byte
+
+ xor a
+ ld [wScriptVar], a
+ call GetScriptByte
+ ld b, a
+ farcall DelCmdQueue ; no need to farcall
+ ret c
+ ld a, TRUE
+ ld [wScriptVar], a
+ ret
+
+Script_changemapblocks:
+; script command 0x78
+; parameters: map_data_pointer
+
+ call GetScriptByte
+ ld [wMapBlocksBank], a
+ call GetScriptByte
+ ld [wMapBlocksPointer], a
+ call GetScriptByte
+ ld [wMapBlocksPointer + 1], a
+ call ChangeMap
+ call BufferScreen
+ ret
+
+Script_changeblock:
+; script command 0x79
+; parameters: x, y, block
+
+ call GetScriptByte
+ add 4
+ ld d, a
+ call GetScriptByte
+ add 4
+ ld e, a
+ call GetBlockLocation
+ call GetScriptByte
+ ld [hl], a
+ call BufferScreen
+ ret
+
+Script_reloadmappart::
+; script command 0x7b
+
+ xor a
+ ldh [hBGMapMode], a
+ call OverworldTextModeSwitch
+ call GetMovementPermissions
+ call ApplyTilemap
+ call UpdateSprites
+ ret
+
+Script_warpcheck:
+; script command 0x8d
+
+ call WarpCheck
+ ret nc
+ farcall EnableEvents
+ ret
+
+Script_enableevents:
+; unused
+ farcall EnableEvents
+ ret
+
+Script_newloadmap:
+; script command 0x89
+; parameters: which_method
+
+ call GetScriptByte
+ ldh [hMapEntryMethod], a
+ ld a, MAPSTATUS_ENTER
+ call LoadMapStatus
+ call StopScript
+ ret
+
+Script_reloadandreturn:
+; script command 0x91
+
+ call Script_newloadmap
+ jp Script_end
+
+Script_opentext:
+; script command 0x47
+
+ call OpenText
+ ret
+
+Script_refreshscreen:
+; script command 0x48
+; parameters: dummy
+
+ call RefreshScreen
+ call GetScriptByte
+ ret
+
+Script_writeunusedbytebuffer:
+; script command 0x4a
+; parameters: byte
+
+ call GetScriptByte
+ ld [wUnusedScriptByteBuffer], a
+ ret
+
+ db closetext_command ; unused
+
+Script_closetext:
+; script command 0x49
+
+ ldh a, [hOAMUpdate]
+ push af
+ ld a, $01
+ ldh [hOAMUpdate], a
+ call WaitBGMap
+ pop af
+ ldh [hOAMUpdate], a
+ call CloseText
+ ret
+
+Script_autoinput:
+; script command 0x88
+; parameters: input_pointer
+
+ call GetScriptByte
+ push af
+ call GetScriptByte
+ ld l, a
+ call GetScriptByte
+ ld h, a
+ pop af
+ call StartAutoInput
+ ret
+
+Script_pause:
+; script command 0x8a
+; parameters: length
+
+ call GetScriptByte
+ and a
+ jr z, .loop
+ ld [wScriptDelay], a
+.loop
+ ld c, 2
+ call DelayFrames
+ ld hl, wScriptDelay
+ dec [hl]
+ jr nz, .loop
+ ret
+
+Script_deactivatefacing:
+; script command 0x8b
+; parameters: time
+
+ call GetScriptByte
+ and a
+ jr z, .no_time
+ ld [wScriptDelay], a
+.no_time
+ ld a, SCRIPT_WAIT
+ ld [wScriptMode], a
+ call StopScript
+ ret
+
+Script_stopandsjump:
+; script command 0x8e
+; parameters: pointer
+
+ call StopScript
+ jp Script_sjump
+
+Script_end:
+; script command 0x90
+
+ call ExitScriptSubroutine
+ jr c, .resume
+ ret
+
+.resume
+ xor a
+ ld [wScriptRunning], a
+ ld a, SCRIPT_OFF
+ ld [wScriptMode], a
+ ld hl, wScriptFlags
+ res 0, [hl]
+ call StopScript
+ ret
+
+Script_return:
+; script command 0x8f
+
+ call ExitScriptSubroutine
+ jr c, .dummy
+.dummy
+ ld hl, wScriptFlags
+ res 0, [hl]
+ call StopScript
+ ret
+
+ExitScriptSubroutine:
+; Return carry if there's no parent to return to.
+
+ ld hl, wScriptStackSize
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+ ld e, [hl]
+ ld d, $0
+ ld hl, wScriptStack
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld b, a
+ and " "
+ ld [wScriptBank], a
+ ld a, [hli]
+ ld e, a
+ ld [wScriptPos], a
+ ld a, [hl]
+ ld d, a
+ ld [wScriptPos + 1], a
+ and a
+ ret
+.done
+ scf
+ ret
+
+Script_endall:
+; script command 0x92
+
+ xor a
+ ld [wScriptStackSize], a
+ ld [wScriptRunning], a
+ ld a, SCRIPT_OFF
+ ld [wScriptMode], a
+ ld hl, wScriptFlags
+ res 0, [hl]
+ call StopScript
+ ret
+
+Script_halloffame:
+; script command 0x9f
+
+ ld hl, wGameTimerPause
+ res GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ farcall HallOfFame
+ ld hl, wGameTimerPause
+ set GAMETIMERPAUSE_TIMER_PAUSED_F, [hl]
+ jr ReturnFromCredits
+
+Script_credits:
+; script command 0xa0
+
+ farcall RedCredits
+ReturnFromCredits:
+ call Script_endall
+ ld a, MAPSTATUS_DONE
+ call LoadMapStatus
+ call StopScript
+ ret
+
+; unused
+ ld a, [.gs_version]
+ ld [wScriptVar], a
+ ret
+
+.gs_version:
+ db GS_VERSION
diff --git a/engine/overworld/time.asm b/engine/overworld/time.asm
index 2ca7e101..5798ee20 100755
--- a/engine/overworld/time.asm
+++ b/engine/overworld/time.asm
@@ -9,10 +9,10 @@ ClearDailyTimers:
ld [wDailyResetTimer], a
ret
-InitCallReceiveDelay:
+InitCallReceiveDelay::
xor a
ld [wTimeCyclesSinceLastCall], a
-Function11804: ; 11804 (4:5804)
+Function11804:
ld a, [wTimeCyclesSinceLastCall]
cp $3
jr c, .asm_1180d
@@ -82,7 +82,7 @@ asm_11867:
ld hl, wDailyResetTimer
jp Function1182e
-CheckDailyResetTimer:
+CheckDailyResetTimer::
ld hl, wDailyResetTimer
call Function1183b
ret nc
@@ -102,7 +102,7 @@ StartBugContestTimer:
call CopyDayHourMinSecToHL
ret
-CheckBugContestTimer:
+CheckBugContestTimer::
ld hl, wBugContestStartTime
call CalcSecsMinsHoursDaysSince
ld a, [wDaysSince]
@@ -141,7 +141,7 @@ Function118c9: ; 118c9 (4:58c9)
call CopyDayToHL
ret
-CheckPokerusTick:
+CheckPokerusTick::
ld hl, wTimerEventStartDay
call CalcDaysSince
call Function119b4
diff --git a/engine/overworld/variables.asm b/engine/overworld/variables.asm
index 445440d2..6483232e 100755
--- a/engine/overworld/variables.asm
+++ b/engine/overworld/variables.asm
@@ -1,4 +1,4 @@
-GetVarAction_::
+_GetVarAction::
ld a, c
cp NUM_VARS
jr c, .valid
diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm
index 39e6ea47..c4ecbdc7 100755
--- a/engine/pokemon/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
@@ -998,7 +998,7 @@ Functiondf65: ; df65 (3:5f65)
jr nz, .asm_df89
ret
-GiveEgg: ; df92 (3:5f92)
+GiveEgg::
ld a, [wCurPartySpecies]
push af
callfar GetPreEvolution
@@ -1482,7 +1482,7 @@ CalcMonStatC: ; e181
pop hl
ret
-GivePoke: ; Give a Pokemon from script
+GivePoke::
push de
push bc
xor a
diff --git a/home/region.asm b/home/region.asm
index e752a605..71c19662 100755
--- a/home/region.asm
+++ b/home/region.asm
@@ -39,9 +39,9 @@ Function2ffe::
ld [hli], a
ld [hli], a
ld [hl], a
- ld a, [wd17a]
+ ld a, [wXYComparePointer]
ld l, a
- ld a, [wd17b]
+ ld a, [wXYComparePointer + 1]
ld h, a
or l
jr z, .quit
diff --git a/hram.asm b/hram.asm
index 4ed58711..30ecafad 100755
--- a/hram.asm
+++ b/hram.asm
@@ -29,7 +29,7 @@ hVBlank:: db ; ffa0
hMapEntryMethod:: db ; ffa1
hMenuReturn:: db ; ffa2
-hFFA3:: db ; ffa3
+hUnusedFFA3:: db ; ffa3
hJoypadReleased:: db ; ffa4
hJoypadPressed:: db ; ffa5
diff --git a/layout.link b/layout.link
index 8ad47c63..6adf1ce0 100644
--- a/layout.link
+++ b/layout.link
@@ -116,8 +116,8 @@ ROMX $24
org $4000
"bank24"
ROMX $25
- org $4000
- "bank25"
+ "Maps"
+ "Events"
ROMX $26
org $4000
"bank26"
@@ -174,7 +174,6 @@ ROMX $40
org $4000
"bank40"
ROMX $41
- org $4000
"bank41"
ROMX $42
"Map Scripts 1"
diff --git a/macros/legacy.asm b/macros/legacy.asm
index ff6bf7c9..eae91e88 100644
--- a/macros/legacy.asm
+++ b/macros/legacy.asm
@@ -187,7 +187,6 @@ talkaftercheck EQUS "checkjustbattled"
playrammusic EQUS "encountermusic"
reloadmapmusic EQUS "dontrestartmapmusic"
resetfuncs EQUS "endall"
-storetext EQUS "battletowertext"
displaylocation EQUS "landmarktotext"
givepokeitem EQUS "givepokemail"
checkpokeitem EQUS "checkpokemail"
diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm
index dd5af81d..3a3cf6e3 100644
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -988,8 +988,7 @@ ENDM
enum swarm_command ; $9e
swarm: MACRO
db swarm_command
- db \1 ; flag
- map_id \2 ; map
+ map_id \1 ; map
ENDM
enum halloffame_command ; $9f
@@ -1010,42 +1009,3 @@ warpfacing: MACRO
db \3 ; x
db \4 ; y
ENDM
-
- enum battletowertext_command ; $a2
-battletowertext: MACRO
- db battletowertext_command
- db \1 ; bttext_id
-ENDM
-
- enum getlandmarkname_command ; $a3
-getlandmarkname: MACRO
- db getlandmarkname_command
- db \2 ; landmark_id
- db \1 ; string_buffer
-ENDM
-
- enum gettrainerclassname_command ; $a4
-gettrainerclassname: MACRO
- db gettrainerclassname_command
- db \2 ; trainer_group
- db \1 ; string_buffer
-ENDM
-
- enum getname_command ; $a5
-getname: MACRO
- db getname_command
- db \2 ; type
- db \3 ; id
- db \1 ; memory
-ENDM
-
- enum wait_command ; $a6
-wait: MACRO
- db wait_command
- db \1 ; duration
-ENDM
-
- enum checksave_command ; $a7
-checksave: MACRO
- db checksave_command
-ENDM
diff --git a/main.asm b/main.asm
index efa33d41..694d50d7 100644
--- a/main.asm
+++ b/main.asm
@@ -220,7 +220,9 @@ TilesetTrainStationMeta::
TilesetTrainStationColl::
dr $235f1, $236f1
TilesetForestMeta::
- dr $236f1, $239fe
+ dr $236f1, $23971
+CatchTutorial::
+ dr $23971, $239fe
EggMovePointers::
dr $239fe, $23e3d
@@ -242,7 +244,11 @@ _ExitMenu::
_InitVerticalMenuCursor::
dr $24395, $243eb
UpdateItemDescription::
- dr $243eb, $24477
+ dr $243eb, $2440b
+Pokepic::
+ dr $2440b, $24450
+ClosePokepic::
+ dr $24450, $24477
LoadObjectMasks::
dr $24477, $244d7
_InitScrollingMenu::
@@ -301,7 +307,9 @@ _PlayerDecorationMenu::
dr $26938, $270d5
ReceiveDecorationC::
- dr $270d5, $271be
+ dr $270d5, $2712c
+DescribeDecoration::
+ dr $2712c, $271be
ToggleMaptileDecorations::
dr $271be, $27216
ToggleDecorationsVisibility::
@@ -370,7 +378,15 @@ BackupMysteryGift::
RestoreMysteryGift::
dr $2a518, $2a539
LoadWildMonData::
- dr $2a539, $2a7d7
+ dr $2a539, $2a643
+TryWildEncounter::
+ dr $2a643, $2a680
+ApplyMusicEffectOnEncounterRate::
+ dr $2a680, $2a694
+ApplyCleanseTagEffectOnEncounterRate::
+ dr $2a694, $2a73b
+CheckRepelEffect::
+ dr $2a73b, $2a7d7
InitRoamMons::
dr $2a7d7, $2a859
UpdateRoamMons::
@@ -505,6 +521,7 @@ EvosAttacksPointers::
SECTION "bank11", ROMX
+FruitTreeScript::
dr $44000, $440c8
INCLUDE "engine/battle/ai/move.asm"
dr $441c2, $44360
@@ -517,7 +534,11 @@ ClearBattleRAM::
PlaceGraphic::
dr $44648, $44679
SendMailToPC::
- dr $44679, $44830
+ dr $44679, $4475f
+CheckPokeMail::
+ dr $4475f, $447d7
+GivePokeMail::
+ dr $447d7, $44830
BackupPartyMonMail::
dr $44830, $44850
RestorePartyMonMail::
@@ -553,7 +574,9 @@ PrintPartyMenuText::
PrintPartyMenuActionText::
dr $504db, $5054f
LoadFishingGFX::
- dr $5054f, $506f2
+ dr $5054f, $50610
+DoPoisonStep::
+ dr $50610, $506f2
SweetScentFromMenu::
dr $506f2, $50763
SquirtbottleFunction::
@@ -621,8 +644,12 @@ PrintMailAndExit::
PrintPartymon::
dr $84616, $84684
Function84684::
- dr $84684, $86632
+ dr $84684, $8640a
+HallOfFame::
+ dr $8640a, $86446
+RedCredits::
+ dr $86446, $86632
_HallOfFamePC::
dr $86632, $87bfd
@@ -719,7 +746,22 @@ ENDC
SECTION "bank24", ROMX
- dr $90000, $90641
+AddPhoneNumber::
+ dr $90000, $9000f
+DelCellNum::
+ dr $9000f, $90019
+CheckCellNum::
+ dr $90019, $90074
+CheckPhoneCall::
+ dr $90074, $9013e
+CheckSpecialPhoneCall::
+ dr $9013e, $9025d
+Script_SpecialBillCall::
+ dr $9025d, $90298
+PhoneCall::
+ dr $90298, $902df
+HangUp::
+ dr $902df, $90641
InitClock::
dr $90641, $908dc
SetDayOfWeek::
@@ -754,28 +796,6 @@ Function92c36::
dr $92c36, $93f86
-SECTION "bank25", ROMX
-
-MapScenes::
- dr $94000, $940ed
-INCLUDE "data/maps/maps.asm"
-INCLUDE "data/maps/attributes.asm"
-
-OverworldLoop::
- dr $965f9, $96b89
-EnableScriptMode::
- dr $96b89, $96b91
-ScriptEvents::
- dr $96b91, $97365
-
-CallCallback::
- dr $97365, $97a59
-WarpToSpawnPoint::
- dr $97a59, $97c2a
-ClearCmdQueue::
- dr $97c2a, $97d96
-
-
SECTION "bank26", ROMX
IF DEF(_GOLD)
@@ -795,8 +815,6 @@ GSIntroTilemap::
dr $9862a, $9886b
ENDC
-INCLUDE "data/maps/blocks.asm"
-
SECTION "bank2e_2", ROMX
@@ -1046,11 +1064,16 @@ TilesetPlayersRoomAnim::
TilesetRuinsOfAlphAnim::
TilesetRadioTowerAnim::
TilesetUndergroundAnim::
- dr $fc28e, $fde20
+ dr $fc28e, $fc9ae
+NPCTrade::
+ dr $fc9ae, $fcd87
+MomTriesToBuySomething::
+ dr $fcd87, $fde20
SECTION "bank40", ROMX
+StdScripts::
dr $100000, $10110c
INCLUDE "data/text/battle.asm"
@@ -1058,7 +1081,6 @@ INCLUDE "data/text/battle.asm"
SECTION "bank41", ROMX
dr $104000, $10614d
-INCLUDE "data/maps/scripts.asm"
SECTION "bank6c", ROMX
diff --git a/wram.asm b/wram.asm
index 6a6d9487..6eae8f54 100644
--- a/wram.asm
+++ b/wram.asm
@@ -130,7 +130,7 @@ wAutoInputLength:: db ; c1ca
wDebugFlags:: ds 1 ; c1cb
wGameLogicPaused:: ds 1 ; c1cc
wSpriteUpdatesEnabled:: db
-wc1ce:: ds 1 ; c1ce
+wUnusedScriptByteBuffer:: db ; c1ce
wMapTimeOfDay:: ds 1 ; c1cf
ds 3
wPrinterConnectionOpen:: ds 1
@@ -1988,6 +1988,10 @@ wUnusedMovementBufferBank:: db
wUnusedMovementBufferPointer:: dw
wMovementBuffer:: ds 55
+NEXTU
+; earthquake data buffer
+wEarthquakeMovementDataBuffer:: ds 5
+
NEXTU ; ceed
; unidentified
wceed:: db ; ceed
@@ -2045,6 +2049,11 @@ wMenuItemsList:: ds 16
wMenuItemsListEnd::
NEXTU ; cf29
+; fruit tree data
+wCurFruitTree:: db
+wCurFruit:: db
+
+NEXTU ; cf29
; item ball data
wItemBallData::
wItemBallItemID:: db
@@ -2548,24 +2557,26 @@ wScriptStack:: ds 3 * 5
wScriptVar:: db ; d173
wScriptDelay:: db ; d174
-wd175:: ds 1 ; d175
-wd176:: ds 1 ; d176
-wd177:: ds 1 ; d177
+wPriorityScriptBank::
+wScriptTextBank::
+ db ; d175
+wPriorityScriptAddr::
+wScriptTextAddr::
+ dw ; d176
+
wd178:: ds 1 ; d178
-wd179:: ds 1 ; d179
-wd17a:: ds 1 ; d17a
-wd17b:: ds 1 ; d17b
+wWildEncounterCooldown:: db ; d179
+wXYComparePointer:: dw ; d17a
wd17c:: ds 1 ; d17c
wd17d:: ds 1 ; d17d
wd17e:: ds 1 ; d17e
wd17f:: ds 1 ; d17f
-wd180:: ds 1 ; d180
+wBattleScriptFlags:: db ; d180
wd181:: ds 1 ; d181
wPlayerSpriteSetupFlags:: db ; d182
-wd183:: ds 1 ; d183
-wd184:: ds 1 ; d184
-wd185:: ds 1 ; d185
-wd186:: ds 1 ; d186
+wMapReentryScriptQueueFlag:: db ; d183
+wMapReentryScriptBank:: db
+wMapReentryScriptAddress:: dw ; d185
wd187:: ds 1 ; d187
wd188:: ds 1 ; d188
wd189:: ds 1 ; d189
@@ -2582,6 +2593,7 @@ wBugContestMinsRemaining:: ds 1 ; d193
wBugContestSecsRemaining:: ds 1 ; d194
wd195:: ds 1 ; d195
wd196:: ds 1 ; d196
+wMapStatusEnd::
wd197:: ds 1 ; d197
wd198:: ds 1 ; d198
@@ -2846,67 +2858,66 @@ wd6b4:: ds 1 ; d6b4
wd6b5:: ds 1 ; d6b5
wd6b6:: ds 1 ; d6b6
-; some of these are probably wrong
-; TODO rename to SceneID
-wPokecenter2FTrigger:: ds 1 ; d6b7
-wTradeCenterTrigger:: ds 1 ; d6b8
-wColosseumTrigger:: ds 1 ; d6b9
-wTimeCapsuleTrigger:: ds 1 ; d6ba
-wPowerPlantTrigger:: ds 1 ; d6bb
-wCeruleanGymTrigger:: ds 1 ; d6bc
-wRoute25Trigger:: ds 1 ; d6bd
-wTrainerHouseB1FTrigger:: ds 1 ; d6be
-wVictoryRoadGateTrigger:: ds 1 ; d6bf
-wSaffronTrainStationTrigger:: ds 1 ; d6c0
-wRoute16GateTrigger:: ds 1 ; d6c1
-wRoute1718GateTrigger:: ds 1 ; d6c2
-wIndigoPlateauPokecenter1FTrigger:: ds 1 ; d6c3
-wWillsRoomTrigger:: ds 1 ; d6c4
-wKogasRoomTrigger:: ds 1 ; d6c5
-wBrunosRoomTrigger:: ds 1 ; d6c6
-wKarensRoomTrigger:: ds 1 ; d6c7
-wLancesRoomTrigger:: ds 1 ; d6c8
-wHallOfFameTrigger:: ds 1 ; d6c9
-wRoute27Trigger:: ds 1 ; d6ca
-wNewBarkTownTrigger:: ds 1 ; d6cb
-wElmsLabTrigger:: ds 1 ; d6cc
-wKrissHouse1FTrigger:: ds 1 ; d6cd
-wRoute29Trigger:: ds 1 ; d6ce
-wCherrygroveCityTrigger:: ds 1 ; d6cf
-wMrPokemonsHouseTrigger:: ds 1 ; d6d0
-wRoute32Trigger:: ds 1 ; d6d1
-wRoute35NationalParkGateTrigger:: ds 1 ; d6d2
-wRoute36NationalParkGateTrigger:: ds 1 ; d6d3
-wAzaleaTownTrigger:: ds 1 ; d6d4
-wGoldenrodGymTrigger:: ds 1 ; d6d5
-wGoldenrodMagnetTrainStationTrigger:: ds 1 ; d6d6
-wOlivineCityTrigger:: ds 1 ; d6d7
-wRoute34Trigger:: ds 1 ; d6d8
-wEcruteakHouseTrigger:: ds 1 ; d6d9
-wEcruteakPokecenter1FTrigger:: ds 1 ; d6da
-wMahoganyTownTrigger:: ds 1 ; d6db
-wRoute43GateTrigger:: ds 1 ; d6dc
-wMountMoonTrigger:: ds 1 ; d6dd
-wSproutTower3FTrigger:: ds 1 ; d6de
-wBurnedTower1FTrigger:: ds 1 ; d6df
-wBurnedTowerB1FTrigger:: ds 1 ; d6e0
-wd6e1:: ds 1 ; d6e1
-wd6e2:: ds 1 ; d6e2
-wd6e3:: ds 1 ; d6e3
-wd6e4:: ds 1 ; d6e4
-wd6e5:: ds 1 ; d6e5
-wd6e6:: ds 1 ; d6e6
-wd6e7:: ds 1 ; d6e7
-wd6e8:: ds 1 ; d6e8
-wd6e9:: ds 1 ; d6e9
-wd6ea:: ds 1 ; d6ea
-wd6eb:: ds 1 ; d6eb
-wd6ec:: ds 1 ; d6ec
-wd6ed:: ds 1 ; d6ed
-wd6ee:: ds 1 ; d6ee
-wd6ef:: ds 1 ; d6ef
-wd6f0:: ds 1 ; d6f0
-wd6f1:: ds 1 ; d6f1
+wPokecenter2FSceneID:: db ; d6b7
+wTradeCenterSceneID:: db ; d6b8
+wColosseumSceneID:: db ; d6b9
+wTimeCapsuleSceneID:: db ; d6ba
+wPowerPlantSceneID:: db ; d6bb
+wCeruleanGymSceneID:: db ; d6bc
+wRoute25SceneID:: db ; d6bd
+wTrainerHouseB1FSceneID:: db ; d6be
+wVictoryRoadGateSceneID:: db ; d6bf
+wSaffronMagnetTrainStationSceneID:: db ; d6c0
+wRoute16GateSceneID:: db ; d6c1
+wRoute17Route18GateSceneID:: db ; d6c2
+wIndigoPlateauPokecenter1FSceneID:: db ; d6c3
+wWillsRoomSceneID:: db ; d6c4
+wKogasRoomSceneID:: db ; d6c5
+wBrunosRoomSceneID:: db ; d6c6
+wKarensRoomSceneID:: db ; d6c7
+wLancesRoomSceneID:: db ; d6c8
+wHallOfFameSceneID:: db ; d6c9
+wRoute27SceneID:: db ; d6ca
+wNewBarkTownSceneID:: db ; d6cb
+wElmsLabSceneID:: db ; d6cc
+wPlayersHouse1FSceneID:: db ; d6cd
+wRoute29SceneID:: db ; d6ce
+wCherrygroveCitySceneID:: db ; d6cf
+wMrPokemonsHouseSceneID:: db ; d6d0
+wRoute32SceneID:: db ; d6d1
+wRoute35NationalParkGateSceneID:: db ; d6d2
+wRoute36NationalParkGateSceneID:: db ; d6d3
+wAzaleaTownSceneID:: db ; d6d4
+wGoldenrodGymSceneID:: db ; d6d5
+wGoldenrodMagnetTrainStationSceneID:: db ; d6d6
+wOlivineCitySceneID:: db ; d6d7
+wRoute34SceneID:: db ; d6d8
+wEcruteakTinTowerEntranceSceneID:: db ; d6d9
+wEcruteakPokecenter1FSceneID:: db ; d6da
+wMahoganyTownSceneID:: db ; d6db
+wRoute43GateSceneID:: db ; d6dc
+wMountMoonSceneID:: db ; d6dd
+wSproutTower3FSceneID:: db ; d6de
+wBurnedTower1FSceneID:: db ; d6df
+wBurnedTowerB1FSceneID:: db ; d6e0
+wRadioTower5FSceneID:: db ; d6e1
+wRuinsOfAlphOutsideSceneID:: db ; d6e2
+wRuinsOfAlphResearchCenterSceneID:: db ; d6e3
+wRuinsOfAlphInnerChamberSceneID:: db ; d6e4
+wMahoganyMart1FSceneID:: db ; d6e5
+wTeamRocketBaseB1FSceneID:: db ; d6e6
+wTeamRocketBaseB2FSceneID:: db ; d6e7
+wTeamRocketBaseB3FSceneID:: db ; d6e8
+wGoldenrodUndergroundSwitchRoomEntrancesSceneID:: db ; d6e9
+wSilverCaveRoom3SceneID:: db ; d6ea
+wVictoryRoadSceneID:: db ; d6eb
+wDragonsDenB1FSceneID:: db ; d6ec
+wOlivinePortSceneID:: db ; d6ed
+wVermilionPortSceneID:: db ; d6ee
+wFastShip1FSceneID:: db ; d6ef
+wFastShipB1FSceneID:: db ; d6f0
+wMountMoonSquareSceneID:: db ; d6f1
+
wd6f2:: ds 1 ; d6f2
wd6f3:: ds 1 ; d6f3
wd6f4:: ds 1 ; d6f4
@@ -3252,8 +3263,8 @@ wd9b9:: ds 1 ; d9b9
wd9ba:: ds 1 ; d9ba
wd9bb:: ds 1 ; d9bb
wd9bc:: ds 1 ; d9bc
-wd9bd:: ds 1 ; d9bd
-wd9be:: ds 1 ; d9be
+wStepCount:: db ; d9bd
+wPoisonStepCount:: db ; d9be
wd9bf:: ds 1 ; d9bf
wd9c0:: ds 1 ; d9c0
wd9c1:: ds 1 ; d9c1
@@ -3297,9 +3308,10 @@ wd9e6:: ds 1 ; d9e6
wLuckyNumberShowFlag:: ds 1 ; d9e7
wd9e8:: ds 1 ; d9e8
wLuckyIDNumber:: dw ; d9e9
-wRepelSteps:: ds 1 ; d9eb
-wd9ec:: ds 1 ; d9ec
-wd9ed:: ds 1 ; d9ed
+
+wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still active
+wBikeStep:: dw
+
wPlayerData3End::
wPlayerDataEnd::