diff options
Diffstat (limited to 'src')
89 files changed, 817 insertions, 260 deletions
@@ -1,5 +1,4 @@ #include "global.h" -#include "task.h" #include "palette.h" #include "item_menu.h" #include "text.h" @@ -9,7 +8,6 @@ #include "new_menu_helpers.h" #include "menu.h" #include "money.h" -#include "bag.h" #include "strings.h" static const u16 sBagWindowPalF[] = INCBIN_U16("data/bag/bag_window_pal.gbapal"); diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 647d2f367..33b5ceacc 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -1,15 +1,9 @@ #include "global.h" -#include "malloc.h" #include "battle_anim.h" #include "battle_interface.h" -#include "decompress.h" #include "gpu_regs.h" -#include "graphics.h" -#include "main.h" -#include "math_util.h" #include "palette.h" #include "random.h" -#include "scanline_effect.h" #include "sound.h" #include "trig.h" #include "util.h" diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 23be07785..093660389 100644 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -5,7 +5,6 @@ #include "decompress.h" #include "gpu_regs.h" #include "graphics.h" -#include "main.h" #include "math_util.h" #include "palette.h" #include "random.h" diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 7df93e170..3d8729824 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -1,27 +1,20 @@ #include "global.h" -#include "bg.h" #include "data.h" #include "link.h" -#include "main.h" #include "m4a.h" #include "palette.h" #include "pokeball.h" #include "pokemon.h" -#include "reshow_battle_screen.h" #include "sound.h" #include "string_util.h" #include "task.h" #include "text.h" #include "util.h" -#include "window.h" #include "battle.h" -#include "battle_ai_script_commands.h" #include "battle_anim.h" #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" -#include "battle_setup.h" -#include "battle_tower.h" #include "constants/battle_anim.h" #include "constants/songs.h" #include "constants/facility_trainer_classes.h" diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 96130f049..5ac4f1abc 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -1,9 +1,6 @@ #include "global.h" -#include "bg.h" #include "data.h" #include "link.h" -#include "main.h" -#include "m4a.h" #include "palette.h" #include "pokeball.h" #include "pokemon.h" @@ -12,16 +9,11 @@ #include "task.h" #include "text.h" #include "util.h" -#include "window.h" #include "battle.h" -#include "battle_ai_script_commands.h" #include "battle_anim.h" #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" -#include "battle_setup.h" -#include "battle_tower.h" -#include "reshow_battle_screen.h" #include "constants/battle_anim.h" #include "constants/songs.h" diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 3cb6d1432..26e35ae65 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1,15 +1,10 @@ #include "global.h" -#include "bg.h" #include "data.h" -#include "item.h" -#include "link.h" #include "main.h" #include "m4a.h" #include "task.h" #include "text.h" #include "util.h" -#include "window.h" -#include "palette.h" #include "pokeball.h" #include "pokemon.h" #include "random.h" @@ -20,15 +15,12 @@ #include "battle_controllers.h" #include "battle_message.h" #include "battle_interface.h" -#include "battle_setup.h" #include "battle_tower.h" #include "battle_gfx_sfx_util.h" #include "battle_ai_script_commands.h" #include "battle_ai_switch_items.h" #include "trainer_tower.h" -#include "reshow_battle_screen.h" #include "constants/battle_anim.h" -#include "constants/items.h" #include "constants/moves.h" #include "constants/songs.h" diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 7b0a8aa47..a751c0eea 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -10,7 +10,6 @@ #include "party_menu.h" #include "pokeball.h" #include "pokemon.h" -#include "random.h" #include "sound.h" #include "strings.h" #include "string_util.h" @@ -24,7 +23,6 @@ #include "battle_controllers.h" #include "battle_interface.h" #include "battle_message.h" -#include "battle_setup.h" #include "battle_script_commands.h" #include "reshow_battle_screen.h" #include "constants/battle_anim.h" diff --git a/src/battle_controller_pokedude.c b/src/battle_controller_pokedude.c index d8ebe5ba4..8737a3866 100644 --- a/src/battle_controller_pokedude.c +++ b/src/battle_controller_pokedude.c @@ -11,7 +11,6 @@ #include "link.h" #include "sound.h" #include "event_data.h" -#include "item.h" #include "item_menu.h" #include "text.h" #include "strings.h" @@ -25,7 +24,6 @@ #include "reshow_battle_screen.h" #include "teachy_tv.h" #include "constants/songs.h" -#include "constants/items.h" #include "constants/moves.h" #include "constants/pokemon.h" #include "constants/trainers.h" diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 4b5153c7c..28ed4091e 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -9,16 +9,12 @@ #include "item_menu.h" #include "link.h" #include "main.h" -#include "m4a.h" #include "palette.h" #include "pokeball.h" #include "pokemon.h" -#include "reshow_battle_screen.h" #include "sound.h" -#include "task.h" #include "text.h" #include "util.h" -#include "window.h" #include "strings.h" #include "constants/songs.h" #include "constants/battle_anim.h" diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 60cff27be..6f9f2b217 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -13,8 +13,6 @@ #include "party_menu.h" #include "battle.h" #include "battle_main.h" -#include "battle_controllers.h" -#include "battle_ai_script_commands.h" #include "battle_anim.h" #include "battle_interface.h" #include "constants/battle_anim.h" diff --git a/src/battle_interface.c b/src/battle_interface.c index 56e9e0fad..e5145adc0 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -12,7 +12,6 @@ #include "safari_zone.h" #include "sound.h" #include "string_util.h" -#include "strings.h" #include "text.h" #include "window.h" #include "constants/songs.h" diff --git a/src/battle_main.c b/src/battle_main.c index faad8bafb..d160436ff 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -8,13 +8,11 @@ #include "battle_message.h" #include "battle_scripts.h" #include "battle_setup.h" -#include "battle_tower.h" #include "battle_string_ids.h" #include "berry.h" #include "bg.h" #include "data.h" #include "decompress.h" -#include "dma3.h" #include "event_data.h" #include "evolution_scene.h" #include "graphics.h" @@ -40,14 +38,12 @@ #include "sound.h" #include "sprite.h" #include "string_util.h" -#include "strings.h" #include "task.h" #include "text.h" #include "trig.h" #include "vs_seeker.h" #include "util.h" #include "window.h" -#include "cable_club.h" #include "constants/abilities.h" #include "constants/battle_move_effects.h" #include "constants/battle_setup.h" diff --git a/src/battle_message.c b/src/battle_message.c index d8367c75e..6ec4c3f5d 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -22,7 +22,6 @@ #include "constants/moves.h" #include "constants/items.h" #include "constants/trainer_classes.h" -#include "constants/trainer_tower.h" struct BattleWindowText { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4875a63f2..de505827f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3,7 +3,6 @@ #include "util.h" #include "pokemon.h" #include "random.h" -#include "data.h" #include "text.h" #include "sound.h" #include "pokedex.h" @@ -14,7 +13,6 @@ #include "bg.h" #include "string_util.h" #include "pokemon_icon.h" -#include "m4a.h" #include "mail.h" #include "event_data.h" #include "strings.h" @@ -30,7 +28,6 @@ #include "battle.h" #include "battle_message.h" #include "battle_anim.h" -#include "battle_setup.h" #include "battle_ai_script_commands.h" #include "battle_scripts.h" #include "battle_string_ids.h" diff --git a/src/battle_setup.c b/src/battle_setup.c index 73e7acc1a..354487abd 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -13,7 +13,7 @@ #include "strings.h" #include "string_util.h" #include "event_data.h" -#include "event_object_80688E4.h" +#include "event_object_movement.h" #include "metatile_behavior.h" #include "event_scripts.h" #include "fldeff.h" @@ -22,10 +22,8 @@ #include "field_player_avatar.h" #include "field_screen_effect.h" #include "field_message_box.h" -#include "event_object_movement.h" #include "vs_seeker.h" #include "battle.h" -#include "battle_setup.h" #include "battle_transition.h" #include "battle_controllers.h" #include "constants/battle_setup.h" @@ -37,7 +35,6 @@ #include "constants/pokemon.h" #include "constants/trainers.h" #include "constants/trainer_classes.h" -#include "constants/maps.h" enum { diff --git a/src/battle_util2.c b/src/battle_util2.c index a3a748767..6de4941cb 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -5,7 +5,6 @@ #include "pokemon.h" #include "malloc.h" #include "trainer_tower.h" -#include "battle_util2.h" void AllocateBattleResources(void) { diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index e60a53ef9..2e0bf8256 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -1,17 +1,12 @@ #include "global.h" #include "gpu_regs.h" #include "multiboot.h" -#include "malloc.h" -#include "bg.h" #include "graphics.h" #include "main.h" #include "sprite.h" #include "task.h" #include "scanline_effect.h" -#include "window.h" -#include "text.h" #include "help_system.h" -#include "menu.h" #include "m4a.h" // Static type declarations diff --git a/src/credits.c b/src/credits.c index ceb2028f9..a53d72f31 100644 --- a/src/credits.c +++ b/src/credits.c @@ -11,8 +11,6 @@ #include "decompress.h" #include "graphics.h" #include "strings.h" -#include "menu.h" -#include "field_weather.h" #include "trainer_pokemon_sprites.h" #include "sound.h" #include "constants/species.h" diff --git a/src/daycare.c b/src/daycare.c index 277a382c7..f9d1b7557 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1,7 +1,6 @@ #include "global.h" #include "gflib.h" #include "battle.h" -#include "daycare.h" #include "constants/species.h" #include "constants/items.h" #include "mail_data.h" diff --git a/src/decompress.c b/src/decompress.c index caeda738a..3f0c82bce 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -2,7 +2,6 @@ #include "malloc.h" #include "decompress.h" #include "pokemon.h" -#include "text.h" #include "constants/species.h" extern const struct CompressedSpriteSheet gMonFrontPicTable[]; diff --git a/src/digit_obj_util.c b/src/digit_obj_util.c index af2618615..ed762c3c3 100644 --- a/src/digit_obj_util.c +++ b/src/digit_obj_util.c @@ -3,7 +3,6 @@ #include "decompress.h" #include "digit_obj_util.h" #include "main.h" -#include "battle.h" struct DigitPrinterAlloc { diff --git a/src/diploma.c b/src/diploma.c index afb22400b..f702eebd5 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -4,7 +4,6 @@ #include "dynamic_placeholder_text_util.h" #include "gba/macro.h" #include "gpu_regs.h" -#include "gpu_regs.h" #include "main.h" #include "malloc.h" #include "menu.h" @@ -19,7 +18,6 @@ #include "task.h" #include "text.h" #include "window.h" -#include "diploma.h" struct Diploma { diff --git a/src/dynamic_placeholder_text_util.c b/src/dynamic_placeholder_text_util.c index a2622bf02..20e7258d3 100644 --- a/src/dynamic_placeholder_text_util.c +++ b/src/dynamic_placeholder_text_util.c @@ -1,6 +1,5 @@ #include "global.h" #include "text.h" -#include "dynamic_placeholder_text_util.h" #include "string_util.h" #include "constants/object_events.h" @@ -10,10 +9,10 @@ static const u8 sTextColorTable[] = { // [LOW_NYBBLE / 2] = 0xXY, // HIGH_NYBBLE [OBJECT_EVENT_GFX_RED_NORMAL / 2] = 0x00, // OBJECT_EVENT_GFX_RED_BIKE - [OBJECT_EVENT_GFX_RED_RUN / 2] = 0x00, // OBJECT_EVENT_GFX_RED_ITEM + [OBJECT_EVENT_GFX_RED_SURF / 2] = 0x00, // OBJECT_EVENT_GFX_RED_ITEM [OBJECT_EVENT_GFX_RED_FISH / 2] = 0x00, // OBJECT_EVENT_GFX_RED_ITEM_COPY [OBJECT_EVENT_GFX_RED_VS_SEEKER / 2] = 0x10, // OBJECT_EVENT_GFX_GREEN_NORMAL - [OBJECT_EVENT_GFX_GREEN_BIKE / 2] = 0x11, // OBJECT_EVENT_GFX_GREEN_RUN + [OBJECT_EVENT_GFX_GREEN_BIKE / 2] = 0x11, // OBJECT_EVENT_GFX_GREEN_SURF [OBJECT_EVENT_GFX_GREEN_ITEM / 2] = 0x11, // OBJECT_EVENT_GFX_GREEN_FISH [OBJECT_EVENT_GFX_GREEN_ITEM_COPY / 2] = 0x11, // OBJECT_EVENT_GFX_GREEN_VS_SEEKER [OBJECT_EVENT_GFX_RS_BRENDAN / 2] = 0x10, // OBJECT_EVENT_GFX_RS_MAY diff --git a/src/easy_chat.c b/src/easy_chat.c index 1d2873fc2..14662b660 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1,33 +1,18 @@ #include "global.h" #include "malloc.h" -#include "bg.h" #include "data.h" -#include "decompress.h" -#include "dynamic_placeholder_text_util.h" #include "easy_chat.h" #include "event_data.h" #include "field_message_box.h" -#include "field_weather.h" -#include "gpu_regs.h" -#include "graphics.h" -#include "main.h" #include "mevent.h" #include "menu.h" #include "mail.h" -#include "overworld.h" -#include "palette.h" #include "pokedex.h" #include "random.h" -#include "sound.h" #include "string_util.h" #include "strings.h" -#include "task.h" -#include "text_window.h" -#include "window.h" #include "constants/easy_chat.h" -#include "constants/object_events.h" #include "constants/flags.h" -#include "constants/songs.h" #include "constants/species.h" struct Unk203A120 diff --git a/src/event_object_80688E4.c b/src/event_object_80688E4.c index 2d79c4f7b..de4cf358a 100644 --- a/src/event_object_80688E4.c +++ b/src/event_object_80688E4.c @@ -1,5 +1,4 @@ #include "global.h" -#include "event_object_80688E4.h" #include "event_object_movement.h" #include "field_effect.h" #include "field_ground_effect.h" @@ -204,6 +203,7 @@ void sub_8068BBC(struct Sprite *sprite, u8 direction) sprite->tStepNo = 0; } +// used by an_walk_any_2 bool8 sub_8068BCC(struct Sprite *sprite) { if (!(sprite->tDelay & 1)) diff --git a/src/event_object_lock.c b/src/event_object_lock.c index 304b71c28..2bb9736aa 100644 --- a/src/event_object_lock.c +++ b/src/event_object_lock.c @@ -3,9 +3,7 @@ #include "field_player_avatar.h" #include "event_object_movement.h" #include "script_movement.h" -#include "event_object_80688E4.h" #include "event_data.h" -#include "event_object_lock.h" bool8 walkrun_is_standing_still(void) { diff --git a/src/evolution_scene.c b/src/evolution_scene.c index f3b05b32c..71eb3fc36 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -31,8 +31,6 @@ #include "text.h" #include "text_window.h" #include "trig.h" -#include "trade.h" -#include "util.h" #include "battle_string_ids.h" #include "constants/species.h" #include "constants/songs.h" diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index 2e1dcd919..6e937e026 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -13,12 +13,11 @@ #include "metatile_behavior.h" #include "quest_log.h" #include "link.h" -#include "event_object_80688E4.h" +#include "event_object_movement.h" #include "sound.h" #include "field_door.h" #include "field_effect.h" #include "field_screen_effect.h" -#include "event_object_movement.h" #include "field_specials.h" #include "event_object_lock.h" #include "start_menu.h" @@ -415,7 +414,7 @@ static void task_map_chg_seq_0807E20C(u8 taskId) if (sub_807E418()) { sub_807DCB0(TRUE); - ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], sub_8063F84(GetPlayerFacingDirection())); + ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], GetWalkNormalMovementAction(GetPlayerFacingDirection())); task->data[0] = 2; } break; diff --git a/src/field_specials.c b/src/field_specials.c index a1de82c0f..d9d15748a 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -46,6 +46,7 @@ #include "constants/region_map.h" #include "constants/moves.h" #include "constants/menu.h" +#include "constants/event_objects.h" static EWRAM_DATA u8 sElevatorCurrentFloorWindowId = 0; static EWRAM_DATA u16 sElevatorScroll = 0; @@ -315,7 +316,7 @@ void Special_AnimatePcTurnOff() void SpawnCameraObject(void) { - u8 objectEventId = SpawnSpecialObjectEventParameterized(OBJECT_EVENT_GFX_YOUNGSTER, 8, 127, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3); + u8 objectEventId = SpawnSpecialObjectEventParameterized(OBJECT_EVENT_GFX_YOUNGSTER, 8, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3); gObjectEvents[objectEventId].invisible = TRUE; CameraObjectSetFollowedObjectId(gObjectEvents[objectEventId].spriteId); } diff --git a/src/fieldmap.c b/src/fieldmap.c index 90682da10..1f7d8b0b8 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -3,7 +3,6 @@ #include "palette.h" #include "overworld.h" #include "script.h" -#include "menu.h" #include "new_menu_helpers.h" #include "quest_log.h" #include "fieldmap.h" diff --git a/src/fldeff_dig.c b/src/fldeff_dig.c index 7d229ce3f..9e1686468 100644 --- a/src/fldeff_dig.c +++ b/src/fldeff_dig.c @@ -5,8 +5,6 @@ #include "item_use.h" #include "overworld.h" #include "party_menu.h" -#include "sprite.h" -#include "constants/object_events.h" static void FieldCallback_Dig(void); static void sub_80C9AFC(void); diff --git a/src/fldeff_rocksmash.c b/src/fldeff_rocksmash.c index 00f17a16d..baa51412b 100644 --- a/src/fldeff_rocksmash.c +++ b/src/fldeff_rocksmash.c @@ -3,16 +3,12 @@ #include "field_player_avatar.h" #include "field_effect.h" #include "party_menu.h" -#include "malloc.h" #include "event_data.h" #include "script.h" #include "fldeff.h" #include "event_scripts.h" -#include "field_weather.h" #include "sound.h" -#include "palette.h" #include "overworld.h" -#include "wild_encounter.h" #include "event_object_movement.h" #include "constants/songs.h" #include "constants/object_events.h" diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index 60437c125..966a7934c 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -5,7 +5,6 @@ #include "menu.h" #include "new_menu_helpers.h" #include "constants/songs.h" -#include "fldeff.h" static void sub_80E57E8(u8 taskId); static void sub_80E583C(u8 taskId); diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index b8d5af31d..f3ddd8212 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -6,7 +6,6 @@ #include "script.h" #include "fldeff.h" #include "event_scripts.h" -#include "constants/songs.h" #include "constants/object_events.h" static void FldEff_UseStrength(void); diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 943d8504c..45c471e95 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -3,7 +3,6 @@ #include "field_effect.h" #include "party_menu.h" #include "malloc.h" -#include "event_data.h" #include "script.h" #include "fldeff.h" #include "event_scripts.h" diff --git a/src/help_system.c b/src/help_system.c index bb3135260..d68acbaa1 100644 --- a/src/help_system.c +++ b/src/help_system.c @@ -10,9 +10,7 @@ #include "strings.h" #include "text.h" #include "blit.h" -#include "event_data.h" #include "constants/songs.h" -#include "constants/flags.h" extern u8 gGlyphInfo[]; diff --git a/src/hof_pc.c b/src/hof_pc.c index 76fd06abf..353c067c2 100644 --- a/src/hof_pc.c +++ b/src/hof_pc.c @@ -5,7 +5,6 @@ #include "script.h" #include "script_menu.h" #include "task.h" -#include "hall_of_fame.h" #include "bg.h" #include "window.h" @@ -1,10 +1,8 @@ #include "global.h" #include "battle_anim.h" #include "bg.h" -#include "field_weather.h" #include "gpu_regs.h" #include "graphics.h" -#include "main.h" #include "palette.h" #include "random.h" #include "sprite.h" diff --git a/src/item_menu.c b/src/item_menu.c index ffba2eae9..a407c582f 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -5,7 +5,7 @@ #include "berry_pouch.h" #include "decompress.h" #include "event_scripts.h" -#include "event_object_80688E4.h" +#include "event_object_movement.h" #include "field_player_avatar.h" #include "graphics.h" #include "help_system.h" diff --git a/src/item_use.c b/src/item_use.c index 022be5b2b..f5e880f98 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -19,7 +19,6 @@ #include "mail.h" #include "main.h" #include "malloc.h" -#include "event_object_80688E4.h" #include "event_object_lock.h" #include "metatile_behavior.h" #include "new_menu_helpers.h" @@ -42,7 +41,6 @@ #include "constants/maps.h" #include "constants/moves.h" #include "constants/songs.h" -#include "constants/maps.h" static EWRAM_DATA void (*sItemUseOnFieldCB)(u8 taskId) = NULL; diff --git a/src/itemfinder.c b/src/itemfinder.c index 370fce841..5d6950acc 100644 --- a/src/itemfinder.c +++ b/src/itemfinder.c @@ -10,7 +10,6 @@ #include "field_player_avatar.h" #include "field_specials.h" #include "fieldmap.h" -#include "itemfinder.h" #include "constants/songs.h" static void Task_NoResponse_CleanUp(u8 taskId); diff --git a/src/list_menu.c b/src/list_menu.c index 706c1679b..bd1d2699e 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -8,9 +8,7 @@ #include "main.h" #include "task.h" #include "graphics.h" -#include "decompress.h" #include "palette.h" -#include "malloc.h" #include "strings.h" #include "sound.h" #include "pokemon_icon.h" diff --git a/src/load_save.c b/src/load_save.c index 7f16f74a5..7ab28ffc3 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -8,7 +8,6 @@ #include "item.h" #include "save_location.h" #include "berry_powder.h" -#include "item.h" #include "overworld.h" #include "quest_log.h" diff --git a/src/main.c b/src/main.c index b88326cda..a67c71746 100644 --- a/src/main.c +++ b/src/main.c @@ -9,7 +9,6 @@ #include "random.h" #include "dma3.h" #include "gba/flash_internal.h" -#include "battle.h" #include "help_system.h" #include "sound.h" #include "new_menu_helpers.h" @@ -17,12 +16,10 @@ #include "overworld.h" #include "sprite.h" #include "play_time.h" -#include "pokemon.h" #include "intro.h" #include "battle_controllers.h" #include "scanline_effect.h" #include "save_failed_screen.h" -#include "battle.h" extern u32 intr_main[]; diff --git a/src/menu.c b/src/menu.c index 5a0da28b9..2f5b1a5db 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,12 +1,8 @@ #include "global.h" #include "bg.h" -#include "malloc.h" #include "menu.h" #include "menu_helpers.h" -#include "new_menu_helpers.h" -#include "string_util.h" #include "strings.h" -#include "task.h" #include "text_window.h" #include "window.h" #include "sound.h" diff --git a/src/menu_indicators.c b/src/menu_indicators.c index c07aaf772..3044fb8b4 100644 --- a/src/menu_indicators.c +++ b/src/menu_indicators.c @@ -3,7 +3,6 @@ #include "task.h" #include "decompress.h" #include "palette.h" -#include "strings.h" #include "sprite.h" #include "trig.h" #include "list_menu.h" diff --git a/src/mevent_server.c b/src/mevent_server.c index 3b1762540..f1505fcbc 100644 --- a/src/mevent_server.c +++ b/src/mevent_server.c @@ -1,10 +1,6 @@ #include "global.h" #include "malloc.h" -#include "decompress.h" -#include "overworld.h" #include "script.h" -#include "battle_tower.h" -#include "mystery_event_script.h" #include "mevent.h" #include "mevent_server.h" diff --git a/src/mevent_server_helpers.c b/src/mevent_server_helpers.c index 94c01c081..234064afc 100644 --- a/src/mevent_server_helpers.c +++ b/src/mevent_server_helpers.c @@ -1,14 +1,7 @@ #include "global.h" -#include "malloc.h" -#include "decompress.h" #include "util.h" #include "link.h" #include "link_rfu.h" -#include "overworld.h" -#include "script.h" -#include "battle_tower.h" -#include "mystery_event_script.h" -#include "mevent.h" #include "mevent_server.h" static u32 mevent_receive_func(struct mevent_srv_sub *); diff --git a/src/mevent_show_card.c b/src/mevent_show_card.c index 3eeafa4b5..d2df613ae 100644 --- a/src/mevent_show_card.c +++ b/src/mevent_show_card.c @@ -1,7 +1,6 @@ #include "global.h" #include "constants/species.h" #include "bg.h" -#include "gpu_regs.h" #include "palette.h" #include "decompress.h" #include "malloc.h" @@ -9,9 +8,7 @@ #include "new_menu_helpers.h" #include "pokemon_icon.h" #include "mystery_gift_menu.h" -#include "menu_indicators.h" #include "string_util.h" -#include "link_rfu.h" #include "mevent.h" #include "battle_anim.h" diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 7b25cc5ff..5a105bae9 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -3,7 +3,6 @@ #include "battle_tower.h" #include "easy_chat.h" #include "event_data.h" -#include "mail.h" #include "mail_data.h" #include "mystery_event_script.h" #include "pokedex.h" diff --git a/src/new_game.c b/src/new_game.c index 9aea0b3aa..d03e83b34 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -1,5 +1,4 @@ #include "global.h" -#include "new_game.h" #include "random.h" #include "main.h" #include "overworld.h" diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 39340ca55..11b353b8c 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -3,7 +3,6 @@ #include "dma3.h" #include "task.h" #include "bg.h" -#include "gpu_regs.h" #include "window.h" #include "menu.h" #include "menu_helpers.h" @@ -13,7 +12,6 @@ #include "field_specials.h" #include "text_window.h" #include "script.h" -#include "graphics.h" #include "palette.h" #define DLG_WINDOW_PALETTE_NUM 15 diff --git a/src/oak_speech.c b/src/oak_speech.c index 6887ff85a..f7ec9a531 100644 --- a/src/oak_speech.c +++ b/src/oak_speech.c @@ -4,7 +4,6 @@ #include "task.h" #include "malloc.h" #include "gpu_regs.h" -#include "wild_encounter.h" #include "palette.h" #include "blend_palette.h" #include "text.h" @@ -25,7 +24,6 @@ #include "overworld.h" #include "random.h" #include "data.h" -#include "oak_speech.h" #include "constants/species.h" #include "constants/songs.h" diff --git a/src/party_menu.c b/src/party_menu.c index 600350ca9..6f2feaaad 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -13,11 +13,9 @@ #include "easy_chat.h" #include "event_data.h" #include "evolution_scene.h" -#include "field_control_avatar.h" #include "field_effect.h" #include "field_player_avatar.h" #include "field_screen_effect.h" -#include "field_specials.h" #include "field_weather.h" #include "fieldmap.h" #include "fldeff.h" @@ -46,7 +44,6 @@ #include "pokemon_icon.h" #include "pokemon_jump.h" #include "pokemon_special_anim.h" -#include "pokemon_storage_system.h" #include "pokemon_summary_screen.h" #include "quest_log.h" #include "region_map.h" @@ -78,7 +75,6 @@ #include "constants/quest_log.h" #include "constants/songs.h" #include "constants/species.h" -#include "constants/vars.h" #define PARTY_PAL_SELECTED (1 << 0) #define PARTY_PAL_FAINTED (1 << 1) diff --git a/src/party_menu_specials.c b/src/party_menu_specials.c index 751684bd5..242422f7b 100644 --- a/src/party_menu_specials.c +++ b/src/party_menu_specials.c @@ -2,7 +2,6 @@ #include "data.h" #include "script.h" #include "overworld.h" -#include "battle.h" #include "palette.h" #include "pokemon.h" #include "party_menu.h" diff --git a/src/pokeball.c b/src/pokeball.c index aeaba08ab..92b22abe6 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -15,7 +15,6 @@ #include "link.h" #include "battle_gfx_sfx_util.h" #include "constants/songs.h" -#include "constants/species.h" #define tFrames data[0] #define tPan data[1] diff --git a/src/pokemon_jump_6.c b/src/pokemon_jump_6.c index 140ec5df6..1e213ad75 100644 --- a/src/pokemon_jump_6.c +++ b/src/pokemon_jump_6.c @@ -1,7 +1,6 @@ #include "global.h" #include "gflib.h" #include "menu.h" -#include "pokemon_jump.h" #include "script.h" #include "strings.h" #include "task.h" diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index 6eff367c5..66bdb9194 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -3,7 +3,6 @@ #include "event_data.h" #include "pokedex.h" #include "pokemon.h" -#include "pokemon_size_record.h" #include "string_util.h" #include "text.h" #include "strings.h" diff --git a/src/quest_log.c b/src/quest_log.c index 2ae5e9cfe..b747dd8b6 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -18,10 +18,8 @@ #include "field_fadetransition.h" #include "field_weather.h" #include "event_object_movement.h" -#include "event_object_80688E4.h" #include "event_object_lock.h" #include "field_player_avatar.h" -#include "field_control_avatar.h" #include "battle.h" #include "item.h" #include "region_map.h" diff --git a/src/quest_log_objects.c b/src/quest_log_objects.c index aecc5fd68..5676c20fc 100644 --- a/src/quest_log_objects.c +++ b/src/quest_log_objects.c @@ -1,11 +1,8 @@ #include "global.h" -#include "event_data.h" #include "quest_log.h" #include "fieldmap.h" #include "field_player_avatar.h" #include "metatile_behavior.h" -#include "link.h" -#include "link_rfu.h" void SetQuestLogObjectEventsData(struct QuestLog * questLog) { @@ -39,8 +36,8 @@ void SetQuestLogObjectEventsData(struct QuestLog * questLog) questLog->unk_008[i].localId = gObjectEvents[i].localId; questLog->unk_008[i].mapNum = gObjectEvents[i].mapNum; questLog->unk_008[i].mapGroup = gObjectEvents[i].mapGroup; - questLog->unk_008[i].x = gObjectEvents[i].coords2.x; - questLog->unk_008[i].y = gObjectEvents[i].coords2.y; + questLog->unk_008[i].x = gObjectEvents[i].currentCoords.x; + questLog->unk_008[i].y = gObjectEvents[i].currentCoords.y; questLog->unk_008[i].trainerRange_berryTreeId = gObjectEvents[i].trainerRange_berryTreeId; questLog->unk_008[i].mapobj_unk_1F = gObjectEvents[i].mapobj_unk_1F; questLog->unk_008[i].mapobj_unk_21 = gObjectEvents[i].mapobj_unk_21; @@ -83,8 +80,8 @@ void sub_815A1F8(const struct QuestLog * questLog, const struct ObjectEventTempl gObjectEvents[i].localId = questLogObjectEvents[i].localId; gObjectEvents[i].mapNum = questLogObjectEvents[i].mapNum; gObjectEvents[i].mapGroup = questLogObjectEvents[i].mapGroup; - gObjectEvents[i].coords2.x = questLogObjectEvents[i].x; - gObjectEvents[i].coords2.y = questLogObjectEvents[i].y; + gObjectEvents[i].currentCoords.x = questLogObjectEvents[i].x; + gObjectEvents[i].currentCoords.y = questLogObjectEvents[i].y; gObjectEvents[i].trainerRange_berryTreeId = questLogObjectEvents[i].trainerRange_berryTreeId; gObjectEvents[i].mapobj_unk_1F = questLogObjectEvents[i].mapobj_unk_1F; gObjectEvents[i].mapobj_unk_21 = questLogObjectEvents[i].mapobj_unk_21; @@ -94,38 +91,38 @@ void sub_815A1F8(const struct QuestLog * questLog, const struct ObjectEventTempl { if (gObjectEvents[i].localId == templates[j].localId) { - gObjectEvents[i].coords1.x = templates[j].x + 7; - gObjectEvents[i].coords1.y = templates[j].y + 7; + gObjectEvents[i].initialCoords.x = templates[j].x + 7; + gObjectEvents[i].initialCoords.y = templates[j].y + 7; gObjectEvents[i].range.as_nybbles.x = templates[j].movementRangeX; gObjectEvents[i].range.as_nybbles.y = templates[j].movementRangeY; } } - gObjectEvents[i].mapobj_unk_1E = MapGridGetMetatileBehaviorAt(gObjectEvents[i].coords2.x, gObjectEvents[i].coords2.y); - if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].coords2.x), (s16)(gObjectEvents[i].coords2.y))) + gObjectEvents[i].mapobj_unk_1E = MapGridGetMetatileBehaviorAt(gObjectEvents[i].currentCoords.x, gObjectEvents[i].currentCoords.y); + if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].currentCoords.x), (s16)(gObjectEvents[i].currentCoords.y))) { - gObjectEvents[i].coords3.x = gObjectEvents[i].coords2.x; - gObjectEvents[i].coords3.y = gObjectEvents[i].coords2.y; + gObjectEvents[i].previousCoords.x = gObjectEvents[i].currentCoords.x; + gObjectEvents[i].previousCoords.y = gObjectEvents[i].currentCoords.y; } - else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].coords2.x - 1), (s16)(gObjectEvents[i].coords2.y))) + else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].currentCoords.x - 1), (s16)(gObjectEvents[i].currentCoords.y))) { - gObjectEvents[i].coords3.x = gObjectEvents[i].coords2.x - 1; - gObjectEvents[i].coords3.y = gObjectEvents[i].coords2.y; + gObjectEvents[i].previousCoords.x = gObjectEvents[i].currentCoords.x - 1; + gObjectEvents[i].previousCoords.y = gObjectEvents[i].currentCoords.y; } - else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].coords2.x + 1), (s16)(gObjectEvents[i].coords2.y))) + else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].currentCoords.x + 1), (s16)(gObjectEvents[i].currentCoords.y))) { - gObjectEvents[i].coords3.x = gObjectEvents[i].coords2.x + 1; - gObjectEvents[i].coords3.y = gObjectEvents[i].coords2.y; + gObjectEvents[i].previousCoords.x = gObjectEvents[i].currentCoords.x + 1; + gObjectEvents[i].previousCoords.y = gObjectEvents[i].currentCoords.y; } - else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].coords2.x), (s16)(gObjectEvents[i].coords2.y - 1))) + else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].currentCoords.x), (s16)(gObjectEvents[i].currentCoords.y - 1))) { - gObjectEvents[i].coords3.x = gObjectEvents[i].coords2.x; - gObjectEvents[i].coords3.y = gObjectEvents[i].coords2.y - 1; + gObjectEvents[i].previousCoords.x = gObjectEvents[i].currentCoords.x; + gObjectEvents[i].previousCoords.y = gObjectEvents[i].currentCoords.y - 1; } - else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].coords2.x), (s16)(gObjectEvents[i].coords2.y + 1))) + else if (gObjectEvents[i].mapobj_unk_1F == MapGridGetMetatileBehaviorAt((s16)(gObjectEvents[i].currentCoords.x), (s16)(gObjectEvents[i].currentCoords.y + 1))) { - gObjectEvents[i].coords3.x = gObjectEvents[i].coords2.x; - gObjectEvents[i].coords3.y = gObjectEvents[i].coords2.y + 1; + gObjectEvents[i].previousCoords.x = gObjectEvents[i].currentCoords.x; + gObjectEvents[i].previousCoords.y = gObjectEvents[i].currentCoords.y + 1; } } diff --git a/src/quest_log_player.c b/src/quest_log_player.c index 0d7a2bb50..b6167a7bf 100644 --- a/src/quest_log_player.c +++ b/src/quest_log_player.c @@ -57,7 +57,7 @@ void sub_8150498(u8 a0) static void sub_81504A8(void) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - sub_81507BC(objectEvent, sub_805C808(0)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(0)); ObjectEventTurn(objectEvent, objectEvent->placeholder18); SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_ON_FOOT); } @@ -65,7 +65,7 @@ static void sub_81504A8(void) static void sub_81504E8(void) { struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - sub_81507BC(objectEvent, sub_805C808(1)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(1)); ObjectEventTurn(objectEvent, objectEvent->placeholder18); SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_MACH_BIKE); sub_80BD620(0, 0); @@ -86,7 +86,7 @@ static void sub_8150530(void) } else { - sub_81507BC(objectEvent, sub_805C808(4)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(4)); StartSpriteAnim(sprite, sub_80634F0(objectEvent->facingDirection)); } } @@ -101,7 +101,7 @@ static void sub_81505C4(u8 taskId) case 0: ObjectEventClearAnimIfSpecialAnimActive(objectEvent); objectEvent->enableAnim = TRUE; - sub_81507BC(objectEvent, sub_805C808(4)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(4)); StartSpriteAnim(sprite, sub_80634F0(objectEvent->facingDirection)); gTasks[taskId].data[0]++; gTasks[taskId].data[1] = 0; @@ -122,9 +122,9 @@ static void sub_81505C4(u8 taskId) if (sprite->animEnded) { if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)) - sub_81507BC(objectEvent, sub_805C808(0)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(0)); else - sub_81507BC(objectEvent, sub_805C808(2)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(2)); ObjectEventTurn(objectEvent, objectEvent->placeholder18); sprite->pos2.x = 0; sprite->pos2.y = 0; @@ -142,11 +142,11 @@ static void sub_8150708(void) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)) { - sub_81507BC(objectEvent, sub_805C808(2)); + sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(2)); ObjectEventTurn(objectEvent, objectEvent->placeholder18); SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_SURFING); - gFieldEffectArguments[0] = objectEvent->coords2.x; - gFieldEffectArguments[1] = objectEvent->coords2.y; + gFieldEffectArguments[0] = objectEvent->currentCoords.x; + gFieldEffectArguments[1] = objectEvent->currentCoords.y; gFieldEffectArguments[2] = gPlayerAvatar.objectEventId; fieldEffectId = FieldEffectStart(FLDEFF_SURF_BLOB); objectEvent->mapobj_unk_1A = fieldEffectId; diff --git a/src/random.c b/src/random.c index f6c49971d..cb12ec805 100644 --- a/src/random.c +++ b/src/random.c @@ -1,5 +1,4 @@ #include "global.h" -#include "random.h" // The number 1103515245 comes from the example implementation // of rand and srand in the ISO C standard. diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index ebfd18493..8eeb3bb55 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -6,7 +6,6 @@ #include "link.h" #include "data.h" #include "sprite.h" -#include "text.h" #include "gpu_regs.h" #include "scanline_effect.h" #include "help_system.h" @@ -14,8 +13,6 @@ #include "battle_interface.h" #include "battle_anim.h" #include "battle_controllers.h" -#include "reshow_battle_screen.h" -#include "constants/species.h" static void CB2_ReshowBattleScreenAfterMenu(void); static void sub_8077AAC(void); diff --git a/src/rfu_union_tool.c b/src/rfu_union_tool.c index 1d33fb7d1..8d90da201 100644 --- a/src/rfu_union_tool.c +++ b/src/rfu_union_tool.c @@ -1,8 +1,6 @@ #include "global.h" #include "event_data.h" #include "event_object_movement.h" -#include "event_object_80688E4.h" -#include "event_object_8097404.h" #include "field_player_avatar.h" #include "fieldmap.h" #include "rfu_union_tool.h" diff --git a/src/roamer.c b/src/roamer.c index b3cc67f85..cf30dc3d2 100644 --- a/src/roamer.c +++ b/src/roamer.c @@ -1,5 +1,4 @@ #include "global.h" -#include "roamer.h" #include "random.h" #include "overworld.h" #include "field_specials.h" diff --git a/src/safari_zone.c b/src/safari_zone.c index 65fb89bca..29e436d35 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -2,7 +2,6 @@ #include "battle.h" #include "event_scripts.h" #include "overworld.h" -#include "battle.h" #include "script.h" #include "event_data.h" #include "field_screen_effect.h" diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index b6cce890a..09e49a1bb 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -6,7 +6,6 @@ #include "help_system.h" #include "m4a.h" #include "save.h" -#include "save_failed_screen.h" #include "strings.h" #include "text.h" diff --git a/src/scanline_effect.c b/src/scanline_effect.c index 22699b96d..e664945cd 100644 --- a/src/scanline_effect.c +++ b/src/scanline_effect.c @@ -1,5 +1,4 @@ #include "global.h" -#include "battle.h" #include "task.h" #include "trig.h" #include "scanline_effect.h" diff --git a/src/scrcmd.c b/src/scrcmd.c index 1ff3eb954..389bf0cc2 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -21,7 +21,6 @@ #include "field_message_box.h" #include "new_menu_helpers.h" #include "window.h" -#include "start_menu.h" #include "script_menu.h" #include "string_util.h" #include "data.h" @@ -38,7 +37,6 @@ #include "field_effect.h" #include "fieldmap.h" #include "field_door.h" -#include "scrcmd.h" extern u16 (*const gSpecials[])(void); extern u16 (*const gSpecialsEnd[])(void); diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index e12b809c6..7c8604b8e 100644 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -1,9 +1,7 @@ #include "global.h" -#include "battle.h" #include "berry.h" #include "daycare.h" #include "event_data.h" -#include "event_object_movement.h" #include "load_save.h" #include "malloc.h" #include "overworld.h" diff --git a/src/sea_cottage_special_anim.c b/src/sea_cottage_special_anim.c index 56d01ca29..c63974a1f 100644 --- a/src/sea_cottage_special_anim.c +++ b/src/sea_cottage_special_anim.c @@ -1,10 +1,8 @@ #include "global.h" #include "event_data.h" #include "task.h" -#include "menu.h" #include "field_player_avatar.h" #include "fieldmap.h" -#include "event_object_movement.h" #include "field_camera.h" static EWRAM_DATA u8 gUnknown_2039984 = 0; diff --git a/src/shop.c b/src/shop.c index 97061f8c0..efbbbd979 100644 --- a/src/shop.c +++ b/src/shop.c @@ -10,7 +10,6 @@ #include "window.h" #include "field_specials.h" #include "field_weather.h" -#include "field_camera.h" #include "task.h" #include "text.h" #include "item.h" @@ -19,7 +18,6 @@ #include "sound.h" #include "string_util.h" #include "overworld.h" -#include "window.h" #include "palette.h" #include "field_fadetransition.h" #include "scanline_effect.h" diff --git a/src/slot_machine.c b/src/slot_machine.c index 651465ddb..d0422ab99 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -11,7 +11,6 @@ #include "coins.h" #include "quest_log.h" #include "overworld.h" -#include "slot_machine.h" #include "menu.h" #include "new_menu_helpers.h" #include "text_window.h" diff --git a/src/sound.c b/src/sound.c index ebd755838..b88d3b642 100644 --- a/src/sound.c +++ b/src/sound.c @@ -5,7 +5,6 @@ #include "quest_log.h" #include "m4a.h" #include "main.h" -#include "pokemon.h" #include "constants/songs.h" #include "task.h" diff --git a/src/start_menu.c b/src/start_menu.c index b159f0375..bdcf68b51 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -23,7 +23,7 @@ #include "field_fadetransition.h" #include "field_player_avatar.h" #include "new_menu_helpers.h" -#include "event_object_80688E4.h" +#include "event_object_movement.h" #include "event_object_lock.h" #include "script.h" #include "sound.h" diff --git a/src/text.c b/src/text.c index 83f089c12..2d4d4a9b0 100644 --- a/src/text.c +++ b/src/text.c @@ -1,15 +1,11 @@ #include "global.h" #include "main.h" -#include "palette.h" -#include "string_util.h" #include "window.h" #include "text.h" #include "sprite.h" -#include "blit.h" #include "sound.h" #include "m4a.h" #include "quest_log.h" -#include "window.h" #include "graphics.h" #include "dynamic_placeholder_text_util.h" #include "constants/songs.h" diff --git a/src/text_window.c b/src/text_window.c index 98f82e818..6fde39078 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -1,7 +1,6 @@ #include "global.h" #include "bg.h" #include "palette.h" -#include "text.h" #include "window.h" #include "text_window.h" #include "text_window_graphics.h" diff --git a/src/tileset_anims.c b/src/tileset_anims.c index dd0fe453d..04e129049 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -1,10 +1,4 @@ #include "global.h" -#include "graphics.h" -#include "palette.h" -#include "util.h" -#include "battle_transition.h" -#include "task.h" -#include "fieldmap.h" static EWRAM_DATA struct { const u16 *src; diff --git a/src/tm_case.c b/src/tm_case.c index ac4134029..f631e1604 100644 --- a/src/tm_case.c +++ b/src/tm_case.c @@ -25,7 +25,6 @@ #include "scanline_effect.h" #include "sound.h" #include "strings.h" -#include "tm_case.h" #include "menu_indicators.h" #include "constants/items.h" #include "constants/songs.h" diff --git a/src/trade.c b/src/trade.c index 1872e98ee..30bfa8389 100644 --- a/src/trade.c +++ b/src/trade.c @@ -6,7 +6,6 @@ #include "pokemon_icon.h" #include "graphics.h" #include "link.h" -#include "load_save.h" #include "link_rfu.h" #include "cable_club.h" #include "data.h" @@ -14,7 +13,6 @@ #include "menu.h" #include "overworld.h" #include "battle_anim.h" -#include "pokeball.h" #include "party_menu.h" #include "daycare.h" #include "event_data.h" @@ -22,7 +20,6 @@ #include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" #include "new_menu_helpers.h" -#include "trade.h" #include "trade_scene.h" #include "constants/songs.h" #include "constants/moves.h" diff --git a/src/trade_scene.c b/src/trade_scene.c index 601d7ae2b..bb441f523 100644 --- a/src/trade_scene.c +++ b/src/trade_scene.c @@ -10,7 +10,6 @@ #include "palette.h" #include "trade.h" #include "link.h" -#include "librfu.h" #include "link_rfu.h" #include "text.h" #include "mevent.h" @@ -31,7 +30,6 @@ #include "quest_log.h" #include "help_system.h" #include "new_menu_helpers.h" -#include "battle_interface.h" #include "pokedex.h" #include "save.h" #include "load_save.h" diff --git a/src/trainer_card.c b/src/trainer_card.c index f29c9c71c..d60738ee6 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -14,7 +14,6 @@ #include "event_data.h" #include "easy_chat.h" #include "money.h" -#include "window.h" #include "strings.h" #include "string_util.h" #include "trainer_card.h" @@ -22,7 +21,6 @@ #include "pokedex.h" #include "pokemon_icon.h" #include "graphics.h" -#include "pokemon_icon.h" #include "help_system.h" #include "trainer_pokemon_sprites.h" #include "new_menu_helpers.h" diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c index 7262954c9..9f706c6d5 100644 --- a/src/trainer_pokemon_sprites.c +++ b/src/trainer_pokemon_sprites.c @@ -2,12 +2,9 @@ #include "sprite.h" #include "window.h" #include "malloc.h" -#include "constants/species.h" #include "palette.h" #include "decompress.h" -#include "trainer_pokemon_sprites.h" #include "pokemon.h" -#include "constants/trainer_classes.h" extern const struct CompressedSpriteSheet gMonFrontPicTable[]; extern const struct CompressedSpriteSheet gMonBackPicTable[]; diff --git a/src/trainer_see.c b/src/trainer_see.c new file mode 100644 index 000000000..2bf8aa504 --- /dev/null +++ b/src/trainer_see.c @@ -0,0 +1,752 @@ +#include "global.h" +#include "battle_setup.h" +#include "event_object_movement.h" +#include "field_effect.h" +#include "field_player_avatar.h" +#include "quest_log.h" +#include "script.h" +#include "task.h" +#include "util.h" +#include "constants/battle_setup.h" +#include "constants/event_object_movement.h" +#include "constants/event_objects.h" +#include "constants/object_events.h" + +typedef u8 (*TrainerApproachFunc)(struct ObjectEvent *, s16, s16, s16); +typedef bool8 (*TrainerSeeFunc)(u8, struct Task *, struct ObjectEvent *); + +static bool8 CheckTrainer(u8 trainerObjId); +static u8 GetTrainerApproachDistance(struct ObjectEvent * trainerObj); +static u8 GetTrainerApproachDistanceSouth(struct ObjectEvent * trainerObj, s16 range, s16 x, s16 y); +static u8 GetTrainerApproachDistanceNorth(struct ObjectEvent * trainerObj, s16 range, s16 x, s16 y); +static u8 GetTrainerApproachDistanceWest(struct ObjectEvent * trainerObj, s16 range, s16 x, s16 y); +static u8 GetTrainerApproachDistanceEast(struct ObjectEvent * trainerObj, s16 range, s16 x, s16 y); +static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent * trainerObj, u8 approachDistance, u8 facingDirection); +static void TrainerApproachPlayer(struct ObjectEvent * trainerObj, u8 approachDistance); +static void Task_RunTrainerSeeFuncList(u8 taskId); +static bool8 TrainerSeeFunc_Dummy(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_StartExclMark(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_WaitExclMark(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_TrainerApproach(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_PrepareToEngage(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_End(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_BeginRemoveDisguise(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_WaitRemoveDisguise(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_TrainerInAshFacesPlayer(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_BeginJumpOutOfAsh(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_WaitJumpOutOfAsh(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_EndJumpOutOfAsh(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCreateCameraObj(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveUp(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveDown(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj); +static void Task_DestroyTrainerApproachTask(u8 taskId); +static void SpriteCB_TrainerIcons(struct Sprite * sprite); +static void SetIconSpriteData(struct Sprite *sprite, u16 fldEffId, u8 spriteAnimNum); + +static const u16 sGfx_Emoticons[] = INCBIN_U16("graphics/object_events/emoticons.4bpp"); + +// u8 func(struct ObjectEvent * trainerObj, s16 range, s16 x, s16 y) +// range is the maximum distance the trainer can see +// x and y are the player's coordinates +// Returns distance to walk if trainer has unobstructed view of player +// Returns 0 if trainer can't see player +static const TrainerApproachFunc sDirectionalApproachDistanceFuncs[] = { + GetTrainerApproachDistanceSouth, + GetTrainerApproachDistanceNorth, + GetTrainerApproachDistanceWest, + GetTrainerApproachDistanceEast +}; + +// bool8 func(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +// Returns TRUE to run the next func immediately +// Returns FALSE to delay the next func to the next frame +static const TrainerSeeFunc sTrainerSeeFuncList[] = { + TrainerSeeFunc_Dummy, + TrainerSeeFunc_StartExclMark, + TrainerSeeFunc_WaitExclMark, + TrainerSeeFunc_TrainerApproach, + TrainerSeeFunc_PrepareToEngage, + TrainerSeeFunc_End, + TrainerSeeFunc_BeginRemoveDisguise, + TrainerSeeFunc_WaitRemoveDisguise, + TrainerSeeFunc_TrainerInAshFacesPlayer, + TrainerSeeFunc_BeginJumpOutOfAsh, + TrainerSeeFunc_WaitJumpOutOfAsh, + TrainerSeeFunc_EndJumpOutOfAsh, + TrainerSeeFunc_OffscreenAboveTrainerCreateCameraObj, + TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveUp, + TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveDown +}; + +static const TrainerSeeFunc sTrainerSeeFuncList2[] = { + TrainerSeeFunc_TrainerInAshFacesPlayer, + TrainerSeeFunc_BeginJumpOutOfAsh, + TrainerSeeFunc_WaitJumpOutOfAsh, + TrainerSeeFunc_EndJumpOutOfAsh +}; + +bool8 CheckForTrainersWantingBattle(void) +{ + u8 i; + if (sub_8111C2C() == TRUE) + return FALSE; + + for (i = 0; i < OBJECT_EVENTS_COUNT; i++) + { + if (gObjectEvents[i].active + && ( + gObjectEvents[i].trainerType == 1 + || gObjectEvents[i].trainerType == 3 + ) + && CheckTrainer(i) + ) + return TRUE; + } + return FALSE; +} + +static bool8 CheckTrainer(u8 trainerObjId) +{ + const u8 *script = GetObjectEventScriptPointerByObjectEventId(trainerObjId); + u8 approachDistance; + if (GetTrainerFlagFromScriptPointer(script)) + return FALSE; + approachDistance = GetTrainerApproachDistance(&gObjectEvents[trainerObjId]); + if (approachDistance != 0) + { + if (script[1] == TRAINER_BATTLE_DOUBLE && GetMonsStateToDoubles()) + return FALSE; + ConfigureAndSetUpOneTrainerBattle(trainerObjId, script); + TrainerApproachPlayer(&gObjectEvents[trainerObjId], approachDistance - 1); + return TRUE; + } + return FALSE; +} + +static u8 GetTrainerApproachDistance(struct ObjectEvent *trainerObj) +{ + s16 x, y; + u8 i; + u8 approachDistance; + + PlayerGetDestCoords(&x, &y); + if (trainerObj->trainerType == 1) // can only see in one direction + { + approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->facingDirection - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); + return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->facingDirection); + } + else // can see in all directions + { + for (i = 0; i < 4; i++) + { + approachDistance = sDirectionalApproachDistanceFuncs[i](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); + if (CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, i + 1)) // directions are 1-4 instead of 0-3. south north west east + return approachDistance; + } + } + + return 0; +} + +// Returns how far south the player is from trainer. 0 if out of trainer's sight. +static u8 GetTrainerApproachDistanceSouth(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y) +{ + if (trainerObj->currentCoords.x == x + && y > trainerObj->currentCoords.y + && y <= trainerObj->currentCoords.y + range) + { + if (range > 3 && GetIndexOfFirstInactiveObjectEvent() == OBJECT_EVENTS_COUNT) + return 0; + return (y - trainerObj->currentCoords.y); + } + else + return 0; +} + +// Returns how far north the player is from trainer. 0 if out of trainer's sight. +static u8 GetTrainerApproachDistanceNorth(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y) +{ + if (trainerObj->currentCoords.x == x + && y < trainerObj->currentCoords.y + && y >= trainerObj->currentCoords.y - range) + return (trainerObj->currentCoords.y - y); + else + return 0; +} + +// Returns how far west the player is from trainer. 0 if out of trainer's sight. +static u8 GetTrainerApproachDistanceWest(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y) +{ + if (trainerObj->currentCoords.y == y + && x < trainerObj->currentCoords.x + && x >= trainerObj->currentCoords.x - range) + return (trainerObj->currentCoords.x - x); + else + return 0; +} + +// Returns how far east the player is from trainer. 0 if out of trainer's sight. +static u8 GetTrainerApproachDistanceEast(struct ObjectEvent *trainerObj, s16 range, s16 x, s16 y) +{ + if (trainerObj->currentCoords.y == y + && x > trainerObj->currentCoords.x + && x <= trainerObj->currentCoords.x + range) + return (x - trainerObj->currentCoords.x); + else + return 0; +} + +#define COLLISION_MASK (~1) + +static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 approachDistance, u8 direction) +{ + s16 x, y; + u8 unk19_temp; + u8 unk19b_temp; + u8 i; + u8 collision; + + if (approachDistance == 0) + return 0; + + x = trainerObj->currentCoords.x; + y = trainerObj->currentCoords.y; + + for (i = 0; i <= approachDistance - 1; i++, MoveCoords(direction, &x, &y)) + { + collision = GetCollisionFlagsAtCoords(trainerObj, x, y, direction); + if (collision != 0 && (collision & COLLISION_MASK)) + return 0; + } + + // preserve mapobj_unk_19 before clearing. + unk19_temp = trainerObj->range.as_nybbles.x; + unk19b_temp = trainerObj->range.as_nybbles.y; + trainerObj->range.as_nybbles.x = 0; + trainerObj->range.as_nybbles.y = 0; + + collision = GetCollisionAtCoords(trainerObj, x, y, direction); + + trainerObj->range.as_nybbles.x = unk19_temp; + trainerObj->range.as_nybbles.y = unk19b_temp; + if (collision == 4) + return approachDistance; + + return 0; +} + +#define tFuncId data[0] +#define tTrainerObjHi data[1] +#define tTrainerObjLo data[2] +#define tTrainerRange data[3] +#define tOutOfAshSpriteId data[4] +#define tData5 data[5] + +#define TaskGetTrainerObj(dest, task) do { \ + (dest) = (struct ObjectEvent *)(((task)->tTrainerObjHi << 16) | ((u16)(task)->tTrainerObjLo)); \ +} while (0) + +static void TrainerApproachPlayer(struct ObjectEvent * trainerObj, u8 approachDistance) +{ + u8 taskId = CreateTask(Task_RunTrainerSeeFuncList, 80); + struct Task * task = &gTasks[taskId]; + task->tTrainerObjHi = ((uintptr_t)trainerObj) >> 16; + task->tTrainerObjLo = (uintptr_t)trainerObj; + task->tTrainerRange = approachDistance; +} + +static void StartTrainerApproachWithFollowupTask(TaskFunc taskFunc) +{ + u8 taskId = FindTaskIdByFunc(Task_RunTrainerSeeFuncList); + SetTaskFuncWithFollowupFunc(taskId, Task_RunTrainerSeeFuncList, taskFunc); + gTasks[taskId].tFuncId = 1; + Task_RunTrainerSeeFuncList(taskId); +} + +static void Task_RunTrainerSeeFuncList(u8 taskId) +{ + struct Task * task = &gTasks[taskId]; + struct ObjectEvent * trainerObj; + TaskGetTrainerObj(trainerObj, task); + + if (!trainerObj->active) + { + SwitchTaskToFollowupFunc(taskId); + } + else + { + while (sTrainerSeeFuncList[task->tFuncId](taskId, task, trainerObj)) + ; + } +} + +// TrainerSeeFuncs + +static bool8 TrainerSeeFunc_Dummy(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + return FALSE; +} + +static bool8 TrainerSeeFunc_StartExclMark(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + u8 action; + // FRLG introduces trainers who can see the player from offscreen above. + // Handle this case here. + if (trainerObj->facingDirection == DIR_SOUTH && task->tTrainerRange > 2) + { + task->tFuncId = 12; + } + else + { + ObjectEventGetLocalIdAndMap(trainerObj, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON); + action = GetFaceDirectionMovementAction(trainerObj->facingDirection); + ObjectEventSetHeldMovement(trainerObj, action); + task->tFuncId++; + } + return TRUE; +} + +static bool8 TrainerSeeFunc_WaitExclMark(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (FieldEffectActiveListContains(FLDEFF_EXCLAMATION_MARK_ICON)) + { + return FALSE; + } + else + { + task->tFuncId++; + if (trainerObj->animPattern == MOVEMENT_TYPE_TREE_DISGUISE || trainerObj->animPattern == MOVEMENT_TYPE_MOUNTAIN_DISGUISE) + task->tFuncId = 6; + if (trainerObj->animPattern == MOVEMENT_TYPE_HIDDEN) + task->tFuncId = 8; + return TRUE; + } +} + +static bool8 TrainerSeeFunc_TrainerApproach(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (!ObjectEventIsMovementOverridden(trainerObj) || ObjectEventClearHeldMovementIfFinished(trainerObj)) + { + if (task->tTrainerRange) + { + ObjectEventSetHeldMovement(trainerObj, GetWalkNormalMovementAction(trainerObj->facingDirection)); + task->tTrainerRange--; + } + else + { + ObjectEventSetHeldMovement(trainerObj, MOVEMENT_ACTION_FACE_PLAYER); + task->tFuncId++; + } + } + return FALSE; +} + +static bool8 TrainerSeeFunc_PrepareToEngage(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + struct ObjectEvent *playerObj; + + if (ObjectEventIsMovementOverridden(trainerObj) && !ObjectEventClearHeldMovementIfFinished(trainerObj)) + return FALSE; + + SetTrainerMovementType(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection)); + TryOverrideTemplateCoordsForObjectEvent(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection)); + OverrideTemplateCoordsForObjectEvent(trainerObj); + + playerObj = &gObjectEvents[gPlayerAvatar.objectEventId]; + if (ObjectEventIsMovementOverridden(playerObj) && !ObjectEventClearHeldMovementIfFinished(playerObj)) + return FALSE; + + sub_805C774(); + // Uncomment to have player turn to face their opponent + // ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], GetFaceDirectionMovementAction(GetOppositeDirection(trainerObj->facingDirection))); + task->tFuncId++; + return FALSE; +} + +static bool8 TrainerSeeFunc_End(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + struct ObjectEvent *playerObj = &gObjectEvents[gPlayerAvatar.objectEventId]; + + if (!ObjectEventIsMovementOverridden(playerObj) + || ObjectEventClearHeldMovementIfFinished(playerObj)) + SwitchTaskToFollowupFunc(taskId); // This ends the trainer walk routine. + return FALSE; +} + +// Jumps here if disguised. Not used in FRLG. +static bool8 TrainerSeeFunc_BeginRemoveDisguise(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (!ObjectEventIsMovementOverridden(trainerObj) + || ObjectEventClearHeldMovementIfFinished(trainerObj)) + { + ObjectEventSetHeldMovement(trainerObj, MOVEMENT_ACTION_REVEAL_TRAINER); + task->tFuncId++; + } + return FALSE; +} + +static bool8 TrainerSeeFunc_WaitRemoveDisguise(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (ObjectEventClearHeldMovementIfFinished(trainerObj)) + task->tFuncId = 3; + + return FALSE; +} + +// Jump here if hidden in ash. Not used in FRLG. +static bool8 TrainerSeeFunc_TrainerInAshFacesPlayer(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (!ObjectEventIsMovementOverridden(trainerObj) + || ObjectEventClearHeldMovementIfFinished(trainerObj)) + { + ObjectEventSetHeldMovement(trainerObj, MOVEMENT_ACTION_FACE_PLAYER); + task->tFuncId++; + } + return FALSE; +} + +static bool8 TrainerSeeFunc_BeginJumpOutOfAsh(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + if (ObjectEventCheckHeldMovementStatus(trainerObj)) + { + gFieldEffectArguments[0] = trainerObj->currentCoords.x; + gFieldEffectArguments[1] = trainerObj->currentCoords.y; + gFieldEffectArguments[2] = gSprites[trainerObj->spriteId].subpriority - 1; + gFieldEffectArguments[3] = 2; + task->tOutOfAshSpriteId = FieldEffectStart(FLDEFF_POP_OUT_OF_ASH); + task->tFuncId++; + } + return FALSE; +} + +static bool8 TrainerSeeFunc_WaitJumpOutOfAsh(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + struct Sprite *sprite; + + if (gSprites[task->tOutOfAshSpriteId].animCmdIndex == 2) + { + trainerObj->fixedPriority = FALSE; + trainerObj->triggerGroundEffectsOnMove = TRUE; + + sprite = &gSprites[trainerObj->spriteId]; + sprite->oam.priority = 2; + ObjectEventClearHeldMovementIfFinished(trainerObj); + ObjectEventSetHeldMovement(trainerObj, GetJumpInPlaceMovementAction(trainerObj->facingDirection)); + task->tFuncId++; + } + + return FALSE; +} + +static bool8 TrainerSeeFunc_EndJumpOutOfAsh(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) +{ + if (!FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + task->tFuncId = 3; + + return FALSE; +} + +// FRLG exclusive: Scroll the camera up to reveal an offscreen above trainer +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCreateCameraObj(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) +{ + int specialObjectId; + task->tData5 = 0; + specialObjectId = SpawnSpecialObjectEventParameterized(OBJECT_EVENT_GFX_YOUNGSTER, 7, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3); + gObjectEvents[specialObjectId].invisible = TRUE; + CameraObjectSetFollowedObjectId(gObjectEvents[specialObjectId].spriteId); + task->tFuncId++; + return FALSE; +} + +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveUp(u8 taskId, struct Task *task, struct ObjectEvent *trainerObj) +{ + u8 specialObjectId; + TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &specialObjectId); + + if (ObjectEventIsMovementOverridden(&gObjectEvents[specialObjectId]) && !ObjectEventClearHeldMovementIfFinished(&gObjectEvents[specialObjectId])) + return FALSE; + + if (task->tData5 != task->tTrainerRange - 1) + { + ObjectEventSetHeldMovement(&gObjectEvents[specialObjectId], sub_8063FB0(DIR_NORTH)); + task->tData5++; + } + else + { + ObjectEventGetLocalIdAndMap(trainerObj, (u8 *)&gFieldEffectArguments[0], (u8 *)&gFieldEffectArguments[1], (u8 *)&gFieldEffectArguments[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON); + task->tData5 = 0; + task->tFuncId++; + } + return FALSE; +} + +static bool8 TrainerSeeFunc_OffscreenAboveTrainerCameraObjMoveDown(u8 taskId, struct Task * task, struct ObjectEvent * trainerObj) +{ + u8 specialObjectId; + TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &specialObjectId); + + if (FieldEffectActiveListContains(FLDEFF_EXCLAMATION_MARK_ICON)) + return FALSE; + + if (ObjectEventIsMovementOverridden(&gObjectEvents[specialObjectId]) && !ObjectEventClearHeldMovementIfFinished(&gObjectEvents[specialObjectId])) + return FALSE; + + if (task->tData5 != task->tTrainerRange - 1) + { + ObjectEventSetHeldMovement(&gObjectEvents[specialObjectId], sub_8063FB0(DIR_SOUTH)); + task->tData5++; + } + else + { + CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId()); + RemoveObjectEventByLocalIdAndMap(OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + task->tData5 = 0; + task->tFuncId = 2; + } + return FALSE; +} + +#undef tData5 +#undef tOutOfAshSpriteId +#undef tTrainerRange +#undef tTrainerObjLo +#undef tTrainerObjHi +#undef tFuncId + +static void Task_RevealTrainer_RunTrainerSeeFuncList(u8 taskId) +{ + struct Task * task = &gTasks[taskId]; + struct ObjectEvent * trainerObj; + + // another objEvent loaded into by loadword? + LoadWordFromTwoHalfwords((u16 *)&task->data[1], (uintptr_t *)&trainerObj); + if (!task->data[7]) + { + ObjectEventClearAnim(trainerObj); + task->data[7]++; + } + sTrainerSeeFuncList2[task->data[0]](taskId, task, trainerObj); + if (task->data[0] == 3 && !FieldEffectActiveListContains(FLDEFF_POP_OUT_OF_ASH)) + { + SetTrainerMovementType(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection)); + TryOverrideTemplateCoordsForObjectEvent(trainerObj, GetTrainerFacingDirectionMovementType(trainerObj->facingDirection)); + DestroyTask(taskId); + } + else + { + trainerObj->heldMovementFinished = FALSE; + } +} + +void MovementAction_RevealTrainer_RunTrainerSeeFuncList(struct ObjectEvent *var) +{ + StoreWordInTwoHalfwords((u16 *)&gTasks[CreateTask(Task_RevealTrainer_RunTrainerSeeFuncList, 0)].data[1], (u32)var); +} + +void ScrSpecial_EndTrainerApproach(void) +{ + StartTrainerApproachWithFollowupTask(Task_DestroyTrainerApproachTask); +} + +static void Task_DestroyTrainerApproachTask(u8 taskId) +{ + DestroyTask(taskId); + EnableBothScriptContexts(); +} + +// Trainer See Excl Mark Field Effect + +#define sLocalId data[0] +#define sMapNum data[1] +#define sMapGroup data[2] +#define sData3 data[3] +#define sData4 data[4] +#define sFldEffId data[7] + +static const struct OamData sOamData_Emoticons = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(16x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(16x16), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct SpriteFrameImage sSpriteImages_Emoticons[] = { + {sGfx_Emoticons + 0x000, 0x80}, + {sGfx_Emoticons + 0x040, 0x80}, + {sGfx_Emoticons + 0x080, 0x80}, + + {sGfx_Emoticons + 0x180, 0x80}, + {sGfx_Emoticons + 0x1C0, 0x80}, + {sGfx_Emoticons + 0x200, 0x80}, + + {sGfx_Emoticons + 0x0C0, 0x80}, + {sGfx_Emoticons + 0x100, 0x80}, + {sGfx_Emoticons + 0x140, 0x80}, + + {sGfx_Emoticons + 0x240, 0x80}, + {sGfx_Emoticons + 0x280, 0x80}, + {sGfx_Emoticons + 0x2C0, 0x80}, + + {sGfx_Emoticons + 0x300, 0x80}, + {sGfx_Emoticons + 0x340, 0x80}, + {sGfx_Emoticons + 0x380, 0x80}, +}; + +static const union AnimCmd sAnimCmd_ExclamationMark1[] = { + ANIMCMD_FRAME( 0, 4), + ANIMCMD_FRAME( 1, 4), + ANIMCMD_FRAME( 2, 52), + ANIMCMD_END +}; + +static const union AnimCmd sAnimCmd_DoubleExclMark[] = { + ANIMCMD_FRAME( 6, 4), + ANIMCMD_FRAME( 7, 4), + ANIMCMD_FRAME( 8, 52), + ANIMCMD_END +}; + +static const union AnimCmd sAnimCmd_X[] = { + ANIMCMD_FRAME( 3, 4), + ANIMCMD_FRAME( 4, 4), + ANIMCMD_FRAME( 5, 52), + ANIMCMD_END +}; + +static const union AnimCmd sAnimCmd_SmileyFace[] = { + ANIMCMD_FRAME( 9, 4), + ANIMCMD_FRAME(10, 4), + ANIMCMD_FRAME(11, 52), + ANIMCMD_END +}; + +static const union AnimCmd sAnimCmd_QuestionMark[] = { + ANIMCMD_FRAME(12, 4), + ANIMCMD_FRAME(13, 4), + ANIMCMD_FRAME(14, 52), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_Emoticons[] = { + sAnimCmd_ExclamationMark1, + sAnimCmd_DoubleExclMark, + sAnimCmd_X, + sAnimCmd_SmileyFace, + sAnimCmd_QuestionMark +}; + +static const struct SpriteTemplate sSpriteTemplate_Emoticons = { + .tileTag = 0xFFFF, + .paletteTag = 0xFFFF, + .oam = &sOamData_Emoticons, + .anims = sSpriteAnimTable_Emoticons, + .images = sSpriteImages_Emoticons, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_TrainerIcons +}; + +u8 FldEff_ExclamationMarkIcon1(void) +{ + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Emoticons, 0, 0, 0x53); + + if (spriteId != MAX_SPRITES) + SetIconSpriteData(&gSprites[spriteId], FLDEFF_EXCLAMATION_MARK_ICON, 0); + + return 0; +} + +u8 FldEff_DoubleExclMarkIcon(void) +{ + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Emoticons, 0, 0, 0x52); + + if (spriteId != MAX_SPRITES) + SetIconSpriteData(&gSprites[spriteId], FLDEFF_DOUBLE_EXCL_MARK_ICON, 1); + + return 0; +} + +u8 FldEff_XIcon(void) +{ + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Emoticons, 0, 0, 0x52); + + if (spriteId != MAX_SPRITES) + SetIconSpriteData(&gSprites[spriteId], FLDEFF_X_ICON, 2); + + return 0; +} + +u8 FldEff_SmileyFaceIcon(void) +{ + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Emoticons, 0, 0, 0x52); + + if (spriteId != MAX_SPRITES) + SetIconSpriteData(&gSprites[spriteId], FLDEFF_SMILEY_FACE_ICON, 3); + + return 0; +} + +u8 FldEff_QuestionMarkIcon(void) +{ + u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Emoticons, 0, 0, 0x52); + + if (spriteId != MAX_SPRITES) + SetIconSpriteData(&gSprites[spriteId], FLDEFF_QUESTION_MARK_ICON, 4); + + return 0; +} + +static void SetIconSpriteData(struct Sprite *sprite, u16 fldEffId, u8 spriteAnimNum) +{ + sprite->oam.priority = 1; + sprite->coordOffsetEnabled = 1; + + sprite->sLocalId = gFieldEffectArguments[0]; + sprite->sMapNum = gFieldEffectArguments[1]; + sprite->sMapGroup = gFieldEffectArguments[2]; + sprite->sData3 = -5; + sprite->sFldEffId = fldEffId; + + StartSpriteAnim(sprite, spriteAnimNum); +} + +static void SpriteCB_TrainerIcons(struct Sprite *sprite) +{ + u8 objEventId; + + if (TryGetObjectEventIdByLocalIdAndMap(sprite->sLocalId, sprite->sMapNum, sprite->sMapGroup, &objEventId) + || sprite->animEnded) + { + FieldEffectStop(sprite, sprite->sFldEffId); + } + else + { + struct Sprite *objEventSprite = &gSprites[gObjectEvents[objEventId].spriteId]; + sprite->sData4 += sprite->sData3; + sprite->pos1.x = objEventSprite->pos1.x; + sprite->pos1.y = objEventSprite->pos1.y - 16; + sprite->pos2.x = objEventSprite->pos2.x; + sprite->pos2.y = objEventSprite->pos2.y + sprite->sData4; + if (sprite->sData4) + sprite->sData3++; + else + sprite->sData3 = 0; + } +} + +#undef sLocalId +#undef sMapNum +#undef sMapGroup +#undef sData3 +#undef sData4 +#undef sFldEffId diff --git a/src/trainer_tower.c b/src/trainer_tower.c index 0f9907e2d..f4e9689a1 100644 --- a/src/trainer_tower.c +++ b/src/trainer_tower.c @@ -2,11 +2,9 @@ #include "main.h" #include "task.h" #include "malloc.h" -#include "save.h" #include "util.h" #include "string_util.h" #include "event_data.h" -#include "random.h" #include "cereader_tool.h" #include "easy_chat.h" #include "text.h" @@ -20,11 +18,9 @@ #include "menu.h" #include "new_menu_helpers.h" #include "sound.h" -#include "constants/flags.h" #include "constants/vars.h" #include "constants/items.h" #include "constants/species.h" -#include "constants/maps.h" #include "constants/songs.h" #include "constants/layouts.h" #include "constants/trainers.h" diff --git a/src/trig.c b/src/trig.c index c2bca3059..2181ebef7 100644 --- a/src/trig.c +++ b/src/trig.c @@ -1,5 +1,4 @@ #include "global.h" -#include "trig.h" // Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319 const s16 gSineTable[] = diff --git a/src/union_room_message.c b/src/union_room_message.c index 1d26d1968..3aeb40524 100644 --- a/src/union_room_message.c +++ b/src/union_room_message.c @@ -1,5 +1,4 @@ #include "global.h" -#include "union_room_message.h" #include "mevent_server.h" #include "constants/union_room.h" diff --git a/src/util.c b/src/util.c index 93aa60f84..b32799584 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,4 @@ #include "global.h" -#include "util.h" const u32 gBitTable[] = { diff --git a/src/vs_seeker.c b/src/vs_seeker.c index 9c9a4d67f..e79c2cf22 100644 --- a/src/vs_seeker.c +++ b/src/vs_seeker.c @@ -18,12 +18,9 @@ #include "battle.h" #include "battle_setup.h" #include "random.h" -#include "event_object_movement.h" #include "field_player_avatar.h" -#include "event_object_80688E4.h" -#include "event_object_8097404.h" #include "vs_seeker.h" -#include "constants/movement_commands.h" +#include "constants/event_object_movement.h" #include "constants/object_events.h" #include "constants/trainers.h" #include "constants/maps.h" @@ -547,29 +544,35 @@ static const VsSeekerData sVsSeekerData[] = { }; static const u8 gUnknown_8453F5C[] = { - delay_16, - delay_16, - delay_16, - step_end + MOVEMENT_ACTION_DELAY_16, + MOVEMENT_ACTION_DELAY_16, + MOVEMENT_ACTION_DELAY_16, + MOVEMENT_ACTION_STEP_END }; static const u8 gUnknown_8453F60[] = { - emote_exclamation_mark, - step_end + MOVEMENT_ACTION_EMOTE_EXCLAMATION_MARK, + MOVEMENT_ACTION_STEP_END }; static const u8 sMovementScript_TrainerNoRematch[] = { - emote_x, - step_end + MOVEMENT_ACTION_EMOTE_X, + MOVEMENT_ACTION_STEP_END }; static const u8 sMovementScript_TrainerRematch[] = { - walk_in_place_fastest_down, - emote_double_exclamation_mark, - step_end + MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, + MOVEMENT_ACTION_EMOTE_DOUBLE_EXCL_MARK, + MOVEMENT_ACTION_STEP_END }; -static const u8 gUnknown_8453F67[] = { 0x08, 0x08, 0x07, 0x09, 0x0a }; +static const u8 gUnknown_8453F67[] = { + MOVEMENT_TYPE_FACE_DOWN, + MOVEMENT_TYPE_FACE_DOWN, + MOVEMENT_TYPE_FACE_UP, + MOVEMENT_TYPE_FACE_LEFT, + MOVEMENT_TYPE_FACE_RIGHT +}; // text @@ -798,8 +801,8 @@ static void GatherNearbyTrainerInfo(void) sVsSeeker->trainerInfo[vsSeekerObjectIdx].localId = templates[objectEventIdx].localId; TryGetObjectEventIdByLocalIdAndMap(templates[objectEventIdx].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); sVsSeeker->trainerInfo[vsSeekerObjectIdx].objectEventId = objectEventId; - sVsSeeker->trainerInfo[vsSeekerObjectIdx].xCoord = gObjectEvents[objectEventId].coords2.x - 7; - sVsSeeker->trainerInfo[vsSeekerObjectIdx].yCoord = gObjectEvents[objectEventId].coords2.y - 7; + sVsSeeker->trainerInfo[vsSeekerObjectIdx].xCoord = gObjectEvents[objectEventId].currentCoords.x - 7; + sVsSeeker->trainerInfo[vsSeekerObjectIdx].yCoord = gObjectEvents[objectEventId].currentCoords.y - 7; sVsSeeker->trainerInfo[vsSeekerObjectIdx].graphicsId = templates[objectEventIdx].graphicsId; vsSeekerObjectIdx++; } @@ -951,12 +954,12 @@ void sub_810CB90(void) TryGetObjectEventIdByLocalIdAndMap(r4[r8].localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &sp0); r4_2 = &gObjectEvents[sp0]; sub_810CF54(&r4[r8]); // You are using this function incorrectly. Please consult the manual. - sub_805FE7C(r4_2, gUnknown_8453F67[r4_2->facingDirection]); + TryOverrideTemplateCoordsForObjectEvent(r4_2, gUnknown_8453F67[r4_2->facingDirection]); gSaveBlock1Ptr->trainerRematches[r4[r8].localId] = 0; if (gSelectedObjectEvent == sp0) r4_2->animPattern = gUnknown_8453F67[r4_2->facingDirection]; else - r4_2->animPattern = 0x08; + r4_2->animPattern = MOVEMENT_TYPE_FACE_DOWN; } } } @@ -1312,7 +1315,7 @@ static void StartAllRespondantIdleMovements(void) if (sub_810CF04(sVsSeeker->trainerInfo[j].objectEventId) == 1) SetTrainerMovementType(r4, sVsSeeker->runningBehaviourEtcArray[i]); - sub_805FE7C(r4, sVsSeeker->runningBehaviourEtcArray[i]); + TryOverrideTemplateCoordsForObjectEvent(r4, sVsSeeker->runningBehaviourEtcArray[i]); gSaveBlock1Ptr->trainerRematches[sVsSeeker->trainerInfo[j].localId] = GetNextAvailableRematchTrainer(sVsSeekerData, sVsSeeker->trainerInfo[j].trainerIdx, &dummy); } } |