summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--asm/flying.s1698
-rw-r--r--asm/macros/battle_script.inc2
-rw-r--r--asm/macros/event.inc10
-rw-r--r--asm/rom_8011DC0.s52
-rw-r--r--asm/rom_81D1C44.s12
-rw-r--r--common_syms/overworld.txt4
-rw-r--r--common_syms/window.txt2
-rw-r--r--data/battle_scripts_1.s8
-rw-r--r--data/event_scripts.s229
-rw-r--r--data/io_reg.s10
-rw-r--r--data/map_events.s1
-rw-r--r--data/maps.s2
-rw-r--r--data/maps/BattleFrontier_ReceptionGate/scripts.inc4
-rw-r--r--data/maps/BattleFrontier_ScottsHouse/scripts.inc6
-rw-r--r--data/maps/CaveOfOrigin_B1F/scripts.inc2
-rw-r--r--data/maps/DewfordTown_Gym/scripts.inc2
-rw-r--r--data/maps/DoubleBattleColosseum/map.json8
-rw-r--r--data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc2
-rw-r--r--data/maps/FallarborTown_BattleTentLobby/scripts.inc2
-rw-r--r--data/maps/FarawayIsland_Interior/scripts.inc2
-rw-r--r--data/maps/FortreeCity_Gym/scripts.inc2
-rw-r--r--data/maps/JaggedPass/map.json10
-rw-r--r--data/maps/JaggedPass/scripts.inc8
-rw-r--r--data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc2
-rw-r--r--data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc16
-rw-r--r--data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc10
-rw-r--r--data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc4
-rw-r--r--data/maps/LittlerootTown_MaysHouse_2F/scripts.inc4
-rw-r--r--data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc4
-rw-r--r--data/maps/MarineCave_End/scripts.inc4
-rw-r--r--data/maps/MauvilleCity/scripts.inc4
-rw-r--r--data/maps/MauvilleCity_Gym/scripts.inc2
-rw-r--r--data/maps/MirageTower_4F/scripts.inc2
-rw-r--r--data/maps/MossdeepCity/map.json12
-rw-r--r--data/maps/MossdeepCity/scripts.inc4
-rw-r--r--data/maps/MossdeepCity_Gym/scripts.inc4
-rw-r--r--data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc30
-rw-r--r--data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc26
-rw-r--r--data/maps/PetalburgCity/map.json8
-rw-r--r--data/maps/PetalburgCity/scripts.inc4
-rw-r--r--data/maps/PetalburgCity_Gym/scripts.inc2
-rw-r--r--data/maps/RecordCorner/map.json8
-rw-r--r--data/maps/Route105/scripts.inc20
-rw-r--r--data/maps/Route111/scripts.inc20
-rw-r--r--data/maps/Route114/scripts.inc20
-rw-r--r--data/maps/Route114_FossilManiacsTunnel/map.json4
-rw-r--r--data/maps/Route114_FossilManiacsTunnel/scripts.inc2
-rw-r--r--data/maps/Route115/scripts.inc20
-rw-r--r--data/maps/Route116/scripts.inc20
-rw-r--r--data/maps/Route118/scripts.inc20
-rw-r--r--data/maps/Route119/scripts.inc4
-rw-r--r--data/maps/Route119_WeatherInstitute_2F/scripts.inc40
-rw-r--r--data/maps/Route124/map.json2
-rw-r--r--data/maps/Route125/map.json2
-rw-r--r--data/maps/Route125/scripts.inc20
-rw-r--r--data/maps/Route126/map.json2
-rw-r--r--data/maps/Route127/map.json2
-rw-r--r--data/maps/Route127/scripts.inc20
-rw-r--r--data/maps/Route128/map.json2
-rw-r--r--data/maps/Route129/map.json2
-rw-r--r--data/maps/Route129/scripts.inc22
-rw-r--r--data/maps/Route130/map.json2
-rw-r--r--data/maps/Route130/scripts.inc2
-rw-r--r--data/maps/Route131/map.json2
-rw-r--r--data/maps/Route131/scripts.inc2
-rw-r--r--data/maps/Route132/map.json2
-rw-r--r--data/maps/Route133/map.json2
-rw-r--r--data/maps/Route134/map.json2
-rw-r--r--data/maps/RustboroCity_PokemonSchool/scripts.inc4
-rw-r--r--data/maps/SSTidalCorridor/scripts.inc4
-rw-r--r--data/maps/SeafloorCavern_Entrance/scripts.inc4
-rw-r--r--data/maps/SeafloorCavern_Room9/scripts.inc2
-rw-r--r--data/maps/SecretBase_YellowCave4/scripts.inc4
-rw-r--r--data/maps/SingleBattleColosseum/map.json4
-rw-r--r--data/maps/SkyPillar_1F/scripts.inc2
-rw-r--r--data/maps/SkyPillar_2F/scripts.inc2
-rw-r--r--data/maps/SkyPillar_3F/scripts.inc2
-rw-r--r--data/maps/SkyPillar_4F/scripts.inc2
-rw-r--r--data/maps/SkyPillar_5F/scripts.inc2
-rw-r--r--data/maps/SkyPillar_Outside/scripts.inc8
-rw-r--r--data/maps/SkyPillar_Top/map.json2
-rw-r--r--data/maps/SkyPillar_Top/scripts.inc12
-rw-r--r--data/maps/SlateportCity/map.json2
-rw-r--r--data/maps/SlateportCity/scripts.inc12
-rw-r--r--data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc2
-rw-r--r--data/maps/SootopolisCity/scripts.inc132
-rw-r--r--data/maps/SootopolisCity_Gym_1F/scripts.inc2
-rw-r--r--data/maps/SootopolisCity_Mart/scripts.inc4
-rw-r--r--data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc2
-rw-r--r--data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc4
-rw-r--r--data/maps/SouthernIsland_Interior/scripts.inc8
-rw-r--r--data/maps/TerraCave_End/scripts.inc4
-rw-r--r--data/maps/TradeCenter/map.json4
-rw-r--r--data/maps/TrainerHill_Entrance/map.json2
-rw-r--r--data/maps/TrainerHill_Entrance/scripts.inc34
-rw-r--r--data/maps/TrainerHill_Roof/scripts.inc8
-rw-r--r--data/maps/Underwater3/scripts.inc2
-rw-r--r--data/maps/Underwater5/scripts.inc2
-rw-r--r--data/maps/Underwater6/scripts.inc2
-rw-r--r--data/maps/Underwater7/scripts.inc2
-rw-r--r--data/maps/VerdanturfTown_BattleTentLobby/scripts.inc2
-rw-r--r--data/scripts/cable_club.inc108
-rw-r--r--data/scripts/players_house.inc3
-rw-r--r--data/scripts/secret_base.inc14
-rw-r--r--data/scripts/tv.inc3
-rw-r--r--data/specials.inc16
-rw-r--r--include/agb_flash.h2
-rw-r--r--include/battle.h2
-rw-r--r--include/battle_anim.h16
-rw-r--r--include/battle_scripts.h6
-rw-r--r--include/battle_util.h4
-rw-r--r--include/cable_club.h2
-rw-r--r--include/constants/battle_frontier.h2
-rw-r--r--include/constants/flags.h2
-rwxr-xr-xinclude/constants/map_types.h6
-rw-r--r--include/constants/trainer_hill.h29
-rw-r--r--include/constants/vars.h250
-rw-r--r--include/constants/weather.h26
-rw-r--r--include/contest.h1
-rw-r--r--include/dewford_trend.h2
-rw-r--r--include/easy_chat.h1
-rw-r--r--include/event_data.h2
-rw-r--r--include/event_obj_lock.h1
-rw-r--r--include/event_object_movement.h3
-rw-r--r--include/event_scripts.h2
-rw-r--r--include/field_control_avatar.h1
-rw-r--r--include/field_effect.h5
-rw-r--r--include/field_effect_helpers.h1
-rw-r--r--include/field_player_avatar.h10
-rw-r--r--include/field_screen_effect.h1
-rw-r--r--include/field_special_scene.h1
-rw-r--r--include/field_specials.h15
-rw-r--r--include/fieldmap.h11
-rw-r--r--include/global.fieldmap.h11
-rw-r--r--include/global.h18
-rw-r--r--include/hall_of_fame.h3
-rw-r--r--include/item_menu.h7
-rw-r--r--include/link.h12
-rw-r--r--include/link_rfu.h6
-rw-r--r--include/main.h6
-rw-r--r--include/match_call.h4
-rw-r--r--include/menu.h20
-rw-r--r--include/overworld.h43
-rw-r--r--include/party_menu.h2
-rw-r--r--include/pokedex.h2
-rw-r--r--include/pokemon_icon.h1
-rw-r--r--include/pokenav.h1
-rw-r--r--include/record_mixing.h2
-rw-r--r--include/rom_8011DC0.h2
-rw-r--r--include/save.h9
-rw-r--r--include/script.h3
-rw-r--r--include/script_menu.h2
-rw-r--r--include/secret_base.h2
-rw-r--r--include/siirtc.h8
-rw-r--r--include/text.h4
-rw-r--r--include/trainer_card.h2
-rw-r--r--include/trainer_hill.h2
-rw-r--r--include/window.h4
-rw-r--r--ld_script.txt1
-rwxr-xr-xmap_data_rules.mk2
-rw-r--r--src/apprentice.c4
-rwxr-xr-xsrc/battle_anim_effects_2.c3
-rwxr-xr-xsrc/battle_anim_effects_3.c3
-rw-r--r--src/battle_controller_link_opponent.c12
-rw-r--r--src/battle_controller_link_partner.c15
-rw-r--r--src/battle_controller_opponent.c10
-rw-r--r--src/battle_controller_player.c10
-rw-r--r--src/battle_controller_player_partner.c9
-rw-r--r--src/battle_controller_recorded_opponent.c9
-rw-r--r--src/battle_controller_recorded_player.c8
-rw-r--r--src/battle_controller_safari.c10
-rw-r--r--src/battle_controller_wally.c10
-rw-r--r--src/battle_controllers.c2
-rw-r--r--src/battle_dome.c2
-rw-r--r--src/battle_factory_screen.c50
-rw-r--r--src/battle_interface.c2
-rw-r--r--src/battle_main.c6
-rw-r--r--src/battle_message.c94
-rw-r--r--src/battle_pyramid.c4
-rw-r--r--src/battle_pyramid_bag.c33
-rw-r--r--src/battle_records.c11
-rw-r--r--src/battle_script_commands.c12
-rw-r--r--src/battle_setup.c7
-rw-r--r--src/battle_tower.c6
-rw-r--r--src/battle_util.c30
-rw-r--r--src/berry.c6
-rw-r--r--src/berry_blender.c32
-rw-r--r--src/berry_fix_program.c8
-rw-r--r--src/berry_tag_screen.c14
-rw-r--r--src/bg.c4
-rw-r--r--src/bike.c6
-rw-r--r--src/cable_club.c47
-rw-r--r--src/clear_save_data_screen.c6
-rw-r--r--src/coins.c6
-rw-r--r--src/contest.c16
-rw-r--r--src/contest_link_80F57C4.c5
-rw-r--r--src/contest_painting.c2
-rw-r--r--src/credits.c2
-rw-r--r--src/daycare.c6
-rw-r--r--src/decoration.c66
-rw-r--r--src/dewford_trend.c4
-rw-r--r--src/diploma.c5
-rw-r--r--src/easy_chat.c18
-rw-r--r--src/egg_hatch.c4
-rw-r--r--src/electric.c3
-rw-r--r--src/event_data.c22
-rw-r--r--src/field_control_avatar.c17
-rw-r--r--src/field_effect.c10
-rwxr-xr-xsrc/field_message_box.c10
-rw-r--r--src/field_player_avatar.c14
-rw-r--r--src/field_region_map.c8
-rw-r--r--src/field_screen_effect.c26
-rw-r--r--src/field_specials.c181
-rw-r--r--src/fieldmap.c39
-rw-r--r--src/fldeff_cut.c1
-rw-r--r--src/fldeff_escalator.c14
-rw-r--r--src/fldeff_misc.c10
-rw-r--r--src/fldeff_softboiled.c2
-rw-r--r--src/flying.c1409
-rw-r--r--src/frontier_pass.c8
-rw-r--r--src/frontier_util.c43
-rw-r--r--src/hall_of_fame.c20
-rw-r--r--src/hof_pc.c4
-rw-r--r--src/ice.c47
-rw-r--r--src/item.c4
-rwxr-xr-xsrc/item_menu.c42
-rwxr-xr-xsrc/item_use.c36
-rw-r--r--src/learn_move.c6
-rw-r--r--src/link.c38
-rw-r--r--src/link_rfu.c24
-rw-r--r--src/list_menu.c20
-rw-r--r--src/load_save.c4
-rw-r--r--src/lottery_corner.c2
-rw-r--r--src/mail.c4
-rw-r--r--src/main.c19
-rw-r--r--src/main_menu.c217
-rw-r--r--src/map_name_popup.c4
-rw-r--r--src/match_call.c10
-rw-r--r--src/mauville_old_man.c2
-rw-r--r--src/menu.c129
-rw-r--r--src/menu_helpers.c8
-rw-r--r--src/mirage_tower.c2
-rw-r--r--src/money.c6
-rw-r--r--src/mystery_event_menu.c10
-rw-r--r--src/mystery_event_script.c2
-rw-r--r--src/naming_screen.c14
-rw-r--r--src/normal.c2
-rw-r--r--src/option_menu.c7
-rw-r--r--src/overworld.c989
-rwxr-xr-xsrc/party_menu.c27
-rw-r--r--src/player_pc.c30
-rw-r--r--src/poison.c2
-rw-r--r--src/pokeblock.c12
-rw-r--r--src/pokeblock_feed.c6
-rw-r--r--src/pokedex.c14
-rw-r--r--src/pokemon.c5
-rw-r--r--src/pokemon_size_record.c4
-rw-r--r--src/pokemon_storage_system.c52
-rw-r--r--src/pokemon_summary_screen.c30
-rw-r--r--src/pokenav.c16
-rw-r--r--src/pokenav_match_call.c4
-rw-r--r--src/record_mixing.c57
-rw-r--r--src/region_map.c26
-rw-r--r--src/reset_rtc_screen.c10
-rw-r--r--src/reshow_battle_screen.c3
-rw-r--r--src/rock.c2
-rw-r--r--src/rom_8011DC0.c33
-rw-r--r--src/roulette.c40
-rw-r--r--src/safari_zone.c3
-rw-r--r--src/save.c19
-rw-r--r--src/save_failed_screen.c20
-rw-r--r--src/scrcmd.c20
-rw-r--r--src/script_menu.c18
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c21
-rw-r--r--src/secret_base.c184
-rwxr-xr-xsrc/shop.c20
-rw-r--r--src/siirtc.c8
-rw-r--r--src/slot_machine.c22
-rw-r--r--src/start_menu.c136
-rw-r--r--src/starter_choose.c8
-rw-r--r--src/text.c12
-rw-r--r--src/time_events.c2
-rw-r--r--src/trade.c30
-rw-r--r--src/trader.c4
-rwxr-xr-xsrc/trainer_card.c18
-rw-r--r--src/trainer_hill.c88
-rw-r--r--src/trainer_see.c2
-rw-r--r--src/tv.c31
-rw-r--r--src/unk_text_util_2.c10
-rw-r--r--src/wallclock.c4
-rw-r--r--src/water.c56
-rw-r--r--src/window.c9
-rw-r--r--tools/scaninc/Makefile4
-rw-r--r--tools/scaninc/asm_file.cpp3
-rw-r--r--tools/scaninc/scaninc.cpp88
-rw-r--r--tools/scaninc/source_file.cpp125
-rw-r--r--tools/scaninc/source_file.h71
298 files changed, 4530 insertions, 4488 deletions
diff --git a/Makefile b/Makefile
index c9a7c2e05..1bfeebf61 100644
--- a/Makefile
+++ b/Makefile
@@ -159,7 +159,7 @@ $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep)
ifeq ($(NODEP),1)
$(ASM_BUILDDIR)/%.o: asm_dep :=
else
-$(ASM_BUILDDIR)/%.o: asm_dep = $(shell $(SCANINC) $(ASM_SUBDIR)/$*.s)
+$(ASM_BUILDDIR)/%.o: asm_dep = $(shell $(SCANINC) -I "" $(ASM_SUBDIR)/$*.s)
endif
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(asm_dep)
@@ -168,7 +168,7 @@ $(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(asm_dep)
ifeq ($(NODEP),1)
$(DATA_ASM_BUILDDIR)/%.o: data_dep :=
else
-$(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) $(DATA_ASM_SUBDIR)/$*.s)
+$(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) -I include -I "" $(DATA_ASM_SUBDIR)/$*.s)
endif
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $$(data_dep)
diff --git a/asm/flying.s b/asm/flying.s
deleted file mode 100644
index 37873f17b..000000000
--- a/asm/flying.s
+++ /dev/null
@@ -1,1698 +0,0 @@
- .include "asm/macros.inc"
- .include "constants/constants.inc"
-
- .syntax unified
-
- .text
-
- thumb_func_start sub_810E520
-sub_810E520: @ 810E520
- push {r4-r7,lr}
- mov r7, r9
- mov r6, r8
- push {r6,r7}
- adds r5, r0, 0
- movs r6, 0
- adds r4, r5, 0
- adds r4, 0x2E
- ldrb r2, [r4]
- movs r7, 0x1
- movs r0, 0x1
- mov r9, r0
- ands r0, r2
- cmp r0, 0
- beq _0810E55A
- ldrb r0, [r4, 0x1]
- adds r1, r0, 0
- adds r1, 0xFF
- strb r1, [r4, 0x1]
- lsls r0, 24
- cmp r0, 0
- beq _0810E54E
- b _0810EA36
-_0810E54E:
- movs r0, 0x2
- negs r0, r0
- ands r0, r2
- strb r0, [r4]
- strb r6, [r4, 0x1]
- b _0810EA36
-_0810E55A:
- ldrh r0, [r4, 0x2]
- lsrs r1, r0, 6
- mov r12, r0
- cmp r1, 0x1
- bne _0810E566
- b _0810E68A
-_0810E566:
- cmp r1, 0x1
- bgt _0810E570
- cmp r1, 0
- beq _0810E57E
- b _0810E97C
-_0810E570:
- cmp r1, 0x2
- bne _0810E576
- b _0810E77E
-_0810E576:
- cmp r1, 0x3
- bne _0810E57C
- b _0810E872
-_0810E57C:
- b _0810E97C
-_0810E57E:
- lsls r1, r2, 24
- lsrs r0, r1, 28
- cmp r0, 0x1
- bne _0810E592
- movs r0, 0x8
- orrs r0, r2
- orrs r0, r7
- strb r0, [r4]
- strb r6, [r4, 0x1]
- b _0810E680
-_0810E592:
- lsrs r0, r1, 28
- cmp r0, 0x3
- bne _0810E5B4
- lsls r0, r2, 30
- lsrs r0, 31
- movs r1, 0x1
- eors r0, r1
- ands r0, r7
- lsls r0, 1
- movs r1, 0x3
- negs r1, r1
- ands r1, r2
- orrs r1, r0
- orrs r1, r7
- strb r1, [r4]
- strb r6, [r4, 0x1]
- b _0810E680
-_0810E5B4:
- movs r0, 0x8
- ands r0, r2
- cmp r0, 0
- beq _0810E680
- adds r3, r5, 0
- adds r3, 0x3F
- ldrb r2, [r3]
- lsls r1, r2, 31
- lsrs r1, 31
- movs r6, 0x1
- eors r1, r6
- ands r1, r7
- movs r0, 0x2
- negs r0, r0
- mov r8, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r3]
- lsls r0, 31
- lsrs r0, 31
- adds r1, r5, 0
- adds r1, 0x2A
- strb r0, [r1]
- ldrb r0, [r3]
- movs r1, 0x4
- orrs r0, r1
- movs r1, 0x11
- negs r1, r1
- ands r0, r1
- strb r0, [r3]
- ldrb r1, [r4]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _0810E672
- bl IsContest
- lsls r0, 24
- cmp r0, 0
- bne _0810E642
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E628
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- subs r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E660
-_0810E628:
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- adds r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E660
-_0810E642:
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E656
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- subs r0, 0xC
- b _0810E65E
-_0810E656:
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- adds r0, 0xC
-_0810E65E:
- strb r0, [r1]
-_0810E660:
- ldrb r2, [r4, 0xE]
- lsls r0, r2, 31
- lsrs r0, 31
- eors r0, r6
- ands r0, r7
- mov r1, r8
- ands r1, r2
- orrs r1, r0
- strb r1, [r4, 0xE]
-_0810E672:
- ldrb r1, [r4]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r4]
- ldrh r1, [r4, 0x2]
- mov r12, r1
-_0810E680:
- ldrb r1, [r4]
- movs r0, 0xF
- ands r0, r1
- strb r0, [r4]
- b _0810E97C
-_0810E68A:
- lsls r1, r2, 24
- lsrs r0, r1, 28
- cmp r0, 0
- bne _0810E698
- movs r0, 0x8
- orrs r0, r2
- b _0810E6A0
-_0810E698:
- lsrs r0, r1, 28
- cmp r0, 0x2
- bne _0810E6A8
- adds r0, r2, 0
-_0810E6A0:
- orrs r0, r7
- strb r0, [r4]
- strb r6, [r4, 0x1]
- b _0810E774
-_0810E6A8:
- movs r0, 0x8
- ands r0, r2
- cmp r0, 0
- beq _0810E774
- adds r3, r5, 0
- adds r3, 0x3F
- ldrb r2, [r3]
- lsls r1, r2, 31
- lsrs r1, 31
- movs r6, 0x1
- eors r1, r6
- ands r1, r7
- movs r0, 0x2
- negs r0, r0
- mov r8, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r3]
- lsls r0, 31
- lsrs r0, 31
- adds r1, r5, 0
- adds r1, 0x2A
- strb r0, [r1]
- ldrb r0, [r3]
- movs r1, 0x4
- orrs r0, r1
- movs r1, 0x11
- negs r1, r1
- ands r0, r1
- strb r0, [r3]
- ldrb r1, [r4]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _0810E766
- bl IsContest
- lsls r0, 24
- cmp r0, 0
- bne _0810E736
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E71C
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- subs r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E754
-_0810E71C:
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- adds r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E754
-_0810E736:
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E74A
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- subs r0, 0xC
- b _0810E752
-_0810E74A:
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- adds r0, 0xC
-_0810E752:
- strb r0, [r1]
-_0810E754:
- ldrb r2, [r4, 0xE]
- lsls r0, r2, 31
- lsrs r0, 31
- eors r0, r6
- ands r0, r7
- mov r1, r8
- ands r1, r2
- orrs r1, r0
- strb r1, [r4, 0xE]
-_0810E766:
- ldrb r1, [r4]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r4]
- ldrh r1, [r4, 0x2]
- mov r12, r1
-_0810E774:
- ldrb r0, [r4]
- movs r1, 0xF
- ands r1, r0
- movs r0, 0x10
- b _0810E978
-_0810E77E:
- lsls r1, r2, 24
- lsrs r0, r1, 28
- cmp r0, 0x3
- bne _0810E78C
- movs r0, 0x8
- orrs r0, r2
- b _0810E794
-_0810E78C:
- lsrs r0, r1, 28
- cmp r0, 0x1
- bne _0810E79C
- adds r0, r2, 0
-_0810E794:
- orrs r0, r7
- strb r0, [r4]
- strb r6, [r4, 0x1]
- b _0810E868
-_0810E79C:
- movs r0, 0x8
- ands r0, r2
- cmp r0, 0
- beq _0810E868
- adds r3, r5, 0
- adds r3, 0x3F
- ldrb r2, [r3]
- lsls r1, r2, 31
- lsrs r1, 31
- movs r6, 0x1
- eors r1, r6
- ands r1, r7
- movs r0, 0x2
- negs r0, r0
- mov r8, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r3]
- lsls r0, 31
- lsrs r0, 31
- adds r1, r5, 0
- adds r1, 0x2A
- strb r0, [r1]
- ldrb r0, [r3]
- movs r1, 0x4
- orrs r0, r1
- movs r1, 0x11
- negs r1, r1
- ands r0, r1
- strb r0, [r3]
- ldrb r1, [r4]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _0810E85A
- bl IsContest
- lsls r0, 24
- cmp r0, 0
- bne _0810E82A
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E810
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- subs r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E848
-_0810E810:
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- adds r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E848
-_0810E82A:
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E83E
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- subs r0, 0xC
- b _0810E846
-_0810E83E:
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- adds r0, 0xC
-_0810E846:
- strb r0, [r1]
-_0810E848:
- ldrb r2, [r4, 0xE]
- lsls r0, r2, 31
- lsrs r0, 31
- eors r0, r6
- ands r0, r7
- mov r1, r8
- ands r1, r2
- orrs r1, r0
- strb r1, [r4, 0xE]
-_0810E85A:
- ldrb r1, [r4]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r4]
- ldrh r1, [r4, 0x2]
- mov r12, r1
-_0810E868:
- ldrb r0, [r4]
- movs r1, 0xF
- ands r1, r0
- movs r0, 0x20
- b _0810E978
-_0810E872:
- lsls r1, r2, 24
- lsrs r0, r1, 28
- cmp r0, 0x2
- bne _0810E882
- movs r0, 0x8
- orrs r0, r2
- strb r0, [r4]
- b _0810E970
-_0810E882:
- lsrs r0, r1, 28
- cmp r0, 0
- bne _0810E8A4
- lsls r0, r2, 30
- lsrs r0, 31
- movs r1, 0x1
- eors r0, r1
- ands r0, r7
- lsls r0, 1
- movs r1, 0x3
- negs r1, r1
- ands r1, r2
- orrs r1, r0
- orrs r1, r7
- strb r1, [r4]
- strb r6, [r4, 0x1]
- b _0810E970
-_0810E8A4:
- movs r0, 0x8
- ands r0, r2
- cmp r0, 0
- beq _0810E970
- adds r3, r5, 0
- adds r3, 0x3F
- ldrb r2, [r3]
- lsls r1, r2, 31
- lsrs r1, 31
- movs r6, 0x1
- eors r1, r6
- ands r1, r7
- movs r0, 0x2
- negs r0, r0
- mov r8, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r3]
- lsls r0, 31
- lsrs r0, 31
- adds r1, r5, 0
- adds r1, 0x2A
- strb r0, [r1]
- ldrb r0, [r3]
- movs r1, 0x4
- orrs r0, r1
- movs r1, 0x11
- negs r1, r1
- ands r0, r1
- strb r0, [r3]
- ldrb r1, [r4]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _0810E962
- bl IsContest
- lsls r0, 24
- cmp r0, 0
- bne _0810E932
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E918
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- subs r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E950
-_0810E918:
- ldrb r2, [r5, 0x5]
- lsls r1, r2, 28
- lsrs r1, 30
- adds r1, 0x1
- movs r0, 0x3
- ands r1, r0
- lsls r1, 2
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r5, 0x5]
- b _0810E950
-_0810E932:
- ldrb r1, [r4, 0xE]
- mov r0, r9
- ands r0, r1
- cmp r0, 0
- bne _0810E946
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- subs r0, 0xC
- b _0810E94E
-_0810E946:
- adds r1, r5, 0
- adds r1, 0x43
- ldrb r0, [r1]
- adds r0, 0xC
-_0810E94E:
- strb r0, [r1]
-_0810E950:
- ldrb r2, [r4, 0xE]
- lsls r0, r2, 31
- lsrs r0, 31
- eors r0, r6
- ands r0, r7
- mov r1, r8
- ands r1, r2
- orrs r1, r0
- strb r1, [r4, 0xE]
-_0810E962:
- ldrb r1, [r4]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r4]
- ldrh r1, [r4, 0x2]
- mov r12, r1
-_0810E970:
- ldrb r0, [r4]
- movs r1, 0xF
- ands r1, r0
- movs r0, 0x30
-_0810E978:
- orrs r1, r0
- strb r1, [r4]
-_0810E97C:
- ldrb r1, [r4]
- lsls r1, 30
- lsrs r1, 31
- adds r0, r4, 0
- adds r0, 0xC
- adds r0, r1
- ldrb r1, [r0]
- ldr r3, =gSineTable
- mov r2, r12
- lsls r0, r2, 1
- adds r0, r3
- movs r2, 0
- ldrsh r0, [r0, r2]
- muls r0, r1
- asrs r0, 8
- strh r0, [r5, 0x24]
- ldrb r2, [r5, 0x3]
- lsls r2, 26
- lsrs r2, 27
- movs r1, 0x24
- ldrsh r0, [r5, r1]
- negs r0, r0
- asrs r0, 1
- ldrb r1, [r4, 0xA]
- adds r0, r1
- lsls r0, 24
- lsrs r0, 24
- lsls r1, r0, 1
- adds r1, r3
- ldrh r6, [r1]
- ldr r1, =gOamMatrices
- lsls r2, 3
- adds r2, r1
- adds r0, 0x40
- lsls r0, 1
- adds r0, r3
- ldrh r0, [r0]
- strh r0, [r2, 0x6]
- strh r0, [r2]
- strh r6, [r2, 0x2]
- lsls r0, r6, 16
- asrs r0, 16
- negs r0, r0
- strh r0, [r2, 0x4]
- ldrh r0, [r4, 0x6]
- ldrh r2, [r4, 0x8]
- adds r0, r2
- strh r0, [r4, 0x8]
- lsls r0, 16
- lsrs r0, 24
- strh r0, [r5, 0x22]
- movs r1, 0x4
- ldrsh r0, [r4, r1]
- movs r1, 0x80
- lsls r1, 8
- ands r0, r1
- cmp r0, 0
- beq _0810EA0C
- ldrh r0, [r4, 0x4]
- subs r1, 0x1
- ands r1, r0
- ldrh r0, [r4, 0x2]
- subs r0, r1
- movs r1, 0xFF
- ands r0, r1
- strh r0, [r4, 0x2]
- b _0810EA1C
- .pool
-_0810EA0C:
- ldrh r0, [r4, 0x4]
- ldr r1, =0x00007fff
- ands r1, r0
- ldrh r2, [r4, 0x2]
- adds r1, r2
- movs r0, 0xFF
- ands r1, r0
- strh r1, [r4, 0x2]
-_0810EA1C:
- movs r0, 0x22
- ldrsh r1, [r5, r0]
- movs r2, 0x26
- ldrsh r0, [r5, r2]
- adds r1, r0
- ldrh r0, [r4, 0xE]
- lsrs r0, 1
- cmp r1, r0
- blt _0810EA36
- movs r0, 0
- strh r0, [r5, 0x2E]
- ldr r0, =sub_810E2C8
- str r0, [r5, 0x1C]
-_0810EA36:
- pop {r3,r4}
- mov r8, r3
- mov r9, r4
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810E520
-
- thumb_func_start sub_810EA4C
-sub_810EA4C: @ 810EA4C
- push {r4,r5,lr}
- adds r4, r0, 0
- ldr r0, =gBattleAnimTarget
- ldrb r0, [r0]
- bl GetBattlerSpriteBGPriority
- movs r1, 0x3
- ands r1, r0
- lsls r1, 2
- ldrb r2, [r4, 0x5]
- movs r0, 0xD
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- strb r0, [r4, 0x5]
- ldr r5, =gBattleAnimAttacker
- ldrb r0, [r5]
- movs r1, 0x2
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r4, 0x20]
- ldrb r0, [r5]
- movs r1, 0x3
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r4, 0x22]
- ldr r0, =TranslateAnimSpriteToTargetMonLocation
- str r0, [r4, 0x1C]
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EA4C
-
- thumb_func_start sub_810EAA0
-sub_810EAA0: @ 810EAA0
- push {r4,r5,lr}
- adds r5, r0, 0
- ldr r0, =gBattleAnimArgs
- movs r1, 0x4
- ldrsh r0, [r0, r1]
- cmp r0, 0
- bne _0810EABC
- adds r0, r5, 0
- movs r1, 0
- bl InitSpritePosToAnimAttacker
- b _0810EAC4
- .pool
-_0810EABC:
- adds r0, r5, 0
- movs r1, 0
- bl InitSpritePosToAnimTarget
-_0810EAC4:
- ldr r4, =gBattleAnimArgs
- movs r2, 0x4
- ldrsh r0, [r4, r2]
- cmp r0, 0
- bne _0810EADC
- ldr r0, =gBattleAnimAttacker
- ldrb r0, [r0]
- bl GetBattlerSide
- lsls r0, 24
- cmp r0, 0
- beq _0810EAF2
-_0810EADC:
- movs r1, 0x4
- ldrsh r0, [r4, r1]
- cmp r0, 0x1
- bne _0810EAF8
- ldr r0, =gBattleAnimTarget
- ldrb r0, [r0]
- bl GetBattlerSide
- lsls r0, 24
- cmp r0, 0
- bne _0810EAF8
-_0810EAF2:
- ldrh r0, [r5, 0x20]
- adds r0, 0x8
- strh r0, [r5, 0x20]
-_0810EAF8:
- ldr r4, =gBattleAnimArgs
- ldrb r1, [r4, 0x8]
- adds r0, r5, 0
- bl SeekSpriteAnim
- ldrh r0, [r5, 0x20]
- subs r0, 0x20
- strh r0, [r5, 0x20]
- ldr r0, =0x00000ccc
- strh r0, [r5, 0x30]
- ldrh r1, [r4, 0x8]
- movs r0, 0xC
- adds r2, r0, 0
- muls r2, r1
- adds r0, r2, 0
- ldrh r2, [r5, 0x24]
- adds r0, r2
- strh r0, [r5, 0x24]
- strh r1, [r5, 0x2E]
- ldrh r0, [r4, 0x6]
- strh r0, [r5, 0x3C]
- ldr r0, =sub_810EB40
- str r0, [r5, 0x1C]
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EAA0
-
- thumb_func_start sub_810EB40
-sub_810EB40: @ 810EB40
- push {r4,lr}
- adds r4, r0, 0
- ldrh r0, [r4, 0x30]
- lsls r0, 16
- asrs r0, 24
- ldrh r1, [r4, 0x24]
- adds r0, r1
- movs r1, 0
- strh r0, [r4, 0x24]
- ldrh r0, [r4, 0x2E]
- adds r0, 0x1
- strh r0, [r4, 0x2E]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0x6
- bne _0810EB6A
- strh r1, [r4, 0x2E]
- strh r1, [r4, 0x24]
- adds r0, r4, 0
- bl StartSpriteAnim
-_0810EB6A:
- ldrh r0, [r4, 0x3C]
- subs r0, 0x1
- strh r0, [r4, 0x3C]
- lsls r0, 16
- asrs r0, 16
- movs r1, 0x1
- negs r1, r1
- cmp r0, r1
- bne _0810EB82
- adds r0, r4, 0
- bl DestroyAnimSprite
-_0810EB82:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end sub_810EB40
-
- thumb_func_start sub_810EB88
-sub_810EB88: @ 810EB88
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- lsls r0, 24
- lsrs r0, 24
- adds r6, r0, 0
- ldr r1, =gTasks
- lsls r0, r6, 2
- adds r0, r6
- lsls r0, 3
- adds r7, r0, r1
- ldrh r0, [r7, 0x8]
- movs r1, 0x1F
- ands r0, r1
- cmp r0, 0
- bne _0810EC02
- ldr r1, =gAnimVisualTaskCount
- ldrb r0, [r1]
- adds r0, 0x1
- strb r0, [r1]
- movs r1, 0x8
- ldrsh r0, [r7, r1]
- movs r5, 0xD
- negs r5, r5
- adds r1, r5, 0
- bl Sin
- ldr r4, =gBattleAnimArgs
- strh r0, [r4]
- movs r1, 0x8
- ldrsh r0, [r7, r1]
- adds r1, r5, 0
- bl Cos
- strh r0, [r4, 0x2]
- movs r0, 0x1
- strh r0, [r4, 0x4]
- movs r0, 0x3
- strh r0, [r4, 0x6]
- ldr r0, =gUnknown_085973E8
- mov r8, r0
- ldr r5, =gBattleAnimTarget
- ldrb r0, [r5]
- movs r1, 0x2
- bl GetBattlerSpriteCoord
- adds r4, r0, 0
- lsls r4, 24
- lsrs r4, 24
- ldrb r0, [r5]
- movs r1, 0x3
- bl GetBattlerSpriteCoord
- adds r2, r0, 0
- lsls r2, 24
- lsrs r2, 24
- mov r0, r8
- adds r1, r4, 0
- movs r3, 0x3
- bl CreateSpriteAndAnimate
-_0810EC02:
- ldrh r0, [r7, 0x8]
- adds r0, 0x8
- strh r0, [r7, 0x8]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0xFF
- ble _0810EC16
- adds r0, r6, 0
- bl DestroyAnimVisualTask
-_0810EC16:
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EB88
-
- thumb_func_start sub_810EC34
-sub_810EC34: @ 810EC34
- push {r4,lr}
- adds r4, r0, 0
- movs r1, 0x2E
- ldrsh r0, [r4, r1]
- cmp r0, 0
- beq _0810EC46
- cmp r0, 0x1
- beq _0810EC78
- b _0810EC8C
-_0810EC46:
- adds r0, r4, 0
- movs r1, 0x1
- bl InitSpritePosToAnimAttacker
- movs r0, 0
- bl GetAnimBattlerSpriteId
- ldr r2, =gSprites
- lsls r0, 24
- lsrs r0, 24
- lsls r1, r0, 4
- adds r1, r0
- lsls r1, 2
- adds r1, r2
- adds r1, 0x3E
- ldrb r0, [r1]
- movs r2, 0x4
- orrs r0, r2
- strb r0, [r1]
- ldrh r0, [r4, 0x2E]
- adds r0, 0x1
- strh r0, [r4, 0x2E]
- b _0810EC8C
- .pool
-_0810EC78:
- adds r0, r4, 0
- adds r0, 0x3F
- ldrb r1, [r0]
- movs r0, 0x20
- ands r0, r1
- cmp r0, 0
- beq _0810EC8C
- adds r0, r4, 0
- bl DestroyAnimSprite
-_0810EC8C:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end sub_810EC34
-
- thumb_func_start sub_810EC94
-sub_810EC94: @ 810EC94
- push {r4,lr}
- adds r4, r0, 0
- movs r1, 0x2E
- ldrsh r0, [r4, r1]
- cmp r0, 0x1
- beq _0810ECCC
- cmp r0, 0x1
- bgt _0810ECAA
- cmp r0, 0
- beq _0810ECB0
- b _0810ED1E
-_0810ECAA:
- cmp r0, 0x2
- beq _0810ECE0
- b _0810ED1E
-_0810ECB0:
- ldr r0, =gBattleAnimTarget
- ldrb r0, [r0]
- movs r1, 0x1
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r4, 0x22]
- negs r0, r0
- subs r0, 0x20
- strh r0, [r4, 0x26]
- b _0810ECD8
- .pool
-_0810ECCC:
- ldrh r0, [r4, 0x26]
- adds r0, 0xA
- strh r0, [r4, 0x26]
- lsls r0, 16
- cmp r0, 0
- blt _0810ED1E
-_0810ECD8:
- ldrh r0, [r4, 0x2E]
- adds r0, 0x1
- strh r0, [r4, 0x2E]
- b _0810ED1E
-_0810ECE0:
- ldrh r0, [r4, 0x26]
- subs r0, 0xA
- strh r0, [r4, 0x26]
- movs r2, 0x22
- ldrsh r0, [r4, r2]
- movs r2, 0x26
- ldrsh r1, [r4, r2]
- adds r0, r1
- movs r1, 0x20
- negs r1, r1
- cmp r0, r1
- bge _0810ED1E
- movs r0, 0
- bl GetAnimBattlerSpriteId
- ldr r2, =gSprites
- lsls r0, 24
- lsrs r0, 24
- lsls r1, r0, 4
- adds r1, r0
- lsls r1, 2
- adds r1, r2
- adds r1, 0x3E
- ldrb r2, [r1]
- movs r0, 0x5
- negs r0, r0
- ands r0, r2
- strb r0, [r1]
- adds r0, r4, 0
- bl DestroyAnimSprite
-_0810ED1E:
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EC94
-
- thumb_func_start sub_810ED28
-sub_810ED28: @ 810ED28
- push {r4,lr}
- adds r4, r0, 0
- movs r1, 0x1
- bl InitSpritePosToAnimAttacker
- ldr r1, =gBattleAnimArgs
- ldrh r0, [r1, 0x4]
- strh r0, [r4, 0x2E]
- ldrh r0, [r1, 0x6]
- strh r0, [r4, 0x30]
- ldr r0, =sub_810ED70
- str r0, [r4, 0x1C]
- movs r0, 0
- bl GetAnimBattlerSpriteId
- ldr r2, =gSprites
- lsls r0, 24
- lsrs r0, 24
- lsls r1, r0, 4
- adds r1, r0
- lsls r1, 2
- adds r1, r2
- adds r1, 0x3E
- ldrb r0, [r1]
- movs r2, 0x4
- orrs r0, r2
- strb r0, [r1]
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810ED28
-
- thumb_func_start sub_810ED70
-sub_810ED70: @ 810ED70
- push {lr}
- adds r2, r0, 0
- ldrh r1, [r2, 0x2E]
- movs r3, 0x2E
- ldrsh r0, [r2, r3]
- cmp r0, 0
- ble _0810ED84
- subs r0, r1, 0x1
- strh r0, [r2, 0x2E]
- b _0810EDC8
-_0810ED84:
- movs r1, 0x22
- ldrsh r0, [r2, r1]
- movs r3, 0x26
- ldrsh r1, [r2, r3]
- adds r0, r1
- movs r1, 0x20
- negs r1, r1
- cmp r0, r1
- ble _0810EDAA
- ldrh r0, [r2, 0x30]
- ldrh r1, [r2, 0x32]
- adds r0, r1
- strh r0, [r2, 0x32]
- lsls r0, 16
- asrs r0, 24
- ldrh r1, [r2, 0x26]
- subs r1, r0
- strh r1, [r2, 0x26]
- b _0810EDC8
-_0810EDAA:
- adds r3, r2, 0
- adds r3, 0x3E
- ldrb r0, [r3]
- movs r1, 0x4
- orrs r0, r1
- strb r0, [r3]
- ldrh r0, [r2, 0x34]
- adds r1, r0, 0x1
- strh r1, [r2, 0x34]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0x14
- ble _0810EDC8
- ldr r0, =sub_810EDD0
- str r0, [r2, 0x1C]
-_0810EDC8:
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810ED70
-
- thumb_func_start sub_810EDD0
-sub_810EDD0: @ 810EDD0
- push {lr}
- adds r2, r0, 0
- ldrh r0, [r2, 0x32]
- lsls r0, 16
- asrs r0, 24
- ldrh r1, [r2, 0x26]
- adds r0, r1
- strh r0, [r2, 0x26]
- movs r3, 0x22
- ldrsh r0, [r2, r3]
- movs r3, 0x26
- ldrsh r1, [r2, r3]
- adds r0, r1
- movs r1, 0x20
- negs r1, r1
- cmp r0, r1
- ble _0810EE00
- adds r3, r2, 0
- adds r3, 0x3E
- ldrb r1, [r3]
- movs r0, 0x5
- negs r0, r0
- ands r0, r1
- strb r0, [r3]
-_0810EE00:
- movs r1, 0x26
- ldrsh r0, [r2, r1]
- cmp r0, 0
- ble _0810EE0E
- adds r0, r2, 0
- bl DestroyAnimSprite
-_0810EE0E:
- pop {r0}
- bx r0
- thumb_func_end sub_810EDD0
-
- thumb_func_start sub_810EE14
-sub_810EE14: @ 810EE14
- push {r4,r5,lr}
- sub sp, 0x4
- adds r5, r0, 0
- movs r1, 0x2E
- ldrsh r0, [r5, r1]
- cmp r0, 0
- beq _0810EE28
- cmp r0, 0x1
- beq _0810EE80
- b _0810EEEC
-_0810EE28:
- ldr r0, =gBattleAnimArgs
- movs r2, 0
- ldrsh r0, [r0, r2]
- cmp r0, 0
- bne _0810EE40
- ldr r4, =gBattleAnimAttacker
- b _0810EE42
- .pool
-_0810EE40:
- ldr r4, =gBattleAnimTarget
-_0810EE42:
- ldrb r0, [r4]
- movs r1, 0
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r5, 0x20]
- ldrb r0, [r4]
- movs r1, 0x1
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r5, 0x22]
- movs r0, 0
- movs r3, 0x80
- lsls r3, 2
- strh r3, [r5, 0x30]
- movs r2, 0x80
- lsls r2, 1
- str r0, [sp]
- adds r0, r5, 0
- movs r1, 0
- bl TrySetSpriteRotScale
- ldrh r0, [r5, 0x2E]
- adds r0, 0x1
- strh r0, [r5, 0x2E]
- b _0810EEEC
- .pool
-_0810EE80:
- movs r1, 0x32
- ldrsh r0, [r5, r1]
- cmp r0, 0xB
- bgt _0810EE8E
- ldrh r0, [r5, 0x30]
- subs r0, 0x28
- b _0810EE92
-_0810EE8E:
- ldrh r0, [r5, 0x30]
- adds r0, 0x28
-_0810EE92:
- strh r0, [r5, 0x30]
- ldrh r0, [r5, 0x32]
- adds r0, 0x1
- movs r1, 0
- strh r0, [r5, 0x32]
- movs r2, 0x80
- lsls r2, 1
- movs r0, 0x30
- ldrsh r3, [r5, r0]
- str r1, [sp]
- adds r0, r5, 0
- bl TrySetSpriteRotScale
- ldrb r1, [r5, 0x3]
- lsls r1, 26
- lsrs r1, 27
- movs r0, 0xF4
- lsls r0, 6
- ldr r2, =gOamMatrices
- lsls r1, 3
- adds r1, r2
- movs r2, 0x6
- ldrsh r1, [r1, r2]
- bl __divsi3
- adds r1, r0, 0x1
- cmp r1, 0x80
- ble _0810EECC
- movs r1, 0x80
-_0810EECC:
- movs r0, 0x40
- subs r0, r1
- lsrs r1, r0, 31
- adds r0, r1
- asrs r1, r0, 1
- strh r1, [r5, 0x26]
- movs r1, 0x32
- ldrsh r0, [r5, r1]
- cmp r0, 0x18
- bne _0810EEEC
- adds r0, r5, 0
- bl sub_80A749C
- adds r0, r5, 0
- bl DestroyAnimSprite
-_0810EEEC:
- add sp, 0x4
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EE14
-
- thumb_func_start sub_810EEF8
-sub_810EEF8: @ 810EEF8
- push {r4,r5,lr}
- adds r5, r0, 0
- bl Random2
- ldr r4, =0x000001ff
- ands r4, r0
- bl Random2
- movs r1, 0x7F
- ands r1, r0
- movs r0, 0x1
- ands r0, r4
- cmp r0, 0
- beq _0810EF20
- movs r2, 0xB8
- lsls r2, 2
- adds r0, r4, r2
- b _0810EF28
- .pool
-_0810EF20:
- movs r2, 0xB8
- lsls r2, 2
- adds r0, r2, 0
- subs r0, r4
-_0810EF28:
- strh r0, [r5, 0x2E]
- movs r0, 0x1
- ands r0, r1
- cmp r0, 0
- beq _0810EF3C
- movs r2, 0xE0
- lsls r2, 2
- adds r0, r2, 0
- adds r0, r1, r0
- b _0810EF44
-_0810EF3C:
- movs r2, 0xE0
- lsls r2, 2
- adds r0, r2, 0
- subs r0, r1
-_0810EF44:
- strh r0, [r5, 0x30]
- ldr r2, =gBattleAnimArgs
- ldrh r0, [r2]
- strh r0, [r5, 0x32]
- lsls r0, 16
- cmp r0, 0
- beq _0810EF60
- ldrb r0, [r5, 0x3]
- movs r1, 0x3F
- negs r1, r1
- ands r1, r0
- movs r0, 0x10
- orrs r1, r0
- strb r1, [r5, 0x3]
-_0810EF60:
- movs r1, 0x2
- ldrsh r0, [r2, r1]
- cmp r0, 0
- bne _0810EF74
- ldr r4, =gBattleAnimAttacker
- b _0810EF76
- .pool
-_0810EF74:
- ldr r4, =gBattleAnimTarget
-_0810EF76:
- ldrb r0, [r4]
- movs r1, 0
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- strh r0, [r5, 0x20]
- ldrb r0, [r4]
- movs r1, 0x1
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- adds r0, 0x20
- strh r0, [r5, 0x22]
- ldr r0, =sub_810EFA8
- str r0, [r5, 0x1C]
- pop {r4,r5}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810EEF8
-
- thumb_func_start sub_810EFA8
-sub_810EFA8: @ 810EFA8
- push {r4,lr}
- adds r4, r0, 0
- movs r1, 0x32
- ldrsh r0, [r4, r1]
- cmp r0, 0
- bne _0810EFC0
- ldrh r3, [r4, 0x2E]
- lsls r0, r3, 16
- asrs r0, 24
- ldrh r1, [r4, 0x24]
- adds r0, r1
- b _0810EFCA
-_0810EFC0:
- ldrh r3, [r4, 0x2E]
- lsls r1, r3, 16
- asrs r1, 24
- ldrh r0, [r4, 0x24]
- subs r0, r1
-_0810EFCA:
- strh r0, [r4, 0x24]
- ldrh r2, [r4, 0x30]
- lsls r1, r2, 16
- asrs r1, 24
- ldrh r0, [r4, 0x26]
- subs r0, r1
- strh r0, [r4, 0x26]
- strh r3, [r4, 0x2E]
- adds r0, r2, 0
- subs r0, 0x20
- strh r0, [r4, 0x30]
- lsls r0, r3, 16
- cmp r0, 0
- bge _0810EFEA
- movs r0, 0
- strh r0, [r4, 0x2E]
-_0810EFEA:
- ldrh r0, [r4, 0x34]
- adds r0, 0x1
- strh r0, [r4, 0x34]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0x1F
- bne _0810EFFE
- adds r0, r4, 0
- bl DestroyAnimSprite
-_0810EFFE:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end sub_810EFA8
-
- thumb_func_start sub_810F004
-sub_810F004: @ 810F004
- movs r1, 0
- strh r1, [r0, 0x3A]
- movs r1, 0x40
- strh r1, [r0, 0x3C]
- ldr r1, =sub_810F018
- str r1, [r0, 0x1C]
- bx lr
- .pool
- thumb_func_end sub_810F004
-
- thumb_func_start sub_810F018
-sub_810F018: @ 810F018
- push {lr}
- adds r3, r0, 0
- movs r0, 0x2E
- ldrsh r1, [r3, r0]
- cmp r1, 0
- beq _0810F02A
- cmp r1, 0x1
- beq _0810F078
- b _0810F07E
-_0810F02A:
- ldrh r0, [r3, 0x30]
- adds r0, 0x1
- strh r0, [r3, 0x30]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0x8
- ble _0810F07E
- strh r1, [r3, 0x30]
- movs r1, 0x3E
- adds r1, r3
- mov r12, r1
- ldrb r2, [r1]
- lsls r0, r2, 29
- lsrs r0, 31
- movs r1, 0x1
- eors r1, r0
- lsls r1, 2
- movs r0, 0x5
- negs r0, r0
- ands r0, r2
- orrs r0, r1
- mov r1, r12
- strb r0, [r1]
- ldrh r0, [r3, 0x32]
- adds r0, 0x1
- strh r0, [r3, 0x32]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0x5
- ble _0810F07E
- ldrb r1, [r1]
- movs r0, 0x4
- ands r0, r1
- cmp r0, 0
- beq _0810F07E
- ldrh r0, [r3, 0x2E]
- adds r0, 0x1
- strh r0, [r3, 0x2E]
- b _0810F07E
-_0810F078:
- adds r0, r3, 0
- bl DestroyAnimSprite
-_0810F07E:
- pop {r0}
- bx r0
- thumb_func_end sub_810F018
-
- thumb_func_start sub_810F084
-sub_810F084: @ 810F084
- push {r4-r6,lr}
- mov r6, r9
- mov r5, r8
- push {r5,r6}
- sub sp, 0x4
- mov r8, r0
- ldrh r4, [r0, 0x20]
- ldrh r5, [r0, 0x22]
- ldr r6, =gBattleAnimAttacker
- ldrb r0, [r6]
- movs r1, 0x2
- bl GetBattlerSpriteCoord
- lsls r0, 24
- lsrs r0, 24
- mov r1, r8
- strh r0, [r1, 0x20]
- ldrb r0, [r6]
- movs r1, 0x3
- bl GetBattlerSpriteCoord
- adds r6, r0, 0
- lsls r6, 24
- lsrs r6, 24
- mov r2, r8
- strh r6, [r2, 0x22]
- ldrh r0, [r2, 0x20]
- mov r9, r0
- mov r1, r9
- lsls r0, r1, 4
- strh r0, [r2, 0x36]
- lsls r0, r6, 4
- strh r0, [r2, 0x38]
- lsls r4, 16
- asrs r4, 16
- movs r1, 0x20
- ldrsh r0, [r2, r1]
- subs r0, r4, r0
- lsls r0, 4
- movs r1, 0xC
- bl __divsi3
- mov r2, r8
- strh r0, [r2, 0x3A]
- lsls r5, 16
- asrs r5, 16
- movs r1, 0x22
- ldrsh r0, [r2, r1]
- subs r0, r5, r0
- lsls r0, 4
- movs r1, 0xC
- bl __divsi3
- mov r2, r8
- strh r0, [r2, 0x3C]
- mov r0, r9
- subs r4, r0
- lsls r4, 16
- asrs r4, 16
- subs r5, r6
- lsls r5, 16
- asrs r5, 16
- adds r0, r4, 0
- adds r1, r5, 0
- bl ArcTan2Neg
- lsls r0, 16
- movs r1, 0xC0
- lsls r1, 24
- adds r0, r1
- lsrs r0, 16
- movs r3, 0x80
- lsls r3, 1
- str r0, [sp]
- mov r0, r8
- movs r1, 0x1
- adds r2, r3, 0
- bl TrySetSpriteRotScale
- ldr r0, =sub_810F140
- mov r2, r8
- str r0, [r2, 0x1C]
- add sp, 0x4
- pop {r3,r4}
- mov r8, r3
- mov r9, r4
- pop {r4-r6}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810F084
-
- thumb_func_start sub_810F140
-sub_810F140: @ 810F140
- push {lr}
- adds r2, r0, 0
- ldrh r0, [r2, 0x3A]
- ldrh r1, [r2, 0x36]
- adds r0, r1
- strh r0, [r2, 0x36]
- ldrh r1, [r2, 0x3C]
- ldrh r3, [r2, 0x38]
- adds r1, r3
- strh r1, [r2, 0x38]
- lsls r0, 16
- asrs r0, 20
- strh r0, [r2, 0x20]
- lsls r1, 16
- asrs r3, r1, 20
- strh r3, [r2, 0x22]
- adds r0, 0x2D
- lsls r0, 16
- movs r1, 0xA5
- lsls r1, 17
- cmp r0, r1
- bhi _0810F17A
- adds r1, r3, 0
- cmp r1, 0x9D
- bgt _0810F17A
- movs r0, 0x2D
- negs r0, r0
- cmp r1, r0
- bge _0810F180
-_0810F17A:
- adds r0, r2, 0
- bl DestroySpriteAndMatrix
-_0810F180:
- pop {r0}
- bx r0
- thumb_func_end sub_810F140
-
- thumb_func_start sub_810F184
-sub_810F184: @ 810F184
- push {r4,lr}
- lsls r0, 24
- lsrs r4, r0, 24
- ldr r0, =gBattleAnimArgs
- movs r1, 0
- ldrsh r0, [r0, r1]
- cmp r0, 0
- bne _0810F1BC
- movs r0, 0
- bl GetAnimBattlerSpriteId
- lsls r0, 24
- lsrs r0, 24
- ldr r2, =gSprites
- lsls r1, r0, 4
- adds r1, r0
- lsls r1, 2
- adds r1, r2
- adds r1, 0x3E
- ldrb r0, [r1]
- movs r2, 0x4
- orrs r0, r2
- b _0810F1DA
- .pool
-_0810F1BC:
- movs r0, 0
- bl GetAnimBattlerSpriteId
- lsls r0, 24
- lsrs r0, 24
- ldr r2, =gSprites
- lsls r1, r0, 4
- adds r1, r0
- lsls r1, 2
- adds r1, r2
- adds r1, 0x3E
- ldrb r2, [r1]
- movs r0, 0x5
- negs r0, r0
- ands r0, r2
-_0810F1DA:
- strb r0, [r1]
- adds r0, r4, 0
- bl DestroyAnimVisualTask
- pop {r4}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_810F184
-
- .align 2, 0
diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc
index 6370ef569..ed32e4643 100644
--- a/asm/macros/battle_script.inc
+++ b/asm/macros/battle_script.inc
@@ -1078,7 +1078,7 @@
.4byte \param0
.endm
- .macro tryimprision param0:req
+ .macro tryimprison param0:req
.byte 0xdb
.4byte \param0
.endm
diff --git a/asm/macros/event.inc b/asm/macros/event.inc
index fa0b3fa06..8b3466fe7 100644
--- a/asm/macros/event.inc
+++ b/asm/macros/event.inc
@@ -824,7 +824,7 @@
.byte \y
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (gMultichoiceLists) and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoice x:req, y:req, list:req, b:req
.byte 0x6f
.byte \x
@@ -833,7 +833,7 @@
.byte \b
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (gMultichoiceLists) and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoicedefault x:req, y:req, list:req, default:req, b:req
.byte 0x70
.byte \x
@@ -843,7 +843,7 @@
.byte \b
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined (gMultichoiceLists) and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
.macro multichoicegrid x:req, y:req, list:req, per_row:req, B:req
.byte 0x71
.byte \x
@@ -1163,12 +1163,12 @@
.endm
@ Changes the metatile at (x, y) on the current map.
- .macro setmetatile x:req, y:req, metatile_number:req, tile_attrib:req
+ .macro setmetatile x:req, y:req, metatile_number:req, has_collision:req
.byte 0xa2
.2byte \x
.2byte \y
.2byte \metatile_number
- .2byte \tile_attrib
+ .2byte \has_collision
.endm
@ Queues a weather change to the default weather for the map.
diff --git a/asm/rom_8011DC0.s b/asm/rom_8011DC0.s
index fafedeeff..c13ab9a96 100644
--- a/asm/rom_8011DC0.s
+++ b/asm/rom_8011DC0.s
@@ -472,7 +472,7 @@ sub_8017020: @ 8017020
bl sub_81973A4
movs r0, 0
movs r1, 0x1
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldr r0, =gStringVar4
adds r1, r4, 0
bl StringExpandPlaceholders
@@ -517,7 +517,7 @@ _08017076:
bl sub_81973A4
movs r0, 0
movs r1, 0x1
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldr r0, =gStringVar4
adds r1, r5, 0
bl StringExpandPlaceholders
@@ -563,7 +563,7 @@ _080170CA:
negs r0, r0
b _08017110
_080170D4:
- bl DisplayYesNoMenu
+ bl DisplayYesNoMenuDefaultYes
ldrb r0, [r4]
adds r0, 0x1
strb r0, [r4]
@@ -609,7 +609,7 @@ sub_8017118: @ 8017118
lsrs r4, 24
adds r0, r4, 0
movs r1, 0
- bl NewMenuHelpers_DrawStdWindowFrame
+ bl DrawStdWindowFrame
adds r0, r4, 0
movs r1, 0xFF
bl FillWindowPixelBuffer
@@ -705,7 +705,7 @@ _080171DC:
strb r0, [r5]
ldrb r0, [r5]
movs r1, 0
- bl NewMenuHelpers_DrawStdWindowFrame
+ bl DrawStdWindowFrame
ldr r0, =gMultiuseListMenuTemplate
adds r2, r0, 0
ldr r1, [sp, 0x24]
@@ -745,7 +745,7 @@ _08017228:
bl DestroyListMenuTask
ldrb r0, [r5]
movs r1, 0x1
- bl sub_819746C
+ bl ClearStdWindowAndFrame
ldrb r0, [r5]
bl RemoveWindow
movs r0, 0
@@ -765,7 +765,7 @@ _08017264:
bl DestroyListMenuTask
ldrb r0, [r5]
movs r1, 0x1
- bl sub_819746C
+ bl ClearStdWindowAndFrame
ldrb r0, [r5]
bl RemoveWindow
strb r4, [r7]
@@ -818,7 +818,7 @@ _080172C8:
strb r0, [r6]
ldrb r0, [r6]
movs r1, 0
- bl NewMenuHelpers_DrawStdWindowFrame
+ bl DrawStdWindowFrame
ldr r0, =gMultiuseListMenuTemplate
adds r2, r0, 0
ldr r1, [sp, 0x24]
@@ -18242,7 +18242,7 @@ sub_801FEBC: @ 801FEBC
lsls r0, 24
lsrs r0, 24
movs r1, 0
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldr r0, [r4]
ldrb r0, [r0, 0x18]
bl ClearWindowTilemap
@@ -18470,7 +18470,7 @@ sub_8020094: @ 8020094
lsls r0, 24
lsrs r0, 24
movs r1, 0
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldr r0, [r4]
ldrb r0, [r0, 0x1E]
bl ClearWindowTilemap
@@ -18913,7 +18913,7 @@ sub_802040C: @ 802040C
push {lr}
movs r0, 0x3
movs r1, 0
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
movs r0, 0x3
bl ClearWindowTilemap
pop {r0}
@@ -22378,7 +22378,7 @@ _0802210C:
movs r1, 0
adds r2, r4, 0
movs r3, 0xD
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
b _08022218
.pool
_08022130:
@@ -22509,7 +22509,7 @@ sub_802222C: @ 802222C
adds r5, r4, r0
ldrb r0, [r5]
movs r1, 0x1
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldrb r0, [r5]
bl RemoveWindow
adds r0, r4, 0
@@ -22577,7 +22577,7 @@ _08022296:
movs r1, 0
adds r2, r4, 0
movs r3, 0xD
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
b _080224BA
.pool
_080222D0:
@@ -22773,7 +22773,7 @@ _08022480:
_08022494:
ldrb r0, [r6, 0x2]
movs r1, 0x1
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldrb r0, [r6, 0x2]
bl ClearWindowTilemap
ldrb r0, [r6, 0x2]
@@ -23864,7 +23864,7 @@ _08022D38:
_08022D42:
movs r0, 0
movs r1, 0
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldrb r1, [r5, 0x1]
movs r0, 0x2
mov r8, r0
@@ -23946,7 +23946,7 @@ _08022DE8:
beq _08022DFA
movs r0, 0
movs r1, 0x1
- bl sub_8197434
+ bl ClearDialogWindowAndFrame
_08022DFA:
ldrb r0, [r7, 0xE]
movs r1, 0x1
@@ -24250,7 +24250,7 @@ _0802301E:
_08023044:
movs r0, 0
movs r1, 0x1
- bl sub_8197434
+ bl ClearDialogWindowAndFrame
movs r0, 0xA
movs r1, 0x1
movs r2, 0
@@ -26462,7 +26462,7 @@ _080241A6:
beq _0802421E
movs r0, 0
movs r1, 0
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldr r2, =gText_SavingDontTurnOffPower
movs r0, 0
str r0, [sp]
@@ -26550,7 +26550,7 @@ _08024246:
strb r0, [r5, 0xC]
b _080242D8
_0802426A:
- bl DisplayYesNoMenu
+ bl DisplayYesNoMenuDefaultYes
b _080242D0
_08024270:
bl Menu_ProcessInputNoWrapClearOnChoose
@@ -26583,7 +26583,7 @@ _080242A4:
_080242A6:
movs r0, 0
movs r1, 0x1
- bl sub_8197434
+ bl ClearDialogWindowAndFrame
movs r4, 0
str r4, [sp]
adds r0, r6, 0
@@ -26761,7 +26761,7 @@ _080243EA:
_080243F6:
movs r0, 0
movs r1, 0x1
- bl sub_8197434
+ bl ClearDialogWindowAndFrame
adds r0, r5, 0
bl sub_8021488
movs r0, 0x1
@@ -26819,7 +26819,7 @@ _0802445A:
_08024460:
movs r0, 0
movs r1, 0
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldrh r1, [r5, 0x14]
cmp r1, 0x3
bne _08024490
@@ -27347,7 +27347,7 @@ sub_802482C: @ 802482C
movs r1, 0
adds r2, r4, 0
adds r3, r5, 0
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
ldr r2, =gText_Powder
movs r0, 0x1
str r0, [sp]
@@ -27446,7 +27446,7 @@ sub_8024918: @ 8024918
bl ClearWindowTilemap
ldrb r0, [r4]
movs r1, 0x1
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldrb r0, [r4]
bl RemoveWindow
pop {r4}
@@ -38552,7 +38552,7 @@ _0802A3A4:
_0802A3AE:
movs r0, 0
movs r1, 0
- bl NewMenuHelpers_DrawDialogueFrame
+ bl DrawDialogueFrame
ldr r2, =gText_SavingDontTurnOffPower
str r4, [sp]
movs r0, 0x2
diff --git a/asm/rom_81D1C44.s b/asm/rom_81D1C44.s
index 13664a4b2..36ebd29da 100644
--- a/asm/rom_81D1C44.s
+++ b/asm/rom_81D1C44.s
@@ -108,7 +108,7 @@ sub_81D1D04: @ 81D1D04
adds r4, r0
ldrb r0, [r4]
movs r1, 0
- bl sub_8198070
+ bl ClearStdWindowAndFrameToTransparent
ldrb r0, [r4]
bl ClearWindowTilemap
ldrb r0, [r4]
@@ -1613,7 +1613,7 @@ _081D284A:
movs r1, 0
movs r2, 0x1
movs r3, 0xE
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
b _081D288E
.pool
_081D287C:
@@ -1623,7 +1623,7 @@ _081D287C:
movs r1, 0
movs r2, 0x1
movs r3, 0xE
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
_081D288E:
movs r0, 0x2
bl PutWindowTilemap
@@ -1633,12 +1633,12 @@ _081D288E:
movs r1, 0
movs r2, 0x1
movs r3, 0xE
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
movs r0, 0x3
movs r1, 0
movs r2, 0x1
movs r3, 0xE
- bl SetWindowBorderStyle
+ bl DrawStdFrameWithCustomTileAndPalette
bl nullsub_79
movs r0, 0x1
bl schedule_bg_copy_tilemap_to_vram
@@ -6500,7 +6500,7 @@ _081D4F6C:
bne _081D4F88
movs r0, 0x49
bl PlaySE
- bl sub_800A620
+ bl CheckShouldAdvanceLinkState
movs r0, 0
strh r0, [r5]
b _081D4FE6
diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt
index b92da84ec..e136f5444 100644
--- a/common_syms/overworld.txt
+++ b/common_syms/overworld.txt
@@ -1,8 +1,8 @@
gBGTilemapBuffers1
gBGTilemapBuffers2
gBGTilemapBuffers3
-gUnknown_03005DA8
+gHeldKeyCodeToSend
gFieldCallback
gFieldCallback2
-gUnknown_03005DB4
+gLocalLinkPlayerId
gFieldLinkPlayerCount
diff --git a/common_syms/window.txt b/common_syms/window.txt
index e1b52a24f..87a1679d1 100644
--- a/common_syms/window.txt
+++ b/common_syms/window.txt
@@ -1,5 +1,5 @@
filler_03002F58
filler_03002F5C
-gUnknown_03002F60
+gTransparentTileNumber
filler_03002F64
gUnknown_03002F70
diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s
index 8ddf56ef8..b0c753752 100644
--- a/data/battle_scripts_1.s
+++ b/data/battle_scripts_1.s
@@ -2538,7 +2538,7 @@ BattleScript_EffectImprison::
attackcanceler
attackstring
ppreduce
- tryimprision BattleScript_ButItFailed
+ tryimprison BattleScript_ButItFailed
attackanimation
waitanimation
printstring STRINGID_PKMNSEALEDOPPONENTMOVE
@@ -3684,11 +3684,11 @@ BattleScript_MoveUsedIsImprisoned::
waitmessage 0x40
goto BattleScript_MoveEnd
-BattleScript_SelectingImprisionedMove::
+BattleScript_SelectingImprisonedMove::
printselectionstring STRINGID_PKMNCANTUSEMOVESEALED
endselectionscript
-BattleScript_SelectingImprisionedMoveInPalace::
+BattleScript_SelectingImprisonedMoveInPalace::
printstring STRINGID_PKMNCANTUSEMOVESEALED
goto BattleScript_SelectingUnusableMoveInPalace
@@ -3876,7 +3876,7 @@ BattleScript_MoveUsedIsInLove::
status2animation BS_ATTACKER, STATUS2_INFATUATION
return
-BattleScript_MoveUsedIsParalyzedCantAttack::
+BattleScript_MoveUsedIsInLoveCantAttack::
printstring STRINGID_PKMNIMMOBILIZEDBYLOVE
waitmessage 0x40
goto BattleScript_MoveEnd
diff --git a/data/event_scripts.s b/data/event_scripts.s
index 1453175b5..1175c8d00 100644
--- a/data/event_scripts.s
+++ b/data/event_scripts.s
@@ -17,6 +17,8 @@
#include "constants/trainers.h"
#include "constants/vars.h"
#include "constants/weather.h"
+#include "constants/trainer_hill.h"
+#include "constants/battle.h"
.include "asm/macros.inc"
.include "asm/macros/event.inc"
.include "constants/constants.inc"
@@ -47,7 +49,7 @@ gSpecialVars:: @ 81DBA0C
.4byte gSpecialVar_ContestCategory
.4byte gSpecialVar_MonBoxId
.4byte gSpecialVar_MonBoxPos
- .4byte gSpecialVar_0x8014
+ .4byte gSpecialVar_Unused_0x8014
.4byte gTrainerBattleOpponent_A
.include "data/specials.inc"
@@ -1094,7 +1096,7 @@ EverGrandeCity_HallOfFame_EventScript_2717C1:: @ 82717C1
special sub_81AFDD0
setflag FLAG_IS_CHAMPION
call EverGrandeCity_HallOfFame_EventScript_271829
- compare VAR_0x40CC, 0
+ compare VAR_FOSSIL_MANIAC_STATE, 0
call_if_eq EverGrandeCity_HallOfFame_EventScript_271839
clearflag FLAG_HIDE_LILCOVE_MOTEL_GAME_DESIGNERS
call EverGrandeCity_HallOfFame_EventScript_2718CC
@@ -1127,7 +1129,7 @@ EverGrandeCity_HallOfFame_EventScript_271829:: @ 8271829
return
EverGrandeCity_HallOfFame_EventScript_271839:: @ 8271839
- setvar VAR_0x40CC, 1
+ setvar VAR_FOSSIL_MANIAC_STATE, 1
return
EverGrandeCity_HallOfFame_EventScript_27183F:: @ 827183F
@@ -1146,19 +1148,19 @@ EverGrandeCity_HallOfFame_EventScript_271851:: @ 8271851
EventScript_WhiteOut:: @ 8271857
call EverGrandeCity_HallOfFame_EventScript_2718CC
- goto EventScript_271862
+ goto EventScript_ResetMrBriney
end
-EventScript_271862:: @ 8271862
+EventScript_ResetMrBriney:: @ 8271862
compare VAR_BRINEY_LOCATION, 1
- goto_if_eq EverGrandeCity_HallOfFame_EventScript_271884
+ goto_if_eq EventScript_MoveMrBrineyToHouse
compare VAR_BRINEY_LOCATION, 2
- goto_if_eq EverGrandeCity_HallOfFame_EventScript_27189A
+ goto_if_eq EventScript_MoveMrBrineyToDewford
compare VAR_BRINEY_LOCATION, 3
- goto_if_eq EverGrandeCity_HallOfFame_EventScript_2718B3
+ goto_if_eq EventScript_MoveMrBrineyToRoute108
end
-EverGrandeCity_HallOfFame_EventScript_271884:: @ 8271884
+EventScript_MoveMrBrineyToHouse:: @ 8271884
setflag FLAG_HIDE_MR_BRINEY_DEWFORD_TOWN
setflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
setflag FLAG_HIDE_ROUTE_108_MR_BRINEY
@@ -1168,7 +1170,7 @@ EverGrandeCity_HallOfFame_EventScript_271884:: @ 8271884
clearflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
end
-EverGrandeCity_HallOfFame_EventScript_27189A:: @ 827189A
+EventScript_MoveMrBrineyToDewford:: @ 827189A
setflag FLAG_HIDE_ROUTE_108_MR_BRINEY
setflag FLAG_HIDE_ROUTE_109_MR_BRINEY_BOAT
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
@@ -1179,7 +1181,7 @@ EverGrandeCity_HallOfFame_EventScript_27189A:: @ 827189A
clearflag FLAG_HIDE_MR_BRINEY_BOAT_DEWFORD_TOWN
end
-EverGrandeCity_HallOfFame_EventScript_2718B3:: @ 82718B3
+EventScript_MoveMrBrineyToRoute108:: @ 82718B3
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY
setflag FLAG_HIDE_ROUTE_104_MR_BRINEY_BOAT
setflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
@@ -1597,7 +1599,7 @@ EventScript_271D5E:: @ 8271D5E
goto EventScript_271D89
EventScript_271D83:: @ 8271D83
- special sub_80E6BE8
+ special RecordMixingPlayerSpotTriggered
waitstate
lock
faceplayer
@@ -2699,10 +2701,10 @@ gUnknown_08273594:: @ 8273594
gUnknown_082735F2:: @ 82735F2
.string "It appears to be for use at\nthe LILYCOVE CITY port.\pWhy not give it a try and see what\nit is about?$"
-gUnknown_08273656:: @ 8273656
+gText_UnusualWeatherEnded_Rain:: @ 8273656
.string "The massive downpour appears to\nhave stopped…$"
-gUnknown_08273684:: @ 8273684
+gText_UnusualWeatherEnded_Sun:: @ 8273684
.string "The intense sunshine appears to\nhave subsided…$"
EventScript_2736B3:: @ 82736B3
@@ -2750,7 +2752,7 @@ EventScript_2736F8:: @ 82736F8
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_252B42
compare VAR_RESULT, 2
goto_if_eq BattleFrontier_BattlePyramidTop_EventScript_252B42
- setvar VAR_0x8004, 10
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_10
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_1F_EventScript_2C83C9
@@ -2991,47 +2993,47 @@ EventScript_2738FF:: @ 82738FF
releaseall
end
-Route114_EventScript_273913:: @ 8273913
+UnusualWeather_EventScript_PlaceTilesRoute114North:: @ 8273913
setmetatile 7, 3, 839, 1
setmetatile 7, 4, 847, 0
return
-Route114_EventScript_273926:: @ 8273926
+UnusualWeather_EventScript_PlaceTilesRoute114South:: @ 8273926
setmetatile 6, 45, 601, 1
setmetatile 6, 46, 609, 0
return
-Route115_EventScript_273939:: @ 8273939
+UnusualWeather_EventScript_PlaceTilesRoute115West:: @ 8273939
setmetatile 21, 5, 601, 1
setmetatile 21, 6, 609, 0
return
-Route115_EventScript_27394C:: @ 827394C
+UnusualWeather_EventScript_PlaceTilesRoute115East:: @ 827394C
setmetatile 36, 9, 601, 1
setmetatile 36, 10, 609, 0
return
-Route116_EventScript_27395F:: @ 827395F
+UnusualWeather_EventScript_PlaceTilesRoute116North:: @ 827395F
setmetatile 59, 12, 159, 1
setmetatile 59, 13, 167, 0
return
-Route116_EventScript_273972:: @ 8273972
+UnusualWeather_EventScript_PlaceTilesRoute116South:: @ 8273972
setmetatile 79, 5, 159, 1
setmetatile 79, 6, 167, 0
return
-Route118_EventScript_273985:: @ 8273985
+UnusualWeather_EventScript_PlaceTilesRoute118East:: @ 8273985
setmetatile 42, 5, 159, 1
setmetatile 42, 6, 167, 0
return
-Route118_EventScript_273998:: @ 8273998
+UnusualWeather_EventScript_PlaceTilesRoute118West:: @ 8273998
setmetatile 9, 5, 159, 1
setmetatile 9, 6, 167, 0
return
-Route105_EventScript_2739AB:: @ 82739AB
+UnusualWeather_EventScript_PlaceTilesRoute105North:: @ 82739AB
setmetatile 10, 28, 334, 0
setmetatile 11, 28, 334, 0
setmetatile 9, 29, 334, 0
@@ -3046,7 +3048,7 @@ Route105_EventScript_2739AB:: @ 82739AB
setmetatile 11, 31, 334, 0
return
-Route105_EventScript_273A18:: @ 8273A18
+UnusualWeather_EventScript_PlaceTilesRoute105South:: @ 8273A18
setmetatile 20, 53, 334, 0
setmetatile 21, 53, 334, 0
setmetatile 19, 54, 334, 0
@@ -3061,7 +3063,7 @@ Route105_EventScript_273A18:: @ 8273A18
setmetatile 21, 56, 334, 0
return
-Route125_EventScript_273A85:: @ 8273A85
+UnusualWeather_EventScript_PlaceTilesRoute125West:: @ 8273A85
setmetatile 8, 16, 334, 0
setmetatile 9, 16, 334, 0
setmetatile 7, 17, 334, 0
@@ -3076,7 +3078,7 @@ Route125_EventScript_273A85:: @ 8273A85
setmetatile 9, 19, 334, 0
return
-Route125_EventScript_273AF2:: @ 8273AF2
+UnusualWeather_EventScript_PlaceTilesRoute125East:: @ 8273AF2
setmetatile 53, 18, 334, 0
setmetatile 54, 18, 334, 0
setmetatile 52, 19, 334, 0
@@ -3091,7 +3093,7 @@ Route125_EventScript_273AF2:: @ 8273AF2
setmetatile 54, 21, 334, 0
return
-Route127_EventScript_273B5F:: @ 8273B5F
+UnusualWeather_EventScript_PlaceTilesRoute127North:: @ 8273B5F
setmetatile 57, 9, 334, 0
setmetatile 58, 9, 334, 0
setmetatile 56, 10, 334, 0
@@ -3106,7 +3108,7 @@ Route127_EventScript_273B5F:: @ 8273B5F
setmetatile 58, 12, 334, 0
return
-Route127_EventScript_273BCC:: @ 8273BCC
+UnusualWeather_EventScript_PlaceTilesRoute127South:: @ 8273BCC
setmetatile 61, 30, 334, 0
setmetatile 62, 30, 334, 0
setmetatile 60, 31, 334, 0
@@ -3121,7 +3123,7 @@ Route127_EventScript_273BCC:: @ 8273BCC
setmetatile 62, 33, 334, 0
return
-Route129_EventScript_273C39:: @ 8273C39
+UnusualWeather_EventScript_PlaceTilesRoute129West:: @ 8273C39
setmetatile 16, 14, 334, 0
setmetatile 17, 14, 334, 0
setmetatile 15, 15, 334, 0
@@ -3136,7 +3138,7 @@ Route129_EventScript_273C39:: @ 8273C39
setmetatile 17, 17, 334, 0
return
-Route129_EventScript_273CA6:: @ 8273CA6
+UnusualWeather_EventScript_PlaceTilesRoute129East:: @ 8273CA6
setmetatile 42, 19, 334, 0
setmetatile 43, 19, 334, 0
setmetatile 41, 20, 334, 0
@@ -3162,114 +3164,106 @@ Route129_EventScript_273D13:: @ 8273D13
setflag FLAG_SPECIAL_FLAG_0x4000
return
-Route105_EventScript_273D17:: @ 8273D17
-Route125_EventScript_273D17:: @ 8273D17
-Route127_EventScript_273D17:: @ 8273D17
-Route129_EventScript_273D17:: @ 8273D17
+UnusualWeather_StartKyogreWeather:: @ 8273D17
setweather WEATHER_RAIN_HEAVY
return
-Route114_EventScript_273D1B:: @ 8273D1B
-Route115_EventScript_273D1B:: @ 8273D1B
-Route116_EventScript_273D1B:: @ 8273D1B
-Route118_EventScript_273D1B:: @ 8273D1B
+UnusualWeather_StartGroudonWeather:: @ 8273D1B
setweather WEATHER_DROUGHT
return
-gUnknown_08273D1F:: @ 8273D1F
-
-gUnknown_08273D1F:: @ 8273D1F
+UnusualWeather_EventScript_EndEventAndCleanup_1:: @ 8273D1F
lockall
- compare VAR_0x4037, 9
- goto_if_ge Route105_EventScript_273D51
- goto Route105_EventScript_273D5F
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START
+ goto_if_ge UnusualWeather_EventScript_ShowRainEndedMessage
+ goto UnusualWeather_EventScript_ShowSunEndedMessage
end
-Route105_EventScript_273D31:: @ 8273D31
+UnusualWeather_EventScript_EndEventAndCleanup_2:: @ 8273D31
closemessage
fadescreenswapbuffers 1
setweather WEATHER_SUNNY
doweather
- call Route105_EventScript_273D6D
+ call UnusualWeather_EventScript_CleanupMapTiles
special DrawWholeMapView
- setvar VAR_0x4037, 0
- setvar VAR_0x4039, 0
+ setvar VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE
+ setvar VAR_SHOULD_END_UNUSUAL_WEATHER, 0
clearflag FLAG_SPECIAL_FLAG_0x4000
fadescreenswapbuffers 0
releaseall
end
-Route105_EventScript_273D51:: @ 8273D51
- msgbox gUnknown_08273656, MSGBOX_DEFAULT
- goto Route105_EventScript_273D31
+UnusualWeather_EventScript_ShowRainEndedMessage:: @ 8273D51
+ msgbox gText_UnusualWeatherEnded_Rain, MSGBOX_DEFAULT
+ goto UnusualWeather_EventScript_EndEventAndCleanup_2
end
-Route105_EventScript_273D5F:: @ 8273D5F
- msgbox gUnknown_08273684, MSGBOX_DEFAULT
- goto Route105_EventScript_273D31
+UnusualWeather_EventScript_ShowSunEndedMessage:: @ 8273D5F
+ msgbox gText_UnusualWeatherEnded_Sun, MSGBOX_DEFAULT
+ goto UnusualWeather_EventScript_EndEventAndCleanup_2
end
-Route105_EventScript_273D6D:: @ 8273D6D
- switch VAR_0x4037
- case 1, Route105_EventScript_273E23
- case 2, Route105_EventScript_273E36
- case 3, Route105_EventScript_273E49
- case 4, Route105_EventScript_273E5C
- case 5, Route105_EventScript_273E6F
- case 6, Route105_EventScript_273E82
- case 7, Route105_EventScript_273E95
- case 8, Route105_EventScript_273EA8
- case 9, Route105_EventScript_273EBB
- case 10, Route105_EventScript_273F28
- case 11, Route105_EventScript_273F95
- case 12, Route105_EventScript_274002
- case 13, Route105_EventScript_27406F
- case 14, Route105_EventScript_2740DC
- case 15, Route105_EventScript_274149
- case 16, Route105_EventScript_2741B6
+UnusualWeather_EventScript_CleanupMapTiles:: @ 8273D6D
+ switch VAR_UNUSUAL_WEATHER_LOCATION
+ case UNUSUAL_WEATHER_ROUTE_114_NORTH, UnusualWeather_EventScript_CleanupRoute114North
+ case UNUSUAL_WEATHER_ROUTE_114_SOUTH, UnusualWeather_EventScript_CleanupRoute114South
+ case UNUSUAL_WEATHER_ROUTE_115_WEST, UnusualWeather_EventScript_CleanupRoute115West
+ case UNUSUAL_WEATHER_ROUTE_115_EAST, UnusualWeather_EventScript_CleanupRoute115East
+ case UNUSUAL_WEATHER_ROUTE_116_NORTH, UnusualWeather_EventScript_CleanupRoute116North
+ case UNUSUAL_WEATHER_ROUTE_116_SOUTH, UnusualWeather_EventScript_CleanupRoute116South
+ case UNUSUAL_WEATHER_ROUTE_118_EAST, UnusualWeather_EventScript_CleanupRoute118East
+ case UNUSUAL_WEATHER_ROUTE_118_WEST, UnusualWeather_EventScript_CleanupRoute118West
+ case UNUSUAL_WEATHER_ROUTE_105_NORTH, UnusualWeather_EventScript_CleanupRoute105North
+ case UNUSUAL_WEATHER_ROUTE_105_SOUTH, UnusualWeather_EventScript_CleanupRoute105South
+ case UNUSUAL_WEATHER_ROUTE_125_WEST, UnusualWeather_EventScript_CleanupRoute125West
+ case UNUSUAL_WEATHER_ROUTE_125_EAST, UnusualWeather_EventScript_CleanupRoute125East
+ case UNUSUAL_WEATHER_ROUTE_127_NORTH, UnusualWeather_EventScript_CleanupRoute127North
+ case UNUSUAL_WEATHER_ROUTE_127_SOUTH, UnusualWeather_EventScript_CleanupRoute127South
+ case UNUSUAL_WEATHER_ROUTE_129_WEST, UnusualWeather_EventScript_CleanupRoute129West
+ case UNUSUAL_WEATHER_ROUTE_129_EAST, UnusualWeather_EventScript_CleanupRoute129East
return
-Route105_EventScript_273E23:: @ 8273E23
+UnusualWeather_EventScript_CleanupRoute114North:: @ 8273E23
setmetatile 7, 3, 617, 1
setmetatile 7, 4, 617, 1
return
-Route105_EventScript_273E36:: @ 8273E36
+UnusualWeather_EventScript_CleanupRoute114South:: @ 8273E36
setmetatile 6, 45, 613, 1
setmetatile 6, 46, 613, 1
return
-Route105_EventScript_273E49:: @ 8273E49
+UnusualWeather_EventScript_CleanupRoute115West:: @ 8273E49
setmetatile 21, 5, 613, 1
setmetatile 21, 6, 613, 1
return
-Route105_EventScript_273E5C:: @ 8273E5C
+UnusualWeather_EventScript_CleanupRoute115East:: @ 8273E5C
setmetatile 36, 9, 613, 1
setmetatile 36, 10, 613, 1
return
-Route105_EventScript_273E6F:: @ 8273E6F
+UnusualWeather_EventScript_CleanupRoute116North:: @ 8273E6F
setmetatile 59, 12, 124, 1
setmetatile 59, 13, 124, 1
return
-Route105_EventScript_273E82:: @ 8273E82
+UnusualWeather_EventScript_CleanupRoute116South:: @ 8273E82
setmetatile 79, 5, 124, 1
setmetatile 79, 6, 124, 1
return
-Route105_EventScript_273E95:: @ 8273E95
+UnusualWeather_EventScript_CleanupRoute118East:: @ 8273E95
setmetatile 42, 5, 124, 1
setmetatile 42, 6, 121, 1
return
-Route105_EventScript_273EA8:: @ 8273EA8
+UnusualWeather_EventScript_CleanupRoute118West:: @ 8273EA8
setmetatile 9, 5, 124, 1
setmetatile 9, 6, 121, 1
return
-Route105_EventScript_273EBB:: @ 8273EBB
+UnusualWeather_EventScript_CleanupRoute105North:: @ 8273EBB
setmetatile 10, 28, 368, 0
setmetatile 11, 28, 368, 0
setmetatile 9, 29, 368, 0
@@ -3284,7 +3278,7 @@ Route105_EventScript_273EBB:: @ 8273EBB
setmetatile 11, 31, 368, 0
return
-Route105_EventScript_273F28:: @ 8273F28
+UnusualWeather_EventScript_CleanupRoute105South:: @ 8273F28
setmetatile 20, 53, 368, 0
setmetatile 21, 53, 368, 0
setmetatile 19, 54, 368, 0
@@ -3299,7 +3293,7 @@ Route105_EventScript_273F28:: @ 8273F28
setmetatile 21, 56, 368, 0
return
-Route105_EventScript_273F95:: @ 8273F95
+UnusualWeather_EventScript_CleanupRoute125West:: @ 8273F95
setmetatile 8, 16, 368, 0
setmetatile 9, 16, 368, 0
setmetatile 7, 17, 368, 0
@@ -3314,7 +3308,7 @@ Route105_EventScript_273F95:: @ 8273F95
setmetatile 9, 19, 368, 0
return
-Route105_EventScript_274002:: @ 8274002
+UnusualWeather_EventScript_CleanupRoute125East:: @ 8274002
setmetatile 53, 18, 368, 0
setmetatile 54, 18, 368, 0
setmetatile 52, 19, 368, 0
@@ -3329,7 +3323,7 @@ Route105_EventScript_274002:: @ 8274002
setmetatile 54, 21, 368, 0
return
-Route105_EventScript_27406F:: @ 827406F
+UnusualWeather_EventScript_CleanupRoute127North:: @ 827406F
setmetatile 57, 9, 368, 0
setmetatile 58, 9, 368, 0
setmetatile 56, 10, 368, 0
@@ -3344,7 +3338,7 @@ Route105_EventScript_27406F:: @ 827406F
setmetatile 58, 12, 368, 0
return
-Route105_EventScript_2740DC:: @ 82740DC
+UnusualWeather_EventScript_CleanupRoute127South:: @ 82740DC
setmetatile 61, 30, 368, 0
setmetatile 62, 30, 368, 0
setmetatile 60, 31, 368, 0
@@ -3359,7 +3353,7 @@ Route105_EventScript_2740DC:: @ 82740DC
setmetatile 62, 33, 368, 0
return
-Route105_EventScript_274149:: @ 8274149
+UnusualWeather_EventScript_CleanupRoute129West:: @ 8274149
setmetatile 16, 14, 368, 0
setmetatile 17, 14, 368, 0
setmetatile 15, 15, 368, 0
@@ -3374,7 +3368,7 @@ Route105_EventScript_274149:: @ 8274149
setmetatile 17, 17, 368, 0
return
-Route105_EventScript_2741B6:: @ 82741B6
+UnusualWeather_EventScript_CleanupRoute129East:: @ 82741B6
setmetatile 42, 19, 368, 0
setmetatile 43, 19, 368, 0
setmetatile 41, 20, 368, 0
@@ -3389,50 +3383,47 @@ Route105_EventScript_2741B6:: @ 82741B6
setmetatile 43, 22, 368, 0
return
-Underwater3_EventScript_274223:: @ 8274223
-Underwater5_EventScript_274223:: @ 8274223
-Underwater6_EventScript_274223:: @ 8274223
-Underwater7_EventScript_274223:: @ 8274223
- switch VAR_0x4037
- case 9, Underwater3_EventScript_274281
- case 10, Underwater3_EventScript_27428A
- case 11, Underwater3_EventScript_274293
- case 12, Underwater3_EventScript_27429C
- case 13, Underwater3_EventScript_2742A5
- case 14, Underwater3_EventScript_2742AE
- case 15, Underwater3_EventScript_2742B7
- case 16, Underwater3_EventScript_2742C0
+UnusualWeather_Underwater_SetupEscapeWarp:: @ 8274223
+ switch VAR_UNUSUAL_WEATHER_LOCATION
+ case UNUSUAL_WEATHER_ROUTE_105_NORTH, UnusualWeather_Underwater_SetupEscapeWarpRoute105North
+ case UNUSUAL_WEATHER_ROUTE_105_SOUTH, UnusualWeather_Underwater_SetupEscapeWarpRoute105South
+ case UNUSUAL_WEATHER_ROUTE_125_WEST, UnusualWeather_Underwater_SetupEscapeWarpRoute125West
+ case UNUSUAL_WEATHER_ROUTE_125_EAST, UnusualWeather_Underwater_SetupEscapeWarpRoute125East
+ case UNUSUAL_WEATHER_ROUTE_127_NORTH, UnusualWeather_Underwater_SetupEscapeWarpRoute127North
+ case UNUSUAL_WEATHER_ROUTE_127_SOUTH, UnusualWeather_Underwater_SetupEscapeWarpRoute127South
+ case UNUSUAL_WEATHER_ROUTE_129_WEST, UnusualWeather_Underwater_SetupEscapeWarpRoute129West
+ case UNUSUAL_WEATHER_ROUTE_129_EAST, UnusualWeather_Underwater_SetupEscapeWarpRoute129East
return
-Underwater3_EventScript_274281:: @ 8274281
+UnusualWeather_Underwater_SetupEscapeWarpRoute105North:: @ 8274281
setescapewarp MAP_ROUTE105, 255, 11, 29
return
-Underwater3_EventScript_27428A:: @ 827428A
+UnusualWeather_Underwater_SetupEscapeWarpRoute105South:: @ 827428A
setescapewarp MAP_ROUTE105, 255, 21, 54
return
-Underwater3_EventScript_274293:: @ 8274293
+UnusualWeather_Underwater_SetupEscapeWarpRoute125West:: @ 8274293
setescapewarp MAP_ROUTE125, 255, 9, 17
return
-Underwater3_EventScript_27429C:: @ 827429C
+UnusualWeather_Underwater_SetupEscapeWarpRoute125East:: @ 827429C
setescapewarp MAP_ROUTE125, 255, 54, 19
return
-Underwater3_EventScript_2742A5:: @ 82742A5
+UnusualWeather_Underwater_SetupEscapeWarpRoute127North:: @ 82742A5
setescapewarp MAP_ROUTE127, 255, 58, 10
return
-Underwater3_EventScript_2742AE:: @ 82742AE
+UnusualWeather_Underwater_SetupEscapeWarpRoute127South:: @ 82742AE
setescapewarp MAP_ROUTE127, 255, 62, 31
return
-Underwater3_EventScript_2742B7:: @ 82742B7
+UnusualWeather_Underwater_SetupEscapeWarpRoute129West:: @ 82742B7
setescapewarp MAP_ROUTE129, 255, 17, 15
return
-Underwater3_EventScript_2742C0:: @ 82742C0
+UnusualWeather_Underwater_SetupEscapeWarpRoute129East:: @ 82742C0
setescapewarp MAP_ROUTE129, 255, 43, 20
return
@@ -6928,16 +6919,16 @@ TrainerHill_3F_MapScript1_2C8336: @ 82C8336
TrainerHill_4F_MapScript1_2C8336: @ 82C8336
TrainerHill_Roof_MapScript1_2C8336: @ 82C8336
setvar VAR_TEMP_2, 0
- setvar VAR_0x8004, 4
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_RESUME_TIMER
special CallTrainerHillFunction
setvar VAR_0x8004, 1
setvar VAR_0x8005, 5
special CallFrontierUtilFunc
- compare VAR_RESULT, 2
+ compare VAR_RESULT, B_OUTCOME_LOST
goto_if_eq TrainerHill_1F_EventScript_2C83C9
- compare VAR_RESULT, 3
+ compare VAR_RESULT, B_OUTCOME_DREW
goto_if_eq TrainerHill_1F_EventScript_2C83C9
- compare VAR_RESULT, 9
+ compare VAR_RESULT, B_OUTCOME_FORFEITED
goto_if_eq TrainerHill_1F_EventScript_2C83C9
end
@@ -6961,7 +6952,7 @@ TrainerHill_Roof_MapScript2_2C8381: @ 82C8381
EventScript_TrainerHillTimer:: @ 82C8393
lockall
- setvar VAR_0x8004, 7
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_7
special CallTrainerHillFunction
msgbox TrainerHill_Entrance_Text_268D47, MSGBOX_DEFAULT
releaseall
@@ -6969,7 +6960,7 @@ EventScript_TrainerHillTimer:: @ 82C8393
TrainerHill_1F_EventScript_2C83A6:: @ 82C83A6
setvar VAR_TEMP_2, 1
- setvar VAR_0x8004, 9
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_9
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_1F_EventScript_2C83BF
@@ -6981,9 +6972,9 @@ TrainerHill_1F_EventScript_2C83BF:: @ 82C83BF
end
TrainerHill_1F_EventScript_2C83C9:: @ 82C83C9
- setvar VAR_0x8004, 12
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_12
special CallTrainerHillFunction
- setvar VAR_0x8004, 5
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_SET_LOST
special CallTrainerHillFunction
setvar VAR_TEMP_1, 1
end
@@ -7001,7 +6992,7 @@ TrainerHill_1F_Movement_2C83EE:: @ 82C83EE
EventScript_2C83F0:: @ 82C83F0
trainerbattle TRAINER_BATTLE_12, TRAINER_PHILLIP, 0, BattleFacility_TrainerBattle_PlaceholderText, BattleFacility_TrainerBattle_PlaceholderText
- setvar VAR_0x8004, 11
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_11
special CallTrainerHillFunction
waitmessage
waitbuttonpress
diff --git a/data/io_reg.s b/data/io_reg.s
index e6315cd89..9c5f64f58 100644
--- a/data/io_reg.s
+++ b/data/io_reg.s
@@ -24,11 +24,11 @@ gUnref_82EC784:: @ 82EC784
.4byte 0x02000100
.4byte 0x08000400
-gUnknown_82EC7C4:: @ 82EC7C4
- .2byte 0x0100
- .2byte 0x0200
- .2byte 0x0400
- .2byte 0x0800
+gOverworldBackgroundLayerFlags:: @ 82EC7C4
+ .2byte 0x0100 /* BLDCNT_TGT2_BG0 */
+ .2byte 0x0200 /* BLDCNT_TGT2_BG1 */
+ .2byte 0x0400 /* BLDCNT_TGT2_BG2 */
+ .2byte 0x0800 /* BLDCNT_TGT2_BG3 */
gUnknown_82EC7CC:: @ 82EC7CC
.2byte 0x0001
diff --git a/data/map_events.s b/data/map_events.s
index cd42bfe75..ceaa72837 100644
--- a/data/map_events.s
+++ b/data/map_events.s
@@ -8,6 +8,7 @@
#include "constants/secret_bases.h"
#include "constants/vars.h"
#include "constants/weather.h"
+#include "constants/trainer_hill.h"
.include "asm/macros.inc"
.include "constants/constants.inc"
diff --git a/data/maps.s b/data/maps.s
index 3334fd103..beb28ddec 100644
--- a/data/maps.s
+++ b/data/maps.s
@@ -4,7 +4,7 @@
#include "constants/weather.h"
#include "constants/region_map_sections.h"
#include "constants/songs.h"
-#include "constants/weather.h"
+#include "constants/trainer_hill.h"
.include "asm/macros.inc"
.include "constants/constants.inc"
diff --git a/data/maps/BattleFrontier_ReceptionGate/scripts.inc b/data/maps/BattleFrontier_ReceptionGate/scripts.inc
index 574415c4c..8ce438d75 100644
--- a/data/maps/BattleFrontier_ReceptionGate/scripts.inc
+++ b/data/maps/BattleFrontier_ReceptionGate/scripts.inc
@@ -8,12 +8,12 @@ BattleFrontier_ReceptionGate_MapScript1_2661E5: @ 82661E5
end
BattleFrontier_ReceptionGate_MapScript2_2661E9: @ 82661E9
- map_script_2 VAR_0x40D0, 0, BattleFrontier_ReceptionGate_EventScript_2661F3
+ map_script_2 VAR_HAS_ENTERED_BATTLE_FRONTIER, 0, BattleFrontier_ReceptionGate_EventScript_2661F3
.2byte 0
BattleFrontier_ReceptionGate_EventScript_2661F3:: @ 82661F3
lockall
- setvar VAR_0x40D0, 1
+ setvar VAR_HAS_ENTERED_BATTLE_FRONTIER, 1
playse SE_PIN
applymovement 1, Common_Movement_ExclamationMark
waitmovement 0
diff --git a/data/maps/BattleFrontier_ScottsHouse/scripts.inc b/data/maps/BattleFrontier_ScottsHouse/scripts.inc
index 9278252e6..52863d474 100644
--- a/data/maps/BattleFrontier_ScottsHouse/scripts.inc
+++ b/data/maps/BattleFrontier_ScottsHouse/scripts.inc
@@ -184,11 +184,11 @@ BattleFrontier_ScottsHouse_EventScript_263943:: @ 8263943
applymovement 1, Common_Movement_FacePlayer
waitmovement 0
msgbox BattleFrontier_ScottsHouse_Text_263BD4, MSGBOX_DEFAULT
- compare VAR_0x40D1, 13
+ compare VAR_SCOTT_STATE, 13
goto_if_eq BattleFrontier_ScottsHouse_EventScript_2639BC
- compare VAR_0x40D1, 9
+ compare VAR_SCOTT_STATE, 9
goto_if_ge BattleFrontier_ScottsHouse_EventScript_2639CB
- compare VAR_0x40D1, 6
+ compare VAR_SCOTT_STATE, 6
goto_if_ge BattleFrontier_ScottsHouse_EventScript_2639DA
goto BattleFrontier_ScottsHouse_EventScript_2639E9
end
diff --git a/data/maps/CaveOfOrigin_B1F/scripts.inc b/data/maps/CaveOfOrigin_B1F/scripts.inc
index c36b60111..0e554a945 100644
--- a/data/maps/CaveOfOrigin_B1F/scripts.inc
+++ b/data/maps/CaveOfOrigin_B1F/scripts.inc
@@ -52,7 +52,7 @@ CaveOfOrigin_B1F_EventScript_23584D:: @ 823584D
playse SE_KAIDAN
fadescreenspeed 1, 4
setflag FLAG_WALLACE_GOES_TO_SKY_PILLAR
- setvar VAR_0x405E, 3
+ setvar VAR_RAYQUAZA_STATE, 3
removeobject 1
clearflag FLAG_HIDE_SKY_PILLAR_WALLACE
fadescreen 0
diff --git a/data/maps/DewfordTown_Gym/scripts.inc b/data/maps/DewfordTown_Gym/scripts.inc
index 3b39fc5d0..eb8183585 100644
--- a/data/maps/DewfordTown_Gym/scripts.inc
+++ b/data/maps/DewfordTown_Gym/scripts.inc
@@ -187,7 +187,7 @@ DewfordTown_Gym_EventScript_1FC7F7:: @ 81FC7F7
closemessage
delay 30
setflag FLAG_ENABLE_BRAWLY_MATCH_CALL
- setvar VAR_0x40F4, 0
+ setvar VAR_ROXANNE_CALL_STEP_COUNTER, 0
setflag FLAG_ENABLE_ROXANNE_FIRST_CALL
release
end
diff --git a/data/maps/DoubleBattleColosseum/map.json b/data/maps/DoubleBattleColosseum/map.json
index 7480e36c1..172bb3fdc 100644
--- a/data/maps/DoubleBattleColosseum/map.json
+++ b/data/maps/DoubleBattleColosseum/map.json
@@ -52,7 +52,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_08277388"
+ "script": "EventScript_DoubleBattleColosseum_PlayerSpot0"
},
{
"type": "trigger",
@@ -61,7 +61,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_082773BE"
+ "script": "EventScript_DoubleBattleColosseum_PlayerSpot2"
},
{
"type": "trigger",
@@ -70,7 +70,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_082773A3"
+ "script": "EventScript_DoubleBattleColosseum_PlayerSpot1"
},
{
"type": "trigger",
@@ -79,7 +79,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_082773D9"
+ "script": "EventScript_DoubleBattleColosseum_PlayerSpot3"
}
],
"bg_events": []
diff --git a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc
index 827c08e54..12c6bbb77 100644
--- a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc
+++ b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc
@@ -40,7 +40,7 @@ EverGrandeCity_PokemonCenter_1F_EventScript_229A79:: @ 8229A79
call_if_eq EverGrandeCity_PokemonCenter_1F_EventScript_229AC1
compare VAR_FACING, 3
call_if_eq EverGrandeCity_PokemonCenter_1F_EventScript_229AC1
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_IN_EVERGRANDE
playse SE_KAIDAN
waitse
diff --git a/data/maps/FallarborTown_BattleTentLobby/scripts.inc b/data/maps/FallarborTown_BattleTentLobby/scripts.inc
index 6d7ea6be5..f6b7e1097 100644
--- a/data/maps/FallarborTown_BattleTentLobby/scripts.inc
+++ b/data/maps/FallarborTown_BattleTentLobby/scripts.inc
@@ -296,7 +296,7 @@ FallarborTown_BattleTentLobby_EventScript_200228:: @ 8200228
faceplayer
goto_if_set FLAG_MET_SCOTT_IN_FALLARBOR, FallarborTown_BattleTentLobby_EventScript_200245
msgbox FallarborTown_BattleTentLobby_Text_200501, MSGBOX_DEFAULT
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_IN_FALLARBOR
release
end
diff --git a/data/maps/FarawayIsland_Interior/scripts.inc b/data/maps/FarawayIsland_Interior/scripts.inc
index 7051d376c..bee33ae07 100644
--- a/data/maps/FarawayIsland_Interior/scripts.inc
+++ b/data/maps/FarawayIsland_Interior/scripts.inc
@@ -38,7 +38,7 @@ FarawayIsland_Interior_EventScript_267D5E:: @ 8267D5E
return
FarawayIsland_Interior_MapScript1_267D72: @ 8267D72
- setvar VAR_0x403A, 0
+ setvar VAR_NEVER_READ_0x403A, 0
setvar VAR_TEMP_1, 1
call_if_unset FLAG_CAUGHT_MEW, FarawayIsland_Interior_EventScript_267D86
end
diff --git a/data/maps/FortreeCity_Gym/scripts.inc b/data/maps/FortreeCity_Gym/scripts.inc
index 30cf8736a..8192e2039 100644
--- a/data/maps/FortreeCity_Gym/scripts.inc
+++ b/data/maps/FortreeCity_Gym/scripts.inc
@@ -43,7 +43,7 @@ FortreeCity_Gym_EventScript_2165FD:: @ 82165FD
closemessage
delay 30
setflag FLAG_ENABLE_WINONA_MATCH_CALL
- setvar VAR_0x40F3, 0
+ setvar VAR_WINONA_CALL_STEP_COUNTER, 0
setflag FLAG_REGISTER_WINONA_POKENAV
release
end
diff --git a/data/maps/JaggedPass/map.json b/data/maps/JaggedPass/map.json
index 1b9c5471d..3ec89fce6 100644
--- a/data/maps/JaggedPass/map.json
+++ b/data/maps/JaggedPass/map.json
@@ -184,7 +184,7 @@
"x": 21,
"y": 15,
"elevation": 3,
- "var": "VAR_0x40C8",
+ "var": "VAR_JAGGED_PASS_STATE",
"var_value": "1",
"script": "JaggedPass_EventScript_2306BB"
},
@@ -193,7 +193,7 @@
"x": 22,
"y": 20,
"elevation": 3,
- "var": "VAR_0x40C8",
+ "var": "VAR_JAGGED_PASS_STATE",
"var_value": "1",
"script": "JaggedPass_EventScript_2306BB"
},
@@ -202,7 +202,7 @@
"x": 21,
"y": 20,
"elevation": 3,
- "var": "VAR_0x40C8",
+ "var": "VAR_JAGGED_PASS_STATE",
"var_value": "1",
"script": "JaggedPass_EventScript_2306BB"
},
@@ -211,7 +211,7 @@
"x": 14,
"y": 15,
"elevation": 3,
- "var": "VAR_0x40C8",
+ "var": "VAR_JAGGED_PASS_STATE",
"var_value": "1",
"script": "JaggedPass_EventScript_2306BB"
},
@@ -220,7 +220,7 @@
"x": 13,
"y": 15,
"elevation": 3,
- "var": "VAR_0x40C8",
+ "var": "VAR_JAGGED_PASS_STATE",
"var_value": "1",
"script": "JaggedPass_EventScript_2306BB"
}
diff --git a/data/maps/JaggedPass/scripts.inc b/data/maps/JaggedPass/scripts.inc
index 3df62fc7d..c51a5ec26 100644
--- a/data/maps/JaggedPass/scripts.inc
+++ b/data/maps/JaggedPass/scripts.inc
@@ -6,7 +6,7 @@ JaggedPass_MapScripts:: @ 8230656
JaggedPass_MapScript1_230666: @ 8230666
setstepcallback 1
- compare VAR_0x40C8, 0
+ compare VAR_JAGGED_PASS_STATE, 0
call_if_eq JaggedPass_EventScript_230674
end
@@ -17,7 +17,7 @@ JaggedPass_EventScript_230674:: @ 8230674
return
JaggedPass_EventScript_230685:: @ 8230685
- setvar VAR_0x40C8, 1
+ setvar VAR_JAGGED_PASS_STATE, 1
return
JaggedPass_MapScript1_23068B: @ 823068B
@@ -31,7 +31,7 @@ JaggedPass_EventScript_230697:: @ 8230697
return
JaggedPass_MapScript1_23069C: @ 823069C
- compare VAR_0x40C8, 1
+ compare VAR_JAGGED_PASS_STATE, 1
goto_if_le JaggedPass_EventScript_2306A8
end
@@ -61,7 +61,7 @@ JaggedPass_EventScript_2306BB:: @ 82306BB
setmetatile 16, 18, 606, 0
special DrawWholeMapView
delay 30
- setvar VAR_0x40C8, 2
+ setvar VAR_JAGGED_PASS_STATE, 2
waitse
releaseall
end
diff --git a/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc b/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc
index 4a761a706..fd6aa34bd 100644
--- a/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc
+++ b/data/maps/LilycoveCity_CoveLilyMotel_2F/scripts.inc
@@ -57,7 +57,7 @@ LilycoveCity_CoveLilyMotel_2F_EventScript_21874D:: @ 821874D
faceplayer
goto_if_set FLAG_MET_SCOTT_IN_LILYCOVE, LilycoveCity_CoveLilyMotel_2F_EventScript_21876A
msgbox LilycoveCity_CoveLilyMotel_2F_Text_218ACF, MSGBOX_DEFAULT
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_IN_LILYCOVE
release
end
diff --git a/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc b/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc
index ec1d89b66..1e01fc168 100644
--- a/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc
+++ b/data/maps/LilycoveCity_DepartmentStore_1F/scripts.inc
@@ -9,7 +9,7 @@ LilycoveCity_DepartmentStore_1F_EventScript_21F69C:: @ 821F69C
lock
faceplayer
dotimebasedevents
- compare VAR_POKELOT_PRIZE, 0
+ compare VAR_POKELOT_PRIZE_ITEM, 0
goto_if_ne LilycoveCity_DepartmentStore_1F_EventScript_21F7F7
goto_if_set FLAG_DAILY_PICKED_LOTO_TICKET, LilycoveCity_DepartmentStore_1F_EventScript_21F78D
msgbox LilycoveCity_DepartmentStore_1F_Text_2A6390, MSGBOX_YESNO
@@ -100,8 +100,8 @@ LilycoveCity_DepartmentStore_1F_EventScript_21F7D4:: @ 821F7D4
return
LilycoveCity_DepartmentStore_1F_EventScript_21F7DD:: @ 821F7DD
- copyvar VAR_0x404D, VAR_0x8004
- copyvar VAR_POKELOT_PRIZE, VAR_0x8005
+ copyvar VAR_POKELOT_PRIZE_PLACE, VAR_0x8004
+ copyvar VAR_POKELOT_PRIZE_ITEM, VAR_0x8005
goto LilycoveCity_DepartmentStore_1F_EventScript_21F7ED
end
@@ -112,14 +112,14 @@ LilycoveCity_DepartmentStore_1F_EventScript_21F7ED:: @ 821F7ED
LilycoveCity_DepartmentStore_1F_EventScript_21F7F7:: @ 821F7F7
msgbox LilycoveCity_DepartmentStore_1F_Text_2A67E1, MSGBOX_DEFAULT
- giveitem_std VAR_POKELOT_PRIZE
+ giveitem_std VAR_POKELOT_PRIZE_ITEM
compare VAR_RESULT, 0
goto_if_eq LilycoveCity_DepartmentStore_1F_EventScript_21F7ED
- copyvar VAR_0x8004, VAR_0x404D
- copyvar VAR_0x8005, VAR_POKELOT_PRIZE
+ copyvar VAR_0x8004, VAR_POKELOT_PRIZE_PLACE
+ copyvar VAR_0x8005, VAR_POKELOT_PRIZE_ITEM
special sub_80EE2CC
- setvar VAR_POKELOT_PRIZE, 0
- setvar VAR_0x404D, 0
+ setvar VAR_POKELOT_PRIZE_ITEM, 0
+ setvar VAR_POKELOT_PRIZE_PLACE, 0
release
end
diff --git a/data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc b/data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc
index e62537422..7cab0f1fa 100644
--- a/data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc
+++ b/data/maps/LilycoveCity_DepartmentStore_5F/scripts.inc
@@ -3,9 +3,9 @@ LilycoveCity_DepartmentStore_5F_MapScripts:: @ 821FF7A
.byte 0
LilycoveCity_DepartmentStore_5F_MapScript2_21FF80: @ 821FF80
- map_script_2 VAR_0x405E, 1, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
- map_script_2 VAR_0x405E, 2, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
- map_script_2 VAR_0x405E, 3, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
+ map_script_2 VAR_RAYQUAZA_STATE, 1, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
+ map_script_2 VAR_RAYQUAZA_STATE, 2, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
+ map_script_2 VAR_RAYQUAZA_STATE, 3, LilycoveCity_DepartmentStore_5F_EventScript_21FF9A
.2byte 0
LilycoveCity_DepartmentStore_5F_EventScript_21FF9A:: @ 821FF9A
@@ -125,9 +125,9 @@ LilycoveCity_DepartmentStore_5F_EventScript_220075:: @ 8220075
lockall
applymovement 7, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 0
+ compare VAR_RAYQUAZA_STATE, 0
goto_if_eq LilycoveCity_DepartmentStore_5F_EventScript_22009C
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
goto_if_ge LilycoveCity_DepartmentStore_5F_EventScript_22009C
goto LilycoveCity_DepartmentStore_5F_EventScript_2200A7
end
diff --git a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
index 87e0e58cc..b553cf65b 100644
--- a/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
+++ b/data/maps/LittlerootTown_BrendansHouse_2F/scripts.inc
@@ -11,7 +11,7 @@ LittlerootTown_BrendansHouse_2F_MapScript1_1F83EE: @ 81F83EE
compare VAR_LITTLEROOT_INTRO_STATE, 4
call_if_eq LittlerootTown_BrendansHouse_2F_EventScript_2926FE
call LittlerootTown_BrendansHouse_2F_EventScript_275CE1
- setvar VAR_0x4089, 0
+ setvar VAR_SECRET_BASE_INITIALIZED, 0
end
LittlerootTown_BrendansHouse_2F_EventScript_1F841A:: @ 81F841A
@@ -44,7 +44,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_1F8464:: @ 81F8464
return
LittlerootTown_BrendansHouse_2F_MapScript2_1F846A: @ 81F846A
- map_script_2 VAR_0x4089, 0, LittlerootTown_BrendansHouse_2F_EventScript_1F8474
+ map_script_2 VAR_SECRET_BASE_INITIALIZED, 0, LittlerootTown_BrendansHouse_2F_EventScript_1F8474
.2byte 0
LittlerootTown_BrendansHouse_2F_EventScript_1F8474:: @ 81F8474
diff --git a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
index e11d2a991..49a9523e0 100644
--- a/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
+++ b/data/maps/LittlerootTown_MaysHouse_2F/scripts.inc
@@ -11,7 +11,7 @@ LittlerootTown_MaysHouse_2F_MapScript1_1F92A1: @ 81F92A1
compare VAR_LITTLEROOT_INTRO_STATE, 4
call_if_eq LittlerootTown_MaysHouse_2F_EventScript_2926FE
call LittlerootTown_MaysHouse_2F_EventScript_275CE1
- setvar VAR_0x4089, 0
+ setvar VAR_SECRET_BASE_INITIALIZED, 0
end
LittlerootTown_MaysHouse_2F_EventScript_1F92CD:: @ 81F92CD
@@ -45,7 +45,7 @@ LittlerootTown_MaysHouse_2F_EventScript_1F9317:: @ 81F9317
return
LittlerootTown_MaysHouse_2F_MapScript2_1F931D: @ 81F931D
- map_script_2 VAR_0x4089, 0, LittlerootTown_MaysHouse_2F_EventScript_1F9327
+ map_script_2 VAR_SECRET_BASE_INITIALIZED, 0, LittlerootTown_MaysHouse_2F_EventScript_1F9327
.2byte 0
LittlerootTown_MaysHouse_2F_EventScript_1F9327:: @ 81F9327
diff --git a/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc b/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc
index 88b1c6929..c02381982 100644
--- a/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc
+++ b/data/maps/LittlerootTown_ProfessorBirchsLab/scripts.inc
@@ -195,7 +195,7 @@ LittlerootTown_ProfessorBirchsLab_EventScript_1F9E80:: @ 81F9E80
setflag FLAG_HIDE_LITTLEROOT_TOWN_BIRCH
setflag FLAG_HIDE_LITTLEROOT_TOWN_RIVAL
setvar VAR_0x40D3, 2
- setvar VAR_0x40F5, 0
+ setvar VAR_SCOTT_CALL_STEP_COUNTER, 0
setflag FLAG_SCOTT_CALL_NATIONAL_DEX
releaseall
end
@@ -570,7 +570,7 @@ LittlerootTown_ProfessorBirchsLab_EventScript_1FA3AC:: @ 81FA3AC
setflag FLAG_SYS_POKEDEX_GET
special sub_81AFDA0
setflag FLAG_RECEIVED_POKEDEX_FROM_BIRCH
- setvar VAR_0x40CD, 1
+ setvar VAR_CABLE_CLUB_TUTORIAL_STATE, 1
return
LittlerootTown_ProfessorBirchsLab_EventScript_1FA3C4:: @ 81FA3C4
diff --git a/data/maps/MarineCave_End/scripts.inc b/data/maps/MarineCave_End/scripts.inc
index 036fa7724..028075648 100644
--- a/data/maps/MarineCave_End/scripts.inc
+++ b/data/maps/MarineCave_End/scripts.inc
@@ -47,13 +47,13 @@ MarineCave_End_EventScript_23B01B:: @ 823B01B
goto_if_eq MarineCave_End_EventScript_23B092
compare VAR_RESULT, 5
goto_if_eq MarineCave_End_EventScript_23B092
- setvar VAR_0x4039, 1
+ setvar VAR_SHOULD_END_UNUSUAL_WEATHER, 1
setflag FLAG_DEFEATED_KYOGRE
releaseall
end
MarineCave_End_EventScript_23B084:: @ 823B084
- setvar VAR_0x4039, 1
+ setvar VAR_SHOULD_END_UNUSUAL_WEATHER, 1
setflag FLAG_DEFEATED_KYOGRE
goto MarineCave_End_EventScript_27376D
end
diff --git a/data/maps/MauvilleCity/scripts.inc b/data/maps/MauvilleCity/scripts.inc
index 120fc9f51..61839d108 100644
--- a/data/maps/MauvilleCity/scripts.inc
+++ b/data/maps/MauvilleCity/scripts.inc
@@ -158,7 +158,7 @@ MauvilleCity_EventScript_1DF593:: @ 81DF593
clearflag FLAG_HIDE_VERDANTURF_TOWN_WANDAS_HOUSE_WALLY
clearflag FLAG_HIDE_VERDANTURF_TOWN_WANDAS_HOUSE_WALLYS_UNCLE
setflag FLAG_DEFEATED_WALLY_MAUVILLE
- setvar VAR_0x40F2, 0
+ setvar VAR_WALLY_CALL_STEP_COUNTER, 0
setflag FLAG_ENABLE_FIRST_WALLY_POKENAV_CALL
compare VAR_FACING, 2
call_if_eq MauvilleCity_EventScript_1DF5F3
@@ -168,7 +168,7 @@ MauvilleCity_EventScript_1DF593:: @ 81DF593
waitmovement 0
msgbox MauvilleCity_Text_1DFED5, MSGBOX_DEFAULT
closemessage
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
compare VAR_FACING, 2
call_if_eq MauvilleCity_EventScript_1DF616
compare VAR_FACING, 4
diff --git a/data/maps/MauvilleCity_Gym/scripts.inc b/data/maps/MauvilleCity_Gym/scripts.inc
index de4bd0ddf..e23d48332 100644
--- a/data/maps/MauvilleCity_Gym/scripts.inc
+++ b/data/maps/MauvilleCity_Gym/scripts.inc
@@ -90,7 +90,7 @@ MauvilleCity_Gym_EventScript_20DF2B:: @ 820DF2B
waitmessage
call Common_EventScript_PlayGymBadgeFanfare
msgbox MauvilleCity_Gym_Text_20E7AA, MSGBOX_DEFAULT
- setvar VAR_0x40D2, 3
+ setvar VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 3
clearflag FLAG_HIDE_VERDANTURF_TOWN_SCOTT
setflag FLAG_DEFEATED_MAUVILLE_GYM
setflag FLAG_BADGE03_GET
diff --git a/data/maps/MirageTower_4F/scripts.inc b/data/maps/MirageTower_4F/scripts.inc
index 312852586..3d8dd80d0 100644
--- a/data/maps/MirageTower_4F/scripts.inc
+++ b/data/maps/MirageTower_4F/scripts.inc
@@ -52,7 +52,7 @@ MirageTower_4F_EventScript_23ADCA:: @ 823ADCA
waitstate
special DoMirageTowerCeilingCrumble
waitstate
- setvar VAR_0x40CB, 1
+ setvar VAR_ROUTE_111_STATE, 1
clearflag FLAG_LANDMARK_MIRAGE_TOWER
warp MAP_ROUTE111, 255, 19, 59
waitstate
diff --git a/data/maps/MossdeepCity/map.json b/data/maps/MossdeepCity/map.json
index 952ff253c..99d7ae01c 100644
--- a/data/maps/MossdeepCity/map.json
+++ b/data/maps/MossdeepCity/map.json
@@ -366,7 +366,7 @@
"x": 42,
"y": 21,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
},
@@ -375,7 +375,7 @@
"x": 41,
"y": 22,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
},
@@ -384,7 +384,7 @@
"x": 41,
"y": 23,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
},
@@ -393,7 +393,7 @@
"x": 41,
"y": 24,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
},
@@ -402,7 +402,7 @@
"x": 40,
"y": 25,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
},
@@ -411,7 +411,7 @@
"x": 40,
"y": 26,
"elevation": 5,
- "var": "VAR_0x405D",
+ "var": "VAR_MOSSDEEP_STATE",
"var_value": "1",
"script": "MossdeepCity_EventScript_1E4B41"
}
diff --git a/data/maps/MossdeepCity/scripts.inc b/data/maps/MossdeepCity/scripts.inc
index b01e9cae8..493cded0a 100644
--- a/data/maps/MossdeepCity/scripts.inc
+++ b/data/maps/MossdeepCity/scripts.inc
@@ -94,7 +94,7 @@ MossdeepCity_EventScript_1E4B41:: @ 81E4B41
removeobject 12
removeobject 13
delay 30
- setvar VAR_0x405D, 2
+ setvar VAR_MOSSDEEP_STATE, 2
setflag FLAG_HIDE_MOSSDEEP_CITY_TEAM_MAGMA
releaseall
end
@@ -259,7 +259,7 @@ MossdeepCity_EventScript_1E4C85:: @ 81E4C85
call_if_eq MossdeepCity_EventScript_1E4CB0
compare VAR_FACING, 4
call_if_eq MossdeepCity_EventScript_1E4CC2
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
removeobject 16
release
end
diff --git a/data/maps/MossdeepCity_Gym/scripts.inc b/data/maps/MossdeepCity_Gym/scripts.inc
index 7638f6119..7fc98dc54 100644
--- a/data/maps/MossdeepCity_Gym/scripts.inc
+++ b/data/maps/MossdeepCity_Gym/scripts.inc
@@ -71,9 +71,9 @@ MossdeepCity_Gym_EventScript_2208D1:: @ 82208D1
clearflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_1F_TEAM_MAGMA
clearflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_2F_TEAM_MAGMA
clearflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_2F_STEVEN
- setvar VAR_0x405D, 1
+ setvar VAR_MOSSDEEP_STATE, 1
setflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_1F_STEVEN
- setvar VAR_0x409F, 1
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_2, 1
call MossdeepCity_Gym_EventScript_22095B
closemessage
delay 30
diff --git a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc
index 43bd56d3a..13bf111ba 100644
--- a/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc
+++ b/data/maps/MossdeepCity_SpaceCenter_1F/scripts.inc
@@ -4,7 +4,7 @@ MossdeepCity_SpaceCenter_1F_MapScripts:: @ 8222F41
.byte 0
MossdeepCity_SpaceCenter_1F_MapScript1_222F4C: @ 8222F4C
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_222F58
end
@@ -18,11 +18,11 @@ MossdeepCity_SpaceCenter_1F_EventScript_222F58:: @ 8222F58
setobjectxyperm 1, 3, 4
setobjectmovementtype 1, MOVEMENT_TYPE_FACE_RIGHT
setobjectmovementtype 2, MOVEMENT_TYPE_FACE_RIGHT
- compare VAR_0x409E, 1
+ compare VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 1
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_222FAA
- compare VAR_0x409E, 2
+ compare VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_222FB2
- compare VAR_0x409E, 3
+ compare VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 3
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_222FBA
end
@@ -39,7 +39,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_222FBA:: @ 8222FBA
end
MossdeepCity_SpaceCenter_1F_MapScript1_222FC2: @ 8222FC2
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_le MossdeepCity_SpaceCenter_1F_EventScript_222FCE
end
@@ -50,7 +50,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_222FCE:: @ 8222FCE
MossdeepCity_SpaceCenter_1F_EventScript_222FD8:: @ 8222FD8
lock
faceplayer
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_223024
dotimebasedevents
specialvar VAR_RESULT, GetWeekCount
@@ -98,7 +98,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_22305A:: @ 822305A
MossdeepCity_SpaceCenter_1F_EventScript_223063:: @ 8223063
lock
faceplayer
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_22307A
msgbox MossdeepCity_SpaceCenter_1F_Text_2233D3, MSGBOX_DEFAULT
release
@@ -114,7 +114,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_22307A:: @ 822307A
MossdeepCity_SpaceCenter_1F_EventScript_22308E:: @ 822308E
lock
faceplayer
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_2230DA
goto_if_set FLAG_RECEIVED_SUN_STONE_MOSSDEEP, MossdeepCity_SpaceCenter_1F_EventScript_2230D0
msgbox MossdeepCity_SpaceCenter_1F_Text_223540, MSGBOX_DEFAULT
@@ -155,9 +155,9 @@ MossdeepCity_SpaceCenter_1F_EventScript_22312D:: @ 822312D
lock
faceplayer
goto_if_set FLAG_SYS_GAME_CLEAR, MossdeepCity_SpaceCenter_1F_EventScript_223154
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_22315E
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_lt MossdeepCity_SpaceCenter_1F_EventScript_223154
goto MossdeepCity_SpaceCenter_1F_EventScript_22315E
end
@@ -176,9 +176,9 @@ MossdeepCity_SpaceCenter_1F_EventScript_223168:: @ 8223168
lock
faceplayer
goto_if_set FLAG_SYS_GAME_CLEAR, MossdeepCity_SpaceCenter_1F_EventScript_22318F
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_1F_EventScript_2231A4
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_lt MossdeepCity_SpaceCenter_1F_EventScript_22318F
goto MossdeepCity_SpaceCenter_1F_EventScript_2231A4
end
@@ -242,7 +242,7 @@ MossdeepCity_SpaceCenter_1F_EventScript_22321F:: @ 822321F
case 3, MossdeepCity_SpaceCenter_1F_EventScript_223289
applymovement 9, MossdeepCity_SpaceCenter_1F_Movement_2232A2
waitmovement 0
- setvar VAR_0x409E, 2
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 2
release
end
@@ -254,14 +254,14 @@ MossdeepCity_SpaceCenter_1F_EventScript_22326E:: @ 822326E
MossdeepCity_SpaceCenter_1F_EventScript_223278:: @ 8223278
applymovement 9, MossdeepCity_SpaceCenter_1F_Movement_22329A
waitmovement 0
- setvar VAR_0x409E, 1
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 1
release
end
MossdeepCity_SpaceCenter_1F_EventScript_223289:: @ 8223289
applymovement 9, MossdeepCity_SpaceCenter_1F_Movement_22329E
waitmovement 0
- setvar VAR_0x409E, 3
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_1, 3
release
end
diff --git a/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc b/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc
index d9727235f..41f8af97c 100644
--- a/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc
+++ b/data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc
@@ -4,9 +4,9 @@ MossdeepCity_SpaceCenter_2F_MapScripts:: @ 8223D58
.byte 0
MossdeepCity_SpaceCenter_2F_MapScript1_223D63: @ 8223D63
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
call_if_eq MossdeepCity_SpaceCenter_2F_EventScript_223D7A
- compare VAR_0x409F, 2
+ compare VAR_MOSSDEEP_SPACE_CENTER_STATE_2, 2
call_if_eq MossdeepCity_SpaceCenter_2F_EventScript_223D9F
end
@@ -27,7 +27,7 @@ MossdeepCity_SpaceCenter_2F_EventScript_223D9F:: @ 8223D9F
return
MossdeepCity_SpaceCenter_2F_MapScript2_223DB5: @ 8223DB5
- map_script_2 VAR_0x409F, 1, MossdeepCity_SpaceCenter_2F_EventScript_223DBF
+ map_script_2 VAR_MOSSDEEP_SPACE_CENTER_STATE_2, 1, MossdeepCity_SpaceCenter_2F_EventScript_223DBF
.2byte 0
MossdeepCity_SpaceCenter_2F_EventScript_223DBF:: @ 8223DBF
@@ -69,7 +69,7 @@ MossdeepCity_SpaceCenter_2F_EventScript_223E09:: @ 8223E09
trainerbattle_no_intro TRAINER_GRUNT_36, MossdeepCity_SpaceCenter_2F_Text_2244F1
applymovement 7, MossdeepCity_SpaceCenter_2F_Movement_223E89
waitmovement 0
- setvar VAR_0x409F, 2
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_2, 2
moveobjectoffscreen 5
moveobjectoffscreen 7
moveobjectoffscreen 6
@@ -98,9 +98,9 @@ MossdeepCity_SpaceCenter_2F_EventScript_223E8D:: @ 8223E8D
lock
faceplayer
goto_if_set FLAG_SYS_GAME_CLEAR, MossdeepCity_SpaceCenter_2F_EventScript_223EB4
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_2F_EventScript_223EBE
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_lt MossdeepCity_SpaceCenter_2F_EventScript_223EB4
goto MossdeepCity_SpaceCenter_2F_EventScript_223EBE
end
@@ -119,9 +119,9 @@ MossdeepCity_SpaceCenter_2F_EventScript_223EC8:: @ 8223EC8
lock
faceplayer
goto_if_set FLAG_SYS_GAME_CLEAR, MossdeepCity_SpaceCenter_2F_EventScript_223EEF
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_2F_EventScript_223EF9
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_lt MossdeepCity_SpaceCenter_2F_EventScript_223EEF
goto MossdeepCity_SpaceCenter_2F_EventScript_223EF9
end
@@ -140,9 +140,9 @@ MossdeepCity_SpaceCenter_2F_EventScript_223F03:: @ 8223F03
lock
faceplayer
goto_if_set FLAG_SYS_GAME_CLEAR, MossdeepCity_SpaceCenter_2F_EventScript_223F2A
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_eq MossdeepCity_SpaceCenter_2F_EventScript_223F34
- compare VAR_0x405D, 2
+ compare VAR_MOSSDEEP_STATE, 2
goto_if_lt MossdeepCity_SpaceCenter_2F_EventScript_223F2A
goto MossdeepCity_SpaceCenter_2F_EventScript_223F34
end
@@ -248,7 +248,7 @@ MossdeepCity_SpaceCenter_2F_EventScript_22400C:: @ 822400C
waitmovement 0
special SavePlayerParty
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
goto_if_ne MossdeepCity_SpaceCenter_2F_EventScript_224032
@@ -287,10 +287,10 @@ MossdeepCity_SpaceCenter_2F_EventScript_224071:: @ 8224071
delay 20
msgbox MossdeepCity_SpaceCenter_2F_Text_2249DC, MSGBOX_DEFAULT
closemessage
- setvar VAR_0x405D, 3
+ setvar VAR_MOSSDEEP_STATE, 3
fadedefaultbgm
fadescreen 1
- setvar VAR_0x409F, 3
+ setvar VAR_MOSSDEEP_SPACE_CENTER_STATE_2, 3
setflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_1F_TEAM_MAGMA
setflag FLAG_HIDE_MOSSDEEP_CITY_SPACE_CENTER_2F_TEAM_MAGMA
setflag FLAG_HIDE_MOSSDEEP_CITY_TEAM_MAGMA
diff --git a/data/maps/PetalburgCity/map.json b/data/maps/PetalburgCity/map.json
index 3d09ae706..6a9a6b33d 100644
--- a/data/maps/PetalburgCity/map.json
+++ b/data/maps/PetalburgCity/map.json
@@ -229,7 +229,7 @@
"x": 4,
"y": 10,
"elevation": 3,
- "var": "VAR_0x40C9",
+ "var": "VAR_SCOTT_PETALBURG_ENCOUNTER",
"var_value": "0",
"script": "PetalburgCity_EventScript_1DC691"
},
@@ -238,7 +238,7 @@
"x": 4,
"y": 11,
"elevation": 3,
- "var": "VAR_0x40C9",
+ "var": "VAR_SCOTT_PETALBURG_ENCOUNTER",
"var_value": "0",
"script": "PetalburgCity_EventScript_1DC6A7"
},
@@ -247,7 +247,7 @@
"x": 4,
"y": 12,
"elevation": 3,
- "var": "VAR_0x40C9",
+ "var": "VAR_SCOTT_PETALBURG_ENCOUNTER",
"var_value": "0",
"script": "PetalburgCity_EventScript_1DC6BD"
},
@@ -256,7 +256,7 @@
"x": 4,
"y": 13,
"elevation": 3,
- "var": "VAR_0x40C9",
+ "var": "VAR_SCOTT_PETALBURG_ENCOUNTER",
"var_value": "0",
"script": "PetalburgCity_EventScript_1DC6D3"
}
diff --git a/data/maps/PetalburgCity/scripts.inc b/data/maps/PetalburgCity/scripts.inc
index e2f5d2a86..5a652ab15 100644
--- a/data/maps/PetalburgCity/scripts.inc
+++ b/data/maps/PetalburgCity/scripts.inc
@@ -551,7 +551,7 @@ PetalburgCity_EventScript_1DC6E9:: @ 81DC6E9
waitmovement 0
applymovement EVENT_OBJ_ID_PLAYER, Common_Movement_WalkInPlaceRight
waitmovement 0
- setvar VAR_0x40D1, 1
+ setvar VAR_SCOTT_STATE, 1
msgbox PetalburgCity_Text_1DCB31, MSGBOX_DEFAULT
closemessage
applymovement 9, Common_Movement_WalkInPlaceRight
@@ -572,7 +572,7 @@ PetalburgCity_EventScript_1DC6E9:: @ 81DC6E9
call_if_eq PetalburgCity_EventScript_1DC7B2
compare VAR_0x8008, 3
call_if_eq PetalburgCity_EventScript_1DC7C4
- setvar VAR_0x40C9, 1
+ setvar VAR_SCOTT_PETALBURG_ENCOUNTER, 1
removeobject 9
releaseall
end
diff --git a/data/maps/PetalburgCity_Gym/scripts.inc b/data/maps/PetalburgCity_Gym/scripts.inc
index 1f0fdd91c..a256a6547 100644
--- a/data/maps/PetalburgCity_Gym/scripts.inc
+++ b/data/maps/PetalburgCity_Gym/scripts.inc
@@ -60,7 +60,7 @@ PetalburgCity_Gym_EventScript_204955:: @ 8204955
return
PetalburgCity_Gym_EventScript_20495D:: @ 820495D
- setorcopyvar VAR_0x8015, 269
+ setorcopyvar VAR_TRAINER_BATTLE_OPPONENT_A, 269
specialvar VAR_RESULT, IsTrainerReadyForRematch
compare VAR_RESULT, 1
goto_if_eq PetalburgCity_Gym_EventScript_204985
diff --git a/data/maps/RecordCorner/map.json b/data/maps/RecordCorner/map.json
index 4777472d2..d34ad4903 100644
--- a/data/maps/RecordCorner/map.json
+++ b/data/maps/RecordCorner/map.json
@@ -66,7 +66,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_0827741D"
+ "script": "EventScript_RecordCenter_Spot0"
},
{
"type": "trigger",
@@ -75,7 +75,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_08277447"
+ "script": "EventScript_RecordCenter_Spot2"
},
{
"type": "trigger",
@@ -84,7 +84,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_08277432"
+ "script": "EventScript_RecordCenter_Spot1"
},
{
"type": "trigger",
@@ -93,7 +93,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_0827745C"
+ "script": "EventScript_RecordCenter_Spot3"
}
],
"bg_events": []
diff --git a/data/maps/Route105/scripts.inc b/data/maps/Route105/scripts.inc
index 6ad11bc52..2b8ebe305 100644
--- a/data/maps/Route105/scripts.inc
+++ b/data/maps/Route105/scripts.inc
@@ -6,10 +6,10 @@ Route105_MapScripts:: @ 81EE1DB
Route105_MapScript1_1EE1EB: @ 81EE1EB
call_if_unset FLAG_REGI_DOORS_OPENED, Route105_EventScript_1EE20B
- compare VAR_0x4037, 9
- call_if_eq Route105_EventScript_2739AB
- compare VAR_0x4037, 10
- call_if_eq Route105_EventScript_273A18
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_NORTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute105North
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_SOUTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute105South
end
Route105_EventScript_1EE20B:: @ 81EE20B
@@ -18,16 +18,16 @@ Route105_EventScript_1EE20B:: @ 81EE20B
return
Route105_MapScript1_1EE21E: @ 81EE21E
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route105_EventScript_273D13
- compare VAR_0x4037, 9
- call_if_eq Route105_EventScript_273D17
- compare VAR_0x4037, 10
- call_if_eq Route105_EventScript_273D17
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_NORTH
+ call_if_eq UnusualWeather_StartKyogreWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_105_SOUTH
+ call_if_eq UnusualWeather_StartKyogreWeather
end
Route105_MapScript2_1EE240: @ 81EE240
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route105_EventScript_1EE24A:: @ 81EE24A
diff --git a/data/maps/Route111/scripts.inc b/data/maps/Route111/scripts.inc
index 754369014..3755ee5e4 100644
--- a/data/maps/Route111/scripts.inc
+++ b/data/maps/Route111/scripts.inc
@@ -7,7 +7,7 @@ Route111_MapScripts:: @ 81F0CA7
Route111_MapScript1_1F0CBC: @ 81F0CBC
call_if_unset FLAG_REGI_DOORS_OPENED, Route111_EventScript_1F0CD1
- compare VAR_0x40CB, 1
+ compare VAR_ROUTE_111_STATE, 1
call_if_eq Route111_EventScript_1F0CE4
end
@@ -38,12 +38,12 @@ Route111_EventScript_1F0CE4:: @ 81F0CE4
return
Route111_MapScript1_1F0D87: @ 81F0D87
- setvar VAR_0x40D6, 0
+ setvar VAR_TRAINER_HILL_IS_ACTIVE, 0
special SetMirageTowerVisibility
call_if_unset FLAG_MIRAGE_TOWER_VISIBLE, Route111_EventScript_1F0E3C
- compare VAR_0x40CB, 1
+ compare VAR_ROUTE_111_STATE, 1
call_if_eq Route111_EventScript_1F0DC2
- compare VAR_0x40CB, 2
+ compare VAR_ROUTE_111_STATE, 2
call_if_eq Route111_EventScript_1F0E40
call Route111_EventScript_1F0DE6
call Route111_EventScript_28CCC7
@@ -101,11 +101,11 @@ Route111_EventScript_1F0E3C:: @ 81F0E3C
return
Route111_EventScript_1F0E40:: @ 81F0E40
- setvar VAR_0x40CB, 3
+ setvar VAR_ROUTE_111_STATE, 3
return
Route111_MapScript2_1F0E46: @ 81F0E46
- map_script_2 VAR_0x40CB, 1, Route111_EventScript_1F0E50
+ map_script_2 VAR_ROUTE_111_STATE, 1, Route111_EventScript_1F0E50
.2byte 0
Route111_EventScript_1F0E50:: @ 81F0E50
@@ -113,7 +113,7 @@ Route111_EventScript_1F0E50:: @ 81F0E50
end
Route111_MapScript2_1F0E56: @ 81F0E56
- map_script_2 VAR_0x40CB, 1, Route111_EventScript_1F0E60
+ map_script_2 VAR_ROUTE_111_STATE, 1, Route111_EventScript_1F0E60
.2byte 0
Route111_EventScript_1F0E60:: @ 81F0E60
@@ -134,7 +134,7 @@ Route111_EventScript_1F0E60:: @ 81F0E60
waitstate
special StartMirageTowerFossilFallAndSink
waitstate
- setvar VAR_0x40CB, 2
+ setvar VAR_ROUTE_111_STATE, 2
clearflag FLAG_HIDE_DESERT_UNDERPASS_FOSSIL
goto_if_set FLAG_CHOSE_ROOT_FOSSIL, Route111_EventScript_1F0EA7
msgbox Route111_Text_1F1C74, MSGBOX_DEFAULT
@@ -411,9 +411,9 @@ Route111_EventScript_1F1192:: @ 81F1192
Route111_EventScript_1F119B:: @ 81F119B
lock
faceplayer
- compare VAR_0x40CB, 3
+ compare VAR_ROUTE_111_STATE, 3
goto_if_eq Route111_EventScript_1F11C6
- compare VAR_0x40CB, 2
+ compare VAR_ROUTE_111_STATE, 2
goto_if_eq Route111_EventScript_1F11D0
goto_if_set FLAG_MIRAGE_TOWER_VISIBLE, Route111_EventScript_1F11DA
msgbox Route111_Text_1F1A22, MSGBOX_DEFAULT
diff --git a/data/maps/Route114/scripts.inc b/data/maps/Route114/scripts.inc
index d4327a2f4..b03a2f228 100644
--- a/data/maps/Route114/scripts.inc
+++ b/data/maps/Route114/scripts.inc
@@ -5,23 +5,23 @@ Route114_MapScripts:: @ 81F252F
.byte 0
Route114_MapScript1_1F253F: @ 81F253F
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route114_EventScript_273D13
- compare VAR_0x4037, 1
- call_if_eq Route114_EventScript_273D1B
- compare VAR_0x4037, 2
- call_if_eq Route114_EventScript_273D1B
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_NORTH
+ call_if_eq UnusualWeather_StartGroudonWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_SOUTH
+ call_if_eq UnusualWeather_StartGroudonWeather
end
Route114_MapScript1_1F2561: @ 81F2561
- compare VAR_0x4037, 1
- call_if_eq Route114_EventScript_273913
- compare VAR_0x4037, 2
- call_if_eq Route114_EventScript_273926
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_NORTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute114North
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_114_SOUTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute114South
end
Route114_MapScript2_1F2578: @ 81F2578
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route114_EventScript_1F2582:: @ 81F2582
diff --git a/data/maps/Route114_FossilManiacsTunnel/map.json b/data/maps/Route114_FossilManiacsTunnel/map.json
index 0582198db..d0992f8fa 100644
--- a/data/maps/Route114_FossilManiacsTunnel/map.json
+++ b/data/maps/Route114_FossilManiacsTunnel/map.json
@@ -57,7 +57,7 @@
"x": 5,
"y": 4,
"elevation": 3,
- "var": "VAR_0x40CC",
+ "var": "VAR_FOSSIL_MANIAC_STATE",
"var_value": "1",
"script": "Route114_FossilManiacsTunnel_EventScript_22AF66"
},
@@ -66,7 +66,7 @@
"x": 6,
"y": 4,
"elevation": 3,
- "var": "VAR_0x40CC",
+ "var": "VAR_FOSSIL_MANIAC_STATE",
"var_value": "1",
"script": "Route114_FossilManiacsTunnel_EventScript_22AF66"
}
diff --git a/data/maps/Route114_FossilManiacsTunnel/scripts.inc b/data/maps/Route114_FossilManiacsTunnel/scripts.inc
index 1a84082ab..8ab83a441 100644
--- a/data/maps/Route114_FossilManiacsTunnel/scripts.inc
+++ b/data/maps/Route114_FossilManiacsTunnel/scripts.inc
@@ -27,7 +27,7 @@ Route114_FossilManiacsTunnel_EventScript_22AF66:: @ 822AF66
applymovement EVENT_OBJ_ID_PLAYER, Common_Movement_WalkInPlaceDown
waitmovement 0
msgbox Route114_FossilManiacsTunnel_Text_22B1F7, MSGBOX_DEFAULT
- setvar VAR_0x40CC, 2
+ setvar VAR_FOSSIL_MANIAC_STATE, 2
releaseall
end
diff --git a/data/maps/Route115/scripts.inc b/data/maps/Route115/scripts.inc
index 9cb3ea2e0..259cd5904 100644
--- a/data/maps/Route115/scripts.inc
+++ b/data/maps/Route115/scripts.inc
@@ -5,23 +5,23 @@ Route115_MapScripts:: @ 81F2920
.byte 0
Route115_MapScript1_1F2930: @ 81F2930
- compare VAR_0x4037, 3
- call_if_eq Route115_EventScript_273939
- compare VAR_0x4037, 4
- call_if_eq Route115_EventScript_27394C
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_WEST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute115West
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_EAST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute115East
end
Route115_MapScript1_1F2947: @ 81F2947
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route115_EventScript_273D13
- compare VAR_0x4037, 3
- call_if_eq Route115_EventScript_273D1B
- compare VAR_0x4037, 4
- call_if_eq Route115_EventScript_273D1B
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_WEST
+ call_if_eq UnusualWeather_StartGroudonWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_115_EAST
+ call_if_eq UnusualWeather_StartGroudonWeather
end
Route115_MapScript2_1F2969: @ 81F2969
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route115_EventScript_1F2973:: @ 81F2973
diff --git a/data/maps/Route116/scripts.inc b/data/maps/Route116/scripts.inc
index 90ae29f5b..454201307 100644
--- a/data/maps/Route116/scripts.inc
+++ b/data/maps/Route116/scripts.inc
@@ -6,12 +6,12 @@ Route116_MapScripts:: @ 81F2C0C
Route116_MapScript1_1F2C1C: @ 81F2C1C
call_if_set FLAG_RECOVERED_DEVON_GOODS, Route116_EventScript_1F2C47
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route116_EventScript_273D13
- compare VAR_0x4037, 5
- call_if_eq Route116_EventScript_273D1B
- compare VAR_0x4037, 6
- call_if_eq Route116_EventScript_273D1B
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_NORTH
+ call_if_eq UnusualWeather_StartGroudonWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_SOUTH
+ call_if_eq UnusualWeather_StartGroudonWeather
end
Route116_EventScript_1F2C47:: @ 81F2C47
@@ -19,14 +19,14 @@ Route116_EventScript_1F2C47:: @ 81F2C47
return
Route116_MapScript1_1F2C4F: @ 81F2C4F
- compare VAR_0x4037, 5
- call_if_eq Route116_EventScript_27395F
- compare VAR_0x4037, 6
- call_if_eq Route116_EventScript_273972
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_NORTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute116North
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_116_SOUTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute116South
end
Route116_MapScript2_1F2C66: @ 81F2C66
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route116_EventScript_1F2C70:: @ 81F2C70
diff --git a/data/maps/Route118/scripts.inc b/data/maps/Route118/scripts.inc
index 758804137..9c1ec46ca 100644
--- a/data/maps/Route118/scripts.inc
+++ b/data/maps/Route118/scripts.inc
@@ -6,23 +6,23 @@ Route118_MapScripts:: @ 81F3DBC
Route118_MapScript1_1F3DCC: @ 81F3DCC
call Route118_EventScript_28CCC7
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route118_EventScript_273D13
- compare VAR_0x4037, 7
- call_if_eq Route118_EventScript_273D1B
- compare VAR_0x4037, 8
- call_if_eq Route118_EventScript_273D1B
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_EAST
+ call_if_eq UnusualWeather_StartGroudonWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_WEST
+ call_if_eq UnusualWeather_StartGroudonWeather
end
Route118_MapScript1_1F3DF3: @ 81F3DF3
- compare VAR_0x4037, 7
- call_if_eq Route118_EventScript_273985
- compare VAR_0x4037, 8
- call_if_eq Route118_EventScript_273998
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_EAST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute118East
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_118_WEST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute118West
end
Route118_MapScript2_1F3E0A: @ 81F3E0A
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route118_EventScript_1F3E14:: @ 81F3E14
diff --git a/data/maps/Route119/scripts.inc b/data/maps/Route119/scripts.inc
index 83ff4707f..22a73b74b 100644
--- a/data/maps/Route119/scripts.inc
+++ b/data/maps/Route119/scripts.inc
@@ -167,7 +167,7 @@ Route119_EventScript_1F460F:: @ 81F460F
addobject 43
applymovement 43, Route119_Movement_1F4752
waitmovement 0
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
msgbox Route119_Text_1F4E60, MSGBOX_DEFAULT
closemessage
compare VAR_TEMP_1, 1
@@ -491,7 +491,7 @@ Route119_EventScript_1F49EC:: @ 81F49EC
pokenavcall Route119_Text_1F4FBA
waitmessage
clearflag FLAG_REGISTER_WINONA_POKENAV
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
releaseall
end
diff --git a/data/maps/Route119_WeatherInstitute_2F/scripts.inc b/data/maps/Route119_WeatherInstitute_2F/scripts.inc
index 7d557fdef..fa2664d68 100644
--- a/data/maps/Route119_WeatherInstitute_2F/scripts.inc
+++ b/data/maps/Route119_WeatherInstitute_2F/scripts.inc
@@ -131,41 +131,43 @@ Route119_WeatherInstitute_2F_EventScript_2700EA:: @ 82700EA
end
Route119_WeatherInstitute_2F_EventScript_2700F7:: @ 82700F7
- goto_if_set FLAG_SYS_GAME_CLEAR, Route119_WeatherInstitute_2F_EventScript_27010A
+ goto_if_set FLAG_SYS_GAME_CLEAR, Route119_WeatherInstitute_2F_EventScript_TryStartUnusualWeather
msgbox Route119_WeatherInstitute_2F_Text_27077E, MSGBOX_DEFAULT
release
end
-Route119_WeatherInstitute_2F_EventScript_27010A:: @ 827010A
+Route119_WeatherInstitute_2F_EventScript_TryStartUnusualWeather:: @ 827010A
+ @ This code uses VAR_0x8004 to count the number of legendaries the player has defeated
+ @ already.
setvar VAR_0x8004, 0
- call_if_set FLAG_DEFEATED_KYOGRE, Route119_WeatherInstitute_2F_EventScript_270160
- call_if_set FLAG_DEFEATED_GROUDON, Route119_WeatherInstitute_2F_EventScript_270160
+ call_if_set FLAG_DEFEATED_KYOGRE, WeatherInstitute_UnusualWeather_EventScript_IncrementLegendCount
+ call_if_set FLAG_DEFEATED_GROUDON, WeatherInstitute_UnusualWeather_EventScript_IncrementLegendCount
compare VAR_0x8004, 2
- goto_if_eq Route119_WeatherInstitute_2F_EventScript_270166
- call_if_unset FLAG_TEMP_2, Route119_WeatherInstitute_2F_EventScript_270159
- specialvar VAR_RESULT, sub_813B374
+ goto_if_eq WeatherInstitute_UnusualWeather_EventScript_ShowLegendariesAlreadyDefeated
+ call_if_unset FLAG_TEMP_2, WeatherInstitute_UnusualWeather_EventScript_DoCreateUnusualWeather
+ specialvar VAR_RESULT, GetUnusualWeatherMapNameAndType
compare VAR_RESULT, 1
- goto_if_eq Route119_WeatherInstitute_2F_EventScript_27014F
- msgbox Route119_WeatherInstitute_2F_Text_2707F1, MSGBOX_DEFAULT
+ goto_if_eq WeatherInstitute_UnusualWeather_EventScript_ShowKyogreWeatherMessage
+ msgbox WeatherInstitute_UnusualWeather_GroudonWeatherText, MSGBOX_DEFAULT
release
end
-Route119_WeatherInstitute_2F_EventScript_27014F:: @ 827014F
- msgbox Route119_WeatherInstitute_2F_Text_270873, MSGBOX_DEFAULT
+WeatherInstitute_UnusualWeather_EventScript_ShowKyogreWeatherMessage:: @ 827014F
+ msgbox WeatherInstitute_UnusualWeather_KyogreWeatherText, MSGBOX_DEFAULT
release
end
-Route119_WeatherInstitute_2F_EventScript_270159:: @ 8270159
- special sub_813B2E4
+WeatherInstitute_UnusualWeather_EventScript_DoCreateUnusualWeather:: @ 8270159
+ special CreateUnusualWeatherEvent
setflag FLAG_TEMP_2
return
-Route119_WeatherInstitute_2F_EventScript_270160:: @ 8270160
+WeatherInstitute_UnusualWeather_EventScript_IncrementLegendCount:: @ 8270160
addvar VAR_0x8004, 1
return
-Route119_WeatherInstitute_2F_EventScript_270166:: @ 8270166
- msgbox Route119_WeatherInstitute_2F_Text_2708FC, MSGBOX_DEFAULT
+WeatherInstitute_UnusualWeather_EventScript_ShowLegendariesAlreadyDefeated:: @ 8270166
+ msgbox WeatherInstitute_UnusualWeather_EventScript_ShowLegendariesAlreadyDefeatedText, MSGBOX_DEFAULT
release
end
@@ -309,7 +311,7 @@ Route119_WeatherInstitute_2F_Text_27077E: @ 827077E
.string "years, but it's ridiculous to think that\l"
.string "humans can freely change the weather.$"
-Route119_WeatherInstitute_2F_Text_2707F1: @ 82707F1
+WeatherInstitute_UnusualWeather_GroudonWeatherText: @ 82707F1
.string "I track weather patterns over\n"
.string "the HOENN region.\p"
.string "Presently, a drought has been recorded\n"
@@ -317,7 +319,7 @@ Route119_WeatherInstitute_2F_Text_2707F1: @ 82707F1
.string "Could that mean, somewhere near\n"
.string "{STR_VAR_1}…$"
-Route119_WeatherInstitute_2F_Text_270873: @ 8270873
+WeatherInstitute_UnusualWeather_KyogreWeatherText: @ 8270873
.string "I track weather patterns over\n"
.string "the HOENN region.\p"
.string "Presently, heavy rainfall has been\n"
@@ -325,7 +327,7 @@ Route119_WeatherInstitute_2F_Text_270873: @ 8270873
.string "Could that mean, somewhere near\n"
.string "{STR_VAR_1}…$"
-Route119_WeatherInstitute_2F_Text_2708FC: @ 82708FC
+WeatherInstitute_UnusualWeather_EventScript_ShowLegendariesAlreadyDefeatedText: @ 82708FC
.string "Abnormal weather conditions are\n"
.string "no longer being reported.\p"
.string "The occasional rainfall is a blessing,\n"
diff --git a/data/maps/Route124/map.json b/data/maps/Route124/map.json
index 7169a0299..c1a22a2d0 100644
--- a/data/maps/Route124/map.json
+++ b/data/maps/Route124/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_124",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route125/map.json b/data/maps/Route125/map.json
index 8071cf244..0ce520fdd 100644
--- a/data/maps/Route125/map.json
+++ b/data/maps/Route125/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_125",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route125/scripts.inc b/data/maps/Route125/scripts.inc
index 4812b9691..8abcbe787 100644
--- a/data/maps/Route125/scripts.inc
+++ b/data/maps/Route125/scripts.inc
@@ -6,23 +6,23 @@ Route125_MapScripts:: @ 81F6748
Route125_MapScript1_1F6758: @ 81F6758
call_if_set FLAG_SYS_WEATHER_CTRL, Common_EventScript_SetWeather15
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route125_EventScript_273D13
- compare VAR_0x4037, 11
- call_if_eq Route125_EventScript_273D17
- compare VAR_0x4037, 12
- call_if_eq Route125_EventScript_273D17
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_WEST
+ call_if_eq UnusualWeather_StartKyogreWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_EAST
+ call_if_eq UnusualWeather_StartKyogreWeather
end
Route125_MapScript1_1F6783: @ 81F6783
- compare VAR_0x4037, 11
- call_if_eq Route125_EventScript_273A85
- compare VAR_0x4037, 12
- call_if_eq Route125_EventScript_273AF2
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_WEST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute125West
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_125_EAST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute125East
end
Route125_MapScript2_1F679A: @ 81F679A
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route125_EventScript_1F67A4:: @ 81F67A4
diff --git a/data/maps/Route126/map.json b/data/maps/Route126/map.json
index 1e886a083..ea63eb80d 100644
--- a/data/maps/Route126/map.json
+++ b/data/maps/Route126/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_126",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route127/map.json b/data/maps/Route127/map.json
index 1b30f7d55..e4a68c3e1 100644
--- a/data/maps/Route127/map.json
+++ b/data/maps/Route127/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_127",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route127/scripts.inc b/data/maps/Route127/scripts.inc
index 7d5eee844..91fab2b61 100644
--- a/data/maps/Route127/scripts.inc
+++ b/data/maps/Route127/scripts.inc
@@ -6,23 +6,23 @@ Route127_MapScripts:: @ 81F69D9
Route127_MapScript1_1F69E9: @ 81F69E9
call_if_set FLAG_SYS_WEATHER_CTRL, Common_EventScript_SetWeather15
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route127_EventScript_273D13
- compare VAR_0x4037, 13
- call_if_eq Route127_EventScript_273D17
- compare VAR_0x4037, 14
- call_if_eq Route127_EventScript_273D17
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_NORTH
+ call_if_eq UnusualWeather_StartKyogreWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_SOUTH
+ call_if_eq UnusualWeather_StartKyogreWeather
end
Route127_MapScript1_1F6A14: @ 81F6A14
- compare VAR_0x4037, 13
- call_if_eq Route127_EventScript_273B5F
- compare VAR_0x4037, 14
- call_if_eq Route127_EventScript_273BCC
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_NORTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute127North
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_127_SOUTH
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute127South
end
Route127_MapScript2_1F6A2B: @ 81F6A2B
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route127_EventScript_1F6A35:: @ 81F6A35
diff --git a/data/maps/Route128/map.json b/data/maps/Route128/map.json
index 826290ff3..58246c247 100644
--- a/data/maps/Route128/map.json
+++ b/data/maps/Route128/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_128",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route129/map.json b/data/maps/Route129/map.json
index b3e45b227..3183f9821 100644
--- a/data/maps/Route129/map.json
+++ b/data/maps/Route129/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_129",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route129/scripts.inc b/data/maps/Route129/scripts.inc
index 8aec4bc28..25aa675a6 100644
--- a/data/maps/Route129/scripts.inc
+++ b/data/maps/Route129/scripts.inc
@@ -5,21 +5,21 @@ Route129_MapScripts:: @ 81F7284
.byte 0
Route129_MapScript1_1F7294: @ 81F7294
- compare VAR_0x4037, 15
- call_if_eq Route129_EventScript_273C39
- compare VAR_0x4037, 16
- call_if_eq Route129_EventScript_273CA6
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_WEST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute129West
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_EAST
+ call_if_eq UnusualWeather_EventScript_PlaceTilesRoute129East
end
Route129_MapScript1_1F72AB: @ 81F72AB
- compare VAR_0x4039, 1
+ compare VAR_SHOULD_END_UNUSUAL_WEATHER, 1
call_if_eq Route129_EventScript_273D13
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_ge Route129_EventScript_1F72D8
- compare VAR_0x4037, 15
- call_if_eq Route129_EventScript_273D17
- compare VAR_0x4037, 16
- call_if_eq Route129_EventScript_273D17
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_WEST
+ call_if_eq UnusualWeather_StartKyogreWeather
+ compare VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_ROUTE_129_EAST
+ call_if_eq UnusualWeather_StartKyogreWeather
end
Route129_EventScript_1F72D8:: @ 81F72D8
@@ -27,7 +27,7 @@ Route129_EventScript_1F72D8:: @ 81F72D8
return
Route129_MapScript2_1F72E2: @ 81F72E2
- map_script_2 VAR_0x4039, 1, gUnknown_08273D1F
+ map_script_2 VAR_SHOULD_END_UNUSUAL_WEATHER, 1, UnusualWeather_EventScript_EndEventAndCleanup_1
.2byte 0
Route129_EventScript_1F72EC:: @ 81F72EC
diff --git a/data/maps/Route130/map.json b/data/maps/Route130/map.json
index 0a68d442c..18d168b17 100644
--- a/data/maps/Route130/map.json
+++ b/data/maps/Route130/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_130",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route130/scripts.inc b/data/maps/Route130/scripts.inc
index 18dce324d..cdcc61550 100644
--- a/data/maps/Route130/scripts.inc
+++ b/data/maps/Route130/scripts.inc
@@ -3,7 +3,7 @@ Route130_MapScripts:: @ 81F735F
.byte 0
Route130_MapScript1_1F7365: @ 81F7365
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_ge Route130_EventScript_1F73B5
specialvar VAR_RESULT, IsMirageIslandPresent
compare VAR_RESULT, 1
diff --git a/data/maps/Route131/map.json b/data/maps/Route131/map.json
index 3a48042f9..379b15b3d 100644
--- a/data/maps/Route131/map.json
+++ b/data/maps/Route131/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_131",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route131/scripts.inc b/data/maps/Route131/scripts.inc
index 7f50b2273..0d178e969 100644
--- a/data/maps/Route131/scripts.inc
+++ b/data/maps/Route131/scripts.inc
@@ -3,7 +3,7 @@ Route131_MapScripts:: @ 81F7404
.byte 0
Route131_MapScript1_1F740A: @ 81F740A
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_ge Route131_EventScript_1F741F
call Route131_EventScript_1F741B
end
diff --git a/data/maps/Route132/map.json b/data/maps/Route132/map.json
index ae04ff62d..15c0de83d 100644
--- a/data/maps/Route132/map.json
+++ b/data/maps/Route132/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_132",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route133/map.json b/data/maps/Route133/map.json
index 2a8941e12..eed30d7ee 100644
--- a/data/maps/Route133/map.json
+++ b/data/maps/Route133/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_133",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/Route134/map.json b/data/maps/Route134/map.json
index 1e9123efe..8b3a9518e 100644
--- a/data/maps/Route134/map.json
+++ b/data/maps/Route134/map.json
@@ -6,7 +6,7 @@
"region_map_section": "MAPSEC_ROUTE_134",
"requires_flash": false,
"weather": "WEATHER_SUNNY",
- "map_type": "MAP_TYPE_6",
+ "map_type": "MAP_TYPE_OCEAN_ROUTE",
"allow_bike": true,
"allow_escape_rope": false,
"allow_running": true,
diff --git a/data/maps/RustboroCity_PokemonSchool/scripts.inc b/data/maps/RustboroCity_PokemonSchool/scripts.inc
index 74394f9a5..ff52ee5ac 100644
--- a/data/maps/RustboroCity_PokemonSchool/scripts.inc
+++ b/data/maps/RustboroCity_PokemonSchool/scripts.inc
@@ -170,7 +170,7 @@ RustboroCity_PokemonSchool_EventScript_214040:: @ 8214040
goto_if_set FLAG_MET_SCOTT_RUSTBORO, RustboroCity_PokemonSchool_EventScript_21406F
goto_if_set FLAG_BADGE01_GET, RustboroCity_PokemonSchool_EventScript_214082
msgbox RustboroCity_PokemonSchool_Text_2148C0, MSGBOX_DEFAULT
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_RUSTBORO
release
end
@@ -192,7 +192,7 @@ RustboroCity_PokemonSchool_EventScript_214090:: @ 8214090
end
RustboroCity_PokemonSchool_EventScript_21409E:: @ 821409E
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_AFTER_OBTAINING_STONE_BADGE
release
end
diff --git a/data/maps/SSTidalCorridor/scripts.inc b/data/maps/SSTidalCorridor/scripts.inc
index ededf1e5f..ec231ccdd 100644
--- a/data/maps/SSTidalCorridor/scripts.inc
+++ b/data/maps/SSTidalCorridor/scripts.inc
@@ -3,7 +3,7 @@ SSTidalCorridor_MapScripts:: @ 823BFCF
.byte 0
SSTidalCorridor_MapScript2_23BFD5: @ 823BFD5
- map_script_2 VAR_0x40D4, 0, SSTidalCorridor_EventScript_23C219
+ map_script_2 VAR_SS_TIDAL_SCOTT_STATE, 0, SSTidalCorridor_EventScript_23C219
map_script_2 VAR_PORTHOLE_STATE, 1, SSTidalCorridor_EventScript_23BFFF
map_script_2 VAR_PORTHOLE_STATE, 5, SSTidalCorridor_EventScript_23C015
map_script_2 VAR_PORTHOLE_STATE, 9, SSTidalCorridor_EventScript_23C067
@@ -216,7 +216,7 @@ SSTidalCorridor_EventScript_23C219:: @ 823C219
waitmovement 0
delay 30
setflag FLAG_MET_SCOTT_ON_SS_TIDAL
- setvar VAR_0x40D4, 1
+ setvar VAR_SS_TIDAL_SCOTT_STATE, 1
releaseall
end
diff --git a/data/maps/SeafloorCavern_Entrance/scripts.inc b/data/maps/SeafloorCavern_Entrance/scripts.inc
index 045c0e065..1bf570549 100644
--- a/data/maps/SeafloorCavern_Entrance/scripts.inc
+++ b/data/maps/SeafloorCavern_Entrance/scripts.inc
@@ -9,7 +9,7 @@ SeafloorCavern_Entrance_MapScript1_234474: @ 8234474
SeafloorCavern_Entrance_EventScript_234485:: @ 8234485
lockall
- compare VAR_0x40D9, 1
+ compare VAR_HAS_TALKED_TO_SEAFLOOR_CAVERN_ENTRANCE_GRUNT, 1
goto_if_eq SeafloorCavern_Entrance_EventScript_2344ED
waitse
playse SE_PIN
@@ -25,7 +25,7 @@ SeafloorCavern_Entrance_EventScript_234485:: @ 8234485
compare VAR_FACING, 2
call_if_eq SeafloorCavern_Entrance_EventScript_234539
delay 30
- setvar VAR_0x40D9, 1
+ setvar VAR_HAS_TALKED_TO_SEAFLOOR_CAVERN_ENTRANCE_GRUNT, 1
moveobjectoffscreen 1
msgbox SeafloorCavern_Entrance_Text_234544, MSGBOX_DEFAULT
closemessage
diff --git a/data/maps/SeafloorCavern_Room9/scripts.inc b/data/maps/SeafloorCavern_Room9/scripts.inc
index 7fe6386c3..38a10a004 100644
--- a/data/maps/SeafloorCavern_Room9/scripts.inc
+++ b/data/maps/SeafloorCavern_Room9/scripts.inc
@@ -119,7 +119,7 @@ SeafloorCavern_Room9_EventScript_234DC9:: @ 8234DC9
waitmovement 0
msgbox SeafloorCavern_Room9_Text_235723, MSGBOX_DEFAULT
setvar VAR_ROUTE128_STATE, 1
- setvar VAR_0x405E, 1
+ setvar VAR_RAYQUAZA_STATE, 1
clearflag FLAG_HIDE_SOOTOPOLIS_CITY_STEVEN
clearflag FLAG_HIDE_SOOTOPOLIS_CITY_ARCHIE
clearflag FLAG_HIDE_SOOTOPOLIS_CITY_MAXIE
diff --git a/data/maps/SecretBase_YellowCave4/scripts.inc b/data/maps/SecretBase_YellowCave4/scripts.inc
index cb26f924e..805d7e299 100644
--- a/data/maps/SecretBase_YellowCave4/scripts.inc
+++ b/data/maps/SecretBase_YellowCave4/scripts.inc
@@ -6,7 +6,7 @@ SecretBase_YellowCave4_MapScripts:: @ 823B483
.byte 0
SecretBase_RedCave1_MapScript2_23B498: @ 823B498
- map_script_2 VAR_0x4089, 0, EventScript_275D0C
+ map_script_2 VAR_SECRET_BASE_INITIALIZED, 0, EventScript_275D0C
.2byte 0
SecretBase_RedCave1_MapScript1_23B4A2: @ 823B4A2
@@ -16,7 +16,7 @@ SecretBase_RedCave1_MapScript1_23B4A2: @ 823B4A2
end
SecretBase_RedCave1_MapScript2_23B4AE: @ 823B4AE
- map_script_2 VAR_0x4097, 0, SecretBase_RedCave1_EventScript_275B81
+ map_script_2 VAR_INIT_SECRET_BASE, 0, SecretBase_RedCave1_EventScript_275B81
.2byte 0
SecretBase_RedCave1_MapScript1_23B4B8: @ 823B4B8
diff --git a/data/maps/SingleBattleColosseum/map.json b/data/maps/SingleBattleColosseum/map.json
index 167344e61..a7ad50f1b 100644
--- a/data/maps/SingleBattleColosseum/map.json
+++ b/data/maps/SingleBattleColosseum/map.json
@@ -52,7 +52,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_08277374"
+ "script": "EventScript_SingleBattleColosseum_PlayerSpot0"
},
{
"type": "trigger",
@@ -61,7 +61,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_0827737E"
+ "script": "EventScript_SingleBattleColosseum_PlayerSpot1"
}
],
"bg_events": []
diff --git a/data/maps/SkyPillar_1F/scripts.inc b/data/maps/SkyPillar_1F/scripts.inc
index b1ec3b74a..18ec43ad6 100644
--- a/data/maps/SkyPillar_1F/scripts.inc
+++ b/data/maps/SkyPillar_1F/scripts.inc
@@ -3,7 +3,7 @@ SkyPillar_1F_MapScripts:: @ 8239615
.byte 0
SkyPillar_1F_MapScript1_23961B: @ 823961B
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_1F_EventScript_239627
end
diff --git a/data/maps/SkyPillar_2F/scripts.inc b/data/maps/SkyPillar_2F/scripts.inc
index 8c1424fd9..9059bd246 100644
--- a/data/maps/SkyPillar_2F/scripts.inc
+++ b/data/maps/SkyPillar_2F/scripts.inc
@@ -5,7 +5,7 @@ SkyPillar_2F_MapScripts:: @ 823962B
.byte 0
SkyPillar_2F_MapScript1_23963B: @ 823963B
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_2F_EventScript_23964C
copyvar VAR_ICE_STEP_COUNT, 0x1
end
diff --git a/data/maps/SkyPillar_3F/scripts.inc b/data/maps/SkyPillar_3F/scripts.inc
index 9bc7eda27..ba6a5128d 100644
--- a/data/maps/SkyPillar_3F/scripts.inc
+++ b/data/maps/SkyPillar_3F/scripts.inc
@@ -3,7 +3,7 @@ SkyPillar_3F_MapScripts:: @ 823965B
.byte 0
SkyPillar_3F_MapScript1_239661: @ 8239661
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_3F_EventScript_23966D
end
diff --git a/data/maps/SkyPillar_4F/scripts.inc b/data/maps/SkyPillar_4F/scripts.inc
index 254d61a59..355530fdc 100644
--- a/data/maps/SkyPillar_4F/scripts.inc
+++ b/data/maps/SkyPillar_4F/scripts.inc
@@ -5,7 +5,7 @@ SkyPillar_4F_MapScripts:: @ 8239671
.byte 0
SkyPillar_4F_MapScript1_239681: @ 8239681
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_4F_EventScript_239692
copyvar VAR_ICE_STEP_COUNT, 0x1
end
diff --git a/data/maps/SkyPillar_5F/scripts.inc b/data/maps/SkyPillar_5F/scripts.inc
index af5a5ffe1..ba35e16f2 100644
--- a/data/maps/SkyPillar_5F/scripts.inc
+++ b/data/maps/SkyPillar_5F/scripts.inc
@@ -3,7 +3,7 @@ SkyPillar_5F_MapScripts:: @ 82396A2
.byte 0
SkyPillar_5F_MapScript1_2396A8: @ 82396A8
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_5F_EventScript_2396B4
return
diff --git a/data/maps/SkyPillar_Outside/scripts.inc b/data/maps/SkyPillar_Outside/scripts.inc
index c68dc03e3..93d4e42c3 100644
--- a/data/maps/SkyPillar_Outside/scripts.inc
+++ b/data/maps/SkyPillar_Outside/scripts.inc
@@ -5,9 +5,9 @@ SkyPillar_Outside_MapScripts:: @ 82392A8
.byte 0
SkyPillar_Outside_MapScript1_2392B8: @ 82392B8
- compare VAR_0x405E, 3
+ compare VAR_RAYQUAZA_STATE, 3
call_if_eq SkyPillar_Outside_EventScript_2392CF
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_ge SkyPillar_Outside_EventScript_2392D3
end
@@ -29,7 +29,7 @@ SkyPillar_Outside_EventScript_2392E7:: @ 82392E7
return
SkyPillar_Outside_MapScript2_2392FA: @ 82392FA
- map_script_2 VAR_0x405E, 3, SkyPillar_Outside_EventScript_239304
+ map_script_2 VAR_RAYQUAZA_STATE, 3, SkyPillar_Outside_EventScript_239304
.2byte 0
SkyPillar_Outside_EventScript_239304:: @ 8239304
@@ -82,7 +82,7 @@ SkyPillar_Outside_EventScript_239304:: @ 8239304
playse SE_KAIDAN
fadescreenswapbuffers 1
clearflag FLAG_SPECIAL_FLAG_0x4000
- setvar VAR_0x405E, 4
+ setvar VAR_RAYQUAZA_STATE, 4
removeobject 1
clearflag FLAG_HIDE_SOOTOPOLIS_CITY_WALLACE
fadescreenswapbuffers 0
diff --git a/data/maps/SkyPillar_Top/map.json b/data/maps/SkyPillar_Top/map.json
index 5cb6a1a69..2d1a6fa1a 100644
--- a/data/maps/SkyPillar_Top/map.json
+++ b/data/maps/SkyPillar_Top/map.json
@@ -56,7 +56,7 @@
"x": 14,
"y": 9,
"elevation": 3,
- "var": "VAR_0x40D7",
+ "var": "VAR_SKY_PILLAR_RAQUAZA_CRY_DONE",
"var_value": "0",
"script": "SkyPillar_Top_EventScript_23979A"
}
diff --git a/data/maps/SkyPillar_Top/scripts.inc b/data/maps/SkyPillar_Top/scripts.inc
index 3d031293d..d08b0b554 100644
--- a/data/maps/SkyPillar_Top/scripts.inc
+++ b/data/maps/SkyPillar_Top/scripts.inc
@@ -16,9 +16,9 @@ SkyPillar_Top_EventScript_2396D2:: @ 82396D2
return
SkyPillar_Top_MapScript1_2396E6: @ 82396E6
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_lt SkyPillar_Top_EventScript_2396FD
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_ge SkyPillar_Top_EventScript_239705
end
@@ -36,7 +36,7 @@ SkyPillar_Top_EventScript_23970F:: @ 823970F
return
SkyPillar_Top_MapScript2_239713: @ 8239713
- map_script_2 VAR_0x40CA, 0, SkyPillar_Top_EventScript_23971D
+ map_script_2 VAR_SKY_PILLAR_STATE, 0, SkyPillar_Top_EventScript_23971D
.2byte 0
SkyPillar_Top_EventScript_23971D:: @ 823971D
@@ -130,9 +130,9 @@ SkyPillar_Top_EventScript_23979A:: @ 823979A
applymovement EVENT_OBJ_ID_CAMERA, SkyPillar_Top_Movement_23985C
waitmovement 0
special RemoveCameraObject
- setvar VAR_0x405E, 5
- setvar VAR_0x40CA, 1
- setvar VAR_0x40D7, 1
+ setvar VAR_RAYQUAZA_STATE, 5
+ setvar VAR_SKY_PILLAR_STATE, 1
+ setvar VAR_SKY_PILLAR_RAQUAZA_CRY_DONE, 1
releaseall
end
diff --git a/data/maps/SlateportCity/map.json b/data/maps/SlateportCity/map.json
index 126519096..f548b7349 100644
--- a/data/maps/SlateportCity/map.json
+++ b/data/maps/SlateportCity/map.json
@@ -571,7 +571,7 @@
"x": 10,
"y": 13,
"elevation": 3,
- "var": "VAR_0x40D2",
+ "var": "VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE",
"var_value": "2",
"script": "SlateportCity_EventScript_1DD5DC"
}
diff --git a/data/maps/SlateportCity/scripts.inc b/data/maps/SlateportCity/scripts.inc
index 9f4310c4a..acf66d2bd 100644
--- a/data/maps/SlateportCity/scripts.inc
+++ b/data/maps/SlateportCity/scripts.inc
@@ -8,7 +8,7 @@ SlateportCity_MapScript1_1DCC6C: @ 81DCC6C
call SlateportCity_EventScript_1DCC8D
compare VAR_SLATEPORT_STATE, 1
call_if_eq SlateportCity_EventScript_1DCC99
- compare VAR_0x40D2, 1
+ compare VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 1
call_if_eq SlateportCity_EventScript_1DCCE7
end
@@ -50,7 +50,7 @@ SlateportCity_EventScript_1DCD06:: @ 81DCD06
return
SlateportCity_MapScript2_1DCD12: @ 81DCD12
- map_script_2 VAR_0x40D2, 1, SlateportCity_EventScript_1DCD1C
+ map_script_2 VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 1, SlateportCity_EventScript_1DCD1C
.2byte 0
SlateportCity_EventScript_1DCD1C:: @ 81DCD1C
@@ -84,8 +84,8 @@ SlateportCity_EventScript_1DCD1C:: @ 81DCD1C
setobjectxyperm 35, 10, 12
setobjectmovementtype 35, MOVEMENT_TYPE_FACE_DOWN
clearflag FLAG_SPECIAL_FLAG_0x4000
- setvar VAR_0x40D2, 2
- addvar VAR_0x40D1, 1
+ setvar VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 2
+ addvar VAR_SCOTT_STATE, 1
releaseall
end
@@ -901,8 +901,8 @@ SlateportCity_EventScript_1DD5DC:: @ 81DD5DC
applymovement 35, SlateportCity_Movement_1DD63A
waitmovement 0
removeobject 35
- addvar VAR_0x40D1, 1
- setvar VAR_0x40D2, 3
+ addvar VAR_SCOTT_STATE, 1
+ setvar VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 3
releaseall
end
diff --git a/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc b/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
index 641c4dd86..96ae96685 100644
--- a/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
+++ b/data/maps/SlateportCity_OceanicMuseum_2F/scripts.inc
@@ -86,7 +86,7 @@ SlateportCity_OceanicMuseum_2F_EventScript_20BB00:: @ 820BB00
setflag FLAG_DELIVERED_DEVON_GOODS
clearflag FLAG_HIDE_ROUTE_116_DEVON_EMPLOYEE
setflag FLAG_HIDE_RUSTBORO_CITY_DEVON_CORP_3F_EMPLOYEE
- setvar VAR_0x40D2, 1
+ setvar VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE, 1
fadescreen 0
release
end
diff --git a/data/maps/SootopolisCity/scripts.inc b/data/maps/SootopolisCity/scripts.inc
index 98c9af1ee..dbfe923f0 100644
--- a/data/maps/SootopolisCity/scripts.inc
+++ b/data/maps/SootopolisCity/scripts.inc
@@ -33,31 +33,31 @@ SootopolisCity_EventScript_1E56E5:: @ 81E56E5
SootopolisCity_MapScript1_1E56EF: @ 81E56EF
setflag FLAG_VISITED_SOOTOPOLIS_CITY
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
call_if_eq SootopolisCity_EventScript_1E5781
- compare VAR_0x40CA, 1
+ compare VAR_SKY_PILLAR_STATE, 1
call_if_eq SootopolisCity_EventScript_1E5781
call SootopolisCity_EventScript_1E5805
call SootopolisCity_EventScript_1E57B2
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
call_if_eq SootopolisCity_EventScript_1E5785
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
call_if_eq SootopolisCity_EventScript_1E5785
- compare VAR_0x405E, 3
+ compare VAR_RAYQUAZA_STATE, 3
call_if_eq SootopolisCity_EventScript_1E5785
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_eq SootopolisCity_EventScript_1E5785
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
call_if_eq SootopolisCity_EventScript_1E5785
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
call_if_eq SootopolisCity_EventScript_1E5842
- compare VAR_0x405E, 3
+ compare VAR_RAYQUAZA_STATE, 3
call_if_eq SootopolisCity_EventScript_1E5842
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
call_if_eq SootopolisCity_EventScript_1E585B
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
call_if_eq SootopolisCity_EventScript_1E5871
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
call_if_eq SootopolisCity_EventScript_1E58D3
end
@@ -77,19 +77,19 @@ SootopolisCity_EventScript_1E5785:: @ 81E5785
return
SootopolisCity_EventScript_1E57B2:: @ 81E57B2
- compare VAR_0x405E, 0
+ compare VAR_RAYQUAZA_STATE, 0
goto_if_eq SootopolisCity_EventScript_1E5800
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E5800
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
goto_if_eq SootopolisCity_EventScript_1E5801
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
goto_if_eq SootopolisCity_EventScript_1E5801
- compare VAR_0x405E, 3
+ compare VAR_RAYQUAZA_STATE, 3
goto_if_eq SootopolisCity_EventScript_1E5801
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
goto_if_eq SootopolisCity_EventScript_1E5801
- compare VAR_0x40CA, 1
+ compare VAR_SKY_PILLAR_STATE, 1
goto_if_le SootopolisCity_EventScript_1E5801
return
@@ -101,15 +101,15 @@ SootopolisCity_EventScript_1E5801:: @ 81E5801
return
SootopolisCity_EventScript_1E5805:: @ 81E5805
- compare VAR_0x405E, 0
+ compare VAR_RAYQUAZA_STATE, 0
goto_if_eq SootopolisCity_EventScript_1E583D
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E583D
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
goto_if_eq SootopolisCity_EventScript_1E583E
- compare VAR_0x40CA, 1
+ compare VAR_SKY_PILLAR_STATE, 1
goto_if_eq SootopolisCity_EventScript_1E583E
- compare VAR_0x40CA, 1
+ compare VAR_SKY_PILLAR_STATE, 1
goto_if_le Common_EventScript_SetWeather15
return
@@ -140,11 +140,11 @@ SootopolisCity_EventScript_1E5871:: @ 81E5871
setobjectxyperm 7, 29, 33
setobjectxyperm 16, 33, 35
setobjectxyperm 17, 34, 35
- compare VAR_0x40D8, 0
+ compare VAR_SOOTOPOLIS_STATE, 0
call_if_eq SootopolisCity_EventScript_1E58AF
- compare VAR_0x40D8, 1
+ compare VAR_SOOTOPOLIS_STATE, 1
call_if_eq SootopolisCity_EventScript_1E58BB
- compare VAR_0x40D8, 2
+ compare VAR_SOOTOPOLIS_STATE, 2
call_if_eq SootopolisCity_EventScript_1E58C7
return
@@ -168,13 +168,13 @@ SootopolisCity_EventScript_1E58D3:: @ 81E58D3
return
SootopolisCity_MapScript2_1E58DB: @ 81E58DB
- map_script_2 VAR_0x405E, 5, SootopolisCity_EventScript_1E58E5
+ map_script_2 VAR_RAYQUAZA_STATE, 5, SootopolisCity_EventScript_1E58E5
.2byte 0
SootopolisCity_EventScript_1E58E5:: @ 81E58E5
- compare VAR_0x40CA, 1
+ compare VAR_SKY_PILLAR_STATE, 1
call_if_eq SootopolisCity_EventScript_1E58FC
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
call_if_eq SootopolisCity_EventScript_1E5901
end
@@ -184,7 +184,7 @@ SootopolisCity_EventScript_1E58FC:: @ 81E58FC
SootopolisCity_EventScript_1E5901:: @ 81E5901
turnobject EVENT_OBJ_ID_PLAYER, 2
- setvar VAR_0x40CA, 3
+ setvar VAR_SKY_PILLAR_STATE, 3
return
SootopolisCity_MapScript1_1E590B: @ 81E590B
@@ -192,8 +192,8 @@ SootopolisCity_MapScript1_1E590B: @ 81E590B
end
SootopolisCity_MapScript2_1E5914: @ 81E5914
- map_script_2 VAR_0x405E, 1, SootopolisCity_EventScript_1E5926
- map_script_2 VAR_0x40CA, 1, SootopolisCity_EventScript_1E5BFE
+ map_script_2 VAR_RAYQUAZA_STATE, 1, SootopolisCity_EventScript_1E5926
+ map_script_2 VAR_SKY_PILLAR_STATE, 1, SootopolisCity_EventScript_1E5BFE
.2byte 0
SootopolisCity_EventScript_1E5926:: @ 81E5926
@@ -271,7 +271,7 @@ SootopolisCity_EventScript_1E5946:: @ 81E5946
applymovement EVENT_OBJ_ID_CAMERA, SootopolisCity_Movement_1E5A75
waitmovement 0
special RemoveCameraObject
- setvar VAR_0x405E, 2
+ setvar VAR_RAYQUAZA_STATE, 2
clearflag FLAG_SPECIAL_FLAG_0x4000
releaseall
end
@@ -371,7 +371,7 @@ SootopolisCity_EventScript_1E5A82:: @ 81E5A82
applymovement EVENT_OBJ_ID_CAMERA, SootopolisCity_Movement_1E5BAE
waitmovement 0
special RemoveCameraObject
- setvar VAR_0x405E, 2
+ setvar VAR_RAYQUAZA_STATE, 2
clearflag FLAG_SPECIAL_FLAG_0x4000
releaseall
end
@@ -540,7 +540,7 @@ SootopolisCity_EventScript_1E5C1E:: @ 81E5C1E
special WaitWeather
waitstate
clearflag FLAG_SYS_WEATHER_CTRL
- setvar VAR_0x40CA, 3
+ setvar VAR_SKY_PILLAR_STATE, 3
clearflag FLAG_LEGENDARIES_IN_SOOTOPOLIS
fadenewbgm MUS_RUNECITY
delay 120
@@ -593,7 +593,7 @@ SootopolisCity_EventScript_1E5CCE:: @ 81E5CCE
special WaitWeather
waitstate
clearflag FLAG_SYS_WEATHER_CTRL
- setvar VAR_0x40CA, 2
+ setvar VAR_SKY_PILLAR_STATE, 2
clearflag FLAG_LEGENDARIES_IN_SOOTOPOLIS
fadenewbgm MUS_NAMINORI
delay 120
@@ -694,11 +694,11 @@ SootopolisCity_Movement_1E5E7F: @ 81E5E7F
SootopolisCity_EventScript_1E5E8D:: @ 81E5E8D
lock
faceplayer
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E5EC4
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E5ECE
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
goto_if_ge SootopolisCity_EventScript_1E5EBA
msgbox SootopolisCity_Text_1E6D77, MSGBOX_DEFAULT
release
@@ -722,11 +722,11 @@ SootopolisCity_EventScript_1E5ECE:: @ 81E5ECE
SootopolisCity_EventScript_1E5ED8:: @ 81E5ED8
lock
faceplayer
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
goto_if_le SootopolisCity_EventScript_1E5F1B
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E5F1B
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E5F10
msgbox SootopolisCity_Text_1E6BFF, MSGBOX_DEFAULT
closemessage
@@ -794,7 +794,7 @@ SootopolisCity_EventScript_1E5FE2:: @ 81E5FE2
lockall
applymovement 2, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E600D
msgbox SootopolisCity_Text_1E71A1, MSGBOX_DEFAULT
closemessage
@@ -811,7 +811,7 @@ SootopolisCity_EventScript_1E600D:: @ 81E600D
SootopolisCity_EventScript_1E6017:: @ 81E6017
lock
faceplayer
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E602E
msgbox SootopolisCity_Text_1E6CCA, MSGBOX_DEFAULT
release
@@ -825,11 +825,11 @@ SootopolisCity_EventScript_1E602E:: @ 81E602E
SootopolisCity_EventScript_1E6038:: @ 81E6038
lock
faceplayer
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E607A
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E6084
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
goto_if_ge SootopolisCity_EventScript_1E6065
msgbox SootopolisCity_Text_1E6F90, MSGBOX_DEFAULT
release
@@ -857,11 +857,11 @@ SootopolisCity_EventScript_1E608E:: @ 81E608E
lockall
applymovement 4, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E60D9
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E60CF
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
goto_if_le SootopolisCity_EventScript_1E60CF
msgbox SootopolisCity_Text_1E690B, MSGBOX_DEFAULT
closemessage
@@ -884,12 +884,12 @@ SootopolisCity_EventScript_1E60E3:: @ 81E60E3
lockall
applymovement 5, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E612D
goto_if_set FLAG_SYS_GAME_CLEAR, SootopolisCity_EventScript_1E6137
- compare VAR_0x405E, 6
+ compare VAR_RAYQUAZA_STATE, 6
goto_if_ge SootopolisCity_EventScript_1E6141
- compare VAR_0x405E, 1
+ compare VAR_RAYQUAZA_STATE, 1
goto_if_le SootopolisCity_EventScript_1E6141
msgbox SootopolisCity_Text_1E6692, MSGBOX_DEFAULT
closemessage
@@ -930,11 +930,11 @@ SootopolisCity_EventScript_1E6166:: @ 81E6166
applymovement 7, Common_Movement_FacePlayer
waitmovement 0
call_if_unset FLAG_STEVEN_GUIDES_TO_CAVE_OF_ORIGIN, SootopolisCity_EventScript_1E61CC
- compare VAR_0x405E, 2
+ compare VAR_RAYQUAZA_STATE, 2
goto_if_eq SootopolisCity_EventScript_1E61AE
- compare VAR_0x405E, 3
+ compare VAR_RAYQUAZA_STATE, 3
goto_if_eq SootopolisCity_EventScript_1E61C2
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
goto_if_eq SootopolisCity_EventScript_1E61C2
goto_if_set FLAG_SOOTOPOLIS_ARCHIE_MAXIE_LEAVE, SootopolisCity_EventScript_1E61B8
msgbox SootopolisCity_Text_1E78E5, MSGBOX_DEFAULT
@@ -1263,7 +1263,7 @@ SootopolisCity_EventScript_1E635D:: @ 81E635D
lockall
applymovement 15, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E6388
msgbox SootopolisCity_Text_1E67DC, MSGBOX_DEFAULT
closemessage
@@ -1280,7 +1280,7 @@ SootopolisCity_EventScript_1E6388:: @ 81E6388
SootopolisCity_EventScript_1E6393:: @ 81E6393
lockall
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E63C7
msgbox SootopolisCity_Text_1E6936, MSGBOX_DEFAULT
closemessage
@@ -1304,7 +1304,7 @@ SootopolisCity_EventScript_1E63DB:: @ 81E63DB
lockall
applymovement 13, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E6406
msgbox SootopolisCity_Text_1E6C7C, MSGBOX_DEFAULT
closemessage
@@ -1323,7 +1323,7 @@ SootopolisCity_EventScript_1E6411:: @ 81E6411
lockall
applymovement 12, Common_Movement_FacePlayer
waitmovement 0
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E643C
msgbox SootopolisCity_Text_1E6A50, MSGBOX_DEFAULT
closemessage
@@ -1340,7 +1340,7 @@ SootopolisCity_EventScript_1E643C:: @ 81E643C
SootopolisCity_EventScript_1E6446:: @ 81E6446
lock
faceplayer
- compare VAR_0x405E, 4
+ compare VAR_RAYQUAZA_STATE, 4
goto_if_eq SootopolisCity_EventScript_1E64D8
goto_if_set FLAG_RECEIVED_HM07, SootopolisCity_EventScript_1E64E2
goto_if_set FLAG_SOOTOPOLIS_ARCHIE_MAXIE_LEAVE, SootopolisCity_EventScript_1E646F
@@ -1367,14 +1367,14 @@ SootopolisCity_EventScript_1E64B2:: @ 81E64B2
applymovement 18, SootopolisCity_Movement_1E64EC
waitmovement 0
moveobjectoffscreen 18
- setvar VAR_0x40D8, 1
+ setvar VAR_SOOTOPOLIS_STATE, 1
return
SootopolisCity_EventScript_1E64C5:: @ 81E64C5
applymovement 18, SootopolisCity_Movement_1E64EF
waitmovement 0
moveobjectoffscreen 18
- setvar VAR_0x40D8, 2
+ setvar VAR_SOOTOPOLIS_STATE, 2
return
SootopolisCity_EventScript_1E64D8:: @ 81E64D8
@@ -1399,7 +1399,7 @@ SootopolisCity_Movement_1E64EF: @ 81E64EF
SootopolisCity_EventScript_1E64F2:: @ 81E64F2
lockall
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E6509
msgbox SootopolisCity_Text_1E72DB, MSGBOX_DEFAULT
closemessage
@@ -1415,7 +1415,7 @@ SootopolisCity_EventScript_1E6509:: @ 81E6509
SootopolisCity_EventScript_1E651F:: @ 81E651F
lockall
- compare VAR_0x405E, 5
+ compare VAR_RAYQUAZA_STATE, 5
goto_if_eq SootopolisCity_EventScript_1E6536
msgbox SootopolisCity_Text_1E7460, MSGBOX_DEFAULT
closemessage
diff --git a/data/maps/SootopolisCity_Gym_1F/scripts.inc b/data/maps/SootopolisCity_Gym_1F/scripts.inc
index 06bc91f21..b9abdf656 100644
--- a/data/maps/SootopolisCity_Gym_1F/scripts.inc
+++ b/data/maps/SootopolisCity_Gym_1F/scripts.inc
@@ -106,7 +106,7 @@ SootopolisCity_Gym_1F_EventScript_224F82:: @ 8224F82
setflag FLAG_HIDE_SOOTOPOLIS_CITY_RESIDENTS
setflag FLAG_HIDE_SOOTOPOLIS_CITY_STEVEN
setflag FLAG_HIDE_SOOTOPOLIS_CITY_WALLACE
- setvar VAR_0x405E, 6
+ setvar VAR_RAYQUAZA_STATE, 6
clearflag FLAG_HIDE_SOOTOPOLIS_CITY_MAN_1
setvar VAR_0x8008, 8
call SootopolisCity_Gym_1F_EventScript_271F43
diff --git a/data/maps/SootopolisCity_Mart/scripts.inc b/data/maps/SootopolisCity_Mart/scripts.inc
index 4a152bcf0..fe0270d62 100644
--- a/data/maps/SootopolisCity_Mart/scripts.inc
+++ b/data/maps/SootopolisCity_Mart/scripts.inc
@@ -28,7 +28,7 @@ SootopolisCity_Mart_Pokemart_2267AC: @ 82267AC
SootopolisCity_Mart_EventScript_2267C2:: @ 82267C2
lock
faceplayer
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
goto_if_ge SootopolisCity_Mart_EventScript_2267E2
goto_if_unset FLAG_KYOGRE_ESCAPED_SEAFLOOR_CAVERN, SootopolisCity_Mart_EventScript_2267E2
msgbox SootopolisCity_Mart_Text_22685D, MSGBOX_DEFAULT
@@ -43,7 +43,7 @@ SootopolisCity_Mart_EventScript_2267E2:: @ 82267E2
SootopolisCity_Mart_EventScript_2267EC:: @ 82267EC
lock
faceplayer
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
goto_if_ge SootopolisCity_Mart_EventScript_22680C
goto_if_unset FLAG_KYOGRE_ESCAPED_SEAFLOOR_CAVERN, SootopolisCity_Mart_EventScript_22680C
msgbox SootopolisCity_Mart_Text_226928, MSGBOX_DEFAULT
diff --git a/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc b/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc
index d107037d4..c7ceb0a4f 100644
--- a/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc
+++ b/data/maps/SootopolisCity_MysteryEventsHouse_1F/scripts.inc
@@ -129,7 +129,7 @@ SootopolisCity_MysteryEventsHouse_1F_EventScript_227AE2:: @ 8227AE2
SootopolisCity_MysteryEventsHouse_1F_EventScript_227AEF:: @ 8227AEF
msgbox SootopolisCity_MysteryEventsHouse_1F_Text_227C84, MSGBOX_DEFAULT
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
return
diff --git a/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc b/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc
index 96f766f7b..97cb2d4d7 100644
--- a/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc
+++ b/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc
@@ -18,7 +18,7 @@ SootopolisCity_PokemonCenter_1F_EventScript_226500:: @ 8226500
SootopolisCity_PokemonCenter_1F_EventScript_22650E:: @ 822650E
lock
faceplayer
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
goto_if_ge SootopolisCity_PokemonCenter_1F_EventScript_22652E
goto_if_unset FLAG_KYOGRE_ESCAPED_SEAFLOOR_CAVERN, SootopolisCity_PokemonCenter_1F_EventScript_22652E
msgbox SootopolisCity_PokemonCenter_1F_Text_22664B, MSGBOX_DEFAULT
@@ -33,7 +33,7 @@ SootopolisCity_PokemonCenter_1F_EventScript_22652E:: @ 822652E
SootopolisCity_PokemonCenter_1F_EventScript_226538:: @ 8226538
lock
faceplayer
- compare VAR_0x40CA, 2
+ compare VAR_SKY_PILLAR_STATE, 2
goto_if_ge SootopolisCity_PokemonCenter_1F_EventScript_226558
goto_if_unset FLAG_KYOGRE_ESCAPED_SEAFLOOR_CAVERN, SootopolisCity_PokemonCenter_1F_EventScript_226558
msgbox SootopolisCity_PokemonCenter_1F_Text_22672F, MSGBOX_DEFAULT
diff --git a/data/maps/SouthernIsland_Interior/scripts.inc b/data/maps/SouthernIsland_Interior/scripts.inc
index a24bc772f..958c5f546 100644
--- a/data/maps/SouthernIsland_Interior/scripts.inc
+++ b/data/maps/SouthernIsland_Interior/scripts.inc
@@ -15,9 +15,9 @@ SouthernIsland_Interior_EventScript_242A5A:: @ 8242A5A
return
SouthernIsland_Interior_MapScript1_242A6E: @ 8242A6E
- compare VAR_0x40D5, 0
+ compare VAR_ROAMER_POKEMON, 0
call_if_eq SouthernIsland_Interior_EventScript_242A8A
- compare VAR_0x40D5, 0
+ compare VAR_ROAMER_POKEMON, 0
call_if_ne SouthernIsland_Interior_EventScript_242A95
call SouthernIsland_Interior_EventScript_242AA0
end
@@ -77,9 +77,9 @@ SouthernIsland_Interior_EventScript_242AD0:: @ 8242AD0
delay 50
special RemoveCameraObject
setvar VAR_LAST_TALKED, 2
- compare VAR_0x40D5, 0
+ compare VAR_ROAMER_POKEMON, 0
call_if_eq SouthernIsland_Interior_EventScript_242BA4
- compare VAR_0x40D5, 0
+ compare VAR_ROAMER_POKEMON, 0
call_if_ne SouthernIsland_Interior_EventScript_242BB7
setflag FLAG_SYS_CTRL_OBJ_DELETE
special BattleSetup_StartLatiBattle
diff --git a/data/maps/TerraCave_End/scripts.inc b/data/maps/TerraCave_End/scripts.inc
index 3f892315d..b5a664a76 100644
--- a/data/maps/TerraCave_End/scripts.inc
+++ b/data/maps/TerraCave_End/scripts.inc
@@ -47,13 +47,13 @@ TerraCave_End_EventScript_23B0EC:: @ 823B0EC
goto_if_eq TerraCave_End_EventScript_23B163
compare VAR_RESULT, 5
goto_if_eq TerraCave_End_EventScript_23B163
- setvar VAR_0x4039, 1
+ setvar VAR_SHOULD_END_UNUSUAL_WEATHER, 1
setflag FLAG_DEFEATED_GROUDON
releaseall
end
TerraCave_End_EventScript_23B155:: @ 823B155
- setvar VAR_0x4039, 1
+ setvar VAR_SHOULD_END_UNUSUAL_WEATHER, 1
setflag FLAG_DEFEATED_GROUDON
goto TerraCave_End_EventScript_27376D
end
diff --git a/data/maps/TradeCenter/map.json b/data/maps/TradeCenter/map.json
index 257c7d1c8..1c409132d 100644
--- a/data/maps/TradeCenter/map.json
+++ b/data/maps/TradeCenter/map.json
@@ -52,7 +52,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_082773F5"
+ "script": "EventScript_TradeCenter_Chair0"
},
{
"type": "trigger",
@@ -61,7 +61,7 @@
"elevation": 3,
"var": "VAR_TEMP_0",
"var_value": "0",
- "script": "gUnknown_082773FF"
+ "script": "EventScript_TradeCenter_Chair1"
}
],
"bg_events": []
diff --git a/data/maps/TrainerHill_Entrance/map.json b/data/maps/TrainerHill_Entrance/map.json
index 4b12b1c80..42f1daa9d 100644
--- a/data/maps/TrainerHill_Entrance/map.json
+++ b/data/maps/TrainerHill_Entrance/map.json
@@ -109,7 +109,7 @@
"x": 9,
"y": 6,
"elevation": 3,
- "var": "VAR_0x40D6",
+ "var": "VAR_TRAINER_HILL_IS_ACTIVE",
"var_value": "0",
"script": "TrainerHill_Entrance_EventScript_268229"
}
diff --git a/data/maps/TrainerHill_Entrance/scripts.inc b/data/maps/TrainerHill_Entrance/scripts.inc
index 5339f49e3..63e067a9a 100644
--- a/data/maps/TrainerHill_Entrance/scripts.inc
+++ b/data/maps/TrainerHill_Entrance/scripts.inc
@@ -15,10 +15,10 @@ TrainerHill_Entrance_MapScript1_2680CF: @ 82680CF
end
TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0
- setvar VAR_0x8004, 4
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_RESUME_TIMER
special CallTrainerHillFunction
setvar VAR_TEMP_0, 0
- setvar VAR_0x8004, 9
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_9
special CallTrainerHillFunction
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_2680FF
@@ -27,7 +27,7 @@ TrainerHill_Entrance_MapScript1_2680D0: @ 82680D0
end
TrainerHill_Entrance_EventScript_2680FF:: @ 82680FF
- setvar VAR_0x8004, 16
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_16
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_Entrance_EventScript_26811A
@@ -74,12 +74,12 @@ TrainerHill_Entrance_EventScript_268160:: @ 8268160
TrainerHill_Entrance_EventScript_268182:: @ 8268182
setvar VAR_TEMP_0, 1
- setvar VAR_0x8004, 6
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS
special CallTrainerHillFunction
switch VAR_RESULT
- case 0, TrainerHill_Entrance_EventScript_2681B5
- case 1, TrainerHill_Entrance_EventScript_2681CA
- case 2, TrainerHill_Entrance_EventScript_2681EE
+ case TRAINER_HILL_PLAYER_STATUS_LOST, TrainerHill_Entrance_EventScript_2681B5
+ case TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED, TrainerHill_Entrance_EventScript_2681CA
+ case TRAINER_HILL_PLAYER_STATUS_NORMAL, TrainerHill_Entrance_EventScript_2681EE
TrainerHill_Entrance_EventScript_2681B5:: @ 82681B5
lockall
@@ -96,7 +96,7 @@ TrainerHill_Entrance_EventScript_2681DA:: @ 82681DA
closemessage
applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_268381
waitmovement 0
- setvar VAR_0x40D6, 0
+ setvar VAR_TRAINER_HILL_IS_ACTIVE, 0
special HealPlayerParty
releaseall
@@ -114,7 +114,7 @@ TrainerHill_Entrance_EventScript_2681EF:: @ 82681EF
TrainerHill_Entrance_EventScript_2681FD:: @ 82681FD
lock
faceplayer
- setvar VAR_0x8004, 10
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_10
special CallTrainerHillFunction
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_26821F
@@ -133,11 +133,11 @@ TrainerHill_Entrance_EventScript_268229:: @ 8268229
applymovement EVENT_OBJ_ID_PLAYER, TrainerHill_Entrance_Movement_26837F
goto_if_unset FLAG_SYS_GAME_CLEAR, TrainerHill_Entrance_EventScript_26836A
msgbox TrainerHill_Entrance_Text_2684C6, MSGBOX_DEFAULT
- setvar VAR_0x8004, 13
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_13
special CallTrainerHillFunction
compare VAR_RESULT, 0
call_if_eq TrainerHill_Entrance_EventScript_26832E
- setvar VAR_0x8004, 8
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_8
special CallTrainerHillFunction
compare VAR_RESULT, 1
goto_if_eq TrainerHill_Entrance_EventScript_268275
@@ -168,14 +168,14 @@ TrainerHill_Entrance_EventScript_2682C8:: @ 82682C8
switch VAR_RESULT
case 4, TrainerHill_Entrance_EventScript_268314
case 127, TrainerHill_Entrance_EventScript_268314
- setvar VAR_0x8004, 17
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_SET_TAG
copyvar VAR_0x8005, VAR_RESULT
special CallTrainerHillFunction
- setvar VAR_0x40D6, 1
+ setvar VAR_TRAINER_HILL_IS_ACTIVE, 1
setvar VAR_TEMP_5, 0
special HealPlayerParty
msgbox TrainerHill_Entrance_Text_26862A, MSGBOX_DEFAULT
- setvar VAR_0x8004, 0
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_START
special CallTrainerHillFunction
releaseall
end
@@ -191,18 +191,18 @@ TrainerHill_Entrance_EventScript_268314:: @ 8268314
TrainerHill_Entrance_EventScript_26832E:: @ 826832E
msgbox TrainerHill_Entrance_Text_26851C, MSGBOX_DEFAULT
- setvar VAR_0x8004, 14
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_14
special CallTrainerHillFunction
setvar VAR_TEMP_5, 1
call Common_EventScript_SaveGame
compare VAR_RESULT, 0
goto_if_eq TrainerHill_Entrance_EventScript_26835C
- setvar VAR_0x8004, 14
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_14
special CallTrainerHillFunction
return
TrainerHill_Entrance_EventScript_26835C:: @ 826835C
- setvar VAR_0x8004, 15
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_15
special CallTrainerHillFunction
goto TrainerHill_Entrance_EventScript_268314
end
diff --git a/data/maps/TrainerHill_Roof/scripts.inc b/data/maps/TrainerHill_Roof/scripts.inc
index fc1ca200f..bf467e100 100644
--- a/data/maps/TrainerHill_Roof/scripts.inc
+++ b/data/maps/TrainerHill_Roof/scripts.inc
@@ -4,11 +4,11 @@ TrainerHill_Roof_MapScripts:: @ 8268FA7
.byte 0
TrainerHill_Roof_EventScript_268FB2:: @ 8268FB2
- setvar VAR_0x8004, 12
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_12
special CallTrainerHillFunction
lock
faceplayer
- setvar VAR_0x8004, 1
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_1
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_268FEA
@@ -19,7 +19,7 @@ TrainerHill_Roof_EventScript_268FEA:: @ 8268FEA
msgbox TrainerHill_Roof_Text_268986, MSGBOX_DEFAULT
TrainerHill_Roof_EventScript_268FF2:: @ 8268FF2
- setvar VAR_0x8004, 2
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_2
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_269020
@@ -41,7 +41,7 @@ TrainerHill_Roof_EventScript_269037:: @ 8269037
goto TrainerHill_Roof_EventScript_269054
TrainerHill_Roof_EventScript_269054:: @ 8269054
- setvar VAR_0x8004, 3
+ setvar VAR_0x8004, TRAINER_HILL_FUNC_3
special CallTrainerHillFunction
switch VAR_RESULT
case 0, TrainerHill_Roof_EventScript_269082
diff --git a/data/maps/Underwater3/scripts.inc b/data/maps/Underwater3/scripts.inc
index 99f0efcf0..53b80053f 100644
--- a/data/maps/Underwater3/scripts.inc
+++ b/data/maps/Underwater3/scripts.inc
@@ -3,6 +3,6 @@ Underwater3_MapScripts:: @ 81F7724
.byte 0
Underwater3_MapScript1_1F772A: @ 81F772A
- call Underwater3_EventScript_274223
+ call UnusualWeather_Underwater_SetupEscapeWarp
end
diff --git a/data/maps/Underwater5/scripts.inc b/data/maps/Underwater5/scripts.inc
index ea37514eb..fe068207e 100644
--- a/data/maps/Underwater5/scripts.inc
+++ b/data/maps/Underwater5/scripts.inc
@@ -3,6 +3,6 @@ Underwater5_MapScripts:: @ 81F7731
.byte 0
Underwater5_MapScript1_1F7737: @ 81F7737
- call Underwater5_EventScript_274223
+ call UnusualWeather_Underwater_SetupEscapeWarp
end
diff --git a/data/maps/Underwater6/scripts.inc b/data/maps/Underwater6/scripts.inc
index fee91dc75..d5a11c1bf 100644
--- a/data/maps/Underwater6/scripts.inc
+++ b/data/maps/Underwater6/scripts.inc
@@ -3,6 +3,6 @@ Underwater6_MapScripts:: @ 81F773D
.byte 0
Underwater6_MapScript1_1F7743: @ 81F7743
- call Underwater6_EventScript_274223
+ call UnusualWeather_Underwater_SetupEscapeWarp
end
diff --git a/data/maps/Underwater7/scripts.inc b/data/maps/Underwater7/scripts.inc
index a0eba386a..c3bee154e 100644
--- a/data/maps/Underwater7/scripts.inc
+++ b/data/maps/Underwater7/scripts.inc
@@ -3,6 +3,6 @@ Underwater7_MapScripts:: @ 81F7749
.byte 0
Underwater7_MapScript1_1F774F: @ 81F774F
- call Underwater7_EventScript_274223
+ call UnusualWeather_Underwater_SetupEscapeWarp
end
diff --git a/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc b/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc
index f6bb194a3..daaaaea1b 100644
--- a/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc
+++ b/data/maps/VerdanturfTown_BattleTentLobby/scripts.inc
@@ -307,7 +307,7 @@ VerdanturfTown_BattleTentLobby_EventScript_201AD0:: @ 8201AD0
faceplayer
goto_if_set FLAG_MET_SCOTT_IN_VERDANTURF, VerdanturfTown_BattleTentLobby_EventScript_201AED
msgbox VerdanturfTown_BattleTentLobby_Text_201F3F, MSGBOX_DEFAULT
- addvar VAR_0x40D1, 1
+ addvar VAR_SCOTT_STATE, 1
setflag FLAG_MET_SCOTT_IN_VERDANTURF
release
end
diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc
index 0858dfabb..1914fee4f 100644
--- a/data/scripts/cable_club.inc
+++ b/data/scripts/cable_club.inc
@@ -74,7 +74,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276B23:: @ 8276B23
msgbox gUnknown_08273594, MSGBOX_DEFAULT
giveitem_std ITEM_EON_TICKET
setflag FLAG_SYS_HAS_EON_TICKET
- setvar VAR_0x403F, 0
+ setvar VAR_ALWAYS_ZERO_0x403F, 0
msgbox gUnknown_082735F2, MSGBOX_DEFAULT
release
end
@@ -197,7 +197,7 @@ RustboroCity_PokemonCenter_2F_MapScript2_276C3B: @ 8276C3B
SlateportCity_PokemonCenter_2F_MapScript2_276C3B: @ 8276C3B
SootopolisCity_PokemonCenter_2F_MapScript2_276C3B: @ 8276C3B
VerdanturfTown_PokemonCenter_2F_MapScript2_276C3B: @ 8276C3B
- map_script_2 VAR_0x40CD, 1, OldaleTown_PokemonCenter_2F_EventScript_276DE0
+ map_script_2 VAR_CABLE_CLUB_TUTORIAL_STATE, 1, OldaleTown_PokemonCenter_2F_EventScript_276DE0
map_script_2 VAR_CABLE_CLUB_STATE, 1, OldaleTown_PokemonCenter_2F_EventScript_276C85
map_script_2 VAR_CABLE_CLUB_STATE, 2, OldaleTown_PokemonCenter_2F_EventScript_276C85
map_script_2 VAR_CABLE_CLUB_STATE, 5, OldaleTown_PokemonCenter_2F_EventScript_276C85
@@ -336,7 +336,7 @@ OldaleTown_PokemonCenter_2F_EventScript_276DE0:: @ 8276DE0
waitmovement 0
delay 30
msgbox OldaleTown_PokemonCenter_2F_Text_279718, MSGBOX_DEFAULT
- setvar VAR_0x40CD, 2
+ setvar VAR_CABLE_CLUB_TUTORIAL_STATE, 2
releaseall
end
@@ -791,116 +791,118 @@ EventScript_CableBoxResults:: @ 8277365
releaseall
end
-gUnknown_08277374:: @ 8277374
+EventScript_SingleBattleColosseum_PlayerSpot0:: @ 8277374
setvar VAR_0x8005, 0
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-gUnknown_0827737E:: @ 827737E
+EventScript_SingleBattleColosseum_PlayerSpot1:: @ 827737E
setvar VAR_0x8005, 1
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-gUnknown_08277388:: @ 8277388
+EventScript_DoubleBattleColosseum_PlayerSpot0:: @ 8277388
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
- goto_if_eq DoubleBattleColosseum_EventScript_2773F4
+ goto_if_eq EventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 0
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-gUnknown_082773A3:: @ 82773A3
+EventScript_DoubleBattleColosseum_PlayerSpot1:: @ 82773A3
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
- goto_if_eq DoubleBattleColosseum_EventScript_2773F4
+ goto_if_eq EventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 1
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-gUnknown_082773BE:: @ 82773BE
+EventScript_DoubleBattleColosseum_PlayerSpot2:: @ 82773BE
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
- goto_if_eq DoubleBattleColosseum_EventScript_2773F4
+ goto_if_eq EventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 2
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-gUnknown_082773D9:: @ 82773D9
+EventScript_DoubleBattleColosseum_PlayerSpot3:: @ 82773D9
fadescreen 1
- special sub_80F9438
+ special ChooseHalfPartyForBattle
waitstate
compare VAR_RESULT, 0
- goto_if_eq DoubleBattleColosseum_EventScript_2773F4
+ goto_if_eq EventScript_DoubleBattleColosseum_CancelSpotTrigger
setvar VAR_0x8005, 3
- special sub_80B3968
+ special ColosseumPlayerSpotTriggered
waitstate
end
-DoubleBattleColosseum_EventScript_2773F4:: @ 82773F4
+EventScript_DoubleBattleColosseum_CancelSpotTrigger:: @ 82773F4
end
-gUnknown_082773F5:: @ 82773F5
+EventScript_TradeCenter_Chair0:: @ 82773F5
setvar VAR_0x8005, 0
- special sub_80B3924
+ special PlayerEnteredTradeSeat
waitstate
end
-gUnknown_082773FF:: @ 82773FF
+EventScript_TradeCenter_Chair1:: @ 82773FF
setvar VAR_0x8005, 1
- special sub_80B3924
+ special PlayerEnteredTradeSeat
waitstate
end
-gUnknown_08277409:: @ 8277409
+/* Never used */
+EventScript_TradeCenter_Chair2:: @ 8277409
setvar VAR_0x8005, 2
- special sub_80B3924
+ special PlayerEnteredTradeSeat
waitstate
end
-gUnknown_08277413:: @ 8277413
+/* Never used */
+EventScript_TradeCenter_Chair3:: @ 8277413
setvar VAR_0x8005, 3
- special sub_80B3924
+ special PlayerEnteredTradeSeat
waitstate
end
-gUnknown_0827741D:: @ 827741D
+EventScript_RecordCenter_Spot0:: @ 827741D
setvar VAR_0x8005, 0
- special sub_80E6BE8
+ special RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
-gUnknown_08277432:: @ 8277432
+EventScript_RecordCenter_Spot1:: @ 8277432
setvar VAR_0x8005, 1
- special sub_80E6BE8
+ special RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
-gUnknown_08277447:: @ 8277447
+EventScript_RecordCenter_Spot2:: @ 8277447
setvar VAR_0x8005, 2
- special sub_80E6BE8
+ special RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
end
-gUnknown_0827745C:: @ 827745C
+EventScript_RecordCenter_Spot3:: @ 827745C
setvar VAR_0x8005, 3
- special sub_80E6BE8
+ special RecordMixingPlayerSpotTriggered
waitstate
compare VAR_TEMP_1, 0
goto_if_ne RecordCorner_EventScript_277471
@@ -914,21 +916,21 @@ RecordCorner_EventScript_277471:: @ 8277471
releaseall
end
-EventScript_TradeRoom_ReadTrainerCard1:: @ 827747E
+gEventScript_TradeRoom_ReadTrainerCard_NoColor:: @ 827747E
msgbox Text_278452, MSGBOX_DEFAULT
fadescreen 1
special sp02A_crash_sound
waitstate
end
-EventScript_TradeRoom_ReadTrainerCard2:: @ 827748D
+gEventScript_TradeRoom_ReadTrainerCard_Normal:: @ 827748D
msgbox Text_27847B, MSGBOX_DEFAULT
fadescreen 1
special sp02A_crash_sound
waitstate
end
-EventScript_TradeRoom_TooBusyToNotice:: @ 827749C
+gEventScript_TradeRoom_TooBusyToNotice:: @ 827749C
msgbox Text_27842E, MSGBOX_DEFAULT
closemessage
end
@@ -967,22 +969,22 @@ RecordCorner_EventScript_2774E0:: @ 82774E0
closemessage
end
-gUnknown_082774EF:: @ 82774EF
- msgbox Text_2783A8, MSGBOX_YESNO
+EventScript_ConfirmLeaveTradeRoom:: @ 82774EF
+ msgbox Text_TerminateLinkConfirmation, MSGBOX_YESNO
compare VAR_RESULT, 1
- goto_if_eq gUnknown_08277509
+ goto_if_eq EventScript_TerminateLink
erasebox 0, 0, 29, 19
releaseall
end
-gUnknown_08277509:: @ 8277509
- messageautoscroll Text_2783E9
+EventScript_TerminateLink:: @ 8277509
+ messageautoscroll Text_TerminateLinkPleaseWait
waitmessage
- special sub_80B371C
+ special ExitLinkRoom
end
-EventScript_277513:: @ 8277513
- special sub_80B36EC
+EventScript_DoLinkRoomExit:: @ 8277513
+ special CleanupLinkRoomState
special sub_80AF9F8
waitstate
end
@@ -1736,11 +1738,11 @@ OldaleTown_PokemonCenter_2F_Text_278372: @ 8278372
.string "Please confirm the number of\n"
.string "players and start again.$"
-Text_2783A8: @ 82783A8
+Text_TerminateLinkConfirmation: @ 82783A8
.string "The link will be terminated if you\n"
.string "leave the room. Is that okay?$"
-Text_2783E9: @ 82783E9
+Text_TerminateLinkPleaseWait: @ 82783E9
.string "Terminating link…\n"
.string "You will be escorted out of\l"
.string "the room. Please wait.$"
diff --git a/data/scripts/players_house.inc b/data/scripts/players_house.inc
index 306157561..c4a5ffe86 100644
--- a/data/scripts/players_house.inc
+++ b/data/scripts/players_house.inc
@@ -510,7 +510,7 @@ LittlerootTown_MaysHouse_1F_EventScript_292AF2:: @ 8292AF2
multichoice 22, 8, 108, 1
copyvar VAR_0x8004, VAR_RESULT
special InitRoamer
- copyvar VAR_0x40D5, VAR_RESULT
+ copyvar VAR_ROAMER_POKEMON, VAR_RESULT
msgbox LittlerootTown_BrendansHouse_1F_Text_1F83A1, MSGBOX_DEFAULT
closemessage
setvar VAR_LITTLEROOT_HOUSES_STATE, 4
@@ -518,6 +518,7 @@ LittlerootTown_MaysHouse_1F_EventScript_292AF2:: @ 8292AF2
releaseall
end
+@ Never called.
LittlerootTown_BrendansHouse_1F_EventScript_292C72:: @ 8292C72
setflag FLAG_SYS_TV_LATIAS_LATIOS
return
diff --git a/data/scripts/secret_base.inc b/data/scripts/secret_base.inc
index 770bc9a5b..6302a33a8 100644
--- a/data/scripts/secret_base.inc
+++ b/data/scripts/secret_base.inc
@@ -430,21 +430,21 @@ EventScript_275B4D:: @ 8275B4D
EventScript_275B5B:: @ 8275B5B
closemessage
playse SE_KAIDAN
- setvar VAR_0x4097, 0
+ setvar VAR_INIT_SECRET_BASE, 0
setflag FLAG_DECORATION_0
special sub_80E8E18
special sub_80E9068
setvar VAR_0x8004, 0
setvar VAR_0x8005, 0
special sub_80E933C
- setvar VAR_0x4089, 1
+ setvar VAR_SECRET_BASE_INITIALIZED, 1
waitstate
end
SecretBase_RedCave1_EventScript_275B81:: @ 8275B81
applymovement EVENT_OBJ_ID_PLAYER, SecretBase_RedCave1_Movement_275BB4
waitmovement 0
- setvar VAR_0x4097, 1
+ setvar VAR_INIT_SECRET_BASE, 1
msgbox SecretBase_RedCave1_Text_23B759, MSGBOX_YESNO
compare VAR_RESULT, 1
goto_if_eq SecretBase_RedCave1_EventScript_275BAB
@@ -467,21 +467,21 @@ SecretBase_RedCave1_Movement_275BB4: @ 8275BB4
EventScript_275BB7:: @ 8275BB7
lockall
- setvar VAR_0x4097, 1
+ setvar VAR_INIT_SECRET_BASE, 1
playse SE_KAIDAN
special sub_80E9744
compare VAR_RESULT, 0
goto_if_eq EventScript_275BDB
clearflag FLAG_DECORATION_0
special sub_80E9068
- setvar VAR_0x4089, 0
+ setvar VAR_SECRET_BASE_INITIALIZED, 0
waitstate
end
EventScript_275BDB:: @ 8275BDB
setflag FLAG_DECORATION_0
special sub_80E9068
- setvar VAR_0x4089, 0
+ setvar VAR_SECRET_BASE_INITIALIZED, 0
waitstate
end
@@ -570,7 +570,7 @@ EventScript_275D0C:: @ 8275D0C
setvar VAR_0x8004, 0
setvar VAR_0x8005, 0
special sub_80E933C
- setvar VAR_0x4089, 1
+ setvar VAR_SECRET_BASE_INITIALIZED, 1
end
EventScript_275D1F:: @ 8275D1F
diff --git a/data/scripts/tv.inc b/data/scripts/tv.inc
index acc75f76a..4a276ffc0 100644
--- a/data/scripts/tv.inc
+++ b/data/scripts/tv.inc
@@ -42,6 +42,9 @@ EventScript_27EE9A:: @ 827EE9A
EventScript_27EEA4:: @ 827EEA4
msgbox LittlerootTown_BrendansHouse_1F_Text_1F826F, MSGBOX_DEFAULT
+ @ This is a junk call. Its input var (VAR_0x8004) hasn't been set, and
+ @ It's called again when Mom actually asks for the color, overwriting
+ @ whatever it does here.
special InitRoamer
clearflag FLAG_SYS_TV_LATIAS_LATIOS
setflag FLAG_LATIOS_OR_LATIAS_ROAMING
diff --git a/data/specials.inc b/data/specials.inc
index e7f5e6072..d57c76bde 100644
--- a/data/specials.inc
+++ b/data/specials.inc
@@ -12,8 +12,8 @@ gSpecials:: @ 81DBA64
def_special SetCableClubWarp
def_special sub_80AF948
def_special sub_80AF9F8
- def_special sub_80B36EC
- def_special sub_80B371C
+ def_special CleanupLinkRoomState
+ def_special ExitLinkRoom
def_special sub_80E8E18
def_special sub_80E8BC8
def_special sub_80E9068
@@ -35,14 +35,14 @@ gSpecials:: @ 81DBA64
def_special sub_80E91F8
def_special sub_80EA30C
def_special DoSecretBasePCTurnOffEffect
- def_special sub_80E6BE8
+ def_special RecordMixingPlayerSpotTriggered
def_special sub_80B2DA4
def_special sub_80B2E4C
def_special sub_80B2E74
def_special sub_80B2EA8
def_special CloseLink
- def_special sub_80B3968
- def_special sub_80B3924
+ def_special ColosseumPlayerSpotTriggered
+ def_special PlayerEnteredTradeSeat
def_special nullsub_37
def_special sub_80B3254
def_special sub_80B2FD8
@@ -50,7 +50,7 @@ gSpecials:: @ 81DBA64
def_special SpawnLinkPartnerEventObject
def_special SavePlayerParty
def_special LoadPlayerParty
- def_special sub_80F9438
+ def_special ChooseHalfPartyForBattle
def_special sp02A_crash_sound
def_special EventObjectInteractionGetBerryTreeData
def_special EventObjectInteractionGetBerryName
@@ -499,8 +499,8 @@ gSpecials:: @ 81DBA64
def_special sub_813B21C
def_special SetMatchCallRegisteredFlag
def_special sub_8175280
- def_special sub_813B2E4
- def_special sub_813B374
+ def_special CreateUnusualWeatherEvent
+ def_special GetUnusualWeatherMapNameAndType
def_special sub_813B490
def_special sub_80A08CC
def_special Unused_SetWeatherSunny
diff --git a/include/agb_flash.h b/include/agb_flash.h
index 27e45e8fa..ba5820f01 100644
--- a/include/agb_flash.h
+++ b/include/agb_flash.h
@@ -8,5 +8,7 @@
// Exported ROM declarations
u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
+u16 IdentifyFlash(void);
+u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src);
#endif //GUARD_AGB_FLASH_H
diff --git a/include/battle.h b/include/battle.h
index 94596c75e..d155ca5a0 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -175,7 +175,7 @@ struct ProtectStruct
u32 targetNotAffected:1;
u32 chargingTurn:1;
u32 fleeFlag:2; // For RunAway and Smoke Ball.
- u32 usedImprisionedMove:1;
+ u32 usedImprisonedMove:1;
u32 loveImmobility:1;
u32 usedDisabledMove:1;
u32 usedTauntedMove:1;
diff --git a/include/battle_anim.h b/include/battle_anim.h
index d0d323216..b3350f893 100644
--- a/include/battle_anim.h
+++ b/include/battle_anim.h
@@ -204,6 +204,9 @@ void sub_80A718C(struct Sprite *sprite);
#define STAT_ANIM_MULTIPLE_MINUS2 58
void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId);
+// battle_anim_8170478.c
+void sub_8172EF0(u8 battler, struct Pokemon *mon);
+
// ground.c
void sub_81152DC(u8 taskId);
@@ -216,6 +219,19 @@ u8 LaunchBallFadeMonTask(bool8 unFadeLater, u8 battlerId, u32 selectedPalettes,
void sub_8116EB4(u8);
void sub_8117854(u8 taskId, int unused, u16 arg2, u8 battler1, u8 arg4, u8 arg5, u8 arg6, u8 arg7, const u32 *arg8, const u32 *arg9, const u32 *palette);
+// battle_anim_effects_1.c
+void sub_810310C(u8 battler, struct Sprite* sprite);
+void AnimMoveTwisterParticle(struct Sprite* sprite);
+
+// water.c
+void sub_8108C94(struct Sprite *sprite);
+
+// flying.c
+void sub_810E2C8(struct Sprite *sprite);
+
+// smokescreen.c
+u8 sub_807521C(s16 x, s16 y, u8 a3);
+
u32 UnpackSelectedBattleAnimPalettes(s16);
u8 GetBattlerSpriteFinal_Y(u8, u16, u8);
diff --git a/include/battle_scripts.h b/include/battle_scripts.h
index a23fa6948..cac3a7652 100644
--- a/include/battle_scripts.h
+++ b/include/battle_scripts.h
@@ -88,8 +88,8 @@ extern const u8 BattleScript_IngrainTurnHeal[];
extern const u8 BattleScript_AtkDefDown[];
extern const u8 BattleScript_KnockedOff[];
extern const u8 BattleScript_MoveUsedIsImprisoned[];
-extern const u8 BattleScript_SelectingImprisionedMove[];
-extern const u8 BattleScript_SelectingImprisionedMoveInPalace[];
+extern const u8 BattleScript_SelectingImprisonedMove[];
+extern const u8 BattleScript_SelectingImprisonedMoveInPalace[];
extern const u8 BattleScript_GrudgeTakesPp[];
extern const u8 BattleScript_MagicCoatBounce[];
extern const u8 BattleScript_SnatchedMove[];
@@ -115,7 +115,7 @@ extern const u8 BattleScript_PrintPayDayMoneyString[];
extern const u8 BattleScript_WrapTurnDmg[];
extern const u8 BattleScript_WrapEnds[];
extern const u8 BattleScript_MoveUsedIsInLove[];
-extern const u8 BattleScript_MoveUsedIsParalyzedCantAttack[];
+extern const u8 BattleScript_MoveUsedIsInLoveCantAttack[];
extern const u8 BattleScript_NightmareTurnDmg[];
extern const u8 BattleScript_CurseTurnDmg[];
extern const u8 BattleScript_TargetPRLZHeal[];
diff --git a/include/battle_util.h b/include/battle_util.h
index 71bb22a00..0756a387a 100644
--- a/include/battle_util.h
+++ b/include/battle_util.h
@@ -6,7 +6,7 @@
#define MOVE_LIMITATION_DISABLED (1 << 2)
#define MOVE_LIMITATION_TORMENTED (1 << 3)
#define MOVE_LIMITATION_TAUNT (1 << 4)
-#define MOVE_LIMITATION_IMPRISION (1 << 5)
+#define MOVE_LIMITATION_IMPRISON (1 << 5)
#define ABILITYEFFECT_ON_SWITCHIN 0x0
#define ABILITYEFFECT_ENDTURN 0x1
@@ -44,7 +44,7 @@
u8 GetBattlerForBattleScript(u8 caseId);
void PressurePPLose(u8 target, u8 attacker, u16 move);
void PressurePPLoseOnUsingPerishSong(u8 attacker);
-void PressurePPLoseOnUsingImprision(u8 attacker);
+void PressurePPLoseOnUsingImprison(u8 attacker);
void MarkAllBattlersForControllerExec(void); // unused
void MarkBattlerForControllerExec(u8 battlerId);
void sub_803F850(u8 arg0);
diff --git a/include/cable_club.h b/include/cable_club.h
index 60d56460d..c2849ca3e 100644
--- a/include/cable_club.h
+++ b/include/cable_club.h
@@ -15,6 +15,6 @@ void sub_80B360C(void);
bool32 sub_80B2AF4(u16 *arg0, u16 *arg1);
void sub_80B3AF8(u8 taskId);
void task00_08081A90(u8 taskId);
-bool32 sub_80B39D4(u8 linkPlayerIndex);
+bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex);
#endif //GUARD_CABLE_CLUB_H
diff --git a/include/constants/battle_frontier.h b/include/constants/battle_frontier.h
index ca9e3bc9f..1224c0f31 100644
--- a/include/constants/battle_frontier.h
+++ b/include/constants/battle_frontier.h
@@ -10,6 +10,8 @@
#define FRONTIER_FACILITY_PIKE 5
#define FRONTIER_FACILITY_PYRAMID 6
#define NUM_FRONTIER_FACILITIES 7
+// The multiplayer battle colosseum rooms re-use VAR_FRONTIER_FACILITY.
+#define FRONTIER_FACILITY_DOUBLE_COLOSSEUM 9
#define TENT_VERDANTURF 2
#define TENT_FALLARBOR 3
diff --git a/include/constants/flags.h b/include/constants/flags.h
index b440ba78b..f0759389f 100644
--- a/include/constants/flags.h
+++ b/include/constants/flags.h
@@ -236,7 +236,7 @@
#define FLAG_MET_WAILMER_TRAINER 0xDA
#define FLAG_EVIL_LEADER_PLEASE_STOP 0xDB
-#define FLAG_UNUSED_0x0DC 0xDC // Unused Flag
+#define FLAG_NEVER_SET_0x0DC 0xDC // This flag is read, but never written to
#define FLAG_RECEIVED_GO_GOGGLES 0xDD
#define FLAG_WINGULL_SENT_ON_ERRAND 0xDE
diff --git a/include/constants/map_types.h b/include/constants/map_types.h
index 504575859..8d071fd41 100755
--- a/include/constants/map_types.h
+++ b/include/constants/map_types.h
@@ -1,14 +1,14 @@
#ifndef GUARD_CONSTANTS_MAP_TYPES_H
#define GUARD_CONSTANTS_MAP_TYPES_H
-#define MAP_TYPE_0 0
+#define MAP_TYPE_UNUSED_1 0
#define MAP_TYPE_TOWN 1
#define MAP_TYPE_CITY 2
#define MAP_TYPE_ROUTE 3
#define MAP_TYPE_UNDERGROUND 4
#define MAP_TYPE_UNDERWATER 5
-#define MAP_TYPE_6 6
-#define MAP_TYPE_7 7
+#define MAP_TYPE_OCEAN_ROUTE 6
+#define MAP_TYPE_UNUSED_2 7
#define MAP_TYPE_INDOOR 8
#define MAP_TYPE_SECRET_BASE 9
diff --git a/include/constants/trainer_hill.h b/include/constants/trainer_hill.h
new file mode 100644
index 000000000..e231a6043
--- /dev/null
+++ b/include/constants/trainer_hill.h
@@ -0,0 +1,29 @@
+#ifndef GUARD_CONSTANTS_TRAINER_HILL_H
+#define GUARD_CONSTANTS_TRAINER_HILL_H
+
+#define TRAINER_HILL_FUNC_START 0
+#define TRAINER_HILL_FUNC_1 1
+#define TRAINER_HILL_FUNC_2 2
+#define TRAINER_HILL_FUNC_3 3
+#define TRAINER_HILL_FUNC_RESUME_TIMER 4
+#define TRAINER_HILL_FUNC_SET_LOST 5
+#define TRAINER_HILL_FUNC_GET_CHALLENGE_STATUS 6
+#define TRAINER_HILL_FUNC_7 7
+#define TRAINER_HILL_FUNC_8 8
+#define TRAINER_HILL_FUNC_9 9
+#define TRAINER_HILL_FUNC_10 10
+#define TRAINER_HILL_FUNC_11 11
+#define TRAINER_HILL_FUNC_12 12
+#define TRAINER_HILL_FUNC_13 13
+#define TRAINER_HILL_FUNC_14 14
+#define TRAINER_HILL_FUNC_15 15
+#define TRAINER_HILL_FUNC_16 16
+#define TRAINER_HILL_FUNC_SET_TAG 17
+
+// Values returned by the TrainerHillGetChallengeStatus
+// function.
+#define TRAINER_HILL_PLAYER_STATUS_LOST 0
+#define TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED 1
+#define TRAINER_HILL_PLAYER_STATUS_NORMAL 2
+
+#endif \ No newline at end of file
diff --git a/include/constants/vars.h b/include/constants/vars.h
index fc3b3263d..c025d62fc 100644
--- a/include/constants/vars.h
+++ b/include/constants/vars.h
@@ -1,7 +1,7 @@
#ifndef GUARD_CONSTANTS_VARS_H
#define GUARD_CONSTANTS_VARS_H
-#define VAR_0x3F20 0x3F20
+#define UNKNOWN_VAR_OFFSET_3F20 0x3F20
#define VARS_START 0x4000
@@ -60,7 +60,7 @@
#define VAR_POISON_STEP_COUNTER 0x402B
#define VAR_RESET_RTC_ENABLE 0x402C
#define VAR_ENIGMA_BERRY_AVAILABLE 0x402D
-#define VAR_0x402E 0x402E // Seems to be unused.
+#define VAR_UNUSED_0x402E 0x402E // Unused Var
#define VAR_FRONTIER_MANIAC_FACILITY 0x402F
#define VAR_FRONTIER_GAMBLER_FACILITY 0x4030
@@ -71,21 +71,21 @@
#define VAR_DEOXYS_ROCK_STEP_COUNT 0x4034
#define VAR_DEOXYS_ROCK_LEVEL 0x4035
#define VAR_STORAGE_UNKNOWN 0x4036
-#define VAR_0x4037 0x4037
-#define VAR_0x4038 0x4038
-#define VAR_0x4039 0x4039
-#define VAR_0x403A 0x403A
+#define VAR_UNUSUAL_WEATHER_LOCATION 0x4037
+#define VAR_UNUSUAL_WEATHER_STEP_COUNTER 0x4038
+#define VAR_SHOULD_END_UNUSUAL_WEATHER 0x4039
+#define VAR_NEVER_READ_0x403A 0x403A // Var is written to, but never checked
#define VAR_REGICE_STEPS_1 0x403B
#define VAR_REGICE_STEPS_2 0x403C
#define VAR_REGICE_STEPS_3 0x403D
#define VAR_ALTERING_CAVE_WILD_SET 0x403E
-#define VAR_0x403F 0x403F
+#define VAR_ALWAYS_ZERO_0x403F 0x403F // This var is read and written, but is always zero.
#define VAR_DAYS 0x4040
#define VAR_FANCLUB_UNKNOWN_1 0x4041
#define VAR_FANCLUB_UNKNOWN_2 0x4042
#define VAR_DEPT_STORE_FLOOR 0x4043
#define VAR_0x4044 0x4044
-#define VAR_POKELOT_PRIZE 0x4045
+#define VAR_POKELOT_PRIZE_ITEM 0x4045
#define VAR_NATIONAL_DEX 0x4046
#define VAR_SEEDOT_SIZE_RECORD 0x4047
#define VAR_ASH_GATHER_COUNT 0x4048
@@ -93,98 +93,98 @@
#define VAR_CRUISE_STEP_COUNT 0x404A
#define VAR_POKELOT_RND1 0x404B
#define VAR_POKELOT_RND2 0x404C
-#define VAR_0x404D 0x404D
-#define VAR_0x404E 0x404E
+#define VAR_POKELOT_PRIZE_PLACE 0x404D
+#define VAR_UNUSED_0x404E 0x404E // Unused Var
#define VAR_LOTAD_SIZE_RECORD 0x404F
#define VAR_0x4050 0x4050
#define VAR_ROUTE102_ACCESSIBLE 0x4051
-#define VAR_0x4052 0x4052
+#define VAR_UNUSED_0x4052 0x4052 // Unused Var
#define VAR_LAVARIDGE_RIVAL_STATE 0x4053
#define VAR_CURRENT_SECRET_BASE 0x4054
-#define VAR_0x4055 0x4055
-#define VAR_0x4056 0x4056
+#define VAR_UNUSED_0x4055 0x4055 // Unused Var
+#define VAR_UNUSED_0x4056 0x4056 // Unused Var
#define VAR_PETALBURG_STATE 0x4057
#define VAR_SLATEPORT_STATE 0x4058
-#define VAR_0x4059 0x4059
+#define VAR_UNUSED_0x4059 0x4059 // Unused Var
#define VAR_RUSTBORO_STATE 0x405A
-#define VAR_0x405B 0x405B
-#define VAR_0x405C 0x405C
-#define VAR_0x405D 0x405D
-#define VAR_0x405E 0x405E
-#define VAR_0x405F 0x405F
+#define VAR_UNUSED_0x405B 0x405B // Unused Var
+#define VAR_UNUSED_0x405C 0x405C // Unused Var
+#define VAR_MOSSDEEP_STATE 0x405D
+#define VAR_RAYQUAZA_STATE 0x405E
+#define VAR_UNUSED_0x405F 0x405F // Unused Var
#define VAR_ROUTE101_STATE 0x4060
-#define VAR_0x4061 0x4061
-#define VAR_0x4062 0x4062
+#define VAR_UNUSED_0x4061 0x4061 // Unused Var
+#define VAR_UNUSED_0x4062 0x4062 // Unused Var
#define VAR_0x4063 0x4063
-#define VAR_0x4064 0x4064
-#define VAR_0x4065 0x4065
-#define VAR_0x4066 0x4066
-#define VAR_0x4067 0x4067
-#define VAR_0x4068 0x4068
+#define VAR_UNUSED_0x4064 0x4064 // Unused Var
+#define VAR_UNUSED_0x4065 0x4065 // Unused Var
+#define VAR_UNUSED_0x4066 0x4066 // Unused Var
+#define VAR_UNUSED_0x4067 0x4067 // Unused Var
+#define VAR_UNUSED_0x4068 0x4068 // Unused Var
#define VAR_ROUTE110_STATE 0x4069
-#define VAR_0x406A 0x406A
-#define VAR_0x406B 0x406B
-#define VAR_0x406C 0x406C
-#define VAR_0x406D 0x406D
-#define VAR_0x406E 0x406E
+#define VAR_UNUSED_0x406A 0x406A // Unused Var
+#define VAR_UNUSED_0x406B 0x406B // Unused Var
+#define VAR_UNUSED_0x406C 0x406C // Unused Var
+#define VAR_UNUSED_0x406D 0x406D // Unused Var
+#define VAR_UNUSED_0x406E 0x406E // Unused Var
#define VAR_ROUTE116_STATE 0x406F
-#define VAR_0x4070 0x4070
+#define VAR_UNUSED_0x4070 0x4070 // Unused Var
#define VAR_ROUTE118_STATE 0x4071
#define VAR_ROUTE119_STATE 0x4072
-#define VAR_0x4073 0x4073
+#define VAR_UNUSED_0x4073 0x4073 // Unused Var
#define VAR_ROUTE121_STATE 0x4074
-#define VAR_0x4075 0x4075
-#define VAR_0x4076 0x4076
-#define VAR_0x4077 0x4077
-#define VAR_0x4078 0x4078
-#define VAR_0x4079 0x4079
-#define VAR_0x407A 0x407A
+#define VAR_UNUSED_0x4075 0x4075 // Unused Var
+#define VAR_UNUSED_0x4076 0x4076 // Unused Var
+#define VAR_UNUSED_0x4077 0x4077 // Unused Var
+#define VAR_UNUSED_0x4078 0x4078 // Unused Var
+#define VAR_UNUSED_0x4079 0x4079 // Unused Var
+#define VAR_UNUSED_0x407A 0x407A // Unused Var
#define VAR_ROUTE128_STATE 0x407B
-#define VAR_0x407C 0x407C
-#define VAR_0x407D 0x407D
-#define VAR_0x407E 0x407E
-#define VAR_0x407F 0x407F
-#define VAR_0x4080 0x4080
-#define VAR_0x4081 0x4081
+#define VAR_UNUSED_0x407C 0x407C // Unused Var
+#define VAR_UNUSED_0x407D 0x407D // Unused Var
+#define VAR_UNUSED_0x407E 0x407E // Unused Var
+#define VAR_UNUSED_0x407F 0x407F // Unused Var
+#define VAR_UNUSED_0x4080 0x4080 // Unused Var
+#define VAR_UNUSED_0x4081 0x4081 // Unused Var
#define VAR_LITTLEROOT_HOUSES_STATE 0x4082
-#define VAR_0x4083 0x4083
+#define VAR_UNUSED_0x4083 0x4083 // Unused Var
#define VAR_BIRCH_LAB_STATE 0x4084
#define VAR_PETALBURG_GYM_STATE 0x4085
#define VAR_LINK_CONTEST_ROOM_STATE 0x4086
#define VAR_CABLE_CLUB_STATE 0x4087
#define VAR_CONTEST_LOCATION 0x4088
-#define VAR_0x4089 0x4089
+#define VAR_SECRET_BASE_INITIALIZED 0x4089
#define VAR_CONTEST_PRIZE_PICKUP 0x408A
-#define VAR_0x408B 0x408B
+#define VAR_UNUSED_0x408B 0x408B // Unused Var
#define VAR_LITTLEROOT_HOUSES_STATE_2 0x408C
#define VAR_LITTLEROOT_RIVAL_STATE 0x408D
#define VAR_BOARD_BRINEY_BOAT_ROUTE104_STATE 0x408E
#define VAR_DEVON_CORP_3F_STATE 0x408F
#define VAR_BRINEY_HOUSE_STATE 0x4090
-#define VAR_0x4091 0x4091
+#define VAR_UNUSED_0x4091 0x4091 // Unused Var
#define VAR_LITTLEROOT_INTRO_STATE 0x4092
#define VAR_MAUVILLE_GYM_STATE 0x4093
#define VAR_LILYCOVE_MUSEUM_2F_STATE 0x4094
#define VAR_LILYCOVE_FAN_CLUB_STATE 0x4095
#define VAR_BRINEY_LOCATION 0x4096
-#define VAR_0x4097 0x4097
+#define VAR_INIT_SECRET_BASE 0x4097
#define VAR_PETALBURG_WOODS_STATE 0x4098
#define VAR_LILYCOVE_CONTEST_LOBBY_STATE 0x4099
#define VAR_RUSTURF_TUNNEL_STATE 0x409A
-#define VAR_0x409B 0x409B
+#define VAR_UNUSED_0x409B 0x409B // Unused Var
#define VAR_ELITE_4_STATE 0x409C
-#define VAR_0x409D 0x409D
-#define VAR_0x409E 0x409E
-#define VAR_0x409F 0x409F
+#define VAR_UNUSED_0x409D 0x409D // Unused Var
+#define VAR_MOSSDEEP_SPACE_CENTER_STATE_1 0x409E
+#define VAR_MOSSDEEP_SPACE_CENTER_STATE_2 0x409F
#define VAR_SLATEPORT_HARBOR_STATE 0x40A0
-#define VAR_0x40A1 0x40A1
+#define VAR_UNUSED_0x40A1 0x40A1 // Unused var
#define VAR_SEAFLOOR_CAVERN_STATE 0x40A2
#define VAR_CABLE_CAR_STATION_STATE 0x40A3
#define VAR_SAFARI_ZONE_STATE 0x40A4
#define VAR_TRICK_HOUSE_ENTRANCE_STATE_1 0x40A5
#define VAR_TRICK_HOUSE_ENTRANCE_STATE_2 0x40A6
#define VAR_TRICK_HOUSE_ENTRANCE_STATE_3 0x40A7
-#define VAR_0x40A8 0x40A8
+#define VAR_UNUSED_0x40A8 0x40A8 // Unused Var
#define VAR_CYCLING_CHALLENGE_STATE 0x40A9
#define VAR_SLATEPORT_MUSEUM_1F_STATE 0x40AA
#define VAR_TRICK_HOUSE_PUZZLE_1_STATE 0x40AB
@@ -197,13 +197,13 @@
#define VAR_TRICK_HOUSE_PUZZLE_8_STATE 0x40B2
#define VAR_WEATHER_INSTITUTE_STATE 0x40B3
#define VAR_PORTHOLE_STATE 0x40B4
-#define VAR_TRICK_HOUSE_STATE 0x40B5 // TODO: needs some further investigation
+#define VAR_TRICK_HOUSE_STATE 0x40B5 // TODO: needs some further investigation
#define VAR_TRICK_HOUSE_PUZZLE_7_STATE_2 0x40B6
#define VAR_SLATEPORT_FAN_CLUB_STATE 0x40B7
-#define VAR_0x40B8 0x40B8
+#define VAR_UNUSED_0x40B8 0x40B8 // Unused Var
#define VAR_MT_PYRE_STATE 0x40B9
#define VAR_NEW_MAUVILLE_STATE 0x40BA
-#define VAR_0x40BB 0x40BB
+#define VAR_UNUSED_0x40BB 0x40BB // Unused Var
#define VAR_BRAVO_TRAINER_BATTLE_TOWER_ON 0x40BC
#define VAR_JAGGED_PASS_ASH_WEATHER 0x40BD
#define VAR_GLASS_WORKSHOP_STATE 0x40BE
@@ -216,87 +216,87 @@
#define VAR_WHICH_FOSSIL_REVIVED 0x40C5
#define VAR_STEVENS_HOUSE_STATE 0x40C6
#define VAR_OLDALE_STATE 0x40C7
-#define VAR_0x40C8 0x40C8
-#define VAR_0x40C9 0x40C9
-#define VAR_0x40CA 0x40CA
-#define VAR_0x40CB 0x40CB
-#define VAR_0x40CC 0x40CC
-#define VAR_0x40CD 0x40CD
+#define VAR_JAGGED_PASS_STATE 0x40C8
+#define VAR_SCOTT_PETALBURG_ENCOUNTER 0x40C9
+#define VAR_SKY_PILLAR_STATE 0x40CA
+#define VAR_ROUTE_111_STATE 0x40CB
+#define VAR_FOSSIL_MANIAC_STATE 0x40CC
+#define VAR_CABLE_CLUB_TUTORIAL_STATE 0x40CD
#define VAR_FRONTIER_BATTLE_MODE 0x40CE
#define VAR_FRONTIER_FACILITY 0x40CF
-#define VAR_0x40D0 0x40D0
-#define VAR_0x40D1 0x40D1
-#define VAR_0x40D2 0x40D2
+#define VAR_HAS_ENTERED_BATTLE_FRONTIER 0x40D0 // Var is used like a flag.
+#define VAR_SCOTT_STATE 0x40D1
+#define VAR_SLATEPORT_OUTSIDE_MUSEUM_STATE 0x40D2
#define VAR_0x40D3 0x40D3
-#define VAR_0x40D4 0x40D4
-#define VAR_0x40D5 0x40D5
-#define VAR_0x40D6 0x40D6
-#define VAR_0x40D7 0x40D7
-#define VAR_0x40D8 0x40D8
-#define VAR_0x40D9 0x40D9
+#define VAR_SS_TIDAL_SCOTT_STATE 0x40D4 // Always equal to FLAG_MET_SCOTT_ON_SS_TIDAL
+#define VAR_ROAMER_POKEMON 0x40D5 // 0 = Latias, 1 = Latios
+#define VAR_TRAINER_HILL_IS_ACTIVE 0x40D6
+#define VAR_SKY_PILLAR_RAQUAZA_CRY_DONE 0x40D7
+#define VAR_SOOTOPOLIS_STATE 0x40D8
+#define VAR_HAS_TALKED_TO_SEAFLOOR_CAVERN_ENTRANCE_GRUNT 0x40D9
#define VAR_0x40DA 0x40DA
-#define VAR_0x40DB 0x40DB
-#define VAR_0x40DC 0x40DC
+#define VAR_UNUSED_0x40DB 0x40DB // Unused Var
+#define VAR_UNUSED_0x40DC 0x40DC // Unused Var
#define VAR_EVENT_PICHU_SLOT 0x40DD
-#define VAR_0x40DE 0x40DE
-#define VAR_0x40DF 0x40DF
-#define VAR_0x40E0 0x40E0
-#define VAR_0x40E1 0x40E1
-#define VAR_0x40E2 0x40E2
-#define VAR_0x40E3 0x40E3
-#define VAR_0x40E4 0x40E4
-#define VAR_0x40E5 0x40E5
+#define VAR_NEVER_READ_0x40DE 0x40DE // Var is written to, but never read
+#define VAR_NEVER_READ_0x40DF 0x40DF // Var is written to, but never read
+#define VAR_NEVER_READ_0x40E0 0x40E0 // Var is written to, but never read
+#define VAR_NEVER_READ_0x40E1 0x40E1 // Var is written to, but never read
+#define VAR_NEVER_READ_0x40E2 0x40E2 // Var is written to, but never read
+#define VAR_NEVER_READ_0x40E3 0x40E3 // Var is written to, but never read
+#define VAR_NEVER_READ_0x40E4 0x40E4 // var is written to, but never read
+#define VAR_UNUSED_0x40E5 0x40E5 // Unused Var
#define VAR_DAILY_SLOTS 0x40E6
#define VAR_DAILY_WILDS 0x40E7
#define VAR_DAILY_BLENDER 0x40E8
#define VAR_DAILY_PLANTED_BERRIES 0x40E9
#define VAR_DAILY_PICKED_BERRIES 0x40EA
#define VAR_DAILY_ROULETTE 0x40EB
-#define VAR_0x40EC 0x40EC
-#define VAR_0x40ED 0x40ED
-#define VAR_0x40EE 0x40EE
-#define VAR_0x40EF 0x40EF
-#define VAR_0x40F0 0x40F0
+#define VAR_SECRET_BASE_STEP_COUNTER 0x40EC // Used by Secret Base TV programs
+#define VAR_SECRET_BASE_LAST_ITEM_USED 0x40ED // Used by Secret Base TV programs
+#define VAR_SECRET_BASE_LOW_TV_FLAGS 0x40EE // Used by Secret Base TV programs
+#define VAR_SECRET_BASE_HIGH_TV_FLAGS 0x40EF // Used by Secret Base TV programs
+#define VAR_SECRET_BASE_IS_NOT_LOCAL 0x40F0 // Set to TRUE while in another player's secret base.
#define VAR_DAILY_BP 0x40F1
-#define VAR_0x40F2 0x40F2
-#define VAR_0x40F3 0x40F3
-#define VAR_0x40F4 0x40F4
-#define VAR_0x40F5 0x40F5
-#define VAR_0x40F6 0x40F6
-#define VAR_0x40F7 0x40F7
-#define VAR_0x40F8 0x40F8
-#define VAR_0x40F9 0x40F9
-#define VAR_0x40FA 0x40FA
-#define VAR_0x40FB 0x40FB
-#define VAR_0x40FC 0x40FC
-#define VAR_0x40FD 0x40FD
-#define VAR_0x40FE 0x40FE
-#define VAR_0x40FF 0x40FF
+#define VAR_WALLY_CALL_STEP_COUNTER 0x40F2
+#define VAR_WINONA_CALL_STEP_COUNTER 0x40F3
+#define VAR_ROXANNE_CALL_STEP_COUNTER 0x40F4
+#define VAR_SCOTT_CALL_STEP_COUNTER 0x40F5
+#define VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER 0x40F6
+#define VAR_UNUSED_0x40F7 0x40F7 // Unused Var
+#define VAR_UNUSED_0x40F8 0x40F8 // Unused Var
+#define VAR_UNUSED_0x40F9 0x40F9 // Unused Var
+#define VAR_UNUSED_0x40FA 0x40FA // Unused Var
+#define VAR_UNUSED_0x40FB 0x40FB // Unused Var
+#define VAR_UNUSED_0x40FC 0x40FC // Unused Var
+#define VAR_UNUSED_0x40FD 0x40FD // Unused Var
+#define VAR_UNUSED_0x40FE 0x40FE // Unused Var
+#define VAR_UNUSED_0x40FF 0x40FF // Unused Var
#define SPECIAL_VARS_START 0x8000
// special vars
// They are commonly used as parameters to commands, or return values from commands.
-#define VAR_0x8000 0x8000
-#define VAR_0x8001 0x8001
-#define VAR_0x8002 0x8002
-#define VAR_0x8003 0x8003
-#define VAR_0x8004 0x8004
-#define VAR_0x8005 0x8005
-#define VAR_0x8006 0x8006
-#define VAR_0x8007 0x8007
-#define VAR_0x8008 0x8008
-#define VAR_0x8009 0x8009
-#define VAR_0x800A 0x800A
-#define VAR_0x800B 0x800B
-#define VAR_FACING 0x800C
-#define VAR_RESULT 0x800D
-#define VAR_ITEM_ID 0x800E
-#define VAR_LAST_TALKED 0x800F
-#define VAR_CONTEST_RANK 0x8010
-#define VAR_CONTEST_CATEGORY 0x8011
-#define VAR_MON_BOX_ID 0x8012
-#define VAR_MON_BOX_POS 0x8013
-#define VAR_0x8014 0x8014
-#define VAR_0x8015 0x8015
+#define VAR_0x8000 0x8000
+#define VAR_0x8001 0x8001
+#define VAR_0x8002 0x8002
+#define VAR_0x8003 0x8003
+#define VAR_0x8004 0x8004
+#define VAR_0x8005 0x8005
+#define VAR_0x8006 0x8006
+#define VAR_0x8007 0x8007
+#define VAR_0x8008 0x8008
+#define VAR_0x8009 0x8009
+#define VAR_0x800A 0x800A
+#define VAR_0x800B 0x800B
+#define VAR_FACING 0x800C
+#define VAR_RESULT 0x800D
+#define VAR_ITEM_ID 0x800E
+#define VAR_LAST_TALKED 0x800F
+#define VAR_CONTEST_RANK 0x8010
+#define VAR_CONTEST_CATEGORY 0x8011
+#define VAR_MON_BOX_ID 0x8012
+#define VAR_MON_BOX_POS 0x8013
+#define VAR_UNUSED_0x8014 0x8014
+#define VAR_TRAINER_BATTLE_OPPONENT_A 0x8015 // Alias of gTrainerBattleOpponent_A
#endif // GUARD_CONSTANTS_VARS_H
diff --git a/include/constants/weather.h b/include/constants/weather.h
index d62e07474..b01cfb390 100644
--- a/include/constants/weather.h
+++ b/include/constants/weather.h
@@ -37,4 +37,30 @@
#define COORD_EVENT_WEATHER_ROUTE119_CYCLE 20
#define COORD_EVENT_WEATHER_ROUTE123_CYCLE 21
+// These are the "unusual weather events" that are used
+// to find Kyogre and Groudon.
+#define UNUSUAL_WEATHER_COUNT_PER_LEGENDARY 8
+#define UNUSUAL_WEATHER_GROUDON_LOCATIONS_START 1
+#define UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START 1 + UNUSUAL_WEATHER_COUNT_PER_LEGENDARY
+
+#define UNUSUAL_WEATHER_NONE 0
+// Groudon locations
+#define UNUSUAL_WEATHER_ROUTE_114_NORTH 1
+#define UNUSUAL_WEATHER_ROUTE_114_SOUTH 2
+#define UNUSUAL_WEATHER_ROUTE_115_WEST 3
+#define UNUSUAL_WEATHER_ROUTE_115_EAST 4
+#define UNUSUAL_WEATHER_ROUTE_116_NORTH 5
+#define UNUSUAL_WEATHER_ROUTE_116_SOUTH 6
+#define UNUSUAL_WEATHER_ROUTE_118_EAST 7
+#define UNUSUAL_WEATHER_ROUTE_118_WEST 8
+// Kyogre locations
+#define UNUSUAL_WEATHER_ROUTE_105_NORTH 9
+#define UNUSUAL_WEATHER_ROUTE_105_SOUTH 10
+#define UNUSUAL_WEATHER_ROUTE_125_WEST 11
+#define UNUSUAL_WEATHER_ROUTE_125_EAST 12
+#define UNUSUAL_WEATHER_ROUTE_127_NORTH 13
+#define UNUSUAL_WEATHER_ROUTE_127_SOUTH 14
+#define UNUSUAL_WEATHER_ROUTE_129_WEST 15
+#define UNUSUAL_WEATHER_ROUTE_129_EAST 16
+
#endif // GUARD_CONSTANTS_WEATHER_H
diff --git a/include/contest.h b/include/contest.h
index e4391a327..8146486cb 100644
--- a/include/contest.h
+++ b/include/contest.h
@@ -478,5 +478,6 @@ bool32 sub_80FC4F4(void *, u16);
bool8 sub_80FC55C(void);
bool8 sub_80FC530(u8);
u8 sub_80F86E0(u8 *);
+void sub_80FC9F8(u8 taskId);
#endif //GUARD_CONTEST_H
diff --git a/include/dewford_trend.h b/include/dewford_trend.h
index 608a925f5..bdb0fc95c 100644
--- a/include/dewford_trend.h
+++ b/include/dewford_trend.h
@@ -5,5 +5,7 @@ void InitDewfordTrend(void);
void UpdateDewfordTrendPerDay(u16);
void UpdateDewfordTrendPerDay(u16 days);
bool8 sub_81226D8(u16 *a);
+void ReceiveEasyChatPairsData(struct EasyChatPair *a, size_t b, u8 unused);
+
#endif // GUARD_DEWFORDTREND_H
diff --git a/include/easy_chat.h b/include/easy_chat.h
index 2efdc4e5d..84ac15422 100644
--- a/include/easy_chat.h
+++ b/include/easy_chat.h
@@ -134,5 +134,6 @@ u16 EasyChat_GetNumWordsInGroup(u8);
u16 sub_811EE90(u16);
void DoEasyChatScreen(u8 type, u16 *words, MainCallback callback, u8 displayedPersonType);
void sub_811F8BC(void);
+void sub_811EFC0(u8 additionalPhraseId);
#endif // GUARD_EASYCHAT_H
diff --git a/include/event_data.h b/include/event_data.h
index 3b8e2701f..11289c1ab 100644
--- a/include/event_data.h
+++ b/include/event_data.h
@@ -47,6 +47,6 @@ extern u16 gSpecialVar_LastTalked;
extern u16 gSpecialVar_Facing;
extern u16 gSpecialVar_MonBoxId;
extern u16 gSpecialVar_MonBoxPos;
-extern u16 gSpecialVar_0x8014;
+extern u16 gSpecialVar_Unused_0x8014;
#endif // GUARD_EVENT_DATA_H
diff --git a/include/event_obj_lock.h b/include/event_obj_lock.h
index 59532fdcb..2f09ad36a 100644
--- a/include/event_obj_lock.h
+++ b/include/event_obj_lock.h
@@ -7,5 +7,6 @@ bool8 sub_809847C(void);
void LockSelectedEventObject(void);
void sub_8098630(void);
bool8 sub_8098734(void);
+void ScriptUnfreezeEventObjects(void);
#endif // GUARD_EVENT_OBJ_LOCK_H
diff --git a/include/event_object_movement.h b/include/event_object_movement.h
index 284bbe8db..63ac09f2d 100644
--- a/include/event_object_movement.h
+++ b/include/event_object_movement.h
@@ -193,6 +193,9 @@ void UpdateEventObjectSpriteVisibility(struct Sprite *sprite, bool8 invisible);
s16 sub_809773C(s16 a1);
s16 sub_8097728(s16 a1);
void CameraObjectReset2(void);
+u8 EventObjectGetBerryTreeId(u8 eventObjectId);
+void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
+bool8 IsBerryTreeSparkling(u8, u8, u8);
void MovementType_None(struct Sprite *);
void MovementType_LookAround(struct Sprite *);
diff --git a/include/event_scripts.h b/include/event_scripts.h
index 65e2c74b7..e3ec8afb4 100644
--- a/include/event_scripts.h
+++ b/include/event_scripts.h
@@ -564,7 +564,7 @@ extern const u8 EventScript_FallDownHole[];
extern const u8 BattleFrontier_BattlePyramidEmptySquare_EventScript_252BE8[];
extern const u8 EventScript_Poison[];
extern const u8 EventScript_EggHatch[];
-extern const u8 gUnknown_08273D1F[];
+extern const u8 UnusualWeather_EventScript_EndEventAndCleanup_1[];
extern const u8 IslandCave_EventScript_238EAF[];
extern const u8 MauvilleCity_EventScript_1DF7BA[];
extern const u8 Route119_EventScript_1F49EC[];
diff --git a/include/field_control_avatar.h b/include/field_control_avatar.h
index 738cceb3e..feb20cef6 100644
--- a/include/field_control_avatar.h
+++ b/include/field_control_avatar.h
@@ -39,5 +39,6 @@ int SetCableClubWarp(void);
u8 TrySetDiveWarp(void);
const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction);
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position);
+void ClearPoisonStepCounter(void);
#endif // GUARD_FIELDCONTROLAVATAR_H
diff --git a/include/field_effect.h b/include/field_effect.h
index 205dbb68a..1f5f4ee29 100644
--- a/include/field_effect.h
+++ b/include/field_effect.h
@@ -36,6 +36,10 @@ bool8 FieldEffectCmd_end(u8 **script, u32 *val);
bool8 FieldEffectCmd_loadgfx_callnative(u8 **script, u32 *val);
bool8 FieldEffectCmd_loadtiles_callnative(u8 **script, u32 *val);
bool8 FieldEffectCmd_loadfadedpal_callnative(u8 **script, u32 *val);
+void sub_80B6B68(void);
+void sub_80B6E4C(u8 a0, u8 priority);
+void sub_80B75D8(u8 priority);
+void sub_80B7A74(u8 priority);
void sub_80B9C28(s16*, u8);
void sub_80B9C54(s16*, u8);
@@ -47,5 +51,6 @@ void sub_80B7A58(struct Sprite*);
void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b);
void FreeResourcesAndDestroySprite(struct Sprite *sprite, u8 spriteId);
u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority);
+void StartEscapeRopeFieldEffect(void);
#endif //GUARD_FIELD_EFFECTS_H
diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h
index 6022467e4..6ea9771e6 100644
--- a/include/field_effect_helpers.h
+++ b/include/field_effect_helpers.h
@@ -34,5 +34,6 @@ void UpdateSparkleFieldEffect(struct Sprite*);
void SetSpriteInvisible(u8 spriteId);
void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y);
void sub_8155604(u8 spriteId, u8 value, s16 data1);
+void sub_81555D8(u8 spriteId, u8 value);
#endif //GUARD_FIELD_EFFECT_HELPERS_H
diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h
index 45cd0dbd9..ca3d41546 100644
--- a/include/field_player_avatar.h
+++ b/include/field_player_avatar.h
@@ -63,5 +63,15 @@ u8 sub_808BCD0(void);
void sub_808B578(void);
u8 GetFRLGAvatarGraphicsIdByGender(u8);
u8 GetRSAvatarGraphicsIdByGender(u8);
+void sub_808B980(u8 direction);
+void sub_808B9BC(u8 direction);
+void sub_808B9A4(u8 direction);
+void sub_808C1B4(u8 direction);
+void sub_808B9D4(u8 direction);
+void sub_808D194(void);
+void sub_808D1C8(void);
+bool32 sub_808D1B4(void);
+bool32 sub_808D1E8(void);
+void sub_808C0A8(u8 a);
#endif // GUARD_FIELD_PLAYER_AVATAR_H
diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h
index 2b8b3a5a3..b4429c167 100644
--- a/include/field_screen_effect.h
+++ b/include/field_screen_effect.h
@@ -41,5 +41,6 @@ void sub_80B0534(void);
void sub_80B058C(void);
void sub_80B05B4(void);
void WriteFlashScanlineEffectBuffer(u8 flashLevel);
+bool8 walkrun_is_standing_still(void);
#endif // GUARD_FIELD_SCREEN_EFFECT_H
diff --git a/include/field_special_scene.h b/include/field_special_scene.h
index 240e9ecb6..2219c9433 100644
--- a/include/field_special_scene.h
+++ b/include/field_special_scene.h
@@ -10,5 +10,6 @@ void Task_HandleTruckSequence(u8 taskId);
void ExecuteTruckSequence(void);
void EndTruckSequence(u8);
void sub_80C791C(void);
+void sub_80FB768(void);
#endif // GUARD_FIELD_SPECIAL_SCENE_H
diff --git a/include/field_specials.h b/include/field_specials.h
index bff04a739..68b233074 100644
--- a/include/field_specials.h
+++ b/include/field_specials.h
@@ -7,13 +7,13 @@ u16 get_unknown_box_id(void);
bool8 InMultiBattleRoom(void);
void sub_813BF10(void);
void IncrementBirthIslandRockStepCount(void);
-bool8 sub_813B3B0(void);
+bool8 UnusualWeatherHasExpired(void);
bool8 ShouldDoBrailleRegicePuzzle(void);
-bool32 is_tile_that_overrides_player_control(void);
-bool32 sub_8138120(void);
-bool32 sub_8138168(void);
-bool32 sub_81381B0(void);
-bool32 sub_81381F8(void);
+bool32 ShouldDoWallyCall(void);
+bool32 ShouldDoWinonaCall(void);
+bool32 ShouldDoScottCall(void);
+bool32 ShouldDoRoxanneCall(void);
+bool32 ShouldDoRivalRayquazaCall(void);
bool32 CountSSTidalStep(u16 delta);
u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y);
void sub_813A128(void);
@@ -26,6 +26,7 @@ void UpdateFrontierGambler(u16 a0);
void ResetCyclingRoadChallengeData(void);
bool8 warp0_in_pokecenter(void);
void ResetFanClub(void);
-
+bool8 sub_813B21C(void);
+void set_unknown_box_id(u8 id);
#endif // GUARD_FIELD_SPECIALS_H
diff --git a/include/fieldmap.h b/include/fieldmap.h
index 24bc4989a..bb5b0e290 100644
--- a/include/fieldmap.h
+++ b/include/fieldmap.h
@@ -9,6 +9,8 @@
#define NUM_PALS_TOTAL 13
#define MAX_MAP_DATA_SIZE 0x2800
+#include "main.h"
+
extern struct BackupMapLayout gBackupMapLayout;
u32 MapGridGetMetatileIdAt(int, int);
@@ -37,11 +39,16 @@ void copy_map_tileset1_tileset2_to_vram(struct MapLayout const *mapLayout);
void apply_map_tileset1_tileset2_palette(struct MapLayout const *mapLayout);
void apply_map_tileset2_palette(struct MapLayout const *mapLayout);
void copy_map_tileset2_to_vram_2(struct MapLayout const *mapLayout);
-extern void copy_map_tileset1_to_vram(const struct MapLayout *);
-extern void copy_map_tileset2_to_vram(const struct MapLayout *);
+void copy_map_tileset1_to_vram(const struct MapLayout *);
+void copy_map_tileset2_to_vram(const struct MapLayout *);
+struct MapHeader const *const mapconnection_get_mapheader(struct MapConnection *connection);
+struct MapConnection *sub_8088A8C(s16 x, s16 y);
void SpriteCB_PokeballGlow(struct Sprite *);
void SpriteCB_PokecenterMonitor(struct Sprite *);
void SpriteCB_HallOfFameMonitor(struct Sprite *);
+// field_region_map.c
+void FieldInitRegionMap(MainCallback callback);
+
#endif //GUARD_FIELDMAP_H
diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h
index 74a8363bb..e35d900d8 100644
--- a/include/global.fieldmap.h
+++ b/include/global.fieldmap.h
@@ -1,6 +1,13 @@
#ifndef GUARD_GLOBAL_FIELDMAP_H
#define GUARD_GLOBAL_FIELDMAP_H
+#define METATILE_COLLISION_MASK 0x0C00
+#define METATILE_ID_MASK 0x03FF
+#define METATILE_ID_UNDEFINED 0x03FF
+#define METATILE_ELEVATION_SHIFT 12
+#define METATILE_COLLISION_SHIFT 10
+#define METATILE_ELEVATION_MASK 0xF000
+
enum
{
CONNECTION_SOUTH = 1,
@@ -19,8 +26,8 @@ struct Tileset
/*0x01*/ bool8 isSecondary;
/*0x04*/ void *tiles;
/*0x08*/ void *palettes;
- /*0x0c*/ void *metatiles;
- /*0x10*/ void *metatileAttributes;
+ /*0x0c*/ u16 *metatiles;
+ /*0x10*/ u16 *metatileAttributes;
/*0x14*/ TilesetCB callback;
};
diff --git a/include/global.h b/include/global.h
index cc026f36a..1f9ac5185 100644
--- a/include/global.h
+++ b/include/global.h
@@ -795,15 +795,15 @@ struct TrainerNameRecord
struct SaveTrainerHill
{
- /*0x3D64*/ u32 field_3D64;
- /*0x3D68*/ u32 field_3D68;
+ /*0x3D64*/ u32 timer;
+ /*0x3D68*/ u32 bestTime;
/*0x3D6C*/ u8 field_3D6C;
/*0x3D6D*/ u8 unused;
/*0x3D6E*/ u16 field_3D6E_0a:1; // 1
/*0x3D6E*/ u16 field_3D6E_0b:1; // 2
/*0x3D6E*/ u16 field_3D6E_0c:1; // 4
- /*0x3D6E*/ u16 field_3D6E_0d:1; // 8
- /*0x3D6E*/ u16 field_3D6E_0e:1; // x10
+ /*0x3D6E*/ u16 hasLost:1; // 8
+ /*0x3D6E*/ u16 maybeECardScanDuringChallenge:1; // x10
/*0x3D6E*/ u16 field_3D6E_0f:1; // x20
/*0x3D6E*/ u16 tag:2; // x40, x80 = xC0
};
@@ -906,13 +906,13 @@ struct MapPosition
s8 height;
};
-struct UnkStruct_8054FF8
+struct TradeRoomPlayer
{
- u8 a;
- u8 b;
+ u8 playerId;
+ u8 isLocalPlayer;
u8 c;
- u8 d;
- struct MapPosition sub;
+ u8 facing;
+ struct MapPosition pos;
u16 field_C;
};
diff --git a/include/hall_of_fame.h b/include/hall_of_fame.h
index d35ecf268..5c8a01bcb 100644
--- a/include/hall_of_fame.h
+++ b/include/hall_of_fame.h
@@ -6,4 +6,7 @@ void CB2_DoHallOfFameScreenDontSaveData(void);
void CB2_DoHallOfFamePC(void);
void sub_8175280(void);
+// hof_pc.c
+void ReturnFromHallOfFamePC(void);
+
#endif // GUARD_HALL_OF_FAME_H
diff --git a/include/item_menu.h b/include/item_menu.h
index 2ca1af200..70d6b5a94 100644
--- a/include/item_menu.h
+++ b/include/item_menu.h
@@ -2,6 +2,7 @@
#define GUARD_item_menu_H
#include "item.h"
+#include "menu_helpers.h"
#define RETURN_LOCATION_FIELD 0
#define RETURN_LOCATION_BATTLE 1
@@ -71,6 +72,7 @@ void sub_81AAC14(void);
void sub_81AAC50(void);
void sub_81AAC70(void);
void sub_81AAC28(void);
+void sub_81AABB0(void);
void SetInitialScrollAndCursorPositions(u8 pocketId);
void bag_menu_mail_related(void);
void CB2_BagMenuFromStartMenu(void);
@@ -80,6 +82,11 @@ void CB2_GoToSellMenu(void);
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
void DoWallyTutorialBagMenu(void);
void ResetBagScrollPositions(void);
+void sub_81AABF0(void (*callback)(void));
+void CB2_ChooseBerry(void);
+void unknown_ItemMenu_Confirm(u8 taskId);
+void bag_menu_yes_no(u8, u8, const struct YesNoFuncTable*);
+void sub_81AB9A8(u8 pocketId);
#endif //GUARD_item_menu_H
diff --git a/include/link.h b/include/link.h
index 11eff5c28..24a834c68 100644
--- a/include/link.h
+++ b/include/link.h
@@ -244,7 +244,7 @@ bool8 IsLinkTaskFinished(void);
void CreateWirelessStatusIndicatorSprite(u8, u8);
void sub_800ADF8(void);
void sub_800B488(void);
-void sub_800A620(void);
+void CheckShouldAdvanceLinkState(void);
void sub_8011BD0(void);
u8 IsLinkMaster(void);
void sub_800AC34(void);
@@ -261,6 +261,8 @@ void sub_800B3A4(u32 who);
bool32 sub_800A07C(void);
void sub_800AB98(void);
void sub_800AA04(u8 a0);
+void sub_800B4C0(void);
+bool32 sub_800B504(void);
extern u16 gLinkPartnersHeldKeys[6];
extern u32 gLinkDebugSeed;
@@ -299,8 +301,8 @@ extern struct LinkPlayer gLocalLinkPlayer;
bool32 Link_AnyPartnersPlayingRubyOrSapphire(void);
bool32 sub_800A03C(void);
-void sub_8009628(u8);
-u8 sub_800AA48(void);
+void SetLocalLinkPlayerId(u8);
+u8 GetSavedPlayerCount(void);
void sub_8009FAC(void);
bool8 sub_800A4D8(u8 a0);
u8 sub_800A9D8(void);
@@ -312,7 +314,7 @@ void sub_800AB18(void);
void sub_8009F18(void);
bool8 sub_800AA60(void);
void sub_800ABF4(u16 a0);
-bool32 sub_8009F3C(void);
-u32 sub_800B4DC(void);
+bool32 IsSendingKeysToLink(void);
+u32 GetLinkRecvQueueLength(void);
#endif // GUARD_LINK_H
diff --git a/include/link_rfu.h b/include/link_rfu.h
index c91f9f1d3..5b8ccd9fb 100644
--- a/include/link_rfu.h
+++ b/include/link_rfu.h
@@ -219,7 +219,7 @@ void sub_800E700(void);
void sub_800EDD4(void);
void sub_800F6FC(u8 who);
void sub_800F728(u8 who);
-bool32 sub_800F7E4(void);
+bool32 IsSendingKeysToRfu(void);
void sub_800F804(void);
void sub_800F850(void);
u8 sub_800FCD8(void);
@@ -238,8 +238,8 @@ void sub_800E6D0(void);
bool32 sub_8010EC0(void);
bool32 sub_8010F1C(void);
bool32 sub_8011A80(void);
-bool32 sub_800F0B8(void);
-u32 sub_80124D4(void);
+bool32 IsRfuRecvQueueEmpty(void);
+u32 GetRfuRecvQueueLength(void);
void RfuVSync(void);
void sub_80111B0(bool32 a0);
u8 sub_8011A74(void);
diff --git a/include/main.h b/include/main.h
index 728064288..4f9a9e61a 100644
--- a/include/main.h
+++ b/include/main.h
@@ -61,14 +61,14 @@ void SetHBlankCallback(IntrCallback callback);
void SetVCountCallback(IntrCallback callback);
void SetSerialCallback(IntrCallback callback);
void InitFlashTimer(void);
-void sub_80008DC(u32 *var);
-void sub_80008E8(void);
+void SetTrainerHillVBlankCounter(u32 *var);
+void ClearTrainerHillVBlankCounter(void);
void DoSoftReset(void);
void ClearPokemonCrySongs(void);
void RestoreSerialTimer3IntrHandlers(void);
void StartTimer1(void);
void SeedRngAndSetTrainerId(void);
-extern u16 GetGeneratedTrainerIdLower(void);
+u16 GetGeneratedTrainerIdLower(void);
#endif // GUARD_MAIN_H
diff --git a/include/match_call.h b/include/match_call.h
index 17d40d41c..6803d2f26 100644
--- a/include/match_call.h
+++ b/include/match_call.h
@@ -12,5 +12,9 @@ enum {
s32 GetRematchIdxByTrainerIdx(s32 trainerIdx);
void InitMatchCallCounters(void);
+bool32 TryStartMatchCall(void);
+bool32 IsMatchCallTaskActive(void);
+void StartMatchCallFromScript(u8* script);
+void sub_8197080(u8 *destStr);
#endif //GUARD_MATCH_CALL_H
diff --git a/include/menu.h b/include/menu.h
index aca462468..947f97a68 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -25,23 +25,23 @@ void InitStandardTextBoxWindows(void);
void sub_8197200(void);
u16 RunTextPrintersAndIsPrinter0Active(void);
void sub_81973A4(void);
-void NewMenuHelpers_DrawDialogueFrame(u8, u8);
-void sub_819746C(u8 windowId, bool8 copyToVram);
+void DrawDialogueFrame(u8, u8);
+void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram);
u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 fgColor, u8 bgColor, u8 shadowColor);
void PrintPlayerNameOnWindow(u8, const u8*, u16, u16);
void DisplayItemMessageOnField(u8 taskId, const u8 *src, TaskFunc callback);
-void sub_8197434(u8 windowId, bool8 copyToVram);
+void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram);
void SetStandardWindowBorderStyle(u8 a0, u8 a1);
-void DisplayYesNoMenu(void);
+void DisplayYesNoMenuDefaultYes(void);
u32 GetPlayerTextSpeed(void);
u8 GetPlayerTextSpeedDelay(void);
void sub_81978B0(u16 arg0);
void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16));
void sub_8199DF0(u32 bg, u8 a1, int a2, int a3);
void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str);
-void sub_8198070(u8 windowId, bool8 copyToVram);
+void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram);
void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock);
-void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette);
+void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette);
void schedule_bg_copy_tilemap_to_vram(u8 bgNum);
void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *strs);
u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 numItems, u8 initialCursorPos);
@@ -60,9 +60,9 @@ s8 ProcessMenuInput_other(void);
void do_scheduled_bg_tilemap_copies_to_vram(void);
void clear_scheduled_bg_copies_to_vram(void);
void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str);
-void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 a2, u8 a3);
+void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 a2, u8 a3);
void sub_81995E4(u8 windowId, u8 optionsNo, const struct MenuAction *actions, const u8 *actionIds);
-void sub_8197DF8(u8 windowId, bool8 copyToVram);
+void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram);
u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16);
void *malloc_and_decompress(const void *src, u32 *sizeOut);
u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode);
@@ -75,13 +75,13 @@ u8 GetStartMenuWindowId(void);
void sub_819A2BC(u8, u8);
u8 Menu_MoveCursor(s8 cursorDelta);
u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta);
-void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, bool8 CopyToVram);
+void DrawStdWindowFrame(u8 windowId, bool8 CopyToVram);
u8 sub_81979C4(u8 a1);
u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos);
void sub_819786C(u8 windowId, bool8 copyToVram);
void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress);
void RemoveStartMenuWindow(void);
-void sub_8197948(u8 initialCursorPos);
+void DisplayYesNoMenuWithDefault(u8 initialCursorPos);
void sub_819A344(u8 a0, u8 *dest, u8 color);
void RemoveMapNamePopUpWindow(void);
u8 GetMapNamePopUpWindowId(void);
diff --git a/include/overworld.h b/include/overworld.h
index 8caba0673..b86067701 100644
--- a/include/overworld.h
+++ b/include/overworld.h
@@ -1,6 +1,29 @@
#ifndef GUARD_OVERWORLD_H
#define GUARD_OVERWORLD_H
+#define LINK_KEY_CODE_NULL 0x00
+#define LINK_KEY_CODE_EMPTY 0x11
+#define LINK_KEY_CODE_DPAD_DOWN 0x12
+#define LINK_KEY_CODE_DPAD_UP 0x13
+#define LINK_KEY_CODE_DPAD_LEFT 0x14
+#define LINK_KEY_CODE_DPAD_RIGHT 0x15
+#define LINK_KEY_CODE_UNK_2 0x16
+#define LINK_KEY_CODE_EXIT_ROOM 0x17
+#define LINK_KEY_CODE_START_BUTTON 0x18
+#define LINK_KEY_CODE_A_BUTTON 0x19
+#define LINK_KEY_CODE_UNK_4 0x1A // I'd guess this is the B button?
+
+// These two are a hack to stop user input until link stuff can be
+// resolved.
+#define LINK_KEY_CODE_HANDLE_RECV_QUEUE 0x1B
+#define LINK_KEY_CODE_HANDLE_SEND_QUEUE 0x1C
+#define LINK_KEY_CODE_UNK_7 0x1D
+#define LINK_KEY_CODE_UNK_8 0x1E
+
+#define MOVEMENT_MODE_FREE 0
+#define MOVEMENT_MODE_FROZEN 1
+#define MOVEMENT_MODE_SCRIPTED 2
+
struct InitialPlayerAvatarState
{
u8 transitionFlags;
@@ -12,7 +35,7 @@ struct LinkPlayerEventObject
u8 active;
u8 linkPlayerId;
u8 eventObjId;
- u8 mode;
+ u8 movementMode;
};
// Exported RAM declarations
@@ -22,10 +45,10 @@ extern struct LinkPlayerEventObject gLinkPlayerEventObjects[4];
extern u16 *gBGTilemapBuffers1;
extern u16 *gBGTilemapBuffers2;
extern u16 *gBGTilemapBuffers3;
-extern u16 gUnknown_03005DA8;
+extern u16 gHeldKeyCodeToSend;
extern void (*gFieldCallback)(void);
extern bool8 (*gFieldCallback2)(void);
-extern u8 gUnknown_03005DB4;
+extern u8 gLocalLinkPlayerId;
extern u8 gFieldLinkPlayerCount;
// Exported ROM declarations
@@ -96,19 +119,19 @@ u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum);
u8 GetMapTypeByWarpData(struct WarpData *warp);
u8 GetCurrentMapType(void);
u8 GetLastUsedWarpMapType(void);
-bool8 is_map_type_1_2_3_5_or_6(u8 mapType);
+bool8 IsMapTypeOutdoors(u8 mapType);
bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType);
-bool8 Overworld_MapTypeIsIndoors(u8 mapType);
+bool8 IsMapTypeIndoors(u8 mapType);
u8 GetSavedWarpRegionMapSectionId(void);
u8 GetCurrentRegionMapSectionId(void);
u8 GetCurrentMapBattleScene(void);
void CleanupOverworldWindowsAndTilemaps(void);
-bool32 is_c1_link_related_active(void);
+bool32 IsUpdateLinkStateCBActive(void);
void CB1_Overworld(void);
void CB2_OverworldBasic(void);
void CB2_Overworld(void);
void SetMainCallback1(void (*cb)(void));
-void sub_8085E94(void *a0);
+void SetUnusedCallback(void *a0);
void CB2_NewGame(void);
void CB2_WhiteOut(void);
void CB2_LoadMap(void);
@@ -117,18 +140,18 @@ void sub_8086074(void);
void CB2_ReturnToField(void);
void CB2_ReturnToFieldLocal(void);
void CB2_ReturnToFieldLink(void);
-void c2_8056854(void);
+void CB2_ReturnToFieldFromMultiplayer(void);
void CB2_ReturnToFieldWithOpenMenu(void);
void CB2_ReturnToFieldContinueScript(void);
void CB2_ReturnToFieldContinueScriptPlayMapMusic(void);
void sub_80861E8(void);
void CB2_ContinueSavedGame(void);
-void sub_8086C2C(void);
+void ResetAllMultiplayerState(void);
u32 sub_8087214(void);
bool32 sub_808727C(void);
u16 sub_8087288(void);
u16 sub_808729C(void);
-u16 sub_80872B0(void);
+u16 QueueExitLinkRoomKey(void);
u16 sub_80872C4(void);
bool32 sub_8087598(void);
bool32 sub_80875C8(void);
diff --git a/include/party_menu.h b/include/party_menu.h
index 702b4fde1..e67dd56f2 100644
--- a/include/party_menu.h
+++ b/include/party_menu.h
@@ -85,7 +85,7 @@ u8 GetItemEffectType(u16 item);
void CB2_PartyMenuFromStartMenu(void);
void sub_81B7F60(void);
void sub_81B8448(void);
-void sub_81B8518(u8 unused);
+void InitChooseHalfPartyForBattle(u8 unused);
void sub_81B8558(void);
void sub_81B8904(u8 initArg, MainCallback callback);
void sub_81B892C(void);
diff --git a/include/pokedex.h b/include/pokedex.h
index 6136f7786..a1b7378bf 100644
--- a/include/pokedex.h
+++ b/include/pokedex.h
@@ -43,5 +43,7 @@ s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId);
u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16);
bool16 HasAllHoennMons(void);
void ResetPokedexScrollPositions(void);
+u16 sub_80C0944(void);
+void CB2_Pokedex(void);
#endif // GUARD_POKEDEX_H
diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h
index 4f27ef281..c7b895028 100644
--- a/include/pokemon_icon.h
+++ b/include/pokemon_icon.h
@@ -23,5 +23,6 @@ void LoadMonIconPalette(u16 species);
void sub_80D328C(struct Sprite *sprite);
void sub_80D3014(struct Sprite *sprite);
void sub_80D32C8(struct Sprite *sprite, u8 animNum);
+u8 sub_80D30A0(u16 species);
#endif // GUARD_POKEMON_ICON_H
diff --git a/include/pokenav.h b/include/pokenav.h
index e5dba8ae0..29ccaec3e 100644
--- a/include/pokenav.h
+++ b/include/pokenav.h
@@ -30,5 +30,6 @@ u32 sub_81D427C(void);
void sub_81D4998(void);
void sub_81D3640(u16 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5);
void sub_81D3784(u16 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4);
+void CB2_InitPokeNav(void);
#endif //GUARD_POKENAV_H
diff --git a/include/record_mixing.h b/include/record_mixing.h
index 0d50f46f9..4cd231e8a 100644
--- a/include/record_mixing.h
+++ b/include/record_mixing.h
@@ -7,7 +7,7 @@ struct PlayerHallRecords
struct RankingHall2P twoPlayers[2];
};
-void sub_80E6BE8(void);
+void RecordMixingPlayerSpotTriggered(void);
void GetPlayerHallRecords(struct PlayerHallRecords *dst);
#endif //GUARD_RECORD_MIXING_H
diff --git a/include/rom_8011DC0.h b/include/rom_8011DC0.h
index faffd3375..ac9bbb5c3 100644
--- a/include/rom_8011DC0.h
+++ b/include/rom_8011DC0.h
@@ -17,5 +17,7 @@ u16 mevent_081445C0(u8);
void sub_801B990(u32, u32);
u8 sub_8013F78(void);
bool32 sub_802C908(u16);
+void nullsub_89(u8 taskId);
+void var_800D_set_xB(void);
#endif //GUARD_rom_8011DC0_H
diff --git a/include/save.h b/include/save.h
index 42ce8b3f3..88e5f2280 100644
--- a/include/save.h
+++ b/include/save.h
@@ -83,15 +83,16 @@ bool8 sub_8153380(void);
bool8 sub_81533AC(void);
u8 sub_81533E0(void);
u8 sub_8153408(void);
-u8 sub_8153430(void);
-bool8 sub_8153474(void);
+u8 FullSaveGame(void);
+bool8 CheckSaveFile(void);
u8 Save_LoadGameData(u8 a1);
u16 sub_815355C(void);
u8 sub_81534D0(u8);
-u8 sub_8153430(void);
-bool8 sub_8153474(void);
u32 TryCopySpecialSaveSection(u8 sector, u8* dst);
u32 sub_8153634(u8 sector, u8* src);
void sub_8153688(u8 taskId);
+// save_failed_screen.c
+void DoSaveFailedScreen(u8 saveType);
+
#endif // GUARD_SAVE_H
diff --git a/include/script.h b/include/script.h
index 386b388d0..34f4635bb 100644
--- a/include/script.h
+++ b/include/script.h
@@ -61,4 +61,7 @@ bool32 sub_80991F8(void);
u8 *sub_8099244(void);
void sub_80992A0(u8 *script, u16 scriptSize);
+// srccmd.h
+void sub_809BE48(u16 npcId);
+
#endif // GUARD_SCRIPT_H
diff --git a/include/script_menu.h b/include/script_menu.h
index a6d52c31e..1f4e549fe 100644
--- a/include/script_menu.h
+++ b/include/script_menu.h
@@ -14,5 +14,7 @@ u8 CreateWindowFromRect(u8, u8, u8, u8);
void sub_80E2A78(u8);
int display_text_and_get_width(const u8*, int);
int sub_80E2D5C(int arg0, int tileWidth);
+bool16 ScrSpecial_CreatePCMenu(void);
+void ScriptMenu_DisplayPCStartupPrompt(void);
#endif //GUARD_SCRIPT_MENU_H
diff --git a/include/secret_base.h b/include/secret_base.h
index 699158d0e..17efc314d 100644
--- a/include/secret_base.h
+++ b/include/secret_base.h
@@ -33,6 +33,8 @@ void sub_80E8B6C(void);
void sub_80E8BC8(void);
void sub_80E8D4C(void);
void EnableBothScriptContexts(void);
+void ReceiveSecretBasesData(void *records, size_t recordSize, u8 linkIdx);
+
#endif //GUARD_SECRET_BASE_H
diff --git a/include/siirtc.h b/include/siirtc.h
index 5864f95b8..de4fd634d 100644
--- a/include/siirtc.h
+++ b/include/siirtc.h
@@ -39,10 +39,10 @@ struct SiiRtcInfo
u8 alarmMinute;
};
-void SiiRtcUnprotect();
-void SiiRtcProtect();
-u8 SiiRtcProbe();
-bool8 SiiRtcReset();
+void SiiRtcUnprotect(void);
+void SiiRtcProtect(void);
+u8 SiiRtcProbe(void);
+bool8 SiiRtcReset(void);
bool8 SiiRtcGetStatus(struct SiiRtcInfo *rtc);
bool8 SiiRtcSetStatus(struct SiiRtcInfo *rtc);
bool8 SiiRtcGetDateTime(struct SiiRtcInfo *rtc);
diff --git a/include/text.h b/include/text.h
index 96c5a4507..d8f2fd8a3 100644
--- a/include/text.h
+++ b/include/text.h
@@ -284,4 +284,8 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese);
u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont9(u16 glyphId);
+// unk_text_util_2.c
+u16 Font6Func(struct TextPrinter *textPrinter);
+u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
+
#endif // GUARD_TEXT_H
diff --git a/include/trainer_card.h b/include/trainer_card.h
index 1cadbd8fc..173d23baa 100644
--- a/include/trainer_card.h
+++ b/include/trainer_card.h
@@ -43,7 +43,7 @@ struct TrainerCard
extern struct TrainerCard gTrainerCards[4];
u32 CountPlayerTrainerStars(void);
-u8 sub_80C4904(u8 cardId);
+u8 GetTrainerCardStars(u8 cardId);
void CopyTrainerCardData(struct TrainerCard *dst, u16 *src, u8 gameVersion);
void ShowPlayerTrainerCard(void (*callback)(void));
void ShowTrainerCardInLink(u8 arg0, void (*callback)(void));
diff --git a/include/trainer_hill.h b/include/trainer_hill.h
index bbc4f45c5..ad2713316 100644
--- a/include/trainer_hill.h
+++ b/include/trainer_hill.h
@@ -1,7 +1,7 @@
#ifndef GUARD_TRAINER_HILL_H
#define GUARD_TRAINER_HILL_H
-extern u32 *gUnknown_0203CF5C;
+extern u32 *gTrainerHillVBlankCounter;
void CallTrainerHillFunction(void);
void ResetTrainerHillResults(void);
diff --git a/include/window.h b/include/window.h
index 25573ac3e..10e447789 100644
--- a/include/window.h
+++ b/include/window.h
@@ -1,6 +1,8 @@
#ifndef GUARD_WINDOW_H
#define GUARD_WINDOW_H
+#define PIXEL_FILL(num) ((num) | ((num) << 4))
+
enum
{
WINDOW_BG,
@@ -73,6 +75,4 @@ extern u32 filler_03002F58;
extern u32 filler_03002F5C;
extern u32 filler_03002F64;
-extern u8 gUnknown_03002F60;
-
#endif // GUARD_WINDOW_H
diff --git a/ld_script.txt b/ld_script.txt
index acfd535f8..e60badcc2 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -165,7 +165,6 @@ SECTIONS {
src/fight.o(.text);
src/poison.o(.text);
src/flying.o(.text);
- asm/flying.o(.text);
src/psychic.o(.text);
src/bug.o(.text);
src/rock.o(.text);
diff --git a/map_data_rules.mk b/map_data_rules.mk
index 5a7d9dd84..0203b383d 100755
--- a/map_data_rules.mk
+++ b/map_data_rules.mk
@@ -3,7 +3,7 @@
MAPS_DIR = $(DATA_ASM_SUBDIR)/maps
LAYOUTS_DIR = $(DATA_ASM_SUBDIR)/layouts
-MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/))
+MAP_DIRS := $(dir $(wildcard $(MAPS_DIR)/*/map.json))
MAP_CONNECTIONS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/connections.inc,$(MAP_DIRS))
MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS))
MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS))
diff --git a/src/apprentice.c b/src/apprentice.c
index 9cf8cd4b4..27ff8e36e 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -1619,7 +1619,7 @@ static u8 CreateAndShowWindow(u8 left, u8 top, u8 width, u8 height)
static void RemoveAndHideWindow(u8 windowId)
{
- sub_8198070(windowId, TRUE);
+ ClearStdWindowAndFrameToTransparent(windowId, TRUE);
RemoveWindow(windowId);
}
@@ -1826,7 +1826,7 @@ static void Script_PrintMessage(void)
FreezeEventObjects();
sub_808B864();
sub_808BCF4();
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
PrintMessage();
}
diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c
index ee6676e64..80b3258b4 100755
--- a/src/battle_anim_effects_2.c
+++ b/src/battle_anim_effects_2.c
@@ -16,9 +16,6 @@
#include "constants/rgb.h"
#include "constants/songs.h"
-extern void sub_8108C94(struct Sprite *);
-extern void sub_810310C(u8, struct Sprite *);
-
void sub_8103448(struct Sprite *);
void sub_8103498(struct Sprite *);
void sub_810358C(struct Sprite *);
diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c
index 49fb69342..efa2620fd 100755
--- a/src/battle_anim_effects_3.c
+++ b/src/battle_anim_effects_3.c
@@ -24,9 +24,6 @@
#include "constants/species.h"
#include "constants/weather.h"
-extern u8 sub_807521C(s16 x, s16 y, u8 a3);
-extern void sub_810E2C8(struct Sprite *);
-
extern const struct SpriteTemplate gUnknown_08593114;
extern const union AffineAnimCmd *const gUnknown_082FF6C0[];
extern const union AffineAnimCmd *const gUnknown_082FF694[];
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index 05da72e16..23d469c27 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -16,6 +16,7 @@
#include "palette.h"
#include "pokeball.h"
#include "pokemon.h"
+#include "recorded_battle.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
@@ -26,15 +27,12 @@
#include "constants/battle_anim.h"
#include "constants/songs.h"
#include "constants/trainers.h"
+#include "recorded_battle.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-extern void sub_81851A8(u8 *);
-extern u16 sub_8068B48(void);
-
// this file's functions
static void LinkOpponentHandleGetMonData(void);
static void LinkOpponentHandleGetRawMonData(void);
@@ -92,7 +90,7 @@ static void LinkOpponentHandleBattleAnimation(void);
static void LinkOpponentHandleLinkStandbyMsg(void);
static void LinkOpponentHandleResetActionMoveSelection(void);
static void LinkOpponentHandleCmd55(void);
-static void nullsub_92(void);
+static void LinkOpponentCmdEnd(void);
static void LinkOpponentBufferRunCommand(void);
static void LinkOpponentBufferExecCompleted(void);
@@ -164,7 +162,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
LinkOpponentHandleLinkStandbyMsg,
LinkOpponentHandleResetActionMoveSelection,
LinkOpponentHandleCmd55,
- nullsub_92
+ LinkOpponentCmdEnd
};
static void nullsub_28(void)
@@ -1857,6 +1855,6 @@ static void LinkOpponentHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_92(void)
+static void LinkOpponentCmdEnd(void)
{
}
diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c
index 19d39609f..22633c5bc 100644
--- a/src/battle_controller_link_partner.c
+++ b/src/battle_controller_link_partner.c
@@ -16,6 +16,7 @@
#include "palette.h"
#include "pokeball.h"
#include "pokemon.h"
+#include "recorded_battle.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
@@ -26,13 +27,11 @@
#include "constants/battle_anim.h"
#include "constants/songs.h"
#include "constants/trainers.h"
+#include "recorded_battle.h"
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-extern void sub_81851A8(u8 *);
-
// this file's functions
static void LinkPartnerHandleGetMonData(void);
static void LinkPartnerHandleGetRawMonData(void);
@@ -90,7 +89,7 @@ static void LinkPartnerHandleBattleAnimation(void);
static void LinkPartnerHandleLinkStandbyMsg(void);
static void LinkPartnerHandleResetActionMoveSelection(void);
static void LinkPartnerHandleCmd55(void);
-static void nullsub_113(void);
+static void LinkPartnerCmdEnd(void);
static void LinkPartnerBufferRunCommand(void);
static void LinkPartnerBufferExecCompleted(void);
@@ -161,10 +160,10 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
LinkPartnerHandleLinkStandbyMsg,
LinkPartnerHandleResetActionMoveSelection,
LinkPartnerHandleCmd55,
- nullsub_113
+ LinkPartnerCmdEnd
};
-static void nullsub_112(void)
+static void SpriteCB_Null2(void)
{
}
@@ -1564,7 +1563,7 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->field_9_x1 = 1;
- gBattlerControllerFuncs[gActiveBattler] = nullsub_112;
+ gBattlerControllerFuncs[gActiveBattler] = SpriteCB_Null2;
}
static void sub_814DCCC(u8 taskId)
@@ -1687,6 +1686,6 @@ static void LinkPartnerHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_113(void)
+static void LinkPartnerCmdEnd(void)
{
}
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index 99bb0c588..7d940cb89 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -32,14 +32,12 @@
#include "constants/moves.h"
#include "constants/songs.h"
#include "constants/trainers.h"
+#include "trainer_hill.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-extern u8 GetTrainerHillTrainerFrontSpriteId(u16 trainerId);
-
// this file's functions
static void OpponentHandleGetMonData(void);
static void OpponentHandleGetRawMonData(void);
@@ -97,7 +95,7 @@ static void OpponentHandleBattleAnimation(void);
static void OpponentHandleLinkStandbyMsg(void);
static void OpponentHandleResetActionMoveSelection(void);
static void OpponentHandleCmd55(void);
-static void nullsub_91(void);
+static void OpponentCmdEnd(void);
static void OpponentBufferRunCommand(void);
static void OpponentBufferExecCompleted(void);
@@ -169,7 +167,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
OpponentHandleLinkStandbyMsg,
OpponentHandleResetActionMoveSelection,
OpponentHandleCmd55,
- nullsub_91
+ OpponentCmdEnd
};
// unknown unused data
@@ -2003,6 +2001,6 @@ static void OpponentHandleCmd55(void)
OpponentBufferExecCompleted();
}
-static void nullsub_91(void)
+static void OpponentCmdEnd(void)
{
}
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 6bcc97c68..b377ecf64 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -39,10 +39,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-extern void sub_81AABB0(void);
-extern void sub_81851A8(u8 *);
-
// this file's functions
static void PlayerHandleGetMonData(void);
static void PlayerHandleSetMonData(void);
@@ -99,7 +95,7 @@ static void PlayerHandleBattleAnimation(void);
static void PlayerHandleLinkStandbyMsg(void);
static void PlayerHandleResetActionMoveSelection(void);
static void PlayerHandleCmd55(void);
-static void nullsub_22(void);
+static void PlayerCmdEnd(void);
static void PlayerBufferRunCommand(void);
static void HandleInputChooseTarget(void);
@@ -186,7 +182,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
PlayerHandleLinkStandbyMsg,
PlayerHandleResetActionMoveSelection,
PlayerHandleCmd55,
- nullsub_22
+ PlayerCmdEnd
};
static const u8 sTargetIdentities[] = {B_POSITION_PLAYER_LEFT, B_POSITION_PLAYER_RIGHT, B_POSITION_OPPONENT_RIGHT, B_POSITION_OPPONENT_LEFT};
@@ -3105,6 +3101,6 @@ static void PlayerHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_22(void)
+static void PlayerCmdEnd(void)
{
}
diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c
index a9b0f376b..2c53938c1 100644
--- a/src/battle_controller_player_partner.c
+++ b/src/battle_controller_player_partner.c
@@ -30,9 +30,6 @@
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_81358F4(void);
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-
// this file's functions
static void PlayerPartnerHandleGetMonData(void);
static void PlayerPartnerHandleGetRawMonData(void);
@@ -90,7 +87,7 @@ static void PlayerPartnerHandleBattleAnimation(void);
static void PlayerPartnerHandleLinkStandbyMsg(void);
static void PlayerPartnerHandleResetActionMoveSelection(void);
static void PlayerPartnerHandleCmd55(void);
-static void nullsub_128(void);
+static void PlayerPartnerCmdEnd(void);
static void PlayerPartnerBufferRunCommand(void);
static void PlayerPartnerBufferExecCompleted(void);
@@ -167,7 +164,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
PlayerPartnerHandleLinkStandbyMsg,
PlayerPartnerHandleResetActionMoveSelection,
PlayerPartnerHandleCmd55,
- nullsub_128
+ PlayerPartnerCmdEnd
};
// unknown unused data
@@ -1928,6 +1925,6 @@ static void PlayerPartnerHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_128(void)
+static void PlayerPartnerCmdEnd(void)
{
}
diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c
index 911eb6ce5..e43c5f8ae 100644
--- a/src/battle_controller_recorded_opponent.c
+++ b/src/battle_controller_recorded_opponent.c
@@ -33,9 +33,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-extern u16 sub_8068B48(void);
-
// this file's functions
static void RecordedOpponentHandleGetMonData(void);
static void RecordedOpponentHandleGetRawMonData(void);
@@ -93,7 +90,7 @@ static void RecordedOpponentHandleBattleAnimation(void);
static void RecordedOpponentHandleLinkStandbyMsg(void);
static void RecordedOpponentHandleResetActionMoveSelection(void);
static void RecordedOpponentHandleCmd55(void);
-static void nullsub_119(void);
+static void RecordedOpponentCmdEnd(void);
static void RecordedOpponentBufferRunCommand(void);
static void RecordedOpponentBufferExecCompleted(void);
@@ -165,7 +162,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void
RecordedOpponentHandleLinkStandbyMsg,
RecordedOpponentHandleResetActionMoveSelection,
RecordedOpponentHandleCmd55,
- nullsub_119
+ RecordedOpponentCmdEnd
};
static void nullsub_70(void)
@@ -1791,6 +1788,6 @@ static void RecordedOpponentHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_119(void)
+static void RecordedOpponentCmdEnd(void)
{
}
diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c
index b2dfca6a0..412c49f17 100644
--- a/src/battle_controller_recorded_player.c
+++ b/src/battle_controller_recorded_player.c
@@ -30,8 +30,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-
// this file's functions
static void RecordedPlayerHandleGetMonData(void);
static void RecordedPlayerHandleGetRawMonData(void);
@@ -89,7 +87,7 @@ static void RecordedPlayerHandleBattleAnimation(void);
static void RecordedPlayerHandleLinkStandbyMsg(void);
static void RecordedPlayerHandleResetActionMoveSelection(void);
static void RecordedPlayerHandleCmd55(void);
-static void nullsub_121(void);
+static void RecordedPlayerCmdEnd(void);
static void RecordedPlayerBufferRunCommand(void);
static void RecordedPlayerBufferExecCompleted(void);
@@ -160,7 +158,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void)
RecordedPlayerHandleLinkStandbyMsg,
RecordedPlayerHandleResetActionMoveSelection,
RecordedPlayerHandleCmd55,
- nullsub_121
+ RecordedPlayerCmdEnd
};
static void nullsub_120(void)
@@ -1808,6 +1806,6 @@ static void RecordedPlayerHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_121(void)
+static void RecordedPlayerCmdEnd(void)
{
}
diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c
index 54ba04ab4..e9da16252 100644
--- a/src/battle_controller_safari.c
+++ b/src/battle_controller_safari.c
@@ -25,8 +25,6 @@
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_81358F4(void);
-
// this file's functions
static void SafariHandleGetMonData(void);
static void SafariHandleGetRawMonData(void);
@@ -84,7 +82,7 @@ static void SafariHandleBattleAnimation(void);
static void SafariHandleLinkStandbyMsg(void);
static void SafariHandleResetActionMoveSelection(void);
static void SafariHandleCmd55(void);
-static void nullsub_115(void);
+static void SafariCmdEnd(void);
static void SafariBufferRunCommand(void);
static void SafariBufferExecCompleted(void);
@@ -148,10 +146,10 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
SafariHandleLinkStandbyMsg,
SafariHandleResetActionMoveSelection,
SafariHandleCmd55,
- nullsub_115
+ SafariCmdEnd
};
-static void nullsub_114(void)
+static void SpriteCB_Null4(void)
{
}
@@ -688,6 +686,6 @@ static void SafariHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_81595E4;
}
-static void nullsub_115(void)
+static void SafariCmdEnd(void)
{
}
diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c
index d891b96b6..f1b783b21 100644
--- a/src/battle_controller_wally.c
+++ b/src/battle_controller_wally.c
@@ -33,8 +33,6 @@
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
-extern void sub_8172EF0(u8 battlerId, struct Pokemon *mon);
-
// this file's functions
static void WallyHandleGetMonData(void);
static void WallyHandleGetRawMonData(void);
@@ -92,7 +90,7 @@ static void WallyHandleBattleAnimation(void);
static void WallyHandleLinkStandbyMsg(void);
static void WallyHandleResetActionMoveSelection(void);
static void WallyHandleCmd55(void);
-static void nullsub_118(void);
+static void WallyCmdEnd(void);
static void WallyBufferRunCommand(void);
static void WallyBufferExecCompleted(void);
@@ -161,10 +159,10 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
WallyHandleLinkStandbyMsg,
WallyHandleResetActionMoveSelection,
WallyHandleCmd55,
- nullsub_118
+ WallyCmdEnd
};
-static void nullsub_117(void)
+static void SpriteCB_Null7(void)
{
}
@@ -1559,6 +1557,6 @@ static void WallyHandleCmd55(void)
gBattlerControllerFuncs[gActiveBattler] = sub_80587B0;
}
-static void nullsub_118(void)
+static void WallyCmdEnd(void)
{
}
diff --git a/src/battle_controllers.c b/src/battle_controllers.c
index 70a53f332..29272c19a 100644
--- a/src/battle_controllers.c
+++ b/src/battle_controllers.c
@@ -767,7 +767,7 @@ static void Task_HandleSendLinkBuffersData(u8 taskId)
{
if (IsLinkMaster())
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
gTasks[taskId].data[11]++;
}
else
diff --git a/src/battle_dome.c b/src/battle_dome.c
index bfede1b28..f86faeffb 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -3794,7 +3794,7 @@ static void sub_8190CD4(u8 taskId)
for (i = windowId; i < windowId + 9; i++)
{
CopyWindowToVram(i, 2);
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
gTasks[taskId].data[0] = 3;
break;
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index e48dbd30b..85c0b2808 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -1741,7 +1741,7 @@ static void Select_CopyMonsToPlayerParty(void)
{
gPlayerParty[i] = sFactorySelectScreen->mons[j].monData;
gSaveBlock2Ptr->frontier.rentalMons[i].monId = sFactorySelectScreen->mons[j].monSetId;
- gSaveBlock2Ptr->frontier.rentalMons[i].personality = GetMonData(&gPlayerParty[i].box, MON_DATA_PERSONALITY, NULL);
+ gSaveBlock2Ptr->frontier.rentalMons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY, NULL);
gSaveBlock2Ptr->frontier.rentalMons[i].abilityBit = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ALT_ABILITY, NULL);
gSaveBlock2Ptr->frontier.rentalMons[i].ivs = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ATK_IV, NULL);
break;
@@ -1786,14 +1786,14 @@ static void sub_819B958(u8 windowId)
{
gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE;
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
CopyWindowToVram(windowId, 2);
ClearWindowTilemap(windowId);
}
static void Select_PrintRentalPkmnString(void)
{
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
AddTextPrinterParameterized(0, 1, gText_RentalPkmn2, 2, 1, 0, NULL);
CopyWindowToVram(0, 3);
}
@@ -1804,7 +1804,7 @@ static void Select_PrintMonSpecies(void)
u8 x;
u8 monId = sFactorySelectScreen->cursorPos;
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL);
StringCopy(gStringVar4, gSpeciesNames[species]);
x = GetStringRightAlignXOffset(1, gStringVar4, 86);
@@ -1816,7 +1816,7 @@ static void Select_PrintSelectMonString(void)
{
const u8 *str = NULL;
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
if (sFactorySelectScreen->selectingMonsState == 1)
str = gText_SelectFirstPkmn;
else if (sFactorySelectScreen->selectingMonsState == 2)
@@ -1832,7 +1832,7 @@ static void Select_PrintSelectMonString(void)
static void Select_PrintCantSelectSameMon(void)
{
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized(2, 1, gText_CantSelectSamePkmn, 2, 5, 0, NULL);
CopyWindowToVram(2, 2);
}
@@ -1842,7 +1842,7 @@ static void Select_PrintMenuOptions(void)
u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId;
PutWindowTilemap(3);
- FillWindowPixelBuffer(3, 0);
+ FillWindowPixelBuffer(3, PIXEL_FILL(0));
AddTextPrinterParameterized3(3, 1, 7, 1, gUnknown_08610476, 0, gText_Summary);
if (selectedId != 0)
AddTextPrinterParameterized3(3, 1, 7, 17, gUnknown_08610476, 0, gText_Deselect);
@@ -1856,7 +1856,7 @@ static void Select_PrintMenuOptions(void)
static void Select_PrintYesNoOptions(void)
{
PutWindowTilemap(4);
- FillWindowPixelBuffer(4, 0);
+ FillWindowPixelBuffer(4, PIXEL_FILL(0));
AddTextPrinterParameterized3(4, 1, 7, 1, gUnknown_08610476, 0, gText_Yes2);
AddTextPrinterParameterized3(4, 1, 7, 17, gUnknown_08610476, 0, gText_No2);
CopyWindowToVram(4, 3);
@@ -1924,7 +1924,7 @@ static void Select_PrintMonCategory(void)
if (monId < SELECTABLE_MONS_COUNT)
{
PutWindowTilemap(5);
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL);
CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text);
x = GetStringRightAlignXOffset(1, text, 0x76);
@@ -2873,7 +2873,7 @@ static void sub_819D588(u8 taskId)
case 3:
if (!gPaletteFade.active)
{
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
CopyWindowToVram(5, 2);
if (sFactorySwapScreen->inEnemyScreen == TRUE)
{
@@ -3002,7 +3002,7 @@ static void sub_819D770(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 6:
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
CopyWindowToVram(5, 2);
gTasks[taskId].data[0]++;
break;
@@ -3546,7 +3546,7 @@ static void sub_819EA64(u8 windowId)
{
gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE;
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
CopyWindowToVram(windowId, 2);
ClearWindowTilemap(windowId);
}
@@ -3554,14 +3554,14 @@ static void sub_819EA64(u8 windowId)
static void sub_819EAC0(void)
{
PutWindowTilemap(1);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
CopyWindowToVram(1, 2);
}
static void sub_819EADC(void)
{
PutWindowTilemap(7);
- FillWindowPixelBuffer(7, 0);
+ FillWindowPixelBuffer(7, PIXEL_FILL(0));
CopyWindowToVram(7, 2);
}
@@ -3569,13 +3569,13 @@ static void sub_819EAF8(void)
{
sub_819EAC0();
PutWindowTilemap(5);
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
CopyWindowToVram(5, 2);
}
static void Swap_PrintPkmnSwap(void)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, 1, gText_PkmnSwap, 2, 1, 0, NULL);
CopyWindowToVram(0, 3);
}
@@ -3585,7 +3585,7 @@ static void Swap_PrintMonSpecies(void)
u16 species;
u8 x;
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
if (sFactorySwapScreen->cursorPos > 2)
{
CopyWindowToVram(1, 2);
@@ -3606,7 +3606,7 @@ static void Swap_PrintMonSpecies(void)
static void Swap_PrintOnInfoWindow(const u8 *str)
{
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized(2, 1, str, 2, 5, 0, NULL);
CopyWindowToVram(2, 2);
}
@@ -3614,7 +3614,7 @@ static void Swap_PrintOnInfoWindow(const u8 *str)
static void Swap_PrintMenuOptions(void)
{
PutWindowTilemap(3);
- FillWindowPixelBuffer(3, 0);
+ FillWindowPixelBuffer(3, PIXEL_FILL(0));
AddTextPrinterParameterized3(3, 1, 15, 1, gUnknown_08610922, 0, gText_Summary2);
AddTextPrinterParameterized3(3, 1, 15, 17, gUnknown_08610922, 0, gText_Swap);
AddTextPrinterParameterized3(3, 1, 15, 33, gUnknown_08610922, 0, gText_Rechoose);
@@ -3624,7 +3624,7 @@ static void Swap_PrintMenuOptions(void)
static void Swap_PrintYesNoOptions(void)
{
PutWindowTilemap(4);
- FillWindowPixelBuffer(4, 0);
+ FillWindowPixelBuffer(4, PIXEL_FILL(0));
AddTextPrinterParameterized3(4, 1, 7, 1, gUnknown_08610922, 0, gText_Yes3);
AddTextPrinterParameterized3(4, 1, 7, 17, gUnknown_08610922, 0, gText_No3);
CopyWindowToVram(4, 3);
@@ -3638,7 +3638,7 @@ static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId)
static void Swap_PrintActionStrings(void)
{
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
switch (sFactorySwapScreen->inEnemyScreen)
{
case TRUE:
@@ -3652,7 +3652,7 @@ static void Swap_PrintActionStrings(void)
static void Swap_PrintActionStrings2(void)
{
- FillWindowPixelBuffer(3, 0);
+ FillWindowPixelBuffer(3, PIXEL_FILL(0));
switch (sFactorySwapScreen->inEnemyScreen)
{
case TRUE:
@@ -3693,7 +3693,7 @@ static void Swap_PrintMonSpecies2(void)
LoadPalette(pal, 0xF0, 0xA);
PutWindowTilemap(7);
- FillWindowPixelBuffer(7, 0);
+ FillWindowPixelBuffer(7, PIXEL_FILL(0));
if (sFactorySwapScreen->cursorPos > 2)
{
CopyWindowToVram(7, 3);
@@ -3745,7 +3745,7 @@ static void Swap_PrintMonCategory(void)
u8 x;
u8 monId = sFactorySwapScreen->cursorPos;
- FillWindowPixelBuffer(8, 0);
+ FillWindowPixelBuffer(8, PIXEL_FILL(0));
if (monId > 2)
{
CopyWindowToVram(8, 2);
@@ -3940,7 +3940,7 @@ static void Task_SwapCantHaveSameMons(u8 taskId)
case 2:
if (sFactorySwapScreen->unk30 != TRUE)
{
- FillWindowPixelBuffer(5, 0);
+ FillWindowPixelBuffer(5, PIXEL_FILL(0));
CopyWindowToVram(5, 2);
gTasks[taskId].data[0]++;
}
diff --git a/src/battle_interface.c b/src/battle_interface.c
index 4a6ac67f1..f2916012e 100644
--- a/src/battle_interface.c
+++ b/src/battle_interface.c
@@ -2579,7 +2579,7 @@ static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y,
struct WindowTemplate winTemplate = sHealthboxWindowTemplate;
winId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(winId, (bgColor << 4) | (bgColor));
+ FillWindowPixelBuffer(winId, PIXEL_FILL(bgColor));
color[0] = bgColor;
color[1] = 1;
diff --git a/src/battle_main.c b/src/battle_main.c
index 043e75808..2b0c5980e 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -57,6 +57,7 @@
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/trainers.h"
+#include "cable_club.h"
extern struct MusicPlayerInfo gMPlayInfo_SE1;
extern struct MusicPlayerInfo gMPlayInfo_SE2;
@@ -69,9 +70,6 @@ extern const u8 *const gBattlescriptsForRunningByItem[];
extern const u8 *const gBattlescriptsForUsingItem[];
extern const u8 *const gBattlescriptsForSafariActions[];
-// functions
-extern void sub_80B3AF8(u8 taskId); // cable club
-
// this file's functions
static void CB2_InitBattleInternal(void);
static void CB2_PreInitMultiBattle(void);
@@ -3279,7 +3277,7 @@ void FaintClearSetData(void)
gProtectStructs[gActiveBattler].targetNotAffected = 0;
gProtectStructs[gActiveBattler].chargingTurn = 0;
gProtectStructs[gActiveBattler].fleeFlag = 0;
- gProtectStructs[gActiveBattler].usedImprisionedMove = 0;
+ gProtectStructs[gActiveBattler].usedImprisonedMove = 0;
gProtectStructs[gActiveBattler].loveImmobility = 0;
gProtectStructs[gActiveBattler].usedDisabledMove = 0;
gProtectStructs[gActiveBattler].usedTauntedMove = 0;
diff --git a/src/battle_message.c b/src/battle_message.c
index 164108dec..6762cd416 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -1357,7 +1357,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
{
// The corresponding WindowTemplate is gStandardBattleWindowTemplates[] within src/battle_bg.c
{ // 0 Standard battle message
- .fillValue = 0xFF,
+ .fillValue = PIXEL_FILL(0xF),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1369,7 +1369,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 6,
},
{ // 1 "What will (pokemon) do?"
- .fillValue = 0xFF,
+ .fillValue = PIXEL_FILL(0xF),
.fontId = 1,
.x = 1,
.y = 1,
@@ -1381,7 +1381,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 6,
},
{ // 2 "Fight/Pokemon/Bag/Run"
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1393,7 +1393,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 3 Top left move
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1405,7 +1405,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 4 Top right move
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1417,7 +1417,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 5 Bottom left move
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1429,7 +1429,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 6 Bottom right move
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1441,7 +1441,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 7 "PP"
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1453,7 +1453,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 11,
},
{ // 8
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1465,7 +1465,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 9 PP remaining
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 2,
.y = 1,
@@ -1477,7 +1477,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 11,
},
{ // 10 "type"
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1489,7 +1489,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 11 "switch which?"
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1501,7 +1501,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 12 "gText_BattleYesNoChoice"
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1513,7 +1513,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 13
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1525,7 +1525,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 14
- .fillValue = 0x0,
+ .fillValue = PIXEL_FILL(0),
.fontId = 1,
.x = 32,
.y = 1,
@@ -1537,7 +1537,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 2,
},
{ // 15
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1549,7 +1549,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 16
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1561,7 +1561,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 17
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1573,7 +1573,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 18
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1585,7 +1585,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 19
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1597,7 +1597,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 20
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1609,7 +1609,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 15,
},
{ // 21
- .fillValue = 0x0,
+ .fillValue = PIXEL_FILL(0),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1621,7 +1621,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 6,
},
{ // 22
- .fillValue = 0x0,
+ .fillValue = PIXEL_FILL(0),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1633,7 +1633,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
.shadowColor = 6,
},
{ // 23
- .fillValue = 0x0,
+ .fillValue = PIXEL_FILL(0x0),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1649,7 +1649,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] =
static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
{
{ // 0
- .fillValue = 0xFF,
+ .fillValue = PIXEL_FILL(0xF),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1661,7 +1661,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 6,
},
{ // 1
- .fillValue = 0xFF,
+ .fillValue = PIXEL_FILL(0xF),
.fontId = 1,
.x = 1,
.y = 1,
@@ -1673,7 +1673,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 6,
},
{ // 2
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1685,7 +1685,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 3
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1697,7 +1697,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 4
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1709,7 +1709,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 5
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1721,7 +1721,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 6
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1733,7 +1733,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 7
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1745,7 +1745,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 11,
},
{ // 8
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1757,7 +1757,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 9
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 2,
.y = 1,
@@ -1769,7 +1769,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 11,
},
{ // 10
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1781,7 +1781,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 11
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 7,
.x = 0,
.y = 1,
@@ -1793,7 +1793,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 12
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1805,7 +1805,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 13
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = 0,
.y = 1,
@@ -1817,7 +1817,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 14
- .fillValue = 0x0,
+ .fillValue = PIXEL_FILL(0),
.fontId = 1,
.x = 32,
.y = 1,
@@ -1829,7 +1829,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 2,
},
{ // 15
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1841,7 +1841,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 16
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1853,7 +1853,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 17
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1865,7 +1865,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 18
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1877,7 +1877,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 19
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1889,7 +1889,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 20
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1901,7 +1901,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 21
- .fillValue = 0xEE,
+ .fillValue = PIXEL_FILL(0xE),
.fontId = 1,
.x = -1,
.y = 1,
@@ -1913,7 +1913,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] =
.shadowColor = 15,
},
{ // 22
- .fillValue = 0x11,
+ .fillValue = PIXEL_FILL(0x1),
.fontId = 1,
.x = 0,
.y = 1,
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index 340c17c59..34da3a25d 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -1267,7 +1267,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
{
for (x = 0; x < 32; x++)
{
- if ((map[x] & 0x3FF) == FLOOR_EXIT_METATILE)
+ if ((map[x] & METATILE_ID_MASK) == FLOOR_EXIT_METATILE)
{
x += 7 - gEventObjects[gSelectedEventObject].initialCoords.x;
y += 7 - gEventObjects[gSelectedEventObject].initialCoords.y;
@@ -1568,7 +1568,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
{
for (x = 0; x < mapLayout->width; x++)
{
- if ((layoutMap[x] & 0x3FF) != FLOOR_EXIT_METATILE)
+ if ((layoutMap[x] & METATILE_ID_MASK) != FLOOR_EXIT_METATILE)
{
map[x] = layoutMap[x];
}
diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c
index 1f0672dcb..2e13ea08b 100644
--- a/src/battle_pyramid_bag.c
+++ b/src/battle_pyramid_bag.c
@@ -651,7 +651,7 @@ static void PrintItemDescription(s32 listMenuId)
StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1);
desc = gStringVar4;
}
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, desc, 3, 0, 0, 1, 0, 0);
}
@@ -804,7 +804,7 @@ static void sub_81C5A98(u8 listMenuTaskId, u8 arg1)
static void sub_81C5AB8(u8 y, u8 arg1)
{
if (arg1 == 0xFF)
- FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
+ FillWindowPixelRect(0, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else
PrintOnWindow_Font1(0, gText_SelectorArrow2, 0, y, 0, 0, 0, arg1);
}
@@ -911,7 +911,7 @@ static void sub_81C5D20(u8 taskId)
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0);
if (gPyramidBagResources->menuActionsCount == 1)
sub_81C5EAC(sub_81C6D24(0));
@@ -1048,7 +1048,7 @@ static void BagAction_UseOnField(u8 taskId)
else if (ItemId_GetFieldFunc(gSpecialVar_ItemId) != NULL)
{
sub_81C61A8();
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
schedule_bg_copy_tilemap_to_vram(0);
ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId);
}
@@ -1086,7 +1086,7 @@ static void BagAction_Toss(u8 taskId)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0);
sub_81C6404();
gTasks[taskId].func = sub_81C64B4;
@@ -1100,7 +1100,7 @@ static void sub_81C6350(u8 taskId)
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 2);
StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0);
sub_81C6DAC(taskId, &sYesNoTossFuncions);
}
@@ -1146,7 +1146,7 @@ static void sub_81C64B4(u8 taskId)
else if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- sub_8198070(3, 0);
+ ClearStdWindowAndFrameToTransparent(3, 0);
ClearWindowTilemap(3);
schedule_bg_copy_tilemap_to_vram(1);
sub_81C6350(taskId);
@@ -1154,7 +1154,7 @@ static void sub_81C64B4(u8 taskId)
else if (gMain.newKeys & B_BUTTON)
{
PlaySE(SE_SELECT);
- sub_8198070(3, 0);
+ ClearStdWindowAndFrameToTransparent(3, 0);
ClearWindowTilemap(3);
schedule_bg_copy_tilemap_to_vram(1);
DontTossItem(taskId);
@@ -1168,7 +1168,7 @@ static void TossItem(u8 taskId)
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 2);
StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0);
gTasks[taskId].func = sub_81C65CC;
}
@@ -1265,7 +1265,7 @@ static void Task_BeginItemSwap(u8 taskId)
ListMenuSetUnkIndicatorsStructField(data[0], 0x10, 1);
CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][data[1]], gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0);
sub_81C5A98(data[0], 1);
sub_81C704C(data[1]);
@@ -1395,7 +1395,7 @@ static void sub_81C6BD8(void)
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
for (i = 0; i < 5; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
PutWindowTilemap(0);
PutWindowTilemap(1);
@@ -1415,7 +1415,7 @@ static void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 lette
static void sub_81C6CEC(u8 windowId)
{
- SetWindowBorderStyle(windowId, 0, 1, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(windowId, 0, 1, 0xE);
schedule_bg_copy_tilemap_to_vram(1);
}
@@ -1430,7 +1430,7 @@ static u8 sub_81C6D24(u8 windowArrayId)
if (*windowId == 0xFF)
{
*windowId = AddWindow(&gUnknown_0861F350[windowArrayId]);
- SetWindowBorderStyle(*windowId, FALSE, 1, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(*windowId, FALSE, 1, 0xE);
schedule_bg_copy_tilemap_to_vram(1);
}
return *windowId;
@@ -1441,7 +1441,7 @@ static void sub_81C6D6C(u8 windowArrayId)
u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId];
if (*windowId != 0xFF)
{
- sub_8198070(*windowId, FALSE);
+ ClearStdWindowAndFrameToTransparent(*windowId, FALSE);
ClearWindowTilemap(*windowId);
RemoveWindow(*windowId);
schedule_bg_copy_tilemap_to_vram(1);
@@ -1456,14 +1456,15 @@ static void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable)
void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId))
{
- FillWindowPixelBuffer(2, 0x11);
+ FillWindowPixelBuffer(2, PIXEL_FILL(1));
DisplayMessageAndContinueTask(taskId, 2, 0xA, 0xD, 1, GetPlayerTextSpeedDelay(), str, callback);
schedule_bg_copy_tilemap_to_vram(1);
}
static void sub_81C6E1C(void)
{
- sub_8197DF8(2, FALSE);
+ ClearDialogWindowAndFrameToTransparent(2, FALSE);
+ // This ClearWindowTilemap call is redundant, since ClearDialogWindowAndFrameToTransparent already calls it.
ClearWindowTilemap(2);
schedule_bg_copy_tilemap_to_vram(1);
}
diff --git a/src/battle_records.c b/src/battle_records.c
index f9c40d8de..fdd915d07 100644
--- a/src/battle_records.c
+++ b/src/battle_records.c
@@ -21,8 +21,7 @@
#include "alloc.h"
#include "gpu_regs.h"
#include "constants/game_stat.h"
-
-extern void PrintOnTrainerHillRecordsWindow(void); // pokenav.s
+#include "trainer_hill.h"
// this file's functions
static void Task_CloseTrainerHillRecordsOnButton(u8 taskId);
@@ -320,8 +319,8 @@ void ShowLinkBattleRecords(void)
s32 i, x;
gRecordsWindowId = AddWindow(&sLinkBattleRecordsWindow);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
StringExpandPlaceholders(gStringVar4, gText_PlayersBattleResults);
x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
@@ -342,7 +341,7 @@ void ShowLinkBattleRecords(void)
void RemoveRecordsWindow(void)
{
- sub_819746C(gRecordsWindowId, FALSE);
+ ClearStdWindowAndFrame(gRecordsWindowId, FALSE);
RemoveWindow(gRecordsWindowId);
}
@@ -383,7 +382,7 @@ static void Task_ExitTrainerHillRecords(u8 taskId)
static void RemoveTrainerHillRecordsWindow(u8 windowId)
{
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
ClearWindowTilemap(windowId);
CopyWindowToVram(windowId, 2);
RemoveWindow(windowId);
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index a53fa30f2..ac9fb3073 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -48,6 +48,7 @@
#include "battle_pyramid.h"
#include "field_specials.h"
#include "pokemon_summary_screen.h"
+#include "pokenav.h"
extern struct MusicPlayerInfo gMPlayInfo_BGM;
@@ -55,9 +56,6 @@ extern const u8* const gBattleScriptsForMoveEffects[];
// functions
extern void sub_81D388C(struct Pokemon* mon, void* statStoreLocation); // pokenav.s
-extern void sub_81D3640(u16 arg0, void* statStoreLocation1, void* statStoreLocation2, u8 arg3, u8 arg4, u8 arg5); // pokenav.s
-extern void sub_81D3784(u16 arg0, void* statStoreLocation1, u8 arg2, u8 arg3, u8 arg4); // pokenav.s
-extern u8 sub_813B21C(void);
#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBattlerTarget].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED))
@@ -297,7 +295,7 @@ static void atkD7_setyawn(void);
static void atkD8_setdamagetohealthdifference(void);
static void atkD9_scaledamagebyhealthratio(void);
static void atkDA_tryswapabilities(void);
-static void atkDB_tryimprision(void);
+static void atkDB_tryimprison(void);
static void atkDC_trysetgrudge(void);
static void atkDD_weightdamagecalculation(void);
static void atkDE_asistattackselect(void);
@@ -549,7 +547,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
atkD8_setdamagetohealthdifference,
atkD9_scaledamagebyhealthratio,
atkDA_tryswapabilities,
- atkDB_tryimprision,
+ atkDB_tryimprison,
atkDC_trysetgrudge,
atkDD_weightdamagecalculation,
atkDE_asistattackselect,
@@ -9611,7 +9609,7 @@ static void atkDA_tryswapabilities(void) // skill swap
}
}
-static void atkDB_tryimprision(void)
+static void atkDB_tryimprison(void)
{
if ((gStatuses3[gBattlerAttacker] & STATUS3_IMPRISONED_OTHERS))
{
@@ -9622,7 +9620,7 @@ static void atkDB_tryimprision(void)
u8 battlerId, sideAttacker;
sideAttacker = GetBattlerSide(gBattlerAttacker);
- PressurePPLoseOnUsingImprision(gBattlerAttacker);
+ PressurePPLoseOnUsingImprison(gBattlerAttacker);
for (battlerId = 0; battlerId < gBattlersCount; battlerId++)
{
if (sideAttacker != GetBattlerSide(battlerId))
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 7626420e9..347486a0b 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -44,6 +44,7 @@
#include "mirage_tower.h"
#include "constants/map_types.h"
#include "constants/battle_frontier.h"
+#include "field_screen_effect.h"
enum
{
@@ -62,10 +63,6 @@ struct TrainerBattleParameter
u8 ptrType;
};
-extern void ClearPoisonStepCounter(void);
-extern void sub_808BCF4(void);
-extern void sub_80AF6F0(void);
-
// this file's functions
static void DoBattlePikeWildBattle(void);
static void DoSafariBattle(void);
@@ -641,7 +638,7 @@ u8 BattleSetup_GetTerrainId(void)
return BATTLE_TERRAIN_BUILDING;
case MAP_TYPE_UNDERWATER:
return BATTLE_TERRAIN_UNDERWATER;
- case MAP_TYPE_6:
+ case MAP_TYPE_OCEAN_ROUTE:
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior))
return BATTLE_TERRAIN_WATER;
return BATTLE_TERRAIN_PLAIN;
diff --git a/src/battle_tower.c b/src/battle_tower.c
index 06aaef48d..46aab4bac 100644
--- a/src/battle_tower.c
+++ b/src/battle_tower.c
@@ -51,7 +51,7 @@ static void AwardBattleTowerRibbons(void);
static void SaveBattleTowerProgress(void);
static void sub_8163914(void);
static void nullsub_61(void);
-static void nullsub_116(void);
+static void SpriteCB_Null6(void);
static void sub_81642A0(void);
static void sub_8164828(void);
static void sub_8164B74(void);
@@ -1061,7 +1061,7 @@ static void (* const gUnknown_085DF96C[])(void) =
SaveBattleTowerProgress,
sub_8163914,
nullsub_61,
- nullsub_116,
+ SpriteCB_Null6,
sub_81642A0,
sub_8164828,
sub_8164B74,
@@ -2437,7 +2437,7 @@ static void nullsub_61(void)
}
-static void nullsub_116(void)
+static void SpriteCB_Null6(void)
{
}
diff --git a/src/battle_util.c b/src/battle_util.c
index 2f583a9c7..aa88cf952 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -106,10 +106,10 @@ void PressurePPLose(u8 target, u8 attacker, u16 move)
}
}
-void PressurePPLoseOnUsingImprision(u8 attacker)
+void PressurePPLoseOnUsingImprison(u8 attacker)
{
int i, j;
- int imprisionPos = 4;
+ int imprisonPos = 4;
u8 atkSide = GetBattlerSide(attacker);
for (i = 0; i < gBattlersCount; i++)
@@ -123,19 +123,19 @@ void PressurePPLoseOnUsingImprision(u8 attacker)
}
if (j != MAX_MON_MOVES)
{
- imprisionPos = j;
+ imprisonPos = j;
if (gBattleMons[attacker].pp[j] != 0)
gBattleMons[attacker].pp[j]--;
}
}
}
- if (imprisionPos != 4
+ if (imprisonPos != 4
&& !(gBattleMons[attacker].status2 & STATUS2_TRANSFORMED)
- && !(gDisableStructs[attacker].mimickedMoves & gBitTable[imprisionPos]))
+ && !(gDisableStructs[attacker].mimickedMoves & gBitTable[imprisonPos]))
{
gActiveBattler = attacker;
- BtlController_EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + imprisionPos, 0, 1, &gBattleMons[gActiveBattler].pp[imprisionPos]);
+ BtlController_EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + imprisonPos, 0, 1, &gBattleMons[gActiveBattler].pp[imprisonPos]);
MarkBattlerForControllerExec(gActiveBattler);
}
}
@@ -224,7 +224,7 @@ bool8 WasUnableToUseMove(u8 battler)
{
if (gProtectStructs[battler].prlzImmobility
|| gProtectStructs[battler].targetNotAffected
- || gProtectStructs[battler].usedImprisionedMove
+ || gProtectStructs[battler].usedImprisonedMove
|| gProtectStructs[battler].loveImmobility
|| gProtectStructs[battler].usedDisabledMove
|| gProtectStructs[battler].usedTauntedMove
@@ -365,12 +365,12 @@ u8 TrySetCantSelectMoveBattleScript(void)
gCurrentMove = move;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{
- gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisionedMoveInPalace;
+ gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1;
}
else
{
- gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisionedMove;
+ gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMove;
limitations++;
}
}
@@ -438,7 +438,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].tauntTimer && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0)
unusableMoves |= gBitTable[i];
- if (GetImprisonedMovesCount(battlerId, gBattleMons[battlerId].moves[i]) && check & MOVE_LIMITATION_IMPRISION)
+ if (GetImprisonedMovesCount(battlerId, gBattleMons[battlerId].moves[i]) && check & MOVE_LIMITATION_IMPRISON)
unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i])
unusableMoves |= gBitTable[i];
@@ -469,7 +469,7 @@ bool8 AreAllMovesUnusable(void)
u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
{
s32 i;
- u8 imprisionedMoves = 0;
+ u8 imprisonedMoves = 0;
u8 battlerSide = GetBattlerSide(battlerId);
for (i = 0; i < gBattlersCount; i++)
@@ -483,11 +483,11 @@ u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
break;
}
if (j < MAX_MON_MOVES)
- imprisionedMoves++;
+ imprisonedMoves++;
}
}
- return imprisionedMoves;
+ return imprisonedMoves;
}
enum
@@ -1466,7 +1466,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_IMPRISONED: // imprisoned
if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove))
{
- gProtectStructs[gBattlerAttacker].usedImprisionedMove = 1;
+ gProtectStructs[gBattlerAttacker].usedImprisonedMove = 1;
CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@@ -1526,7 +1526,7 @@ u8 AtkCanceller_UnableToUseMove(void)
}
else
{
- BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack);
+ BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gProtectStructs[gBattlerAttacker].loveImmobility = 1;
CancelMultiTurnMoves(gBattlerAttacker);
diff --git a/src/berry.c b/src/berry.c
index bd596db7f..cbac06a3d 100644
--- a/src/berry.c
+++ b/src/berry.c
@@ -11,11 +11,9 @@
#include "text.h"
#include "constants/event_object_movement_constants.h"
#include "constants/items.h"
+#include "event_object_movement.h"
+
-extern u8 EventObjectGetBerryTreeId(u8 eventObjectId);
-extern void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
-extern void CB2_ChooseBerry(void);
-extern bool8 IsBerryTreeSparkling(u8, u8, u8);
extern const u8 BerryTreeScript[];
diff --git a/src/berry_blender.c b/src/berry_blender.c
index c85d0e827..450bcae42 100644
--- a/src/berry_blender.c
+++ b/src/berry_blender.c
@@ -34,6 +34,8 @@
#include "battle_records.h"
#include "graphics.h"
#include "new_game.h"
+#include "save.h"
+#include "link.h"
#define BLENDER_SCORE_BEST 0
#define BLENDER_SCORE_GOOD 1
@@ -140,16 +142,6 @@ extern const u8 gText_Space[];
extern const u8 gText_BlenderMaxSpeedRecord[];
extern const u8 gText_234Players[];
-extern void sub_800A418(void);
-extern u8 sub_800A9D8(void);
-extern void sub_81AABF0(void (*callback)(void));
-extern void sub_800B4C0(void);
-extern void ClearLinkCallback(void);
-extern void sub_8009F8C(void);
-extern void sub_8153430(void);
-extern bool8 sub_8153474(void);
-extern void sub_80EECEC(void);
-
// this file's functions
static void BerryBlender_SetBackgroundsPos(void);
static void sub_8080EA4(u8 taskId);
@@ -945,7 +937,7 @@ static void InitBerryBlenderWindows(void)
DeactivateAllTextPrinters();
for (i = 0; i < 5; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14);
sub_81978B0(0xE0);
@@ -1251,7 +1243,7 @@ static void sub_8080018(void)
case 10:
if (++sBerryBlenderData->framesToWait > 20)
{
- sub_8197DF8(4, TRUE);
+ ClearDialogWindowAndFrameToTransparent(4, TRUE);
if (GetBlockReceivedStatus() == sub_800A9D8())
{
for (i = 0; i < GetLinkPlayerCount(); i++)
@@ -2600,7 +2592,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
}
break;
case 2:
- sub_8153430();
+ FullSaveGame();
sBerryBlenderData->field_1A0++;
sBerryBlenderData->framesToWait = 0;
break;
@@ -2614,7 +2606,7 @@ static bool8 LinkPlayAgainHandleSaving(void)
case 4:
if (IsLinkTaskFinished())
{
- if (sub_8153474())
+ if (CheckSaveFile())
{
sBerryBlenderData->field_1A0 = 5;
}
@@ -3325,7 +3317,7 @@ static bool8 Blender_PrintBlendingResults(void)
sBerryBlenderData->mainState++;
break;
case 5:
- sub_8198070(5, 1);
+ ClearStdWindowAndFrameToTransparent(5, 1);
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
@@ -3466,7 +3458,7 @@ static bool8 Blender_PrintBlendingRanking(void)
}
break;
case 3:
- SetWindowBorderStyle(5, 0, 1, 0xD);
+ DrawStdFrameWithCustomTileAndPalette(5, 0, 1, 0xD);
xPos = GetStringCenterAlignXOffset(1, sText_Ranking, 0xA8);
Blender_AddTextPrinter(5, sText_Ranking, xPos, 1, TEXT_SPEED_FF, 0);
@@ -3537,8 +3529,8 @@ void ShowBerryBlenderRecordWindow(void)
winTemplate = sBlenderRecordWindowTemplate;
gRecordsWindowId = AddWindow(&winTemplate);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, 0);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, 0);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
xPos = GetStringCenterAlignXOffset(1, gText_BlenderMaxSpeedRecord, 0x90);
AddTextPrinterParameterized(gRecordsWindowId, 1, gText_BlenderMaxSpeedRecord, xPos, 1, 0, NULL);
@@ -3647,7 +3639,7 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3
if (caseId != 3)
{
- FillWindowPixelBuffer(windowId, txtColor[0] | (txtColor[0] << 4));
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(txtColor[0]));
}
AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, 1, txtColor, speed, string);
@@ -3658,7 +3650,7 @@ static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed)
switch (*textState)
{
case 0:
- sub_8197B1C(4, FALSE, 0x14, 0xF);
+ DrawDialogFrameWithCustomTileAndPalette(4, FALSE, 0x14, 0xF);
Blender_AddTextPrinter(4, string, 0, 1, textSpeed, 0);
PutWindowTilemap(4);
CopyWindowToVram(4, 3);
diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c
index 3631c083a..37be569f8 100644
--- a/src/berry_fix_program.c
+++ b/src/berry_fix_program.c
@@ -226,9 +226,9 @@ static void berry_fix_gpu_set(void)
DmaCopy32(3, sUnknown_08618138, BG_PLTT + 0x1E0, 0x20);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
- FillWindowPixelBuffer(2, 0);
- FillWindowPixelBuffer(3, 0);
- FillWindowPixelBuffer(0, 0xAA);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
+ FillWindowPixelBuffer(3, PIXEL_FILL(0));
+ FillWindowPixelBuffer(0, PIXEL_FILL(0xA));
width = GetStringWidth(0, sUnknown_08617E9B, 0);
left = (0x78 - width) / 2;
@@ -273,7 +273,7 @@ static int berry_fix_text_update(int checkval)
static void berry_fix_text_print(int scene)
{
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
- FillWindowPixelBuffer(1, 0xAA);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(1, 1, 0, 0, sUnknown_08618158, -1, gUnknown_08618160[scene]);
PutWindowTilemap(1);
CopyWindowToVram(1, 2);
diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c
index 6e968fc0a..a7cf4daf2 100644
--- a/src/berry_tag_screen.c
+++ b/src/berry_tag_screen.c
@@ -381,7 +381,7 @@ static void PrintTextInBerryTagScreen(u8 windowId, const u8 *text, u8 x, u8 y, s
static void AddBerryTagTextToBg0(void)
{
memcpy(GetBgTilemapBuffer(0), sBerryTag->tilemapBuffers[2], sizeof(sBerryTag->tilemapBuffers[2]));
- FillWindowPixelBuffer(WIN_BERRY_TAG, 0xFF);
+ FillWindowPixelBuffer(WIN_BERRY_TAG, PIXEL_FILL(15));
PrintTextInBerryTagScreen(WIN_BERRY_TAG, gText_BerryTag, GetStringCenterAlignXOffset(1, gText_BerryTag, 0x40), 1, 0, 1);
PutWindowTilemap(WIN_BERRY_TAG);
schedule_bg_copy_tilemap_to_vram(0);
@@ -598,7 +598,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
switch (data[0])
{
case 0x30:
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
break;
case 0x40:
PrintBerryNumberAndName();
@@ -608,7 +608,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
CreateBerrySprite();
break;
case 0x60:
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
break;
case 0x70:
PrintBerrySize();
@@ -620,7 +620,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
SetFlavorCirclesVisiblity();
break;
case 0xA0:
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
break;
case 0xB0:
PrintBerryDescription1();
@@ -635,7 +635,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
switch (data[0])
{
case 0x30:
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
break;
case 0x40:
PrintBerryDescription2();
@@ -647,7 +647,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
SetFlavorCirclesVisiblity();
break;
case 0x70:
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
break;
case 0x80:
PrintBerryFirmness();
@@ -660,7 +660,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
CreateBerrySprite();
break;
case 0xB0:
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
break;
case 0xC0:
PrintBerryNumberAndName();
diff --git a/src/bg.c b/src/bg.c
index f73f5998d..1826f9a28 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -1056,7 +1056,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++)
{
CopyTileMapEntry(&firstTileNum, &((u16*)sGpuBgConfigs2[bg].tilemap)[(u16)GetTileMapIndexFromCoords(x16, y16, attribute, mode, mode2)], paletteSlot, 0, 0);
- firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
+ firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK);
}
}
break;
@@ -1067,7 +1067,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
for (x16 = x; x16 < (x + width); x16++)
{
((u8*)sGpuBgConfigs2[bg].tilemap)[(y16 * mode3) + x16] = firstTileNum;
- firstTileNum = (firstTileNum & 0xFC00) + ((firstTileNum + tileNumDelta) & 0x3FF);
+ firstTileNum = (firstTileNum & (METATILE_COLLISION_MASK | METATILE_ELEVATION_MASK)) + ((firstTileNum + tileNumDelta) & METATILE_ID_MASK);
}
}
break;
diff --git a/src/bike.c b/src/bike.c
index 1e91baab0..530742bdf 100644
--- a/src/bike.c
+++ b/src/bike.c
@@ -14,12 +14,6 @@
extern bool8 gBikeCyclingChallenge;
extern u8 gBikeCollisions;
-extern u8 sub_808B980(u8 direction);
-extern u8 sub_808B9BC(u8 direction);
-extern u8 sub_808B9A4(u8 direction);
-extern u8 sub_808C1B4(u8 direction);
-extern u8 sub_808B9D4(u8 direction);
-
// this file's functions
static void MovePlayerOnMachBike(u8, u16, u16);
static u8 GetMachBikeTransition(u8 *);
diff --git a/src/cable_club.c b/src/cable_club.c
index 303b0d016..b80e76e99 100644
--- a/src/cable_club.c
+++ b/src/cable_club.c
@@ -92,7 +92,9 @@ static void sub_80B23B0(u16 windowId, u32 value)
static void sub_80B241C(u16 windowId)
{
- sub_819746C(windowId, FALSE);
+ // Following this call with a copy-to-vram with mode 3 is identical to
+ // calling ClearStdWindowAndFrame(windowId, TRUE).
+ ClearStdWindowAndFrame(windowId, FALSE);
CopyWindowToVram(windowId, 3);
}
@@ -282,7 +284,7 @@ static void sub_80B2804(u8 taskId)
if (GetFieldMessageBoxMode() == FIELD_MESSAGE_BOX_HIDDEN)
{
- if (sub_800AA48() != GetLinkPlayerCount_2())
+ if (GetSavedPlayerCount() != GetLinkPlayerCount_2())
{
ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady);
gTasks[taskId].func = sub_80B270C;
@@ -295,7 +297,7 @@ static void sub_80B2804(u8 taskId)
else if (gMain.heldKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- sub_800A620();
+ CheckShouldAdvanceLinkState();
gTasks[taskId].func = sub_80B28A8;
}
}
@@ -310,7 +312,7 @@ static void sub_80B28A8(u8 taskId)
|| sub_80B2D6C(taskId) == TRUE)
return;
- if (GetLinkPlayerCount_2() != sub_800AA48())
+ if (GetLinkPlayerCount_2() != GetSavedPlayerCount())
{
gTasks[taskId].func = sub_80B2D2C;
}
@@ -352,7 +354,7 @@ static void sub_80B2918(u8 taskId)
else
{
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
- gUnknown_03005DB4 = GetMultiplayerId();
+ gLocalLinkPlayerId = GetMultiplayerId();
sub_800AA04(gFieldLinkPlayerCount);
card = (struct TrainerCard *)gBlockSendBuffer;
TrainerCard_GenerateCardForPlayer(card);
@@ -399,7 +401,7 @@ static void sub_80B2A08(u8 taskId)
else
{
gFieldLinkPlayerCount = GetLinkPlayerCount_2();
- gUnknown_03005DB4 = GetMultiplayerId();
+ gLocalLinkPlayerId = GetMultiplayerId();
sub_800AA04(gFieldLinkPlayerCount);
card = (struct TrainerCard *)gBlockSendBuffer;
TrainerCard_GenerateCardForPlayer(card);
@@ -764,9 +766,9 @@ static void sub_80B3194(u8 taskId)
static void sub_80B31E8(u8 taskId)
{
- if (sub_800AA48() == GetLinkPlayerCount_2())
+ if (GetSavedPlayerCount() == GetLinkPlayerCount_2())
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
gTasks[taskId].func = sub_80B3220;
}
}
@@ -972,7 +974,7 @@ void sub_80B360C(void)
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2)
{
- UpdatePlayerLinkBattleRecords(gUnknown_03005DB4 ^ 1);
+ UpdatePlayerLinkBattleRecords(gLocalLinkPlayerId ^ 1);
if (gWirelessCommType)
{
switch (gBattleOutcome)
@@ -993,13 +995,13 @@ void sub_80B360C(void)
}
else
{
- gMain.savedCallback = c2_8056854;
+ gMain.savedCallback = CB2_ReturnToFieldFromMultiplayer;
}
SetMainCallback2(sub_80A0514);
}
-void sub_80B36EC(void)
+void CleanupLinkRoomState(void)
{
if (gSpecialVar_0x8004 == 1 || gSpecialVar_0x8004 == 2 || gSpecialVar_0x8004 == 5 || gSpecialVar_0x8004 == 9)
{
@@ -1009,9 +1011,9 @@ void sub_80B36EC(void)
SetWarpDestinationToDynamicWarp(0x7F);
}
-void sub_80B371C(void)
+void ExitLinkRoom(void)
{
- sub_80872B0();
+ QueueExitLinkRoomKey();
}
static void sub_80B3728(u8 taskId)
@@ -1028,7 +1030,7 @@ static void sub_80B3728(u8 taskId)
if (IsFieldMessageBoxHidden())
{
sub_8087288();
- sub_8009628(gSpecialVar_0x8005);
+ SetLocalLinkPlayerId(gSpecialVar_0x8005);
task->data[0] = 2;
}
break;
@@ -1130,7 +1132,8 @@ static void sub_80B3894(u8 taskId)
}
}
-void sub_80B3924(void)
+// Note: VAR_0x8005 is set to the ID of the trade seat.
+void PlayerEnteredTradeSeat(void)
{
if (gWirelessCommType != 0)
{
@@ -1152,7 +1155,8 @@ void nullsub_37(void)
}
-void sub_80B3968(void)
+// Note: VAR_0x8005 is set to the ID of the player spot.
+void ColosseumPlayerSpotTriggered(void)
{
gLinkType = 0x2211;
@@ -1166,6 +1170,7 @@ void sub_80B3968(void)
}
}
+// This function is never called.
static void sub_80B39A4(void)
{
u8 taskId = CreateTask(sub_80B3728, 80);
@@ -1177,14 +1182,16 @@ void sp02A_crash_sound(void)
ShowTrainerCardInLink(gSpecialVar_0x8006, CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
-bool32 sub_80B39D4(u8 linkPlayerIndex)
+// Returns FALSE if the player has no stars. Returns TRUE otherwise, and puts the name of the
+// color into gStringVar2.
+bool32 GetLinkTrainerCardColor(u8 linkPlayerIndex)
{
u32 trainerCardColorIndex;
gSpecialVar_0x8006 = linkPlayerIndex;
StringCopy(gStringVar1, gLinkPlayers[linkPlayerIndex].name);
- trainerCardColorIndex = sub_80C4904(linkPlayerIndex);
+ trainerCardColorIndex = GetTrainerCardStars(linkPlayerIndex);
if (trainerCardColorIndex == 0)
return FALSE;
@@ -1263,13 +1270,13 @@ void sub_80B3AF8(u8 taskId)
}
break;
case 2:
- if (GetLinkPlayerCount_2() >= sub_800AA48())
+ if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
{
if (IsLinkMaster())
{
if (++data[1] > 30)
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
data[0]++;
}
}
diff --git a/src/clear_save_data_screen.c b/src/clear_save_data_screen.c
index 5ec90e10c..c1d6930c7 100644
--- a/src/clear_save_data_screen.c
+++ b/src/clear_save_data_screen.c
@@ -79,7 +79,7 @@ void CB2_InitClearSaveDataScreen(void)
static void Task_DoClearSaveDataScreenYesNo(u8 taskId)
{
- SetWindowBorderStyle(0, 0, 2, 14);
+ DrawStdFrameWithCustomTileAndPalette(0, 0, 2, 14);
AddTextPrinterParameterized(0, 1, gText_ClearAllSaveData, 0, 1, 0, 0);
CreateYesNoMenu(sClearSaveYesNo, 2, 14, 1);
gTasks[taskId].func = Task_ClearSaveDataScreenYesNoChoice;
@@ -90,7 +90,7 @@ static void Task_ClearSaveDataScreenYesNoChoice(u8 taskId)
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
case 0:
- FillWindowPixelBuffer(0, 17);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, 1, gText_ClearingData, 0, 1, 0, 0);
gTasks[taskId].func = Task_ClearSaveData;
break;
@@ -203,7 +203,7 @@ static void InitClearSaveDataScreenWindows(void)
{
InitWindows(sClearSaveTextWindow);
DeactivateAllTextPrinters();
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
LoadWindowGfx(0, 0, 2, 224);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
}
diff --git a/src/coins.c b/src/coins.c
index 967eb92ac..b838c303e 100644
--- a/src/coins.c
+++ b/src/coins.c
@@ -27,15 +27,15 @@ void ShowCoinsWindow(u32 coinAmount, u8 x, u8 y)
struct WindowTemplate template;
SetWindowTemplateFields(&template, 0, x, y, 8, 2, 0xF, 0x141);
sCoinsWindowId = AddWindow(&template);
- FillWindowPixelBuffer(sCoinsWindowId, 0);
+ FillWindowPixelBuffer(sCoinsWindowId, PIXEL_FILL(0));
PutWindowTilemap(sCoinsWindowId);
- SetWindowBorderStyle(sCoinsWindowId, FALSE, 0x214, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(sCoinsWindowId, FALSE, 0x214, 0xE);
PrintCoinsString(coinAmount);
}
void HideCoinsWindow(void)
{
- sub_819746C(sCoinsWindowId, TRUE);
+ ClearStdWindowAndFrame(sCoinsWindowId, TRUE);
RemoveWindow(sCoinsWindowId);
}
diff --git a/src/contest.c b/src/contest.c
index 7be4aa23b..114a1fb69 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -45,8 +45,6 @@
#include "constants/rgb.h"
#include "contest_ai.h"
-extern void sub_80FC9F8(u8); // contest_link_80FC4F4.c
-
// This file's functions.
static void sub_80D782C(void);
static void sub_80D7C7C(u8 taskId);
@@ -819,7 +817,7 @@ static void sub_80D8490(u8 taskId)
}
r5 = StringCopy(r5, gMoveNames[move]);
- FillWindowPixelBuffer(i + 5, 0);
+ FillWindowPixelBuffer(i + 5, PIXEL_FILL(0));
Contest_PrintTextToBg0WindowAt(i + 5, sp8, 5, 1, 7);
}
@@ -941,7 +939,7 @@ static void sub_80D895C(u8 taskId)
for (i = 0; i < 4; i++)
{
- FillWindowPixelBuffer(5 + i, 0);
+ FillWindowPixelBuffer(5 + i, PIXEL_FILL(0));
PutWindowTilemap(5 + i);
CopyWindowToVram(5 + i, 2);
}
@@ -2258,7 +2256,7 @@ static void sub_80DAEA4(void)
for (i = 0; i < 4; i++)
{
- FillWindowPixelBuffer(gUnknown_02039F26[i], 0);
+ FillWindowPixelBuffer(gUnknown_02039F26[i], PIXEL_FILL(0));
sub_80DAF04(i);
sub_80DAF88(i);
}
@@ -2478,7 +2476,7 @@ static void prints_contest_move_description(u16 a)
ContestBG_FillBoxWithTile(0, 0x5036, 0x15, 0x20, 0x08, 0x01, 0x11);
ContestBG_FillBoxWithTile(0, 0x5014, 0x15, 0x20, numHearts, 0x01, 0x11);
- FillWindowPixelBuffer(10, 0);
+ FillWindowPixelBuffer(10, PIXEL_FILL(0));
Contest_PrintTextToBg0WindowStd(10, gContestEffectDescriptionPointers[gContestMoves[a].effect]);
Contest_PrintTextToBg0WindowStd(9, gText_Slash);
}
@@ -2621,7 +2619,7 @@ static void sub_80DB884(void)
static void sub_80DB89C(void)
{
- FillWindowPixelBuffer(4, 0);
+ FillWindowPixelBuffer(4, PIXEL_FILL(0));
CopyWindowToVram(4, 2);
Contest_SetBgCopyFlags(0);
}
@@ -3456,7 +3454,7 @@ static void sub_80DCD48(void)
break;
default:
for (i = 0; i < 4; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
for (i = 0; i < 4; i++)
{
value = sContestantStatus[i].unk4;
@@ -5038,7 +5036,7 @@ static void sub_80DF750(void)
return;
for (i = 0; i < 4; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
if (gHeap[0x1A000] == 2)
{
diff --git a/src/contest_link_80F57C4.c b/src/contest_link_80F57C4.c
index c0a79af81..a4b88c074 100644
--- a/src/contest_link_80F57C4.c
+++ b/src/contest_link_80F57C4.c
@@ -39,6 +39,7 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/vars.h"
+#include "contest.h"
struct ContestLinkUnk0
{
@@ -99,8 +100,6 @@ extern const struct SpriteSheet gUnknown_0858D810[];
extern const struct SpritePalette gUnknown_0858D850;
extern const struct SpriteTemplate gSpriteTemplate_858D860;
-extern void sub_81D9DE4(u8);
-
static void sub_80F6A9C(void);
static void sub_80F71C8(void);
u8 sub_80F7310(u8, u8);
@@ -935,7 +934,7 @@ static void sub_80F6AE8(void)
// windowTemplate.width = 30;
// windowTemplate.height = 2;
// windowId = AddWindow(&windowTemplate);
-// FillWindowPixelBuffer(windowId, 0x11);
+// FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
// origWidth = GetStringWidth(1, text, 0) + 9;
// strWidth = origWidth;
// if (strWidth < 0)
diff --git a/src/contest_painting.c b/src/contest_painting.c
index 2f0c97764..931deb01b 100644
--- a/src/contest_painting.c
+++ b/src/contest_painting.c
@@ -279,7 +279,7 @@ static void InitContestPaintingWindow(void)
SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE));
gContestPaintingWindowId = AddWindow(&gUnknown_085B07EC);
DeactivateAllTextPrinters();
- FillWindowPixelBuffer(gContestPaintingWindowId, 0);
+ FillWindowPixelBuffer(gContestPaintingWindowId, PIXEL_FILL(0));
PutWindowTilemap(gContestPaintingWindowId);
CopyWindowToVram(gContestPaintingWindowId, 3);
ShowBg(1);
diff --git a/src/credits.c b/src/credits.c
index aee5332f5..4483e3160 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -1592,7 +1592,7 @@ static void sub_8175DA0(u8 taskIdB)
case 5:
if (!gPaletteFade.active)
{
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
CopyWindowToVram(0, 2);
gTasks[taskIdB].data[TDB_0] = 2;
}
diff --git a/src/daycare.c b/src/daycare.c
index b75fab292..885ac31a1 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -1259,7 +1259,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
break;
}
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);
- sub_819746C(gTasks[taskId].tWindowId, TRUE);
+ ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
RemoveWindow(gTasks[taskId].tWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
@@ -1268,7 +1268,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId)
{
gSpecialVar_Result = 2;
DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL);
- sub_819746C(gTasks[taskId].tWindowId, TRUE);
+ ClearStdWindowAndFrame(gTasks[taskId].tWindowId, TRUE);
RemoveWindow(gTasks[taskId].tWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
@@ -1283,7 +1283,7 @@ void ShowDaycareLevelMenu(void)
u8 daycareMenuTaskId;
windowId = AddWindow(&sDaycareLevelMenuWindowTemplate);
- NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE);
+ DrawStdWindowFrame(windowId, FALSE);
menuTemplate = sDaycareListMenuLevelTemplate;
menuTemplate.windowId = windowId;
diff --git a/src/decoration.c b/src/decoration.c
index 2ac49b98c..0712b5d32 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -463,14 +463,14 @@ u8 sub_81269D4(u8 idx)
{
*winidx = AddWindow(&gUnknown_085A6B90[idx]);
}
- SetWindowBorderStyle(*winidx, 0, 0x214, 0xe);
+ DrawStdFrameWithCustomTileAndPalette(*winidx, 0, 0x214, 0xe);
schedule_bg_copy_tilemap_to_vram(0);
return *winidx;
}
void sub_8126A58(u8 idx)
{
- sub_8198070(sDecorMenuWindowIndices[idx], FALSE);
+ ClearStdWindowAndFrameToTransparent(sDecorMenuWindowIndices[idx], FALSE);
ClearWindowTilemap(sDecorMenuWindowIndices[idx]);
RemoveWindow(sDecorMenuWindowIndices[idx]);
schedule_bg_copy_tilemap_to_vram(0);
@@ -543,7 +543,7 @@ void sub_8126B80(u8 taskId)
void sub_8126C08(void)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3);
}
@@ -572,7 +572,7 @@ void SecretBasePC_PutAway(u8 taskId)
else
{
sub_8126A58(0);
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
FadeScreen(1, 0);
gTasks[taskId].data[2] = 0;
gTasks[taskId].func = sub_8129ABC;
@@ -617,7 +617,7 @@ void sub_8126DA4(u8 taskId)
void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId)
{
LoadPalette(gUnknown_085A6BB0, 0xd0, 0x20);
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_8126A58(0);
sub_8126DFC(taskId);
}
@@ -634,7 +634,7 @@ void sub_8126DFC(u8 taskId)
void sub_8126E44(u8 taskId)
{
- FillWindowPixelBuffer(sDecorMenuWindowIndices[1], 0x11);
+ FillWindowPixelBuffer(sDecorMenuWindowIndices[1], PIXEL_FILL(1));
sub_8126E8C(taskId);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDecorMenuWindowIndices[1], 9, sCurDecorationCategory);
gTasks[taskId].func = sub_8127088;
@@ -751,7 +751,7 @@ void sub_81270E8(u8 taskId)
void sub_8127180(u8 taskId)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_8126DFC(taskId);
}
@@ -771,7 +771,7 @@ void sub_81271CC(u8 taskId)
{
sub_8126A58(1);
sub_8126A88();
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
sub_8126C08();
gTasks[taskId].func = sub_8126B80;
}
@@ -779,7 +779,7 @@ void sub_81271CC(u8 taskId)
void sub_8127208(u8 taskId)
{
LoadPalette(gUnknown_085A6BB0, 0xd0, 0x20);
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
gTasks[taskId].data[11] = 2;
sCurDecorationCategory = DECORCAT_DESK;
sub_8126DFC(taskId);
@@ -968,7 +968,7 @@ void sub_8127744(u32 a0)
const u8 *txt;
winidx = sDecorMenuWindowIndices[3];
- FillWindowPixelBuffer(winidx, 0x11);
+ FillWindowPixelBuffer(winidx, PIXEL_FILL(1));
if (a0 >= sCurDecorCatCount)
{
txt = gText_GoBackPrevMenu;
@@ -1095,7 +1095,7 @@ void sub_8127A14(u8 taskId)
void sub_8127A30(u8 taskId)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
gTasks[taskId].func = sub_8127A14;
}
@@ -1103,7 +1103,7 @@ void sub_8127A5C(u8 taskId)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_81269D4(1);
sub_8127620(taskId);
}
@@ -1158,7 +1158,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
u16 i;
u16 j;
u16 behavior;
- u16 flags;
+ u16 impassableFlag;
u16 v0;
u16 v1;
s16 decLeft;
@@ -1173,11 +1173,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decor].tiles[i * decWidth + j]);
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decor].permission != DECORPERM_PASS_FLOOR && (behavior >> 12)))
{
- flags = 0xc00;
+ impassableFlag = METATILE_COLLISION_MASK;
}
else
{
- flags = 0x000;
+ impassableFlag = 0x000;
}
if (gDecorations[decor].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(decLeft, decBottom)) == TRUE)
{
@@ -1190,11 +1190,11 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j);
if (v1 != 0xFFFF)
{
- MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1);
+ MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag | v1);
}
else
{
- MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags);
+ MapGridSetMetatileIdAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | impassableFlag);
}
}
}
@@ -1254,7 +1254,7 @@ void sub_8127E18(void)
break;
}
}
- VarSet(VAR_0x3F20 + gMapHeader.events->eventObjects[j].graphicsId, sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0]);
+ VarSet(UNKNOWN_VAR_OFFSET_3F20 + gMapHeader.events->eventObjects[j].graphicsId, sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0]);
gSpecialVar_0x8005 = gMapHeader.events->eventObjects[j].localId;
gSpecialVar_0x8006 = sCurDecorMapX;
gSpecialVar_0x8007 = sCurDecorMapY;
@@ -1502,7 +1502,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
+ behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
if (!sub_81284F4(behaviorAt, decoration))
{
return FALSE;
@@ -1527,7 +1527,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & 0xf000;
+ behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_8128484(behaviorAt, behaviorBy))
{
return FALSE;
@@ -1547,7 +1547,7 @@ bool8 sub_812853C(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].data[0] + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & 0xf000;
+ behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & METATILE_ELEVATION_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
{
return FALSE;
@@ -1628,13 +1628,13 @@ void sub_8128950(u8 taskId)
void sub_81289D0(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_085A72C4);
}
void sub_81289F0(u8 taskId)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_8128AAC(taskId);
if (gDecorations[gCurDecorInventoryItems[gCurDecorationIndex]].permission != DECORPERM_SOLID_MAT)
{
@@ -1693,13 +1693,13 @@ void sub_8128AAC(u8 taskId)
void sub_8128B80(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_085A72CC);
}
void sub_8128BA0(u8 taskId)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_8128BBC(taskId);
}
@@ -1887,7 +1887,7 @@ void sub_8128E18(u8 taskId)
void sub_8128FD8(u8 taskId)
{
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0;
gTasks[taskId].data[10] = 0;
gTasks[taskId].func = sub_8128E18;
@@ -2251,7 +2251,7 @@ void sub_81298EC(u8 taskId)
if (!gPaletteFade.active) {
DrawWholeMapView();
ScriptContext1_SetupScript(EventScript_275D2E);
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
gTasks[taskId].data[2] = 2;
}
break;
@@ -2343,7 +2343,7 @@ void sub_8129ABC(u8 taskId)
void sub_8129B34(u8 taskId)
{
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0;
gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE;
gSprites[sDecor_CameraSpriteObjectIdx1].callback = sub_812A36C;
@@ -2588,7 +2588,7 @@ void sub_812A0E8(u8 taskId)
void sub_812A1A0(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_085A7348);
}
@@ -2601,13 +2601,13 @@ void sub_812A1C0(u8 taskId)
void sub_812A1F0(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_085A7350);
}
void sub_812A210(u8 taskId)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
sub_812A22C(taskId);
}
@@ -2671,7 +2671,7 @@ void sub_812A334(void)
u8 taskId;
pal_fill_black();
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
sub_8126ABC();
taskId = CreateTask(sub_812A2C4, 8);
gTasks[taskId].data[2] = 0;
@@ -2725,7 +2725,7 @@ void sub_812A3D4(u8 taskId)
void sub_812A458(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_085A741C);
}
diff --git a/src/dewford_trend.c b/src/dewford_trend.c
index cad5ef9c2..ee310af04 100644
--- a/src/dewford_trend.c
+++ b/src/dewford_trend.c
@@ -159,7 +159,7 @@ static void sub_8122804(struct EasyChatPair *s, u16 b, u8 c)
}
}
-void ReceiveEasyChatPairsData(void *a, u32 b, u8 unused)
+void ReceiveEasyChatPairsData(struct EasyChatPair *a, size_t size, u8 unused)
{
u16 i, j, r3, players;
struct EasyChatPair *buffer1, *buffer2, *src, *dst, *foo_of_buffer2;
@@ -176,7 +176,7 @@ void ReceiveEasyChatPairsData(void *a, u32 b, u8 unused)
{
players = GetLinkPlayerCount();
for (i = 0; i < players; i++)
- memcpy(&(buffer1[i * 5]), (u8 *)a + i * b, 40);
+ memcpy(&(buffer1[i * 5]), (u8 *)a + i * size, 40);
src = buffer1;
dst = buffer2;
r3 = 0;
diff --git a/src/diploma.c b/src/diploma.c
index b3d5a48fa..2113b09ed 100644
--- a/src/diploma.c
+++ b/src/diploma.c
@@ -13,8 +13,7 @@
#include "text.h"
#include "overworld.h"
#include "menu.h"
-
-extern bool16 sub_80C0944(void);
+#include "pokedex.h"
extern const u8 gText_DexNational[];
extern const u8 gText_DexHoenn[];
@@ -197,7 +196,7 @@ static void InitDiplomaWindow(void)
InitWindows(sDiplomaWinTemplates);
DeactivateAllTextPrinters();
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
}
diff --git a/src/easy_chat.c b/src/easy_chat.c
index aa681eeba..b03058eb9 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -1114,7 +1114,7 @@ static void sub_811A2A4(u8 taskId, TaskFunc taskFunc)
static void sub_811A2C0(u8 taskId)
{
- if (!is_c1_link_related_active())
+ if (!IsUpdateLinkStateCBActive())
{
while (sub_811A428(taskId));
}
@@ -3697,7 +3697,7 @@ static void sub_811CFCC(void)
return;
xOffset = GetStringCenterAlignXOffset(1, titleText, 144);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
sub_811D058(0, 1, titleText, xOffset, 1, 0xFF, 0, 2, 3);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
@@ -3767,7 +3767,7 @@ static void sub_811D104(u8 arg0)
break;
}
- FillWindowPixelBuffer(1, 0x11);
+ FillWindowPixelBuffer(1, PIXEL_FILL(1));
if (text1)
sub_811D028(1, 1, text1, 0, 1, 0xFF, 0);
@@ -3817,7 +3817,7 @@ static void sub_811D2C8(void)
if (frameId == 7)
var1 = 1;
- FillWindowPixelBuffer(sUnknown_0203A11C->windowId, 0x11);
+ FillWindowPixelBuffer(sUnknown_0203A11C->windowId, PIXEL_FILL(1));
for (i = 0; i < numRows; i++)
{
memcpy(spC, sText_Clear17, sizeof(sText_Clear17));
@@ -3957,7 +3957,7 @@ static void sub_811D684(void)
static void sub_811D698(u32 arg0)
{
sub_811DD84();
- FillWindowPixelBuffer(2, 0x11);
+ FillWindowPixelBuffer(2, PIXEL_FILL(1));
switch (arg0)
{
case 0:
@@ -4114,14 +4114,14 @@ static void sub_811D950(u8 arg0, u8 arg1)
var1 = 0;
}
- FillWindowPixelRect(2, 0x11, 0, y, 224, var2);
+ FillWindowPixelRect(2, PIXEL_FILL(1), 0, y, 224, var2);
if (var1)
- FillWindowPixelRect(2, 0x11, 0, 0, 224, var1);
+ FillWindowPixelRect(2, PIXEL_FILL(1), 0, 0, 224, var1);
}
static void sub_811D9B4(void)
{
- FillWindowPixelBuffer(2, 0x11);
+ FillWindowPixelBuffer(2, PIXEL_FILL(1));
CopyWindowToVram(2, 2);
}
@@ -4791,7 +4791,7 @@ static void sub_811E948(void)
template.paletteNum = 11;
template.baseBlock = 0x34;
windowId = AddWindow(&template);
- FillWindowPixelBuffer(windowId, 0x11);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
for (i = 0; i < 4; i++)
{
const u8 *str = sFooterTextOptions[footerId][i];
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index ba1020669..a9b6001ec 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -606,7 +606,7 @@ static void CB2_EggHatch_1(void)
case 1:
if (!gPaletteFade.active)
{
- FillWindowPixelBuffer(sEggHatchData->windowId, 0);
+ FillWindowPixelBuffer(sEggHatchData->windowId, PIXEL_FILL(0));
sEggHatchData->CB2_PalCounter = 0;
sEggHatchData->CB2_state++;
}
@@ -857,7 +857,7 @@ static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8
static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
{
- FillWindowPixelBuffer(windowId, 0xFF);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(15));
sEggHatchData->textColor[0] = 0;
sEggHatchData->textColor[1] = 5;
sEggHatchData->textColor[2] = 6;
diff --git a/src/electric.c b/src/electric.c
index 142a9ca09..5e7729842 100644
--- a/src/electric.c
+++ b/src/electric.c
@@ -5,9 +5,6 @@
#include "constants/songs.h"
#include "sound.h"
-extern void sub_810E2C8(struct Sprite *);
-extern void TranslateAnimSpriteToTargetMonLocation(struct Sprite *);
-
static void sub_810A1A8(struct Sprite *);
static void sub_810A1F8(struct Sprite *);
static void sub_810A214(struct Sprite *);
diff --git a/src/event_data.c b/src/event_data.c
index e75c37773..50628f984 100644
--- a/src/event_data.c
+++ b/src/event_data.c
@@ -23,8 +23,8 @@ EWRAM_DATA u16 gSpecialVar_LastTalked = 0;
EWRAM_DATA u16 gSpecialVar_Facing = 0;
EWRAM_DATA u16 gSpecialVar_MonBoxId = 0;
EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0;
-EWRAM_DATA u16 gSpecialVar_0x8014 = 0;
-EWRAM_DATA static u8 gUnknown_020375FC[16] = {0};
+EWRAM_DATA u16 gSpecialVar_Unused_0x8014 = 0;
+EWRAM_DATA static u8 gSpecialFlags[16] = {0};
extern u16 *const gSpecialVars[];
@@ -32,7 +32,7 @@ void InitEventData(void)
{
memset(gSaveBlock1Ptr->flags, 0, sizeof(gSaveBlock1Ptr->flags));
memset(gSaveBlock1Ptr->vars, 0, sizeof(gSaveBlock1Ptr->vars));
- memset(gUnknown_020375FC, 0, sizeof(gUnknown_020375FC));
+ memset(gSpecialFlags, 0, sizeof(gSpecialFlags));
}
void ClearTempFieldEventData(void)
@@ -131,13 +131,13 @@ void sub_809D4D8(void)
void sub_809D570(void)
{
VarSet(VAR_EVENT_PICHU_SLOT, 0);
- VarSet(VAR_0x40DE, 0);
- VarSet(VAR_0x40DF, 0);
- VarSet(VAR_0x40E0, 0);
- VarSet(VAR_0x40E1, 0);
- VarSet(VAR_0x40E2, 0);
- VarSet(VAR_0x40E3, 0);
- VarSet(VAR_0x40E4, 0);
+ VarSet(VAR_NEVER_READ_0x40DE, 0);
+ VarSet(VAR_NEVER_READ_0x40DF, 0);
+ VarSet(VAR_NEVER_READ_0x40E0, 0);
+ VarSet(VAR_NEVER_READ_0x40E1, 0);
+ VarSet(VAR_NEVER_READ_0x40E2, 0);
+ VarSet(VAR_NEVER_READ_0x40E3, 0);
+ VarSet(VAR_NEVER_READ_0x40E4, 0);
}
void DisableResetRTC(void)
@@ -199,7 +199,7 @@ u8 *GetFlagPointer(u16 id)
else if (id < SPECIAL_FLAGS_START)
return &gSaveBlock1Ptr->flags[id / 8];
else
- return &gUnknown_020375FC[(id - SPECIAL_FLAGS_START) / 8];
+ return &gSpecialFlags[(id - SPECIAL_FLAGS_START) / 8];
}
u8 FlagSet(u16 id)
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index cffafaf9f..680191bb3 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -32,8 +32,7 @@
#include "constants/map_types.h"
#include "constants/maps.h"
#include "constants/songs.h"
-
-extern bool32 TryStartMatchCall(void);
+#include "match_call.h"
static EWRAM_DATA u8 sWildEncounterImmunitySteps = 0;
static EWRAM_DATA u16 sPreviousPlayerMetatileBehavior = 0;
@@ -557,9 +556,9 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
ScriptContext1_SetupScript(EventScript_EggHatch);
return TRUE;
}
- if (sub_813B3B0() == TRUE)
+ if (UnusualWeatherHasExpired() == TRUE)
{
- ScriptContext1_SetupScript(gUnknown_08273D1F);
+ ScriptContext1_SetupScript(UnusualWeather_EventScript_EndEventAndCleanup_1);
return TRUE;
}
if (ShouldDoBrailleRegicePuzzle() == TRUE)
@@ -567,27 +566,27 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
ScriptContext1_SetupScript(IslandCave_EventScript_238EAF);
return TRUE;
}
- if (is_tile_that_overrides_player_control() == TRUE)
+ if (ShouldDoWallyCall() == TRUE)
{
ScriptContext1_SetupScript(MauvilleCity_EventScript_1DF7BA);
return TRUE;
}
- if (sub_8138120() == TRUE)
+ if (ShouldDoWinonaCall() == TRUE)
{
ScriptContext1_SetupScript(Route119_EventScript_1F49EC);
return TRUE;
}
- if (sub_8138168() == TRUE)
+ if (ShouldDoScottCall() == TRUE)
{
ScriptContext1_SetupScript(LittlerootTown_ProfessorBirchsLab_EventScript_1FA4D6);
return TRUE;
}
- if (sub_81381B0() == TRUE)
+ if (ShouldDoRoxanneCall() == TRUE)
{
ScriptContext1_SetupScript(RustboroCity_Gym_EventScript_21307B);
return TRUE;
}
- if (sub_81381F8() == TRUE)
+ if (ShouldDoRivalRayquazaCall() == TRUE)
{
ScriptContext1_SetupScript(MossdeepCity_SpaceCenter_2F_EventScript_224175);
return TRUE;
diff --git a/src/field_effect.c b/src/field_effect.c
index e7c0b39b9..ee9dcb987 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -240,12 +240,6 @@ static IWRAM_DATA u8 sActiveList[32];
extern u8 *gFieldEffectScriptPointers[];
extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
-extern void sub_81555D8(u8, u8);
-extern void pal_fill_for_maplights(void);
-extern void sub_80E1558(u8);
-extern void sub_80E1570(void);
-extern bool8 sub_80E1584(void);
-extern void WarpFadeScreen(void);
// .rodata
const u32 gNewGameBirchPic[] = INCBIN_U32("graphics/birch_speech/birch.4bpp");
@@ -2443,7 +2437,7 @@ static void sub_80B8410(struct Task *task)
bool8 FldEff_FieldMoveShowMon(void)
{
u8 taskId;
- if (is_map_type_1_2_3_5_or_6(GetCurrentMapType()) == TRUE)
+ if (IsMapTypeOutdoors(GetCurrentMapType()) == TRUE)
{
taskId = CreateTask(sub_80B8554, 0xff);
} else
@@ -2620,7 +2614,7 @@ static void sub_80B8874(u16 offs)
dest = (u16 *)(VRAM + 0x140 + offs);
for (i = 0; i < 0x140; i++, dest++)
{
- *dest = gFieldMoveStreaksTilemap[i] | 0xf000;
+ *dest = gFieldMoveStreaksTilemap[i] | METATILE_ELEVATION_MASK;
}
}
diff --git a/src/field_message_box.c b/src/field_message_box.c
index 299aafaf2..1c554b6c6 100755
--- a/src/field_message_box.c
+++ b/src/field_message_box.c
@@ -4,9 +4,7 @@
#include "string_util.h"
#include "task.h"
#include "text.h"
-
-extern bool32 IsMatchCallTaskActive(void);
-extern void StartMatchCallFromScript(u8*);
+#include "match_call.h"
static EWRAM_DATA u8 sFieldMessageBoxMode = 0;
@@ -33,7 +31,7 @@ static void sub_8098154(u8 taskId)
task->data[0]++;
break;
case 1:
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
task->data[0]++;
break;
case 2:
@@ -127,7 +125,7 @@ static void textbox_auto_and_task_add(void)
void HideFieldMessageBox(void)
{
task_del_textbox();
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
sFieldMessageBoxMode = 0;
}
@@ -146,7 +144,7 @@ bool8 IsFieldMessageBoxHidden(void)
void sub_8098358(void)
{
task_del_textbox();
- NewMenuHelpers_DrawStdWindowFrame(0, 1);
+ DrawStdWindowFrame(0, 1);
sFieldMessageBoxMode = 0;
}
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index b1291f0ce..a070fe0e1 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -1918,7 +1918,7 @@ static bool8 Fishing9(struct Task *task)
static bool8 Fishing10(struct Task *task)
{
AlignFishingAnimationFrames();
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gText_PokemonOnHook, 1, 0, 2, 1, 3);
task->tStep++;
task->tFrameCounter = 0;
@@ -1944,7 +1944,7 @@ static bool8 Fishing11(struct Task *task)
sub_8155604(gEventObjects[gPlayerAvatar.eventObjectId].fieldEffectSpriteId, 0, 0);
gSprites[gPlayerAvatar.spriteId].pos2.x = 0;
gSprites[gPlayerAvatar.spriteId].pos2.y = 0;
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
task->tFrameCounter++;
return FALSE;
}
@@ -1966,7 +1966,7 @@ static bool8 Fishing12(struct Task *task)
{
AlignFishingAnimationFrames();
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gText_NotEvenANibble, 1, 0, 2, 1, 3);
task->tStep = FISHING_SHOW_RESULT;
return TRUE;
@@ -1977,7 +1977,7 @@ static bool8 Fishing13(struct Task *task)
{
AlignFishingAnimationFrames();
StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gText_ItGotAway, 1, 0, 2, 1, 3);
task->tStep++;
return TRUE;
@@ -2017,7 +2017,7 @@ static bool8 Fishing16(struct Task *task)
gPlayerAvatar.preventStep = FALSE;
ScriptContext2_Disable();
UnfreezeEventObjects();
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sub_80ED950(0);
DestroyTask(FindTaskIdByFunc(Task_Fishing));
}
@@ -2125,7 +2125,7 @@ void sub_808D194(void)
sub_808D1FC(CreateTask(sub_808D1FC, 0));
}
-bool8 sub_808D1B4(void)
+bool32 sub_808D1B4(void)
{
return FuncIsActiveTask(sub_808D1FC);
}
@@ -2135,7 +2135,7 @@ void sub_808D1C8(void)
sub_808D094(CreateTask(sub_808D094, 0));
}
-bool8 sub_808D1E8(void)
+bool32 sub_808D1E8(void)
{
return FuncIsActiveTask(sub_808D094);
}
diff --git a/src/field_region_map.c b/src/field_region_map.c
index d49ce3a4e..1d54333fb 100644
--- a/src/field_region_map.c
+++ b/src/field_region_map.c
@@ -139,11 +139,11 @@ static void FieldUpdateRegionMap(void)
sFieldRegionMapHandler->state++;
break;
case 1:
- SetWindowBorderStyle(1, 0, 0x27, 0xd);
+ DrawStdFrameWithCustomTileAndPalette(1, 0, 0x27, 0xd);
offset = GetStringCenterAlignXOffset(1, gText_Hoenn, 0x38);
AddTextPrinterParameterized(1, 1, gText_Hoenn, offset, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
- SetWindowBorderStyle(0, 0, 0x27, 0xd);
+ DrawStdFrameWithCustomTileAndPalette(0, 0, 0x27, 0xd);
PrintRegionMapSecName();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0);
sFieldRegionMapHandler->state++;
@@ -196,13 +196,13 @@ static void PrintRegionMapSecName(void)
{
if (sFieldRegionMapHandler->regionMap.iconDrawType != MAPSECTYPE_NONE)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, 1, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
}
else
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, 3);
}
}
diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c
index 0a4f3212b..b6dcf212c 100644
--- a/src/field_screen_effect.c
+++ b/src/field_screen_effect.c
@@ -10,7 +10,6 @@
#include "field_screen_effect.h"
#include "field_special_scene.h"
#include "field_weather.h"
-// #include "fldeff_flash.h"
#include "gpu_regs.h"
#include "link.h"
#include "link_rfu.h"
@@ -31,22 +30,9 @@
#include "constants/event_object_movement_constants.h"
#include "constants/songs.h"
#include "constants/rgb.h"
-
-extern bool32 sub_81D6534(void);
-extern bool8 walkrun_is_standing_still(void);
-extern void ScriptUnfreezeEventObjects(void);
-extern void sub_80FB768(void);
-extern void sub_808D194(void);
-extern void sub_808D1C8(void);
-extern bool32 sub_808D1B4(void);
-extern bool32 sub_808D1E8(void);
-extern void sub_80B6B68(void);
-extern void sub_80B6E4C(u8, u8);
-extern void sub_80B75D8(u8);
-extern void sub_80B7A74(u8);
-extern void sub_808C0A8(u8);
-extern u8 GetMapPairFadeToType(u8, u8);
-extern u8 GetMapPairFadeFromType(u8, u8);
+#include "trainer_hill.h"
+#include "event_obj_lock.h"
+#include "fldeff.h"
extern const u16 gUnknown_82EC7CC[];
@@ -255,7 +241,7 @@ void sub_80AF2B4(u8 taskId)
break;
case 2:
sub_8009F18();
- sub_8086C2C();
+ ResetAllMultiplayerState();
ScriptContext2_Disable();
DestroyTask(taskId);
break;
@@ -621,7 +607,7 @@ void sub_80AF948(void)
CreateTask(sub_80AF8E0, 10);
}
-static void sub_80AF96C(u8 taskId)
+static void Task_ReturnToWorldFromLinkRoom(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@@ -654,7 +640,7 @@ static void sub_80AF96C(u8 taskId)
void sub_80AF9F8(void)
{
- CreateTask(sub_80AF96C, 10);
+ CreateTask(Task_ReturnToWorldFromLinkRoom, 10);
}
static void sub_80AFA0C(u8 taskId)
diff --git a/src/field_specials.c b/src/field_specials.c
index 307f81399..436b06f53 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -55,6 +55,7 @@
#include "constants/vars.h"
#include "constants/battle_frontier.h"
#include "constants/weather.h"
+#include "palette.h"
EWRAM_DATA bool8 gBikeCyclingChallenge = FALSE;
EWRAM_DATA u8 gBikeCollisions = 0;
@@ -80,9 +81,6 @@ extern const u16 gEventObjectPalette17[];
extern const u16 gEventObjectPalette33[];
extern const u16 gEventObjectPalette34[];
-extern void LoadPalette(const void *src, u32 offset, u16 size); // incorrect signature, needed to match
-extern void BlendPalettes(u32, u8, u16);
-extern void FieldInitRegionMap(MainCallback callback);
void UpdateMovedLilycoveFanClubMembers(void);
void sub_813BF60(void);
@@ -360,17 +358,17 @@ u8 GetSSTidalLocation(s8 *mapGroup, s8 *mapNum, s16 *x, s16 *y)
return 0;
}
-bool32 is_tile_that_overrides_player_control(void)
+bool32 ShouldDoWallyCall(void)
{
if (FlagGet(FLAG_ENABLE_FIRST_WALLY_POKENAV_CALL))
{
switch (gMapHeader.mapType)
{
- case 1:
- case 2:
- case 3:
- case 6:
- if (++(*GetVarPointer(VAR_0x40F2)) < 0xFA)
+ case MAP_TYPE_TOWN:
+ case MAP_TYPE_CITY:
+ case MAP_TYPE_ROUTE:
+ case MAP_TYPE_OCEAN_ROUTE:
+ if (++(*GetVarPointer(VAR_WALLY_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
@@ -387,7 +385,7 @@ bool32 is_tile_that_overrides_player_control(void)
return TRUE;
}
-bool32 sub_8138120(void)
+bool32 ShouldDoWinonaCall(void)
{
if (FlagGet(FLAG_REGISTER_WINONA_POKENAV))
{
@@ -396,8 +394,8 @@ bool32 sub_8138120(void)
case MAP_TYPE_TOWN:
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
- case MAP_TYPE_6:
- if (++(*GetVarPointer(VAR_0x40F3)) < 10)
+ case MAP_TYPE_OCEAN_ROUTE:
+ if (++(*GetVarPointer(VAR_WINONA_CALL_STEP_COUNTER)) < 10)
{
return FALSE;
}
@@ -414,7 +412,7 @@ bool32 sub_8138120(void)
return TRUE;
}
-bool32 sub_8138168(void)
+bool32 ShouldDoScottCall(void)
{
if (FlagGet(FLAG_SCOTT_CALL_NATIONAL_DEX))
{
@@ -424,7 +422,7 @@ bool32 sub_8138168(void)
case 2:
case 3:
case 6:
- if (++(*GetVarPointer(VAR_0x40F5)) < 0xA)
+ if (++(*GetVarPointer(VAR_SCOTT_CALL_STEP_COUNTER)) < 10)
{
return FALSE;
}
@@ -441,7 +439,7 @@ bool32 sub_8138168(void)
return TRUE;
}
-bool32 sub_81381B0(void)
+bool32 ShouldDoRoxanneCall(void)
{
if (FlagGet(FLAG_ENABLE_ROXANNE_FIRST_CALL))
{
@@ -451,7 +449,7 @@ bool32 sub_81381B0(void)
case 2:
case 3:
case 6:
- if (++(*GetVarPointer(VAR_0x40F4)) < 0xFA)
+ if (++(*GetVarPointer(VAR_ROXANNE_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
@@ -468,7 +466,7 @@ bool32 sub_81381B0(void)
return TRUE;
}
-bool32 sub_81381F8(void)
+bool32 ShouldDoRivalRayquazaCall(void)
{
if (FlagGet(FLAG_DEFEATED_MAGMA_SPACE_CENTER))
{
@@ -478,7 +476,7 @@ bool32 sub_81381F8(void)
case 2:
case 3:
case 6:
- if (++(*GetVarPointer(VAR_0x40F6)) < 0xFA)
+ if (++(*GetVarPointer(VAR_RIVAL_RAYQUAZA_CALL_STEP_COUNTER)) < 250)
{
return FALSE;
}
@@ -591,7 +589,9 @@ void SpawnLinkPartnerEventObject(void)
static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEventId, u8 paletteNum)
{
- paletteNum += 6;
+ u8 adjustedPaletteNum;
+ // Note: This temp var is necessary; paletteNum += 6 doesn't match.
+ adjustedPaletteNum = paletteNum + 6;
if (graphicsId == EVENT_OBJ_GFX_LINK_RS_BRENDAN ||
graphicsId == EVENT_OBJ_GFX_LINK_RS_MAY ||
graphicsId == EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL ||
@@ -602,21 +602,21 @@ static void LoadLinkPartnerEventObjectSpritePalette(u8 graphicsId, u8 localEvent
{
u8 spriteId = gEventObjects[obj].spriteId;
struct Sprite *sprite = &gSprites[spriteId];
- sprite->oam.paletteNum = paletteNum;
+ sprite->oam.paletteNum = adjustedPaletteNum;
switch (graphicsId)
{
case EVENT_OBJ_GFX_LINK_RS_BRENDAN:
- LoadPalette(gEventObjectPalette33, 0x100 + paletteNum * 16, 0x20);
+ LoadPalette(gEventObjectPalette33, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_LINK_RS_MAY:
- LoadPalette(gEventObjectPalette34, 0x100 + paletteNum * 16, 0x20);
+ LoadPalette(gEventObjectPalette34, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_RIVAL_BRENDAN_NORMAL:
- LoadPalette(gEventObjectPalette8, 0x100 + paletteNum * 16, 0x20);
+ LoadPalette(gEventObjectPalette8, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
case EVENT_OBJ_GFX_RIVAL_MAY_NORMAL:
- LoadPalette(gEventObjectPalette17, 0x100 + paletteNum * 16, 0x20);
+ LoadPalette(gEventObjectPalette17, 0x100 + (adjustedPaletteNum << 4), 0x20);
break;
}
}
@@ -887,8 +887,8 @@ static void PetalburgGymFunc(u8 a0, u16 a1)
}
for (i = 0; i < nDoors; i++)
{
- MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | 0xc00);
- MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | 0xc00);
+ MapGridSetMetatileIdAt(x[i] + 7, y[i] + 7, a1 | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x[i] + 7, y[i] + 8, (a1 + 8) | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
}
@@ -1100,7 +1100,7 @@ static void PCTurnOnEffect_1(s16 flag, s8 dx, s8 dy)
tileId = 0x27e;
}
}
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
}
void DoPCTurnOffEffect(void)
@@ -1141,7 +1141,7 @@ static void PCTurnOffEffect(void)
{
tileId = 0x259;
}
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | 0xc00);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
@@ -1516,7 +1516,7 @@ bool8 FoundBlackGlasses(void)
void SetRoute119Weather(void)
{
- if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE)
+ if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
{
SetSav1Weather(20);
}
@@ -1524,7 +1524,7 @@ void SetRoute119Weather(void)
void SetRoute123Weather(void)
{
- if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()) != TRUE)
+ if (IsMapTypeOutdoors(GetLastUsedWarpMapType()) != TRUE)
{
SetSav1Weather(21);
}
@@ -1860,7 +1860,7 @@ void sub_8139B60(void)
void sub_8139C10(void)
{
- sub_8198070(gUnknown_0203AB5E, TRUE);
+ ClearStdWindowAndFrameToTransparent(gUnknown_0203AB5E, TRUE);
RemoveWindow(gUnknown_0203AB5E);
}
@@ -1892,7 +1892,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
- MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | 0xC00);
+ MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2BF4[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
}
}
@@ -1902,7 +1902,7 @@ static void sub_8139C80(u8 taskId)
{
for (x = 0; x < 3; x++)
{
- MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | 0xC00);
+ MapGridSetMetatileIdAt(x + 8, y + 7, gUnknown_085B2C06[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
}
}
@@ -2645,8 +2645,8 @@ static void sub_813A570(u8 taskId)
sub_813A738(taskId);
DestroyListMenuTask(task->data[14], NULL, NULL);
Free(gUnknown_0203AB64);
- sub_8198070(task->data[13], 1);
- FillWindowPixelBuffer(task->data[13], 0);
+ ClearStdWindowAndFrameToTransparent(task->data[13], 1);
+ FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
DestroyTask(taskId);
@@ -2890,7 +2890,7 @@ void sub_813A958(void)
void sub_813A988(void)
{
- sub_8198070(gUnknown_0203AB6D, TRUE);
+ ClearStdWindowAndFrameToTransparent(gUnknown_0203AB6D, TRUE);
RemoveWindow(gUnknown_0203AB6D);
}
@@ -2942,7 +2942,7 @@ void sub_813AA18(void)
void sub_813AA44(void)
{
- sub_8198070(gUnknown_0203AB6E, TRUE);
+ ClearStdWindowAndFrameToTransparent(gUnknown_0203AB6E, TRUE);
RemoveWindow(gUnknown_0203AB6E);
}
@@ -3001,7 +3001,7 @@ static void sub_813AA60(u16 a0, u16 a1)
if (a0 > 2 && a0 < 7)
{
- FillWindowPixelRect(0, 0x11, 0, 0, 216, 32);
+ FillWindowPixelRect(0, PIXEL_FILL(1), 0, 0, 216, 32);
switch (a0)
{
case 3:
@@ -3140,7 +3140,7 @@ static void sub_813AD34(u8 a0, u16 a1)
if (a0 == 9 || a0 == 10)
{
- FillWindowPixelRect(gUnknown_0203AB5E, 0x11, 0, 0, 96, 48);
+ FillWindowPixelRect(gUnknown_0203AB5E, PIXEL_FILL(1), 0, 0, 96, 48);
if (a0 == 10)
{
AddTextPrinterParameterized(gUnknown_0203AB5E, 1, gUnknown_085B3254[a1], 0, 1, 0, NULL);
@@ -3154,7 +3154,7 @@ static void sub_813AD34(u8 a0, u16 a1)
void sub_813ADB8(void)
{
- sub_8198070(gUnknown_0203AB5E, TRUE);
+ ClearStdWindowAndFrameToTransparent(gUnknown_0203AB5E, TRUE);
RemoveWindow(gUnknown_0203AB5E);
}
@@ -3226,8 +3226,8 @@ void sub_813AF48(void)
struct Task *task = &gTasks[taskId];
DestroyListMenuTask(task->data[14], NULL, NULL);
Free(gUnknown_0203AB64);
- sub_8198070(task->data[13], TRUE);
- FillWindowPixelBuffer(task->data[13], 0);
+ ClearStdWindowAndFrameToTransparent(task->data[13], TRUE);
+ FillWindowPixelBuffer(task->data[13], PIXEL_FILL(0));
ClearWindowTilemap(task->data[13]);
CopyWindowToVram(task->data[13], 2);
RemoveWindow(task->data[13]);
@@ -3379,7 +3379,7 @@ u16 get_unknown_box_id(void)
return gUnknown_0203AB6F;
}
-bool32 sub_813B21C(void)
+bool8 sub_813B21C(void)
{
if (FlagGet(FLAG_SYS_STORAGE_UNKNOWN_FLAG) == FALSE)
{
@@ -3421,40 +3421,59 @@ bool8 sub_813B260(void)
return FALSE;
}
-void sub_813B2E4(void)
+void CreateUnusualWeatherEvent(void)
{
u16 randomValue = Random();
- VarSet(VAR_0x4038, 0);
+ VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, 0);
if (FlagGet(FLAG_DEFEATED_KYOGRE) == TRUE)
{
- VarSet(VAR_0x4037, (randomValue & 7) + 1);
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START);
}
else if (FlagGet(FLAG_DEFEATED_GROUDON) == TRUE)
{
- VarSet(VAR_0x4037, (randomValue & 7) + 9);
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START);
}
else if ((randomValue & 1) == 0)
{
randomValue = Random();
- VarSet(VAR_0x4037, (randomValue & 7) + 1);
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_GROUDON_LOCATIONS_START);
}
else
{
randomValue = Random();
- VarSet(VAR_0x4037, (randomValue & 7) + 9);
- }
-}
-
-bool32 sub_813B374(void)
-{
- static const u8 gUnknown_085B3400[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, (randomValue % UNUSUAL_WEATHER_COUNT_PER_LEGENDARY) + UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START);
+ }
+}
+
+// Saves the map name for the current unusual weather location in gStringVar1, then
+// returns TRUE if the weather is for Kyogre, and FALSE if it's for Groudon.
+bool32 GetUnusualWeatherMapNameAndType(void)
+{
+ static const u8 sUnusualWeatherMapNumbers[] = {
+ MAP_NUM(ROUTE114),
+ MAP_NUM(ROUTE114),
+ MAP_NUM(ROUTE115),
+ MAP_NUM(ROUTE115),
+ MAP_NUM(ROUTE116),
+ MAP_NUM(ROUTE116),
+ MAP_NUM(ROUTE118),
+ MAP_NUM(ROUTE118),
+ MAP_NUM(ROUTE105),
+ MAP_NUM(ROUTE105),
+ MAP_NUM(ROUTE125),
+ MAP_NUM(ROUTE125),
+ MAP_NUM(ROUTE127),
+ MAP_NUM(ROUTE127),
+ MAP_NUM(ROUTE129),
+ MAP_NUM(ROUTE129)
+ };
- u16 var = VarGet(VAR_0x4037);
+ u16 unusualWeather = VarGet(VAR_UNUSUAL_WEATHER_LOCATION);
- GetMapName(gStringVar1, gUnknown_085B3400[var - 1], 0);
+ GetMapName(gStringVar1, sUnusualWeatherMapNumbers[unusualWeather - 1], 0);
- if (var < 9)
+ if (unusualWeather < UNUSUAL_WEATHER_KYOGRE_LOCATIONS_START)
{
return FALSE;
}
@@ -3464,21 +3483,39 @@ bool32 sub_813B374(void)
}
}
-bool8 sub_813B3B0(void)
-{
- static const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };
+bool8 UnusualWeatherHasExpired(void)
+{
+ // Duplicate array.
+ static const u8 sUnusualWeatherMapNumbers_2[] = {
+ MAP_NUM(ROUTE114),
+ MAP_NUM(ROUTE114),
+ MAP_NUM(ROUTE115),
+ MAP_NUM(ROUTE115),
+ MAP_NUM(ROUTE116),
+ MAP_NUM(ROUTE116),
+ MAP_NUM(ROUTE118),
+ MAP_NUM(ROUTE118),
+ MAP_NUM(ROUTE105),
+ MAP_NUM(ROUTE105),
+ MAP_NUM(ROUTE125),
+ MAP_NUM(ROUTE125),
+ MAP_NUM(ROUTE127),
+ MAP_NUM(ROUTE127),
+ MAP_NUM(ROUTE129),
+ MAP_NUM(ROUTE129)
+ };
- u16 var1 = VarGet(VAR_0x4038);
- u16 var2 = VarGet(VAR_0x4037);
+ u16 steps = VarGet(VAR_UNUSUAL_WEATHER_STEP_COUNTER);
+ u16 unusualWeather = VarGet(VAR_UNUSUAL_WEATHER_LOCATION);
- if (!var2)
+ if (unusualWeather == UNUSUAL_WEATHER_NONE)
{
return FALSE;
}
- if (++var1 > 999)
+ if (++steps > 999)
{
- VarSet(VAR_0x4038, 0);
+ VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, 0);
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(UNDERWATER_MARINE_CAVE))
{
switch (gSaveBlock1Ptr->location.mapNum)
@@ -3488,7 +3525,7 @@ bool8 sub_813B3B0(void)
case MAP_NUM(MARINE_CAVE_END):
case MAP_NUM(TERRA_CAVE_ENTRANCE):
case MAP_NUM(TERRA_CAVE_END):
- VarSet(VAR_0x4039, 1);
+ VarSet(VAR_SHOULD_END_UNUSUAL_WEATHER, 1);
return FALSE;
default:
break;
@@ -3503,27 +3540,27 @@ bool8 sub_813B3B0(void)
case MAP_NUM(UNDERWATER5):
case MAP_NUM(UNDERWATER6):
case MAP_NUM(UNDERWATER7):
- VarSet(VAR_0x4039, 1);
+ VarSet(VAR_SHOULD_END_UNUSUAL_WEATHER, 1);
return FALSE;
default:
break;
}
}
- if (gSaveBlock1Ptr->location.mapNum == gUnknown_085B3410[var2 - 1] &&
+ if (gSaveBlock1Ptr->location.mapNum == sUnusualWeatherMapNumbers_2[unusualWeather - 1] &&
gSaveBlock1Ptr->location.mapGroup == 0)
{
return TRUE;
}
else
{
- VarSet(VAR_0x4037, 0);
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE);
return FALSE;
}
}
else
{
- VarSet(VAR_0x4038, var1);
+ VarSet(VAR_UNUSUAL_WEATHER_STEP_COUNTER, steps);
return FALSE;
}
}
@@ -3577,7 +3614,7 @@ bool32 sub_813B4E0(void)
bool32 sub_813B514(void)
{
- if (!VarGet(VAR_0x403F))
+ if (!VarGet(VAR_ALWAYS_ZERO_0x403F))
{
return FALSE;
}
diff --git a/src/fieldmap.c b/src/fieldmap.c
index cf5f0356e..a96b71c0f 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -383,15 +383,15 @@ u8 MapGridGetZCoordAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
- block |= 0xc00;
+ block |= METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
return 0;
}
- return block >> 12;
+ return block >> METATILE_ELEVATION_SHIFT;
}
u8 MapGridIsImpassableAt(int x, int y)
@@ -411,13 +411,13 @@ u8 MapGridIsImpassableAt(int x, int y)
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
block = gMapHeader.mapLayout->border[i];
- block |= 0xc00;
+ block |= METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
return 1;
}
- return (block & 0xc00) >> 10;
+ return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
}
u32 MapGridGetMetatileIdAt(int x, int y)
@@ -439,18 +439,19 @@ u32 MapGridGetMetatileIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
i = (x + 1) & 1;
i += ((y + 1) & 1) * 2;
- block = mapLayout->border[i] | 0xc00;
+ block = mapLayout->border[i] | METATILE_COLLISION_MASK;
}
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
border = gMapHeader.mapLayout->border;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
block2 = gMapHeader.mapLayout->border[j];
- block2 |= 0xc00;
- return block2 & block;
+ // This OR is completely pointless.
+ block2 |= METATILE_COLLISION_MASK;
+ return block2 & METATILE_ID_MASK;
}
- return block & 0x3ff;
+ return block & METATILE_ID_MASK;
}
u32 MapGridGetMetatileBehaviorAt(int x, int y)
@@ -464,7 +465,7 @@ u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{
u16 metatile;
metatile = MapGridGetMetatileIdAt(x, y);
- return (GetBehaviorByMetatileId(metatile) & 0xf000) >> 12;
+ return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT;
}
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@@ -474,7 +475,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
&& y >= 0 && y < gBackupMapLayout.height)
{
i = x + y * gBackupMapLayout.width;
- gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & 0xf000) | (metatile & 0xfff);
+ gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
}
}
@@ -654,7 +655,7 @@ int GetMapBorderIdAt(int x, int y)
i = gBackupMapLayout.width;
i *= y;
block = gBackupMapLayout.map[x + i];
- if (block == 0x3ff)
+ if (block == METATILE_ID_UNDEFINED)
{
goto fail;
}
@@ -664,8 +665,8 @@ int GetMapBorderIdAt(int x, int y)
mapLayout = gMapHeader.mapLayout;
j = (x + 1) & 1;
j += ((y + 1) & 1) * 2;
- block2 = 0xc00 | mapLayout->border[j];
- if (block2 == 0x3ff)
+ block2 = METATILE_COLLISION_MASK | mapLayout->border[j];
+ if (block2 == METATILE_ID_UNDEFINED)
{
goto fail;
}
@@ -921,9 +922,9 @@ void sub_8088B94(int x, int y, int a2)
if (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
{
if (a2 != 0)
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= 0xC00;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
else
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= 0xF3FF;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
}
}
@@ -937,7 +938,7 @@ static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth,
else
mapMetatilePtr += mapWidth;
- if (sub_80FADE4(*mapMetatilePtr & 0x3FF, yMode) == 1)
+ if (sub_80FADE4(*mapMetatilePtr & METATILE_ID_MASK, yMode) == 1)
return TRUE;
return FALSE;
}
diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c
index 348a1f46c..a715608c5 100644
--- a/src/fldeff_cut.c
+++ b/src/fldeff_cut.c
@@ -20,7 +20,6 @@
#include "constants/field_effects.h"
#include "constants/songs.h"
-extern void ScriptUnfreezeEventObjects(void);
extern bool8 IsMewPlayingHideAndSeek(void);
extern struct MapPosition gPlayerFacingPosition;
diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c
index 3d00fb162..7ab2db4db 100644
--- a/src/fldeff_escalator.c
+++ b/src/fldeff_escalator.c
@@ -7,7 +7,7 @@
static EWRAM_DATA u8 sEscalatorAnim_TaskId = 0;
-static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
+static void sub_80E12E8(u8 taskId, const s16 *list, u16 isImpassableFlag)
{
s16 r5 = gTasks[taskId].data[4] - 1;
s16 r3 = gTasks[taskId].data[5] - 1;
@@ -26,9 +26,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
if (list[r4] == metatileId)
{
if (r4 != 2)
- MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[r4 + 1]);
+ MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[r4 + 1]);
else
- MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[0]);
+ MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[0]);
}
}
}
@@ -44,9 +44,9 @@ static void sub_80E12E8(u8 taskId, const s16 *list, u16 c)
if (list[2 - r4] == metatileId)
{
if (r4 != 2)
- MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[1 - r4]);
+ MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[1 - r4]);
else
- MapGridSetMetatileIdAt(r5 + x, r3 + y, c | list[2]);
+ MapGridSetMetatileIdAt(r5 + x, r3 + y, isImpassableFlag | list[2]);
}
}
}
@@ -76,13 +76,13 @@ static void sub_80E1444(u8 taskId)
sub_80E12E8(taskId, gUnknown_08589AC0, 0);
break;
case 2:
- sub_80E12E8(taskId, gUnknown_08589AC6, 0xC00);
+ sub_80E12E8(taskId, gUnknown_08589AC6, METATILE_COLLISION_MASK);
break;
case 3:
sub_80E12E8(taskId, gUnknown_08589ACC, 0);
break;
case 4:
- sub_80E12E8(taskId, gUnknown_08589AD2, 0xC00);
+ sub_80E12E8(taskId, gUnknown_08589AD2, METATILE_COLLISION_MASK);
break;
case 5:
sub_80E12E8(taskId, gUnknown_08589AD8, 0);
diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c
index df4576a7f..d4d6075f3 100644
--- a/src/fldeff_misc.c
+++ b/src/fldeff_misc.c
@@ -1126,7 +1126,7 @@ void GetShieldToyTVDecorationInfo(void)
if (!VarGet(VAR_CURRENT_SECRET_BASE))
return;
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x10);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x10);
break;
case 734:
ConvertIntToDecimalStringN(gStringVar1, 50, STR_CONV_MODE_LEFT_ALIGN, 2);
@@ -1137,7 +1137,7 @@ void GetShieldToyTVDecorationInfo(void)
if (!VarGet(VAR_CURRENT_SECRET_BASE))
return;
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x20);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x20);
break;
case 756:
gSpecialVar_Result = 1;
@@ -1145,7 +1145,7 @@ void GetShieldToyTVDecorationInfo(void)
if (!VarGet(VAR_CURRENT_SECRET_BASE))
return;
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x80);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x80);
break;
case 757:
gSpecialVar_Result = 2;
@@ -1153,7 +1153,7 @@ void GetShieldToyTVDecorationInfo(void)
if (!VarGet(VAR_CURRENT_SECRET_BASE))
return;
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x80);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x80);
break;
case 758:
gSpecialVar_Result = 3;
@@ -1161,7 +1161,7 @@ void GetShieldToyTVDecorationInfo(void)
if (!VarGet(VAR_CURRENT_SECRET_BASE))
return;
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x80);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x80);
break;
}
}
diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c
index adec780b3..eca7d045b 100644
--- a/src/fldeff_softboiled.c
+++ b/src/fldeff_softboiled.c
@@ -86,7 +86,7 @@ static void sub_8161724(u8 taskId)
sub_81B0FCC(gUnknown_0203CEC8.unk9, 0);
gUnknown_0203CEC8.unk9 = gUnknown_0203CEC8.unkA;
sub_81B0FCC(gUnknown_0203CEC8.unkA, 1);
- sub_8198070(0x6, FALSE);
+ ClearStdWindowAndFrameToTransparent(0x6, FALSE);
ClearWindowTilemap(0x6);
display_pokemon_menu_message(0);
gTasks[taskId].func = sub_81B1370;
diff --git a/src/flying.c b/src/flying.c
index 48df12a06..a157582e9 100644
--- a/src/flying.c
+++ b/src/flying.c
@@ -4,6 +4,9 @@
#include "trig.h"
#include "constants/battle_anim.h"
#include "constants/rgb.h"
+#include "random.h"
+
+extern const struct SpriteTemplate gUnknown_085973E8;
void sub_810DE70(struct Sprite *);
void sub_810DFA8(struct Sprite *);
@@ -11,22 +14,29 @@ void sub_810E044(struct Sprite *);
void sub_810E13C(struct Sprite *);
void sub_810E1C8(struct Sprite *);
void sub_810E314(struct Sprite *);
-extern void sub_810EA4C(struct Sprite *);
-extern void sub_810EAA0(struct Sprite *);
-extern void sub_810EC34(struct Sprite *);
-extern void sub_810EC94(struct Sprite *);
-extern void sub_810ED28(struct Sprite *);
-extern void sub_810EE14(struct Sprite *);
-extern void sub_810EEF8(struct Sprite *);
-extern void sub_810F004(struct Sprite *);
-extern void sub_810F084(struct Sprite *);
+void sub_810E520(struct Sprite *);
+void sub_810EB40(struct Sprite *);
+void sub_810EA4C(struct Sprite *);
+void sub_810EAA0(struct Sprite *);
+void sub_810EC34(struct Sprite *);
+void sub_810EC94(struct Sprite *);
+void sub_810ED28(struct Sprite *);
+void sub_810ED70(struct Sprite *);
+void sub_810EDD0(struct Sprite *);
+void sub_810EE14(struct Sprite *);
+void sub_810EEF8(struct Sprite *);
+void sub_810EFA8(struct Sprite *);
+void sub_810F004(struct Sprite *);
+void sub_810F018(struct Sprite *);
+void sub_810F084(struct Sprite *);
+void sub_810F140(struct Sprite *);
static void sub_810DE98(struct Sprite *);
static void sub_810DF18(u8);
static void sub_810E028(struct Sprite *);
static void sub_810E184(struct Sprite *);
static void sub_810E24C(struct Sprite *);
-void sub_810E520(struct Sprite *);
+
const struct SpriteTemplate gUnknown_08596270 =
{
@@ -98,7 +108,7 @@ const union AffineAnimCmd gUnknown_085962EC[] =
const union AffineAnimCmd *const gUnknown_08596314[] =
{
- gUnknown_085962EC,
+ gUnknown_085962EC,
};
const union AffineAnimCmd gUnknown_08596318[] =
@@ -347,7 +357,8 @@ void sub_810DE70(struct Sprite *sprite)
sprite->callback(sprite);
}
-static void sub_810DE98(struct Sprite *sprite) {
+static void sub_810DE98(struct Sprite *sprite)
+{
sprite->pos2.x = Sin(sprite->data[1], 32);
sprite->pos2.y = Cos(sprite->data[1], 8);
sprite->data[1] += 5;
@@ -382,8 +393,7 @@ static void sub_810DF18(u8 taskId)
{
gPlttBufferFaded[base + 0x101 + i] = gPlttBufferFaded[base + 0x100 + i];
i--;
- }
- while (i > 0);
+ } while (i > 0);
gPlttBufferFaded[base + 0x101] = temp;
}
@@ -514,7 +524,9 @@ static void sub_810E24C(struct Sprite *sprite)
sprite->data[3] &= 0xFF;
}
- if ((u32)(sprite->pos1.x + sprite->pos2.x + 32) > 304 || sprite->pos1.y + sprite->pos2.y > 160)
+ if (sprite->pos1.x + sprite->pos2.x < -32
+ || sprite->pos1.x + sprite->pos2.x > 272
+ || sprite->pos1.y + sprite->pos2.y > 160)
{
gSprites[GetAnimBattlerSpriteId(ANIM_ATTACKER)].invisible = 0;
DestroyAnimSprite(sprite);
@@ -536,56 +548,62 @@ void sub_810E2C8(struct Sprite *sprite)
}
}
-// FAKEMATCHING
+struct FeatherDanceData
+{
+ u8 unk0_0a:1;
+ u8 unk0_0b:1;
+ u8 unk0_0c:1;
+ u8 unk0_0d:1;
+ u8 unk0_1:4;
+ u8 unk1;
+ u16 unk2;
+ s16 unk4;
+ u16 unk6;
+ u16 unk8;
+ u16 unkA;
+ u8 unkC[2];
+ u16 unkE_0:1;
+ u16 unkE_1:15;
+};
+
void sub_810E314(struct Sprite *sprite)
{
- s16 *data;
- u8 slot;
- s16 spriteCoord;
- int t1, t2;
- u32 arg2;
- u32 matrixNum;
- u8 sinIndex;
- register s16 sinVal asm ("r4");
- register int sinVal2 asm ("r0");
+ u8 battler, matrixNum, sinIndex;
+ s16 spriteCoord, sinVal;
- data = sprite->data;
+ struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
if (gBattleAnimArgs[7] & 0x100)
- slot = gBattleAnimAttacker;
+ battler = gBattleAnimAttacker;
else
- slot = gBattleAnimTarget;
+ battler = gBattleAnimTarget;
- if (GetBattlerSide(slot) == B_SIDE_PLAYER)
+ if (GetBattlerSide(battler) == B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
- sprite->pos1.x = GetBattlerSpriteCoord(slot, 0) + gBattleAnimArgs[0];
- spriteCoord = GetBattlerSpriteCoord(slot, 1);
+ sprite->pos1.x = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_HEIGHT) + gBattleAnimArgs[0];
+ spriteCoord = GetBattlerSpriteCoord(battler, BATTLER_COORD_ATTR_WIDTH);
sprite->pos1.y = spriteCoord + gBattleAnimArgs[1];
- data[4] = sprite->pos1.y << 8;
-
- t1 = (spriteCoord + (u16) gBattleAnimArgs[6]) << 1;
- data[7] = (data[7] & 1) | t1;
- ((u8 *) data)[0] |= 4;
- arg2 = (u16) gBattleAnimArgs[2];
- data[1] = (u8) gBattleAnimArgs[2];
- arg2 <<= 16;
- data[5] = arg2 >> 24;
- data[2] = gBattleAnimArgs[3];
- data[3] = gBattleAnimArgs[4];
- data[6] = gBattleAnimArgs[5];
+ data->unk8 = sprite->pos1.y << 8;
+ data->unkE_1 = spriteCoord + gBattleAnimArgs[6];
+ data->unk0_0c = 1;
+ data->unk2 = gBattleAnimArgs[2] & 0xFF;
+ data->unkA = (gBattleAnimArgs[2] >> 8) & 0xFF;
+ data->unk4 = gBattleAnimArgs[3];
+ data->unk6 = gBattleAnimArgs[4];
+ *(u16*)(data->unkC) = gBattleAnimArgs[5];
- if ((u16) (data[1] - 64) <= 0x7f)
+ if (data->unk2 >= 64 && data->unk2 <= 191)
{
if (!IsContest())
- sprite->oam.priority = GetBattlerSpriteBGPriority(slot) + 1;
+ sprite->oam.priority = GetBattlerSpriteBGPriority(battler) + 1;
else
- sprite->oam.priority = GetBattlerSpriteBGPriority(slot);
+ sprite->oam.priority = GetBattlerSpriteBGPriority(battler);
- ((u8 *) data)[14] = data[7] & -2;
+ data->unkE_0 = 0;
- if (!(data[2] & 0x8000))
+ if (!(data->unk4 & 0x8000))
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
@@ -596,10 +614,10 @@ void sub_810E314(struct Sprite *sprite)
}
else
{
- sprite->oam.priority = GetBattlerSpriteBGPriority(slot);
- ((u8 *) data)[14] |= 1;
+ sprite->oam.priority = GetBattlerSpriteBGPriority(battler);
+ data->unkE_0 = 1;
- if (data[2] & 0x8000)
+ if (data->unk4 & 0x8000)
{
sprite->hFlip ^= 1;
sprite->animNum = sprite->hFlip;
@@ -609,20 +627,1291 @@ void sub_810E314(struct Sprite *sprite)
}
}
- t2 = (u16) data[1] >> 6 << 4;
- ((u8 *) data)[0] = (15 & data[0]) | t2;
-
- sprite->pos2.x = (gSineTable[(u16) data[1]] * (u8) data[6]) >> 8;
-
+ data->unk0_1 = data->unk2 >> 6;
+ sprite->pos2.x = (gSineTable[data->unk2] * data->unkC[0]) >> 8;
matrixNum = sprite->oam.matrixNum;
- sinIndex = (-sprite->pos2.x >> 1) + data[5];
+ sinIndex = (-sprite->pos2.x >> 1) + data->unkA;
sinVal = gSineTable[sinIndex];
gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64];
- gOamMatrices[matrixNum].b = sinVal;
- sinVal2 = -sinVal;
- gOamMatrices[matrixNum].c = sinVal2;
+ // The comparison below is completely pointless. 'sprite' is sure to be a valid pointer and
+ // both the 'if' and 'else' parts are exactly the same.
+ // The only reason for this is making sure the compiler generates the exact ASM.
+ if (sprite)
+ {
+ gOamMatrices[matrixNum].b = sinVal;
+ gOamMatrices[matrixNum].c = -sinVal;
+ }
+ else
+ {
+ gOamMatrices[matrixNum].b = sinVal;
+ gOamMatrices[matrixNum].c = -sinVal;
+ }
sprite->callback = sub_810E520;
}
+
+#ifdef NONMATCHING
+/*
+Things I can't get to match:
+1. data->unk0_1 bitfield behaviour. The way bits are read is different.
+2. sprite->oam.priority--; sprite->oam.priority++; Nonmatching version tail-merges these, original does not.
+3. sprite->pos2.x = (gSineTable[data->unk2] * var) >> 8; data->unk2 is very weirdly read at seemingly random moments inside the switch.
+4. sinVal r6/r7 mismatch.
+*/
+void sub_810E520(struct Sprite *sprite)
+{
+ u8 matrixNum, sinIndex, var;
+ s16 sinVal = 0;
+ struct FeatherDanceData *data = (struct FeatherDanceData *)sprite->data;
+
+ if (data->unk0_0a)
+ {
+ if (data->unk1-- % 256 == 0)
+ {
+ data->unk0_0a = 0;
+ data->unk1 = 0;
+ }
+ }
+ else
+ {
+ switch (data->unk2 >> 6)
+ {
+ case 0:
+ if (data->unk0_1 == 1)
+ {
+ data->unk0_0d = 1;
+ data->unk0_0a = 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_1 == 3)
+ {
+ data->unk0_0b ^= 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_0d)
+ {
+ sprite->hFlip ^= 1;
+ sprite->animNum = sprite->hFlip;
+ sprite->animBeginning = 1;
+ sprite->animEnded = 0;
+ if (data->unk0_0c)
+ {
+ if (!IsContest())
+ {
+ if (!data->unkE_0)
+ sprite->oam.priority--;
+ else
+ sprite->oam.priority++;
+ }
+ else
+ {
+ if (!data->unkE_0)
+ sprite->subpriority -= 12;
+ else
+ sprite->subpriority += 12;
+ }
+ data->unkE_0 ^= 1;
+ }
+ data->unk0_0d = 0;
+ }
+ data->unk0_1 = 0;
+ break;
+ case 1:
+ if (data->unk0_1 == 0)
+ {
+ data->unk0_0d = 1;
+ data->unk0_0a = 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_1 == 2)
+ {
+ data->unk0_0a = 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_0d)
+ {
+ sprite->hFlip ^= 1;
+ sprite->animNum = sprite->hFlip;
+ sprite->animBeginning = 1;
+ sprite->animEnded = 0;
+ if (data->unk0_0c)
+ {
+ if (!IsContest())
+ {
+ if (!data->unkE_0)
+ sprite->oam.priority--;
+ else
+ sprite->oam.priority++;
+ }
+ else
+ {
+ if (!data->unkE_0)
+ sprite->subpriority -= 12;
+ else
+ sprite->subpriority += 12;
+ }
+ data->unkE_0 ^= 1;
+ }
+ data->unk0_0d = 0;
+ }
+ data->unk0_1 = 1;
+ break;
+ case 2:
+ if (data->unk0_1 == 0)
+ {
+ data->unk0_0d = 1;
+ data->unk0_0a = 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_1 == 2)
+ {
+ data->unk0_0a = 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_0d)
+ {
+ sprite->hFlip ^= 1;
+ sprite->animNum = sprite->hFlip;
+ sprite->animBeginning = 1;
+ sprite->animEnded = 0;
+ if (data->unk0_0c)
+ {
+ if (!IsContest())
+ {
+ if (!data->unkE_0)
+ sprite->oam.priority--;
+ else
+ sprite->oam.priority++;
+ }
+ else
+ {
+ if (!data->unkE_0)
+ sprite->subpriority -= 12;
+ else
+ sprite->subpriority += 12;
+ }
+ data->unkE_0 ^= 1;
+ }
+ data->unk0_0d = 0;
+ }
+ data->unk0_1 = 2;
+ break;
+ case 3:
+ if (data->unk0_1 == 2)
+ {
+ data->unk0_0d = 1;
+ }
+ else if (data->unk0_1 == 0)
+ {
+ data->unk0_0b ^= 1;
+ data->unk1 = 0;
+ }
+ else if (data->unk0_0d)
+ {
+ sprite->hFlip ^= 1;
+ sprite->animNum = sprite->hFlip;
+ sprite->animBeginning = 1;
+ sprite->animEnded = 0;
+ if (data->unk0_0c)
+ {
+ if (!IsContest())
+ {
+ if (!data->unkE_0)
+ sprite->oam.priority--;
+ else
+ sprite->oam.priority++;
+ }
+ else
+ {
+ if (!data->unkE_0)
+ sprite->subpriority -= 12;
+ else
+ sprite->subpriority += 12;
+ }
+ data->unkE_0 ^= 1;
+ }
+ data->unk0_0d = 0;
+ }
+ data->unk0_1 = 3;
+ break;
+ }
+
+ var = data->unkC[data->unk0_0b];
+ sprite->pos2.x = (gSineTable[data->unk2] * var) >> 8;
+ matrixNum = sprite->oam.matrixNum;
+
+ sinIndex = (-sprite->pos2.x >> 1) + data->unkA;
+ sinVal = gSineTable[sinIndex];
+
+ gOamMatrices[matrixNum].a = gOamMatrices[matrixNum].d = gSineTable[sinIndex + 64];
+ gOamMatrices[matrixNum].b = sinVal;
+ gOamMatrices[matrixNum].c = -sinVal;
+
+ data->unk8 += data->unk6;
+ sprite->pos1.y = data->unk8 >> 8;
+ if (data->unk4 & 0x8000)
+ data->unk2 = (data->unk2 - (data->unk4 & 0x7FFF)) & 0xFF;
+ else
+ data->unk2 = (data->unk2 + (data->unk4 & 0x7FFF)) & 0xFF;
+
+ if (sprite->pos1.y + sprite->pos2.y > data->unkE_1)
+ {
+ sprite->data[0] = 0;
+ sprite->callback = sub_810E2C8;
+ }
+ }
+}
+#else
+NAKED
+void sub_810E520(struct Sprite *sprite)
+{
+ asm_unified("push {r4-r7,lr}\n\
+ mov r7, r9\n\
+ mov r6, r8\n\
+ push {r6,r7}\n\
+ adds r5, r0, 0\n\
+ movs r6, 0\n\
+ adds r4, r5, 0\n\
+ adds r4, 0x2E\n\
+ ldrb r2, [r4]\n\
+ movs r7, 0x1\n\
+ movs r0, 0x1\n\
+ mov r9, r0\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _0810E55A\n\
+ ldrb r0, [r4, 0x1]\n\
+ adds r1, r0, 0\n\
+ adds r1, 0xFF\n\
+ strb r1, [r4, 0x1]\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ beq _0810E54E\n\
+ b _0810EA36\n\
+_0810E54E:\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ strb r0, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810EA36\n\
+_0810E55A:\n\
+ ldrh r0, [r4, 0x2]\n\
+ lsrs r1, r0, 6\n\
+ mov r12, r0\n\
+ cmp r1, 0x1\n\
+ bne _0810E566\n\
+ b _0810E68A\n\
+_0810E566:\n\
+ cmp r1, 0x1\n\
+ bgt _0810E570\n\
+ cmp r1, 0\n\
+ beq _0810E57E\n\
+ b _0810E97C\n\
+_0810E570:\n\
+ cmp r1, 0x2\n\
+ bne _0810E576\n\
+ b _0810E77E\n\
+_0810E576:\n\
+ cmp r1, 0x3\n\
+ bne _0810E57C\n\
+ b _0810E872\n\
+_0810E57C:\n\
+ b _0810E97C\n\
+_0810E57E:\n\
+ lsls r1, r2, 24\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x1\n\
+ bne _0810E592\n\
+ movs r0, 0x8\n\
+ orrs r0, r2\n\
+ orrs r0, r7\n\
+ strb r0, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810E680\n\
+_0810E592:\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x3\n\
+ bne _0810E5B4\n\
+ lsls r0, r2, 30\n\
+ lsrs r0, 31\n\
+ movs r1, 0x1\n\
+ eors r0, r1\n\
+ ands r0, r7\n\
+ lsls r0, 1\n\
+ movs r1, 0x3\n\
+ negs r1, r1\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ orrs r1, r7\n\
+ strb r1, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810E680\n\
+_0810E5B4:\n\
+ movs r0, 0x8\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _0810E680\n\
+ adds r3, r5, 0\n\
+ adds r3, 0x3F\n\
+ ldrb r2, [r3]\n\
+ lsls r1, r2, 31\n\
+ lsrs r1, 31\n\
+ movs r6, 0x1\n\
+ eors r1, r6\n\
+ ands r1, r7\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ mov r8, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r3]\n\
+ lsls r0, 31\n\
+ lsrs r0, 31\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x2A\n\
+ strb r0, [r1]\n\
+ ldrb r0, [r3]\n\
+ movs r1, 0x4\n\
+ orrs r0, r1\n\
+ movs r1, 0x11\n\
+ negs r1, r1\n\
+ ands r0, r1\n\
+ strb r0, [r3]\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0810E672\n\
+ bl IsContest\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ bne _0810E642\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E628\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ subs r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E660\n\
+_0810E628:\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ adds r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E660\n\
+_0810E642:\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E656\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ subs r0, 0xC\n\
+ b _0810E65E\n\
+_0810E656:\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ adds r0, 0xC\n\
+_0810E65E:\n\
+ strb r0, [r1]\n\
+_0810E660:\n\
+ ldrb r2, [r4, 0xE]\n\
+ lsls r0, r2, 31\n\
+ lsrs r0, 31\n\
+ eors r0, r6\n\
+ ands r0, r7\n\
+ mov r1, r8\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ strb r1, [r4, 0xE]\n\
+_0810E672:\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x9\n\
+ negs r0, r0\n\
+ ands r0, r1\n\
+ strb r0, [r4]\n\
+ ldrh r1, [r4, 0x2]\n\
+ mov r12, r1\n\
+_0810E680:\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0xF\n\
+ ands r0, r1\n\
+ strb r0, [r4]\n\
+ b _0810E97C\n\
+_0810E68A:\n\
+ lsls r1, r2, 24\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0\n\
+ bne _0810E698\n\
+ movs r0, 0x8\n\
+ orrs r0, r2\n\
+ b _0810E6A0\n\
+_0810E698:\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x2\n\
+ bne _0810E6A8\n\
+ adds r0, r2, 0\n\
+_0810E6A0:\n\
+ orrs r0, r7\n\
+ strb r0, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810E774\n\
+_0810E6A8:\n\
+ movs r0, 0x8\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _0810E774\n\
+ adds r3, r5, 0\n\
+ adds r3, 0x3F\n\
+ ldrb r2, [r3]\n\
+ lsls r1, r2, 31\n\
+ lsrs r1, 31\n\
+ movs r6, 0x1\n\
+ eors r1, r6\n\
+ ands r1, r7\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ mov r8, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r3]\n\
+ lsls r0, 31\n\
+ lsrs r0, 31\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x2A\n\
+ strb r0, [r1]\n\
+ ldrb r0, [r3]\n\
+ movs r1, 0x4\n\
+ orrs r0, r1\n\
+ movs r1, 0x11\n\
+ negs r1, r1\n\
+ ands r0, r1\n\
+ strb r0, [r3]\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0810E766\n\
+ bl IsContest\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ bne _0810E736\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E71C\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ subs r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E754\n\
+_0810E71C:\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ adds r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E754\n\
+_0810E736:\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E74A\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ subs r0, 0xC\n\
+ b _0810E752\n\
+_0810E74A:\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ adds r0, 0xC\n\
+_0810E752:\n\
+ strb r0, [r1]\n\
+_0810E754:\n\
+ ldrb r2, [r4, 0xE]\n\
+ lsls r0, r2, 31\n\
+ lsrs r0, 31\n\
+ eors r0, r6\n\
+ ands r0, r7\n\
+ mov r1, r8\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ strb r1, [r4, 0xE]\n\
+_0810E766:\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x9\n\
+ negs r0, r0\n\
+ ands r0, r1\n\
+ strb r0, [r4]\n\
+ ldrh r1, [r4, 0x2]\n\
+ mov r12, r1\n\
+_0810E774:\n\
+ ldrb r0, [r4]\n\
+ movs r1, 0xF\n\
+ ands r1, r0\n\
+ movs r0, 0x10\n\
+ b _0810E978\n\
+_0810E77E:\n\
+ lsls r1, r2, 24\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x3\n\
+ bne _0810E78C\n\
+ movs r0, 0x8\n\
+ orrs r0, r2\n\
+ b _0810E794\n\
+_0810E78C:\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x1\n\
+ bne _0810E79C\n\
+ adds r0, r2, 0\n\
+_0810E794:\n\
+ orrs r0, r7\n\
+ strb r0, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810E868\n\
+_0810E79C:\n\
+ movs r0, 0x8\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _0810E868\n\
+ adds r3, r5, 0\n\
+ adds r3, 0x3F\n\
+ ldrb r2, [r3]\n\
+ lsls r1, r2, 31\n\
+ lsrs r1, 31\n\
+ movs r6, 0x1\n\
+ eors r1, r6\n\
+ ands r1, r7\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ mov r8, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r3]\n\
+ lsls r0, 31\n\
+ lsrs r0, 31\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x2A\n\
+ strb r0, [r1]\n\
+ ldrb r0, [r3]\n\
+ movs r1, 0x4\n\
+ orrs r0, r1\n\
+ movs r1, 0x11\n\
+ negs r1, r1\n\
+ ands r0, r1\n\
+ strb r0, [r3]\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0810E85A\n\
+ bl IsContest\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ bne _0810E82A\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E810\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ subs r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E848\n\
+_0810E810:\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ adds r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E848\n\
+_0810E82A:\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E83E\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ subs r0, 0xC\n\
+ b _0810E846\n\
+_0810E83E:\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ adds r0, 0xC\n\
+_0810E846:\n\
+ strb r0, [r1]\n\
+_0810E848:\n\
+ ldrb r2, [r4, 0xE]\n\
+ lsls r0, r2, 31\n\
+ lsrs r0, 31\n\
+ eors r0, r6\n\
+ ands r0, r7\n\
+ mov r1, r8\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ strb r1, [r4, 0xE]\n\
+_0810E85A:\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x9\n\
+ negs r0, r0\n\
+ ands r0, r1\n\
+ strb r0, [r4]\n\
+ ldrh r1, [r4, 0x2]\n\
+ mov r12, r1\n\
+_0810E868:\n\
+ ldrb r0, [r4]\n\
+ movs r1, 0xF\n\
+ ands r1, r0\n\
+ movs r0, 0x20\n\
+ b _0810E978\n\
+_0810E872:\n\
+ lsls r1, r2, 24\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0x2\n\
+ bne _0810E882\n\
+ movs r0, 0x8\n\
+ orrs r0, r2\n\
+ strb r0, [r4]\n\
+ b _0810E970\n\
+_0810E882:\n\
+ lsrs r0, r1, 28\n\
+ cmp r0, 0\n\
+ bne _0810E8A4\n\
+ lsls r0, r2, 30\n\
+ lsrs r0, 31\n\
+ movs r1, 0x1\n\
+ eors r0, r1\n\
+ ands r0, r7\n\
+ lsls r0, 1\n\
+ movs r1, 0x3\n\
+ negs r1, r1\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ orrs r1, r7\n\
+ strb r1, [r4]\n\
+ strb r6, [r4, 0x1]\n\
+ b _0810E970\n\
+_0810E8A4:\n\
+ movs r0, 0x8\n\
+ ands r0, r2\n\
+ cmp r0, 0\n\
+ beq _0810E970\n\
+ adds r3, r5, 0\n\
+ adds r3, 0x3F\n\
+ ldrb r2, [r3]\n\
+ lsls r1, r2, 31\n\
+ lsrs r1, 31\n\
+ movs r6, 0x1\n\
+ eors r1, r6\n\
+ ands r1, r7\n\
+ movs r0, 0x2\n\
+ negs r0, r0\n\
+ mov r8, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r3]\n\
+ lsls r0, 31\n\
+ lsrs r0, 31\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x2A\n\
+ strb r0, [r1]\n\
+ ldrb r0, [r3]\n\
+ movs r1, 0x4\n\
+ orrs r0, r1\n\
+ movs r1, 0x11\n\
+ negs r1, r1\n\
+ ands r0, r1\n\
+ strb r0, [r3]\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x4\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0810E962\n\
+ bl IsContest\n\
+ lsls r0, 24\n\
+ cmp r0, 0\n\
+ bne _0810E932\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E918\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ subs r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E950\n\
+_0810E918:\n\
+ ldrb r2, [r5, 0x5]\n\
+ lsls r1, r2, 28\n\
+ lsrs r1, 30\n\
+ adds r1, 0x1\n\
+ movs r0, 0x3\n\
+ ands r1, r0\n\
+ lsls r1, 2\n\
+ movs r0, 0xD\n\
+ negs r0, r0\n\
+ ands r0, r2\n\
+ orrs r0, r1\n\
+ strb r0, [r5, 0x5]\n\
+ b _0810E950\n\
+_0810E932:\n\
+ ldrb r1, [r4, 0xE]\n\
+ mov r0, r9\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ bne _0810E946\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ subs r0, 0xC\n\
+ b _0810E94E\n\
+_0810E946:\n\
+ adds r1, r5, 0\n\
+ adds r1, 0x43\n\
+ ldrb r0, [r1]\n\
+ adds r0, 0xC\n\
+_0810E94E:\n\
+ strb r0, [r1]\n\
+_0810E950:\n\
+ ldrb r2, [r4, 0xE]\n\
+ lsls r0, r2, 31\n\
+ lsrs r0, 31\n\
+ eors r0, r6\n\
+ ands r0, r7\n\
+ mov r1, r8\n\
+ ands r1, r2\n\
+ orrs r1, r0\n\
+ strb r1, [r4, 0xE]\n\
+_0810E962:\n\
+ ldrb r1, [r4]\n\
+ movs r0, 0x9\n\
+ negs r0, r0\n\
+ ands r0, r1\n\
+ strb r0, [r4]\n\
+ ldrh r1, [r4, 0x2]\n\
+ mov r12, r1\n\
+_0810E970:\n\
+ ldrb r0, [r4]\n\
+ movs r1, 0xF\n\
+ ands r1, r0\n\
+ movs r0, 0x30\n\
+_0810E978:\n\
+ orrs r1, r0\n\
+ strb r1, [r4]\n\
+_0810E97C:\n\
+ ldrb r1, [r4]\n\
+ lsls r1, 30\n\
+ lsrs r1, 31\n\
+ adds r0, r4, 0\n\
+ adds r0, 0xC\n\
+ adds r0, r1\n\
+ ldrb r1, [r0]\n\
+ ldr r3, =gSineTable\n\
+ mov r2, r12\n\
+ lsls r0, r2, 1\n\
+ adds r0, r3\n\
+ movs r2, 0\n\
+ ldrsh r0, [r0, r2]\n\
+ muls r0, r1\n\
+ asrs r0, 8\n\
+ strh r0, [r5, 0x24]\n\
+ ldrb r2, [r5, 0x3]\n\
+ lsls r2, 26\n\
+ lsrs r2, 27\n\
+ movs r1, 0x24\n\
+ ldrsh r0, [r5, r1]\n\
+ negs r0, r0\n\
+ asrs r0, 1\n\
+ ldrb r1, [r4, 0xA]\n\
+ adds r0, r1\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ lsls r1, r0, 1\n\
+ adds r1, r3\n\
+ ldrh r6, [r1]\n\
+ ldr r1, =gOamMatrices\n\
+ lsls r2, 3\n\
+ adds r2, r1\n\
+ adds r0, 0x40\n\
+ lsls r0, 1\n\
+ adds r0, r3\n\
+ ldrh r0, [r0]\n\
+ strh r0, [r2, 0x6]\n\
+ strh r0, [r2]\n\
+ strh r6, [r2, 0x2]\n\
+ lsls r0, r6, 16\n\
+ asrs r0, 16\n\
+ negs r0, r0\n\
+ strh r0, [r2, 0x4]\n\
+ ldrh r0, [r4, 0x6]\n\
+ ldrh r2, [r4, 0x8]\n\
+ adds r0, r2\n\
+ strh r0, [r4, 0x8]\n\
+ lsls r0, 16\n\
+ lsrs r0, 24\n\
+ strh r0, [r5, 0x22]\n\
+ movs r1, 0x4\n\
+ ldrsh r0, [r4, r1]\n\
+ movs r1, 0x80\n\
+ lsls r1, 8\n\
+ ands r0, r1\n\
+ cmp r0, 0\n\
+ beq _0810EA0C\n\
+ ldrh r0, [r4, 0x4]\n\
+ subs r1, 0x1\n\
+ ands r1, r0\n\
+ ldrh r0, [r4, 0x2]\n\
+ subs r0, r1\n\
+ movs r1, 0xFF\n\
+ ands r0, r1\n\
+ strh r0, [r4, 0x2]\n\
+ b _0810EA1C\n\
+ .pool\n\
+_0810EA0C:\n\
+ ldrh r0, [r4, 0x4]\n\
+ ldr r1, =0x00007fff\n\
+ ands r1, r0\n\
+ ldrh r2, [r4, 0x2]\n\
+ adds r1, r2\n\
+ movs r0, 0xFF\n\
+ ands r1, r0\n\
+ strh r1, [r4, 0x2]\n\
+_0810EA1C:\n\
+ movs r0, 0x22\n\
+ ldrsh r1, [r5, r0]\n\
+ movs r2, 0x26\n\
+ ldrsh r0, [r5, r2]\n\
+ adds r1, r0\n\
+ ldrh r0, [r4, 0xE]\n\
+ lsrs r0, 1\n\
+ cmp r1, r0\n\
+ blt _0810EA36\n\
+ movs r0, 0\n\
+ strh r0, [r5, 0x2E]\n\
+ ldr r0, =sub_810E2C8\n\
+ str r0, [r5, 0x1C]\n\
+_0810EA36:\n\
+ pop {r3,r4}\n\
+ mov r8, r3\n\
+ mov r9, r4\n\
+ pop {r4-r7}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .pool\n\
+ ");
+}
+#endif
+
+void sub_810EA4C(struct Sprite *sprite)
+{
+ sprite->oam.priority = GetBattlerSpriteBGPriority(gBattleAnimTarget);
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
+ sprite->callback = TranslateAnimSpriteToTargetMonLocation;
+}
+
+void sub_810EAA0(struct Sprite * sprite)
+{
+ u16 arg;
+ u8 mult;
+
+ if (!gBattleAnimArgs[2])
+ InitSpritePosToAnimAttacker(sprite, 0);
+ else
+ InitSpritePosToAnimTarget(sprite, FALSE);
+
+ if ((!gBattleAnimArgs[2] && !GetBattlerSide(gBattleAnimAttacker))
+ || (gBattleAnimArgs[2] == 1 && !GetBattlerSide(gBattleAnimTarget)))
+ {
+ sprite->pos1.x += 8;
+ }
+
+ SeekSpriteAnim(sprite, gBattleAnimArgs[4]);
+ sprite->pos1.x -= 32;
+ sprite->data[1] = 0x0ccc;
+
+ arg = gBattleAnimArgs[4];
+ mult = 12;
+ sprite->pos2.x += mult * arg;
+ sprite->data[0] = arg;
+ sprite->data[7] = gBattleAnimArgs[3];
+ sprite->callback = sub_810EB40;
+}
+
+void sub_810EB40(struct Sprite *sprite)
+{
+ sprite->pos2.x += sprite->data[1] >> 8;
+
+ if (++sprite->data[0] == 6)
+ {
+ sprite->data[0] = 0;
+ sprite->pos2.x = 0;
+ StartSpriteAnim(sprite, 0);
+ }
+
+ if (--sprite->data[7] == -1)
+ DestroyAnimSprite(sprite);
+}
+
+void sub_810EB88(u8 task)
+{
+ if (!(gTasks[task].data[0] % 32))
+ {
+ gAnimVisualTaskCount++;
+
+ gBattleAnimArgs[0] = Sin(gTasks[task].data[0], -13);
+ gBattleAnimArgs[1] = Cos(gTasks[task].data[0], -13);
+ gBattleAnimArgs[2] = 1;
+ gBattleAnimArgs[3] = 3;
+
+ CreateSpriteAndAnimate(&gUnknown_085973E8,
+ GetBattlerSpriteCoord(gBattleAnimTarget, 2),
+ GetBattlerSpriteCoord(gBattleAnimTarget, 3),
+ 3);
+ }
+
+ gTasks[task].data[0] += 8;
+
+ if (gTasks[task].data[0] > 255)
+ DestroyAnimVisualTask(task);
+}
+
+void sub_810EC34(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ InitSpritePosToAnimAttacker(sprite, 1);
+ gSprites[GetAnimBattlerSpriteId(0)].invisible = 1;
+ ++sprite->data[0];
+ break;
+ case 1:
+ if (sprite->affineAnimEnded)
+ DestroyAnimSprite(sprite);
+ break;
+ }
+}
+
+void sub_810EC94(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1);
+ sprite->pos2.y = -sprite->pos1.y - 32;
+ sprite->data[0]++;
+ break;
+ case 1:
+ sprite->pos2.y += 10;
+ if (sprite->pos2.y >= 0)
+ ++sprite->data[0];
+ break;
+ case 2:
+ sprite->pos2.y -= 10;
+ if (sprite->pos1.y + sprite->pos2.y < -32)
+ {
+ gSprites[GetAnimBattlerSpriteId(0)].invisible = 0;
+ DestroyAnimSprite(sprite);
+ }
+ break;
+ }
+}
+
+void sub_810ED28(struct Sprite *sprite)
+{
+ InitSpritePosToAnimAttacker(sprite, 1);
+ sprite->data[0] = gBattleAnimArgs[2];
+ sprite->data[1] = gBattleAnimArgs[3];
+ sprite->callback = sub_810ED70;
+ gSprites[GetAnimBattlerSpriteId(0)].invisible = 1;
+}
+
+void sub_810ED70(struct Sprite *sprite)
+{
+ if (sprite->data[0] > 0)
+ {
+ sprite->data[0]--;
+ }
+ else if (sprite->pos1.y + sprite->pos2.y > -32)
+ {
+ sprite->data[2] += sprite->data[1];
+ sprite->pos2.y -= (sprite->data[2] >> 8);
+ }
+ else
+ {
+ sprite->invisible = 1;
+ if (sprite->data[3]++ > 20)
+ sprite->callback = sub_810EDD0;
+ }
+}
+
+void sub_810EDD0(struct Sprite *sprite)
+{
+ sprite->pos2.y += sprite->data[2] >> 8;
+
+ if (sprite->pos1.y + sprite->pos2.y > -32)
+ sprite->invisible = 0;
+
+ if (sprite->pos2.y > 0)
+ DestroyAnimSprite(sprite);
+}
+
+void sub_810EE14(struct Sprite *sprite)
+{
+ u32 matrixNum;
+ int t1, t2;
+
+ switch (sprite->data[0])
+ {
+ case 0:
+ if (!gBattleAnimArgs[0])
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1);
+ }
+ else
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1);
+ }
+
+ sprite->data[1] = 512;
+
+ TrySetSpriteRotScale(sprite, 0, 256, sprite->data[1], 0);
+ sprite->data[0]++;
+ break;
+ case 1:
+ if (sprite->data[2] <= 11)
+ sprite->data[1] -= 40;
+ else
+ sprite->data[1] += 40;
+
+ sprite->data[2]++;
+
+ TrySetSpriteRotScale(sprite, 0, 256, sprite->data[1], 0);
+
+ matrixNum = sprite->oam.matrixNum;
+
+ t1 = 15616;
+ t2 = t1 / gOamMatrices[matrixNum].d + 1;
+
+ if (t2 > 128)
+ t2 = 128;
+
+ t2 = (64 - t2) / 2;
+ sprite->pos2.y = t2;
+
+ if (sprite->data[2] == 24)
+ {
+ sub_80A749C(sprite);
+ DestroyAnimSprite(sprite);
+ }
+ break;
+ }
+}
+
+void sub_810EEF8(struct Sprite *sprite)
+{
+ int v1 = 0x1ff & Random2();
+ int v2 = 0x7f & Random2();
+
+ if (v1 % 2)
+ sprite->data[0] = 736 + v1;
+ else
+ sprite->data[0] = 736 - v1;
+
+ if (v2 % 2)
+ sprite->data[1] = 896 + v2;
+ else
+ sprite->data[1] = 896 - v2;
+
+ sprite->data[2] = gBattleAnimArgs[0];
+
+ if (sprite->data[2])
+ sprite->oam.matrixNum = 8;
+
+ if (gBattleAnimArgs[1] == 0)
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1) + 32;
+ }
+ else
+ {
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimTarget, 0);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimTarget, 1) + 32;
+ }
+
+ sprite->callback = sub_810EFA8;
+}
+
+void sub_810EFA8(struct Sprite *sprite)
+{
+ if (sprite->data[2] == 0)
+ {
+ sprite->pos2.x += sprite->data[0] >> 8;
+ sprite->pos2.y -= sprite->data[1] >> 8;
+ }
+ else
+ {
+ sprite->pos2.x -= sprite->data[0] >> 8;
+ sprite->pos2.y -= sprite->data[1] >> 8;
+ }
+
+ sprite->data[0] = sprite->data[0];
+ sprite->data[1] -= 32;
+
+ if (sprite->data[0] < 0)
+ sprite->data[0] = 0;
+
+ if (++sprite->data[3] == 31)
+ DestroyAnimSprite(sprite);
+}
+
+void sub_810F004(struct Sprite *sprite)
+{
+ sprite->data[6] = 0;
+ sprite->data[7] = 64;
+ sprite->callback = sub_810F018;
+}
+
+void sub_810F018(struct Sprite *sprite)
+{
+ switch (sprite->data[0])
+ {
+ case 0:
+ if (++sprite->data[1] > 8)
+ {
+ sprite->data[1] = 0;
+ sprite->invisible ^= 1;
+ if (++sprite->data[2] > 5 && sprite->invisible)
+ sprite->data[0]++;
+ }
+ break;
+ case 1:
+ DestroyAnimSprite(sprite);
+ break;
+ }
+}
+
+void sub_810F084(struct Sprite *sprite)
+{
+ u16 rotation;
+ s16 posx = sprite->pos1.x;
+ s16 posy = sprite->pos1.y;
+
+ sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
+ sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
+
+ sprite->data[4] = sprite->pos1.x << 4;
+ sprite->data[5] = sprite->pos1.y << 4;
+
+ sprite->data[6] = ((posx - sprite->pos1.x) << 4) / 12;
+ sprite->data[7] = ((posy - sprite->pos1.y) << 4) / 12;
+
+ rotation = ArcTan2Neg(posx - sprite->pos1.x, posy - sprite->pos1.y);
+ rotation += 49152;
+
+ TrySetSpriteRotScale(sprite, 1, 0x100, 0x100, rotation);
+
+ sprite->callback = sub_810F140;
+}
+
+void sub_810F140(struct Sprite *sprite)
+{
+ sprite->data[4] += sprite->data[6];
+ sprite->data[5] += sprite->data[7];
+
+ sprite->pos1.x = sprite->data[4] >> 4;
+ sprite->pos1.y = sprite->data[5] >> 4;
+
+ if (sprite->pos1.x > 285 || sprite->pos1.x < -45
+ || sprite->pos1.y > 157 || sprite->pos1.y < -45)
+ DestroySpriteAndMatrix(sprite);
+}
+
+void unref_sub_810F184(u8 taskId)
+{
+ if (gBattleAnimArgs[0] == 0)
+ {
+ u8 spriteId = GetAnimBattlerSpriteId(0);
+ gSprites[spriteId].invisible = 1;
+ }
+ else
+ {
+ u8 spriteId = GetAnimBattlerSpriteId(0);
+ gSprites[spriteId].invisible = 0;
+ }
+ DestroyAnimVisualTask(taskId);
+}
diff --git a/src/frontier_pass.c b/src/frontier_pass.c
index 0db546c4d..fff93c3c7 100644
--- a/src/frontier_pass.c
+++ b/src/frontier_pass.c
@@ -1090,7 +1090,7 @@ static void ShowAndPrintWindows(void)
for (i = 0; i < WINDOW_COUNT; i++)
{
PutWindowTilemap(i);
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
x = GetStringCenterAlignXOffset(1, gText_SymbolsEarned, 96);
@@ -1116,7 +1116,7 @@ static void ShowAndPrintWindows(void)
static void PrintAreaDescription(u8 cursorArea)
{
- FillWindowPixelBuffer(WINDOW_DESCRIPTION, 0);
+ FillWindowPixelBuffer(WINDOW_DESCRIPTION, PIXEL_FILL(0));
if (cursorArea == CURSOR_AREA_RECORD && !sPassData->hasBattleRecord)
AddTextPrinterParameterized3(WINDOW_DESCRIPTION, 1, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[0]);
else if (cursorArea != CURSOR_AREA_NOTHING)
@@ -1656,7 +1656,7 @@ static void PrintOnFrontierMap(void)
for (i = 0; i < MAP_WINDOW_COUNT; i++)
{
PutWindowTilemap(i);
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
for (i = 0; i < NUM_FRONTIER_FACILITIES; i++)
@@ -1698,7 +1698,7 @@ static void HandleFrontierMapCursorMove(u8 direction)
StartSpriteAnim(sMapData->mapIndicatorSprite, sMapLandmarks[sMapData->cursorPos].animNum);
sMapData->mapIndicatorSprite->pos1.x = sMapLandmarks[sMapData->cursorPos].x;
sMapData->mapIndicatorSprite->pos1.y = sMapLandmarks[sMapData->cursorPos].y;
- FillWindowPixelBuffer(MAP_WINDOW_DESCRIPTION, 0);
+ FillWindowPixelBuffer(MAP_WINDOW_DESCRIPTION, PIXEL_FILL(0));
AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, 1, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description);
for (i = 0; i < 3; i++)
diff --git a/src/frontier_util.c b/src/frontier_util.c
index 6fcbd4ffb..bce7b926f 100644
--- a/src/frontier_util.c
+++ b/src/frontier_util.c
@@ -35,8 +35,7 @@
#include "constants/moves.h"
#include "constants/items.h"
#include "constants/event_objects.h"
-
-extern u8 gSelectedOrderFromParty[];
+#include "party_menu.h"
struct FrontierBrainMon
{
@@ -48,8 +47,6 @@ struct FrontierBrainMon
u16 moves[4];
};
-extern void sub_81B8558(void);
-
// This file's functions.
static void sub_81A17A0(void);
static void sub_81A1830(void);
@@ -1044,8 +1041,8 @@ static void TowerPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x
static void ShowTowerResultsWindow(u8 battleMode)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
if (battleMode == FRONTIER_MODE_SINGLES)
StringExpandPlaceholders(gStringVar4, gText_SingleBattleRoomResults);
else if (battleMode == FRONTIER_MODE_DOUBLES)
@@ -1115,8 +1112,8 @@ static void DomePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2
static void ShowDomeResultsWindow(u8 battleMode)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
if (battleMode == FRONTIER_MODE_SINGLES)
StringExpandPlaceholders(gStringVar4, gText_SingleBattleTourneyResults);
else
@@ -1191,8 +1188,8 @@ static void PalacePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8
static void ShowPalaceResultsWindow(u8 battleMode)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
if (battleMode == FRONTIER_MODE_SINGLES)
StringExpandPlaceholders(gStringVar4, gText_SingleBattleHallResults);
else
@@ -1247,8 +1244,8 @@ static void PikePrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y)
static void ShowPikeResultsWindow(void)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
StringExpandPlaceholders(gStringVar4, gText_BattleChoiceResults);
PrintAligned(gStringVar4, 0);
AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 33, TEXT_SPEED_FF, NULL);
@@ -1309,8 +1306,8 @@ static void ArenaPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y)
static void ShowArenaResultsWindow(void)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
PrintHyphens(10);
StringExpandPlaceholders(gStringVar4, gText_SetKOTourneyResults);
PrintAligned(gStringVar4, 2);
@@ -1395,8 +1392,8 @@ static void FactoryPrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8
static void ShowFactoryResultsWindow(u8 battleMode)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
if (battleMode == FRONTIER_MODE_SINGLES)
StringExpandPlaceholders(gStringVar4, gText_BattleSwapSingleResults);
else
@@ -1460,8 +1457,8 @@ static void PyramidPrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y)
static void ShowPyramidResultsWindow(void)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C74);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
StringExpandPlaceholders(gStringVar4, gText_BattleQuestResults);
PrintAligned(gStringVar4, 2);
AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 49, TEXT_SPEED_FF, NULL);
@@ -1483,8 +1480,8 @@ static void ShowLinkContestResultsWindow(void)
s32 x;
gRecordsWindowId = AddWindow(&gUnknown_08611C7C);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
StringExpandPlaceholders(gStringVar4, gText_LinkContestResults);
x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
@@ -2353,8 +2350,8 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode)
void ShowRankingHallRecordsWindow(void)
{
gRecordsWindowId = AddWindow(&gUnknown_08611C84);
- NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ DrawStdWindowFrame(gRecordsWindowId, FALSE);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_50);
PutWindowTilemap(gRecordsWindowId);
CopyWindowToVram(gRecordsWindowId, 3);
@@ -2362,7 +2359,7 @@ void ShowRankingHallRecordsWindow(void)
void ScrollRankingHallRecordsWindow(void)
{
- FillWindowPixelBuffer(gRecordsWindowId, 0x11);
+ FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1));
PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_OPEN);
CopyWindowToVram(gRecordsWindowId, 2);
}
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 3f217b782..2c31dba01 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -66,8 +66,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
#define HALL_OF_FAME_MAX_TEAMS 50
-extern void ReturnFromHallOfFamePC(void);
-
// this file's functions
static void ClearVramOamPltt_LoadHofPal(void);
static void sub_8174F70(void);
@@ -490,7 +488,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
}
*lastSavedTeam = *sHofMonPtr;
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3);
CopyWindowToVram(0, 3);
gTasks[taskId].func = Task_Hof_TrySaveData;
@@ -570,7 +568,7 @@ static void Task_Hof_DisplayMon(u8 taskId)
gSprites[spriteId].tSpecies = currMon->species;
gSprites[spriteId].callback = SpriteCB_GetOnScreenAndAnimate;
gTasks[taskId].tMonSpriteId(currMonId) = spriteId;
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
gTasks[taskId].func = Task_Hof_PrintMonInfoAfterAnimating;
}
@@ -649,7 +647,7 @@ static void sub_8173DC0(u8 taskId)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1;
}
BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24));
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
CopyWindowToVram(0, 3);
gTasks[taskId].tFrameCount = 7;
gTasks[taskId].func = sub_8173EA4;
@@ -697,7 +695,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId)
{
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
HallOfFame_PrintPlayerInfo(1, 2);
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3);
CopyWindowToVram(0, 3);
gTasks[taskId].func = Task_Hof_ExitOnKeyPressed;
@@ -1066,7 +1064,7 @@ static void Task_HofPC_HandleExit(u8 taskId)
static void Task_HofPC_PrintDataIsCorrupted(u8 taskId)
{
sub_8198180(gText_UnkCtrlF800Exit, 8, TRUE);
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized2(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3);
CopyWindowToVram(0, 3);
gTasks[taskId].func = Task_HofPC_ExitOnButtonPress;
@@ -1086,7 +1084,7 @@ static void Task_HofPC_ExitOnButtonPress(u8 taskId)
static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2)
{
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
AddTextPrinterParameterized3(0, 1, GetStringCenterAlignXOffset(1, gText_WelcomeToHOF, 0xD0), 1, sUnknown_085E5388, 0, gText_WelcomeToHOF);
CopyWindowToVram(0, 3);
@@ -1099,7 +1097,7 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u
s32 dexNumber;
s32 width;
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
// dex number
@@ -1180,9 +1178,9 @@ static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2)
u32 width;
u16 trainerId;
- FillWindowPixelBuffer(1, 0x11);
+ FillWindowPixelBuffer(1, PIXEL_FILL(1));
PutWindowTilemap(1);
- SetWindowBorderStyle(1, FALSE, 0x21D, 0xD);
+ DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x21D, 0xD);
AddTextPrinterParameterized3(1, 1, 0, 1, sUnknown_085E538C, -1, gText_Name);
width = GetStringRightAlignXOffset(1, gSaveBlock2Ptr->playerName, 0x70);
diff --git a/src/hof_pc.c b/src/hof_pc.c
index 2cea5540a..d76f04372 100644
--- a/src/hof_pc.c
+++ b/src/hof_pc.c
@@ -7,10 +7,6 @@
#include "script_menu.h"
#include "task.h"
-extern void Overworld_PlaySpecialMapMusic(void);
-extern bool16 ScrSpecial_CreatePCMenu(void);
-extern void ScriptMenu_DisplayPCStartupPrompt(void);
-
static void ReshowPCMenuAfterHallOfFamePC(void);
static void Task_WaitForPaletteFade(u8);
diff --git a/src/ice.c b/src/ice.c
index 34ad572e8..fa1913b96 100644
--- a/src/ice.c
+++ b/src/ice.c
@@ -21,30 +21,29 @@ struct HailStruct {
};
static void sub_810B6C4(struct Sprite *);
-extern void sub_810B848(struct Sprite *);
-extern void AnimIcePunchSwirlingParticle(struct Sprite *);
-extern void AnimIceBeamParticle(struct Sprite *);
-extern void AnimIceEffectParticle(struct Sprite *);
-extern void AnimFlickerIceEffectParticle(struct Sprite *);
-extern void AnimSwirlingSnowball_Step1(struct Sprite *);
-extern void AnimSwirlingSnowball_Step2(struct Sprite *);
-extern void AnimSwirlingSnowball_Step3(struct Sprite *);
-extern void AnimSwirlingSnowball_End(struct Sprite *);
-extern void AnimMoveParticleBeyondTarget(struct Sprite *);
-extern void AnimWiggleParticleTowardsTarget(struct Sprite *);
-extern void AnimWaveFromCenterOfTarget(struct Sprite *);
-extern void InitSwirlingFogAnim(struct Sprite *);
-extern void AnimSwirlingFogAnim(struct Sprite *);
-extern void AnimThrowMistBall(struct Sprite *);
-extern void InitPoisonGasCloudAnim(struct Sprite *);
-extern void MovePoisonGasCloud(struct Sprite *);
-extern void AnimHailBegin(struct Sprite *);
-extern void AnimHailContinue(struct Sprite *);
-extern void sub_80A8EE4(struct Sprite *);
-extern void InitIceBallAnim(struct Sprite *);
-extern void AnimThrowIceBall(struct Sprite *);
-extern void InitIceBallParticle(struct Sprite *);
-extern void AnimIceBallParticle(struct Sprite *);
+void sub_810B848(struct Sprite *);
+void AnimIcePunchSwirlingParticle(struct Sprite *);
+void AnimIceBeamParticle(struct Sprite *);
+void AnimIceEffectParticle(struct Sprite *);
+void AnimFlickerIceEffectParticle(struct Sprite *);
+void AnimSwirlingSnowball_Step1(struct Sprite *);
+void AnimSwirlingSnowball_Step2(struct Sprite *);
+void AnimSwirlingSnowball_Step3(struct Sprite *);
+void AnimSwirlingSnowball_End(struct Sprite *);
+void AnimMoveParticleBeyondTarget(struct Sprite *);
+void AnimWiggleParticleTowardsTarget(struct Sprite *);
+void AnimWaveFromCenterOfTarget(struct Sprite *);
+void InitSwirlingFogAnim(struct Sprite *);
+void AnimSwirlingFogAnim(struct Sprite *);
+void AnimThrowMistBall(struct Sprite *);
+void InitPoisonGasCloudAnim(struct Sprite *);
+void MovePoisonGasCloud(struct Sprite *);
+void AnimHailBegin(struct Sprite *);
+void AnimHailContinue(struct Sprite *);
+void InitIceBallAnim(struct Sprite *);
+void AnimThrowIceBall(struct Sprite *);
+void InitIceBallParticle(struct Sprite *);
+void AnimIceBallParticle(struct Sprite *);
void AnimTask_Haze2(u8);
void AnimTask_OverlayFogTiles(u8);
void AnimTask_Hail2(u8);
diff --git a/src/item.c b/src/item.c
index 71c2dc0f7..0e13ddf4c 100644
--- a/src/item.c
+++ b/src/item.c
@@ -539,8 +539,8 @@ bool8 RemoveBagItem(u16 itemId, u16 count)
if (CurrentMapIsSecretBase() == TRUE)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x200);
- VarSet(VAR_0x40ED, itemId);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x200);
+ VarSet(VAR_SECRET_BASE_LAST_ITEM_USED, itemId);
}
var = GetItemListPosition(pocket);
diff --git a/src/item_menu.c b/src/item_menu.c
index 43f2afce3..5738757bd 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -8,6 +8,7 @@
#include "bg.h"
#include "constants/items.h"
#include "constants/songs.h"
+#include "data2.h"
#include "decompress.h"
#include "event_data.h"
#include "event_object_movement.h"
@@ -140,7 +141,6 @@ void unknown_ItemMenu_Confirm2(u8 taskId);
void unknown_item_menu_type(u8 taskId);
void item_menu_type_2(u8 taskId);
void display_sell_item_ask_str(u8 taskId);
-void unknown_ItemMenu_Confirm(u8 taskId);
void display_deposit_item_ask_str(u8 taskId);
void item_menu_type_b(u8 taskId);
void BagMenuActuallyToss(u8 taskId);
@@ -446,7 +446,6 @@ EWRAM_DATA u16 gSpecialVar_ItemId = 0;
static EWRAM_DATA struct TempWallyStruct *gUnknown_0203CE80 = 0;
extern u8 *const gPocketNamesStringsTable[];
-extern const u8 gMoveNames[][0xD];
extern u8* gReturnToXStringsTable[];
extern const u8 EventScript_2736B3[];
extern const u16 gUnknown_0860F074[];
@@ -476,7 +475,7 @@ void CB2_ChooseBerry(void)
GoToBagMenu(RETURN_LOCATION_FIELD_2, BERRIES_POCKET, CB2_ReturnToFieldContinueScript);
}
-void sub_81AABF0(void(*callback)(void))
+void sub_81AABF0(void (*callback)(void))
{
GoToBagMenu(RETURN_LOCATION_FIELD_3, BERRIES_POCKET, callback);
}
@@ -884,7 +883,7 @@ void bag_menu_print_description_box_text(int a)
StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1);
str = gStringVar4;
}
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, str, 3, 1, 0, 0, 0, 0);
}
@@ -896,7 +895,7 @@ void bag_menu_print_cursor_(u8 a, u8 b)
void bag_menu_print_cursor(u8 a, u8 b)
{
if (b == 0xFF)
- FillWindowPixelRect(0, 0, 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
+ FillWindowPixelRect(0, PIXEL_FILL(0), 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else
bag_menu_print(0, 1, gText_SelectorArrow2, 0, a, 0, 0, 0, b);
@@ -1028,7 +1027,7 @@ void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u
s16* data = gTasks[taskId].data;
data[10] = AddItemMessageWindow(4);
- FillWindowPixelBuffer(data[10], 17);
+ FillWindowPixelBuffer(data[10], PIXEL_FILL(1));
DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeedDelay(), str, callback);
schedule_bg_copy_tilemap_to_vram(1);
}
@@ -1293,7 +1292,7 @@ void bag_menu_swap_items(u8 taskId)
gUnknown_0203CE54->unk81A = data[1];
CopyItemName(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, data[1]), gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
sub_80D4FEC(data[1]);
sub_81AB89C();
@@ -1505,7 +1504,7 @@ void sub_81AC644(u8 unused)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
}
if (gUnknown_0203CE54->unk828 == 1)
@@ -1646,7 +1645,7 @@ void ItemMenu_UseOutOfBattle(u8 taskId)
bag_menu_print_there_is_no_pokemon(taskId);
else
{
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
schedule_bg_copy_tilemap_to_vram(0);
if (gUnknown_0203CE58.pocket != BERRIES_POCKET)
ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId);
@@ -1670,7 +1669,7 @@ void ItemMenu_Toss(u8 taskId)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
sub_81ABC3C(7);
gTasks[taskId].func = Task_ChooseHowManyToToss;
@@ -1684,7 +1683,7 @@ void BagMenuConfirmToss(u8 taskId)
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, data[8], 0, 3);
StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
bag_menu_yes_no(taskId, 5, &gUnknown_08614084);
}
@@ -1727,7 +1726,7 @@ void BagMenuActuallyToss(u8 taskId)
CopyItemName(gSpecialVar_ItemId, gStringVar1);
ConvertIntToDecimalStringN(gStringVar2, data[8], 0, 3);
StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
gTasks[taskId].func = Task_ActuallyToss;
}
@@ -2043,7 +2042,7 @@ void display_deposit_item_ask_str(u8 taskId)
{
CopyItemName(gSpecialVar_ItemId, gStringVar1);
StringExpandPlaceholders(gStringVar4, gText_DepositHowManyVar1);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0);
sub_81ABC3C(7);
gTasks[taskId].func = sub_81ADA7C;
@@ -2078,7 +2077,7 @@ void sub_81ADB14(u8 taskId)
{
s16* data = gTasks[taskId].data;
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
if (ItemId_GetImportance(gSpecialVar_ItemId))
{
bag_menu_print(1, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, 0);
@@ -2244,7 +2243,7 @@ void bag_menu_print_pocket_names(const u8 *pocketName1, const u8 *pocketName2)
window.width = 16;
window.height = 2;
windowId = AddWindow(&window);
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
offset = GetStringCenterAlignXOffset(1, pocketName1, 0x40);
bag_menu_print(windowId, 1, pocketName1, offset, 1, 0, 0, -1, 1);
if (pocketName2)
@@ -2283,7 +2282,7 @@ void setup_bag_menu_textboxes(void)
LoadPalette(&gUnknown_0860F074, 0xF0, 0x20);
for (i = 0; i < 3; i++)
{
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
PutWindowTilemap(i);
}
schedule_bg_copy_tilemap_to_vram(0);
@@ -2306,7 +2305,7 @@ u8 bag_menu_add_window(u8 a)
if (*ptr == 0xFF)
{
*ptr = AddWindow(&gUnknown_086141AC[a]);
- SetWindowBorderStyle(*ptr, 0, 1, 14);
+ DrawStdFrameWithCustomTileAndPalette(*ptr, 0, 1, 14);
schedule_bg_copy_tilemap_to_vram(1);
}
return *ptr;
@@ -2317,7 +2316,7 @@ void bag_menu_remove_window(u8 a)
u8 *ptr = &gUnknown_0203CE54->windowPointers[a];
if (*ptr != 0xFF)
{
- sub_8198070(*ptr, 0);
+ ClearStdWindowAndFrameToTransparent(*ptr, 0);
ClearWindowTilemap(*ptr);
RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1);
@@ -2338,7 +2337,8 @@ void bag_menu_RemoveBagItem_message_window(u8 a)
u8 *ptr = &gUnknown_0203CE54->windowPointers[a];
if (*ptr != 0xFF)
{
- sub_8197DF8(*ptr, 0);
+ ClearDialogWindowAndFrameToTransparent(*ptr, FALSE);
+ // This ClearWindowTilemap call is redundant, since ClearDialogWindowAndFrameToTransparent already calls it.
ClearWindowTilemap(*ptr);
RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1);
@@ -2366,7 +2366,7 @@ void bag_menu_remove_money_window(void)
void bag_menu_prepare_tmhm_move_window(void)
{
- FillWindowPixelBuffer(3, 0);
+ FillWindowPixelBuffer(3, PIXEL_FILL(0));
blit_move_info_icon(3, 19, 0, 0);
blit_move_info_icon(3, 20, 0, 12);
blit_move_info_icon(3, 21, 0, 24);
@@ -2380,7 +2380,7 @@ void PrintTMHMMoveData(u16 itemId)
u16 moveId;
const u8* text;
- FillWindowPixelBuffer(4, 0);
+ FillWindowPixelBuffer(4, PIXEL_FILL(0));
if (itemId == ITEM_NONE)
{
for (i = 0; i < 4; i++)
diff --git a/src/item_use.c b/src/item_use.c
index 97d6292c4..e646a18ee 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -8,13 +8,15 @@
#include "coins.h"
#include "data2.h"
#include "event_data.h"
-#include "fieldmap.h"
#include "event_object_movement.h"
+#include "fieldmap.h"
+#include "field_effect.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
#include "field_weather.h"
#include "item.h"
#include "item_menu.h"
+#include "item_use.h"
#include "mail.h"
#include "main.h"
#include "menu.h"
@@ -37,31 +39,15 @@
#include "constants/items.h"
#include "constants/songs.h"
#include "constants/vars.h"
+#include "event_obj_lock.h"
-extern void unknown_ItemMenu_Confirm(u8 taskId);
-extern void sub_81C5B14(u8 taskId);
-extern void ScriptUnfreezeEventObjects(void);
-extern void ItemUseOutOfBattle_TMHM(u8 a);
-extern void ItemUseOutOfBattle_EvolutionStone(u8 b);
-extern bool8 IsPlayerFacingSurfableFishableWater(void);
-extern bool8 sub_81221AC(void);
extern u8 Route102_EventScript_274482[];
extern u8 Route102_EventScript_2744C0[];
extern u8 BattleFrontier_OutsideEast_EventScript_242CFC[];
-extern int sub_80247BC(void);
-extern struct MapHeader* mapconnection_get_mapheader(struct MapConnection *connection);
-extern void SetUpItemUseCallback(u8 taskId);
-extern void ItemUseCB_Medicine(u8, TaskFunc);
-extern void bag_menu_yes_no(u8, u8, const struct YesNoFuncTable*);
-extern void sub_81C5924(void);
-extern void sub_81C59BC(void);
-extern void sub_81AB9A8(u8);
-extern void StartEscapeRopeFieldEffect(void);
-extern u8* sub_806CF78(u16);
-extern void sub_81B89F0(void);
-extern u8 GetItemEffectType(u16);
-extern struct MapConnection *sub_8088A8C(s16, s16);
+extern s32 sub_80247BC(void);
+
+void SetUpItemUseCallback(u8 taskId);
void MapPostLoadHook_UseItem(void);
void sub_80AF6D4(void);
void Task_CallItemUseOnFieldCallback(u8 taskId);
@@ -188,7 +174,7 @@ void DisplayCannotDismountBikeMessage(u8 taskId, bool8 isUsingRegisteredKeyItemO
void CleanUpAfterFailingToUseRegisteredKeyItemOnField(u8 taskId)
{
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
DestroyTask(taskId);
ScriptUnfreezeEventObjects();
ScriptContext2_Disable();
@@ -350,7 +336,7 @@ void sub_80FD504(u8 taskId)
void sub_80FD5CC(u8 taskId)
{
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
ScriptUnfreezeEventObjects();
ScriptContext2_Disable();
DestroyTask(taskId);
@@ -404,12 +390,12 @@ bool8 sub_80FD6D4(const struct MapEvents *events, s16 x, s16 y)
bool8 sub_80FD730(struct MapConnection *connection, int x, int y)
{
- struct MapHeader *mapHeader;
+
u16 localX, localY;
u32 localOffset;
s32 localLength;
- mapHeader = mapconnection_get_mapheader(connection);
+ struct MapHeader const *const mapHeader = mapconnection_get_mapheader(connection);
switch (connection->direction)
{
diff --git a/src/learn_move.c b/src/learn_move.c
index 7a6916013..879acff6d 100644
--- a/src/learn_move.c
+++ b/src/learn_move.c
@@ -498,7 +498,7 @@ static void LearnMoveMain(void)
case 27:
if (!sub_81D2C3C())
{
- FillWindowPixelBuffer(3, 0x11);
+ FillWindowPixelBuffer(3, PIXEL_FILL(1));
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
sLearnMoveStruct->state = 3;
@@ -631,7 +631,7 @@ static void HideSpritesAndPrintTeachText(bool8 a)
if (!a)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
- FillWindowPixelBuffer(3, 0x11);
+ FillWindowPixelBuffer(3, PIXEL_FILL(1));
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
@@ -695,7 +695,7 @@ static void ShowTeachMoveText(bool8 showContest)
if (showContest == FALSE)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
- FillWindowPixelBuffer(3, 0x11);
+ FillWindowPixelBuffer(3, PIXEL_FILL(1));
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
diff --git a/src/link.c b/src/link.c
index bec9dddc6..525d50d7c 100644
--- a/src/link.c
+++ b/src/link.c
@@ -28,7 +28,7 @@
#include "link.h"
#include "link_rfu.h"
-extern u16 gUnknown_03005DA8;
+extern u16 gHeldKeyCodeToSend;
// Static type declarations
@@ -302,9 +302,9 @@ void LinkTestScreen(void)
SetMainCallback2(CB2_LinkTest);
}
-void sub_8009628(u8 a0)
+void SetLocalLinkPlayerId(u8 playerId)
{
- gLocalLinkPlayer.id = a0;
+ gLocalLinkPlayer.id = playerId;
}
static void InitLocalLinkPlayer(void)
@@ -695,12 +695,12 @@ static void BuildSendCmd(u16 command)
gSendCmd[0] = LINKCMD_0x5566;
break;
case LINKCMD_SEND_HELD_KEYS_2:
- if (gUnknown_03005DA8 == 0 || gLinkTransferringData)
+ if (gHeldKeyCodeToSend == 0 || gLinkTransferringData)
{
break;
}
gSendCmd[0] = LINKCMD_SEND_HELD_KEYS_2;
- gSendCmd[1] = gUnknown_03005DA8;
+ gSendCmd[1] = gHeldKeyCodeToSend;
break;
}
}
@@ -714,11 +714,11 @@ void sub_8009F18(void)
gLinkCallback = sub_8009F70;
}
-bool32 sub_8009F3C(void)
+bool32 IsSendingKeysToLink(void)
{
if (gWirelessCommType)
{
- return sub_800F7E4();
+ return IsSendingKeysToRfu();
}
if (gLinkCallback == sub_8009F70)
{
@@ -1142,7 +1142,7 @@ void ResetBlockReceivedFlag(u8 who)
}
}
-void sub_800A620(void)
+void CheckShouldAdvanceLinkState(void)
{
if ((gLinkStatus & LINK_STAT_MASTER) && EXTRACT_PLAYER_COUNT(gLinkStatus) > 1)
{
@@ -1327,7 +1327,9 @@ void sub_800AA04(u8 a0)
}
}
-u8 sub_800AA48(void)
+// The number of players when trading began. This is frequently compared against the
+// current number of connected players to check if anyone dropped out.
+u8 GetSavedPlayerCount(void)
{
return gSavedLinkPlayerCount;
}
@@ -1683,8 +1685,8 @@ static void sub_800B080(void)
CopyToBgTilemapBuffer(1, gWirelessLinkDisplayTilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
LoadPalette(gWirelessLinkDisplayPal, 0, 0x20);
- FillWindowPixelBuffer(0, 0x00);
- FillWindowPixelBuffer(2, 0x00);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(0, 3, 2, 6, gUnknown_082ED224, 0, gText_CommErrorEllipsis);
AddTextPrinterParameterized3(2, 3, 2, 1, gUnknown_082ED224, 0, gText_MoveCloserToLinkPartner);
PutWindowTilemap(0);
@@ -1696,8 +1698,8 @@ static void sub_800B080(void)
static void sub_800B138(void)
{
LoadBgTiles(0, g2BlankTilesGfx, 0x20, 0);
- FillWindowPixelBuffer(1, 0x00);
- FillWindowPixelBuffer(2, 0x00);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(1, 3, 2, 0, gUnknown_082ED224, 0, gText_CommErrorCheckConnections);
PutWindowTilemap(1);
PutWindowTilemap(2);
@@ -1849,7 +1851,7 @@ bool8 HandleLinkConnection(void)
r5 = sub_8010F1C();
if (sub_808766C() == TRUE)
{
- if (r4 == TRUE || sub_800F0B8() || r5)
+ if (r4 == TRUE || IsRfuRecvQueueEmpty() || r5)
{
return TRUE;
}
@@ -1882,18 +1884,18 @@ void sub_800B4C0(void)
}
}
-u32 sub_800B4DC(void)
+u32 GetLinkRecvQueueLength(void)
{
if (gWirelessCommType != 0)
{
- return sub_80124D4();
+ return GetRfuRecvQueueLength();
}
return gLink.recvQueue.count;
}
-bool8 sub_800B504(void)
+bool32 sub_800B504(void)
{
- if (sub_800B4DC() > 2)
+ if (GetLinkRecvQueueLength() > 2)
{
return TRUE;
}
diff --git a/src/link_rfu.c b/src/link_rfu.c
index 4ad2a5169..d80ff2ae9 100644
--- a/src/link_rfu.c
+++ b/src/link_rfu.c
@@ -17,9 +17,9 @@
#include "text.h"
#include "constants/species.h"
#include "save.h"
+#include "rom_8011DC0.h"
-extern u16 gUnknown_03005DA8;
-extern void nullsub_89(u8 taskId);
+extern u16 gHeldKeyCodeToSend;
struct UnkRfuStruct_1 gUnknown_03004140;
struct UnkRfuStruct_2 gUnknown_03005000;
@@ -2991,7 +2991,7 @@ static void sub_800F048(void)
}
}
-bool32 sub_800F0B8(void)
+bool32 IsRfuRecvQueueEmpty(void)
{
s32 i;
s32 j;
@@ -3212,7 +3212,7 @@ bool32 sub_800F4F0(void)
for (i = 0; i < CMD_LENGTH - 1; i++)
gSendCmd[i] = 0;
}
- return sub_800F0B8();
+ return IsRfuRecvQueueEmpty();
}
void sub_800F638(u8 unused, u32 flags)
@@ -3272,10 +3272,12 @@ u8 sub_800F74C(const u8 *a0)
void rfu_func_080F97B8(void)
{
- if (gReceivedRemoteLinkPlayers && gUnknown_03005DA8 && gLinkTransferringData != 1)
+ if (gReceivedRemoteLinkPlayers
+ && gHeldKeyCodeToSend != LINK_KEY_CODE_NULL
+ && gLinkTransferringData != TRUE)
{
gUnknown_03000D78[0]++;
- gUnknown_03005DA8 |= (gUnknown_03000D78[0] << 8);
+ gHeldKeyCodeToSend |= (gUnknown_03000D78[0] << 8);
sub_800FD14(0xbe00);
}
}
@@ -3285,7 +3287,7 @@ struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void)
return &gUnknown_02022B14;
}
-bool32 sub_800F7E4(void)
+bool32 IsSendingKeysToRfu(void)
{
return gUnknown_03005000.unk_00 == rfu_func_080F97B8;
}
@@ -3509,7 +3511,7 @@ void sub_800FD14(u16 command)
gSendCmd[1 + i] = gUnknown_03005000.unk_f2[i];
break;
case 0xbe00:
- gSendCmd[1] = gUnknown_03005DA8;
+ gSendCmd[1] = gHeldKeyCodeToSend;
break;
case 0xee00:
break;
@@ -3799,10 +3801,10 @@ bool32 sub_8010454(u32 a0)
u8 sub_801048C(bool32 a0)
{
- if (a0 == 0)
+ if (a0 == FALSE)
return sub_800D550(0, 0);
sub_800D550(1, 0x258);
- return FALSE;
+ return 0;
}
void sub_80104B0(void)
@@ -5163,7 +5165,7 @@ u32 sub_80124C0(void)
return gUnknown_03005000.unk_9e8.unk_232;
}
-u32 sub_80124D4(void)
+u32 GetRfuRecvQueueLength(void)
{
return gUnknown_03005000.unk_124.unk_8c2;
}
diff --git a/src/list_menu.c b/src/list_menu.c
index 7a9547661..51d7dcb15 100644
--- a/src/list_menu.c
+++ b/src/list_menu.c
@@ -355,11 +355,11 @@ s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenu
switch (arg2)
{
case 0: // can never be reached, because of the if statement above
- sub_819746C(sMysteryGiftLinkMenu.windowId, FALSE);
+ ClearStdWindowAndFrame(sMysteryGiftLinkMenu.windowId, FALSE);
break;
case 2:
case 1:
- sub_819746C(sMysteryGiftLinkMenu.windowId, FALSE);
+ ClearStdWindowAndFrame(sMysteryGiftLinkMenu.windowId, FALSE);
break;
}
}
@@ -486,7 +486,7 @@ void RedrawListMenu(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
- FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
+ FillWindowPixelBuffer(list->template.windowId, PIXEL_FILL(list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
CopyWindowToVram(list->template.windowId, 2);
@@ -584,7 +584,7 @@ static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 sc
if (list->template.totalItems < list->template.maxShowed)
list->template.maxShowed = list->template.totalItems;
- FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
+ FillWindowPixelBuffer(list->template.windowId, PIXEL_FILL(list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, TRUE);
@@ -698,7 +698,7 @@ static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow)
u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0);
u8 height = GetMenuCursorDimensionByFont(list->template.fontId, 1);
FillWindowPixelRect(list->template.windowId,
- (list->template.fillValue << 4) | (list->template.fillValue),
+ PIXEL_FILL(list->template.fillValue),
list->template.cursor_X,
selectedRow * yMultiplier + list->template.upText_Y,
width,
@@ -795,7 +795,7 @@ static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown)
{
if (count >= list->template.maxShowed)
{
- FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
+ FillWindowPixelBuffer(list->template.windowId, PIXEL_FILL(list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
}
else
@@ -806,26 +806,26 @@ static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown)
{
u16 y, width, height;
- ScrollWindow(list->template.windowId, 1, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
+ ScrollWindow(list->template.windowId, 1, count * yMultiplier, PIXEL_FILL(list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, count);
y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y;
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
height = (GetWindowAttribute(list->template.windowId, WINDOW_HEIGHT) * 8) - y;
FillWindowPixelRect(list->template.windowId,
- (list->template.fillValue << 4) | (list->template.fillValue),
+ PIXEL_FILL(list->template.fillValue),
0, y, width, height);
}
else
{
u16 width;
- ScrollWindow(list->template.windowId, 0, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
+ ScrollWindow(list->template.windowId, 0, count * yMultiplier, PIXEL_FILL(list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset + (list->template.maxShowed - count), list->template.maxShowed - count, count);
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
FillWindowPixelRect(list->template.windowId,
- (list->template.fillValue << 4) | (list->template.fillValue),
+ PIXEL_FILL(list->template.fillValue),
0, 0, width, list->template.upText_Y);
}
}
diff --git a/src/load_save.c b/src/load_save.c
index 0d19c6dae..d6785254f 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -11,10 +11,10 @@
#include "trainer_hill.h"
#include "gba/flash_internal.h"
#include "decoration_inventory.h"
+#include "agb_flash.h"
static void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
-extern bool16 IdentifyFlash(void);
extern void ApplyNewEncryptionKeyToBerryPowder(u32 key);
#define SAVEBLOCK_MOVE_RANGE 128
@@ -99,7 +99,7 @@ void MoveSaveBlocks_ResetHeap(void)
hblankCB = gMain.hblankCallback;
gMain.vblankCallback = NULL;
gMain.hblankCallback = NULL;
- gUnknown_0203CF5C = NULL;
+ gTrainerHillVBlankCounter = NULL;
saveBlock2Copy = (struct SaveBlock2 *)(gHeap);
saveBlock1Copy = (struct SaveBlock1 *)(gHeap + sizeof(struct SaveBlock2));
diff --git a/src/lottery_corner.c b/src/lottery_corner.c
index bd7d17ef7..bb3bb7a5c 100644
--- a/src/lottery_corner.c
+++ b/src/lottery_corner.c
@@ -27,7 +27,7 @@ void ResetLotteryCorner(void)
u16 rand = Random();
SetLotteryNumber((Random() << 16) | rand);
- VarSet(VAR_POKELOT_PRIZE, 0);
+ VarSet(VAR_POKELOT_PRIZE_ITEM, 0);
}
void SetRandomLotteryNumber(u16 i)
diff --git a/src/mail.c b/src/mail.c
index aa4ba571f..9cca4492e 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -477,8 +477,8 @@ static void sub_8121B1C(void)
y = 0;
PutWindowTilemap(0);
PutWindowTilemap(1);
- FillWindowPixelBuffer(0, 0);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
for (i = 0; i < sMailRead->layout->numSubStructs; i ++)
{
if (sMailRead->strbuf[i][0] == EOS || sMailRead->strbuf[i][0] == CHAR_SPACE)
diff --git a/src/main.c b/src/main.c
index 61c5e3386..40381bb68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,9 +24,6 @@
#include "main.h"
#include "trainer_hill.h"
-extern void sub_800B9B8(void);
-extern u8 gUnknown_03002748;
-
static void VBlankIntr(void);
static void HBlankIntr(void);
static void VCountIntr(void);
@@ -163,7 +160,7 @@ static void UpdateLinkAndCallCallbacks(void)
static void InitMainCallbacks(void)
{
gMain.vblankCounter1 = 0;
- gUnknown_0203CF5C = NULL;
+ gTrainerHillVBlankCounter = NULL;
gMain.vblankCounter2 = 0;
gMain.callback1 = NULL;
SetMainCallback2(CB2_InitCopyrightScreenAfterBootup);
@@ -313,8 +310,6 @@ void SetSerialCallback(IntrCallback callback)
gMain.serialCallback = callback;
}
-extern void CopyBufferedValuesToGpuRegs(void);
-
static void VBlankIntr(void)
{
if (gWirelessCommType != 0)
@@ -324,8 +319,8 @@ static void VBlankIntr(void)
gMain.vblankCounter1++;
- if (gUnknown_0203CF5C && *gUnknown_0203CF5C < 0xFFFFFFFF)
- (*gUnknown_0203CF5C)++;
+ if (gTrainerHillVBlankCounter && *gTrainerHillVBlankCounter < 0xFFFFFFFF)
+ (*gTrainerHillVBlankCounter)++;
if (gMain.vblankCallback)
gMain.vblankCallback();
@@ -393,14 +388,14 @@ static void WaitForVBlank(void)
;
}
-void sub_80008DC(u32 *var)
+void SetTrainerHillVBlankCounter(u32 *counter)
{
- gUnknown_0203CF5C = var;
+ gTrainerHillVBlankCounter = counter;
}
-void sub_80008E8(void)
+void ClearTrainerHillVBlankCounter(void)
{
- gUnknown_0203CF5C = NULL;
+ gTrainerHillVBlankCounter = NULL;
}
void DoSoftReset(void)
diff --git a/src/main_menu.c b/src/main_menu.c
index 82a30aa59..e6e29d942 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -39,6 +39,135 @@
#include "title_screen.h"
#include "window.h"
+/*
+ * Main menu state machine
+ * -----------------------
+ *
+ * Entry point: CB2_InitMainMenu
+ *
+ * Note: States advance sequentially unless otherwise stated.
+ *
+ * CB2_InitMainMenu / CB2_ReinitMainMenu
+ * - Both of these states call InitMainMenu, which does all the work.
+ * - In the Reinit case, the init code will check if the user came from
+ * the options screen. If they did, then the options menu item is
+ * pre-selected.
+ *
+ * Task_MainMenuCheckSaveFile
+ * - Determines how many menu options to show based on whether
+ * the save file is Ok, empty, corrupted, etc.
+ * - If there was an error loading the save file, advance to
+ * Task_WaitForSaveFileErrorWindow.
+ * - If there were no errors, advance to Task_MainMenuCheckBattery.
+ * - Note that the check to enable Mystery Events would normally happen
+ * here, but this version of Emerald has them disabled.
+ *
+ * Task_WaitForSaveFileErrorWindow
+ * - Wait for the text to finish printing and then for the A button
+ * to be pressed.
+ *
+ * Task_MainMenuCheckBattery
+ * - If the battery is OK, advance to Task_DisplayMainMenu.
+ * - If the battery is dry, advance to Task_WaitForBatteryDryErrorWindow.
+ *
+ * Task_WaitForBatteryDryErrorWindow
+ * - Wait for the text to finish printing and then for the A button
+ * to be pressed.
+ *
+ * Task_DisplayMainWindow
+ * - Display the buttons to the user. If the menu is in HAS_MYSTERY_EVENTS
+ * mode, there are too many buttons for one screen and a scrollbar is added,
+ * and the scrollbar task is spawned (Task_ScrollIndicatorArrowPairOnMainMenu).
+ *
+ * Task_HighlightSelectedMainMenuItem
+ * - Update the UI to match the currently selected item.
+ *
+ * Task_HandleMainMenuInput
+ * - If A is pressed, advance to Task_HandleMainMenuAPressed.
+ * - If B is pressed, return to the title screen via CB2_InitTitleScreen.
+ * - If Up or Down is pressed, handle scrolling if there is a scroll bar, change
+ * the selection, then go back to Task_HighlightSelectedMainMenuItem.
+ *
+ * Task_HandleMainMenuAPressed
+ * - If the user selected New Game, advance to Task_NewGameBirchSpeech_Init.
+ * - If the user selected Continue, advance to CB2_ContinueSavedGame.
+ * - If the user selected the Options menu, advance to CB2_InitOptionMenu.
+ * - If the user selected Mystery Gift, advance to CB2_MysteryGift. However,
+ * if the wireless adapter was removed, instead advance to
+ * Task_DisplayMainMenuInvalidActionError.
+ * - Code to start a Mystery Event is present here, but is unreachable in this
+ * version.
+ *
+ * Task_HandleMainMenuBPressed
+ * - Clean up the main menu and go back to CB2_InitTitleScreen.
+ *
+ * Task_DisplayMainMenuInvalidActionError
+ * - Print one of three different error messages, wait for the text to stop
+ * printing, and then wait for A or B to be pressed.
+ * - Then advance to Task_HandleMainMenuBPressed.
+ *
+ * Task_NewGameBirchSpeechInit
+ * - Load the sprites for the intro speech, start playing music
+ * Task_NewGameBirchSpeech_WaitToShowBirch
+ * - Spawn Task_NewGameBirchSpeech_FadeInTarget1OutTarget2
+ * - Spawn Task_NewGameBirchSpeech_FadePlatformOut
+ * - Both of these tasks destroy themselves when done.
+ * Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome
+ * Task_NewGameBirchSpeech_ThisIsAPokemon
+ * - When the text is done printing, spawns Task_NewGameBirchSpeechSub_InitPokeball
+ * Task_NewGameBirchSpeech_MainSpeech
+ * Task_NewGameBirchSpeech_AndYouAre
+ * Task_NewGameBirchSpeech_StartBirchLotadPlatformFade
+ * Task_NewGameBirchSpeech_StartBirchLotadPlatformFade
+ * Task_NewGameBirchSpeech_SlidePlatformAway
+ * Task_NewGameBirchSpeech_StartPlayerFadeIn
+ * Task_NewGameBirchSpeech_WaitForPlayerFadeIn
+ * Task_NewGameBirchSpeech_BoyOrGirl
+ * Task_NewGameBirchSpeech_WaitToShowGenderMenu
+ * Task_NewGameBirchSpeech_ChooseGender
+ * - Animates by advancing to Task_NewGameBirchSpeech_SlideOutOldGenderSprite
+ * whenever the player's selection changes.
+ * - Advances to Task_NewGameBirchSpeech_WhatsYourName when done.
+ *
+ * Task_NewGameBirchSpeech_SlideOutOldGenderSprite
+ * Task_NewGameBirchSpeech_SlideInNewGenderSprite
+ * - Returns back to Task_NewGameBirchSpeech_ChooseGender.
+ *
+ * Task_NewGameBirchSpeech_WhatsYourName
+ * Task_NewGameBirchSpeech_WaitForWhatsYourNameToPrint
+ * Task_NewGameBirchSpeech_WaitPressBeforeNameChoice
+ * Task_NewGameBirchSpeech_StartNamingScreen
+ * C2_NamingScreen
+ * - Returns to CB2_NewGameBirchSpeech_ReturnFromNamingScreen when done
+ * CB2_NewGameBirchSpeech_ReturnFromNamingScreen
+ * Task_NewGameBirchSpeech_ReturnFromNamingScreenShowTextbox
+ * Task_NewGameBirchSpeech_SoItsPlayerName
+ * Task_NewGameBirchSpeech_CreateNameYesNo
+ * Task_NewGameBirchSpeech_ProcessNameYesNoMenu
+ * - If confirmed, advance to Task_NewGameBirchSpeech_SlidePlatformAway2.
+ * - Otherwise, return to Task_NewGameBirchSpeech_BoyOrGirl.
+ *
+ * Task_NewGameBirchSpeech_SlidePlatformAway2
+ * Task_NewGameBirchSpeech_ReshowBirchLotad
+ * Task_NewGameBirchSpeech_WaitForSpriteFadeInAndTextPrinter
+ * Task_NewGameBirchSpeech_AreYouReady
+ * Task_NewGameBirchSpeech_ShrinkPlayer
+ * Task_NewGameBirchSpeech_WaitForPlayerShrink
+ * Task_NewGameBirchSpeech_FadePlayerToWhite
+ * Task_NewGameBirchSpeech_Cleanup
+ * - Advances to CB2_NewGame.
+ *
+ * Task_NewGameBirchSpeechSub_InitPokeball
+ * - Advances to Task_NewGameBirchSpeechSub_WaitForLotad
+ * Task_NewGameBirchSpeechSub_WaitForLotad
+ * - Destroys itself when done.
+ */
+
+// These two defines are used with the sCurrItemAndOptionsMenuCheck,
+// to distinguish between its two parts.
+#define OPTION_MENU_FLAG 0x8000
+#define CURRENT_ITEM_MASK 0x7FFF
+
// Static type declarations
// Static RAM declarations
@@ -112,7 +241,7 @@ static void SpriteCB_MovePlayerDownWhileShrinking(struct Sprite*);
static void Task_NewGameBirchSpeech_WaitForPlayerShrink(u8);
static void Task_NewGameBirchSpeech_FadePlayerToWhite(u8);
static void Task_NewGameBirchSpeech_Cleanup(u8);
-static void nullsub_11();
+static void SpriteCB_Null();
static void Task_NewGameBirchSpeech_ReturnFromNamingScreenShowTextbox(u8);
static void MainMenu_FormatSavegamePlayer(void);
static void MainMenu_FormatSavegamePokedex(void);
@@ -247,7 +376,7 @@ static const struct WindowTemplate sWindowTemplates_MainMenu[] =
DUMMY_WIN_TEMPLATE
};
-static const struct WindowTemplate gUnknown_082FF080[] =
+static const struct WindowTemplate gNewGameBirchSpeechTextWindows[] =
{
{
.bg = 0,
@@ -542,7 +671,7 @@ static void Task_MainMenuCheckSaveFile(u8 taskId)
gTasks[taskId].func = Task_WaitForSaveFileErrorWindow;
break;
}
- if (sCurrItemAndOptionMenuCheck & 0x8000) // are we returning from the options menu?
+ if (sCurrItemAndOptionMenuCheck & OPTION_MENU_FLAG) // are we returning from the options menu?
{
switch (tMenuType) // if so, highlight the OPTIONS item
{
@@ -558,7 +687,7 @@ static void Task_MainMenuCheckSaveFile(u8 taskId)
break;
}
}
- sCurrItemAndOptionMenuCheck &= 0x7FFF; // turn off the "returning from options menu" flag
+ sCurrItemAndOptionMenuCheck &= CURRENT_ITEM_MASK; // turn off the "returning from options menu" flag
tCurrItem = sCurrItemAndOptionMenuCheck;
tItemCount = tMenuType + 2;
}
@@ -637,6 +766,8 @@ static void Task_DisplayMainMenu(u8 taskId)
palette = RGB(26, 26, 25);
LoadPalette(&palette, 252, 2);
+ // Note: If there is no save file, the save block is zeroed out,
+ // so the default gender is MALE.
if (gSaveBlock2Ptr->playerGender == MALE)
{
palette = RGB(4, 16, 31);
@@ -652,8 +783,8 @@ static void Task_DisplayMainMenu(u8 taskId)
{
case HAS_NO_SAVED_GAME:
default:
- FillWindowPixelBuffer(0, 0xAA);
- FillWindowPixelBuffer(1, 0xAA);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(1, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(0, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame);
AddTextPrinterParameterized3(1, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption);
PutWindowTilemap(0);
@@ -664,9 +795,9 @@ static void Task_DisplayMainMenu(u8 taskId)
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[1], MAIN_MENU_BORDER_TILE);
break;
case HAS_SAVED_GAME:
- FillWindowPixelBuffer(2, 0xAA);
- FillWindowPixelBuffer(3, 0xAA);
- FillWindowPixelBuffer(4, 0xAA);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption);
@@ -682,10 +813,10 @@ static void Task_DisplayMainMenu(u8 taskId)
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE);
break;
case HAS_MYSTERY_GIFT:
- FillWindowPixelBuffer(2, 0xAA);
- FillWindowPixelBuffer(3, 0xAA);
- FillWindowPixelBuffer(4, 0xAA);
- FillWindowPixelBuffer(5, 0xAA);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(5, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuMysteryGift);
@@ -705,11 +836,11 @@ static void Task_DisplayMainMenu(u8 taskId)
DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[5], MAIN_MENU_BORDER_TILE);
break;
case HAS_MYSTERY_EVENTS:
- FillWindowPixelBuffer(2, 0xAA);
- FillWindowPixelBuffer(3, 0xAA);
- FillWindowPixelBuffer(4, 0xAA);
- FillWindowPixelBuffer(5, 0xAA);
- FillWindowPixelBuffer(6, 0xAA);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(3, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(4, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(5, PIXEL_FILL(0xA));
+ FillWindowPixelBuffer(6, PIXEL_FILL(0xA));
AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue);
AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame);
AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuMysteryGift2);
@@ -813,14 +944,14 @@ static void Task_HandleMainMenuAPressed(u8 taskId)
{
if (gTasks[taskId].tMenuType == HAS_MYSTERY_EVENTS)
RemoveScrollIndicatorArrowPair(gTasks[taskId].tScrollArrowTaskId);
- sub_819746C(0, 1);
- sub_819746C(1, 1);
- sub_819746C(2, 1);
- sub_819746C(3, 1);
- sub_819746C(4, 1);
- sub_819746C(5, 1);
- sub_819746C(6, 1);
- sub_819746C(7, 1);
+ ClearStdWindowAndFrame(0, TRUE);
+ ClearStdWindowAndFrame(1, TRUE);
+ ClearStdWindowAndFrame(2, TRUE);
+ ClearStdWindowAndFrame(3, TRUE);
+ ClearStdWindowAndFrame(4, TRUE);
+ ClearStdWindowAndFrame(5, TRUE);
+ ClearStdWindowAndFrame(6, TRUE);
+ ClearStdWindowAndFrame(7, TRUE);
wirelessAdapterConnected = IsWirelessAdapterConnected();
switch (gTasks[taskId].tMenuType)
{
@@ -973,7 +1104,7 @@ static void Task_HandleMainMenuAPressed(u8 taskId)
if (action != ACTION_OPTION)
sCurrItemAndOptionMenuCheck = 0;
else
- sCurrItemAndOptionMenuCheck |= 0x8000; // entering the options menu
+ sCurrItemAndOptionMenuCheck |= OPTION_MENU_FLAG; // entering the options menu
}
}
@@ -981,7 +1112,7 @@ static void Task_HandleMainMenuBPressed(u8 taskId)
{
if (!gPaletteFade.active)
{
- if (gTasks[taskId].tMenuType == 3)
+ if (gTasks[taskId].tMenuType == HAS_MYSTERY_EVENTS)
RemoveScrollIndicatorArrowPair(gTasks[taskId].tScrollArrowTaskId);
sCurrItemAndOptionMenuCheck = 0;
FreeAllWindowBuffers();
@@ -1199,7 +1330,7 @@ static void Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome(u8 taskId)
}
else
{
- InitWindows(gUnknown_082FF080);
+ InitWindows(gNewGameBirchSpeechTextWindows);
LoadMainMenuWindowFrameTiles(0, 0xF3);
LoadMessageBoxGfx(0, 0xFC, 0xF0);
NewGameBirchSpeech_ShowDialogueWindow(0, 1);
@@ -1642,7 +1773,7 @@ static void Task_NewGameBirchSpeech_FadePlayerToWhite(u8 taskId)
if (!gPaletteFade.active)
{
spriteId = gTasks[taskId].tPlayerSpriteId;
- gSprites[spriteId].callback = nullsub_11;
+ gSprites[spriteId].callback = SpriteCB_Null;
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
BeginNormalPaletteFade(0xFFFF0000, 0, 0, 16, RGB_WHITEALPHA);
gTasks[taskId].func = Task_NewGameBirchSpeech_Cleanup;
@@ -1730,14 +1861,14 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void)
REG_IME = savedIme;
SetVBlankCallback(VBlankCB_MainMenu);
SetMainCallback2(CB2_MainMenu);
- InitWindows(gUnknown_082FF080);
+ InitWindows(gNewGameBirchSpeechTextWindows);
LoadMainMenuWindowFrameTiles(0, 0xF3);
LoadMessageBoxGfx(0, 0xFC, 0xF0);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
}
-static void nullsub_11(struct Sprite *sprite)
+static void SpriteCB_Null(struct Sprite *sprite)
{
}
@@ -1763,22 +1894,22 @@ static void AddBirchSpeechObjects(u8 taskId)
u8 maySpriteId;
birchSpriteId = AddNewGameBirchObject(0x88, 0x3C, 1);
- gSprites[birchSpriteId].callback = nullsub_11;
+ gSprites[birchSpriteId].callback = SpriteCB_Null;
gSprites[birchSpriteId].oam.priority = 0;
gSprites[birchSpriteId].invisible = TRUE;
gTasks[taskId].tBirchSpriteId = birchSpriteId;
lotadSpriteId = NewGameBirchSpeech_CreateLotadSprite(100, 0x4B);
- gSprites[lotadSpriteId].callback = nullsub_11;
+ gSprites[lotadSpriteId].callback = SpriteCB_Null;
gSprites[lotadSpriteId].oam.priority = 0;
gSprites[lotadSpriteId].invisible = TRUE;
gTasks[taskId].tLotadSpriteId = lotadSpriteId;
brendanSpriteId = CreateTrainerSprite(FacilityClassToPicIndex(FACILITY_CLASS_BRENDAN), 120, 60, 0, &gDecompressionBuffer[0]);
- gSprites[brendanSpriteId].callback = nullsub_11;
+ gSprites[brendanSpriteId].callback = SpriteCB_Null;
gSprites[brendanSpriteId].invisible = TRUE;
gSprites[brendanSpriteId].oam.priority = 0;
gTasks[taskId].tBrendanSpriteId = brendanSpriteId;
maySpriteId = CreateTrainerSprite(FacilityClassToPicIndex(FACILITY_CLASS_MAY), 120, 60, 0, &gDecompressionBuffer[0x800]);
- gSprites[maySpriteId].callback = nullsub_11;
+ gSprites[maySpriteId].callback = SpriteCB_Null;
gSprites[maySpriteId].invisible = TRUE;
gSprites[maySpriteId].oam.priority = 0;
gTasks[taskId].tMaySpriteId = maySpriteId;
@@ -1966,8 +2097,8 @@ static void NewGameBirchSpeech_StartFadePlatformOut(u8 taskId, u8 delay)
static void NewGameBirchSpeech_ShowGenderMenu(void)
{
- DrawMainMenuWindowBorder(&gUnknown_082FF080[1], 0xF3);
- FillWindowPixelBuffer(1, 17);
+ DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3);
+ FillWindowPixelBuffer(1, PIXEL_FILL(1));
PrintMenuTable(1, 2, sMenuActions_Gender);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0);
PutWindowTilemap(1);
@@ -1995,7 +2126,7 @@ static void NewGameBirchSpeech_SetDefaultPlayerName(u8 nameId)
static void CreateMainMenuErrorWindow(const u8* str)
{
- FillWindowPixelBuffer(7, 17);
+ FillWindowPixelBuffer(7, PIXEL_FILL(1));
AddTextPrinterParameterized(7, 1, str, 0, 1, 2, 0);
PutWindowTilemap(7);
CopyWindowToVram(7, 2);
@@ -2105,12 +2236,12 @@ static void NewGameBirchSpeech_ClearGenderWindowTilemap(u8 a, u8 b, u8 c, u8 d,
FillBgTilemapBufferRect(a, 0, b + 0xFF, c + 0xFF, d + 2, e + 2, 2);
}
-static void NewGameBirchSpeech_ClearGenderWindow(u8 windowId, u8 a)
+static void NewGameBirchSpeech_ClearGenderWindow(u8 windowId, bool8 copyToVram)
{
CallWindowFunction(windowId, NewGameBirchSpeech_ClearGenderWindowTilemap);
- FillWindowPixelBuffer(windowId, 0x11);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
ClearWindowTilemap(windowId);
- if (a == 1)
+ if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
@@ -2146,7 +2277,7 @@ void CreateYesNoMenuParameterized(u8 a, u8 b, u16 c, u16 d, u8 e, u8 f)
static void NewGameBirchSpeech_ShowDialogueWindow(u8 windowId, u8 copyToVram)
{
CallWindowFunction(windowId, NewGameBirchSpeech_CreateDialogueWindowBorder);
- FillWindowPixelBuffer(windowId, 17);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
diff --git a/src/map_name_popup.c b/src/map_name_popup.c
index cdb4c3330..8936198ae 100644
--- a/src/map_name_popup.c
+++ b/src/map_name_popup.c
@@ -276,7 +276,7 @@ static void Task_MapNamePopUpWindow(u8 taskId)
}
break;
case 4:
- sub_819746C(GetMapNamePopUpWindowId(), TRUE);
+ ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE);
task->data[0] = 5;
break;
case 5:
@@ -290,7 +290,7 @@ void HideMapNamePopUpWindow(void)
{
if (FuncIsActiveTask(Task_MapNamePopUpWindow))
{
- sub_819746C(GetMapNamePopUpWindowId(), TRUE);
+ ClearStdWindowAndFrame(GetMapNamePopUpWindowId(), TRUE);
RemoveMapNamePopUpWindow();
SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0);
DestroyTask(sPopupTaskId);
diff --git a/src/match_call.c b/src/match_call.c
index e7e91969f..641079ba9 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -111,8 +111,6 @@ static void PopulateSpeciesFromTrainerParty(int, u8 *);
static void PopulateBattleFrontierFacilityName(int, u8 *);
static void PopulateBattleFrontierStreak(int, u8 *);
-extern void sub_81973A4(void);
-
#define TEXT_ID(topic, id) (((topic) << 8) | ((id) & 0xFF))
static const struct MatchCallTrainerTextInfo sMatchCallTrainers[] =
@@ -1016,7 +1014,7 @@ static bool32 MapAllowsMatchCall(void)
if (gMapHeader.regionMapSectionId == MAPSEC_SOOTOPOLIS_CITY
&& FlagGet(FLAG_HIDE_SOOTOPOLIS_CITY_RAYQUAZA) == TRUE
- && FlagGet(FLAG_UNUSED_0x0DC) == FALSE)
+ && FlagGet(FLAG_NEVER_SET_0x0DC) == FALSE)
return FALSE;
if (gMapHeader.regionMapSectionId == MAPSEC_MT_CHIMNEY
@@ -1191,7 +1189,7 @@ static bool32 LoadMatchCallWindowGfx(u8 taskId)
return FALSE;
}
- FillWindowPixelBuffer(taskData[2], 0x88);
+ FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8));
LoadPalette(sUnknown_0860EA4C, 0xE0, 0x20);
LoadPalette(sPokeNavIconPalette, 0xF0, 0x20);
ChangeBgY(0, -0x2000, 0);
@@ -1241,7 +1239,7 @@ static bool32 sub_81962D8(u8 taskId)
s16 *taskData = gTasks[taskId].data;
if (!ExecuteMatchCallTextPrinter(taskData[2]))
{
- FillWindowPixelBuffer(taskData[2], 0x88);
+ FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8));
if (!gMatchCallState.triggeredFromScript)
SelectMatchCallMessage(gMatchCallState.trainerId, gStringVar4);
@@ -1257,7 +1255,7 @@ static bool32 sub_8196330(u8 taskId)
s16 *taskData = gTasks[taskId].data;
if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- FillWindowPixelBuffer(taskData[2], 0x88);
+ FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8));
CopyWindowToVram(taskData[2], 2);
PlaySE(SE_TOREOFF);
return TRUE;
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index fd8e74c0a..ec5cb238b 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -437,7 +437,7 @@ static void BardSong_TextSubPrinter(struct TextPrinterTemplate * printer, u16 a1
static void sub_8120708(const u8 * src)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, src, 0, 1, 1, BardSong_TextSubPrinter);
gUnknown_03002F84 = TRUE;
CopyWindowToVram(0, 3);
diff --git a/src/menu.c b/src/menu.c
index ae589dff4..b04572b81 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -122,20 +122,18 @@ const struct MoveMenuInfoIcon gMoveMenuInfoIcons[] =
{ 8, 8, 0xAF }, // Unused (Small dark pokeball)
};
+
// Forward declarations
-extern void sub_81973A4(void);
-extern void DrawStandardFrame(u8, u8, u8, u8, u8, u8);
-extern void DrawDialogueFrame(u8, u8, u8, u8, u8, u8);
-extern void sub_81977BC(u8, u8, u8, u8, u8, u8);
-extern void sub_8197804(u8, u8, u8, u8, u8, u8);
-extern void sub_8197BB4(u8, u8, u8, u8, u8, u8);
-extern void sub_8197E30(u8, u8, u8, u8, u8, u8);
-extern void DrawWindowBorder(u8, u8, u8, u8, u8, u8);
-extern void sub_81980A8(u8, u8, u8, u8, u8, u8);
-extern u8 Menu_MoveCursor(s8);
-extern u8 sub_8199134(s8, s8);
-extern void sub_8198C78(void);
-extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
+void WindowFunc_DrawStandardFrame(u8, u8, u8, u8, u8, u8);
+void WindowFunc_DrawDialogueFrame(u8, u8, u8, u8, u8, u8);
+void WindowFunc_ClearStdWindowAndFrame(u8, u8, u8, u8, u8, u8);
+void WindowFunc_ClearDialogWindowAndFrame(u8, u8, u8, u8, u8, u8);
+void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8);
+void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8, u8, u8, u8, u8, u8);
+void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8);
+void WindowFunc_ClearStdWindowAndFrameToTransparent(u8, u8, u8, u8, u8, u8);
+void sub_8198C78(void);
+void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
void InitStandardTextBoxWindows(void)
{
@@ -210,43 +208,43 @@ void sub_81973A4(void)
LoadUserWindowBorderGfx(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10);
}
-void NewMenuHelpers_DrawDialogueFrame(u8 windowId, bool8 copyToVram)
+void DrawDialogueFrame(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, DrawDialogueFrame);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawDialogueFrame);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void NewMenuHelpers_DrawStdWindowFrame(u8 windowId, bool8 copyToVram)
+void DrawStdWindowFrame(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, DrawStandardFrame);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawStandardFrame);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_8197434(u8 windowId, bool8 copyToVram)
+void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, sub_8197804);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrame);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_819746C(u8 windowId, bool8 copyToVram)
+void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, sub_81977BC);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrame);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
int i;
@@ -313,7 +311,7 @@ void DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height
STD_WINDOW_PALETTE_NUM);
}
-void DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg,
DLG_WINDOW_BASE_TILE_NUM + 1,
@@ -408,25 +406,25 @@ void DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height
DLG_WINDOW_PALETTE_NUM);
}
-void sub_81977BC(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM);
}
-void sub_8197804(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM);
}
void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram)
{
- SetWindowBorderStyle(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM);
+ DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM);
}
void sub_819786C(u8 windowId, bool8 copyToVram)
{
LoadMessageBoxGfx(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
- sub_8197B1C(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF);
+ DrawDialogFrameWithCustomTileAndPalette(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF);
}
void sub_819789C(void)
@@ -458,12 +456,12 @@ void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback)
CopyWindowToVram(0, 3);
}
-void DisplayYesNoMenu(void)
+void DisplayYesNoMenuDefaultYes(void)
{
CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0);
}
-void sub_8197948(u8 initialCursorPos)
+void DisplayYesNoMenuWithDefault(u8 initialCursorPos)
{
CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos);
}
@@ -549,29 +547,30 @@ void sub_8197AE8(bool8 copyToVram)
CopyBgTilemapBufferToVram(0);
}
-void sub_8197B1C(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum)
+void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum)
{
sTileNum = tileNum;
sPaletteNum = paletteNum;
- CallWindowFunction(windowId, sub_8197BB4);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_8197B64(u8 windowId, bool8 copyToVram, u16 tileNum)
+// Never used.
+void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum)
{
sTileNum = tileNum;
sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
- CallWindowFunction(windowId, sub_8197BB4);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_8197BB4(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg,
sTileNum + 1,
@@ -666,43 +665,45 @@ void sub_8197BB4(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 p
sPaletteNum);
}
-void sub_8197DF8(u8 windowId, bool8 copyToVram)
+void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, sub_8197E30);
- FillWindowPixelBuffer(windowId, 0);
+ // The palette slot doesn't matter, since the tiles are transparent.
+ CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrameNullPalette);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_8197E30(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, 0);
}
-void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum)
+void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum)
{
sTileNum = baseTileNum;
sPaletteNum = paletteNum;
- CallWindowFunction(windowId, DrawWindowBorder);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_8197EC8(u8 windowId, bool8 copyToVram, u16 baseTileNum)
+// Never used.
+void DrawStdFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 baseTileNum)
{
sTileNum = baseTileNum;
sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
- CallWindowFunction(windowId, DrawWindowBorder);
- FillWindowPixelBuffer(windowId, 0x11);
+ CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void DrawWindowBorder(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg,
sTileNum + 0,
@@ -762,16 +763,16 @@ void DrawWindowBorder(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height,
sPaletteNum);
}
-void sub_8198070(u8 windowId, bool8 copyToVram)
+void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram)
{
- CallWindowFunction(windowId, sub_81980A8);
- FillWindowPixelBuffer(windowId, 0);
+ CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrameToTransparent);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
ClearWindowTilemap(windowId);
if (copyToVram == TRUE)
CopyWindowToVram(windowId, 3);
}
-void sub_81980A8(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
+void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
{
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0);
}
@@ -811,7 +812,7 @@ void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram)
if (sWindowId != 0xFF)
{
PutWindowTilemap(sWindowId);
- FillWindowPixelBuffer(sWindowId, 0xFF);
+ FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15));
width = GetStringWidth(0, string, 0);
AddTextPrinterParameterized3(sWindowId,
0,
@@ -845,7 +846,7 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo
color[2] = 2;
}
PutWindowTilemap(sWindowId);
- FillWindowPixelBuffer(sWindowId, 0xFF);
+ FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15));
if (string2 != NULL)
{
width = GetStringWidth(0, string2, 0);
@@ -873,7 +874,7 @@ void sub_81982F0(void)
{
if (sWindowId != 0xFF)
{
- FillWindowPixelBuffer(sWindowId, 0xFF);
+ FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15));
CopyWindowToVram(sWindowId, 3);
}
}
@@ -882,7 +883,7 @@ void sub_8198314(void)
{
if (sWindowId != 0xFF)
{
- FillWindowPixelBuffer(sWindowId, 0);
+ FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0));
ClearWindowTilemap(sWindowId);
CopyWindowToVram(sWindowId, 3);
RemoveWindow(sWindowId);
@@ -931,7 +932,7 @@ void RedrawMenuCursor(u8 oldPos, u8 newPos)
width = GetMenuCursorDimensionByFont(sMenu.fontId, 0);
height = GetMenuCursorDimensionByFont(sMenu.fontId, 1);
- FillWindowPixelRect(sMenu.windowId, 0x11, sMenu.left, sMenu.optionHeight * oldPos + sMenu.top, width, height);
+ FillWindowPixelRect(sMenu.windowId, PIXEL_FILL(1), sMenu.left, sMenu.optionHeight * oldPos + sMenu.top, width, height);
AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gText_SelectorArrow3, sMenu.left, sMenu.optionHeight * newPos + sMenu.top, 0, 0);
}
@@ -1175,7 +1176,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top
struct TextPrinterTemplate printer;
sYesNoWindowId = AddWindow(window);
- SetWindowBorderStyle(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
+ DrawStdFrameWithCustomTileAndPalette(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
printer.currentChar = gText_YesNo;
printer.windowId = sYesNoWindowId;
@@ -1211,7 +1212,7 @@ s8 Menu_ProcessInputNoWrapClearOnChoose(void)
void sub_8198C78(void)
{
- sub_8198070(sYesNoWindowId, TRUE);
+ ClearStdWindowAndFrameToTransparent(sYesNoWindowId, TRUE);
RemoveWindow(sYesNoWindowId);
}
@@ -1310,7 +1311,7 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos)
u8 xPos = (oldCursorPos % sMenu.horizontalCount) * sMenu.optionWidth + sMenu.left;
u8 yPos = (oldCursorPos / sMenu.horizontalCount) * sMenu.optionHeight + sMenu.top;
FillWindowPixelRect(sMenu.windowId,
- 0x11,
+ PIXEL_FILL(1),
xPos,
yPos,
cursorWidth,
@@ -1640,7 +1641,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa
struct TextPrinterTemplate printer;
sYesNoWindowId = AddWindow(window);
- SetWindowBorderStyle(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
+ DrawStdFrameWithCustomTileAndPalette(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
printer.currentChar = gText_YesNo;
printer.windowId = sYesNoWindowId;
diff --git a/src/menu_helpers.c b/src/menu_helpers.c
index e6547b300..3fb5ca40d 100644
--- a/src/menu_helpers.c
+++ b/src/menu_helpers.c
@@ -18,8 +18,6 @@
#include "constants/items.h"
#include "constants/maps.h"
-extern bool32 sub_800B504(void);
-
// this file's functions
static void Task_ContinueTaskAfterMessagePrints(u8 taskId);
static void Task_CallYesOrNoCallback(u8 taskId);
@@ -129,7 +127,7 @@ void SetVBlankHBlankCallbacksToNull(void)
void DisplayMessageAndContinueTask(u8 taskId, u8 windowId, u16 arg2, u8 arg3, u8 fontId, u8 textSpeed, const u8 *string, void *taskFunc)
{
gUnknown_0203A140 = windowId;
- sub_8197B1C(windowId, TRUE, arg2, arg3);
+ DrawDialogFrameWithCustomTileAndPalette(windowId, TRUE, arg2, arg3);
if (string != gStringVar4)
StringExpandPlaceholders(gStringVar4, string);
@@ -293,7 +291,7 @@ bool8 sub_8122148(u16 itemId)
bool8 itemid_80BF6D8_mail_related(u16 itemId)
{
- if (is_c1_link_related_active() != TRUE && InUnionRoom() != TRUE)
+ if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE)
return TRUE;
else if (ItemIsMail(itemId) != TRUE)
return TRUE;
@@ -303,7 +301,7 @@ bool8 itemid_80BF6D8_mail_related(u16 itemId)
bool8 sub_81221AC(void)
{
- if (is_c1_link_related_active() == TRUE || gReceivedRemoteLinkPlayers == 1)
+ if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1)
return TRUE;
else
return FALSE;
diff --git a/src/mirage_tower.c b/src/mirage_tower.c
index a8dd5d9de..4f5834db1 100644
--- a/src/mirage_tower.c
+++ b/src/mirage_tower.c
@@ -317,7 +317,7 @@ void SetMirageTowerVisibility(void)
u16 rand;
bool8 visible;
- if (VarGet(VAR_0x40CB))
+ if (VarGet(VAR_ROUTE_111_STATE))
{
FlagClear(FLAG_MIRAGE_TOWER_VISIBLE);
return;
diff --git a/src/money.c b/src/money.c
index faf830637..4ff8086ea 100644
--- a/src/money.c
+++ b/src/money.c
@@ -154,7 +154,7 @@ void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed)
void PrintMoneyAmountInMoneyBoxWithBorder(u8 windowId, u16 tileStart, u8 pallete, int amount)
{
- SetWindowBorderStyle(windowId, FALSE, tileStart, pallete);
+ DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, tileStart, pallete);
PrintMoneyAmountInMoneyBox(windowId, amount, 0);
}
@@ -169,7 +169,7 @@ void DrawMoneyBox(int amount, u8 x, u8 y)
SetWindowTemplateFields(&template, 0, x + 1, y + 1, 10, 2, 15, 8);
sMoneyBoxWindowId = AddWindow(&template);
- FillWindowPixelBuffer(sMoneyBoxWindowId, 0);
+ FillWindowPixelBuffer(sMoneyBoxWindowId, PIXEL_FILL(0));
PutWindowTilemap(sMoneyBoxWindowId);
CopyWindowToVram(sMoneyBoxWindowId, 1);
PrintMoneyAmountInMoneyBoxWithBorder(sMoneyBoxWindowId, 0x214, 14, amount);
@@ -179,7 +179,7 @@ void DrawMoneyBox(int amount, u8 x, u8 y)
void HideMoneyBox(void)
{
RemoveMoneyLabelObject();
- sub_8198070(sMoneyBoxWindowId, FALSE);
+ ClearStdWindowAndFrameToTransparent(sMoneyBoxWindowId, FALSE);
CopyWindowToVram(sMoneyBoxWindowId, 2);
RemoveWindow(sMoneyBoxWindowId);
}
diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c
index 0de4675d9..ad4a2e692 100644
--- a/src/mystery_event_menu.c
+++ b/src/mystery_event_menu.c
@@ -90,7 +90,7 @@ void CB2_InitMysteryEventMenu(void)
DeactivateAllTextPrinters();
for (i = 0; i < 2; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14);
LoadUserWindowBorderGfx(0, 1u, 0xD0u);
@@ -133,7 +133,7 @@ static void CB2_MysteryEventMenu(void)
switch (gMain.state)
{
case 0:
- SetWindowBorderStyle(0, 1, 1, 0xD);
+ DrawStdFrameWithCustomTileAndPalette(0, 1, 1, 0xD);
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
ShowBg(0);
@@ -179,8 +179,8 @@ static void CB2_MysteryEventMenu(void)
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- sub_800A620();
- SetWindowBorderStyle(1, 1, 1, 0xD);
+ CheckShouldAdvanceLinkState();
+ DrawStdFrameWithCustomTileAndPalette(1, 1, 1, 0xD);
PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0);
PutWindowTilemap(1);
CopyWindowToVram(1, 3);
@@ -313,6 +313,6 @@ static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 sp
textColor[1] = 2;
textColor[2] = 3;
- FillWindowPixelBuffer(windowId, (textColor[0]) | (textColor[0] << 4));
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(textColor[0]));
AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, textColor, speed, text);
}
diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c
index 4196bb34c..dba914b51 100644
--- a/src/mystery_event_script.c
+++ b/src/mystery_event_script.c
@@ -17,8 +17,6 @@
#include "mystery_event_msg.h"
#include "pokemon_storage_system.h"
-extern void sub_811EFC0(u8);
-
extern ScrCmdFunc gMysteryEventScriptCmdTable[];
extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[];
diff --git a/src/naming_screen.c b/src/naming_screen.c
index c310ceb9f..22bbb84d7 100644
--- a/src/naming_screen.c
+++ b/src/naming_screen.c
@@ -557,7 +557,7 @@ static void DisplaySentToPCMessage(void)
stringToDisplay++;
StringExpandPlaceholders(gStringVar4, gUnknown_0858BDB8[stringToDisplay]);
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
gTextFlags.canABSpeedUpPrint = TRUE;
AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3);
CopyWindowToVram(0, 3);
@@ -1474,7 +1474,7 @@ static void HandleDpadMovement(struct Task *task)
static void sub_80E4894(void)
{
- FillWindowPixelBuffer(gNamingScreenData->windows[3], 0x11);
+ FillWindowPixelBuffer(gNamingScreenData->windows[3], PIXEL_FILL(1));
AddTextPrinterParameterized(gNamingScreenData->windows[3], 1, gNamingScreenData->template->title, 8, 1, 0, 0);
PutWindowTilemap(gNamingScreenData->windows[3]);
}
@@ -1485,7 +1485,7 @@ static void sub_80E48E8(void)
StringCopy(buffer, gSpeciesNames[gNamingScreenData->monSpecies]);
StringAppendN(buffer, gNamingScreenData->template->title, 15);
- FillWindowPixelBuffer(gNamingScreenData->windows[3], 0x11);
+ FillWindowPixelBuffer(gNamingScreenData->windows[3], PIXEL_FILL(1));
AddTextPrinterParameterized(gNamingScreenData->windows[3], 1, buffer, 8, 1, 0, 0);
PutWindowTilemap(gNamingScreenData->windows[3]);
}
@@ -1672,7 +1672,7 @@ static void sub_80E4D10(void)
u8 maxChars = gNamingScreenData->template->maxChars;
u16 unk = gNamingScreenData->inputCharBaseXPos - 0x40;
- FillWindowPixelBuffer(gNamingScreenData->windows[2], 0x11);
+ FillWindowPixelBuffer(gNamingScreenData->windows[2], PIXEL_FILL(1));
for (i = 0; i < maxChars; i++)
{
@@ -1704,7 +1704,9 @@ static const struct TextColorThing sUnkColorStruct =
static const u8 sFillValues[3] =
{
- 0xEE, 0xDD, 0xFF
+ PIXEL_FILL(0xE),
+ PIXEL_FILL(0xD),
+ PIXEL_FILL(0xF)
};
static const u8 *const sUnkColors[3] =
@@ -1766,7 +1768,7 @@ static void sub_80E4EF0(void)
{
const u8 color[3] = { 15, 1, 2 };
- FillWindowPixelBuffer(gNamingScreenData->windows[4], 0xFF);
+ FillWindowPixelBuffer(gNamingScreenData->windows[4], PIXEL_FILL(15));
AddTextPrinterParameterized3(gNamingScreenData->windows[4], 0, 2, 1, color, 0, gText_MoveOkBack);
PutWindowTilemap(gNamingScreenData->windows[4]);
CopyWindowToVram(gNamingScreenData->windows[4], 3);
diff --git a/src/normal.c b/src/normal.c
index 87c8792f1..2b592e199 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -36,8 +36,6 @@ static void sub_81162F8(u8);
static void sub_81163D0(struct Sprite *);
static void sub_81165E4(struct Sprite *);
-extern void sub_810E2C8(struct Sprite *);
-
const union AnimCmd gUnknown_0859722C[] =
{
ANIMCMD_FRAME(0, 8),
diff --git a/src/option_menu.c b/src/option_menu.c
index 122ba8d8a..2fc0d6f3e 100644
--- a/src/option_menu.c
+++ b/src/option_menu.c
@@ -13,8 +13,7 @@
#include "text_window.h"
#include "international_string_util.h"
#include "strings.h"
-
-extern void SetPokemonCryStereo(u32 val);
+#include "gba/m4a_internal.h"
// Task data
enum
@@ -620,7 +619,7 @@ static void ButtonMode_DrawChoices(u8 selection)
static void DrawTextOption(void)
{
- FillWindowPixelBuffer(WIN_TEXT_OPTION, 0x11);
+ FillWindowPixelBuffer(WIN_TEXT_OPTION, PIXEL_FILL(1));
AddTextPrinterParameterized(WIN_TEXT_OPTION, 1, gText_Option, 8, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(WIN_TEXT_OPTION, 3);
}
@@ -629,7 +628,7 @@ static void DrawOptionMenuTexts(void)
{
u8 i;
- FillWindowPixelBuffer(WIN_OPTIONS, 0x11);
+ FillWindowPixelBuffer(WIN_OPTIONS, PIXEL_FILL(1));
for (i = 0; i < MENUITEM_COUNT; i++)
{
AddTextPrinterParameterized(WIN_OPTIONS, 1, sOptionMenuItemsNames[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL);
diff --git a/src/overworld.c b/src/overworld.c
index a10d1e17a..0ff8d5b7f 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -66,32 +66,47 @@
#include "constants/species.h"
#include "constants/weather.h"
+#define PLAYER_TRADING_STATE_IDLE 0x80
+#define PLAYER_TRADING_STATE_BUSY 0x81
+#define PLAYER_TRADING_STATE_UNK_2 0x82
+#define PLAYER_TRADING_STATE_EXITING_ROOM 0x83
+
+#define FACING_NONE 0
+#define FACING_UP 1
+#define FACING_DOWN 2
+#define FACING_LEFT 3
+#define FACING_RIGHT 4
+#define FACING_FORCED_UP 7
+#define FACING_FORCED_DOWN 8
+#define FACING_FORCED_LEFT 9
+#define FACING_FORCED_RIGHT 10
+
// event scripts
extern const u8 EventScript_WhiteOut[];
-extern const u8 EventScript_271862[];
-extern const u8 EventScript_277513[];
-extern const u8 EventScript_TradeRoom_TooBusyToNotice[];
-extern const u8 EventScript_TradeRoom_ReadTrainerCard1[];
-extern const u8 EventScript_TradeRoom_ReadTrainerCard2[];
-extern const u8 gUnknown_08277388[];
-extern const u8 gUnknown_082773A3[];
-extern const u8 gUnknown_082773BE[];
-extern const u8 gUnknown_082773D9[];
-extern const u8 gUnknown_0827741D[];
-extern const u8 gUnknown_08277432[];
-extern const u8 gUnknown_08277447[];
-extern const u8 gUnknown_0827745C[];
-extern const u8 gUnknown_08277374[];
-extern const u8 gUnknown_0827737E[];
-extern const u8 gUnknown_082773FF[];
-extern const u8 gUnknown_082773F5[];
-extern const u8 gUnknown_082774EF[];
-extern const u8 gUnknown_08277509[];
+extern const u8 EventScript_ResetMrBriney[];
+extern const u8 EventScript_DoLinkRoomExit[];
+extern const u8 gEventScript_TradeRoom_TooBusyToNotice[];
+extern const u8 gEventScript_TradeRoom_ReadTrainerCard_NoColor[];
+extern const u8 gEventScript_TradeRoom_ReadTrainerCard_Normal[];
+extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot0[];
+extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot1[];
+extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot2[];
+extern const u8 EventScript_DoubleBattleColosseum_PlayerSpot3[];
+extern const u8 EventScript_RecordCenter_Spot0[];
+extern const u8 EventScript_RecordCenter_Spot1[];
+extern const u8 EventScript_RecordCenter_Spot2[];
+extern const u8 EventScript_RecordCenter_Spot3[];
+extern const u8 EventScript_SingleBattleColosseum_PlayerSpot0[];
+extern const u8 EventScript_SingleBattleColosseum_PlayerSpot1[];
+extern const u8 EventScript_TradeCenter_Chair1[];
+extern const u8 EventScript_TradeCenter_Chair0[];
+extern const u8 EventScript_ConfirmLeaveTradeRoom[];
+extern const u8 EventScript_TerminateLink[];
extern const struct MapLayout *const gMapLayouts[];
extern const struct MapHeader *const *const gMapGroups[];
extern const int gMaxFlashLevel;
-extern const u16 gUnknown_82EC7C4[];
+extern const u16 gOverworldBackgroundLayerFlags[];
static void Overworld_ResetStateAfterWhiteOut(void);
static void c2_80567AC(void);
@@ -106,63 +121,63 @@ static bool32 load_map_stuff(u8 *state, u32);
static bool32 map_loading_iteration_2_link(u8 *state);
static void mli4_mapscripts_and_other(void);
static void InitOverworldGraphicsRegisters(void);
-static u8 sub_8087858(u8);
-static u16 sub_80871C0(u32 a1);
+static u8 GetSpriteForLinkedPlayer(u8);
+static u16 KeyInterCB_SendNothing(u32 a1);
static void sub_80867C8(void);
static void sub_80867D8(void);
static void sub_8086AE4(void);
static void sub_80869DC(void);
static void sub_8086B14(void);
-static void sub_8086AAC(void);
+static void SetCameraToTrackGuestPlayer(void);
static void sub_8086988(bool32 arg0);
static void sub_8086A80(void);
static void sub_8086A68(void);
static void sub_8086860(void);
-static void sub_8086AC8(void);
-static void sub_8086B9C(void);
-static void sub_8086C40(void);
-static void sub_8086C90(void);
-static void sub_8086FA0(u16);
-static void sub_8086F38(u16*, s32);
-static u8 npc_something3(u8 a1, u8 a2);
+static void SetCameraToTrackGuestPlayer_2(void);
+static void CreateLinkPlayerSprites(void);
+static void ClearAllPlayerKeys(void);
+static void ResetAllTradingStates(void);
+static void UpdateHeldKeyCode(u16);
+static void UpdateAllLinkPlayers(u16*, s32);
+static u8 FlipVerticalAndClearForced(u8 a1, u8 a2);
static u8 LinkPlayerDetectCollision(u8 selfEventObjId, u8 a2, s16 x, s16 y);
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion);
-static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y);
-static u8 sub_80878A0(u8 linkPlayerId);
-static u8 sub_80878C0(u8 linkPlayerId);
+static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y);
+static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId);
+static u8 GetLinkPlayerElevation(u8 linkPlayerId);
static s32 sub_80878E4(u8 linkPlayerId);
static u8 GetLinkPlayerIdAt(s16 x, s16 y);
-static void sub_808796C(u8 linkPlayerId, u8 a2);
+static void SetPlayerFacingDirection(u8 linkPlayerId, u8 a2);
static void ZeroEventObject(struct EventObject *eventObj);
static void SpawnLinkPlayerEventObject(u8 linkPlayerId, s16 x, s16 y, u8 a4);
static void InitLinkPlayerEventObjectPos(struct EventObject *eventObj, s16 x, s16 y);
static void sub_80877DC(u8 linkPlayerId, u8 a2);
static void sub_808780C(u8 linkPlayerId);
-static u8 sub_8087858(u8 linkPlayerId);
+static u8 GetSpriteForLinkedPlayer(u8 linkPlayerId);
static void sub_8087584(void);
-static u32 sub_8087690(void);
+static u32 GetLinkSendQueueLength(void);
static void ZeroLinkPlayerEventObject(struct LinkPlayerEventObject *linkPlayerEventObj);
-static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1);
-static u16 sub_8087480(const u8 *script);
+static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *a1);
+static u16 GetDirectionForEventScript(const u8 *script);
static void sub_8087510(void);
-static void sub_808751C(void);
+static void InitLinkRoomStartMenuScript(void);
static void sub_8087530(const u8 *script);
-static void sub_808754C(void);
-static void sub_8087568(const u8 *script);
-static void sub_80872D8(s32 linkPlayerId, s32 a2, struct UnkStruct_8054FF8 *a3);
-static bool32 sub_8087340(struct UnkStruct_8054FF8 *a1);
-static bool32 sub_8087358(struct UnkStruct_8054FF8 *a1);
-static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1);
-static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1);
-static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1);
-static u16 sub_808711C(u32);
-static u16 sub_8087140(u32);
-static void sub_808709C(u16 *a1);
-static u16 sub_80870B0(u32 a1);
-static u16 sub_80870F8(u32 a1);
-static u16 sub_8087068(u16 a1);
-static void c1_link_related(void);
-static void c1_link_related_func_set(u16 (*func)(u32));
+static void CreateConfirmLeaveTradeRoomPrompt(void);
+static void InitMenuBasedScript(const u8 *script);
+static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 a2, struct TradeRoomPlayer *a3);
+static bool32 sub_8087340(struct TradeRoomPlayer *a1);
+static bool32 sub_8087340_2(struct TradeRoomPlayer *a1);
+static u8 *TryGetTileEventScript(struct TradeRoomPlayer *a1);
+static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *a1);
+static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *a1);
+static u16 KeyInterCB_DeferToRecvQueue(u32);
+static u16 KeyInterCB_DeferToSendQueue(u32);
+static void ResetPlayerHeldKeys(u16 *a1);
+static u16 KeyInterCB_SelfIdle(u32 a1);
+static u16 KeyInterCB_DeferToEventScript(u32 a1);
+static u16 GetDirectionForDpadKey(u16 a1);
+static void CB1_UpdateLinkState(void);
+static void SetKeyInterceptCallback(u16 (*func)(u32));
static void SetFieldVBlankCallback(void);
static void FieldClearVBlankHBlankCallbacks(void);
static void sub_8085810(void);
@@ -171,21 +186,24 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
-IWRAM_DATA static void *sUnknown_03000E0C;
-IWRAM_DATA static u8 sUnknown_03000E10[4];
-IWRAM_DATA static u16 (*sUnknown_03000E14)(u32);
-IWRAM_DATA static u8 sUnknown_03000E18;
-IWRAM_DATA static u8 sUnknown_03000E19;
+IWRAM_DATA static void *sUnusedOverworldCallback;
+IWRAM_DATA static u8 sPlayerTradingStates[4];
+// This callback is called with a player's key code. It then returns an
+// adjusted key code, effectively intercepting the input before anything
+// can process it.
+IWRAM_DATA static u16 (*sPlayerKeyInterceptCallback)(u32);
+IWRAM_DATA static bool8 sUnknown_03000E18;
+IWRAM_DATA static u8 sRfuKeepAliveTimer;
IWRAM_DATA static u32 sUnusedVar;
// IWRAM common
u16 *gBGTilemapBuffers1;
u16 *gBGTilemapBuffers2;
u16 *gBGTilemapBuffers3;
-u16 gUnknown_03005DA8;
+u16 gHeldKeyCodeToSend;
void (*gFieldCallback)(void);
bool8 (*gFieldCallback2)(void);
-u8 gUnknown_03005DB4;
+u8 gLocalLinkPlayerId; // This is our player id in a multiplayer mode.
u8 gFieldLinkPlayerCount;
// EWRAM vars
@@ -319,43 +337,47 @@ static const struct ScanlineEffectParams sFlashEffectParams =
0,
};
-static u8 sub_80879D8(struct LinkPlayerEventObject *, struct EventObject *, u8);
-static u8 sub_80879F8(struct LinkPlayerEventObject *, struct EventObject *, u8);
-static u8 sub_80879FC(struct LinkPlayerEventObject *, struct EventObject *, u8);
+static u8 MovementEventModeCB_Normal(struct LinkPlayerEventObject *, struct EventObject *, u8);
+static u8 MovementEventModeCB_Ignored(struct LinkPlayerEventObject *, struct EventObject *, u8);
+static u8 MovementEventModeCB_Normal_2(struct LinkPlayerEventObject *, struct EventObject *, u8);
-static u8 (*const gUnknown_08339DC8[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
+static u8 (*const gLinkPlayerMovementModes[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
{
- sub_80879D8,
- sub_80879F8,
- sub_80879FC,
+ MovementEventModeCB_Normal, // MOVEMENT_MODE_FREE
+ MovementEventModeCB_Ignored, // MOVEMENT_MODE_FROZEN
+ MovementEventModeCB_Normal_2, // MOVEMENT_MODE_SCRIPTED
};
-static u8 sub_8087A1C(struct LinkPlayerEventObject *, struct EventObject *, u8);
-static u8 sub_8087A20(struct LinkPlayerEventObject *, struct EventObject *, u8);
-static u8 sub_8087A88(struct LinkPlayerEventObject *, struct EventObject *, u8);
-
-static u8 (*const gUnknown_08339DD4[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
-{
- sub_8087A1C,
- sub_8087A20,
- sub_8087A20,
- sub_8087A20,
- sub_8087A20,
- sub_8087A1C,
- sub_8087A1C,
- sub_8087A88,
- sub_8087A88,
- sub_8087A88,
- sub_8087A88,
+static u8 FacingHandler_DoNothing(struct LinkPlayerEventObject *, struct EventObject *, u8);
+static u8 FacingHandler_DpadMovement(struct LinkPlayerEventObject *, struct EventObject *, u8);
+static u8 FacingHandler_ForcedFacingChange(struct LinkPlayerEventObject *, struct EventObject *, u8);
+
+// These handlers return TRUE if the movement was scripted and successful, and FALSE otherwise.
+static bool8 (*const gLinkPlayerFacingHandlers[])(struct LinkPlayerEventObject *, struct EventObject *, u8) =
+{
+ FacingHandler_DoNothing,
+ FacingHandler_DpadMovement,
+ FacingHandler_DpadMovement,
+ FacingHandler_DpadMovement,
+ FacingHandler_DpadMovement,
+ FacingHandler_DoNothing,
+ FacingHandler_DoNothing,
+ FacingHandler_ForcedFacingChange,
+ FacingHandler_ForcedFacingChange,
+ FacingHandler_ForcedFacingChange,
+ FacingHandler_ForcedFacingChange,
};
-static void sub_8087AA0(struct LinkPlayerEventObject *, struct EventObject *);
-static void sub_8087AA8(struct LinkPlayerEventObject *, struct EventObject *);
+static void MovementStatusHandler_EnterFreeMode(struct LinkPlayerEventObject *, struct EventObject *);
+static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerEventObject *, struct EventObject *);
-static void (*const gUnknown_08339E00[])(struct LinkPlayerEventObject *, struct EventObject *) =
+// These handlers are run after an attempted movement.
+static void (*const gMovementStatusHandler[])(struct LinkPlayerEventObject *, struct EventObject *) =
{
- sub_8087AA0,
- sub_8087AA8,
+ // FALSE:
+ MovementStatusHandler_EnterFreeMode,
+ // TRUE:
+ MovementStatusHandler_TryAdvanceScript,
};
// code
@@ -387,7 +409,7 @@ void Overworld_ResetStateAfterTeleport(void)
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
- ScriptContext2_RunNewScript(EventScript_271862);
+ ScriptContext2_RunNewScript(EventScript_ResetMrBriney);
}
void Overworld_ResetStateAfterDigEscRope(void)
@@ -408,10 +430,12 @@ static void Overworld_ResetStateAfterWhiteOut(void)
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
- if (VarGet(VAR_0x4039) == 1)
+ // If you were defeated by Kyogre/Groudon and the step counter has
+ // maxed out, end the unusual weather.
+ if (VarGet(VAR_SHOULD_END_UNUSUAL_WEATHER) == 1)
{
- VarSet(VAR_0x4039, 0);
- VarSet(VAR_0x4037, 0);
+ VarSet(VAR_SHOULD_END_UNUSUAL_WEATHER, 0);
+ VarSet(VAR_UNUSUAL_WEATHER_LOCATION, UNUSUAL_WEATHER_NONE);
}
}
@@ -676,7 +700,7 @@ void UpdateEscapeWarp(s16 x, s16 y)
{
u8 currMapType = GetCurrentMapType();
u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
- if (is_map_type_1_2_3_5_or_6(currMapType) && is_map_type_1_2_3_5_or_6(destMapType) != TRUE)
+ if (IsMapTypeOutdoors(currMapType) && IsMapTypeOutdoors(destMapType) != TRUE)
SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x - 7, y - 6);
}
@@ -821,8 +845,8 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum)
static void mli0_load_map(u32 a1)
{
- bool8 v2;
- bool8 indoors;
+ bool8 isOutdoors;
+ bool8 isIndoors;
LoadCurrentMapData();
if (!(sUnknown_020322D8 & 1))
@@ -835,8 +859,8 @@ static void mli0_load_map(u32 a1)
LoadEventObjTemplatesFromHeader();
}
- v2 = is_map_type_1_2_3_5_or_6(gMapHeader.mapType);
- indoors = Overworld_MapTypeIsIndoors(gMapHeader.mapType);
+ isOutdoors = IsMapTypeOutdoors(gMapHeader.mapType);
+ isIndoors = IsMapTypeIndoors(gMapHeader.mapType);
sub_80EB218();
TrySetMapSaveWarpStatus();
@@ -848,7 +872,7 @@ static void mli0_load_map(u32 a1)
DoTimeBasedEvents();
SetSav1WeatherFromCurrMapHeader();
ChooseAmbientCrySpecies();
- if (v2)
+ if (isOutdoors)
FlagClear(FLAG_SYS_USE_FLASH);
SetDefaultFlashLevel();
Overworld_ClearSavedMusic();
@@ -862,7 +886,7 @@ static void mli0_load_map(u32 a1)
else
InitMap();
- if (a1 != 1 && indoors)
+ if (a1 != 1 && isIndoors)
{
UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height);
sub_80E9238(1);
@@ -923,7 +947,7 @@ static u8 GetAdjustedInitialTransitionFlags(struct InitialPlayerAvatarState *pla
static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStruct, u8 transitionFlags, u16 metatileBehavior, u8 mapType)
{
- if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_6)
+ if (FlagGet(FLAG_SYS_CRUISE_MODE) && mapType == MAP_TYPE_OCEAN_ROUTE)
return DIR_EAST;
else if (MetatileBehavior_IsDeepSouthWarp(metatileBehavior) == TRUE)
return DIR_NORTH;
@@ -1016,7 +1040,7 @@ static bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp)
case MAP_NUM(ROUTE128):
return TRUE;
default:
- if (VarGet(VAR_0x405E) < 4)
+ if (VarGet(VAR_RAYQUAZA_STATE) < 4)
return FALSE;
switch (warp->mapNum)
{
@@ -1032,7 +1056,7 @@ static bool16 ShouldLegendaryMusicPlayAtLocation(struct WarpData *warp)
static bool16 NoMusicInSotopolisWithLegendaries(struct WarpData *warp)
{
- if (VarGet(VAR_0x40CA) != 1)
+ if (VarGet(VAR_SKY_PILLAR_STATE) != 1)
return FALSE;
else if (warp->mapGroup != MAP_GROUP(SOOTOPOLIS_CITY))
return FALSE;
@@ -1057,9 +1081,9 @@ static bool16 IsInfiltratedWeatherInstitute(struct WarpData *warp)
static bool16 IsInflitratedSpaceCenter(struct WarpData *warp)
{
- if (VarGet(VAR_0x405D) == 0)
+ if (VarGet(VAR_MOSSDEEP_STATE) == 0)
return FALSE;
- else if (VarGet(VAR_0x405D) > 2)
+ else if (VarGet(VAR_MOSSDEEP_STATE) > 2)
return FALSE;
else if (warp->mapGroup != MAP_GROUP(MOSSDEEP_CITY_SPACE_CENTER_1F))
return FALSE;
@@ -1197,7 +1221,7 @@ void Overworld_ChangeMusicTo(u16 newMusic)
u8 GetMapMusicFadeoutSpeed(void)
{
const struct MapHeader *mapHeader = GetDestinationWarpMapHeader();
- if (Overworld_MapTypeIsIndoors(mapHeader->mapType) == TRUE)
+ if (IsMapTypeIndoors(mapHeader->mapType) == TRUE)
return 2;
else
return 4;
@@ -1210,7 +1234,7 @@ void TryFadeOutOldMapMusic(void)
if (FlagGet(FLAG_SPECIAL_FLAG_0x4001) != TRUE && warpMusic != GetCurrentMapMusic())
{
if (currentMusic == MUS_NAMINORI
- && VarGet(VAR_0x40CA) == 2
+ && VarGet(VAR_SKY_PILLAR_STATE) == 2
&& gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY)
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(SOOTOPOLIS_CITY)
&& sWarpDestination.mapGroup == MAP_GROUP(SOOTOPOLIS_CITY)
@@ -1328,13 +1352,13 @@ u8 GetLastUsedWarpMapType(void)
return GetMapTypeByWarpData(&gLastUsedWarp);
}
-bool8 is_map_type_1_2_3_5_or_6(u8 mapType)
+bool8 IsMapTypeOutdoors(u8 mapType)
{
if (mapType == MAP_TYPE_ROUTE
|| mapType == MAP_TYPE_TOWN
|| mapType == MAP_TYPE_UNDERWATER
|| mapType == MAP_TYPE_CITY
- || mapType == MAP_TYPE_6)
+ || mapType == MAP_TYPE_OCEAN_ROUTE)
return TRUE;
else
return FALSE;
@@ -1344,14 +1368,14 @@ bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType)
{
if (mapType == MAP_TYPE_ROUTE
|| mapType == MAP_TYPE_TOWN
- || mapType == MAP_TYPE_6
+ || mapType == MAP_TYPE_OCEAN_ROUTE
|| mapType == MAP_TYPE_CITY)
return TRUE;
else
return FALSE;
}
-bool8 Overworld_MapTypeIsIndoors(u8 mapType)
+bool8 IsMapTypeIndoors(u8 mapType)
{
if (mapType == MAP_TYPE_INDOOR
|| mapType == MAP_TYPE_SECRET_BASE)
@@ -1407,9 +1431,9 @@ static void ResetSafariZoneFlag_(void)
ResetSafariZoneFlag();
}
-bool32 is_c1_link_related_active(void)
+bool32 IsUpdateLinkStateCBActive(void)
{
- if (gMain.callback1 == c1_link_related)
+ if (gMain.callback1 == CB1_UpdateLinkState)
return TRUE;
else
return FALSE;
@@ -1476,9 +1500,10 @@ void SetMainCallback1(MainCallback cb)
gMain.callback1 = cb;
}
-void sub_8085E94(void *a0)
+// This function is never called.
+void SetUnusedCallback(void *func)
{
- sUnknown_03000E0C = a0;
+ sUnusedOverworldCallback = func;
}
static bool8 map_post_load_hook_exec(void)
@@ -1595,15 +1620,15 @@ static void c2_80567AC(void)
if (map_loading_iteration_3(&gMain.state))
{
SetFieldVBlankCallback();
- SetMainCallback1(c1_link_related);
- sub_8086C2C();
+ SetMainCallback1(CB1_UpdateLinkState);
+ ResetAllMultiplayerState();
SetMainCallback2(CB2_Overworld);
}
}
void CB2_ReturnToField(void)
{
- if (is_c1_link_related_active() == TRUE)
+ if (IsUpdateLinkStateCBActive() == TRUE)
{
SetMainCallback2(CB2_ReturnToFieldLink);
}
@@ -1629,12 +1654,12 @@ void CB2_ReturnToFieldLink(void)
SetMainCallback2(CB2_Overworld);
}
-void c2_8056854(void)
+void CB2_ReturnToFieldFromMultiplayer(void)
{
FieldClearVBlankHBlankCallbacks();
StopMapMusic();
- SetMainCallback1(c1_link_related);
- sub_8086C2C();
+ SetMainCallback1(CB1_UpdateLinkState);
+ ResetAllMultiplayerState();
if (gWirelessCommType != 0)
gFieldCallback = sub_80AF314;
@@ -1810,7 +1835,7 @@ static bool32 map_loading_iteration_3(u8 *state)
sub_8086AE4();
sub_80869DC();
sub_8086B14();
- sub_8086AAC();
+ SetCameraToTrackGuestPlayer();
(*state)++;
break;
case 4:
@@ -1980,9 +2005,9 @@ static bool32 map_loading_iteration_2_link(u8 *state)
(*state)++;
break;
case 2:
- sub_8086B9C();
+ CreateLinkPlayerSprites();
sub_8086A68();
- sub_8086AC8();
+ SetCameraToTrackGuestPlayer_2();
(*state)++;
break;
case 3:
@@ -2083,7 +2108,7 @@ static void InitOverworldGraphicsRegisters(void)
SetGpuReg(REG_OFFSET_WIN0V, 0xFF);
SetGpuReg(REG_OFFSET_WIN1H, 0xFFFF);
SetGpuReg(REG_OFFSET_WIN1V, 0xFFFF);
- SetGpuReg(REG_OFFSET_BLDCNT, gUnknown_82EC7C4[1] | gUnknown_82EC7C4[2] | gUnknown_82EC7C4[3]
+ SetGpuReg(REG_OFFSET_BLDCNT, gOverworldBackgroundLayerFlags[1] | gOverworldBackgroundLayerFlags[2] | gOverworldBackgroundLayerFlags[3]
| BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(13, 7));
InitOverworldBgs();
@@ -2169,21 +2194,25 @@ static void sub_8086A80(void)
InitCameraUpdateCallback(gPlayerAvatar.spriteId);
}
-static void sub_8086AAC(void)
+static void SetCameraToTrackGuestPlayer(void)
{
- InitCameraUpdateCallback(sub_8087858(gUnknown_03005DB4));
+ InitCameraUpdateCallback(GetSpriteForLinkedPlayer(gLocalLinkPlayerId));
}
-static void sub_8086AC8(void)
+// Duplicate function.
+static void SetCameraToTrackGuestPlayer_2(void)
{
- InitCameraUpdateCallback(sub_8087858(gUnknown_03005DB4));
+ InitCameraUpdateCallback(GetSpriteForLinkedPlayer(gLocalLinkPlayerId));
}
static void sub_8086AE4(void)
{
u16 x, y;
GetCameraFocusCoords(&x, &y);
- sub_8088B3C(x + gUnknown_03005DB4, y);
+
+ // This is a hack of some kind; it's undone in sub_8086B14, which is called
+ // soon after this function.
+ sub_8088B3C(x + gLocalLinkPlayerId, y);
}
static void sub_8086B14(void)
@@ -2192,7 +2221,7 @@ static void sub_8086B14(void)
u16 x, y;
GetCameraFocusCoords(&x, &y);
- x -= gUnknown_03005DB4;
+ x -= gLocalLinkPlayerId;
for (i = 0; i < gFieldLinkPlayerCount; i++)
{
@@ -2200,161 +2229,180 @@ static void sub_8086B14(void)
CreateLinkPlayerSprite(i, gLinkPlayers[i].version);
}
- sub_8086C40();
+ ClearAllPlayerKeys();
}
-static void sub_8086B9C(void)
+static void CreateLinkPlayerSprites(void)
{
u16 i;
for (i = 0; i < gFieldLinkPlayerCount; i++)
CreateLinkPlayerSprite(i, gLinkPlayers[i].version);
}
-static void c1_link_related(void)
+
+static void CB1_UpdateLinkState(void)
{
- if (gWirelessCommType == 0 || !sub_800F0B8() || !sub_8009F3C())
+ if (gWirelessCommType == 0 || !IsRfuRecvQueueEmpty() || !IsSendingKeysToLink())
{
- u8 var = gUnknown_03005DB4;
- sub_8086F38(gLinkPartnersHeldKeys, var);
- sub_8086FA0(sUnknown_03000E14(var));
- sub_8086C40();
+ u8 selfId = gLocalLinkPlayerId;
+ UpdateAllLinkPlayers(gLinkPartnersHeldKeys, selfId);
+
+ // Note: Because guestId is between 0 and 4, while the smallest key code is
+ // LINK_KEY_CODE_EMPTY, this is functionally equivalent to `sPlayerKeyInterceptCallback(0)`.
+ // It is expecting the callback to be KeyInterCB_SelfIdle, and that will
+ // completely ignore any input parameters.
+ //
+ // UpdateHeldKeyCode performs a sanity check on its input; if
+ // sPlayerKeyInterceptCallback echoes back the argument, which is selfId, then
+ // it'll use LINK_KEY_CODE_EMPTY instead.
+ //
+ // Note 2: There are some key intercept callbacks that treat the key as a player
+ // ID. It's so hacky.
+ UpdateHeldKeyCode(sPlayerKeyInterceptCallback(selfId));
+ ClearAllPlayerKeys();
}
}
-void sub_8086C2C(void)
+void ResetAllMultiplayerState(void)
{
- sub_8086C90();
- c1_link_related_func_set(sub_80870B0);
+ ResetAllTradingStates();
+ SetKeyInterceptCallback(KeyInterCB_SelfIdle);
}
-static void sub_8086C40(void)
+static void ClearAllPlayerKeys(void)
{
- sub_808709C(gLinkPartnersHeldKeys);
+ ResetPlayerHeldKeys(gLinkPartnersHeldKeys);
}
-static void c1_link_related_func_set(u16 (*func)(u32))
+static void SetKeyInterceptCallback(u16 (*func)(u32))
{
- sUnknown_03000E19 = 0;
- sUnknown_03000E14 = func;
+ sRfuKeepAliveTimer = 0;
+ sPlayerKeyInterceptCallback = func;
}
-static void sub_8086C64(void)
+// Once every ~60 frames, if the link state hasn't changed (timer reset by calls
+// to SetKeyInterceptCallback), it does a bunch of sanity checks on the connection.
+// I'm not sure if sRfuKeepAliveTimer is reset in the process, though; rfu stuff is
+// still undocumented.
+static void CheckRfuKeepAliveTimer(void)
{
- if (gWirelessCommType != 0 && ++sUnknown_03000E19 > 60)
+ if (gWirelessCommType != 0 && ++sRfuKeepAliveTimer > 60)
sub_8010198();
}
-static void sub_8086C90(void)
+static void ResetAllTradingStates(void)
{
s32 i;
for (i = 0; i < 4; i++)
- sUnknown_03000E10[i] = 0x80;
+ sPlayerTradingStates[i] = PLAYER_TRADING_STATE_IDLE;
}
-static bool32 sub_8086CA8(u16 a1)
+// Returns true if all connected players are in tradingState.
+static bool32 AreAllPlayersInTradingState(u16 tradingState)
{
s32 i;
s32 count = gFieldLinkPlayerCount;
for (i = 0; i < count; i++)
- if (sUnknown_03000E10[i] != a1)
+ if (sPlayerTradingStates[i] != tradingState)
return FALSE;
return TRUE;
}
-static bool32 sub_8086CE0(u16 a1)
+static bool32 IsAnyPlayerInTradingState(u16 tradingState)
{
s32 i;
s32 count = gFieldLinkPlayerCount;
for (i = 0; i < count; i++)
- if (sUnknown_03000E10[i] == a1)
+ if (sPlayerTradingStates[i] == tradingState)
return TRUE;
return FALSE;
}
-static void sub_8086D18(u32 a1, u16 a2, struct UnkStruct_8054FF8 *a3, u16 *a4)
+static void HandleLinkPlayerKeyInput(u32 playerId, u16 key, struct TradeRoomPlayer *trainer, u16 *forceFacing)
{
const u8 *script;
- if (sUnknown_03000E10[a1] == 0x80)
+ if (sPlayerTradingStates[playerId] == PLAYER_TRADING_STATE_IDLE)
{
- script = sub_8087370(a3);
+ script = TryGetTileEventScript(trainer);
if (script)
{
- *a4 = sub_8087480(script);
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ *forceFacing = GetDirectionForEventScript(script);
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_80870F8);
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
sub_8087530(script);
}
return;
}
- if (sub_8086CE0(0x83) == 1)
+ if (IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_80870F8);
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
sub_8087584();
}
return;
}
- switch (a2)
+
+ switch (key)
{
- case 24:
- if (sub_8087358(a3))
+ case LINK_KEY_CODE_START_BUTTON:
+ if (sub_8087340_2(trainer))
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_80870F8);
- sub_808751C();
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
+ InitLinkRoomStartMenuScript();
}
}
break;
- case 18:
- if (sub_8087388(a3) == TRUE)
+ case LINK_KEY_CODE_DPAD_DOWN:
+ if (PlayerIsAtSouthExit(trainer) == TRUE)
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_80870F8);
- sub_808754C();
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
+ CreateConfirmLeaveTradeRoomPrompt();
}
}
break;
- case 25:
- script = sub_80873B4(a3);
+ case LINK_KEY_CODE_A_BUTTON:
+ script = TryInteractWithPlayer(trainer);
if (script)
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_80870F8);
- sub_8087568(script);
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
+ InitMenuBasedScript(script);
}
}
break;
- case 27:
- if (sub_8087340(a3))
+ case LINK_KEY_CODE_HANDLE_RECV_QUEUE:
+ if (sub_8087340(trainer))
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_808711C);
+ SetKeyInterceptCallback(KeyInterCB_DeferToRecvQueue);
sub_8087510();
}
}
break;
- case 28:
- if (sub_8087340(a3))
+ case LINK_KEY_CODE_HANDLE_SEND_QUEUE:
+ if (sub_8087340(trainer))
{
- sUnknown_03000E10[a1] = 0x81;
- if (a3->b)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
+ if (trainer->isLocalPlayer)
{
- c1_link_related_func_set(sub_8087140);
+ SetKeyInterceptCallback(KeyInterCB_DeferToSendQueue);
sub_8087510();
}
}
@@ -2362,388 +2410,403 @@ static void sub_8086D18(u32 a1, u16 a2, struct UnkStruct_8054FF8 *a3, u16 *a4)
}
}
- switch (a2)
+ switch (key)
{
- case 23:
- sUnknown_03000E10[a1] = 0x83;
+ case LINK_KEY_CODE_EXIT_ROOM:
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_EXITING_ROOM;
break;
- case 22:
- sUnknown_03000E10[a1] = 0x82;
+ case LINK_KEY_CODE_UNK_2:
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_UNK_2;
break;
- case 26:
- sUnknown_03000E10[a1] = 0x80;
- if (a3->b)
- c1_link_related_func_set(sub_80870B0);
+ case LINK_KEY_CODE_UNK_4:
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_IDLE;
+ if (trainer->isLocalPlayer)
+ SetKeyInterceptCallback(KeyInterCB_SelfIdle);
break;
- case 29:
- if (sUnknown_03000E10[a1] == 0x82)
- sUnknown_03000E10[a1] = 0x81;
+ case LINK_KEY_CODE_UNK_7:
+ if (sPlayerTradingStates[playerId] == PLAYER_TRADING_STATE_UNK_2)
+ sPlayerTradingStates[playerId] = PLAYER_TRADING_STATE_BUSY;
break;
}
}
-static void sub_8086F38(u16 *a1, s32 a2)
+static void UpdateAllLinkPlayers(u16 *keys, s32 selfId)
{
- struct UnkStruct_8054FF8 st;
+ struct TradeRoomPlayer trainer;
s32 i;
for (i = 0; i < 4; i++)
{
- u8 v5 = a1[i];
- u16 v8 = 0;
- sub_80872D8(i, a2, &st);
- sub_8086D18(i, v5, &st, &v8);
- if (sUnknown_03000E10[i] == 0x80)
- v8 = sub_8087068(v5);
- sub_808796C(i, v8);
+ u8 key = keys[i];
+ u16 setFacing = FACING_NONE;
+ LoadTradeRoomPlayer(i, selfId, &trainer);
+ HandleLinkPlayerKeyInput(i, key, &trainer, &setFacing);
+ if (sPlayerTradingStates[i] == PLAYER_TRADING_STATE_IDLE)
+ setFacing = GetDirectionForDpadKey(key);
+ SetPlayerFacingDirection(i, setFacing);
}
}
-static void sub_8086FA0(u16 a1)
+static void UpdateHeldKeyCode(u16 key)
{
- if (a1 >= 17 && a1 < 30)
- gUnknown_03005DA8 = a1;
+ if (key >= LINK_KEY_CODE_EMPTY && key < LINK_KEY_CODE_UNK_8)
+ gHeldKeyCodeToSend = key;
else
- gUnknown_03005DA8 = 17;
+ gHeldKeyCodeToSend = LINK_KEY_CODE_EMPTY;
if (gWirelessCommType != 0
- && sub_8087690() > 1
- && is_c1_link_related_active() == TRUE
- && sub_8009F3C() == TRUE)
+ && GetLinkSendQueueLength() > 1
+ && IsUpdateLinkStateCBActive() == TRUE
+ && IsSendingKeysToLink() == TRUE)
{
- switch (a1)
+ switch (key)
{
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 24:
- case 25:
- gUnknown_03005DA8 = 0;
+ case LINK_KEY_CODE_EMPTY:
+ case LINK_KEY_CODE_DPAD_DOWN:
+ case LINK_KEY_CODE_DPAD_UP:
+ case LINK_KEY_CODE_DPAD_LEFT:
+ case LINK_KEY_CODE_DPAD_RIGHT:
+ case LINK_KEY_CODE_START_BUTTON:
+ case LINK_KEY_CODE_A_BUTTON:
+ gHeldKeyCodeToSend = LINK_KEY_CODE_NULL;
break;
}
}
}
-static u16 sub_808700C(u32 a1)
+static u16 KeyInterCB_ReadButtons(u32 key)
{
if (gMain.heldKeys & DPAD_UP)
- return 19;
+ return LINK_KEY_CODE_DPAD_UP;
else if (gMain.heldKeys & DPAD_DOWN)
- return 18;
+ return LINK_KEY_CODE_DPAD_DOWN;
else if (gMain.heldKeys & DPAD_LEFT)
- return 20;
+ return LINK_KEY_CODE_DPAD_LEFT;
else if (gMain.heldKeys & DPAD_RIGHT)
- return 21;
+ return LINK_KEY_CODE_DPAD_RIGHT;
else if (gMain.newKeys & START_BUTTON)
- return 24;
+ return LINK_KEY_CODE_START_BUTTON;
else if (gMain.newKeys & A_BUTTON)
- return 25;
+ return LINK_KEY_CODE_A_BUTTON;
else
- return 17;
+ return LINK_KEY_CODE_EMPTY;
}
-static u16 sub_8087068(u16 a1)
+static u16 GetDirectionForDpadKey(u16 a1)
{
switch (a1)
{
- case 21:
- return 4;
- case 20:
- return 3;
- case 19:
- return 1;
- case 18:
- return 2;
+ case LINK_KEY_CODE_DPAD_RIGHT:
+ return FACING_RIGHT;
+ case LINK_KEY_CODE_DPAD_LEFT:
+ return FACING_LEFT;
+ case LINK_KEY_CODE_DPAD_UP:
+ return FACING_UP;
+ case LINK_KEY_CODE_DPAD_DOWN:
+ return FACING_DOWN;
default:
- return 0;
+ return FACING_NONE;
}
}
-static void sub_808709C(u16 *a1)
+// Overwrites the keys with 0x11
+static void ResetPlayerHeldKeys(u16 *keys)
{
s32 i;
for (i = 0; i < 4; i++)
- a1[i] = 17;
+ keys[i] = LINK_KEY_CODE_EMPTY;
}
-static u16 sub_80870B0(u32 a1)
+
+static u16 KeyInterCB_SelfIdle(u32 key)
{
- if (ScriptContext2_IsEnabled() == 1)
- return 17;
- if (sub_800B4DC() > 4)
- return 27;
- if (sub_8087690() <= 4)
- return sub_808700C(a1);
- return 28;
+ if (ScriptContext2_IsEnabled() == TRUE)
+ return LINK_KEY_CODE_EMPTY;
+ if (GetLinkRecvQueueLength() > 4)
+ return LINK_KEY_CODE_HANDLE_RECV_QUEUE;
+ if (GetLinkSendQueueLength() <= 4)
+ return KeyInterCB_ReadButtons(key);
+ return LINK_KEY_CODE_HANDLE_SEND_QUEUE;
}
-static u16 sub_80870EC(u32 a1)
+static u16 sub_80870EC(u32 key)
{
- sub_8086C64();
- return 17;
+ CheckRfuKeepAliveTimer();
+ return LINK_KEY_CODE_EMPTY;
}
-static u16 sub_80870F8(u32 a1)
+// Ignore the player's inputs as long as there is an event script
+// in ScriptContext2.
+static u16 KeyInterCB_DeferToEventScript(u32 key)
{
u16 retVal;
if (ScriptContext2_IsEnabled() == TRUE)
{
- retVal = 17;
+ retVal = LINK_KEY_CODE_EMPTY;
}
else
{
- retVal = 26;
- c1_link_related_func_set(sub_80870EC);
+ retVal = LINK_KEY_CODE_UNK_4;
+ SetKeyInterceptCallback(sub_80870EC);
}
return retVal;
}
-static u16 sub_808711C(u32 a1)
+// Ignore the player's inputs as long as there are events being recived.
+static u16 KeyInterCB_DeferToRecvQueue(u32 key)
{
u16 retVal;
- if (sub_800B4DC() > 2)
+ if (GetLinkRecvQueueLength() > 2)
{
- retVal = 17;
+ retVal = LINK_KEY_CODE_EMPTY;
}
else
{
- retVal = 26;
+ retVal = LINK_KEY_CODE_UNK_4;
ScriptContext2_Disable();
- c1_link_related_func_set(sub_80870EC);
+ SetKeyInterceptCallback(sub_80870EC);
}
return retVal;
}
-static u16 sub_8087140(u32 a1)
+// Ignore the player's inputs as long as there are events being sent.
+static u16 KeyInterCB_DeferToSendQueue(u32 key)
{
u16 retVal;
- if (sub_8087690() > 2)
+ if (GetLinkSendQueueLength() > 2)
{
- retVal = 17;
+ retVal = LINK_KEY_CODE_EMPTY;
}
else
{
- retVal = 26;
+ retVal = LINK_KEY_CODE_UNK_4;
ScriptContext2_Disable();
- c1_link_related_func_set(sub_80870EC);
+ SetKeyInterceptCallback(sub_80870EC);
}
return retVal;
}
-static u16 sub_8087164(u32 a1)
+static u16 KeyInterCB_DoNothingAndKeepAlive(u32 key)
{
- sub_8086C64();
- return 17;
+ CheckRfuKeepAliveTimer();
+ return LINK_KEY_CODE_EMPTY;
}
-static u16 sub_8087170(u32 linkPlayerId)
+static u16 sub_8087170(u32 keyOrPlayerId)
{
- if (sUnknown_03000E10[linkPlayerId] == 0x82)
+ if (sPlayerTradingStates[keyOrPlayerId] == PLAYER_TRADING_STATE_UNK_2)
{
if (gMain.newKeys & B_BUTTON)
{
- c1_link_related_func_set(sub_8087164);
- return 29;
+ SetKeyInterceptCallback(KeyInterCB_DoNothingAndKeepAlive);
+ return LINK_KEY_CODE_UNK_7;
}
else
{
- return 17;
+ return LINK_KEY_CODE_EMPTY;
}
}
else
{
- sub_8086C64();
- return 17;
+ CheckRfuKeepAliveTimer();
+ return LINK_KEY_CODE_EMPTY;
}
}
static u16 sub_80871AC(u32 a1)
{
- c1_link_related_func_set(sub_8087170);
- return 22;
+ SetKeyInterceptCallback(sub_8087170);
+ return LINK_KEY_CODE_UNK_2;
}
-static u16 sub_80871C0(u32 a1)
+static u16 KeyInterCB_SendNothing(u32 key)
{
- return 17;
+ return LINK_KEY_CODE_EMPTY;
}
-static u16 sub_80871C4(u32 a1)
+static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId)
{
- if (sUnknown_03000E10[a1] != 0x83)
- sub_8086C64();
- if (sub_8086CA8(0x83) == TRUE)
+ // keyOrPlayerId could be any keycode. This callback does no sanity checking
+ // on the size of the key. It's assuming that it is being called from
+ // CB1_UpdateLinkState.
+ if (sPlayerTradingStates[keyOrPlayerId] != PLAYER_TRADING_STATE_EXITING_ROOM)
+ CheckRfuKeepAliveTimer();
+ if (AreAllPlayersInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
{
- ScriptContext1_SetupScript(EventScript_277513);
- c1_link_related_func_set(sub_80871C0);
+ ScriptContext1_SetupScript(EventScript_DoLinkRoomExit);
+ SetKeyInterceptCallback(KeyInterCB_SendNothing);
}
- return 17;
+ return LINK_KEY_CODE_EMPTY;
}
-static u16 sub_80871FC(u32 a1)
+static u16 KeyInterCB_SendExitRoomKey(u32 key)
{
- c1_link_related_func_set(sub_80871C4);
- return 23;
+ SetKeyInterceptCallback(KeyInterCB_WaitForPlayersToExit);
+ return LINK_KEY_CODE_EXIT_ROOM;
}
-static u16 sub_8087210(u32 a1)
+// Duplicate function.
+static u16 KeyInterCB_SendNothing_2(u32 key)
{
- return 17;
+ return LINK_KEY_CODE_EMPTY;
}
u32 sub_8087214(void)
{
- if (sub_8086CE0(0x83) == TRUE)
+ if (IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM) == TRUE)
return 2;
- if (sUnknown_03000E14 == sub_8087170 && sUnknown_03000E10[gUnknown_03005DB4] != 0x82)
+ if (sPlayerKeyInterceptCallback == sub_8087170 && sPlayerTradingStates[gLocalLinkPlayerId] != PLAYER_TRADING_STATE_UNK_2)
return 0;
- if (sUnknown_03000E14 == sub_8087164 && sUnknown_03000E10[gUnknown_03005DB4] == 0x81)
+ if (sPlayerKeyInterceptCallback == KeyInterCB_DoNothingAndKeepAlive && sPlayerTradingStates[gLocalLinkPlayerId] == PLAYER_TRADING_STATE_BUSY)
return 2;
- if (sub_8086CA8(0x82) != 0)
+ if (AreAllPlayersInTradingState(PLAYER_TRADING_STATE_UNK_2) != FALSE)
return 1;
return 0;
}
bool32 sub_808727C(void)
{
- return sub_8086CE0(0x83);
+ return IsAnyPlayerInTradingState(PLAYER_TRADING_STATE_EXITING_ROOM);
}
u16 sub_8087288(void)
{
- c1_link_related_func_set(sub_80871AC);
+ SetKeyInterceptCallback(sub_80871AC);
return 0;
}
u16 sub_808729C(void)
{
- c1_link_related_func_set(sub_80870F8);
+ SetKeyInterceptCallback(KeyInterCB_DeferToEventScript);
return 0;
}
-u16 sub_80872B0(void)
+// The exit room key will be sent at the next opportunity.
+// The return value is meaningless.
+u16 QueueExitLinkRoomKey(void)
{
- c1_link_related_func_set(sub_80871FC);
+ SetKeyInterceptCallback(KeyInterCB_SendExitRoomKey);
return 0;
}
u16 sub_80872C4(void)
{
- c1_link_related_func_set(sub_8087210);
+ SetKeyInterceptCallback(KeyInterCB_SendNothing_2);
return 0;
}
-static void sub_80872D8(s32 linkPlayerId, s32 a2, struct UnkStruct_8054FF8 *a3)
+static void LoadTradeRoomPlayer(s32 linkPlayerId, s32 myPlayerId, struct TradeRoomPlayer *trainer)
{
s16 x, y;
- a3->a = linkPlayerId;
- a3->b = (linkPlayerId == a2) ? 1 : 0;
- a3->c = gLinkPlayerEventObjects[linkPlayerId].mode;
- a3->d = sub_80878A0(linkPlayerId);
- sub_8087878(linkPlayerId, &x, &y);
- a3->sub.x = x;
- a3->sub.y = y;
- a3->sub.height = sub_80878C0(linkPlayerId);
- a3->field_C = MapGridGetMetatileBehaviorAt(x, y);
+ trainer->playerId = linkPlayerId;
+ trainer->isLocalPlayer = (linkPlayerId == myPlayerId) ? 1 : 0;
+ trainer->c = gLinkPlayerEventObjects[linkPlayerId].movementMode;
+ trainer->facing = GetLinkPlayerFacingDirection(linkPlayerId);
+ GetLinkPlayerCoords(linkPlayerId, &x, &y);
+ trainer->pos.x = x;
+ trainer->pos.y = y;
+ trainer->pos.height = GetLinkPlayerElevation(linkPlayerId);
+ trainer->field_C = MapGridGetMetatileBehaviorAt(x, y);
}
-static bool32 sub_8087340(struct UnkStruct_8054FF8 *a1)
+static bool32 sub_8087340(struct TradeRoomPlayer *player)
{
- u8 v1 = a1->c;
- if (v1 == 2 || v1 == 0)
+ u8 v1 = player->c;
+ if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE)
return TRUE;
else
return FALSE;
}
-static bool32 sub_8087358(struct UnkStruct_8054FF8 *a1)
+// Duplicate function.
+static bool32 sub_8087340_2(struct TradeRoomPlayer *player)
{
- u8 v1 = a1->c;
- if (v1 == 2 || v1 == 0)
+ u8 v1 = player->c;
+ if (v1 == MOVEMENT_MODE_SCRIPTED || v1 == MOVEMENT_MODE_FREE)
return TRUE;
else
return FALSE;
}
-static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1)
+static u8 *TryGetTileEventScript(struct TradeRoomPlayer *player)
{
- if (a1->c != 2)
- return 0;
- return GetCoordEventScriptAtMapPosition(&a1->sub);
+ if (player->c != MOVEMENT_MODE_SCRIPTED)
+ return FACING_NONE;
+ return GetCoordEventScriptAtMapPosition(&player->pos);
}
-static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1)
+static bool32 PlayerIsAtSouthExit(struct TradeRoomPlayer *player)
{
- if (a1->c != 2 && a1->c != 0)
+ if (player->c != MOVEMENT_MODE_SCRIPTED && player->c != MOVEMENT_MODE_FREE)
return FALSE;
- else if (!MetatileBehavior_IsSouthArrowWarp(a1->field_C))
+ else if (!MetatileBehavior_IsSouthArrowWarp(player->field_C))
return FALSE;
- else if (a1->d != 1)
+ else if (player->facing != 1)
return FALSE;
else
return TRUE;
}
-static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1)
+static const u8 *TryInteractWithPlayer(struct TradeRoomPlayer *player)
{
- struct MapPosition unkStruct;
+ struct MapPosition otherPlayerPos;
u8 linkPlayerId;
- if (a1->c && a1->c != 2)
- return 0;
+ if (player->c != MOVEMENT_MODE_FREE && player->c != MOVEMENT_MODE_SCRIPTED)
+ return FACING_NONE;
- unkStruct = a1->sub;
- unkStruct.x += gDirectionToVectors[a1->d].x;
- unkStruct.y += gDirectionToVectors[a1->d].y;
- unkStruct.height = 0;
- linkPlayerId = GetLinkPlayerIdAt(unkStruct.x, unkStruct.y);
+ otherPlayerPos = player->pos;
+ otherPlayerPos.x += gDirectionToVectors[player->facing].x;
+ otherPlayerPos.y += gDirectionToVectors[player->facing].y;
+ otherPlayerPos.height = 0;
+ linkPlayerId = GetLinkPlayerIdAt(otherPlayerPos.x, otherPlayerPos.y);
if (linkPlayerId != 4)
{
- if (!a1->b)
- return EventScript_TradeRoom_TooBusyToNotice;
- else if (sUnknown_03000E10[linkPlayerId] != 0x80)
- return EventScript_TradeRoom_TooBusyToNotice;
- else if (!sub_80B39D4(linkPlayerId))
- return EventScript_TradeRoom_ReadTrainerCard1;
+ if (!player->isLocalPlayer)
+ return gEventScript_TradeRoom_TooBusyToNotice;
+ else if (sPlayerTradingStates[linkPlayerId] != PLAYER_TRADING_STATE_IDLE)
+ return gEventScript_TradeRoom_TooBusyToNotice;
+ else if (!GetLinkTrainerCardColor(linkPlayerId))
+ return gEventScript_TradeRoom_ReadTrainerCard_NoColor;
else
- return EventScript_TradeRoom_ReadTrainerCard2;
- }
-
- return GetInteractedLinkPlayerScript(&unkStruct, a1->field_C, a1->d);
-}
-
-static u16 sub_8087480(const u8 *script)
-{
- if (script == gUnknown_08277388)
- return 10;
- else if (script == gUnknown_082773A3)
- return 9;
- else if (script == gUnknown_082773BE)
- return 10;
- else if (script == gUnknown_082773D9)
- return 9;
- else if (script == gUnknown_0827741D)
- return 10;
- else if (script == gUnknown_08277432)
- return 9;
- else if (script == gUnknown_08277447)
- return 10;
- else if (script == gUnknown_0827745C)
- return 9;
- else if (script == gUnknown_08277374)
- return 10;
- else if (script == gUnknown_0827737E)
- return 9;
- else if (script == gUnknown_082773F5)
- return 10;
- else if (script == gUnknown_082773FF)
- return 9;
+ return gEventScript_TradeRoom_ReadTrainerCard_Normal;
+ }
+
+ return GetInteractedLinkPlayerScript(&otherPlayerPos, player->field_C, player->facing);
+}
+
+// This returns which direction to force the player to look when one of
+// these event scripts runs.
+static u16 GetDirectionForEventScript(const u8 *script)
+{
+ if (script == EventScript_DoubleBattleColosseum_PlayerSpot0)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_DoubleBattleColosseum_PlayerSpot1)
+ return FACING_FORCED_LEFT;
+ else if (script == EventScript_DoubleBattleColosseum_PlayerSpot2)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_DoubleBattleColosseum_PlayerSpot3)
+ return FACING_FORCED_LEFT;
+ else if (script == EventScript_RecordCenter_Spot0)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_RecordCenter_Spot1)
+ return FACING_FORCED_LEFT;
+ else if (script == EventScript_RecordCenter_Spot2)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_RecordCenter_Spot3)
+ return FACING_FORCED_LEFT;
+ else if (script == EventScript_SingleBattleColosseum_PlayerSpot0)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_SingleBattleColosseum_PlayerSpot1)
+ return FACING_FORCED_LEFT;
+ else if (script == EventScript_TradeCenter_Chair0)
+ return FACING_FORCED_RIGHT;
+ else if (script == EventScript_TradeCenter_Chair1)
+ return FACING_FORCED_LEFT;
else
- return 0;
+ return FACING_NONE;
}
static void sub_8087510(void)
@@ -2751,7 +2814,7 @@ static void sub_8087510(void)
ScriptContext2_Enable();
}
-static void sub_808751C(void)
+static void InitLinkRoomStartMenuScript(void)
{
PlaySE(SE_WIN_OPEN);
ShowStartMenu();
@@ -2765,14 +2828,14 @@ static void sub_8087530(const u8 *script)
ScriptContext2_Enable();
}
-static void sub_808754C(void)
+static void CreateConfirmLeaveTradeRoomPrompt(void)
{
PlaySE(SE_WIN_OPEN);
- ScriptContext1_SetupScript(gUnknown_082774EF);
+ ScriptContext1_SetupScript(EventScript_ConfirmLeaveTradeRoom);
ScriptContext2_Enable();
}
-static void sub_8087568(const u8 *script)
+static void InitMenuBasedScript(const u8 *script)
{
PlaySE(SE_SELECT);
ScriptContext1_SetupScript(script);
@@ -2781,18 +2844,18 @@ static void sub_8087568(const u8 *script)
static void sub_8087584(void)
{
- ScriptContext1_SetupScript(gUnknown_08277509);
+ ScriptContext1_SetupScript(EventScript_TerminateLink);
ScriptContext2_Enable();
}
bool32 sub_8087598(void)
{
- if (!is_c1_link_related_active())
- return 0;
- if (sub_800B4DC() >= 3)
- sUnknown_03000E18 = 1;
+ if (!IsUpdateLinkStateCBActive())
+ return FALSE;
+ if (GetLinkRecvQueueLength() >= 3)
+ sUnknown_03000E18 = TRUE;
else
- sUnknown_03000E18 = 0;
+ sUnknown_03000E18 = FALSE;
return sUnknown_03000E18;
}
@@ -2800,19 +2863,19 @@ bool32 sub_80875C8(void)
{
u8 temp;
- if (sub_800B4DC() < 2)
+ if (GetLinkRecvQueueLength() < 2)
return FALSE;
- else if (is_c1_link_related_active() != TRUE)
+ else if (IsUpdateLinkStateCBActive() != TRUE)
return FALSE;
- else if (sub_8009F3C() != TRUE)
+ else if (IsSendingKeysToLink() != TRUE)
return FALSE;
- else if (sUnknown_03000E14 == sub_808711C)
+ else if (sPlayerKeyInterceptCallback == KeyInterCB_DeferToRecvQueue)
return TRUE;
- else if (sUnknown_03000E14 != sub_80870F8)
+ else if (sPlayerKeyInterceptCallback != KeyInterCB_DeferToEventScript)
return FALSE;
temp = sUnknown_03000E18;
- sUnknown_03000E18 = 0;
+ sUnknown_03000E18 = FALSE;
if (temp == TRUE)
return TRUE;
@@ -2824,13 +2887,13 @@ bool32 sub_80875C8(void)
bool32 sub_8087634(void)
{
- if (sub_8087690() < 2)
+ if (GetLinkSendQueueLength() < 2)
return FALSE;
- else if (is_c1_link_related_active() != TRUE)
+ else if (IsUpdateLinkStateCBActive() != TRUE)
return FALSE;
- else if (sub_8009F3C() != TRUE)
+ else if (IsSendingKeysToLink() != TRUE)
return FALSE;
- else if (sUnknown_03000E14 == sub_8087140)
+ else if (sPlayerKeyInterceptCallback == KeyInterCB_DeferToSendQueue)
return TRUE;
else
return FALSE;
@@ -2840,13 +2903,13 @@ bool32 sub_808766C(void)
{
if (gWirelessCommType != 0)
return FALSE;
- else if (!sub_8009F3C())
+ else if (!IsSendingKeysToLink())
return FALSE;
else
return TRUE;
}
-static u32 sub_8087690(void)
+static u32 GetLinkSendQueueLength(void)
{
if (gWirelessCommType != 0)
return gUnknown_03005000.unk_9e8.unk_232;
@@ -2881,7 +2944,7 @@ static void SpawnLinkPlayerEventObject(u8 linkPlayerId, s16 x, s16 y, u8 a4)
linkPlayerEventObj->active = 1;
linkPlayerEventObj->linkPlayerId = linkPlayerId;
linkPlayerEventObj->eventObjId = eventObjId;
- linkPlayerEventObj->mode = 0;
+ linkPlayerEventObj->movementMode = MOVEMENT_MODE_FREE;
eventObj->active = 1;
eventObj->singleMovementActive = a4;
@@ -2923,14 +2986,15 @@ static void sub_808780C(u8 linkPlayerId)
eventObj->active = 0;
}
-static u8 sub_8087858(u8 linkPlayerId)
+// Returns the spriteId corresponding to this player.
+static u8 GetSpriteForLinkedPlayer(u8 linkPlayerId)
{
u8 eventObjId = gLinkPlayerEventObjects[linkPlayerId].eventObjId;
struct EventObject *eventObj = &gEventObjects[eventObjId];
return eventObj->spriteId;
}
-static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y)
+static void GetLinkPlayerCoords(u8 linkPlayerId, u16 *x, u16 *y)
{
u8 eventObjId = gLinkPlayerEventObjects[linkPlayerId].eventObjId;
struct EventObject *eventObj = &gEventObjects[eventObjId];
@@ -2938,14 +3002,14 @@ static void sub_8087878(u8 linkPlayerId, u16 *x, u16 *y)
*y = eventObj->currentCoords.y;
}
-static u8 sub_80878A0(u8 linkPlayerId)
+static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId)
{
u8 eventObjId = gLinkPlayerEventObjects[linkPlayerId].eventObjId;
struct EventObject *eventObj = &gEventObjects[eventObjId];
return eventObj->range.as_byte;
}
-static u8 sub_80878C0(u8 linkPlayerId)
+static u8 GetLinkPlayerElevation(u8 linkPlayerId)
{
u8 eventObjId = gLinkPlayerEventObjects[linkPlayerId].eventObjId;
struct EventObject *eventObj = &gEventObjects[eventObjId];
@@ -2965,7 +3029,7 @@ static u8 GetLinkPlayerIdAt(s16 x, s16 y)
for (i = 0; i < 4; i++)
{
if (gLinkPlayerEventObjects[i].active
- && (gLinkPlayerEventObjects[i].mode == 0 || gLinkPlayerEventObjects[i].mode == 2))
+ && (gLinkPlayerEventObjects[i].movementMode == 0 || gLinkPlayerEventObjects[i].movementMode == 2))
{
struct EventObject *eventObj = &gEventObjects[gLinkPlayerEventObjects[i].eventObjId];
if (eventObj->currentCoords.x == x && eventObj->currentCoords.y == y)
@@ -2975,7 +3039,7 @@ static u8 GetLinkPlayerIdAt(s16 x, s16 y)
return 4;
}
-static void sub_808796C(u8 linkPlayerId, u8 a2)
+static void SetPlayerFacingDirection(u8 linkPlayerId, u8 facing)
{
struct LinkPlayerEventObject *linkPlayerEventObj = &gLinkPlayerEventObjects[linkPlayerId];
u8 eventObjId = linkPlayerEventObj->eventObjId;
@@ -2983,94 +3047,111 @@ static void sub_808796C(u8 linkPlayerId, u8 a2)
if (linkPlayerEventObj->active)
{
- if (a2 > 10)
+ if (facing > FACING_FORCED_RIGHT)
+ {
eventObj->triggerGroundEffectsOnMove = 1;
+ }
else
- gUnknown_08339E00[gUnknown_08339DC8[linkPlayerEventObj->mode](linkPlayerEventObj, eventObj, a2)](linkPlayerEventObj, eventObj);
+ {
+ // This is a hack to split this code onto two separate lines, without declaring a local variable.
+ // C++ style inline variables would be nice here.
+ #define TEMP gLinkPlayerMovementModes[linkPlayerEventObj->movementMode](linkPlayerEventObj, eventObj, facing)
+
+ gMovementStatusHandler[TEMP](linkPlayerEventObj, eventObj);
+
+ // Clean up the hack.
+ #undef TEMP
+ }
}
}
-static u8 sub_80879D8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+
+static u8 MovementEventModeCB_Normal(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
- return gUnknown_08339DD4[a3](linkPlayerEventObj, eventObj, a3);
+ return gLinkPlayerFacingHandlers[a3](linkPlayerEventObj, eventObj, a3);
}
-static u8 sub_80879F8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+static u8 MovementEventModeCB_Ignored(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
- return 1;
+ return FACING_UP;
}
-static u8 sub_80879FC(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+// Duplicate Function
+static u8 MovementEventModeCB_Normal_2(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
- return gUnknown_08339DD4[a3](linkPlayerEventObj, eventObj, a3);
+ return gLinkPlayerFacingHandlers[a3](linkPlayerEventObj, eventObj, a3);
}
-static u8 sub_8087A1C(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+static bool8 FacingHandler_DoNothing(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
- return 0;
+ return FALSE;
}
-static u8 sub_8087A20(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+static bool8 FacingHandler_DpadMovement(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
s16 x, y;
- eventObj->range.as_byte = npc_something3(a3, eventObj->range.as_byte);
+ eventObj->range.as_byte = FlipVerticalAndClearForced(a3, eventObj->range.as_byte);
EventObjectMoveDestCoords(eventObj, eventObj->range.as_byte, &x, &y);
if (LinkPlayerDetectCollision(linkPlayerEventObj->eventObjId, eventObj->range.as_byte, x, y))
{
- return 0;
+ return FALSE;
}
else
{
eventObj->directionSequenceIndex = 16;
ShiftEventObjectCoords(eventObj, x, y);
EventObjectUpdateZCoord(eventObj);
- return 1;
+ return TRUE;
}
}
-static u8 sub_8087A88(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
+static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj, u8 a3)
{
- eventObj->range.as_byte = npc_something3(a3, eventObj->range.as_byte);
- return 0;
+ eventObj->range.as_byte = FlipVerticalAndClearForced(a3, eventObj->range.as_byte);
+ return FALSE;
}
-static void sub_8087AA0(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
+// This is called every time a free movement happens. Most of the time it's a No-Op.
+static void MovementStatusHandler_EnterFreeMode(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
{
- linkPlayerEventObj->mode = 0;
+ linkPlayerEventObj->movementMode = MOVEMENT_MODE_FREE;
}
-static void sub_8087AA8(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
+static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerEventObject *linkPlayerEventObj, struct EventObject *eventObj)
{
eventObj->directionSequenceIndex--;
- linkPlayerEventObj->mode = 1;
+ linkPlayerEventObj->movementMode = MOVEMENT_MODE_FROZEN;
MoveCoords(eventObj->range.as_byte, &eventObj->initialCoords.x, &eventObj->initialCoords.y);
if (!eventObj->directionSequenceIndex)
{
ShiftStillEventObjectCoords(eventObj);
- linkPlayerEventObj->mode = 2;
+ linkPlayerEventObj->movementMode = MOVEMENT_MODE_SCRIPTED;
}
}
-static u8 npc_something3(u8 a1, u8 a2)
+// Flip Up/Down facing codes. If newFacing doesn't specify a direction, default
+// to oldFacing. Note that this clears also the "FORCED" part of the facing code,
+// even for Left/Right codes.
+static u8 FlipVerticalAndClearForced(u8 newFacing, u8 oldFacing)
{
- switch (a1 - 1)
+ switch (newFacing)
{
- case 0:
- case 6:
- return 2;
- case 1:
- case 7:
- return 1;
- case 2:
- case 8:
- return 3;
- case 3:
- case 9:
- return 4;
+ case FACING_UP:
+ case FACING_FORCED_UP:
+ return DIR_NORTH;
+ case FACING_DOWN:
+ case FACING_FORCED_DOWN:
+ return DIR_SOUTH;
+ case FACING_LEFT:
+ case FACING_FORCED_LEFT:
+ return DIR_WEST;
+ case FACING_RIGHT:
+ case FACING_FORCED_RIGHT:
+ return DIR_EAST;
}
- return a2;
+ return oldFacing;
}
static u8 LinkPlayerDetectCollision(u8 selfEventObjId, u8 a2, s16 x, s16 y)
@@ -3130,7 +3211,7 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(eventObj->previousElevation);
- if (!linkPlayerEventObj->mode)
+ if (!linkPlayerEventObj->movementMode != MOVEMENT_MODE_FREE)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(eventObj->range.as_byte));
else
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(eventObj->range.as_byte));
diff --git a/src/party_menu.c b/src/party_menu.c
index 4103c212c..525063326 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -2754,7 +2754,7 @@ static void sub_81B1B8C(u8 taskId)
{
if (gTasks[taskId].data[0] == 0)
{
- sub_8198070(6, 0);
+ ClearStdWindowAndFrameToTransparent(6, 0);
ClearWindowTilemap(6);
}
DestroyTask(taskId);
@@ -2779,7 +2779,7 @@ static void sub_81B1C1C(u8 taskId)
{
if (sub_81B1BD4() != TRUE)
{
- sub_8198070(6, 0);
+ ClearStdWindowAndFrameToTransparent(6, 0);
ClearWindowTilemap(6);
if (sub_81221AC() == TRUE)
{
@@ -3109,7 +3109,7 @@ static void sub_81B239C(u8 a)
}
DeactivateAllTextPrinters();
for (i = 0; i < PARTY_SIZE; i++)
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
LoadUserWindowBorderGfx(0, 0x4F, 0xD0);
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
@@ -3127,7 +3127,7 @@ static void sub_81B2428(bool8 a)
if (a == TRUE)
{
firstWindowId = AddWindow(&gUnknown_08615918);
- FillWindowPixelBuffer(firstWindowId, 0);
+ FillWindowPixelBuffer(firstWindowId, PIXEL_FILL(0));
mainOffset = GetStringCenterAlignXOffset(0, gMenuText_Confirm, 48);
AddTextPrinterParameterized4(firstWindowId, 0, mainOffset, 1, 0, 0, gUnknown_086157FC[0], -1, gMenuText_Confirm);
PutWindowTilemap(firstWindowId);
@@ -3140,7 +3140,7 @@ static void sub_81B2428(bool8 a)
windowId = AddWindow(&gUnknown_08615908);
offset = 3;
}
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
if (gUnknown_0203CEC8.unk8_0 != 10)
{
mainOffset = GetStringCenterAlignXOffset(0, gText_Cancel, 48);
@@ -3480,8 +3480,9 @@ static void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *pt
FillWindowPixelRect(ptr->windowId, gUnknown_08615AB8[0], ptr->unk0->unk4[20], ptr->unk0->unk4[21] + 1, hpFraction, 2);
if (hpFraction != ptr->unk0->unk4[22])
{
- FillWindowPixelRect(ptr->windowId, 13, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21], ptr->unk0->unk4[22] - hpFraction, 1);
- FillWindowPixelRect(ptr->windowId, 2, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21] + 1, ptr->unk0->unk4[22] - hpFraction, 2);
+ // This appears to be an alternating fill
+ FillWindowPixelRect(ptr->windowId, 0x0D, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21], ptr->unk0->unk4[22] - hpFraction, 1);
+ FillWindowPixelRect(ptr->windowId, 0x02, ptr->unk0->unk4[20] + hpFraction, ptr->unk0->unk4[21] + 1, ptr->unk0->unk4[22] - hpFraction, 2);
}
CopyWindowToVram(ptr->windowId, 2);
}
@@ -3502,7 +3503,7 @@ static void sub_81B302C(u8 *ptr)
{
if (*ptr != 0xFF)
{
- sub_8198070(*ptr, 0);
+ ClearStdWindowAndFrameToTransparent(*ptr, 0);
RemoveWindow(*ptr);
*ptr = 0xFF;
schedule_bg_copy_tilemap_to_vram(2);
@@ -3547,7 +3548,7 @@ void display_pokemon_menu_message(u32 stringID)
else if (sub_81B314C() == FALSE)
stringID = 1;
}
- SetWindowBorderStyle(*windowPtr, FALSE, 0x4F, 0xD);
+ DrawStdFrameWithCustomTileAndPalette(*windowPtr, FALSE, 0x4F, 0xD);
StringExpandPlaceholders(gStringVar4, gUnknown_08615AF4[stringID]);
AddTextPrinterParameterized(*windowPtr, 1, gStringVar4, 0, 1, 0, 0);
schedule_bg_copy_tilemap_to_vram(2);
@@ -3597,7 +3598,7 @@ static u8 sub_81B31B0(u8 a)
}
gUnknown_0203CEC4->unkC[0] = AddWindow(&window);
- SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13);
+ DrawStdFrameWithCustomTileAndPalette(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13);
if (a == 3)
return gUnknown_0203CEC4->unkC[0];
cursorDimension = GetMenuCursorDimensionByFont(1, 0);
@@ -3617,7 +3618,7 @@ static u8 sub_81B31B0(u8 a)
static void sub_81B3300(const u8 *text)
{
- SetWindowBorderStyle(6, FALSE, 0x4F, 13);
+ DrawStdFrameWithCustomTileAndPalette(6, FALSE, 0x4F, 13);
gTextFlags.canABSpeedUpPrint = TRUE;
AddTextPrinterParameterized2(6, 1, text, GetPlayerTextSpeedDelay(), 0, 2, 1, 3);
}
@@ -3630,7 +3631,7 @@ static void sub_81B334C(void)
static u8 sub_81B3364(void)
{
gUnknown_0203CEC4->unkC[0] = AddWindow(&gUnknown_08615970);
- SetWindowBorderStyle(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13);
+ DrawStdFrameWithCustomTileAndPalette(gUnknown_0203CEC4->unkC[0], FALSE, 0x4F, 13);
return gUnknown_0203CEC4->unkC[0];
}
@@ -6522,7 +6523,7 @@ static void sub_81B8474(u8 taskId)
gTasks[taskId].func = sub_81B8104;
}
-void sub_81B8518(u8 unused)
+void InitChooseHalfPartyForBattle(u8 unused)
{
sub_81B8558();
InitPartyMenu(4, 0, 0, 0, 0, sub_81B1370, gMain.savedCallback);
diff --git a/src/player_pc.c b/src/player_pc.c
index 0d08a5e7b..6e78533e7 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -361,14 +361,14 @@ static void PlayerPCProcessMenuInput(u8 taskId)
break;
case MENU_B_PRESSED:
PlaySE(SE_SELECT);
- sub_8198070(data[4], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = PlayerPC_TurnOff;
break;
default:
- sub_8198070(data[4], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
@@ -403,7 +403,7 @@ static void PlayerPC_Mailbox(u8 taskId)
ItemStorage_SetItemAndMailCount(taskId);
if (sub_81D1C44(playerPCItemPageInfo.count) == TRUE)
{
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
Mailbox_DrawMailboxMenu(taskId);
gTasks[taskId].func = Mailbox_ProcessInput;
}
@@ -451,7 +451,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var)
static void ItemStorageMenuPrint(const u8 *textPtr)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, textPtr, 0, 1, 0, 0);
}
@@ -506,7 +506,7 @@ void sub_816B31C(void)
void Mailbox_DoRedrawMailboxMenuAfterReturn(void)
{
sub_81973A4();
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1);
pal_fill_black();
}
@@ -560,7 +560,7 @@ static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss)
FreeAndReserveObjectSpritePalettes();
LoadListMenuArrowsGfx();
sub_8122344(gUnknown_0203BCC4->spriteIds, 7);
- sub_8197434(0,0);
+ ClearDialogWindowAndFrame(0,0);
gTasks[taskId].func = ItemStorage_ProcessWithdrawTossInput;
}
@@ -583,7 +583,7 @@ static void sub_816B4DC(u8 taskId)
{
u16 *data = gTasks[taskId].data;
- sub_8198070(data[4], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[4], FALSE);
ClearWindowTilemap(data[4]);
RemoveWindow(data[4]);
schedule_bg_copy_tilemap_to_vram(0);
@@ -761,7 +761,7 @@ static void Mailbox_MoveToBag(u8 taskId)
static void Mailbox_DrawYesNoBeforeMove(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
gTasks[taskId].func = Mailbox_MoveToBagYesNoPrompt;
}
@@ -863,7 +863,7 @@ static void Mailbox_NoPokemonForMail(u8 taskId)
static void Mailbox_Cancel(u8 taskId)
{
sub_81D1D04(2);
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
Mailbox_DrawMailboxMenu(taskId);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = Mailbox_ProcessInput;
@@ -892,7 +892,7 @@ static u8 sub_816BC7C(u8 a)
if (*windowIdLoc == 0xFF)
{
*windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]);
- SetWindowBorderStyle(*windowIdLoc, FALSE, 0x214, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(*windowIdLoc, FALSE, 0x214, 0xE);
schedule_bg_copy_tilemap_to_vram(0);
}
return *windowIdLoc;
@@ -903,7 +903,7 @@ static void sub_816BCC4(u8 a)
u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]);
if (*windowIdLoc != 0xFF)
{
- sub_8198070(*windowIdLoc, FALSE);
+ ClearStdWindowAndFrameToTransparent(*windowIdLoc, FALSE);
ClearWindowTilemap(*windowIdLoc);
schedule_bg_copy_tilemap_to_vram(0);
RemoveWindow(*windowIdLoc);
@@ -977,7 +977,7 @@ static void sub_816BEF0(s32 id)
description = (u8 *)ItemId_GetDescription(gSaveBlock1Ptr->pcItems[id].itemId);
else
description = ItemStorage_GetItemPcResponse(ITEMPC_GO_BACK_TO_PREV);
- FillWindowPixelBuffer(windowId, 17);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
AddTextPrinterParameterized(windowId, 1, description, 0, 1, 0, NULL);
}
@@ -1005,7 +1005,7 @@ static void sub_816BFE0(u8 y, u8 b, u8 speed)
{
u8 windowId = gUnknown_0203BCC4->windowIds[0];
if (b == 0xFF)
- FillWindowPixelRect(windowId, 17, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
+ FillWindowPixelRect(windowId, PIXEL_FILL(1), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else
AddTextPrinterParameterized4(windowId, 1, 0, y, 0, 0, gUnknown_085DFF8C, speed, gText_SelectorArrow2);
}
@@ -1123,7 +1123,7 @@ static const u8* ItemStorage_GetItemPcResponse(u16 itemId)
static void ItemStorage_PrintItemPcResponse(const u8 *string)
{
u8 windowId = gUnknown_0203BCC4->windowIds[1];
- FillWindowPixelBuffer(windowId, 0x11);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
StringExpandPlaceholders(gStringVar4, string);
AddTextPrinterParameterized(windowId, 1, gStringVar4, 0, 1, 0, NULL);
}
@@ -1170,7 +1170,7 @@ static void ItemStorage_GoBackToPlayerPCMenu_InitStorage(u8 taskId)
data = gTasks[taskId].data;
if (!IsDma3ManagerBusyWithBgCopy())
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
if (!data[3])
InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW);
else
diff --git a/src/poison.c b/src/poison.c
index c86ec2cd8..9af981694 100644
--- a/src/poison.c
+++ b/src/poison.c
@@ -3,8 +3,6 @@
#include "trig.h"
#include "constants/rgb.h"
-extern void sub_80A77C8(struct Sprite *);
-
void sub_810DBAC(struct Sprite *);
void sub_810DC2C(struct Sprite *);
void sub_810DCD0(struct Sprite *);
diff --git a/src/pokeblock.c b/src/pokeblock.c
index 3fd4f34df..2682754aa 100644
--- a/src/pokeblock.c
+++ b/src/pokeblock.c
@@ -665,7 +665,7 @@ static void HandleInitWindows(void)
for (i = 0; i < ARRAY_COUNT(sWindowTemplatesForPokeblockMenu) - 1; i++)
{
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
schedule_bg_copy_tilemap_to_vram(0);
@@ -749,7 +749,7 @@ static void sub_8135FCC(s32 pkblId)
struct Pokeblock *pokeblock;
u16 rectTilemapSrc[2];
- FillWindowPixelBuffer(7, 0);
+ FillWindowPixelBuffer(7, PIXEL_FILL(0));
if (pkblId != LIST_B_PRESSED)
{
@@ -1120,7 +1120,7 @@ static void PutPokeblockOptionsWindow(u8 taskId)
data[1] = 9;
sub_8136418();
- SetWindowBorderStyle(data[1], 0, 1, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(data[1], 0, 1, 0xE);
sub_81995E4(data[1], sPokeblockMenu->optionsNo, sPokeblockMenuActions, sPokeblockMenu->pokeblockOptionsIds);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[1], sPokeblockMenu->optionsNo, 0);
PutWindowTilemap(data[1]);
@@ -1173,7 +1173,7 @@ static void PokeblockAction_Toss(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- sub_8198070(data[1], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[1], FALSE);
StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]);
StringExpandPlaceholders(gStringVar4, gText_ThrowAwayVar1);
DisplayMessageAndContinueTask(taskId, 10, 10, 13, 1, GetPlayerTextSpeedDelay(), gStringVar4, CreateTossPokeblockYesNoMenu);
@@ -1219,7 +1219,7 @@ static void HandleErasePokeblock(u8 taskId)
static void TossPokeblockChoice_No(u8 taskId)
{
- sub_8197DF8(10, FALSE);
+ ClearDialogWindowAndFrameToTransparent(10, FALSE);
schedule_bg_copy_tilemap_to_vram(1);
sub_81363BC();
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
@@ -1266,7 +1266,7 @@ static void PokeblockAction_Cancel(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- sub_8198070(data[1], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[1], FALSE);
schedule_bg_copy_tilemap_to_vram(1);
sub_81363BC();
gTasks[taskId].func = Task_HandlePokeblockMenuInput;
diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c
index b1f182b66..da803f454 100644
--- a/src/pokeblock_feed.c
+++ b/src/pokeblock_feed.c
@@ -55,8 +55,6 @@ extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern const struct CompressedSpriteSheet gMonFrontPicTable[];
extern const u16 gUnknown_0860F074[];
-extern bool8 sub_81221EC(void);
-
// this file's functions
static void HandleInitBackgrounds(void);
static void HandleInitWindows(void);
@@ -581,7 +579,7 @@ static bool8 TransitionToPokeblockFeedScene(void)
gMain.state++;
break;
case 10:
- SetWindowBorderStyle(0, 1, 1, 14);
+ DrawStdFrameWithCustomTileAndPalette(0, 1, 1, 14);
gMain.state++;
break;
case 11:
@@ -704,7 +702,7 @@ static void HandleInitWindows(void)
DeactivateAllTextPrinters();
LoadUserWindowBorderGfx(0, 1, 0xE0);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
schedule_bg_copy_tilemap_to_vram(0);
}
diff --git a/src/pokedex.c b/src/pokedex.c
index 805412c85..4bf8dff6d 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -2152,7 +2152,7 @@ static void CreateCaughtBall(u16 a, u8 x, u8 y, u16 unused)
if (a)
BlitBitmapToWindow(0, gUnknown_0855D2BE, x * 8, y * 8, 8, 16);
else
- FillWindowPixelRect(0, 0, x * 8, y * 8, 8, 16);
+ FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 8, 16);
}
static u8 CreateMonName(u16 num, u8 left, u8 top)
@@ -2170,7 +2170,7 @@ static u8 CreateMonName(u16 num, u8 left, u8 top)
void sub_80BD28C(u8 x, u8 y, u16 unused)
{
- FillWindowPixelRect(0, 0, x * 8, y * 8, 0x60, 16);
+ FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 0x60, 16);
}
static void CreateInitialPokemonSprites(u16 selectedMon, u16 b)
@@ -2927,7 +2927,7 @@ void sub_80BEA24(u8 taskId)
case 1:
DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
PutWindowTilemap(1);
sub_80C0D30(1, sPokedexListItem->dexNum);
@@ -3222,7 +3222,7 @@ void sub_80BF250(u8 taskId)
case 1:
DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, &gPokedexTilemap_CryScreen, 0, 0);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
PutWindowTilemap(3);
PutWindowTilemap(2);
@@ -3416,7 +3416,7 @@ void sub_80BF82C(u8 taskId)
case 1:
DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gPokedexTilemap_SizeScreen, 0, 0);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
gMain.state++;
break;
@@ -3766,7 +3766,7 @@ void sub_80BFE38(u8 taskId)
case 1:
DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0);
CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0);
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
PutWindowTilemap(0);
PutWindowTilemap(1);
sub_80C0D30(1, gTasks[taskId].data[1]);
@@ -4784,7 +4784,7 @@ void sub_80C1270(const u8 *str, u32 left, u32 top)
void sub_80C12B0(u32 x, u32 y, u32 width, u32 height)
{
- FillWindowPixelRect(0, 0, x, y, width, height);
+ FillWindowPixelRect(0, PIXEL_FILL(0), x, y, width, height);
}
void sub_80C12E0(u8 taskId)
diff --git a/src/pokemon.c b/src/pokemon.c
index a35033d49..a984abbb9 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -10,6 +10,7 @@
#include "battle_tower.h"
#include "event_data.h"
#include "evolution_scene.h"
+#include "field_specials.h"
#include "item.h"
#include "link.h"
#include "main.h"
@@ -72,10 +73,6 @@ extern const struct CompressedSpritePalette gMonPaletteTable[];
extern const struct CompressedSpritePalette gMonShinyPaletteTable[];
extern const u8 gTrainerClassNames[][13];
-extern u16 get_unknown_box_id(void);
-extern void set_unknown_box_id(u8);
-extern bool8 sub_806F104(void);
-
// this file's functions
static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon);
static union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 personality, u8 substructType);
diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c
index b0e14d2b1..98d83d8ce 100644
--- a/src/pokemon_size_record.c
+++ b/src/pokemon_size_record.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "event_data.h"
+#include "pokedex.h"
#include "pokemon.h"
#include "pokemon_size_record.h"
#include "string_util.h"
@@ -15,9 +16,6 @@ struct UnknownStruct
u16 unk4;
};
-extern u16 GetPokedexHeightWeight(u16 dexNo, bool8 height);
-extern u16 SpeciesToNationalPokedexNum(u16 species);
-
static const struct UnknownStruct sBigMonSizeTable[] =
{
{ 290, 1, 0 },
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index cdfc4ba6b..c5d40877b 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -1552,7 +1552,7 @@ void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4)
winTemplate.width = 24;
winTemplate.height = 2;
windowId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(windowId, (arg3 << 4) | arg3);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3));
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
tileData2 = (winTemplate.width * 32) + tileData1;
@@ -1599,7 +1599,7 @@ void sub_80C6EAC(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr
winTemplate.height = 2;
var = winTemplate.width * 32;
windowId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(windowId, (arg3 << 4) | arg3);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3));
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
tileData2 = (winTemplate.width * 32) + tileData1;
txtColor[0] = arg3;
@@ -1736,8 +1736,8 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
case 0:
CreatePCMenu(task->data[1], &task->data[15]);
sub_81973A4();
- NewMenuHelpers_DrawDialogueFrame(0, 0);
- FillWindowPixelBuffer(0, 0x11);
+ DrawDialogueFrame(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, TEXT_SPEED_FF, NULL, 2, 1, 3);
CopyWindowToVram(0, 3);
CopyWindowToVram(task->data[15], 3);
@@ -1763,13 +1763,13 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
if (task->data[1] != task->data[3])
{
task->data[1] = task->data[3];
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
}
break;
case MENU_B_PRESSED:
case 4:
- sub_819746C(task->data[15], TRUE);
+ ClearStdWindowAndFrame(task->data[15], TRUE);
ScriptContext2_Disable();
EnableBothScriptContexts();
RemoveWindow(task->data[15]);
@@ -1778,13 +1778,13 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
default:
if (task->data[2] == 0 && CountPartyMons() == PARTY_SIZE)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gText_PartyFull, 0, NULL, 2, 1, 3);
task->data[0] = 3;
}
else if (task->data[2] == 1 && CountPartyMons() == 1)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gText_JustOnePkmn, 0, NULL, 2, 1, 3);
task->data[0] = 3;
}
@@ -1799,7 +1799,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
case 3:
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
}
@@ -1809,7 +1809,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
task->data[1] = 4;
Menu_MoveCursor(-1);
task->data[1] = Menu_GetCursorPos();
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
}
@@ -1819,7 +1819,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
task->data[1] = 0;
Menu_MoveCursor(1);
task->data[1] = Menu_GetCursorPos();
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3);
task->data[0] = 2;
}
@@ -1865,7 +1865,7 @@ static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr)
winTemplate.width = GetMaxWidthInMenuTable((void *)gUnknown_085716C0, ARRAY_COUNT(gUnknown_085716C0));
windowId = AddWindow(&winTemplate);
- NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE);
+ DrawStdWindowFrame(windowId, FALSE);
PrintMenuTable(windowId, ARRAY_COUNT(gUnknown_085716C0), (void *)gUnknown_085716C0);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, ARRAY_COUNT(gUnknown_085716C0), whichMenu);
*windowIdPtr = windowId;
@@ -2103,7 +2103,7 @@ static void sub_80C7BE4(void)
winTemplate.height = 4;
windowId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(windowId, 0x44);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
center = GetStringCenterAlignXOffset(1, boxName, 64);
AddTextPrinterParameterized3(windowId, 1, center, 1, gUnknown_08571734, TEXT_SPEED_FF, boxName);
@@ -4107,7 +4107,7 @@ static void LoadCursorMonGfx(u16 species, u32 pid)
static void PrintCursorMonInfo(void)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS)
{
AddTextPrinterParameterized(0, 1, sPSSData->cursorMonNickText, 6, 0, TEXT_SPEED_FF, NULL);
@@ -4416,7 +4416,7 @@ static void PrintStorageActionText(u8 id)
}
DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, gPCStorageActionTexts[id].text);
- FillWindowPixelBuffer(1, 0x11);
+ FillWindowPixelBuffer(1, PIXEL_FILL(1));
AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 0, 1, TEXT_SPEED_FF, NULL);
sub_8098858(1, 2, 14);
PutWindowTilemap(1);
@@ -4432,7 +4432,7 @@ static void ShowYesNoWindow(s8 cursorPos)
static void ClearBottomWindow(void)
{
- sub_8198070(1, FALSE);
+ ClearStdWindowAndFrameToTransparent(1, FALSE);
schedule_bg_copy_tilemap_to_vram(0);
}
@@ -6501,7 +6501,7 @@ static void InitCanRelaseMonVars(void)
}
sub_80CE350(sPSSData->field_2176);
- sPSSData->field_2174 = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ sPSSData->field_2174 = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176);
if (sPSSData->field_2174 != 0)
{
sPSSData->field_216D = 0;
@@ -6559,7 +6559,7 @@ static s8 RunCanReleaseMon(void)
{
if (sPSSData->field_2170 != TOTAL_BOXES_COUNT || sPSSData->field_2171 != i)
{
- knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176);
sPSSData->field_2174 &= ~(knownMoves);
}
}
@@ -6578,7 +6578,7 @@ static s8 RunCanReleaseMon(void)
case 1:
for (i = 0; i < IN_BOX_COUNT; i++)
{
- knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, sPSSData->field_2176);
+ knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176);
if (knownMoves != 0
&& !(sPSSData->field_2170 == sPSSData->field_216E && sPSSData->field_2171 == sPSSData->field_216F))
{
@@ -8733,7 +8733,7 @@ static void AddMenu(void)
sPSSData->menuWindow.tilemapTop = 15 - sPSSData->menuWindow.height;
sPSSData->field_CB0 = AddWindow(&sPSSData->menuWindow);
ClearWindowTilemap(sPSSData->field_CB0);
- SetWindowBorderStyle(sPSSData->field_CB0, FALSE, 11, 14);
+ DrawStdFrameWithCustomTileAndPalette(sPSSData->field_CB0, FALSE, 11, 14);
PrintMenuTable(sPSSData->field_CB0, sPSSData->menuItemsCount, (void*)sPSSData->menuItems);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sPSSData->field_CB0, sPSSData->menuItemsCount, 0);
schedule_bg_copy_tilemap_to_vram(0);
@@ -8787,7 +8787,7 @@ static s16 sub_80D00AC(void)
static void sub_80D013C(void)
{
- sub_8198070(sPSSData->field_CB0, TRUE);
+ ClearStdWindowAndFrameToTransparent(sPSSData->field_CB0, TRUE);
RemoveWindow(sPSSData->field_CB0);
}
@@ -8835,7 +8835,7 @@ static bool8 sub_80D0164(void)
sPSSData->field_2200 = AddWindow8Bit(&gUnknown_0857BB1C);
if (sPSSData->field_2200 != 0xFF)
{
- FillWindowPixelBuffer(sPSSData->field_2200, 0);
+ FillWindowPixelBuffer(sPSSData->field_2200, PIXEL_FILL(0));
return TRUE;
}
}
@@ -8892,7 +8892,7 @@ static bool8 sub_80D024C(void)
ChangeBgX(0, -1024, 0);
ChangeBgY(0, -1024, 0);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
- FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0);
+ FillWindowPixelBuffer8Bit(sPSSData->field_2200, PIXEL_FILL(0));
sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn);
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
PutWindowTilemap(sPSSData->field_2200);
@@ -9194,7 +9194,7 @@ static void sub_80D0834(u8 arg0, u8 arg1)
if (species != SPECIES_NONE)
{
FillWindowPixelRect8Bit(sPSSData->field_2200,
- 0,
+ PIXEL_FILL(0),
24 * arg0,
24 * arg1,
32,
@@ -9911,7 +9911,7 @@ static void PrintItemDescription(void)
else
description = ItemId_GetDescription(sPSSData->cursorMonItem);
- FillWindowPixelBuffer(2, 0x11);
+ FillWindowPixelBuffer(2, PIXEL_FILL(1));
AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1);
}
@@ -10357,7 +10357,7 @@ bool32 AnyStorageMonWithMove(u16 moveId)
{
if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
&& !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG)
- && GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_KNOWN_MOVES, moves))
+ && GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_KNOWN_MOVES, (u8*)moves))
return TRUE;
}
}
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index bd1ae7802..0133e40f1 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -1349,7 +1349,7 @@ static bool8 ExtractMonDataToSummaryStruct(struct Pokemon *a)
}
break;
case 3:
- GetMonData(a, MON_DATA_OT_NAME, &sum->OTName);
+ GetMonData(a, MON_DATA_OT_NAME, sum->OTName);
ConvertInternationalString((u8*)&sum->OTName, GetMonData(a, MON_DATA_LANGUAGE));
sum->unk7 = sub_81B205C(a);
sum->OTGender = GetMonData(a, MON_DATA_OT_GENDER);
@@ -2629,7 +2629,7 @@ static void ResetWindows(void)
for (i = 0; i < 20; i++)
{
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
for (i = 0; i < ARRAY_COUNT(pssData->windowIds); i++)
{
@@ -2644,9 +2644,9 @@ static void SummaryScreen_PrintTextOnWindow(u8 windowId, const u8 *string, u8 x,
static void sub_81C25E8(void)
{
- FillWindowPixelBuffer(17, 0);
- FillWindowPixelBuffer(18, 0);
- FillWindowPixelBuffer(19, 0);
+ FillWindowPixelBuffer(17, PIXEL_FILL(0));
+ FillWindowPixelBuffer(18, PIXEL_FILL(0));
+ FillWindowPixelBuffer(19, PIXEL_FILL(0));
if (!pssData->summary.isEgg)
sub_81C2628();
else
@@ -2898,7 +2898,7 @@ static u8 AddWindowFromTemplateList(const struct WindowTemplate *template, u8 te
if (*windowIdPtr == 0xFF)
{
*windowIdPtr = AddWindow(&template[templateId]);
- FillWindowPixelBuffer(*windowIdPtr, 0);
+ FillWindowPixelBuffer(*windowIdPtr, PIXEL_FILL(0));
}
return *windowIdPtr;
}
@@ -2920,7 +2920,7 @@ static void PrintPageSpecificText(u8 pageIndex)
for (i = 0; i < ARRAY_COUNT(pssData->windowIds); i++)
{
if (pssData->windowIds[i] != 0xFF)
- FillWindowPixelBuffer(pssData->windowIds[i], 0);
+ FillWindowPixelBuffer(pssData->windowIds[i], PIXEL_FILL(0));
}
sTextPrinterFunctions[pageIndex]();
}
@@ -3469,7 +3469,7 @@ static void PrintMovePowerAndAccuracy(u16 moveIndex)
const u8 *text;
if (moveIndex != 0)
{
- FillWindowPixelRect(14, 0, 53, 0, 19, 32);
+ FillWindowPixelRect(14, PIXEL_FILL(0), 53, 0, 19, 32);
if (gBattleMoves[moveIndex].power < 2)
{
@@ -3567,7 +3567,7 @@ static void PrintContestMoveDescription(u8 moveSlot)
static void PrintMoveDetails(u16 move)
{
u8 windowId = AddWindowFromTemplateList(sPageMovesTemplate, 2);
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
if (move != MOVE_NONE)
{
if (pssData->currPageIndex == 2)
@@ -3619,7 +3619,7 @@ static void PrintNewMoveDetailsOrCancelText(void)
static void sub_81C4064(void)
{
u8 windowId = AddWindowFromTemplateList(sPageMovesTemplate, 0);
- FillWindowPixelRect(windowId, 0, 0, 66, 72, 16);
+ FillWindowPixelRect(windowId, PIXEL_FILL(0), 0, 66, 72, 16);
CopyWindowToVram(windowId, 2);
}
@@ -3628,11 +3628,11 @@ static void sub_81C40A0(u8 moveIndex1, u8 moveIndex2)
u8 windowId1 = AddWindowFromTemplateList(sPageMovesTemplate, 0);
u8 windowId2 = AddWindowFromTemplateList(sPageMovesTemplate, 1);
- FillWindowPixelRect(windowId1, 0, 0, moveIndex1 * 16, 0x48, 0x10);
- FillWindowPixelRect(windowId1, 0, 0, moveIndex2 * 16, 0x48, 0x10);
+ FillWindowPixelRect(windowId1, PIXEL_FILL(0), 0, moveIndex1 * 16, 0x48, 0x10);
+ FillWindowPixelRect(windowId1, PIXEL_FILL(0), 0, moveIndex2 * 16, 0x48, 0x10);
- FillWindowPixelRect(windowId2, 0, 0, moveIndex1 * 16, 0x30, 0x10);
- FillWindowPixelRect(windowId2, 0, 0, moveIndex2 * 16, 0x30, 0x10);
+ FillWindowPixelRect(windowId2, PIXEL_FILL(0), 0, moveIndex1 * 16, 0x30, 0x10);
+ FillWindowPixelRect(windowId2, PIXEL_FILL(0), 0, moveIndex2 * 16, 0x30, 0x10);
PrintMoveNameAndPP(moveIndex1);
PrintMoveNameAndPP(moveIndex2);
@@ -3641,7 +3641,7 @@ static void sub_81C40A0(u8 moveIndex1, u8 moveIndex2)
static void PrintHMMovesCantBeForgotten(void)
{
u8 windowId = AddWindowFromTemplateList(sPageMovesTemplate, 2);
- FillWindowPixelBuffer(windowId, 0);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
SummaryScreen_PrintTextOnWindow(windowId, gText_HMMovesCantBeForgotten2, 6, 1, 0, 0);
}
diff --git a/src/pokenav.c b/src/pokenav.c
index d09c3da94..42114a4b2 100644
--- a/src/pokenav.c
+++ b/src/pokenav.c
@@ -141,7 +141,7 @@ void sub_81C7710(void);
static void InitKeys_(void);
static void FreeVars(void);
static void VblankCb_Pokenav(void);
-static void Cb2_Pokenav(void);
+static void CB2_Pokenav(void);
void sub_81C7C28(void);
void sub_81C72BC(void);
void sub_81C7B74(void);
@@ -388,7 +388,7 @@ u32 sub_81C7078(u32 (*func)(s32), u32 priority)
{
u16 taskId;
- if (!is_c1_link_related_active())
+ if (!IsUpdateLinkStateCBActive())
taskId = CreateTask(sub_81C7170, priority);
else
taskId = CreateTask(sub_81C71E4, priority);
@@ -485,7 +485,7 @@ void sub_81C71E4(u8 taskId)
}
}
-void CB2_PokeNav(void)
+void CB2_InitPokeNav(void)
{
gUnknown_0203CF40 = Alloc(sizeof(*gUnknown_0203CF40));
if (gUnknown_0203CF40 == NULL)
@@ -498,7 +498,7 @@ void CB2_PokeNav(void)
ResetTasks();
SetVBlankCallback(NULL);
CreateTask(sub_81C742C, 0);
- SetMainCallback2(Cb2_Pokenav);
+ SetMainCallback2(CB2_Pokenav);
SetVBlankCallback(VblankCb_Pokenav);
}
}
@@ -529,7 +529,7 @@ void sub_81C72BC(void)
FreeAllSpritePalettes();
SetVBlankCallback(NULL);
CreateTask(sub_81C742C, 0);
- SetMainCallback2(Cb2_Pokenav);
+ SetMainCallback2(CB2_Pokenav);
SetVBlankCallback(VblankCb_Pokenav);
}
}
@@ -588,7 +588,7 @@ static bool32 AnyMonHasRibbon(void)
return FALSE;
}
-static void Cb2_Pokenav(void)
+static void CB2_Pokenav(void)
{
RunTasks();
AnimateSprites();
@@ -1138,8 +1138,8 @@ bool32 IsDma3ManagerBusyWithBgCopy_(void)
void sub_81C7BF8(u32 windowId)
{
- FillWindowPixelBuffer(windowId, 0x44);
- FillWindowPixelRect(windowId, 0x55, 0, 0, 0x80, 1);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
+ FillWindowPixelRect(windowId, PIXEL_FILL(5), 0, 0, 0x80, 1);
}
void sub_81C7C28(void)
diff --git a/src/pokenav_match_call.c b/src/pokenav_match_call.c
index 53f9f0548..b775ed10e 100644
--- a/src/pokenav_match_call.c
+++ b/src/pokenav_match_call.c
@@ -1,13 +1,11 @@
-
-// Includes
#include "global.h"
#include "battle_setup.h"
#include "event_data.h"
#include "string_util.h"
#include "battle.h"
#include "gym_leader_rematch.h"
+#include "match_call.h"
-extern void sub_8197080(u8 *dest);
extern const u8 gTrainerClassNames[][13];
// Static type declarations
diff --git a/src/record_mixing.c b/src/record_mixing.c
index c0ca5f19c..3a16f817e 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -34,9 +34,8 @@
#include "daycare.h"
#include "international_string_util.h"
#include "constants/battle_frontier.h"
+#include "dewford_trend.h"
-extern void ReceiveSecretBasesData(struct SecretBaseRecord *, size_t, u8);
-extern void ReceiveEasyChatPairsData(struct EasyChatPair *, size_t, u8);
// Static type declarations
@@ -106,7 +105,7 @@ static EWRAM_DATA union PlayerRecords *sSentRecord = NULL;
// Static ROM declarations
static void Task_RecordMixing_Main(u8 taskId);
-static void sub_80E7324(u8 taskId);
+static void Task_MixingRecordsRecv(u8 taskId);
static void Task_SendPacket(u8 taskId);
static void Task_CopyReceiveBuffer(u8 taskId);
static void Task_SendPacket_SwitchToReceive(u8 taskId);
@@ -120,7 +119,7 @@ static void ReceiveLilycoveLadyData(LilycoveLady *, size_t, u8);
static void sub_80E7B2C(const u8 *);
static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *, size_t, u8, TVShow *);
static void ReceiveGiftItem(u16 *item, u8 which);
-static void sub_80E7FF8(u8 taskId);
+static void Task_DoRecordMixing(u8 taskId);
static void sub_80E8110(struct Apprentice *arg0, struct Apprentice *arg1);
static void ReceiveApprenticeData(struct Apprentice *arg0, size_t arg1, u32 arg2);
static void ReceiveRankingHallRecords(struct PlayerHallRecords *hallRecords, size_t arg1, u32 arg2);
@@ -170,7 +169,8 @@ static const u8 gUnknown_0858CFBE[3][4] =
#define BUFFER_CHUNK_SIZE 200
-void sub_80E6BE8(void)
+// Note: VAR_0x8005 contains the spotId.
+void RecordMixingPlayerSpotTriggered(void)
{
sub_80B37D4(Task_RecordMixing_Main);
}
@@ -292,7 +292,7 @@ static void ReceiveExchangePacket(u32 which)
static void PrintTextOnRecordMixing(const u8 *src)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, src, 0, 1, 0, NULL);
CopyWindowToVram(0, 3);
}
@@ -313,6 +313,7 @@ static void Task_RecordMixing_SoundEffect(u8 taskId)
#define tState data[0]
#define tSndEffTaskId data[15]
+// Note: Currently, special var 8005 contains the player's spot id.
static void Task_RecordMixing_Main(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@@ -322,16 +323,16 @@ static void Task_RecordMixing_Main(u8 taskId)
case 0: // init
sSentRecord = malloc(sizeof(union PlayerRecords));
sReceivedRecords = malloc(sizeof(union PlayerRecords) * 4);
- sub_8009628(gSpecialVar_0x8005);
+ SetLocalLinkPlayerId(gSpecialVar_0x8005);
VarSet(VAR_TEMP_0, 1);
gUnknown_03001130 = FALSE;
PrepareExchangePacket();
CreateRecordMixingSprite();
tState = 1;
- data[10] = CreateTask(sub_80E7324, 80);
+ data[10] = CreateTask(Task_MixingRecordsRecv, 80);
tSndEffTaskId = CreateTask(Task_RecordMixing_SoundEffect, 81);
break;
- case 1: // wait for sub_80E7324
+ case 1: // wait for Task_MixingRecordsRecv
if (!gTasks[data[10]].isActive)
{
tState = 2;
@@ -341,11 +342,11 @@ static void Task_RecordMixing_Main(u8 taskId)
}
break;
case 2:
- data[10] = CreateTask(sub_80E7FF8, 10);
+ data[10] = CreateTask(Task_DoRecordMixing, 10);
tState = 3;
PlaySE(SE_W226);
break;
- case 3: // wait for sub_80E7FF8
+ case 3: // wait for Task_DoRecordMixing
if (!gTasks[data[10]].isActive)
{
tState = 4;
@@ -370,7 +371,7 @@ static void Task_RecordMixing_Main(u8 taskId)
{
CreateTask(sub_80AF2B4, 10);
}
- sub_8197434(0, 1);
+ ClearDialogWindowAndFrame(0, 1);
DestroyTask(taskId);
EnableBothScriptContexts();
}
@@ -381,7 +382,7 @@ static void Task_RecordMixing_Main(u8 taskId)
#undef tState
#undef tSndEffTaskId
-static void sub_80E7324(u8 taskId)
+static void Task_MixingRecordsRecv(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@@ -405,7 +406,7 @@ static void sub_80E7324(u8 taskId)
u8 players = GetLinkPlayerCount_2();
if (IsLinkMaster() == TRUE)
{
- if (players == sub_800AA48())
+ if (players == GetSavedPlayerCount())
{
PlaySE(SE_PIN);
task->data[0] = 201;
@@ -420,14 +421,15 @@ static void sub_80E7324(u8 taskId)
}
break;
case 201:
- if (sub_800AA48() == GetLinkPlayerCount_2() && ++task->data[12] > (GetLinkPlayerCount_2() * 30))
+ // We're the link master. Delay for 30 frames per connected player.
+ if (GetSavedPlayerCount() == GetLinkPlayerCount_2() && ++task->data[12] > (GetLinkPlayerCount_2() * 30))
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
task->data[0] = 1;
}
break;
case 301:
- if (sub_800AA48() == GetLinkPlayerCount_2())
+ if (GetSavedPlayerCount() == GetLinkPlayerCount_2())
task->data[0] = 1;
break;
case 400: // wait 20 frames
@@ -470,6 +472,7 @@ static void sub_80E7324(u8 taskId)
StorePtrInTaskData(sReceivedRecords, (u16 *)&gTasks[subTaskId].data[5]);
sRecordStructSize = sizeof(struct PlayerRecordsEmerald);
}
+ // Note: This task is destroyed by Task_CopyReceiveBuffer when it's done.
}
break;
case 5: // wait 60 frames
@@ -938,7 +941,7 @@ static void ReceiveGiftItem(u16 *item, u8 which)
}
}
-static void sub_80E7FF8(u8 taskId)
+static void Task_DoRecordMixing(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@@ -953,20 +956,22 @@ static void sub_80E7FF8(u8 taskId)
else
task->data[0] = 6;
break;
+
+ // Mixing Ruby/Sapphire records.
case 2:
SetContinueGameWarpStatusToDynamicWarp();
- sub_8153430();
+ FullSaveGame();
task->data[0] ++;
break;
case 3:
- if (sub_8153474())
+ if (CheckSaveFile())
{
ClearContinueGameWarpStatus2();
task->data[0] = 4;
task->data[1] = 0;
}
break;
- case 4:
+ case 4: // Wait 10 frames
if (++task->data[1] > 10)
{
sub_800AC34();
@@ -974,22 +979,24 @@ static void sub_80E7FF8(u8 taskId)
}
break;
case 5:
- if (gReceivedRemoteLinkPlayers == 0)
+ if (gReceivedRemoteLinkPlayers == FALSE)
DestroyTask(taskId);
break;
+
+ // Mixing Emerald records.
case 6:
- if (!sub_801048C(0))
+ if (!sub_801048C(FALSE))
{
CreateTask(sub_8153688, 5);
task->data[0] ++;
}
break;
- case 7:
+ case 7: // wait for sub_8153688 to finish.
if (!FuncIsActiveTask(sub_8153688))
{
if (gWirelessCommType)
{
- sub_801048C(1);
+ sub_801048C(TRUE);
task->data[0] = 8;
}
else
diff --git a/src/region_map.c b/src/region_map.c
index ff0c19167..8dadc78a7 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -883,7 +883,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
case MAP_TYPE_CITY:
case MAP_TYPE_ROUTE:
case MAP_TYPE_UNDERWATER:
- case MAP_TYPE_6:
+ case MAP_TYPE_OCEAN_ROUTE:
gRegionMap->mapSecId = gMapHeader.regionMapSectionId;
gRegionMap->playerIsInCave = FALSE;
mapWidth = gMapHeader.mapLayout->width;
@@ -896,7 +896,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
}
break;
case MAP_TYPE_UNDERGROUND:
- case MAP_TYPE_7:
+ case MAP_TYPE_UNUSED_2:
if (gMapHeader.flags & 0x02)
{
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->escapeWarp.mapGroup, gSaveBlock1Ptr->escapeWarp.mapNum);
@@ -1159,7 +1159,7 @@ static u16 RegionMap_GetTerraCaveMapSecId(void)
{
s16 idx;
- idx = VarGet(VAR_0x4037) - 1;
+ idx = VarGet(VAR_UNUSUAL_WEATHER_LOCATION) - 1;
if (idx < 0 || idx > 15)
{
idx = 0;
@@ -1171,7 +1171,7 @@ static void RegionMap_GetMarineCaveCoords(u16 *x, u16 *y)
{
u16 idx;
- idx = VarGet(VAR_0x4037);
+ idx = VarGet(VAR_UNUSUAL_WEATHER_LOCATION);
if (idx < 9 || idx > 16)
{
idx = 9;
@@ -1622,7 +1622,7 @@ void MCB2_FlyMap(void)
case 7:
LoadPalette(sRegionMapFramePal, 0x10, 0x20);
PutWindowTilemap(2);
- FillWindowPixelBuffer(2, 0x00);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized(2, 1, gText_FlyToWhere, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
gMain.state++;
@@ -1687,8 +1687,8 @@ static void sub_8124904(void)
{
StringLength(gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec]);
flag = TRUE;
- sub_8198070(0, FALSE);
- SetWindowBorderStyle(1, FALSE, 0x65, 0x0d);
+ ClearStdWindowAndFrameToTransparent(0, FALSE);
+ DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x65, 0x0d);
AddTextPrinterParameterized(1, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
name = gUnknown_085A1EDC[i].name[sFlyMap->regionMap.posWithinMapSec];
AddTextPrinterParameterized(1, 1, name, GetStringRightAlignXOffset(1, name, 0x60), 0x11, 0, NULL);
@@ -1702,12 +1702,12 @@ static void sub_8124904(void)
{
if (gUnknown_03001180 == TRUE)
{
- sub_8198070(1, FALSE);
- SetWindowBorderStyle(0, FALSE, 0x65, 0x0d);
+ ClearStdWindowAndFrameToTransparent(1, FALSE);
+ DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x65, 0x0d);
}
else
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
}
AddTextPrinterParameterized(0, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
@@ -1718,10 +1718,10 @@ static void sub_8124904(void)
{
if (gUnknown_03001180 == TRUE)
{
- sub_8198070(1, FALSE);
- SetWindowBorderStyle(0, FALSE, 0x65, 0x0d);
+ ClearStdWindowAndFrameToTransparent(1, FALSE);
+ DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x65, 0x0d);
}
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, 2);
schedule_bg_copy_tilemap_to_vram(0);
gUnknown_03001180 = FALSE;
diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c
index 34444cbf4..ce9f5b98b 100644
--- a/src/reset_rtc_screen.c
+++ b/src/reset_rtc_screen.c
@@ -290,7 +290,7 @@ static void FreeCursorPalette(void)
static void HideChooseTimeWindow(u8 windowId)
{
- sub_8198070(windowId, FALSE);
+ ClearStdWindowAndFrameToTransparent(windowId, FALSE);
RemoveWindow(windowId);
schedule_bg_copy_tilemap_to_vram(0);
}
@@ -319,7 +319,7 @@ static void PrintTime(u8 windowId, u8 x, u8 y, u16 days, u8 hours, u8 minutes, u
static void ShowChooseTimeWindow(u8 windowId, u16 days, u8 hours, u8 minutes, u8 seconds)
{
- SetWindowBorderStyle(windowId, FALSE, 0x214, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x214, 0xE);
PrintTime(windowId, 0, 1, days, hours, minutes, seconds);
AddTextPrinterParameterized(windowId, 1, gText_Confirm2, 126, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
@@ -495,7 +495,7 @@ static void VBlankCB(void)
static void ShowMessage(const u8 *str)
{
- sub_8197B1C(1, FALSE, 0x200, 0xF);
+ DrawDialogFrameWithCustomTileAndPalette(1, FALSE, 0x200, 0xF);
AddTextPrinterParameterized(1, 1, str, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
}
@@ -507,7 +507,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId)
switch (data[0])
{
case 0:
- SetWindowBorderStyle(0, FALSE, 0x214, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x214, 0xE);
AddTextPrinterParameterized(0, 1, gText_PresentTime, 0, 1, TEXT_SPEED_FF, 0);
PrintTime(
0,
@@ -574,7 +574,7 @@ static void Task_ResetRtcScreen(u8 taskId)
case 2:
if (gTasks[data[1]].isActive != TRUE)
{
- sub_8198070(0, FALSE);
+ ClearStdWindowAndFrameToTransparent(0, FALSE);
ShowMessage(gText_PleaseResetTime);
gLocalTime = gSaveBlock2Ptr->lastBerryTreeUpdate;
data[1] = CreateTask(Task_ResetRtc_0, 80);
diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c
index 0926d4569..dd177f884 100644
--- a/src/reshow_battle_screen.c
+++ b/src/reshow_battle_screen.c
@@ -2,6 +2,7 @@
#include "reshow_battle_screen.h"
#include "battle.h"
#include "palette.h"
+#include "pokemon.h"
#include "main.h"
#include "scanline_effect.h"
#include "text.h"
@@ -18,8 +19,6 @@
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
-extern void SetMultiuseSpriteTemplateToTrainerBack(u16 backPicId, u8 battlerPosition);
-
// this file's functions
static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBattlerSpriteGfx(u8 battlerId);
diff --git a/src/rock.c b/src/rock.c
index 14ffc63e0..814b1d88b 100644
--- a/src/rock.c
+++ b/src/rock.c
@@ -12,8 +12,6 @@
extern const union AnimCmd *const gUnknown_085950E0[];
extern const union AnimCmd *const gUnknown_085954D0[];
-extern void AnimMoveTwisterParticle(struct Sprite *);
-
void sub_81109F0(struct Sprite *);
void sub_8110AB4(struct Sprite *);
void AnimDirtParticleAcrossScreen(struct Sprite *);
diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c
index c8adfbe0b..3d9eab8d7 100644
--- a/src/rom_8011DC0.c
+++ b/src/rom_8011DC0.c
@@ -33,8 +33,7 @@
#include "start_menu.h"
#include "data2.h"
#include "field_screen_effect.h"
-
-extern void HealPlayerParty(void);
+#include "script_pokemon_util_80F87D8.h"
struct UnkStruct_Shared
{
@@ -188,7 +187,7 @@ extern u8 gUnknown_02022C3E;
extern u16 gUnknown_02022C3C;
extern u8 gUnknown_02022C20[];
extern u8 gFieldLinkPlayerCount;
-extern u8 gUnknown_03005DB4;
+extern u8 gLocalLinkPlayerId;
// IWRAM vars
IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0;
@@ -387,7 +386,7 @@ void nullsub_89(void)
void sub_80124EC(u8 windowId, u8 arg1, u8 stringId)
{
- FillWindowPixelBuffer(windowId, 0x11);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
switch (arg1 << 8)
{
case 0x200:
@@ -506,17 +505,17 @@ void sub_8012780(u8 taskId)
}
data->field_11 = AddWindow(&gUnknown_082F012C);
- FillWindowPixelBuffer(data->field_10, 0x22);
+ FillWindowPixelBuffer(data->field_10, PIXEL_FILL(2));
sub_80173E0(data->field_10, 0, gUnknown_082EDBC4, 8, 1, 4);
PutWindowTilemap(data->field_10);
CopyWindowToVram(data->field_10, 2);
- NewMenuHelpers_DrawStdWindowFrame(data->listWindowId, FALSE);
+ DrawStdWindowFrame(data->listWindowId, FALSE);
gMultiuseListMenuTemplate = gUnknown_082F015C;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- NewMenuHelpers_DrawStdWindowFrame(data->field_11, FALSE);
+ DrawStdWindowFrame(data->field_11, FALSE);
PutWindowTilemap(data->field_11);
CopyWindowToVram(data->field_11, 2);
@@ -786,10 +785,10 @@ void sub_8012780(u8 taskId)
void sub_8012F64(struct UnkStruct_Leader *data)
{
ClearWindowTilemap(data->field_11);
- sub_819746C(data->field_11, FALSE);
+ ClearStdWindowAndFrame(data->field_11, FALSE);
DestroyListMenuTask(data->listTaskId, 0, 0);
ClearWindowTilemap(data->field_10);
- sub_819746C(data->listWindowId, FALSE);
+ ClearStdWindowAndFrame(data->listWindowId, FALSE);
CopyBgTilemapBufferToVram(0);
RemoveWindow(data->field_11);
RemoveWindow(data->listWindowId);
@@ -1075,17 +1074,17 @@ void sub_80134E8(u8 taskId)
data->listWindowId = AddWindow(&gUnknown_082F0174);
data->field_D = AddWindow(&gUnknown_082F017C);
- FillWindowPixelBuffer(data->field_C, 0x22);
+ FillWindowPixelBuffer(data->field_C, PIXEL_FILL(2));
sub_80173E0(data->field_C, 0, gUnknown_082EF7DC, 8, 1, 4);
PutWindowTilemap(data->field_C);
CopyWindowToVram(data->field_C, 2);
- NewMenuHelpers_DrawStdWindowFrame(data->listWindowId, FALSE);
+ DrawStdWindowFrame(data->listWindowId, FALSE);
gMultiuseListMenuTemplate = gUnknown_082F0204;
gMultiuseListMenuTemplate.windowId = data->listWindowId;
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
- NewMenuHelpers_DrawStdWindowFrame(data->field_D, FALSE);
+ DrawStdWindowFrame(data->field_D, FALSE);
PutWindowTilemap(data->field_D);
sub_80125BC(data->field_D);
CopyWindowToVram(data->field_D, 2);
@@ -1254,10 +1253,10 @@ void sub_80134E8(u8 taskId)
case 18:
case 20:
ClearWindowTilemap(data->field_D);
- sub_819746C(data->field_D, FALSE);
+ ClearStdWindowAndFrame(data->field_D, FALSE);
DestroyListMenuTask(data->listTaskId, 0, 0);
ClearWindowTilemap(data->field_C);
- sub_819746C(data->listWindowId, FALSE);
+ ClearStdWindowAndFrame(data->listWindowId, FALSE);
CopyBgTilemapBufferToVram(0);
RemoveWindow(data->field_D);
RemoveWindow(data->listWindowId);
@@ -1641,7 +1640,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
gSpecialVar_0x8004 = arg4;
VarSet(VAR_CABLE_CLUB_STATE, arg4);
gFieldLinkPlayerCount = GetLinkPlayerCount();
- gUnknown_03005DB4 = GetMultiplayerId();
+ gLocalLinkPlayerId = GetMultiplayerId();
SetCableClubWarp();
SetWarpDestination(mapGroup, mapNum, -1, x, y);
WarpIntoMap();
@@ -1697,7 +1696,7 @@ void sub_801440C(u8 taskId)
case 81:
CleanupOverworldWindowsAndTilemaps();
gMain.savedCallback = sub_801AC54;
- sub_81B8518(3);
+ InitChooseHalfPartyForBattle(3);
break;
case 1:
CleanupOverworldWindowsAndTilemaps();
@@ -2155,7 +2154,7 @@ void sub_8014F48(u8 taskId)
data->listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
sub_8018784(data->field_D);
- FillWindowPixelBuffer(data->field_D, 0x11);
+ FillWindowPixelBuffer(data->field_D, PIXEL_FILL(1));
PutWindowTilemap(data->field_D);
sub_80125BC(data->field_D);
CopyWindowToVram(data->field_D, 2);
diff --git a/src/roulette.c b/src/roulette.c
index 4c20bd0fe..05d5006f0 100644
--- a/src/roulette.c
+++ b/src/roulette.c
@@ -973,7 +973,7 @@ static void sub_81405CC(void)
sub_814372C(6);
sub_81436D0(0);
sub_81424FC(0);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5B89, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
gSpriteCoordOffsetX = -60;
@@ -1043,8 +1043,8 @@ static void sub_81408A8(u8 taskId)
static void sub_8140914(u8 taskId)
{
- DisplayYesNoMenu();
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, 0);
+ DisplayYesNoMenuDefaultYes();
+ DrawStdWindowFrame(gUnknown_0203AB8C, 0);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5C13, 0, 1, TEXT_SPEED_FF, 0);
CopyWindowToVram(gUnknown_0203AB8C, 3);
DoYesNoFuncWithChoice(taskId, &gUnknown_085B6410);
@@ -1052,7 +1052,7 @@ static void sub_8140914(u8 taskId)
static void sub_8140968(u8 taskId)
{
- sub_819746C(0, TRUE);
+ ClearStdWindowAndFrame(0, TRUE);
gTasks[taskId].func = sub_8140BD0;
}
@@ -1808,14 +1808,14 @@ static void sub_814189C(u8 taskId)
if (gTasks[taskId].data[2] == 12)
{
PlayFanfare(MUS_ME_B_BIG);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5BD7, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
}
else
{
PlayFanfare(MUS_ME_B_SMALL);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5BCB, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
}
@@ -1823,7 +1823,7 @@ static void sub_814189C(u8 taskId)
case 0:
default:
m4aSongNumStart(SE_HAZURE);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5BE0, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
break;
@@ -1867,7 +1867,7 @@ static void sub_8141A18(u8 taskId)
{
ConvertIntToDecimalStringN(gStringVar1, (gUnknown_0203AB88->var19 * gTasks[taskId].data[2]), STR_CONV_MODE_LEFT_ALIGN, 2);
StringExpandPlaceholders(gStringVar4, gUnknown_082A5BEF);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
gTasks[taskId].data[1] = (gUnknown_0203AB88->var19 * gTasks[taskId].data[2]);
@@ -1900,14 +1900,14 @@ static void sub_8141B58(u8 taskId)
{
if (gTasks[taskId].data[6] == 6)
{
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5C21, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
sub_8141F7C(taskId, dp01t_12_3_battle_menu, 0xFFFF, 3);
}
else if (gTasks[taskId].data[13] == 9999)
{
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5C61, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
sub_8141F7C(taskId, sub_8140914, 0xFFFF, 0x3);
@@ -1919,7 +1919,7 @@ static void sub_8141B58(u8 taskId)
}
else
{
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5C04, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
sub_8141F7C(taskId, sub_8140994, 0x3C, 0x3);
@@ -1944,7 +1944,7 @@ static void dp01t_12_3_battle_menu(u8 taskId)
if (gTasks[taskId].data[13] == 9999)
{
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
+ DrawStdWindowFrame(gUnknown_0203AB8C, FALSE);
AddTextPrinterParameterized(gUnknown_0203AB8C, 1, gUnknown_082A5C61, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(gUnknown_0203AB8C, 3);
sub_8141F7C(taskId, sub_8140914, 0xFFFF, 3);
@@ -3256,7 +3256,7 @@ static const struct SpriteTemplate gUnknown_085B7AEC =
static void sub_81428C4(u8 r0)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(r0, &gUnknown_085B6408);
}
@@ -3272,7 +3272,7 @@ static void sub_81428E4(u8 taskId)
static void sub_8142918(u8 taskId)
{
- sub_819746C(0, TRUE);
+ ClearStdWindowAndFrame(0, TRUE);
HideCoinsWindow();
FreeAllWindowBuffers();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
@@ -3283,7 +3283,7 @@ static void sub_8142918(u8 taskId)
static void sub_814297C(u8 taskId)
{
- sub_819746C(0, FALSE);
+ ClearStdWindowAndFrame(0, FALSE);
HideCoinsWindow();
ScriptContext2_Disable();
DestroyTask(taskId);
@@ -3296,7 +3296,7 @@ static void sub_81429A0(u8 taskId)
{
gSpecialVar_0x8004 = 1;
HideCoinsWindow();
- sub_819746C(0, TRUE);
+ ClearStdWindowAndFrame(0, TRUE);
ScriptContext2_Disable();
DestroyTask(taskId);
}
@@ -3309,7 +3309,7 @@ static void sub_81429F0(u8 taskId)
u32 temp = gUnknown_085B6344[(gSpecialVar_0x8004 & 1) + (gSpecialVar_0x8004 >> 7 << 1)];
ConvertIntToDecimalStringN(gStringVar1, temp, STR_CONV_MODE_LEADING_ZEROS, 1);
StringExpandPlaceholders(gStringVar4, gUnknown_082A5B12);
- NewMenuHelpers_DrawStdWindowFrame(0, FALSE);
+ DrawStdWindowFrame(0, FALSE);
AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(0, 3);
gTasks[taskId].func = sub_81428C4;
@@ -3326,7 +3326,7 @@ static void Task_Roulette_0(u8 taskId)
{
if ((gSpecialVar_0x8004 & 0x80) && (gSpecialVar_0x8004 & 1))
{
- NewMenuHelpers_DrawStdWindowFrame(0, FALSE);
+ DrawStdWindowFrame(0, FALSE);
AddTextPrinterParameterized(0, 1, gUnknown_082A5B6B, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(0, 3);
gTasks[taskId].func = sub_81429F0;
@@ -3334,7 +3334,7 @@ static void Task_Roulette_0(u8 taskId)
else
{
StringExpandPlaceholders(gStringVar4, gUnknown_082A5B12);
- NewMenuHelpers_DrawStdWindowFrame(0, FALSE);
+ DrawStdWindowFrame(0, FALSE);
AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(0, 3);
gTasks[taskId].func = sub_81428C4;
@@ -3343,7 +3343,7 @@ static void Task_Roulette_0(u8 taskId)
else
{
StringExpandPlaceholders(gStringVar4, gUnknown_082A5B4E);
- NewMenuHelpers_DrawStdWindowFrame(0, FALSE);
+ DrawStdWindowFrame(0, FALSE);
AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL);
CopyWindowToVram(0, 3);
gTasks[taskId].func = sub_81429A0;
diff --git a/src/safari_zone.c b/src/safari_zone.c
index accf94981..703c3d0cd 100644
--- a/src/safari_zone.c
+++ b/src/safari_zone.c
@@ -10,6 +10,7 @@
#include "string_util.h"
#include "tv.h"
#include "constants/game_stat.h"
+#include "field_screen_effect.h"
struct PokeblockFeeder
{
@@ -27,8 +28,6 @@ extern const u8 EventScript_2A4B6F[];
extern const u8 EventScript_2A4B4C[];
extern const u8 EventScript_2A4B9B[];
-extern void sub_80AF6F0(void);
-
EWRAM_DATA u8 gNumSafariBalls = 0;
EWRAM_DATA static u16 sSafariZoneStepCounter = 0;
EWRAM_DATA static u8 sSafariZoneCaughtMons = 0;
diff --git a/src/save.c b/src/save.c
index a22e20f0b..361a88e1e 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1,5 +1,7 @@
#include "global.h"
+#include "agb_flash.h"
#include "gba/flash_internal.h"
+#include "fieldmap.h"
#include "save.h"
#include "task.h"
#include "decompress.h"
@@ -8,6 +10,7 @@
#include "pokemon_storage_system.h"
#include "main.h"
#include "trainer_hill.h"
+#include "link.h"
#include "constants/game_stat.h"
static u16 CalculateChecksum(void *data, u16 size);
@@ -70,12 +73,6 @@ const struct SaveSectionOffsets gSaveSectionOffsets[] =
SAVEBLOCK_CHUNK(gPokemonStorage, 8),
};
-extern void DoSaveFailedScreen(u8); // save_failed_screen
-extern bool32 ProgramFlashSectorAndVerify(u8 sector, u8 *data);
-extern void save_serialize_map(void);
-extern void sub_800ADF8(void);
-extern bool8 IsLinkTaskFinished(void);
-
// iwram common
u16 gLastWrittenSector;
u32 gLastSaveCounter;
@@ -659,10 +656,10 @@ static void UpdateSaveAddresses(void)
u8 HandleSavingData(u8 saveType)
{
u8 i;
- u32 *backupVar = gUnknown_0203CF5C;
+ u32 *backupVar = gTrainerHillVBlankCounter;
u8 *tempAddr;
- gUnknown_0203CF5C = NULL;
+ gTrainerHillVBlankCounter = NULL;
UpdateSaveAddresses();
switch (saveType)
{
@@ -705,7 +702,7 @@ u8 HandleSavingData(u8 saveType)
save_write_to_flash(0xFFFF, gRamSaveSectionLocations);
break;
}
- gUnknown_0203CF5C = backupVar;
+ gTrainerHillVBlankCounter = backupVar;
return 0;
}
@@ -768,7 +765,7 @@ u8 sub_8153408(void) // trade.s save
return 0;
}
-u8 sub_8153430(void)
+u8 FullSaveGame(void)
{
if (gFlashMemoryPresent != TRUE)
return 1;
@@ -780,7 +777,7 @@ u8 sub_8153430(void)
return 0;
}
-bool8 sub_8153474(void)
+bool8 CheckSaveFile(void)
{
u8 retVal = FALSE;
u16 val = ++gUnknown_03006208;
diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c
index 2478ebbec..08f193890 100644
--- a/src/save_failed_screen.c
+++ b/src/save_failed_screen.c
@@ -229,10 +229,10 @@ static void CB2_SaveFailedScreen(void)
LoadPalette(sSaveFailedClockPal, 0x100, 0x20);
LoadPalette(gTextWindowFrame1_Pal, 0xE0, 0x20);
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
- SetWindowBorderStyle(gSaveFailedWindowIds[TEXT_WIN_ID], FALSE, 0x214, 0xE);
- SetWindowBorderStyle(gSaveFailedWindowIds[CLOCK_WIN_ID], FALSE, 0x214, 0xE);
- FillWindowPixelBuffer(gSaveFailedWindowIds[CLOCK_WIN_ID], 0x11); // backwards?
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ DrawStdFrameWithCustomTileAndPalette(gSaveFailedWindowIds[TEXT_WIN_ID], FALSE, 0x214, 0xE);
+ DrawStdFrameWithCustomTileAndPalette(gSaveFailedWindowIds[CLOCK_WIN_ID], FALSE, 0x214, 0xE);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[CLOCK_WIN_ID], PIXEL_FILL(1)); // backwards?
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
CopyWindowToVram(gSaveFailedWindowIds[CLOCK_WIN_ID], 2); // again?
CopyWindowToVram(gSaveFailedWindowIds[TEXT_WIN_ID], 1);
SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0);
@@ -265,19 +265,19 @@ static void CB2_WipeSave(void)
{
if (WipeSectors(gDamagedSaveSectors) != FALSE)
{
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_BackupMemoryDamaged, 1, 0);
SetMainCallback2(CB2_GameplayCannotBeContinued);
return;
}
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_CheckCompleted, 1, 0);
HandleSavingData(gSaveFailedType);
if (gDamagedSaveSectors != 0)
{
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0);
}
@@ -286,12 +286,12 @@ static void CB2_WipeSave(void)
if (wipeTries == 3)
{
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_BackupMemoryDamaged, 1, 0);
}
else
{
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
if (gGameContinueCallback == NULL)
SaveFailedScreenTextPrint(gText_SaveCompleteGameCannotContinue, 1, 0);
@@ -308,7 +308,7 @@ static void CB2_GameplayCannotBeContinued(void)
if (gMain.newKeys & A_BUTTON)
{
- FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], 0x11);
+ FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1));
SaveFailedScreenTextPrint(gText_GamePlayCannotBeContinued, 1, 0);
SetVBlankCallback(VBlankCB);
SetMainCallback2(CB2_FadeAndReturnToTitleScreen);
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 51d96ff2e..314504600 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1203,7 +1203,7 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
bool8 ScrCmd_lockall(struct ScriptContext *ctx)
{
- if (is_c1_link_related_active())
+ if (IsUpdateLinkStateCBActive())
{
return FALSE;
}
@@ -1217,7 +1217,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
bool8 ScrCmd_lock(struct ScriptContext *ctx)
{
- if (is_c1_link_related_active())
+ if (IsUpdateLinkStateCBActive())
{
return FALSE;
}
@@ -1302,7 +1302,7 @@ bool8 ScrCmd_cmdDB(struct ScriptContext *ctx)
if (msg == NULL)
msg = (const u8 *)ctx->data[0];
sub_81973A4();
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
AddTextPrinterParameterized(0, 1, msg, 0, 1, 0, 0);
return FALSE;
}
@@ -1517,9 +1517,9 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
winTemplate = CreateWindowTemplate(0, xWindow, yWindow + 1, width, height, 0xF, 0x1);
gUnknown_03000F30 = AddWindow(&winTemplate);
LoadUserWindowBorderGfx(gUnknown_03000F30, 0x214, 0xE0);
- NewMenuHelpers_DrawStdWindowFrame(gUnknown_03000F30, 0);
+ DrawStdWindowFrame(gUnknown_03000F30, 0);
PutWindowTilemap(gUnknown_03000F30);
- FillWindowPixelBuffer(gUnknown_03000F30, 0x11);
+ FillWindowPixelBuffer(gUnknown_03000F30, PIXEL_FILL(1));
AddTextPrinterParameterized(gUnknown_03000F30, 6, gStringVar4, xText, yText, 0xFF, 0x0);
CopyWindowToVram(gUnknown_03000F30, 3);
return FALSE;
@@ -2028,14 +2028,14 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
u16 tileId = VarGet(ScriptReadHalfword(ctx));
- u16 v8 = VarGet(ScriptReadHalfword(ctx));
+ u16 isImpassable = VarGet(ScriptReadHalfword(ctx));
x += 7;
y += 7;
- if (!v8)
+ if (!isImpassable)
MapGridSetMetatileIdAt(x, y, tileId);
else
- MapGridSetMetatileIdAt(x, y, tileId | 0xC00);
+ MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
return FALSE;
}
@@ -2182,7 +2182,7 @@ bool8 ScrCmd_cmdD8(struct ScriptContext *ctx)
bool8 ScrCmd_cmdD9(struct ScriptContext *ctx)
{
- if (is_c1_link_related_active())
+ if (IsUpdateLinkStateCBActive())
{
return FALSE;
}
@@ -2254,7 +2254,7 @@ bool8 ScrCmd_setmonmetlocation(struct ScriptContext *ctx)
void sub_809BDB4(void)
{
- sub_819746C(gUnknown_03000F30, 1);
+ ClearStdWindowAndFrame(gUnknown_03000F30, 1);
RemoveWindow(gUnknown_03000F30);
}
diff --git a/src/script_menu.c b/src/script_menu.c
index 7180bfc60..c7523a370 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1202,7 +1202,7 @@ bool8 ScriptMenu_YesNo(u8 left, u8 top)
else
{
gSpecialVar_Result = 0xFF;
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
taskId = CreateTask(Task_HandleYesNoInput, 0x50);
return TRUE;
}
@@ -1312,7 +1312,7 @@ static void Task_HandleMultichoiceGridInput(u8 taskId)
#undef tWindowId
-bool8 ScrSpecial_CreatePCMenu(void)
+bool16 ScrSpecial_CreatePCMenu(void)
{
if (FuncIsActiveTask(Task_HandleMultichoiceInput) == TRUE)
{
@@ -1630,7 +1630,7 @@ u8 CreateWindowFromRect(u8 x, u8 y, u8 width, u8 height)
void sub_80E2A78(u8 windowId)
{
- sub_8198070(windowId, TRUE);
+ ClearStdWindowAndFrameToTransparent(windowId, TRUE);
RemoveWindow(windowId);
}
@@ -1639,27 +1639,27 @@ static void sub_80E2A94(u8 multichoiceId)
switch (multichoiceId)
{
case 77:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 76:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 78:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 79:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 75:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
case 74:
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
break;
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index cade00b50..7d6020c7a 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -29,6 +29,7 @@
#include "constants/items.h"
#include "constants/species.h"
#include "constants/vars.h"
+#include "constants/battle_frontier.h"
extern const u16 gEventObjectPalette8[];
extern const u16 gEventObjectPalette17[];
@@ -40,7 +41,7 @@ static const u8 gUnknown_0858D8EC[] = { 3, 4, 5, 14 };
static void sub_80F8EE8(u8 taskId);
static void sub_80F9088(u8 taskId);
-static void sub_80F9460(void);
+static void CB2_ReturnFromChooseHalfParty(void);
static void sub_80F94B8(void);
void SetContestTrainerGfxIds(void)
@@ -640,22 +641,24 @@ void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot)
SetMonMoveSlot(&gPlayerParty[monIndex], move, slot);
}
-void sub_80F9438(void)
+// Note: When control returns to the event script, gSpecialVar_Result will be
+// TRUE if the party selection was successful.
+void ChooseHalfPartyForBattle(void)
{
- gMain.savedCallback = sub_80F9460;
- VarSet(VAR_FRONTIER_FACILITY, 9); // this isn't a valid frontier facility id (??)
- sub_81B8518(0);
+ gMain.savedCallback = CB2_ReturnFromChooseHalfParty;
+ VarSet(VAR_FRONTIER_FACILITY, FRONTIER_FACILITY_DOUBLE_COLOSSEUM);
+ InitChooseHalfPartyForBattle(0);
}
-static void sub_80F9460(void)
+static void CB2_ReturnFromChooseHalfParty(void)
{
switch (gSelectedOrderFromParty[0])
{
case 0:
- gSpecialVar_Result = 0;
+ gSpecialVar_Result = FALSE;
break;
default:
- gSpecialVar_Result = 1;
+ gSpecialVar_Result = TRUE;
break;
}
@@ -665,7 +668,7 @@ static void sub_80F9460(void)
void sub_80F9490(void)
{
gMain.savedCallback = sub_80F94B8;
- sub_81B8518(gSpecialVar_0x8004 + 1);
+ InitChooseHalfPartyForBattle(gSpecialVar_0x8004 + 1);
}
static void sub_80F94B8(void)
diff --git a/src/secret_base.c b/src/secret_base.c
index adcab9cbc..4b270e424 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -43,8 +43,6 @@
#include "constants/species.h"
#include "constants/trainers.h"
-extern void mapldr_default(void);
-
// Static type declarations
struct SecretBaseListMenuBuffer {
@@ -60,7 +58,7 @@ struct SecretBaseRecordMixer {
// Static RAM declarations
EWRAM_DATA u8 sCurSecretBaseId = 0;
-EWRAM_DATA u8 gUnknown_0203A01D = 0;
+EWRAM_DATA bool8 gInFriendSecretBase = FALSE;
EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
// Static ROM declarations
@@ -259,7 +257,7 @@ void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile)
{
for (x = 0; x < mapLayout->width; x ++)
{
- if ((mapLayout->map[y * mapLayout->width + x] & 0x3ff) == tile)
+ if ((mapLayout->map[y * mapLayout->width + x] & METATILE_ID_MASK) == tile)
{
*xPtr = x;
*yPtr = y;
@@ -282,7 +280,7 @@ void sub_80E8D4C(void)
{
if (gUnknown_0858CFCC[i].tile1 == tile)
{
- MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xC00);
+ MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@@ -291,7 +289,7 @@ void sub_80E8D4C(void)
{
if (gUnknown_0858CFCC[i].tile2 == tile)
{
- MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | 0xC00);
+ MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@@ -352,7 +350,7 @@ void sub_80E8EE0(struct MapEvents const *events)
{
if (gUnknown_0858CFCC[i].tile1 == tile_id)
{
- MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xc00);
+ MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | METATILE_COLLISION_MASK);
break;
}
}
@@ -407,7 +405,7 @@ void sub_80E9068(void)
bool8 sub_80E909C(void)
{
- if (gMapHeader.mapType == MAP_TYPE_SECRET_BASE && VarGet(VAR_0x4097) == 0)
+ if (gMapHeader.mapType == MAP_TYPE_SECRET_BASE && VarGet(VAR_INIT_SECRET_BASE) == 0)
{
return FALSE;
}
@@ -434,7 +432,7 @@ void sub_80E9108(void)
sub_80E8CB0(&x, &y, 0x220);
x += 7;
y += 7;
- MapGridSetMetatileIdAt(x, y, 0x220 | 0xC00);
+ MapGridSetMetatileIdAt(x, y, 0x220 | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
pal_fill_black();
CreateTask(sub_80E90C8, 0);
@@ -492,12 +490,12 @@ void sub_80E9238(u8 flagIn)
if (curBaseId != 0)
{
sub_80E8CB0(&x, &y, 0x220);
- MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | 0xc00);
+ MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | METATILE_COLLISION_MASK);
}
- else if (flagIn == 1 && VarGet(VAR_0x4089) == 1)
+ else if (flagIn == 1 && VarGet(VAR_SECRET_BASE_INITIALIZED) == 1)
{
sub_80E8CB0(&x, &y, 0x220);
- MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | 0xc00);
+ MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | METATILE_COLLISION_MASK);
}
}
}
@@ -552,7 +550,7 @@ void sub_80E933C(void)
metatile = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
if (MetatileBehavior_IsSecretBaseLargeMatEdge(metatile) == TRUE || MetatileBehavior_IsLargeMatCenter(metatile) == TRUE)
{
- gSpecialVar_Result = gMapHeader.events->eventObjects[objIdx].graphicsId + VAR_0x3F20;
+ gSpecialVar_Result = gMapHeader.events->eventObjects[objIdx].graphicsId + UNKNOWN_VAR_OFFSET_3F20;
VarSet(gSpecialVar_Result, gDecorations[roomDecor[decorIdx]].tiles[0]);
gSpecialVar_Result = gMapHeader.events->eventObjects[objIdx].localId;
FlagClear(gSpecialVar_0x8004 + 0xAE);
@@ -791,7 +789,7 @@ void sub_80E9AD0(void)
{
if (gUnknown_0858CFCC[j].tile2 == tile)
{
- MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | 0xc00);
+ MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | METATILE_COLLISION_MASK);
break;
}
}
@@ -871,7 +869,7 @@ void sub_80E9C9C(u8 taskId)
{
data[1] = 0;
data[2] = 0;
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
gUnknown_0203A020 = calloc(1, sizeof(struct SecretBaseListMenuBuffer));
data[6] = AddWindow(&gUnknown_0858D06C[0]);
game_continue(taskId);
@@ -963,7 +961,7 @@ void sub_80E9E90(u8 taskId)
PlaySE(SE_SELECT);
DestroyListMenuTask(data[5], NULL, NULL);
RemoveScrollIndicatorArrowPair(data[8]);
- sub_819746C(data[6], 0);
+ ClearStdWindowAndFrame(data[6], 0);
ClearWindowTilemap(data[6]);
RemoveWindow(data[6]);
schedule_bg_copy_tilemap_to_vram(0);
@@ -1020,8 +1018,8 @@ void sub_80E9FFC(u8 taskId)
s16 *data;
data = gTasks[taskId].data;
- sub_819746C(data[6], FALSE);
- sub_819746C(data[7], FALSE);
+ ClearStdWindowAndFrame(data[6], FALSE);
+ ClearStdWindowAndFrame(data[7], FALSE);
ClearWindowTilemap(data[6]);
ClearWindowTilemap(data[7]);
RemoveWindow(data[7]);
@@ -1033,7 +1031,7 @@ void sub_80E9FFC(u8 taskId)
void sub_80EA06C(u8 taskId)
{
- DisplayYesNoMenu();
+ DisplayYesNoMenuDefaultYes();
DoYesNoFuncWithChoice(taskId, &gUnknown_0858D058);
}
@@ -1042,7 +1040,7 @@ void sub_80EA08C(u8 taskId)
s16 *data;
data = gTasks[taskId].data;
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
DestroyListMenuTask(data[5], &data[2], &data[1]);
gSaveBlock1Ptr->secretBases[data[4]].sbr_field_1_6 = 0;
game_continue(taskId);
@@ -1061,7 +1059,7 @@ void sub_80EA13C(u8 taskId)
s16 *data;
data = gTasks[taskId].data;
- sub_8197434(0, 0);
+ ClearDialogWindowAndFrame(0, 0);
DestroyListMenuTask(data[5], &data[2], &data[1]);
sub_80E9E00(taskId);
gTasks[taskId].func = sub_80E9E90;
@@ -1073,7 +1071,7 @@ void sub_80EA18C(u8 taskId)
data = gTasks[taskId].data;
sub_80E9E44(taskId);
- sub_819746C(data[7], 0);
+ ClearStdWindowAndFrame(data[7], 0);
ClearWindowTilemap(data[7]);
RemoveWindow(data[7]);
schedule_bg_copy_tilemap_to_vram(0);
@@ -1186,11 +1184,11 @@ void SecretBasePerStepCallback(u8 taskId)
case 0:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- gUnknown_0203A01D = TRUE;
+ gInFriendSecretBase = TRUE;
}
else
{
- gUnknown_0203A01D = FALSE;
+ gInFriendSecretBase = FALSE;
}
PlayerGetDestCoords(&data[2], &data[3]);
data[1] = 1;
@@ -1201,103 +1199,103 @@ void SecretBasePerStepCallback(u8 taskId)
{
data[2] = x;
data[3] = y;
- VarSet(VAR_0x40EC, VarGet(VAR_0x40EC) + 1);
+ VarSet(VAR_SECRET_BASE_STEP_COUNTER, VarGet(VAR_SECRET_BASE_STEP_COUNTER) + 1);
behavior = MapGridGetMetatileBehaviorAt(x, y);
tileId = MapGridGetMetatileIdAt(x, y);
if (tileId == 0x234 || tileId == 0x23C)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x20);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x20);
}
}
else if (tileId == 0x2b8 || tileId == 0x2b9 || tileId == 0x2ba || tileId == 0x2c0 || tileId == 0x2c1 || tileId == 0x2c2 || tileId == 0x2c8 || tileId == 0x2c9 || tileId == 0x2ca)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x01);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x01);
}
}
else if (tileId == 0x239 || tileId == 0x241 || tileId == 0x251 || tileId == 0x259)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x04);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x04);
}
}
else if ((behavior == 0x34 && tileId == 0x26d) || (behavior == 0x35 && MapGridGetMetatileIdAt(x, y) == 0x26a))
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x200);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x200);
}
}
else if (behavior == 0xc1 && tileId == 0x23d)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) ^ 0x1000);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x2000);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) ^ 0x1000);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x2000);
}
}
else if (behavior == 0x47 && tileId == 0x23e)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x1000);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) ^ 0x2000);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x1000);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) ^ 0x2000);
}
}
else if (MetatileBehavior_IsSecretBaseGlitterMat(behavior) == TRUE)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x80);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x80);
}
}
else if (MetatileBehavior_IsSecretBaseBalloon(behavior) == TRUE)
{
PopSecretBaseBalloon(MapGridGetMetatileIdAt(x, y), x, y);
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
switch ((int)MapGridGetMetatileIdAt(x, y))
{
case 0x338:
case 0x33c:
case 0x340:
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x02);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x02);
break;
case 0x228:
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x100);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x100);
break;
}
}
}
else if (MetatileBehavior_IsSecretBaseBreakableDoor(behavior) == TRUE)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x400);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x400);
}
ShatterSecretBaseBreakableDoor(x, y);
}
else if (MetatileBehavior_IsSecretBaseSoundMat(behavior) == TRUE){
- if (gUnknown_0203A01D == TRUE) {
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x8000);
+ if (gInFriendSecretBase == TRUE) {
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x8000);
}
}
else if (MetatileBehavior_IsSecretBaseJumpMat(behavior) == TRUE)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x4000);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x4000);
}
}
else if (MetatileBehavior_IsSecretBaseSpinMat(behavior) == TRUE)
{
- if (gUnknown_0203A01D == TRUE)
+ if (gInFriendSecretBase == TRUE)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x02);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x02);
}
}
}
@@ -1780,33 +1778,33 @@ void sub_80EB18C(struct SecretBaseRecord *bases)
void sub_80EB1AC(void)
{
- VarSet(VAR_0x40EC, 0);
- VarSet(VAR_0x40ED, 0);
- VarSet(VAR_0x40EE, 0);
- VarSet(VAR_0x40EF, 0);
+ VarSet(VAR_SECRET_BASE_STEP_COUNTER, 0);
+ VarSet(VAR_SECRET_BASE_LAST_ITEM_USED, 0);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, 0);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, 0);
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40F0, TRUE);
+ VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, TRUE);
}
else
{
- VarSet(VAR_0x40F0, FALSE);
+ VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
}
- gUnknown_0203A01D = FALSE;
+ gInFriendSecretBase = FALSE;
}
void sub_80EB218(void)
{
- if (VarGet(VAR_0x40F0) && gUnknown_0203A01D == TRUE && !CurrentMapIsSecretBase())
+ if (VarGet(VAR_SECRET_BASE_IS_NOT_LOCAL) && gInFriendSecretBase == TRUE && !CurrentMapIsSecretBase())
{
- VarSet(VAR_0x40F0, FALSE);
- gUnknown_0203A01D = FALSE;
+ VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
+ gInFriendSecretBase = FALSE;
sub_80EEA70();
- VarSet(VAR_0x40EC, 0);
- VarSet(VAR_0x40ED, 0);
- VarSet(VAR_0x40EE, 0);
- VarSet(VAR_0x40EF, 0);
- VarSet(VAR_0x40F0, FALSE);
+ VarSet(VAR_SECRET_BASE_STEP_COUNTER, 0);
+ VarSet(VAR_SECRET_BASE_LAST_ITEM_USED, 0);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, 0);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, 0);
+ VarSet(VAR_SECRET_BASE_IS_NOT_LOCAL, FALSE);
}
}
@@ -1814,7 +1812,7 @@ void sub_80EB290(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x800);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x800);
}
}
@@ -1822,7 +1820,7 @@ void sub_80EB2C8(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x400);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x400);
}
}
@@ -1830,9 +1828,9 @@ void sub_80EB300(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) & ~0x3800);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) & ~0x001);
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x2000);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~0x3800);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~0x001);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x2000);
}
}
@@ -1840,9 +1838,9 @@ void sub_80EB368(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) & ~0x3800);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) & ~0x001);
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x800);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~0x3800);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~0x001);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x800);
}
}
@@ -1850,9 +1848,9 @@ void sub_80EB3D0(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) & ~0x3800);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) & ~0x001);
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x1000);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~0x3800);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~0x001);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x1000);
}
}
@@ -1860,9 +1858,9 @@ void sub_80EB438(void)
{
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) & ~0x3800);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) & ~0x001);
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x001);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) & ~0x3800);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) & ~0x001);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x001);
}
}
@@ -1891,7 +1889,7 @@ void sub_80EB498(void)
case 0x334:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x4000);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x4000);
}
break;
}
@@ -1909,7 +1907,7 @@ void sub_80EB56C(void)
case 0x28b:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x40);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x40);
}
break;
case 0x2d8:
@@ -1932,21 +1930,21 @@ void sub_80EB56C(void)
case 0x2fb:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EE, VarGet(VAR_0x40EE) | 0x8);
+ VarSet(VAR_SECRET_BASE_LOW_TV_FLAGS, VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) | 0x8);
}
break;
case 0x22c:
case 0x233:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x40);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x40);
}
break;
case 0x288:
case 0x289:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x100);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x100);
}
break;
case 0x22d:
@@ -1954,7 +1952,7 @@ void sub_80EB56C(void)
case 0x22f:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x10);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x10);
}
break;
case 0x287:
@@ -1982,7 +1980,7 @@ void sub_80EB56C(void)
case 0x2cf:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x8);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x8);
}
break;
}
@@ -2009,7 +2007,7 @@ void sub_80EB9E0(void)
case 0x2c6:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x8);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x8);
}
break;
}
@@ -2047,14 +2045,14 @@ void sub_80EBB28(void)
case 0x2c7:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x8);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x8);
}
break;
case 0x280:
case 0x281:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x100);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x100);
}
break;
case 0x225:
@@ -2062,7 +2060,7 @@ void sub_80EBB28(void)
case 0x227:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x10);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x10);
}
break;
}
@@ -2080,7 +2078,7 @@ void sub_80EBE7C(void)
case 0x28e:
if (VarGet(VAR_CURRENT_SECRET_BASE) != 0)
{
- VarSet(VAR_0x40EF, VarGet(VAR_0x40EF) | 0x4);
+ VarSet(VAR_SECRET_BASE_HIGH_TV_FLAGS, VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) | 0x4);
}
break;
}
diff --git a/src/shop.c b/src/shop.c
index 8eefd5e97..e03e2ab0c 100755
--- a/src/shop.c
+++ b/src/shop.c
@@ -366,7 +366,7 @@ void CB2_ExitSellMenu(void)
static void Task_HandleShopMenuQuit(u8 taskId)
{
- sub_8198070(gMartInfo.windowId, 2);
+ ClearStdWindowAndFrameToTransparent(gMartInfo.windowId, 2);
RemoveWindow(gMartInfo.windowId);
SaveRecordedItemPurchasesForTVShow();
ScriptContext2_Disable();
@@ -545,7 +545,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, s
description = gText_QuitShopping;
}
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
BuyMenuPrint(2, description, 3, 1, 0, 0);
}
@@ -981,12 +981,12 @@ static void Task_BuyHowManyDialogueInit(u8 taskId)
u16 quantityInBag = CountTotalItemQuantityInBag(tItemId);
u16 maxQuantity;
- SetWindowBorderStyle(3, FALSE, 1, 13);
+ DrawStdFrameWithCustomTileAndPalette(3, FALSE, 1, 13);
ConvertIntToDecimalStringN(gStringVar1, quantityInBag, STR_CONV_MODE_RIGHT_ALIGN, 4);
StringExpandPlaceholders(gStringVar4, gText_InBagVar1);
BuyMenuPrint(3, gStringVar4, 0, 1, 0, 0);
tItemCount = 1;
- SetWindowBorderStyle(4, FALSE, 1, 13);
+ DrawStdFrameWithCustomTileAndPalette(4, FALSE, 1, 13);
BuyMenuPrintItemQuantityAndPrice(taskId);
schedule_bg_copy_tilemap_to_vram(0);
@@ -1018,8 +1018,8 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
- sub_8198070(4, 0);
- sub_8198070(3, 0);
+ ClearStdWindowAndFrameToTransparent(4, 0);
+ ClearStdWindowAndFrameToTransparent(3, 0);
ClearWindowTilemap(4);
ClearWindowTilemap(3);
PutWindowTilemap(1);
@@ -1031,8 +1031,8 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId)
else if (gMain.newKeys & B_BUTTON)
{
PlaySE(SE_SELECT);
- sub_8198070(4, 0);
- sub_8198070(3, 0);
+ ClearStdWindowAndFrameToTransparent(4, 0);
+ ClearStdWindowAndFrameToTransparent(3, 0);
ClearWindowTilemap(4);
ClearWindowTilemap(3);
BuyMenuReturnToItemList(taskId);
@@ -1131,7 +1131,7 @@ static void BuyMenuReturnToItemList(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- sub_8197DF8(5, 0);
+ ClearDialogWindowAndFrameToTransparent(5, 0);
BuyMenuPrintCursor(tListTaskId, 1);
PutWindowTilemap(1);
PutWindowTilemap(2);
@@ -1144,7 +1144,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId)
{
s16 *data = gTasks[taskId].data;
- FillWindowPixelBuffer(4, 0x11);
+ FillWindowPixelBuffer(4, PIXEL_FILL(1));
PrintMoneyAmount(4, 38, 1, gShopDataPtr->totalCost, TEXT_SPEED_FF);
ConvertIntToDecimalStringN(gStringVar1, tItemCount, 2, 2);
StringExpandPlaceholders(gStringVar4, gText_xVar1);
diff --git a/src/siirtc.c b/src/siirtc.c
index f7e85ef4f..5c153a841 100644
--- a/src/siirtc.c
+++ b/src/siirtc.c
@@ -76,19 +76,19 @@ static void DisableGpioPortRead();
static const char AgbLibRtcVersion[] = "SIIRTC_V001";
-void SiiRtcUnprotect()
+void SiiRtcUnprotect(void)
{
EnableGpioPortRead();
sLocked = FALSE;
}
-void SiiRtcProtect()
+void SiiRtcProtect(void)
{
DisableGpioPortRead();
sLocked = TRUE;
}
-u8 SiiRtcProbe()
+u8 SiiRtcProbe(void)
{
u8 errorCode;
struct SiiRtcInfo rtc;
@@ -129,7 +129,7 @@ u8 SiiRtcProbe()
return (errorCode << 4) | 1;
}
-bool8 SiiRtcReset()
+bool8 SiiRtcReset(void)
{
u8 result;
struct SiiRtcInfo rtc;
diff --git a/src/slot_machine.c b/src/slot_machine.c
index fb1c88097..a2e1f1554 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -1025,7 +1025,7 @@ static bool8 SlotAction_AwaitPlayerInput(struct Task *task)
static bool8 SlotAction_PrintYouDontHaveThreeCoins(struct Task *task)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, gText_YouDontHaveThreeCoins, 0, 1, 0, 0);
CopyWindowToVram(0, 3);
sSlotMachine->state = 7;
@@ -1036,7 +1036,7 @@ static bool8 SlotAction_ExitYouDontHaveThreeCoinsMessage(struct Task *task)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sSlotMachine->state = 5;
}
return FALSE;
@@ -1274,7 +1274,7 @@ static bool8 SlotAction_NoMatches(struct Task *task)
static bool8 SlotAction_PrintQuitTheGame(struct Task *task)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, gText_QuitTheGame, 0, 1, 0, 0);
CopyWindowToVram(0, 3);
CreateYesNoMenuParameterized(0x15, 7, 0x214, 0x180, 0xE, 0xF);
@@ -1287,7 +1287,7 @@ static bool8 SlotAction_SeeIfPlayerQuits(struct Task *task)
s8 input = Menu_ProcessInputNoWrapClearOnChoose();
if (input == 0) // player chooses to quit
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sub_8103D8C(0);
sub_8103D8C(1);
sub_8103D8C(2);
@@ -1296,7 +1296,7 @@ static bool8 SlotAction_SeeIfPlayerQuits(struct Task *task)
}
else if (input == 1 || input == -1) // player chooses not to quit
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sSlotMachine->state = 5;
}
return FALSE;
@@ -1304,7 +1304,7 @@ static bool8 SlotAction_SeeIfPlayerQuits(struct Task *task)
static bool8 SlotAction_PrintMessage_9999Coins(struct Task *task)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, gText_YouveGot9999Coins, 0, 1, 0, 0);
CopyWindowToVram(0, 3);
sSlotMachine->state = 24;
@@ -1315,7 +1315,7 @@ static bool8 SlotAction_ExitMessage_9999Coins(struct Task *task)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sSlotMachine->state = 5;
}
return FALSE;
@@ -1323,7 +1323,7 @@ static bool8 SlotAction_ExitMessage_9999Coins(struct Task *task)
static bool8 SlotAction_PrintMessage_NoMoreCoins(struct Task *task)
{
- NewMenuHelpers_DrawDialogueFrame(0, 0);
+ DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, 1, gText_YouveRunOutOfCoins, 0, 1, 0, 0);
CopyWindowToVram(0, 3);
sSlotMachine->state = 26;
@@ -1334,7 +1334,7 @@ static bool8 SlotAction_ExitMessage_NoMoreCoins(struct Task *task)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
sSlotMachine->state = 27;
}
return FALSE;
@@ -3120,7 +3120,7 @@ static void InfoBox_8104B80(struct Task *task)
sub_81065DC();
AddWindow(&gUnknown_085A7444);
PutWindowTilemap(1);
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
task->data[0]++;
}
@@ -3136,7 +3136,7 @@ static void InfoBox_AwaitPlayerInput(struct Task *task)
{
if (gMain.newKeys & (B_BUTTON | SELECT_BUTTON))
{
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
ClearWindowTilemap(1);
CopyWindowToVram(1, 1);
RemoveWindow(1);
diff --git a/src/start_menu.c b/src/start_menu.c
index 6efd7a04a..4822c12e6 100644
--- a/src/start_menu.c
+++ b/src/start_menu.c
@@ -1,44 +1,49 @@
#include "global.h"
-#include "start_menu.h"
-#include "menu.h"
-#include "safari_zone.h"
-#include "event_data.h"
-#include "window.h"
-#include "string_util.h"
-#include "text.h"
-#include "strings.h"
+#include "battle_pike.h"
+#include "battle_pyramid.h"
+#include "battle_pyramid_bag.h"
#include "bg.h"
+#include "event_data.h"
+#include "event_object_movement.h"
+#include "event_obj_lock.h"
+#include "event_scripts.h"
+#include "fieldmap.h"
#include "field_effect.h"
-#include "party_menu.h"
-#include "frontier_pass.h"
-#include "task.h"
-#include "overworld.h"
-#include "link.h"
-#include "frontier_util.h"
+#include "field_player_avatar.h"
#include "field_specials.h"
-#include "event_object_movement.h"
-#include "script.h"
-#include "main.h"
-#include "sound.h"
-#include "pokedex.h"
#include "field_weather.h"
-#include "palette.h"
+#include "field_screen_effect.h"
+#include "frontier_pass.h"
+#include "frontier_util.h"
+#include "gpu_regs.h"
+#include "international_string_util.h"
#include "item_menu.h"
+#include "link.h"
+#include "load_save.h"
+#include "main.h"
+#include "menu.h"
+#include "new_game.h"
#include "option_menu.h"
-#include "event_scripts.h"
+#include "overworld.h"
+#include "palette.h"
+#include "party_menu.h"
+#include "pokedex.h"
+#include "pokenav.h"
+#include "safari_zone.h"
#include "save.h"
-#include "gpu_regs.h"
#include "scanline_effect.h"
+#include "script.h"
+#include "sound.h"
+#include "start_menu.h"
+#include "strings.h"
+#include "string_util.h"
+#include "task.h"
+#include "text.h"
#include "text_window.h"
-#include "load_save.h"
#include "trainer_card.h"
-#include "international_string_util.h"
+#include "window.h"
#include "constants/songs.h"
-#include "field_player_avatar.h"
-#include "battle_pyramid.h"
-#include "battle_pyramid_bag.h"
-#include "battle_pike.h"
-#include "new_game.h"
+#include "rom_8011DC0.h"
// Menu actions
enum
@@ -83,19 +88,6 @@ EWRAM_DATA static u8 sSaveDialogTimer = 0;
EWRAM_DATA static bool8 sSavingComplete = FALSE;
EWRAM_DATA static u8 sSaveInfoWindowId = 0;
-// Extern variables.
-extern u8 gUnknown_03005DB4;
-
-// Extern functions in not decompiled files.
-extern void sub_80AF688(void);
-extern void var_800D_set_xB(void);
-extern void sub_808B864(void);
-extern void CB2_Pokedex(void);
-extern void PlayRainStoppingSoundEffect(void);
-extern void CB2_PokeNav(void);
-extern void ScriptUnfreezeEventObjects(void);
-extern void save_serialize_map(void);
-
// Menu action callbacks
static bool8 StartMenuPokedexCallback(void);
static bool8 StartMenuPokemonCallback(void);
@@ -123,7 +115,7 @@ static u8 SaveConfirmSaveCallback(void);
static u8 SaveYesNoCallback(void);
static u8 SaveConfirmInputCallback(void);
static u8 SaveFileExistsCallback(void);
-static u8 SaveConfirmOverwriteNoCallback(void);
+static u8 SaveConfirmOverwriteDefaultNoCallback(void);
static u8 SaveConfirmOverwriteCallback(void);
static u8 SaveOverwriteInputCallback(void);
static u8 SaveSavingMessageCallback(void);
@@ -244,7 +236,7 @@ static void BuildStartMenuActions(void)
{
sNumStartMenuActions = 0;
- if (is_c1_link_related_active() == TRUE)
+ if (IsUpdateLinkStateCBActive() == TRUE)
{
BuildLinkModeStartMenu();
}
@@ -376,7 +368,7 @@ static void ShowSafariBallsWindow(void)
{
sSafariBallsWindowId = AddWindow(&sSafariBallsWindowTemplate);
PutWindowTilemap(sSafariBallsWindowId);
- NewMenuHelpers_DrawStdWindowFrame(sSafariBallsWindowId, FALSE);
+ DrawStdWindowFrame(sSafariBallsWindowId, FALSE);
ConvertIntToDecimalStringN(gStringVar1, gNumSafariBalls, STR_CONV_MODE_RIGHT_ALIGN, 2);
StringExpandPlaceholders(gStringVar4, gText_SafariBallStock);
AddTextPrinterParameterized(sSafariBallsWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
@@ -391,7 +383,7 @@ static void ShowPyramidFloorWindow(void)
sBattlePyramidFloorWindowId = AddWindow(&sPyramidFloorWindowTemplate_2);
PutWindowTilemap(sBattlePyramidFloorWindowId);
- NewMenuHelpers_DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE);
+ DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE);
StringCopy(gStringVar1, sPyramindFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]);
StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor);
AddTextPrinterParameterized(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL);
@@ -402,13 +394,13 @@ static void RemoveExtraStartMenuWindows(void)
{
if (GetSafariZoneFlag())
{
- sub_8198070(sSafariBallsWindowId, FALSE);
+ ClearStdWindowAndFrameToTransparent(sSafariBallsWindowId, FALSE);
CopyWindowToVram(sSafariBallsWindowId, 2);
RemoveWindow(sSafariBallsWindowId);
}
if (InBattlePyramid())
{
- sub_8198070(sBattlePyramidFloorWindowId, FALSE);
+ ClearStdWindowAndFrameToTransparent(sBattlePyramidFloorWindowId, FALSE);
RemoveWindow(sBattlePyramidFloorWindowId);
}
}
@@ -459,7 +451,7 @@ static bool32 InitStartMenuStep(void)
break;
case 2:
sub_81973A4();
- NewMenuHelpers_DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE);
+ DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE);
sUnknown_02037619[1] = 0;
sUnknown_02037619[0]++;
break;
@@ -547,7 +539,7 @@ void sub_809FA34(u8 taskId) // Referenced in field_screen.s and rom_8011DC0.s
void ShowStartMenu(void) // Called from overworld.c and field_control_avatar.s
{
- if (!is_c1_link_related_active())
+ if (!IsUpdateLinkStateCBActive())
{
FreezeEventObjects();
sub_808B864();
@@ -656,7 +648,7 @@ static bool8 StartMenuPokeNavCallback(void)
PlayRainStoppingSoundEffect();
RemoveExtraStartMenuWindows();
CleanupOverworldWindowsAndTilemaps();
- SetMainCallback2(CB2_PokeNav); // Display PokeNav
+ SetMainCallback2(CB2_InitPokeNav); // Display PokeNav
return TRUE;
}
@@ -672,7 +664,7 @@ static bool8 StartMenuPlayerNameCallback(void)
RemoveExtraStartMenuWindows();
CleanupOverworldWindowsAndTilemaps();
- if (is_c1_link_related_active() || InUnionRoom())
+ if (IsUpdateLinkStateCBActive() || InUnionRoom())
ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card
else if (FlagGet(FLAG_SYS_FRONTIER_PASS))
ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass
@@ -734,7 +726,7 @@ static bool8 StartMenuLinkModePlayerNameCallback(void)
{
PlayRainStoppingSoundEffect();
CleanupOverworldWindowsAndTilemaps();
- ShowTrainerCardInLink(gUnknown_03005DB4, CB2_ReturnToFieldWithOpenMenu);
+ ShowTrainerCardInLink(gLocalLinkPlayerId, CB2_ReturnToFieldWithOpenMenu);
return TRUE;
}
@@ -751,7 +743,7 @@ static bool8 StartMenuBattlePyramidRetireCallback(void)
void sub_809FDD4(void)
{
- sub_8197DF8(0, FALSE);
+ ClearDialogWindowAndFrameToTransparent(0, FALSE);
ScriptUnfreezeEventObjects();
CreateStartMenuTask(sub_809FA34);
ScriptContext2_Enable();
@@ -787,13 +779,13 @@ static bool8 SaveCallback(void)
case SAVE_IN_PROGRESS:
return FALSE;
case SAVE_CANCELED: // Back to start menu
- sub_8197DF8(0, FALSE);
+ ClearDialogWindowAndFrameToTransparent(0, FALSE);
InitStartMenu();
gMenuCallback = HandleStartMenuInput;
return FALSE;
case SAVE_SUCCESS:
case SAVE_ERROR: // Close start menu
- sub_8197DF8(0, TRUE);
+ ClearDialogWindowAndFrameToTransparent(0, TRUE);
ScriptUnfreezeEventObjects();
ScriptContext2_Disable();
SoftResetInBattlePyramid();
@@ -830,7 +822,7 @@ static bool8 BattlePyramidRetireCallback(void)
case SAVE_IN_PROGRESS:
return FALSE;
case SAVE_CANCELED: // Yes (Retire from battle pyramid)
- sub_8197DF8(0, TRUE);
+ ClearDialogWindowAndFrameToTransparent(0, TRUE);
ScriptUnfreezeEventObjects();
ScriptContext2_Disable();
ScriptContext1_SetupScript(BattleFrontier_BattlePyramidEmptySquare_EventScript_252C88);
@@ -897,7 +889,7 @@ static void SaveGameTask(u8 taskId)
static void sub_80A0014(void)
{
- sub_8197434(0, TRUE);
+ ClearDialogWindowAndFrame(0, TRUE);
}
static void HideSaveInfoWindow(void)
@@ -943,7 +935,7 @@ static bool8 SaveErrorTimer(void)
static u8 SaveConfirmSaveCallback(void)
{
- sub_819746C(GetStartMenuWindowId(), FALSE);
+ ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE);
RemoveStartMenuWindow();
ShowSaveInfoWindow();
@@ -961,7 +953,7 @@ static u8 SaveConfirmSaveCallback(void)
static u8 SaveYesNoCallback(void)
{
- DisplayYesNoMenu(); // Show Yes/No menu
+ DisplayYesNoMenuDefaultYes(); // Show Yes/No menu
sSaveDialogCallback = SaveConfirmInputCallback;
return SAVE_IN_PROGRESS;
}
@@ -1002,7 +994,7 @@ static u8 SaveFileExistsCallback(void)
{
if (gDifferentSaveFile == TRUE)
{
- ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteNoCallback);
+ ShowSaveMessage(gText_DifferentSaveFile, SaveConfirmOverwriteDefaultNoCallback);
}
else
{
@@ -1012,16 +1004,16 @@ static u8 SaveFileExistsCallback(void)
return SAVE_IN_PROGRESS;
}
-static u8 SaveConfirmOverwriteNoCallback(void)
+static u8 SaveConfirmOverwriteDefaultNoCallback(void)
{
- sub_8197948(1); // Show Yes/No menu (No selected as default)
+ DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default)
sSaveDialogCallback = SaveOverwriteInputCallback;
return SAVE_IN_PROGRESS;
}
static u8 SaveConfirmOverwriteCallback(void)
{
- DisplayYesNoMenu(); // Show Yes/No menu
+ DisplayYesNoMenuDefaultYes(); // Show Yes/No menu
sSaveDialogCallback = SaveOverwriteInputCallback;
return SAVE_IN_PROGRESS;
}
@@ -1135,7 +1127,7 @@ static void InitBattlePyramidRetire(void)
static u8 BattlePyramidConfirmRetireCallback(void)
{
- sub_819746C(GetStartMenuWindowId(), FALSE);
+ ClearStdWindowAndFrame(GetStartMenuWindowId(), FALSE);
RemoveStartMenuWindow();
ShowSaveMessage(gText_BattlePyramidConfirmRetire, BattlePyramidRetireYesNoCallback);
@@ -1144,7 +1136,7 @@ static u8 BattlePyramidConfirmRetireCallback(void)
static u8 BattlePyramidRetireYesNoCallback(void)
{
- sub_8197948(1); // Show Yes/No menu (No selected as default)
+ DisplayYesNoMenuWithDefault(1); // Show Yes/No menu (No selected as default)
sSaveDialogCallback = BattlePyramidRetireInputCallback;
return SAVE_IN_PROGRESS;
@@ -1232,7 +1224,7 @@ static void sub_80A0550(u8 taskId)
switch (*step)
{
case 0:
- FillWindowPixelBuffer(0, 17);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized2(0,
1,
gText_SavingDontTurnOffPower,
@@ -1265,11 +1257,11 @@ static void sub_80A0550(u8 taskId)
break;
case 1:
SetContinueGameWarpStatusToDynamicWarp();
- sub_8153430();
+ FullSaveGame();
*step = 2;
break;
case 2:
- if (sub_8153474())
+ if (CheckSaveFile())
{
ClearContinueGameWarpStatus2();
*step = 3;
@@ -1313,7 +1305,7 @@ static void ShowSaveInfoWindow(void)
}
sSaveInfoWindowId = AddWindow(&saveInfoWindow);
- NewMenuHelpers_DrawStdWindowFrame(sSaveInfoWindowId, FALSE);
+ DrawStdWindowFrame(sSaveInfoWindowId, FALSE);
gender = gSaveBlock2Ptr->playerGender;
color = TEXT_COLOR_RED; // Red when female, blue when male.
@@ -1364,7 +1356,7 @@ static void ShowSaveInfoWindow(void)
static void RemoveSaveInfoWindow(void)
{
- sub_819746C(sSaveInfoWindowId, FALSE);
+ ClearStdWindowAndFrame(sSaveInfoWindowId, FALSE);
RemoveWindow(sSaveInfoWindowId);
}
@@ -1386,7 +1378,7 @@ void sub_80A08CC(void) // Referenced in data/specials.inc and data/scripts/maps/
static void HideStartMenuWindow(void)
{
- sub_819746C(GetStartMenuWindowId(), TRUE);
+ ClearStdWindowAndFrame(GetStartMenuWindowId(), TRUE);
RemoveStartMenuWindow();
ScriptUnfreezeEventObjects();
ScriptContext2_Disable();
diff --git a/src/starter_choose.c b/src/starter_choose.c
index 5a8de3b4a..4ed53539f 100644
--- a/src/starter_choose.c
+++ b/src/starter_choose.c
@@ -469,7 +469,7 @@ static void MainCallback2_StarterChoose(void)
static void Task_StarterChoose1(u8 taskId)
{
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
- SetWindowBorderStyle(0, FALSE, 0x2A8, 0xD);
+ DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x2A8, 0xD);
AddTextPrinterParameterized(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL);
PutWindowTilemap(0);
schedule_bg_copy_tilemap_to_vram(0);
@@ -523,7 +523,7 @@ static void Task_StarterChoose3(u8 taskId)
static void Task_StarterChoose4(u8 taskId)
{
PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0);
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0);
@@ -579,7 +579,7 @@ static void CreateStarterPokemonLabel(u8 selection)
winTemplate.tilemapTop = gStarterChoose_LabelCoords[selection][1];
sStarterChooseWindowId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(sStarterChooseWindowId, 0);
+ FillWindowPixelBuffer(sStarterChooseWindowId, PIXEL_FILL(0));
width = GetStringCenterAlignXOffset(7, text, 0x68);
AddTextPrinterParameterized3(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text);
@@ -600,7 +600,7 @@ static void CreateStarterPokemonLabel(u8 selection)
static void sub_8134604(void)
{
- FillWindowPixelBuffer(sStarterChooseWindowId, 0);
+ FillWindowPixelBuffer(sStarterChooseWindowId, PIXEL_FILL(0));
ClearWindowTilemap(sStarterChooseWindowId);
RemoveWindow(sStarterChooseWindowId);
sStarterChooseWindowId = 0xFF;
diff --git a/src/text.c b/src/text.c
index a439d3ced..be4bf2697 100644
--- a/src/text.c
+++ b/src/text.c
@@ -12,10 +12,6 @@
#include "menu.h"
#include "dynamic_placeholder_text_util.h"
-extern u8 GetKeypadIconWidth(u8 keypadIconId);
-extern u16 Font6Func(struct TextPrinter *textPrinter);
-extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
-
EWRAM_DATA struct TextPrinter gTempTextPrinter = {0};
EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0};
@@ -1581,7 +1577,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->printerTemplate.currentChar++;
return 2;
case 15:
- FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | textPrinter->printerTemplate.bgColor << 4);
+ FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y;
return 2;
@@ -1702,7 +1698,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
case 2:
if (TextPrinterWaitWithDownArrow(textPrinter))
{
- FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, (textPrinter->printerTemplate.bgColor << 4) | textPrinter->printerTemplate.bgColor);
+ FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y;
textPrinter->state = 0;
@@ -1724,12 +1720,12 @@ u16 RenderText(struct TextPrinter *textPrinter)
int speed = gWindowVerticalScrollSpeeds[scrollSpeed];
if (textPrinter->scrollDistance < speed)
{
- ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor);
+ ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance = 0;
}
else
{
- ScrollWindow(textPrinter->printerTemplate.windowId, 0, speed, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor);
+ ScrollWindow(textPrinter->printerTemplate.windowId, 0, speed, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance -= speed;
}
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
diff --git a/src/time_events.c b/src/time_events.c
index 9702d321f..bd51f0c2d 100644
--- a/src/time_events.c
+++ b/src/time_events.c
@@ -81,7 +81,7 @@ void UpdateShoalTideFlag(void)
1, // 23
};
- if (is_map_type_1_2_3_5_or_6(GetLastUsedWarpMapType()))
+ if (IsMapTypeOutdoors(GetLastUsedWarpMapType()))
{
RtcCalcLocalTime();
if (tide[gLocalTime.hours])
diff --git a/src/trade.c b/src/trade.c
index 6dfb6e2c4..9a9828f34 100644
--- a/src/trade.c
+++ b/src/trade.c
@@ -1418,7 +1418,7 @@ static void sub_80772A4(void)
for (i = 0; i < 18; i++)
{
ClearWindowTilemap(i);
- FillWindowPixelBuffer(i, 0);
+ FillWindowPixelBuffer(i, PIXEL_FILL(0));
}
FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 15);
@@ -1507,13 +1507,13 @@ static void sub_80773D0(void)
}
break;
case 3:
- if (GetLinkPlayerCount_2() >= sub_800AA48())
+ if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
{
if (IsLinkMaster())
{
if (++gUnknown_0203229C->unk_A8 > 30)
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
gMain.state++;
}
}
@@ -2461,7 +2461,7 @@ static void sub_8078DBC(void)
if (gUnknown_0203229C->tradeMenuCursorPosition < 6)
{
sub_8098858(1, 1, 14);
- FillWindowPixelBuffer(1, 0x11);
+ FillWindowPixelBuffer(1, PIXEL_FILL(1));
PrintMenuTable(1, 2, gUnknown_0832DEAC);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0);
PutWindowTilemap(1);
@@ -2724,7 +2724,7 @@ static void sub_8079408(void)
for (i = 0; i < 4; i++)
{
- FillWindowPixelBuffer(i + 14, 0);
+ FillWindowPixelBuffer(i + 14, PIXEL_FILL(0));
rbox_fill_rectangle(i + 14);
}
@@ -2762,7 +2762,7 @@ static void sub_80794CC(void)
Free(gUnknown_0203229C);
FreeAllWindowBuffers();
sub_800E084();
- SetMainCallback2(c2_8056854);
+ SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
}
}
else
@@ -2772,7 +2772,7 @@ static void sub_80794CC(void)
Free(gUnknown_02032184);
Free(gUnknown_0203229C);
FreeAllWindowBuffers();
- SetMainCallback2(c2_8056854);
+ SetMainCallback2(CB2_ReturnToFieldFromMultiplayer);
}
}
}
@@ -3256,7 +3256,7 @@ static void sub_807A0C4(void)
static void sub_807A19C(u8 a0)
{
- FillWindowPixelBuffer(0, 0x11);
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, 1, gUnknown_0832DEBC[a0], 0, 1, TEXT_SPEED_FF, NULL);
sub_8098858(0, 20, 12);
PutWindowTilemap(0);
@@ -4099,11 +4099,11 @@ void sub_807AE50(void)
case 3:
if (IsLinkMaster())
{
- if (GetLinkPlayerCount_2() >= sub_800AA48())
+ if (GetLinkPlayerCount_2() >= GetSavedPlayerCount())
{
if (++gUnknown_020322A0->timer > 30)
{
- sub_800A620();
+ CheckShouldAdvanceLinkState();
gMain.state++;
}
}
@@ -4185,7 +4185,7 @@ void sub_807B140(void)
void sub_807B154(void)
{
- FillWindowPixelBuffer(0, 0xFF);
+ FillWindowPixelBuffer(0, PIXEL_FILL(15));
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
}
@@ -4263,7 +4263,7 @@ static void sub_807B270(void)
break;
case 8:
sub_807ACFC(1, 1);
- FillWindowPixelBuffer(0, 0xFF);
+ FillWindowPixelBuffer(0, PIXEL_FILL(15));
PutWindowTilemap(0);
CopyWindowToVram(0, 3);
gMain.state++;
@@ -4654,7 +4654,7 @@ static bool8 sub_807BBEC(void)
if (!gPaletteFade.active)
{
sub_807B62C(4);
- FillWindowPixelBuffer(0, 0xFF);
+ FillWindowPixelBuffer(0, PIXEL_FILL(15));
CopyWindowToVram(0, 3);
gUnknown_020322A0->state++;
}
@@ -5146,7 +5146,7 @@ static bool8 sub_807CFC8(void)
if (!gPaletteFade.active)
{
sub_807B62C(4);
- FillWindowPixelBuffer(0, 0xFF);
+ FillWindowPixelBuffer(0, PIXEL_FILL(15));
CopyWindowToVram(0, 3);
gUnknown_020322A0->state++;
}
@@ -6085,7 +6085,7 @@ void sub_807F19C(void)
void sub_807F1A8(u8 windowId, const u8 *str, u8 speed)
{
- FillWindowPixelBuffer(windowId, 0xFF);
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(15));
gUnknown_020322A0->unk_F6[0] = 15;
gUnknown_020322A0->unk_F6[1] = 1;
gUnknown_020322A0->unk_F6[2] = 6;
diff --git a/src/trader.c b/src/trader.c
index b5c159fb9..97bc4626f 100644
--- a/src/trader.c
+++ b/src/trader.c
@@ -73,7 +73,7 @@ void CreateAvailableDecorationsMenu(u8 taskId)
}
windowTemplate.width = convert_pixel_width_to_tile_width(windowWidth);
data[3] = AddWindow(&windowTemplate);
- SetWindowBorderStyle(data[3], FALSE, 0x214, 14);
+ DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14);
for (i = 0; i < 4; i++)
{
if (trader->decorIds[i] > NUM_DECORATIONS)
@@ -98,7 +98,7 @@ void sub_8133BE4(u8 taskId, u8 decorationId)
gSpecialVar_0x8004 = decorationId;
}
- sub_8198070(data[3], FALSE);
+ ClearStdWindowAndFrameToTransparent(data[3], FALSE);
ClearWindowTilemap(data[3]);
RemoveWindow(data[3]);
schedule_bg_copy_tilemap_to_vram(0);
diff --git a/src/trainer_card.c b/src/trainer_card.c
index 4019ef0bd..01839d598 100755
--- a/src/trainer_card.c
+++ b/src/trainer_card.c
@@ -21,6 +21,7 @@
#include "gpu_regs.h"
#include "international_string_util.h"
#include "pokedex.h"
+#include "pokemon_icon.h"
#include "graphics.h"
#include "pokemon_icon.h"
#include "trainer_pokemon_sprites.h"
@@ -89,9 +90,6 @@ struct TrainerCardData
u8 language;
};
-//external functions
-extern u8 sub_80D30A0(u16);
-
// EWRAM
EWRAM_DATA struct TrainerCard gTrainerCards[4] = {0};
EWRAM_DATA static struct TrainerCardData *sData = NULL;
@@ -350,7 +348,7 @@ static void sub_80C2760(u8 taskId)
case 0:
if (!IsDma3ManagerBusyWithBgCopy())
{
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
sData->var_0++;
}
break;
@@ -363,7 +361,7 @@ static void sub_80C2760(u8 taskId)
sData->var_0++;
break;
case 3:
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
sub_80C4FF0();
sub_80C438C(2);
sData->var_0++;
@@ -469,7 +467,7 @@ static void sub_80C2760(u8 taskId)
break;
case 15:
sub_800AC34();
- NewMenuHelpers_DrawDialogueFrame(0, 1);
+ DrawDialogueFrame(0, 1);
AddTextPrinterParameterized(0, 1, gText_WaitingTrainerFinishReading, 0, 1, 255, 0);
CopyWindowToVram(0, 3);
sData->var_0 = 16;
@@ -1103,7 +1101,7 @@ static void PrintTimeOnCard(void)
r10 = width + 30;
r7 -= r10;
- FillWindowPixelRect(1, 0, r7, r4, r10, 15);
+ FillWindowPixelRect(1, PIXEL_FILL(0), r7, r4, r10, 15);
ConvertIntToDecimalStringN(gStringVar4, hours, 1, 3);
AddTextPrinterParameterized3(1, 1, r7, r4, gUnknown_0856FB0C, TEXT_SPEED_FF, gStringVar4);
r7 += 18;
@@ -1536,7 +1534,7 @@ static void sub_80C48C8(void)
}
}
-u8 sub_80C4904(u8 cardId)
+u8 GetTrainerCardStars(u8 cardId)
{
struct TrainerCard* trainerCards = gTrainerCards;
return trainerCards[cardId].stars;
@@ -1634,7 +1632,7 @@ static bool8 sub_80C4B08(struct Task* task)
switch (sData->var_4)
{
case 0:
- FillWindowPixelBuffer(1, 0);
+ FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20);
break;
case 1:
@@ -1659,7 +1657,7 @@ static bool8 sub_80C4B08(struct Task* task)
if (!sData->var_8)
sub_80C474C();
else
- FillWindowPixelBuffer(2, 0);
+ FillWindowPixelBuffer(2, PIXEL_FILL(0));
break;
case 4:
if (sData->var_8)
diff --git a/src/trainer_hill.c b/src/trainer_hill.c
index 42b196abd..43b29e26e 100644
--- a/src/trainer_hill.c
+++ b/src/trainer_hill.c
@@ -30,6 +30,7 @@
#include "constants/species.h"
#include "constants/trainers.h"
#include "constants/easy_chat.h"
+#include "constants/trainer_hill.h"
extern bool32 sub_81D3B34(void);
@@ -92,16 +93,16 @@ struct TrHillStruct2
// EWRAM
static EWRAM_DATA struct TrHillStruct2 *sHillData = NULL;
static EWRAM_DATA struct TrHillRoomTrainers *sRoomTrainers = NULL;
-EWRAM_DATA u32 *gUnknown_0203CF5C = NULL;
+EWRAM_DATA u32 *gTrainerHillVBlankCounter = NULL;
// This file's functions.
-static void sub_81D581C(void);
+static void TrainerHillStartChallenge(void);
static void sub_81D58D8(void);
static void sub_81D5924(void);
static void sub_81D59D0(void);
-static void sub_81D5A70(void);
-static void sub_81D5AB4(void);
-static void sub_81D5AD0(void);
+static void TrainerHillResumeTimer(void);
+static void TrainerHillSetPlayerLost(void);
+static void TrainerHillGetChallengeStatus(void);
static void sub_81D5B2C(void);
static void sub_81D5BBC(void);
static void sub_81D5C00(void);
@@ -112,7 +113,7 @@ static void sub_81D64DC(void);
static void sub_81D64FC(void);
static void sub_81D6518(void);
static void sub_81D6568(void);
-static void sub_81D65A0(void);
+static void TrainerHillSetTag(void);
static void SetUpDataStruct(void);
static void FreeDataStruct(void);
static void nullsub_2(void);
@@ -263,13 +264,13 @@ static const u8 *const sFloorStrings[] =
static void (* const sHillFunctions[])(void) =
{
- sub_81D581C,
+ TrainerHillStartChallenge,
sub_81D58D8,
sub_81D5924,
sub_81D59D0,
- sub_81D5A70,
- sub_81D5AB4,
- sub_81D5AD0,
+ TrainerHillResumeTimer,
+ TrainerHillSetPlayerLost,
+ TrainerHillGetChallengeStatus,
sub_81D5B2C,
sub_81D5BBC,
sub_81D5C00,
@@ -280,7 +281,7 @@ static void (* const sHillFunctions[])(void) =
sub_81D64FC,
sub_81D6518,
sub_81D6568,
- sub_81D65A0,
+ TrainerHillSetTag,
};
static const u8 *const sTagMatchStrings[] =
@@ -318,7 +319,7 @@ void ResetTrainerHillResults(void)
gSaveBlock2Ptr->frontier.field_EF9_1 = 0;
gSaveBlock2Ptr->frontier.field_EF9_0 = 0;
- gSaveBlock1Ptr->trainerHill.field_3D68 = 0;
+ gSaveBlock1Ptr->trainerHill.bestTime = 0;
for (i = 0; i < 4; i++)
SetTimerValue(&gSaveBlock1Ptr->trainerHillTimes[i], HILL_MAX_TIME);
}
@@ -371,7 +372,7 @@ void InitTrainerHillBattleStruct(void)
}
sRoomTrainers->facilityClass[i] = sHillData->tag.floors[sHillData->floorId].trainers[i].facilityClass;
}
- sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
+ SetTrainerHillVBlankCounter(&gSaveBlock1Ptr->trainerHill.timer);
FreeDataStruct();
}
@@ -425,7 +426,7 @@ void CopyTrainerHillTrainerText(u8 which, u16 trainerId)
FreeDataStruct();
}
-static void sub_81D581C(void)
+static void TrainerHillStartChallenge(void)
{
nullsub_2();
if (!sub_81D3B34())
@@ -434,11 +435,11 @@ static void sub_81D581C(void)
gSaveBlock1Ptr->trainerHill.field_3D6E_0f = 0;
gSaveBlock1Ptr->trainerHill.field_3D6C = 0;
- sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
- gSaveBlock1Ptr->trainerHill.field_3D64 = 0;
+ SetTrainerHillVBlankCounter(&gSaveBlock1Ptr->trainerHill.timer);
+ gSaveBlock1Ptr->trainerHill.timer = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0c = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 0;
- gSaveBlock1Ptr->trainerHill.field_3D6E_0e = 0;
+ gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge = 0;
gSaveBlock2Ptr->frontier.field_EE0 = 0;
gBattleOutcome = 0;
gSaveBlock1Ptr->trainerHill.field_3D6E_0a = 0;
@@ -446,7 +447,7 @@ static void sub_81D581C(void)
static void sub_81D58D8(void)
{
- sub_80008E8();
+ ClearTrainerHillVBlankCounter();
gSpecialVar_Result = 0;
if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
gSpecialVar_Result++;
@@ -483,10 +484,10 @@ static void sub_81D59D0(void)
{
gSpecialVar_Result = 2;
}
- else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68) > gSaveBlock1Ptr->trainerHill.field_3D64)
+ else if (GetTimerValue(&gSaveBlock1Ptr->trainerHill.bestTime) > gSaveBlock1Ptr->trainerHill.timer)
{
- SetTimerValue(&gSaveBlock1Ptr->trainerHill.field_3D68, gSaveBlock1Ptr->trainerHill.field_3D64);
- gSaveBlock1Ptr->trainerHillTimes[gSaveBlock1Ptr->trainerHill.tag] = gSaveBlock1Ptr->trainerHill.field_3D68;
+ SetTimerValue(&gSaveBlock1Ptr->trainerHill.bestTime, gSaveBlock1Ptr->trainerHill.timer);
+ gSaveBlock1Ptr->trainerHillTimes[gSaveBlock1Ptr->trainerHill.tag] = gSaveBlock1Ptr->trainerHill.bestTime;
gSpecialVar_Result = 0;
}
else
@@ -497,37 +498,40 @@ static void sub_81D59D0(void)
gSaveBlock1Ptr->trainerHill.field_3D6E_0b = 1;
}
-static void sub_81D5A70(void)
+static void TrainerHillResumeTimer(void)
{
if (!gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
{
- if (gSaveBlock1Ptr->trainerHill.field_3D64 >= HILL_MAX_TIME)
- gSaveBlock1Ptr->trainerHill.field_3D64 = HILL_MAX_TIME;
+ if (gSaveBlock1Ptr->trainerHill.timer >= HILL_MAX_TIME)
+ gSaveBlock1Ptr->trainerHill.timer = HILL_MAX_TIME;
else
- sub_80008DC(&gSaveBlock1Ptr->trainerHill.field_3D64);
+ SetTrainerHillVBlankCounter(&gSaveBlock1Ptr->trainerHill.timer);
}
}
-static void sub_81D5AB4(void)
+static void TrainerHillSetPlayerLost(void)
{
- gSaveBlock1Ptr->trainerHill.field_3D6E_0d = 1;
+ gSaveBlock1Ptr->trainerHill.hasLost = 1;
}
-static void sub_81D5AD0(void)
+static void TrainerHillGetChallengeStatus(void)
{
- if (gSaveBlock1Ptr->trainerHill.field_3D6E_0d)
+ if (gSaveBlock1Ptr->trainerHill.hasLost)
{
- gSaveBlock1Ptr->trainerHill.field_3D6E_0d = 0;
- gSpecialVar_Result = 0;
+ // The player lost their last match.
+ gSaveBlock1Ptr->trainerHill.hasLost = 0;
+ gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_LOST;
}
- else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0e)
+ else if (gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge)
{
- gSaveBlock1Ptr->trainerHill.field_3D6E_0e = 0;
- gSpecialVar_Result = 1;
+ // Unreachable code. Something relating to eCards?
+ gSaveBlock1Ptr->trainerHill.maybeECardScanDuringChallenge = 0;
+ gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_ECARD_SCANNED;
}
else
{
- gSpecialVar_Result = 2;
+ // Continue playing.
+ gSpecialVar_Result = TRAINER_HILL_PLAYER_STATUS_NORMAL;
}
}
@@ -535,7 +539,7 @@ static void sub_81D5B2C(void)
{
s32 total, minutes, secondsWhole, secondsFraction;
- total = gSaveBlock1Ptr->trainerHill.field_3D64;
+ total = gSaveBlock1Ptr->trainerHill.timer;
if (total >= HILL_MAX_TIME)
total = HILL_MAX_TIME;
@@ -575,7 +579,7 @@ static void sub_81D5C00(void)
bool8 sub_81D5C18(void)
{
- if (VarGet(VAR_0x40D6) == 0)
+ if (VarGet(VAR_TRAINER_HILL_IS_ACTIVE) == 0)
return FALSE;
else if (gSaveBlock1Ptr->trainerHill.field_3D6E_0c)
return FALSE;
@@ -609,7 +613,7 @@ void PrintOnTrainerHillRecordsWindow(void)
u32 total, minutes, secondsWhole, secondsFraction;
SetUpDataStruct();
- FillWindowPixelBuffer(0, 0);
+ FillWindowPixelBuffer(0, PIXEL_FILL(0));
x = GetStringCenterAlignXOffset(1, gText_TimeBoard, 0xD0);
AddTextPrinterParameterized3(0, 1, x, 2, sRecordWinColors, TEXT_SPEED_FF, gText_TimeBoard);
@@ -1048,16 +1052,16 @@ bool32 sub_81D6534(void)
static void sub_81D6568(void)
{
- if (gSaveBlock1Ptr->trainerHill.field_3D6E_0d)
+ if (gSaveBlock1Ptr->trainerHill.hasLost)
gSpecialVar_Result = 0;
else
gSpecialVar_Result = 1;
}
-static void sub_81D65A0(void)
+static void TrainerHillSetTag(void)
{
gSaveBlock1Ptr->trainerHill.tag = gSpecialVar_0x8005;
- gSaveBlock1Ptr->trainerHill.field_3D68 = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005];
+ gSaveBlock1Ptr->trainerHill.bestTime = gSaveBlock1Ptr->trainerHillTimes[gSpecialVar_0x8005];
}
static u8 sub_81D65E8(u8 arg0)
@@ -1103,7 +1107,7 @@ static u16 sub_81D6640(void)
i = (i + 1) % 10;
ptr = gUnknown_0862A5CC[var2][i];
- minutes = (signed)(gSaveBlock1Ptr->trainerHill.field_3D64) / (60 * 60);
+ minutes = (signed)(gSaveBlock1Ptr->trainerHill.timer) / (60 * 60);
if (minutes < 12)
id = 0;
else if (minutes < 13)
diff --git a/src/trainer_see.c b/src/trainer_see.c
index bc5d9cbc3..16ea88a45 100644
--- a/src/trainer_see.c
+++ b/src/trainer_see.c
@@ -17,8 +17,6 @@
#include "constants/event_object_movement_constants.h"
#include "constants/field_effects.h"
-extern void sub_809BE48(u16 npcId);
-
// this file's functions
static u8 CheckTrainer(u8 eventObjectId);
static u8 GetTrainerApproachDistance(struct EventObject *trainerObj);
diff --git a/src/tv.c b/src/tv.c
index ee3614e83..17243a456 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -39,6 +39,7 @@
#include "tv.h"
#include "data2.h"
#include "constants/layouts.h"
+#include "constants/metatile_behaviors.h"
// Static type declarations
@@ -853,9 +854,9 @@ void SetTVMetatilesOnMap(int width, int height, u16 tileId)
{
for (x = 0; x < width; x ++)
{
- if (MapGridGetMetatileBehaviorAt(x, y) == 0x86) // is this tile a TV?
+ if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION)
{
- MapGridSetMetatileIdAt(x, y, tileId | 0xc00);
+ MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
}
}
}
@@ -2565,13 +2566,13 @@ void sub_80EEA70(void)
show->secretBaseSecrets.kind = TVSHOW_SECRET_BASE_SECRETS;
show->secretBaseSecrets.active = FALSE;
StringCopy(show->secretBaseSecrets.playerName, gSaveBlock2Ptr->playerName);
- show->secretBaseSecrets.stepsInBase = VarGet(VAR_0x40EC);
+ show->secretBaseSecrets.stepsInBase = VarGet(VAR_SECRET_BASE_STEP_COUNTER);
sub_80E980C();
StringCopy(strbuf, gStringVar1);
StripExtCtrlCodes(strbuf);
StringCopy(show->secretBaseSecrets.baseOwnersName, strbuf);
- show->secretBaseSecrets.item = VarGet(VAR_0x40ED);
- show->secretBaseSecrets.flags = VarGet(VAR_0x40EE) + (VarGet(VAR_0x40EF) << 16);
+ show->secretBaseSecrets.item = VarGet(VAR_SECRET_BASE_LAST_ITEM_USED);
+ show->secretBaseSecrets.flags = VarGet(VAR_SECRET_BASE_LOW_TV_FLAGS) + (VarGet(VAR_SECRET_BASE_HIGH_TV_FLAGS) << 16);
tv_store_id_3x(show);
show->secretBaseSecrets.language = gGameLanguage;
if (show->secretBaseSecrets.language == LANGUAGE_JAPANESE || gSaveBlock1Ptr->secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].language == LANGUAGE_JAPANESE)
@@ -7350,7 +7351,7 @@ static void DoTVShowWhatsNo1InHoennToday(void)
ShowFieldMessage(sTVWhatsNo1InHoennTodayTextGroup[state]);
}
-u8 sub_80F5180(TVShow *show)
+u8 TVShowGetFlagCount(TVShow *show)
{
u8 i;
u8 tot;
@@ -7365,7 +7366,7 @@ u8 sub_80F5180(TVShow *show)
return tot;
}
-u8 sub_80F51AC(TVShow *show, u8 a1)
+u8 TVShowGetStateForFlagNumber(TVShow *show, u8 a1)
{
u8 i;
u8 tot;
@@ -7399,7 +7400,7 @@ static void DoTVShowSecretBaseSecrets(void)
case 0:
TVShowConvertInternationalString(gStringVar1, show->secretBaseSecrets.baseOwnersName, show->secretBaseSecrets.baseOwnersNameLanguage);
TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language);
- bitCount = sub_80F5180(show);
+ bitCount = TVShowGetFlagCount(show);
if (bitCount == 0)
{
sTVShowState = 8;
@@ -7408,12 +7409,12 @@ static void DoTVShowSecretBaseSecrets(void)
{
show->secretBaseSecrets.savedState = 1;
sTVSecretBaseSecretsRandomValues[0] = Random() % bitCount;
- sTVShowState = sub_80F51AC(show, sTVSecretBaseSecretsRandomValues[0]);
+ sTVShowState = TVShowGetStateForFlagNumber(show, sTVSecretBaseSecretsRandomValues[0]);
}
break;
case 1:
TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language);
- bitCount = sub_80F5180(show);
+ bitCount = TVShowGetFlagCount(show);
switch (bitCount)
{
case 1:
@@ -7423,11 +7424,11 @@ static void DoTVShowSecretBaseSecrets(void)
show->secretBaseSecrets.savedState = 2;
if (sTVSecretBaseSecretsRandomValues[0] == 0)
{
- sTVShowState = sub_80F51AC(show, 1);
+ sTVShowState = TVShowGetStateForFlagNumber(show, 1);
}
else
{
- sTVShowState = sub_80F51AC(show, 0);
+ sTVShowState = TVShowGetStateForFlagNumber(show, 0);
}
break;
default:
@@ -7440,13 +7441,13 @@ static void DoTVShowSecretBaseSecrets(void)
}
}
show->secretBaseSecrets.savedState = 2;
- sTVShowState = sub_80F51AC(show, sTVSecretBaseSecretsRandomValues[1]);
+ sTVShowState = TVShowGetStateForFlagNumber(show, sTVSecretBaseSecretsRandomValues[1]);
break;
}
break;
case 2:
TVShowConvertInternationalString(gStringVar2, show->secretBaseSecrets.playerName, show->secretBaseSecrets.language);
- bitCount = sub_80F5180(show);
+ bitCount = TVShowGetFlagCount(show);
if (bitCount == 2)
{
sTVShowState = 9;
@@ -7462,7 +7463,7 @@ static void DoTVShowSecretBaseSecrets(void)
}
}
show->secretBaseSecrets.savedState = 3;
- sTVShowState = sub_80F51AC(show, sTVSecretBaseSecretsRandomValues[2]);
+ sTVShowState = TVShowGetStateForFlagNumber(show, sTVSecretBaseSecretsRandomValues[2]);
}
break;
case 3:
diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c
index bbc256915..02648bf93 100644
--- a/src/unk_text_util_2.c
+++ b/src/unk_text_util_2.c
@@ -114,7 +114,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++;
return 2;
case 15:
- FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4));
+ FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
return 2;
}
break;
@@ -146,7 +146,7 @@ u16 Font6Func(struct TextPrinter *textPrinter)
case 2:
if (TextPrinterWaitWithDownArrow(textPrinter))
{
- FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4));
+ FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x;
textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y;
textPrinter->state = 0;
@@ -166,12 +166,12 @@ u16 Font6Func(struct TextPrinter *textPrinter)
{
if (textPrinter->scrollDistance < sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed])
{
- ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4));
+ ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance = 0;
}
else
{
- ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], textPrinter->printerTemplate.bgColor | (textPrinter->printerTemplate.bgColor << 4));
+ ScrollWindow(textPrinter->printerTemplate.windowId, 0, sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor));
textPrinter->scrollDistance -= sUnknown_08616124[gSaveBlock2Ptr->optionsTextSpeed];
}
CopyWindowToVram(textPrinter->printerTemplate.windowId, 2);
@@ -214,7 +214,7 @@ static void DecompressGlyphFont6(u16 glyph)
gUnknown_03002F90.unk81 = 0x10;
}
-u8 GetGlyphWidthFont6(void)
+u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese)
{
return 0x10;
}
diff --git a/src/wallclock.c b/src/wallclock.c
index 546750ba6..d3bbcf7a2 100644
--- a/src/wallclock.c
+++ b/src/wallclock.c
@@ -793,7 +793,7 @@ static void Task_SetClock2(u8 taskId)
static void Task_SetClock3(u8 taskId)
{
- SetWindowBorderStyle(0, FALSE, 0x250, 0x0d);
+ DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x250, 0x0d);
AddTextPrinterParameterized(0, 1, gText_IsThisTheCorrectTime, 0, 1, 0, NULL);
PutWindowTilemap(0);
schedule_bg_copy_tilemap_to_vram(0);
@@ -812,7 +812,7 @@ static void Task_SetClock4(u8 taskId)
case 1: //B button
case -1: //NO
PlaySE(SE_SELECT);
- sub_8198070(0, FALSE);
+ ClearStdWindowAndFrameToTransparent(0, FALSE);
ClearWindowTilemap(0);
gTasks[taskId].func = Task_SetClock2;
break;
diff --git a/src/water.c b/src/water.c
index d13b1378e..20bf2542d 100644
--- a/src/water.c
+++ b/src/water.c
@@ -13,35 +13,33 @@
#include "constants/battle.h"
#include "constants/rgb.h"
-extern void sub_810721C(struct Sprite *);
-extern void sub_8107228(struct Sprite *);
-extern void sub_8107260(struct Sprite *);
-extern void sub_8107380(struct Sprite *);
-extern void sub_8107408(struct Sprite *);
-extern void sub_8107430(struct Sprite *);
-extern void sub_810744C(struct Sprite *);
-extern void sub_81074E4(struct Sprite *);
-extern void sub_81075EC(struct Sprite *);
-extern void sub_8107674(struct Sprite *);
-extern void sub_8107730(struct Sprite *);
-extern void sub_81077A4(struct Sprite *);
-extern void sub_81077C0(struct Sprite *);
-extern void sub_80A78AC(struct Sprite *);
-extern void sub_8107894(struct Sprite *);
-extern void sub_81078D0(struct Sprite *);
-extern void sub_810790C(struct Sprite *);
-extern void sub_8108034(struct Sprite *);
-extern void sub_8108098(struct Sprite *);
-extern void sub_810851C(struct Sprite *);
-extern void sub_81087C0(struct Sprite *);
-extern void sub_810886C(struct Sprite *);
-extern void sub_8108B2C(struct Sprite *);
-extern void sub_8108B94(struct Sprite *);
-extern void sub_8108BE0(struct Sprite *);
-extern void sub_8108C08(struct Sprite *);
-extern void sub_8108C54(struct Sprite *);
-extern void sub_8108CDC(struct Sprite *);
-extern void sub_80A8EE4(struct Sprite *);
+void sub_810721C(struct Sprite *);
+void sub_8107228(struct Sprite *);
+void sub_8107260(struct Sprite *);
+void sub_8107380(struct Sprite *);
+void sub_8107408(struct Sprite *);
+void sub_8107430(struct Sprite *);
+void sub_810744C(struct Sprite *);
+void sub_81074E4(struct Sprite *);
+void sub_81075EC(struct Sprite *);
+void sub_8107674(struct Sprite *);
+void sub_8107730(struct Sprite *);
+void sub_81077A4(struct Sprite *);
+void sub_81077C0(struct Sprite *);
+void sub_8107894(struct Sprite *);
+void sub_81078D0(struct Sprite *);
+void sub_810790C(struct Sprite *);
+void sub_8108034(struct Sprite *);
+void sub_8108098(struct Sprite *);
+void sub_810851C(struct Sprite *);
+void sub_81087C0(struct Sprite *);
+void sub_810886C(struct Sprite *);
+void sub_8108B2C(struct Sprite *);
+void sub_8108B94(struct Sprite *);
+void sub_8108BE0(struct Sprite *);
+void sub_8108C08(struct Sprite *);
+void sub_8108C54(struct Sprite *);
+void sub_8108CDC(struct Sprite *);
void sub_810756C(u8);
void sub_81076F4(u8);
void sub_8107B84(u8);
diff --git a/src/window.c b/src/window.c
index 3da529178..fbce57743 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6,7 +6,8 @@
u32 filler_03002F58;
u32 filler_03002F5C;
-u8 gUnknown_03002F60;
+// This global is set to 0 and never changed.
+u8 gTransparentTileNumber;
u32 filler_03002F64;
void *gUnknown_03002F70[4];
extern u32 gUnneededFireRedVariable;
@@ -106,7 +107,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
}
}
- gUnknown_03002F60 = 0;
+ gTransparentTileNumber = 0;
return TRUE;
}
@@ -359,13 +360,14 @@ void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 h
}
}
+// Fills a window with transparent tiles.
void ClearWindowTilemap(u8 windowId)
{
struct Window windowLocal = gWindows[windowId];
FillBgTilemapBufferRect(
windowLocal.window.bg,
- gUnknown_03002F60,
+ gTransparentTileNumber,
windowLocal.window.tilemapLeft,
windowLocal.window.tilemapTop,
windowLocal.window.width,
@@ -451,6 +453,7 @@ void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOff
LZ77UnCompWram(src, gWindows[windowId].tileData + (0x20 * tileOffset));
}
+// Sets all pixels within the window to the fillValue color.
void FillWindowPixelBuffer(u8 windowId, u8 fillValue)
{
int fillSize = gWindows[windowId].window.width * gWindows[windowId].window.height;
diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile
index 367a3350b..53c9d0060 100644
--- a/tools/scaninc/Makefile
+++ b/tools/scaninc/Makefile
@@ -2,9 +2,9 @@ CXX = g++
CXXFLAGS = -Wall -Werror -std=c++11 -O2
-SRCS = scaninc.cpp c_file.cpp asm_file.cpp
+SRCS = scaninc.cpp c_file.cpp asm_file.cpp source_file.cpp
-HEADERS := scaninc.h asm_file.h c_file.h
+HEADERS := scaninc.h asm_file.h c_file.h source_file.h
.PHONY: clean
diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp
index 6322749e2..109e604a2 100644
--- a/tools/scaninc/asm_file.cpp
+++ b/tools/scaninc/asm_file.cpp
@@ -64,7 +64,8 @@ IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)
IncDirectiveType incDirectiveType = IncDirectiveType::None;
- if (PeekChar() == '.')
+ char c = PeekChar();
+ if (c == '.' || c == '#')
{
m_pos++;
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp
index 3dc221479..b95cbd033 100644
--- a/tools/scaninc/scaninc.cpp
+++ b/tools/scaninc/scaninc.cpp
@@ -25,8 +25,7 @@
#include <set>
#include <string>
#include "scaninc.h"
-#include "asm_file.h"
-#include "c_file.h"
+#include "source_file.h"
bool CanOpenFile(std::string path)
{
@@ -46,7 +45,7 @@ int main(int argc, char **argv)
std::queue<std::string> filesToProcess;
std::set<std::string> dependencies;
- std::list<std::string> includeDirs;
+ std::vector<std::string> includeDirs;
argc--;
argv++;
@@ -63,7 +62,7 @@ int main(int argc, char **argv)
argv++;
includeDir = std::string(argv[0]);
}
- if (includeDir.back() != '/')
+ if (!includeDir.empty() && includeDir.back() != '/')
{
includeDir += '/';
}
@@ -83,79 +82,36 @@ int main(int argc, char **argv)
std::string initialPath(argv[0]);
- std::size_t pos = initialPath.find_last_of('.');
+ filesToProcess.push(initialPath);
- if (pos == std::string::npos)
- FATAL_ERROR("no file extension in path \"%s\"\n", initialPath.c_str());
-
- std::string extension = initialPath.substr(pos + 1);
-
- std::string srcDir("");
- std::size_t slash = initialPath.rfind('/');
- if (slash != std::string::npos)
- {
- srcDir = initialPath.substr(0, slash + 1);
- }
- includeDirs.push_back(srcDir);
-
- if (extension == "c" || extension == "h")
+ while (!filesToProcess.empty())
{
- filesToProcess.push(initialPath);
+ std::string filePath = filesToProcess.front();
+ SourceFile file(filePath);
+ filesToProcess.pop();
- while (!filesToProcess.empty())
+ includeDirs.push_back(file.GetSrcDir());
+ for (auto incbin : file.GetIncbins())
{
- CFile file(filesToProcess.front());
- filesToProcess.pop();
-
- file.FindIncbins();
- for (auto incbin : file.GetIncbins())
- {
- dependencies.insert(incbin);
- }
- for (auto include : file.GetIncludes())
+ dependencies.insert(incbin);
+ }
+ for (auto include : file.GetIncludes())
+ {
+ for (auto includeDir : includeDirs)
{
- for (auto includeDir : includeDirs)
+ std::string path(includeDir + include);
+ if (CanOpenFile(path))
{
- std::string path(includeDir + include);
- if (CanOpenFile(path))
+ bool inserted = dependencies.insert(path).second;
+ if (inserted)
{
- bool inserted = dependencies.insert(path).second;
- if (inserted)
- {
- filesToProcess.push(path);
- }
- break;
+ filesToProcess.push(path);
}
+ break;
}
}
}
- }
- else if (extension == "s" || extension == "inc")
- {
- filesToProcess.push(initialPath);
-
- while (!filesToProcess.empty())
- {
- AsmFile file(filesToProcess.front());
-
- filesToProcess.pop();
-
- IncDirectiveType incDirectiveType;
- std::string path;
-
- while ((incDirectiveType = file.ReadUntilIncDirective(path)) != IncDirectiveType::None)
- {
- bool inserted = dependencies.insert(path).second;
- if (inserted
- && incDirectiveType == IncDirectiveType::Include
- && CanOpenFile(path))
- filesToProcess.push(path);
- }
- }
- }
- else
- {
- FATAL_ERROR("unknown extension \"%s\"\n", extension.c_str());
+ includeDirs.pop_back();
}
for (const std::string &path : dependencies)
diff --git a/tools/scaninc/source_file.cpp b/tools/scaninc/source_file.cpp
new file mode 100644
index 000000000..f23ff6db6
--- /dev/null
+++ b/tools/scaninc/source_file.cpp
@@ -0,0 +1,125 @@
+// Copyright(c) 2019 Phlosioneer
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <new>
+#include "source_file.h"
+
+
+SourceFileType GetFileType(std::string& path)
+{
+ std::size_t pos = path.find_last_of('.');
+
+ if (pos == std::string::npos)
+ FATAL_ERROR("no file extension in path \"%s\"\n", path.c_str());
+
+ std::string extension = path.substr(pos + 1);
+
+ if (extension == "c")
+ return SourceFileType::Cpp;
+ else if (extension == "s")
+ return SourceFileType::Asm;
+ else if (extension == "h")
+ return SourceFileType::Header;
+ else if (extension == "inc")
+ return SourceFileType::Inc;
+ else
+ FATAL_ERROR("Unrecognized extension \"%s\"\n", extension.c_str());
+
+ // Unreachable
+ return SourceFileType::Cpp;
+}
+
+std::string GetDir(std::string& path)
+{
+ std::size_t slash = path.rfind('/');
+
+ if (slash != std::string::npos)
+ return path.substr(0, slash + 1);
+ else
+ return std::string("");
+}
+
+SourceFile::SourceFile(std::string path)
+{
+ m_file_type = GetFileType(path);
+
+ m_src_dir = GetDir(path);
+
+ if (m_file_type == SourceFileType::Cpp
+ || m_file_type == SourceFileType::Header)
+ {
+ new (&m_source_file.c_file) CFile(path);
+ m_source_file.c_file.FindIncbins();
+ }
+ else
+ {
+ AsmFile file(path);
+ std::set<std::string> incbins;
+ std::set<std::string> includes;
+
+ IncDirectiveType incDirectiveType;
+ std::string outputPath;
+
+ while ((incDirectiveType = file.ReadUntilIncDirective(outputPath)) != IncDirectiveType::None)
+ {
+ if (incDirectiveType == IncDirectiveType::Include)
+ includes.insert(outputPath);
+ else
+ incbins.insert(outputPath);
+ }
+
+ new (&m_source_file.asm_wrapper) SourceFile::InnerUnion::AsmWrapper{incbins, includes};
+ }
+}
+
+SourceFile::~SourceFile()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ {
+ m_source_file.c_file.~CFile();
+ }
+ else
+ {
+ m_source_file.asm_wrapper.asm_incbins.~set();
+ m_source_file.asm_wrapper.asm_includes.~set();
+ }
+}
+
+const std::set<std::string>& SourceFile::GetIncbins()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ return m_source_file.c_file.GetIncbins();
+ else
+ return m_source_file.asm_wrapper.asm_incbins;
+}
+
+const std::set<std::string>& SourceFile::GetIncludes()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ return m_source_file.c_file.GetIncludes();
+ else
+ return m_source_file.asm_wrapper.asm_includes;
+}
+
+std::string& SourceFile::GetSrcDir()
+{
+ return m_src_dir;
+}
+
diff --git a/tools/scaninc/source_file.h b/tools/scaninc/source_file.h
new file mode 100644
index 000000000..f7b6412bd
--- /dev/null
+++ b/tools/scaninc/source_file.h
@@ -0,0 +1,71 @@
+// Copyright(c) 2019 Phlosioneer
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#ifndef SOURCE_FILE_H
+#define SOURCE_FILE_H
+
+#include <string>
+#include "scaninc.h"
+#include "asm_file.h"
+#include "c_file.h"
+
+enum class SourceFileType
+{
+ Cpp,
+ Header,
+ Asm,
+ Inc
+};
+
+SourceFileType GetFileType(std::string& path);
+
+class SourceFile
+{
+public:
+
+ SourceFile(std::string path);
+ ~SourceFile();
+ SourceFile(SourceFile const&) = delete;
+ SourceFile(SourceFile&&) = delete;
+ SourceFile& operator =(SourceFile const&) = delete;
+ SourceFile& operator =(SourceFile&&) = delete;
+ bool HasIncbins();
+ const std::set<std::string>& GetIncbins();
+ const std::set<std::string>& GetIncludes();
+ std::string& GetSrcDir();
+
+private:
+ union InnerUnion {
+ CFile c_file;
+ struct AsmWrapper {
+ std::set<std::string> asm_incbins;
+ std::set<std::string> asm_includes;
+ } asm_wrapper;
+
+ // Construction and destruction handled by SourceFile.
+ InnerUnion() {};
+ ~InnerUnion() {};
+ } m_source_file;
+ SourceFileType m_file_type;
+ std::string m_src_dir;
+};
+
+#endif // SOURCE_FILE_H
+