diff --git a/.githooks/pre-commit b/.githooks/pre-commit index f623b5d524..4528b6073e 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -3,7 +3,7 @@ exec 1>&2 # Run clang-format on staged files; abort the commit if any files are changed -if ! git clang-format ; then +if ! git clang-format --extensions c,h,cpp,hpp ; then echo "linting made changes to source files; aborting commit" exit 1 fi diff --git a/asm/macros/scrcmd.inc b/asm/macros/scrcmd.inc index 820ad9f3d8..61f2000548 100644 --- a/asm/macros/scrcmd.inc +++ b/asm/macros/scrcmd.inc @@ -1840,81 +1840,81 @@ .short \arg0 .endm - .macro ScrCmd_157 arg0 + .macro CheckPokedexAcquired destVarID .short 343 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_158 + .macro GivePokedex .short 344 .endm - .macro ScrCmd_159 arg0 + .macro CheckRunningShoesAcquired destVarID .short 345 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_15A + .macro GiveRunningShoes .short 346 .endm - .macro CheckBadge badgeID, destVarID + .macro CheckBadgeAcquired badgeID, destVarID .short 347 .short \badgeID .short \destVarID .endm - .macro ScrCmd_15C arg0 + .macro GiveBadge badgeID .short 348 - .short \arg0 + .short \badgeID .endm - .macro ScrCmd_15D arg0 + .macro CountBadgesAcquired destVarID .short 349 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_15E arg0 + .macro CheckBagAcquired destVarID .short 350 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_15F + .macro GiveBag .short 351 .endm - .macro ScrCmd_160 arg0 + .macro CheckHasPartner destVarID .short 352 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_161 + .macro SetHasPartner .short 353 .endm - .macro ScrCmd_162 + .macro ClearHasPartner .short 354 .endm - .macro ScrCmd_163 arg0 + .macro CheckStepFlag destVarID .short 355 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_164 + .macro SetStepFlag .short 356 .endm - .macro ScrCmd_165 + .macro ClearStepFlag .short 357 .endm - .macro ScrCmd_166 arg0 + .macro CheckGameCompleted destVarID .short 358 - .short \arg0 + .short \destVarID .endm - .macro ScrCmd_167 + .macro SetGameCompleted .short 359 .endm @@ -2457,7 +2457,7 @@ .short \arg2 .endm - .macro ScrCmd_1CC + .macro GiveJournal .short 460 .endm @@ -2474,27 +2474,27 @@ .short 462 .endm - .macro ScrCmd_1CF arg0, arg1=0 + .macro Strength mode, checkDestVarID=0 .short 463 - .byte \arg0 - .if \arg0 == 2 - .short \arg1 + .byte \mode + .if \mode == 2 + .short \checkDestVarID .endif .endm - .macro ScrCmd_1D0 arg0, arg1=0 + .macro Flash mode, checkDestVarID=0 .short 464 - .byte \arg0 - .if \arg0 == 2 - .short \arg1 + .byte \mode + .if \mode == 2 + .short \checkDestVarID .endif .endm - .macro ScrCmd_1D1 arg0, arg1=0 + .macro Defog mode, checkDestVarID=0 .short 465 - .byte \arg0 - .if \arg0 == 2 - .short \arg1 + .byte \mode + .if \mode == 2 + .short \checkDestVarID .endif .endm @@ -3317,11 +3317,11 @@ .short \arg0 .endm - .macro ScrCmd_265 + .macro HidePoketch .short 613 .endm - .macro ScrCmd_266 + .macro ShowPoketch .short 614 .endm diff --git a/include/constants/heap.h b/include/constants/heap.h index 030b2a0fcd..85172b703f 100644 --- a/include/constants/heap.h +++ b/include/constants/heap.h @@ -18,6 +18,8 @@ enum HeapId { HEAP_ID_DISTORTION_WORLD_WARP = 30, + HEAP_ID_FIELD_TASK = 32, + HEAP_ID_OPTIONS_MENU = 38, HEAP_ID_CHOOSE_STARTER_APP = 47, @@ -28,10 +30,11 @@ enum HeapId { }; enum HeapSize { - HEAP_SIZE_POKETCH_MAIN = 0xc000, - HEAP_SIZE_POKETCH_APP = 0xc000, + HEAP_SIZE_POKETCH_MAIN = 0xC000, + HEAP_SIZE_POKETCH_APP = 0xC000, HEAP_SIZE_FIELDMAP = 0x1C000, + HEAP_SIZE_FIELD_TASK = 0x4000, HEAP_SIZE_CHOOSE_STARTER_APP = 0x40000, HEAP_SIZE_LIBRARY_TV = 0x40000, diff --git a/include/constants/savedata/vars_flags.h b/include/constants/savedata/vars_flags.h new file mode 100644 index 0000000000..cab778c040 --- /dev/null +++ b/include/constants/savedata/vars_flags.h @@ -0,0 +1,178 @@ +#ifndef POKEPLATINUM_CONSTANTS_VARS_AND_FLAGS_H +#define POKEPLATINUM_CONSTANTS_VARS_AND_FLAGS_H + +#define SYSTEM_FLAGS_START 2400 +#define FLAG_BAG_ACQUIRED (SYSTEM_FLAGS_START + 0) +#define FLAG_HAS_PARTNER (SYSTEM_FLAGS_START + 1) +#define FLAG_STRENGTH_ACTIVE (SYSTEM_FLAGS_START + 2) +#define FLAG_JOURNAL_ACQUIRED (SYSTEM_FLAGS_START + 3) +#define FLAG_GAME_COMPLETED (SYSTEM_FLAGS_START + 4) +#define FLAG_STEP (SYSTEM_FLAGS_START + 5) +#define FLAG_COMMUNICATION_CLUB_ACCESSIBLE (SYSTEM_FLAGS_START + 6) +#define FLAG_SAFARI_GAME_ACTIVE (SYSTEM_FLAGS_START + 7) +#define FLAG_CONTEST_MASTER_COOL (SYSTEM_FLAGS_START + 8) +#define FLAG_CONTEST_MASTER_CUTE (SYSTEM_FLAGS_START + 9) +#define FLAG_CONTEST_MASTER_BEAUTY (SYSTEM_FLAGS_START + 10) +#define FLAG_CONTEST_MASTER_SMART (SYSTEM_FLAGS_START + 11) +#define FLAG_CONTEST_MASTER_TOUGH (SYSTEM_FLAGS_START + 12) +#define FLAG_VS_SEEKER_USED (SYSTEM_FLAGS_START + 13) +#define FLAG_ENTERED_UNDERGROUND (SYSTEM_FLAGS_START + 14) +#define FLAG_DIGGING_FOR_FOSSILS (SYSTEM_FLAGS_START + 15) +#define FLAG_SPHERE_ACQUIRED (SYSTEM_FLAGS_START + 16) +#define FLAG_CREATED_SECRET_BASE (SYSTEM_FLAGS_START + 17) +#define FLAG_DECORATED_SECRET_BASE (SYSTEM_FLAGS_START + 18) +#define FLAG_DELIVERED_STOLEN_FLAG (SYSTEM_FLAGS_START + 19) +#define FLAG_UNUSED_2420 (SYSTEM_FLAGS_START + 20) +#define FLAG_UNUSED_2421 (SYSTEM_FLAGS_START + 21) +#define FLAG_UNUSED_2422 (SYSTEM_FLAGS_START + 22) +#define FLAG_DISTORTION_WORLD_STEPPING_STONES (SYSTEM_FLAGS_START + 23) +#define FLAG_CONTEST_HALL_VISITED (SYSTEM_FLAGS_START + 24) +#define FLAG_IN_PAL_PARK (SYSTEM_FLAGS_START + 25) +#define FLAG_FLASH_ACTIVE (SYSTEM_FLAGS_START + 26) +#define FLAG_DEFOG_ACTIVE (SYSTEM_FLAGS_START + 27) +#define FLAG_POKETCH_HIDDEN (SYSTEM_FLAGS_START + 28) +#define FLAG_FREED_GALACTIC_HQ_POKEMON (SYSTEM_FLAGS_START + 29) +#define FLAG_MET_BEBE (SYSTEM_FLAGS_START + 30) +#define FLAG_UNLOCKED_VS_SEEKER_LVL_1 (SYSTEM_FLAGS_START + 31) +#define FLAG_UNLOCKED_VS_SEEKER_LVL_2 (SYSTEM_FLAGS_START + 32) +#define FLAG_UNLOCKED_VS_SEEKER_LVL_3 (SYSTEM_FLAGS_START + 33) +#define FLAG_UNLOCKED_VS_SEEKER_LVL_4 (SYSTEM_FLAGS_START + 34) +#define FLAG_UNLOCKED_VS_SEEKER_LVL_5 (SYSTEM_FLAGS_START + 35) +#define FLAG_ALT_MUSIC_LAKE_VALOR (SYSTEM_FLAGS_START + 36) +#define FLAG_ALT_MUSIC_GALACTIC_HQ (SYSTEM_FLAGS_START + 37) +#define FLAG_ALT_MUSIC_GALACTIC_HQ_1F (SYSTEM_FLAGS_START + 38) +#define FLAG_ALT_MUSIC_GALACTIC_ETERNA_BUILDING (SYSTEM_FLAGS_START + 39) +#define FLAG_ALT_MUSIC_VALLEY_WINDWORKS_BUILDING (SYSTEM_FLAGS_START + 40) +#define FLAG_ALT_MUSIC_FLOAROMA_MEADOW (SYSTEM_FLAGS_START + 41) +#define FLAG_ALT_MUSIC_ROUTE_224 (SYSTEM_FLAGS_START + 42) +#define FLAG_ALT_MUSIC_CHAMPION_ROOM (SYSTEM_FLAGS_START + 43) +#define FLAG_CONNECTED_TO_WIFI (SYSTEM_FLAGS_START + 44) +#define FLAG_DUMMY_2445 (SYSTEM_FLAGS_START + 45) +#define FLAG_ALT_MUSIC_LAKE_VERITY (SYSTEM_FLAGS_START + 46) +#define FLAG_ALT_MUSIC_LAKE_ACUITY (SYSTEM_FLAGS_START + 47) +#define FLAG_UNUSED_2448 (SYSTEM_FLAGS_START + 48) +#define FLAG_UNUSED_2449 (SYSTEM_FLAGS_START + 49) +#define FLAG_UNDERGROUND_FIRST_ENTERED (SYSTEM_FLAGS_START + 50) +#define FLAG_ALT_MUSIC_ROWANS_LAB (SYSTEM_FLAGS_START + 51) +#define FLAG_ON_CYCLING_ROAD (SYSTEM_FLAGS_START + 52) +#define FLAG_ALT_MUSIC_PAL_PARK (SYSTEM_FLAGS_START + 53) +#define FLAG_FORCE_BIKING_IN_GATE (SYSTEM_FLAGS_START + 54) + +#define SYSTEM_FLAGS_VILLA_FURNITURE_START (SYSTEM_FLAGS_START + 55) + +enum VillaFurniture { + VILLA_FURNITURE_UNK_00 = 0, + VILLA_FURNITURE_UNK_01, + VILLA_FURNITURE_UNK_02, + VILLA_FURNITURE_UNK_03, + VILLA_FURNITURE_UNK_04, + VILLA_FURNITURE_UNK_05, + VILLA_FURNITURE_UNK_06, + VILLA_FURNITURE_UNK_07, + VILLA_FURNITURE_UNK_08, + VILLA_FURNITURE_UNK_09, + VILLA_FURNITURE_UNK_10, + VILLA_FURNITURE_UNK_11, + VILLA_FURNITURE_UNK_12, + VILLA_FURNITURE_UNK_13, + VILLA_FURNITURE_UNK_14, + VILLA_FURNITURE_UNK_15, + VILLA_FURNITURE_UNK_16, + VILLA_FURNITURE_UNK_17, + VILLA_FURNITURE_UNK_18, + VILLA_FURNITURE_UNK_19, + + VILLA_FURNITURE_MAX, +}; + +#define SYSTEM_FLAGS_VILLA_VISITOR_START (SYSTEM_FLAGS_VILLA_FURNITURE_START + VILLA_FURNITURE_MAX) +#define FLAG_VILLA_VISITOR_INSIDE (SYSTEM_FLAGS_VILLA_VISITOR_START + 0) +#define FLAG_VILLA_VISITOR_OUTSIDE (SYSTEM_FLAGS_VILLA_VISITOR_START + 1) +#define FLAG_DISTORTION_WORLD_PUZZLE_FINISHED (SYSTEM_FLAGS_VILLA_VISITOR_START + 2) + +#define SYSTEM_FLAGS_GIRATINA_ANIM_START (FLAG_DISTORTION_WORLD_PUZZLE_FINISHED + 1) + +enum GiratinaShadowAnimation { + GIRATINA_SHADOW_ANIM_LEFT_TO_RIGHT = 0, + GIRATINA_SHADOW_ANIM_BOTTOM_TO_TOP, + + GIRATINA_SHADOW_ANIM_MAX, +}; + +#define SYSTEM_FLAGS_FIRST_ARRIVAL_TO_ZONE (SYSTEM_FLAGS_GIRATINA_ANIM_START + GIRATINA_SHADOW_ANIM_MAX) + +enum FirstArrivalToZone { + FIRST_ARRIVAL_TWINLEAF_TOWN = 0, + FIRST_ARRIVAL_SANDGEM_TOWN, + FIRST_ARRIVAL_FLOAROMA_TOWN, + FIRST_ARRIVAL_SOLACEON_TOWN, + FIRST_ARRIVAL_CELESTIC_TOWN, + FIRST_ARRIVAL_SURVIVAL_AREA, + FIRST_ARRIVAL_RESORT_AREA, + FIRST_ARRIVAL_JUBILIFE_CITY, + FIRST_ARRIVAL_CANALAVE_CITY, + FIRST_ARRIVAL_OREBURGH_CITY, + FIRST_ARRIVAL_ETERNA_CITY, + FIRST_ARRIVAL_HEARTHOME_CITY, + FIRST_ARRIVAL_PASTORIA_CITY, + FIRST_ARRIVAL_VEILSTONE_CITY, + FIRST_ARRIVAL_SUNYSHORE_CITY, + FIRST_ARRIVAL_SNOWPOINT_CITY, + FIRST_ARRIVAL_OUTSIDE_VICTORY_ROAD, + FIRST_ARRIVAL_FIGHT_AREA, + FIRST_ARRIVAL_OREBURGH_MINE, + FIRST_ARRIVAL_VALLEY_WINDWORKS, + FIRST_ARRIVAL_ETERNA_FOREST, + FIRST_ARRIVAL_FUEGO_IRONWORKS, + FIRST_ARRIVAL_MYSTERY_ZONE_D05, + FIRST_ARRIVAL_SPEAR_PILLAR, + FIRST_ARRIVAL_MYSTERY_ZONE_D06, + FIRST_ARRIVAL_SOLACEON_RUINS, + FIRST_ARRIVAL_VICTORY_ROAD, + FIRST_ARRIVAL_PAL_PARK, + FIRST_ARRIVAL_AMITY_SQUARE, + FIRST_ARRIVAL_RAVAGED_PATH, + FIRST_ARRIVAL_FLOAROMA_MEADOW, + FIRST_ARRIVAL_OREBURGH_GATE, + FIRST_ARRIVAL_FULLMOON_ISLAND, + FIRST_ARRIVAL_STARK_MOUNTAIN_EXTERIOR, + FIRST_ARRIVAL_STARK_MOUNTAIN_INTERIOR, + FIRST_ARRIVAL_SENDOFF_SPRING_UNUSED, + FIRST_ARRIVAL_TURNBACK_CAVE, + FIRST_ARRIVAL_FLOWER_PARADISE, + FIRST_ARRIVAL_SNOWPOINT_TEMPLE, + FIRST_ARRIVAL_WAYWARD_CAVE, + FIRST_ARRIVAL_RUIN_MANIAC_CAVE, + FIRST_ARRIVAL_TROPHY_GARDEN, + FIRST_ARRIVAL_IRON_ISLAND_EXTERIOR, + FIRST_ARRIVAL_IRON_ISLAND_INTERIOR, + FIRST_ARRIVAL_OLD_CHATEAU, + FIRST_ARRIVAL_GALACTIC_HQ, + FIRST_ARRIVAL_LAKE_VERITY_UNUSED, + FIRST_ARRIVAL_VERITY_CAVERN, + FIRST_ARRIVAL_LAKE_VALOR_UNUSED, + FIRST_ARRIVAL_VALOR_CAVERN, + FIRST_ARRIVAL_LAKE_ACUITY_UNUSED, + FIRST_ARRIVAL_ACUITY_CAVERN, + FIRST_ARRIVAL_NEWMOON_ISLAND, + FIRST_ARRIVAL_BATTLE_PARK, + FIRST_ARRIVAL_CYCLING_ROAD_UNUSED, + FIRST_ARRIVAL_BERRY_MASTERS_HOUSE, + FIRST_ARRIVAL_LOST_TOWER, + FIRST_ARRIVAL_ROUTE_210_COFFEE_SHOP, + FIRST_ARRIVAL_DRAGON_MASTERS_HOUSE, + FIRST_ARRIVAL_POKEMON_MANSION, + FIRST_ARRIVAL_ROUTE_212_MOVE_TUTOR, + FIRST_ARRIVAL_DOCTOR_FOOTSTEPS_HOUSE, + FIRST_ARRIVAL_VALOR_LAKEFRONT_RESTAURANT, + FIRST_ARRIVAL_PIKACHU_FAN_CLUB, + FIRST_ARRIVAL_POKEMON_SIZE_JUDGE, + FIRST_ARRIVAL_THE_MEISTERS_HOUSE, + FIRST_ARRIVAL_ROUTE_221, + FIRST_ARRIVAL_POKE_PARK_FRONT_GATE, + FIRST_ARRIVAL_POKEMON_LEAGUE, + + FIRST_ARRIVAL_MAX, +}; + +#endif // POKEPLATINUM_CONSTANTS_VARS_AND_FLAGS_H diff --git a/include/encounter.h b/include/encounter.h new file mode 100644 index 0000000000..6cf0f452e7 --- /dev/null +++ b/include/encounter.h @@ -0,0 +1,27 @@ +#ifndef POKEPLATINUM_ENCOUNTER_H +#define POKEPLATINUM_ENCOUNTER_H + +#include "struct_decls/struct_party_decl.h" + +#include "field/field_system_decl.h" +#include "overlay006/battle_params.h" + +#include "field_task.h" + +void sub_02050ABC(FieldTask *param0, BattleParams *param1); +void sub_02050E10(FieldSystem *fieldSystem, BattleParams *param1); +void sub_02050E78(FieldSystem *fieldSystem, FieldTask *param1, BattleParams *param2); +void sub_0205120C(FieldTask *param0, int *param1); +void sub_02051270(FieldTask *param0, u16 param1, u8 param2, int *param3, BOOL param4); +void sub_020512E4(FieldTask *param0, u16 param1, u8 param2, int *param3, BOOL param4); +void sub_02051450(FieldSystem *fieldSystem, BattleParams *param1); +void sub_02051480(FieldTask *param0, int param1, int param2, int *param3); +void sub_02051590(FieldTask *param0); +void sub_020515CC(FieldTask *param0, int param1, int param2, int param3, int param4, int *param5); +void sub_0205167C(FieldTask *param0, const u8 *param1, int param2); +void sub_020516F4(FieldTask *param0, int param1, int param2, int param3); +void sub_020517E8(FieldSystem *fieldSystem, const u8 *param1, int param2); +void sub_0205184C(FieldSystem *fieldSystem, const Party *param1, int param2); +void sub_02051ABC(FieldTask *param0, u16 param1, u8 param2, int *param3, BOOL param4); + +#endif // POKEPLATINUM_ENCOUNTER_H diff --git a/include/field/field_system.h b/include/field/field_system.h index 7d0fa3c9c3..4d3efff208 100644 --- a/include/field/field_system.h +++ b/include/field/field_system.h @@ -2,7 +2,6 @@ #define POKEPLATINUM_FIELD_SYSTEM_STRUCT_H #include "struct_decls/struct_02039E30_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02054C18_decl.h" #include "struct_decls/struct_0205B43C_decl.h" #include "struct_decls/struct_0205C22C_decl.h" @@ -39,6 +38,7 @@ #include "bag.h" #include "bg_window.h" #include "camera.h" +#include "field_task.h" #include "journal.h" #include "location.h" #include "map_header_data.h" @@ -58,7 +58,7 @@ typedef struct FieldSystem_t { FieldSystem_sub2 *unk_04; BgConfig *bgConfig; SaveData *saveData; - TaskManager *taskManager; + FieldTask *task; MapHeaderData *mapHeaderData; int bottomScreen; Location *location; diff --git a/include/field_map_change.h b/include/field_map_change.h index 25285f5283..ea199b9685 100644 --- a/include/field_map_change.h +++ b/include/field_map_change.h @@ -1,11 +1,9 @@ #ifndef POKEPLATINUM_FIELD_MAP_CHANGE_H #define POKEPLATINUM_FIELD_MAP_CHANGE_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" -#include "functypes/funcptr_02050904.h" +#include "field_task.h" #include "location.h" void FieldMapChange_Set3DDisplay(FieldSystem *fieldSystem); @@ -15,23 +13,23 @@ void sub_02053494(FieldSystem *fieldSystem); void FieldSystem_SetLoadNewGameSpawnTask(FieldSystem *fieldSystem); void FieldSystem_SetLoadSavedGameMapTask(FieldSystem *fieldSystem); void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem); -void FieldSystem_StartChangeMapTask(TaskManager *param0, const Location *param1); -void FieldTask_ChangeMapByLocation(TaskManager *param0, const Location *param1); -void FieldTask_ChangeMapToLocation(TaskManager *param0, int param1, int param2, int param3, int param4, int param5); -void FieldTask_StartMapChangeFull(TaskManager *param0, int param1, int param2, int param3, int param4, int param5); +void FieldSystem_StartChangeMapTask(FieldTask *param0, const Location *param1); +void FieldTask_ChangeMapByLocation(FieldTask *param0, const Location *param1); +void FieldTask_ChangeMapToLocation(FieldTask *param0, int param1, int param2, int param3, int param4, int param5); +void FieldTask_StartMapChangeFull(FieldTask *param0, int param1, int param2, int param3, int param4, int param5); void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param2, int param3, int param4, int param5); -void FieldTask_ChangeMapChangeFly(TaskManager *param0, int param1, int param2, int param3, int param4, int param5); -void FieldTask_ChangeMapChangeByDig(TaskManager *param0, const Location *param1, u32 param2); +void FieldTask_ChangeMapChangeFly(FieldTask *param0, int param1, int param2, int param3, int param4, int param5); +void FieldTask_ChangeMapChangeByDig(FieldTask *param0, const Location *param1, u32 param2); void FieldSystem_StartMapChangeWarpTask(FieldSystem *fieldSystem, int param1, int param2); void *sub_02053FAC(FieldSystem *fieldSystem); void FieldTask_SetUndergroundMapChange(FieldSystem *fieldSystem); -BOOL FieldTask_MapChangeToUnderground(TaskManager *param0); -BOOL sub_0205430C(TaskManager *param0); -FieldTask FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem); -void sub_020544F0(TaskManager *param0, const Location *param1); +BOOL FieldTask_MapChangeToUnderground(FieldTask *param0); +BOOL sub_0205430C(FieldTask *param0); +FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem); +void sub_020544F0(FieldTask *param0, const Location *param1); void sub_020545EC(FieldSystem *fieldSystem); -void sub_02054708(TaskManager *param0); -void sub_02054800(TaskManager *param0, int param1, int param2, int param3, int param4, int param5); -void sub_02054864(TaskManager *param0); +void sub_02054708(FieldTask *param0); +void sub_02054800(FieldTask *param0, int param1, int param2, int param3, int param4, int param5); +void sub_02054864(FieldTask *param0); #endif // POKEPLATINUM_FIELD_MAP_CHANGE_H diff --git a/include/field_menu.h b/include/field_menu.h index 4ebfe95f3c..11ee88587a 100644 --- a/include/field_menu.h +++ b/include/field_menu.h @@ -1,25 +1,26 @@ #ifndef POKEPLATINUM_UNK_0203A9C8_H #define POKEPLATINUM_UNK_0203A9C8_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_020708E0.h" #include "field/field_system_decl.h" +#include "field_task.h" + BOOL sub_0203A9C8(FieldSystem *fieldSystem); void FieldMenu_Init(struct FieldSystem_t *fieldSystem); void sub_0203AA78(struct FieldSystem_t *fieldSystem); void sub_0203AABC(FieldSystem *fieldSystem); void sub_0203AB00(FieldSystem *fieldSystem); void sub_0203B674(FieldMenu *param0, void *param1); -BOOL sub_0203B7C0(TaskManager *param0); -BOOL sub_0203C3F4(TaskManager *param0); -BOOL sub_0203C434(TaskManager *param0); -BOOL sub_0203C50C(TaskManager *param0); +BOOL sub_0203B7C0(FieldTask *param0); +BOOL sub_0203C3F4(FieldTask *param0); +BOOL sub_0203C434(FieldTask *param0); +BOOL sub_0203C50C(FieldTask *param0); void *sub_0203C540(u16 param0, u8 param1, u8 param2); -BOOL sub_0203C558(TaskManager *param0); -BOOL sub_0203C710(TaskManager *param0); -BOOL sub_0203C750(TaskManager *param0); -BOOL sub_0203C784(TaskManager *param0); +BOOL sub_0203C558(FieldTask *param0); +BOOL sub_0203C710(FieldTask *param0); +BOOL sub_0203C750(FieldTask *param0); +BOOL sub_0203C784(FieldTask *param0); #endif // POKEPLATINUM_UNK_0203A9C8_H diff --git a/include/field_script_context.h b/include/field_script_context.h index 2b55178915..4481ece6bd 100644 --- a/include/field_script_context.h +++ b/include/field_script_context.h @@ -1,10 +1,9 @@ #ifndef POKEPLATINUM_FIELD_SCRIPT_CONTEXT_H #define POKEPLATINUM_FIELD_SCRIPT_CONTEXT_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" #include "message.h" typedef struct ScriptContext ScriptContext; @@ -22,7 +21,7 @@ struct ScriptContext { const ScrCmdFunc *cmdTable; u32 cmdTableSize; u32 data[4]; - TaskManager *taskManager; + FieldTask *task; MessageLoader *loader; const u8 *scripts; FieldSystem *fieldSystem; @@ -34,7 +33,7 @@ void ScriptContext_Init(ScriptContext *ctx, const ScrCmdFunc *cmdTable, u32 cmdT BOOL ScriptContext_Start(ScriptContext *ctx, const u8 *ptr); void ScriptContext_Pause(ScriptContext *ctx, ShouldResumeScriptFunc shouldResume); void ScriptContext_Stop(ScriptContext *ctx); -void ScriptContext_SetTaskManager(ScriptContext *ctx, TaskManager *taskManager); +void ScriptContext_SetTask(ScriptContext *ctx, FieldTask *taskManager); BOOL ScriptContext_Run(ScriptContext *ctx); void ScriptContext_Jump(ScriptContext *ctx, const u8 *ptr); void ScriptContext_Call(ScriptContext *ctx, const u8 *ptr); diff --git a/include/field_system.h b/include/field_system.h index 30c7f58d15..3515580529 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -8,10 +8,10 @@ #include "overlay_manager.h" #include "savedata.h" -void FieldSystem_StartFieldMap(FieldSystem *fieldSystem); +void FieldSystem_StartFieldMapInner(FieldSystem *fieldSystem); void FieldSystem_FlagNotRunningFieldMap(FieldSystem *fieldSystem); BOOL FieldSystem_HasParentProcess(FieldSystem *fieldSystem); -BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSystem); +BOOL FieldSystem_IsRunningFieldMapInner(FieldSystem *fieldSystem); BOOL FieldSystem_HasChildProcess(FieldSystem *fieldSystem); void FieldSystem_StartChildProcess(FieldSystem *fieldSystem, const OverlayManagerTemplate *overlayTemplate, void *overlayArgs); void FieldSystem_PauseProcessing(void); diff --git a/include/field_task.h b/include/field_task.h new file mode 100644 index 0000000000..f4e1a49fff --- /dev/null +++ b/include/field_task.h @@ -0,0 +1,37 @@ +#ifndef POKEPLATINUM_FIELD_TASK_H +#define POKEPLATINUM_FIELD_TASK_H + +#include "field/field_system_decl.h" + +#include "overlay_manager.h" + +typedef struct FieldTask FieldTask; + +typedef BOOL (*FieldTaskFunc)(FieldTask *); // Return TRUE on completion; return FALSE while still running. + +struct FieldTask { + FieldTask *prev; + FieldTaskFunc func; + int state; + void *env; + int dummy10; + void *dummy14; + FieldSystem *fieldSys; + int *dummy1C; +}; + +FieldTask *FieldSystem_CreateTask(FieldSystem *fieldSys, FieldTaskFunc taskFunc, void *taskEnv); +void FieldTask_InitJump(FieldTask *task, FieldTaskFunc taskFunc, void *taskEnv); +FieldTask *FieldTask_InitCall(FieldTask *task, FieldTaskFunc taskFunc, void *taskEnv); +BOOL FieldTask_Run(FieldSystem *fieldSys); +BOOL FieldSystem_IsRunningTask(FieldSystem *fieldSys); +BOOL FieldSystem_IsRunningApplication(FieldSystem *fieldSys); +void FieldSystem_StartFieldMap(FieldSystem *fieldSys); +BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSys); +void FieldTask_RunApplication(FieldTask *task, const OverlayManagerTemplate *overlayTemplate, void *overlayArgs); +FieldSystem *FieldTask_GetFieldSystem(FieldTask *task); +void *FieldTask_GetEnv(FieldTask *task); +int *FieldTask_GetState(FieldTask *task); +u32 FieldTask_GetDummy1CVal(FieldTask *task); + +#endif // POKEPLATINUM_FIELD_TASK_H diff --git a/include/functypes/funcptr_02050904.h b/include/functypes/funcptr_02050904.h deleted file mode 100644 index 847c25bfec..0000000000 --- a/include/functypes/funcptr_02050904.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_FUNCPTR_02050904_H -#define POKEPLATINUM_FUNCPTR_02050904_H - -#include "struct_decls/struct_020508D4_decl.h" - -typedef BOOL (*FieldTask)(TaskManager *); - -#endif // POKEPLATINUM_FUNCPTR_02050904_H diff --git a/include/functypes/funcptr_020EC560.h b/include/functypes/funcptr_020EC560.h index 0e9707197a..7d797e3604 100644 --- a/include/functypes/funcptr_020EC560.h +++ b/include/functypes/funcptr_020EC560.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_FUNCPTR_020EC560_H #define POKEPLATINUM_FUNCPTR_020EC560_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -typedef BOOL (*UnkFuncPtr_020EC560)(TaskManager *); +typedef BOOL (*UnkFuncPtr_020EC560)(FieldTask *); #endif // POKEPLATINUM_FUNCPTR_020EC560_H diff --git a/include/inlines.h b/include/inlines.h index 1682719ad0..f401ccc80d 100644 --- a/include/inlines.h +++ b/include/inlines.h @@ -20,8 +20,8 @@ #include "script_manager.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_0201D15C.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" static inline void inline_ov61_0222C3B0_sub_1(UnkStruct_ov61_0222C3B0 *); @@ -160,41 +160,6 @@ static inline u16 ScriptContext_GetVar(ScriptContext *ctx) return FieldSystem_TryGetVar(ctx->fieldSystem, ScriptContext_ReadHalfWord(ctx)); } -static inline void inline_0204E650(VarsFlags *param0) -{ - sub_0206AEAC(param0, 1); -} - -static inline void inline_0204E650_1(VarsFlags *param0) -{ - sub_0206AEAC(param0, 0); -} - -static inline BOOL inline_0204E650_2(VarsFlags *param0) -{ - return sub_0206AEAC(param0, 2); -} - -static inline void inline_02044528(VarsFlags *param0) -{ - sub_0206AF2C(param0, 1); -} - -static inline BOOL inline_020535E8(VarsFlags *param0) -{ - return sub_0206AF2C(param0, 2); -} - -static inline void inline_0203A8E8(VarsFlags *param0, u32 param1) -{ - sub_0206AF3C(param0, 1, param1); -} - -static inline BOOL inline_0208BE68(VarsFlags *param0, u32 param1) -{ - return sub_0206AF3C(param0, 2, param1); -} - inline u16 inline_020564D0(const u16 param0) { GF_ASSERT(param0 != 0); diff --git a/include/overlay005/ov5_021D431C.h b/include/overlay005/ov5_021D431C.h index 505eb0e61a..038b206cae 100644 --- a/include/overlay005/ov5_021D431C.h +++ b/include/overlay005/ov5_021D431C.h @@ -1,12 +1,12 @@ #ifndef POKEPLATINUM_OV5_021D431C_H #define POKEPLATINUM_OV5_021D431C_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" #include "overlay005/struct_ov5_021D432C_decl.h" #include "overlay005/struct_ov5_021D4E00_decl.h" +#include "field_task.h" + UnkStruct_ov5_021D432C *ov5_021D431C(void); void ov5_021D432C(UnkStruct_ov5_021D432C *param0); void ov5_021D4334(const int param0, const int param1, UnkStruct_ov5_021D432C *param2); @@ -21,10 +21,10 @@ void ov5_021D4D48(FieldSystem *fieldSystem, const u8 param1); void ov5_021D4D68(FieldSystem *fieldSystem, const u8 param1); void ov5_021D4D78(const int param0, const int param1, const int param2, FieldSystem *param3); UnkStruct_ov5_021D4E00 *ov5_021D4E00(void); -BOOL ov5_021D4E10(TaskManager *param0); -BOOL ov5_021D4F14(TaskManager *param0); -BOOL ov5_021D4FA0(TaskManager *param0); -BOOL ov5_021D5020(TaskManager *param0); -BOOL ov5_021D5150(TaskManager *param0); +BOOL ov5_021D4E10(FieldTask *param0); +BOOL ov5_021D4F14(FieldTask *param0); +BOOL ov5_021D4FA0(FieldTask *param0); +BOOL ov5_021D5020(FieldTask *param0); +BOOL ov5_021D5150(FieldTask *param0); #endif // POKEPLATINUM_OV5_021D431C_H diff --git a/include/overlay005/ov5_021DDAE4.h b/include/overlay005/ov5_021DDAE4.h index dfb39e3cc1..cfd5ca55b1 100644 --- a/include/overlay005/ov5_021DDAE4.h +++ b/include/overlay005/ov5_021DDAE4.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_OV5_021DDAE4_H #define POKEPLATINUM_OV5_021DDAE4_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void ov5_021DDBC8(TaskManager *param0); +void ov5_021DDBC8(FieldTask *param0); #endif // POKEPLATINUM_OV5_021DDAE4_H diff --git a/include/overlay005/ov5_021DFB54.h b/include/overlay005/ov5_021DFB54.h index 056d5bc345..d7b3b0d2ca 100644 --- a/include/overlay005/ov5_021DFB54.h +++ b/include/overlay005/ov5_021DFB54.h @@ -1,23 +1,23 @@ #ifndef POKEPLATINUM_OV5_021DFB54_H #define POKEPLATINUM_OV5_021DFB54_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "field/field_system_decl.h" +#include "field_task.h" #include "sys_task_manager.h" void PlayerAvatar_SetRequestStateBit(PlayerAvatar *playerAvatar, u32 param1); void PlayerAvatar_RequestChangeState(PlayerAvatar *playerAvatar); int ov5_021DFDE0(FieldSystem *fieldSystem, PlayerAvatar *param1, int param2, int param3); -void ov5_021E00EC(TaskManager *param0, int param1, int param2); +void ov5_021E00EC(FieldTask *param0, int param1, int param2); int ov5_021E0118(PlayerAvatar *playerAvatar, u32 param1, u32 param2); -void ov5_021E0734(TaskManager *param0, int param1, int param2); +void ov5_021E0734(FieldTask *param0, int param1, int param2); int ov5_021E0760(u32 param0, int param1); void ov5_021E097C(FieldSystem *fieldSystem, int param1); -void ov5_021E0998(TaskManager *param0, int param1, int param2); -void ov5_021E0DD4(TaskManager *param0); +void ov5_021E0998(FieldTask *param0, int param1, int param2); +void ov5_021E0DD4(FieldTask *param0); void ov5_021E0E94(PlayerAvatar *playerAvatar); void ov5_021E0EEC(PlayerAvatar *playerAvatar); SysTask *ov5_021E1000(FieldSystem *fieldSystem); diff --git a/include/overlay005/ov5_021F007C.h b/include/overlay005/ov5_021F007C.h index 5780dc16b1..7c9593ab61 100644 --- a/include/overlay005/ov5_021F007C.h +++ b/include/overlay005/ov5_021F007C.h @@ -1,11 +1,11 @@ #ifndef POKEPLATINUM_OV5_021F007C_H #define POKEPLATINUM_OV5_021F007C_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" #include "overlay005/struct_ov5_021D1BEC_decl.h" +#include "field_task.h" + UnkStruct_ov5_021D1BEC *ov5_021F01F0(FieldSystem *fieldSystem); UnkStruct_ov5_021D1BEC *ov5_021F0204(FieldSystem *fieldSystem); void ov5_021F0218(UnkStruct_ov5_021D1BEC *param0); @@ -14,6 +14,6 @@ UnkStruct_ov5_021D1BEC *ov5_021F022C(FieldSystem *fieldSystem); UnkStruct_ov5_021D1BEC *ov5_021F0240(FieldSystem *fieldSystem); BOOL ov5_021F0254(UnkStruct_ov5_021D1BEC *param0); u32 ov5_021F0484(void); -BOOL ov5_021F0488(TaskManager *param0); +BOOL ov5_021F0488(FieldTask *param0); #endif // POKEPLATINUM_OV5_021F007C_H diff --git a/include/overlay005/ov5_021F08CC.h b/include/overlay005/ov5_021F08CC.h index 8c1e830bfe..8d70a948d8 100644 --- a/include/overlay005/ov5_021F08CC.h +++ b/include/overlay005/ov5_021F08CC.h @@ -1,14 +1,13 @@ #ifndef POKEPLATINUM_OV5_021F08CC_H #define POKEPLATINUM_OV5_021F08CC_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" #include "sys_task_manager.h" void *ov5_021F08CC(FieldSystem *fieldSystem, u32 param1, int param2); -BOOL ov5_021F08F8(TaskManager *param0); +BOOL ov5_021F08F8(FieldTask *param0); SysTask *ov5_021F09B4(FieldSystem *fieldSystem, int param1, BOOL param2); int ov5_021F09D8(SysTask *param0); int ov5_021F09E4(SysTask *param0); diff --git a/include/overlay005/ov5_021F101C.h b/include/overlay005/ov5_021F101C.h index 94f273f4a2..b098514465 100644 --- a/include/overlay005/ov5_021F101C.h +++ b/include/overlay005/ov5_021F101C.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_OV5_021F101C_H #define POKEPLATINUM_OV5_021F101C_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -BOOL ov5_021F101C(TaskManager *param0); +BOOL ov5_021F101C(FieldTask *param0); #endif // POKEPLATINUM_OV5_021F101C_H diff --git a/include/overlay005/struct_ov5_021D219C.h b/include/overlay005/struct_ov5_021D219C.h deleted file mode 100644 index fe2705d068..0000000000 --- a/include/overlay005/struct_ov5_021D219C.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV5_021D219C_H -#define POKEPLATINUM_STRUCT_OV5_021D219C_H - -typedef struct { - u32 unk_00; -} UnkStruct_ov5_021D219C; - -#endif // POKEPLATINUM_STRUCT_OV5_021D219C_H diff --git a/include/overlay005/vs_seeker.h b/include/overlay005/vs_seeker.h index 34e72e6620..03bca6ddb2 100644 --- a/include/overlay005/vs_seeker.h +++ b/include/overlay005/vs_seeker.h @@ -1,14 +1,14 @@ #ifndef POKEPLATINUM_VS_SEEKER_H #define POKEPLATINUM_VS_SEEKER_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system_decl.h" +#include "field_task.h" #include "string_template.h" -void VsSeeker_Start(TaskManager *taskMan, StringTemplate *template, u16 *outResult); +void VsSeeker_Start(FieldTask *taskMan, StringTemplate *template, u16 *outResult); BOOL VsSeeker_UpdateStepCount(FieldSystem *fieldSystem); u16 VsSeeker_GetRematchTrainerID(FieldSystem *fieldSystem, MapObject *trainerObj, u16 trainerID); void VsSeeker_SetMoveCodeForFacingDirection(FieldSystem *fieldSystem, MapObject *trainerObj); diff --git a/include/overlay006/ov6_0223E140.h b/include/overlay006/ov6_0223E140.h index b1ccab0137..0e220c64c3 100644 --- a/include/overlay006/ov6_0223E140.h +++ b/include/overlay006/ov6_0223E140.h @@ -1,8 +1,6 @@ #ifndef POKEPLATINUM_OV6_0223E140_H #define POKEPLATINUM_OV6_0223E140_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" #include "overlay005/struct_ov5_021D1BEC_decl.h" #include "overlay006/struct_ov6_0223FDE4_decl.h" @@ -14,9 +12,10 @@ #include "overlay006/struct_ov6_02240C44_decl.h" #include "camera.h" +#include "field_task.h" -void ov6_0223E384(TaskManager *param0); -void ov6_0223E4EC(TaskManager *param0); +void ov6_0223E384(FieldTask *param0); +void ov6_0223E4EC(FieldTask *param0); UnkStruct_ov5_021D1BEC *ov6_0223E6EC(FieldSystem *fieldSystem); void ov6_0223E700(UnkStruct_ov5_021D1BEC *param0); BOOL ov6_0223E708(UnkStruct_ov5_021D1BEC *param0); diff --git a/include/overlay006/ov6_02240C9C.h b/include/overlay006/ov6_02240C9C.h index 766eb9e54d..f5011313c3 100644 --- a/include/overlay006/ov6_02240C9C.h +++ b/include/overlay006/ov6_02240C9C.h @@ -1,16 +1,16 @@ #ifndef POKEPLATINUM_OV6_02240C9C_H #define POKEPLATINUM_OV6_02240C9C_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" #include "overlay006/battle_params.h" #include "overlay006/wild_encounters.h" +#include "field_task.h" + void WildEncounters_ReplaceTimedEncounters(const WildEncounters *encounterData, int *param1, int *param2); BOOL ov6_02240D5C(FieldSystem *fieldSystem); BOOL ov6_0224106C(FieldSystem *fieldSystem, const int param1, BattleParams **param2); -BOOL ov6_022411C8(FieldSystem *fieldSystem, TaskManager *param1); +BOOL ov6_022411C8(FieldSystem *fieldSystem, FieldTask *param1); BOOL ov6_022413E4(FieldSystem *fieldSystem, BattleParams **param1); void ov6_02242034(FieldSystem *fieldSystem, BattleParams *param1); void ov6_022420D4(FieldSystem *fieldSystem, u16 param1, u8 param2, BattleParams *param3); diff --git a/include/overlay006/ov6_02247100.h b/include/overlay006/ov6_02247100.h index 50595ab888..2735c4e8cd 100644 --- a/include/overlay006/ov6_02247100.h +++ b/include/overlay006/ov6_02247100.h @@ -1,19 +1,18 @@ #ifndef POKEPLATINUM_OV6_02247100_H #define POKEPLATINUM_OV6_02247100_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" #include "pokemon.h" void *ov6_02247100(FieldSystem *fieldSystem, u32 param1); -BOOL ov6_02247120(TaskManager *param0); +BOOL ov6_02247120(FieldTask *param0); void *ov6_022472C8(FieldSystem *fieldSystem, u32 param1, int param2); -BOOL ov6_022472E8(TaskManager *param0); +BOOL ov6_022472E8(FieldTask *param0); void *ov6_02247488(FieldSystem *, Pokemon *, u32 param0); -BOOL ov6_022474AC(TaskManager *param0); +BOOL ov6_022474AC(FieldTask *param0); void *ov6_02247530(FieldSystem *fieldSystem, Pokemon *param1, u32 param2); -BOOL ov6_02247554(TaskManager *param0); +BOOL ov6_02247554(FieldTask *param0); #endif // POKEPLATINUM_OV6_02247100_H diff --git a/include/overlay006/ov6_02247A0C.h b/include/overlay006/ov6_02247A0C.h index c1d99f793f..7a7d42ae00 100644 --- a/include/overlay006/ov6_02247A0C.h +++ b/include/overlay006/ov6_02247A0C.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_OV6_02247A0C_H #define POKEPLATINUM_OV6_02247A0C_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void ov6_02247A0C(TaskManager *param0); +void ov6_02247A0C(FieldTask *param0); void *ov6_02247A90(void *param0); void ov6_02247CC8(void *param0); diff --git a/include/overlay007/ov7_0224B4E8.h b/include/overlay007/ov7_0224B4E8.h index 844d69f0ec..843e1fad09 100644 --- a/include/overlay007/ov7_0224B4E8.h +++ b/include/overlay007/ov7_0224B4E8.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_OV7_0224B4E8_H #define POKEPLATINUM_OV7_0224B4E8_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void ov7_0224BE7C(TaskManager *param0, u16 *param1); +void ov7_0224BE7C(FieldTask *param0, u16 *param1); #endif // POKEPLATINUM_OV7_0224B4E8_H diff --git a/include/overlay007/ov7_0224CD28.h b/include/overlay007/ov7_0224CD28.h index 67606392fd..f661969bf1 100644 --- a/include/overlay007/ov7_0224CD28.h +++ b/include/overlay007/ov7_0224CD28.h @@ -1,11 +1,11 @@ #ifndef POKEPLATINUM_OV7_0224CD28_H #define POKEPLATINUM_OV7_0224CD28_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" -void ov7_0224CDA4(TaskManager *param0, FieldSystem *fieldSystem, u16 *param2, u8 param3, BOOL param4); -BOOL ov7_0224CEAC(TaskManager *param0); +#include "field_task.h" + +void ov7_0224CDA4(FieldTask *param0, FieldSystem *fieldSystem, u16 *param2, u8 param3, BOOL param4); +BOOL ov7_0224CEAC(FieldTask *param0); #endif // POKEPLATINUM_OV7_0224CD28_H diff --git a/include/overlay009/ov9_02249960.h b/include/overlay009/ov9_02249960.h index 65ba885b21..9533494630 100644 --- a/include/overlay009/ov9_02249960.h +++ b/include/overlay009/ov9_02249960.h @@ -2,12 +2,13 @@ #define POKEPLATINUM_OV9_02249960_H #include "struct_decls/struct_020216E0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system_decl.h" #include "overlay009/struct_ov9_0224F6EC_decl.h" +#include "field_task.h" + void ov9_02249960(FieldSystem *fieldSystem); void ov9_02249A60(FieldSystem *fieldSystem); BOOL ov9_02249E50(FieldSystem *fieldSystem, const int param1, const int param2, const fx32 param3, BOOL *param4); @@ -28,7 +29,7 @@ void ov9_0224F158(FieldSystem *fieldSystem, u16 param1); void ov9_0224F16C(FieldSystem *fieldSystem, u16 param1); BOOL ov9_0224F240(const MapObject *param0, int param1); BOOL ov9_0224F2B0(const MapObject *param0); -UnkStruct_ov9_0224F6EC *ov9_0224F2BC(FieldSystem *fieldSystem, TaskManager *param1, MapObject *param2); +UnkStruct_ov9_0224F6EC *ov9_0224F2BC(FieldSystem *fieldSystem, FieldTask *param1, MapObject *param2); BOOL ov9_0224F6EC(UnkStruct_ov9_0224F6EC *param0); void ov9_02250780(FieldSystem *fieldSystem); BOOL ov9_02250F74(FieldSystem *fieldSystem); diff --git a/include/overlay023/ov23_02254A14.h b/include/overlay023/ov23_02254A14.h index d8813fe63e..6f05f134ba 100644 --- a/include/overlay023/ov23_02254A14.h +++ b/include/overlay023/ov23_02254A14.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_OV23_02254A14_H #define POKEPLATINUM_OV23_02254A14_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" -void ov23_02254D98(FieldSystem *fieldSystem, TaskManager *param1); +#include "field_task.h" + +void ov23_02254D98(FieldSystem *fieldSystem, FieldTask *param1); #endif // POKEPLATINUM_OV23_02254A14_H diff --git a/include/pokeradar.h b/include/pokeradar.h index cca5049d12..97232dc7a3 100644 --- a/include/pokeradar.h +++ b/include/pokeradar.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_POKERADAR_H #define POKEPLATINUM_POKERADAR_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" + typedef struct RadarChain RadarChain; #define NUM_GRASS_PATCHES 4 @@ -28,7 +28,7 @@ void GetRadarMon(RadarChain *chain, int *species, int *level); const BOOL sub_02069798(const RadarChain *chain); void sub_0206979C(FieldSystem *fieldSystem); BOOL GetRadarChainActive(const RadarChain *chain); -BOOL RefreshRadarChain(TaskManager *param0); +BOOL RefreshRadarChain(FieldTask *param0); void sub_02069B74(FieldSystem *fieldSystem); int GetChainCount(FieldSystem *fieldSystem); void RadarChargeStep(FieldSystem *fieldSystem); diff --git a/include/scrcmd_system_flags.h b/include/scrcmd_system_flags.h new file mode 100644 index 0000000000..53d828e186 --- /dev/null +++ b/include/scrcmd_system_flags.h @@ -0,0 +1,27 @@ +#ifndef POKEPLATINUM_SCRCMD_SYSTEM_FLAGS_H +#define POKEPLATINUM_SCRCMD_SYSTEM_FLAGS_H + +#include "field_script_context.h" + +BOOL ScrCmd_CheckPokedexAcquired(ScriptContext *ctx); +BOOL ScrCmd_GivePokedex(ScriptContext *ctx); +BOOL ScrCmd_CheckRunningShoesAcquired(ScriptContext *ctx); +BOOL ScrCmd_GiveRunningShoes(ScriptContext *ctx); +BOOL ScrCmd_CheckBadgeAcquired(ScriptContext *ctx); +BOOL ScrCmd_GiveBadge(ScriptContext *ctx); +BOOL ScrCmd_CountBadgesAcquired(ScriptContext *ctx); +BOOL ScrCmd_CheckBagAcquired(ScriptContext *ctx); +BOOL ScrCmd_GiveBag(ScriptContext *ctx); +BOOL ScrCmd_CheckHasPartner(ScriptContext *ctx); +BOOL ScrCmd_SetHasPartner(ScriptContext *ctx); +BOOL ScrCmd_ClearHasPartner(ScriptContext *ctx); +BOOL ScrCmd_CheckStepFlag(ScriptContext *ctx); +BOOL ScrCmd_SetStepFlag(ScriptContext *ctx); +BOOL ScrCmd_ClearStepFlag(ScriptContext *ctx); +BOOL ScrCmd_CheckGameCompleted(ScriptContext *ctx); +BOOL ScrCmd_SetGameCompleted(ScriptContext *ctx); +BOOL ScrCmd_Strength(ScriptContext *ctx); +BOOL ScrCmd_Flash(ScriptContext *ctx); +BOOL ScrCmd_Defog(ScriptContext *ctx); + +#endif // POKEPLATINUM_SCRCMD_SYSTEM_FLAGS_H diff --git a/include/script_manager.h b/include/script_manager.h index e9d876d12a..b600334786 100644 --- a/include/script_manager.h +++ b/include/script_manager.h @@ -1,7 +1,6 @@ #ifndef POKEPLATINUM_SCRIPT_MANAGER_H #define POKEPLATINUM_SCRIPT_MANAGER_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_defs/struct_0203F478.h" @@ -12,6 +11,7 @@ #include "bg_window.h" #include "field_script_context.h" +#include "field_task.h" #include "menu.h" #include "string_template.h" #include "sys_task_manager.h" @@ -141,8 +141,8 @@ typedef struct ScriptManager { void ScriptManager_Set(FieldSystem *fieldSystem, u16 scriptID, MapObject *object); void ScriptManager_SetApproachingTrainer(FieldSystem *fieldSystem, MapObject *object, int sightRange, int direction, int scriptID, int trainerID, int trainerType, int approachNum); -void ScriptManager_Start(TaskManager *taskManager, u16 scriptID, MapObject *object, void *saveType); -void ScriptManager_Change(TaskManager *taskManager, u16 scriptID, MapObject *object); +void ScriptManager_Start(FieldTask *taskManager, u16 scriptID, MapObject *object, void *saveType); +void ScriptManager_Change(FieldTask *taskManager, u16 scriptID, MapObject *object); ScriptContext *ScriptContext_CreateAndStart(FieldSystem *fieldSystem, u16 scriptID); void *ScriptManager_GetMemberPtr(ScriptManager *scriptManager, u32 member); void *FieldSystem_GetScriptMemberPtr(FieldSystem *fieldSystem, u32 member); diff --git a/include/struct_decls/struct_020508D4_decl.h b/include/struct_decls/struct_020508D4_decl.h deleted file mode 100644 index 9d9f5fd09c..0000000000 --- a/include/struct_decls/struct_020508D4_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_020508D4_DECL_H -#define POKEPLATINUM_STRUCT_020508D4_DECL_H - -typedef struct UnkStruct_020508D4_t TaskManager; - -#endif // POKEPLATINUM_STRUCT_020508D4_DECL_H diff --git a/include/struct_defs/struct_02068630.h b/include/struct_defs/struct_02068630.h index 81390ff099..0c4ef0211e 100644 --- a/include/struct_defs/struct_02068630.h +++ b/include/struct_defs/struct_02068630.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_STRUCT_02068630_H #define POKEPLATINUM_STRUCT_02068630_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" typedef struct { - TaskManager *unk_00; + FieldTask *unk_00; u16 unk_04; u8 unk_06; u8 padding_07; diff --git a/include/struct_defs/struct_020708E0.h b/include/struct_defs/struct_020708E0.h index 1e655dd7c0..52bf42021d 100644 --- a/include/struct_defs/struct_020708E0.h +++ b/include/struct_defs/struct_020708E0.h @@ -5,10 +5,10 @@ #include "struct_defs/struct_020684D0.h" #include "struct_defs/struct_02070950.h" -#include "functypes/funcptr_02050904.h" #include "overlay005/struct_ov5_021D30A8.h" #include "bg_window.h" +#include "field_task.h" #include "menu.h" #include "string_list.h" @@ -26,7 +26,7 @@ typedef struct { u32 unk_220; u32 unk_224; u32 unk_228; - FieldTask unk_22C; + FieldTaskFunc unk_22C; UnkStruct_020684D0 unk_230; UnkStruct_02070950 unk_24C; void *unk_25C; diff --git a/include/struct_defs/struct_020709CC.h b/include/struct_defs/struct_020709CC.h index 08769b8575..3acbdc3a6b 100644 --- a/include/struct_defs/struct_020709CC.h +++ b/include/struct_defs/struct_020709CC.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_STRUCT_020709CC_H #define POKEPLATINUM_STRUCT_020709CC_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" typedef struct UnkStruct_020709CC_t { - TaskManager *unk_00; + FieldTask *unk_00; u16 unk_04; u16 unk_06; } UnkStruct_020709CC; diff --git a/include/system_flags.h b/include/system_flags.h new file mode 100644 index 0000000000..5ad62c4b6c --- /dev/null +++ b/include/system_flags.h @@ -0,0 +1,74 @@ +#ifndef POKEPLATINUM_SYSTEM_FLAGS_H +#define POKEPLATINUM_SYSTEM_FLAGS_H + +#include "constants/savedata/vars_flags.h" +#include "consts/map.h" +#include "consts/pokemon.h" + +#include "vars_flags.h" + +enum HandleFlagOp { + HANDLE_FLAG_CLEAR = 0, + HANDLE_FLAG_SET, + HANDLE_FLAG_CHECK, +}; + +void SystemFlag_SetBagAcquired(VarsFlags *varsFlags); +BOOL SystemFlag_CheckBagAcquired(VarsFlags *varsFlags); +void SystemFlag_SetGameCompleted(VarsFlags *varsFlags); +BOOL SystemFlag_CheckGameCompleted(VarsFlags *varsFlags); +void SystemFlag_SetHasPartner(VarsFlags *varsFlags); +void SystemFlag_ClearHasPartner(VarsFlags *varsFlags); +BOOL SystemFlag_CheckHasPartner(VarsFlags *varsFlags); +void SystemFlag_SetStep(VarsFlags *varsFlags); +void SystemFlag_ClearStep(VarsFlags *varsFlags); +BOOL SystemFlag_CheckStep(VarsFlags *varsFlags); +void SystemFlag_SetVsSeekerUsed(VarsFlags *varsFlags); +void SystemFlag_ClearVsSeekerUsed(VarsFlags *varsFlags); +BOOL SystemFlag_CheckVsSeekerUsed(VarsFlags *varsFlags); +void SystemFlag_SetEnteredUnderground(VarsFlags *varsFlags); +void SystemFlag_SetDiggingForFossils(VarsFlags *varsFlags); +void SystemFlag_SetSphereAcquired(VarsFlags *varsFlags); +void SystemFlag_SetCreatedSecretBase(VarsFlags *varsFlags); +void SystemFlag_SetDecoratedSecretBase(VarsFlags *varsFlags); +void SystemFlag_SetDeliveredStolenFlag(VarsFlags *varsFlags); +void SystemFlag_SetContestMaster(VarsFlags *varsFlags, enum PokemonContestType contestType); +BOOL SystemFlag_CheckContestMaster(VarsFlags *varsFlags, enum PokemonContestType contestType); +BOOL SystemFlag_CheckUnlockedVsSeekerLevel(VarsFlags *varsFlags, int level); +u16 SystemFlag_GetAltMusicForHeader(VarsFlags *varsFlags, enum MapHeader mapHeader); +void SystemFlag_SetCommunicationClubAccessible(VarsFlags *varsFlags); +void SystemFlag_ClearCommunicationClubAccessible(VarsFlags *varsFlags); +BOOL SystemFlag_CheckCommunicationClubAccessible(VarsFlags *varsFlags); +BOOL SystemFlag_CheckContestHallVisited(VarsFlags *varsFlags); +BOOL SystemFlag_CheckUndergroundFirstEntered(VarsFlags *varsFlags); +BOOL SystemFlag_CheckFreedGalacticHQPokemon(VarsFlags *varsFlags); +BOOL SystemFlag_CheckMetBebe(VarsFlags *varsFlags); +void SystemFlag_SetPoketchHidden(VarsFlags *varsFlags); +void SystemFlag_ClearPoketchHidden(VarsFlags *varsFlags); +BOOL SystemFlag_CheckPoketchHidden(VarsFlags *varsFlags); +void SystemFlag_SetSafariGameActive(VarsFlags *varsFlags); +void SystemFlag_ClearSafariGameActive(VarsFlags *varsFlags); +BOOL SystemFlag_CheckSafariGameActive(VarsFlags *varsFlags); +void SystemFlag_SetInPalPark(VarsFlags *varsFlags); +void SystemFlag_ClearInPalPark(VarsFlags *varsFlags); +BOOL SystemFlag_CheckInPalPark(VarsFlags *varsFlags); +void SystemFlag_CheckOnCyclingRoad(VarsFlags *varsFlags); +BOOL SystemFlag_HandleStrengthActive(VarsFlags *varsFlags, enum HandleFlagOp op); +void SystemFlag_SetFlashActive(VarsFlags *varsFlags); +void SystemFlag_ClearFlashActive(VarsFlags *varsFlags); +BOOL SystemFlag_CheckFlashActive(VarsFlags *varsFlags); +void SystemFlag_SetDefogActive(VarsFlags *varsFlags); +void SystemFlag_ClearDefogActive(VarsFlags *varsFlags); +BOOL SystemFlag_CheckDefogActive(VarsFlags *varsFlags); +BOOL SystemFlag_HandleForceBikingInGate(VarsFlags *varsFlags, enum HandleFlagOp op); +BOOL SystemFlag_HandleJournalAcquired(VarsFlags *varsFlags, enum HandleFlagOp op); +BOOL SystemFlag_HandleFirstArrivalToZone(VarsFlags *varsFlags, enum HandleFlagOp op, u32 firstArrival); +void SystemFlag_SetConnectedToWiFi(VarsFlags *varsFlags); +BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurniture furniture); +void SystemFlag_ClearVillaVisitorInside(VarsFlags *varsFlags); +void SystemFlag_ClearVillaVisitorOutside(VarsFlags *varsFlags); +BOOL SystemFlag_HandleGiratinaAnimation(VarsFlags *varsFlags, enum HandleFlagOp op, enum GiratinaShadowAnimation anim); +BOOL SystemFlag_HandleDistortionWorldPuzzleFinished(VarsFlags *varsFlags, enum HandleFlagOp op); +BOOL SystemFlag_CheckDistortionWorldSteppingStones(VarsFlags *varsFlags); + +#endif // POKEPLATINUM_SYSTEM_FLAGS_H diff --git a/include/unk_0202631C.h b/include/unk_0202631C.h index 6c3f508ac1..6bc16ba634 100644 --- a/include/unk_0202631C.h +++ b/include/unk_0202631C.h @@ -45,7 +45,7 @@ BOOL sub_020274D0(const PokedexData *param0, u16 param1, u32 param2); void sub_02027508(PokedexData *param0); BOOL sub_02027514(const PokedexData *param0); BOOL Pokedex_IsObtained(const PokedexData *pokedex); -void sub_02027540(PokedexData *param0); +void Pokedex_FlagObtained(PokedexData *param0); PokedexData *SaveData_Pokedex(SaveData *saveData); u32 sub_0202756C(const PokedexData *param0, int param1, int param2); u32 sub_020276C8(const PokedexData *param0, int param1); diff --git a/include/unk_0203D1B8.h b/include/unk_0203D1B8.h index 74bf0ca6c9..ecb5754114 100644 --- a/include/unk_0203D1B8.h +++ b/include/unk_0203D1B8.h @@ -1,7 +1,6 @@ #ifndef POKEPLATINUM_UNK_0203D1B8_H #define POKEPLATINUM_UNK_0203D1B8_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02070950_decl.h" #include "struct_decls/struct_0209747C_decl.h" #include "struct_defs/choose_starter_data.h" @@ -22,6 +21,7 @@ #include "overlay006/battle_params.h" #include "overlay090/struct_ov90_021D0D80.h" +#include "field_task.h" #include "pokemon.h" #include "savedata.h" @@ -40,7 +40,7 @@ int sub_0203D408(void *param0); void *sub_0203D410(int param0, FieldSystem *fieldSystem, int param2); int sub_0203D438(void *param0); int sub_0203D440(void *param0); -void *sub_0203D50C(TaskManager *param0, int param1); +void *sub_0203D50C(FieldTask *param0, int param1); void *sub_0203D578(int param0, FieldSystem *fieldSystem, int param2, int param3, int param4, int param5); void *sub_0203D5C8(int param0, FieldSystem *fieldSystem, int param2); void *sub_0203D644(FieldSystem *fieldSystem, int param1); @@ -48,7 +48,7 @@ PokemonSummary *sub_0203D670(FieldSystem *fieldSystem, int param1, int param2); void *sub_0203D6E4(int param0, FieldSystem *fieldSystem, u8 param2); int sub_0203D750(void *param0); void sub_0203D754(FieldSystem *fieldSystem, UnkStruct_02042434 *param1); -void sub_0203D80C(TaskManager *param0, u16 *param1, u16 *param2, u16 *param3); +void sub_0203D80C(FieldTask *param0, u16 *param1, u16 *param2, u16 *param3); void sub_0203D874(FieldSystem *fieldSystem, UnkStruct_0209747C *param1); void sub_0203D884(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1); void *sub_0203D8AC(FieldSystem *fieldSystem); @@ -58,16 +58,16 @@ UnkStruct_02097728 *sub_0203D94C(FieldSystem *fieldSystem, int param1, u8 param2 UnkStruct_02097728 *sub_0203D984(FieldSystem *fieldSystem, Pokemon *param1, int param2); UnkStruct_0203D9B8 *sub_0203D9B8(FieldSystem *fieldSystem, int param1); void sub_0203D9D8(FieldSystem *fieldSystem, UnkStruct_ov90_021D0D80 *param1); -void sub_0203DAC0(TaskManager *param0, u16 *param1, SaveData *param2, u16 param3, u16 param4); +void sub_0203DAC0(FieldTask *param0, u16 *param1, SaveData *param2, u16 param3, u16 param4); BOOL sub_0203DB10(FieldSystem *fieldSystem, void *param1); BOOL sub_0203DB24(FieldSystem *fieldSystem, void *param1); -BOOL sub_0203DBF0(TaskManager *param0); -void sub_0203DDDC(TaskManager *param0); +BOOL sub_0203DBF0(FieldTask *param0); +void sub_0203DDDC(FieldTask *param0); void sub_0203DDFC(FieldSystem *fieldSystem); void *sub_0203DE34(FieldSystem *fieldSystem); void sub_0203DE78(FieldSystem *fieldSystem, SaveData *param1); void sub_0203DE88(FieldSystem *fieldSystem, SaveData *param1); -void sub_0203DFE8(TaskManager *param0, int param1, int param2, int param3, int param4, const u16 *param5, u16 *param6); +void sub_0203DFE8(FieldTask *param0, int param1, int param2, int param3, int param4, const u16 *param5, u16 *param6); void sub_0203E09C(FieldSystem *fieldSystem, TrainerCard *param1); BOOL sub_0203E0AC(FieldSystem *fieldSystem, void *param1); void sub_0203E0C0(FieldSystem *fieldSystem, ChooseStarterData *param1); @@ -83,8 +83,8 @@ void sub_0203E2AC(FieldSystem *fieldSystem, void *param1); void sub_0203E2D4(FieldSystem *fieldSystem, void *param1); void sub_0203E2FC(FieldSystem *fieldSystem); BOOL sub_0203E348(FieldSystem *fieldSystem, UnkStruct_0203E348 *param1); -void sub_0203E414(TaskManager *param0, int param1); -void sub_0203E518(TaskManager *param0); +void sub_0203E414(FieldTask *param0, int param1); +void sub_0203E518(FieldTask *param0); void *sub_0203E53C(FieldSystem *fieldSystem, int param1, int param2); void *sub_0203E564(FieldSystem *fieldSystem, u8 param1, u8 param2, u16 param3, int param4); PartyManagementData *sub_0203E598(FieldSystem *fieldSystem, int param1, int param2); diff --git a/include/unk_02049D08.h b/include/unk_02049D08.h index 46ca6f5996..86d214d879 100644 --- a/include/unk_02049D08.h +++ b/include/unk_02049D08.h @@ -2,11 +2,11 @@ #define POKEPLATINUM_UNK_02049D08_H #include "struct_decls/struct_0202D060_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0204AFC4.h" #include "field/field_system_decl.h" +#include "field_task.h" #include "journal.h" #include "savedata.h" @@ -25,7 +25,7 @@ u16 sub_0204A100(SaveData *param0); void sub_0204A110(UnkStruct_0204AFC4 **param0); UnkStruct_0204AFC4 *sub_0204A124(SaveData *param0, u16 param1, u16 param2); void sub_0204A32C(UnkStruct_0204AFC4 *param0); -void sub_0204A358(UnkStruct_0204AFC4 *param0, TaskManager *param1, void **param2); +void sub_0204A358(UnkStruct_0204AFC4 *param0, FieldTask *param1, void **param2); BOOL sub_0204A378(UnkStruct_0204AFC4 *param0, void **param1, SaveData *param2); int sub_0204A410(UnkStruct_0204AFC4 *param0, SaveData *param1); void sub_0204A4C8(UnkStruct_0204AFC4 *param0, SaveData *param1); diff --git a/include/unk_0204E3CC.h b/include/unk_0204E3CC.h deleted file mode 100644 index ba7b3df404..0000000000 --- a/include/unk_0204E3CC.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0204E3CC_H -#define POKEPLATINUM_UNK_0204E3CC_H - -#include "field_script_context.h" - -BOOL ScrCmd_157(ScriptContext *param0); -BOOL ScrCmd_158(ScriptContext *param0); -BOOL ScrCmd_159(ScriptContext *param0); -BOOL ScrCmd_15A(ScriptContext *param0); -BOOL ScrCmd_CheckBadge(ScriptContext *ctx); -BOOL ScrCmd_15C(ScriptContext *param0); -BOOL ScrCmd_15E(ScriptContext *param0); -BOOL ScrCmd_15D(ScriptContext *param0); -BOOL ScrCmd_15F(ScriptContext *param0); -BOOL ScrCmd_160(ScriptContext *param0); -BOOL ScrCmd_161(ScriptContext *param0); -BOOL ScrCmd_162(ScriptContext *param0); -BOOL ScrCmd_163(ScriptContext *param0); -BOOL ScrCmd_164(ScriptContext *param0); -BOOL ScrCmd_165(ScriptContext *param0); -BOOL ScrCmd_166(ScriptContext *param0); -BOOL ScrCmd_167(ScriptContext *param0); -BOOL ScrCmd_1CF(ScriptContext *param0); -BOOL ScrCmd_1D0(ScriptContext *param0); -BOOL ScrCmd_1D1(ScriptContext *param0); - -#endif // POKEPLATINUM_UNK_0204E3CC_H diff --git a/include/unk_020508D4.h b/include/unk_020508D4.h deleted file mode 100644 index aa21435d33..0000000000 --- a/include/unk_020508D4.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef POKEPLATINUM_UNK_020508D4_H -#define POKEPLATINUM_UNK_020508D4_H - -#include "struct_decls/struct_020508D4_decl.h" - -#include "field/field_system_decl.h" -#include "functypes/funcptr_02050904.h" - -#include "overlay_manager.h" - -TaskManager *FieldTask_Set(FieldSystem *fieldSystem, FieldTask param1, void *param2); -void FieldTask_Change(TaskManager *param0, FieldTask param1, void *param2); -TaskManager *FieldTask_Start(TaskManager *param0, FieldTask param1, void *param2); -BOOL sub_02050958(FieldSystem *fieldSystem); -BOOL sub_020509A4(FieldSystem *fieldSystem); -BOOL sub_020509B4(FieldSystem *fieldSystem); -void sub_020509D4(FieldSystem *fieldSystem); -BOOL sub_020509DC(FieldSystem *fieldSystem); -void sub_02050A38(TaskManager *param0, const OverlayManagerTemplate *param1, void *param2); -FieldSystem *TaskManager_FieldSystem(TaskManager *param0); -void *TaskManager_Environment(TaskManager *param0); -int *FieldTask_GetState(TaskManager *param0); -u32 sub_02050A6C(TaskManager *param0); - -#endif // POKEPLATINUM_UNK_020508D4_H diff --git a/include/unk_02050A74.h b/include/unk_02050A74.h deleted file mode 100644 index eefc5a36c0..0000000000 --- a/include/unk_02050A74.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef POKEPLATINUM_UNK_02050A74_H -#define POKEPLATINUM_UNK_02050A74_H - -#include "struct_decls/struct_020508D4_decl.h" -#include "struct_decls/struct_party_decl.h" - -#include "field/field_system_decl.h" -#include "overlay006/battle_params.h" - -void sub_02050ABC(TaskManager *param0, BattleParams *param1); -void sub_02050E10(FieldSystem *fieldSystem, BattleParams *param1); -void sub_02050E78(FieldSystem *fieldSystem, TaskManager *param1, BattleParams *param2); -void sub_0205120C(TaskManager *param0, int *param1); -void sub_02051270(TaskManager *param0, u16 param1, u8 param2, int *param3, BOOL param4); -void sub_020512E4(TaskManager *param0, u16 param1, u8 param2, int *param3, BOOL param4); -void sub_02051450(FieldSystem *fieldSystem, BattleParams *param1); -void sub_02051480(TaskManager *param0, int param1, int param2, int *param3); -void sub_02051590(TaskManager *param0); -void sub_020515CC(TaskManager *param0, int param1, int param2, int param3, int param4, int *param5); -void sub_0205167C(TaskManager *param0, const u8 *param1, int param2); -void sub_020516F4(TaskManager *param0, int param1, int param2, int param3); -void sub_020517E8(FieldSystem *fieldSystem, const u8 *param1, int param2); -void sub_0205184C(FieldSystem *fieldSystem, const Party *param1, int param2); -void sub_02051ABC(TaskManager *param0, u16 param1, u8 param2, int *param3, BOOL param4); - -#endif // POKEPLATINUM_UNK_02050A74_H diff --git a/include/unk_020528D0.h b/include/unk_020528D0.h index 70a132b495..4f6b25dd15 100644 --- a/include/unk_020528D0.h +++ b/include/unk_020528D0.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_UNK_020528D0_H #define POKEPLATINUM_UNK_020528D0_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -BOOL sub_02052B2C(TaskManager *param0); -void sub_02052C5C(TaskManager *param0); +BOOL sub_02052B2C(FieldTask *param0); +void sub_02052C5C(FieldTask *param0); #endif // POKEPLATINUM_UNK_020528D0_H diff --git a/include/unk_02052C6C.h b/include/unk_02052C6C.h index 35682a3a32..d2e551a639 100644 --- a/include/unk_02052C6C.h +++ b/include/unk_02052C6C.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_02052C6C_H #define POKEPLATINUM_UNK_02052C6C_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_02052E58(TaskManager *param0); +void sub_02052E58(FieldTask *param0); #endif // POKEPLATINUM_UNK_02052C6C_H diff --git a/include/unk_0205578C.h b/include/unk_0205578C.h index b0067b2d7d..eb2ad70d5b 100644 --- a/include/unk_0205578C.h +++ b/include/unk_0205578C.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0205578C_H #define POKEPLATINUM_UNK_0205578C_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_020557DC(TaskManager *param0, int param1, int param2); +void sub_020557DC(FieldTask *param0, int param1, int param2); #endif // POKEPLATINUM_UNK_0205578C_H diff --git a/include/unk_02055808.h b/include/unk_02055808.h index 82e02385ee..ee8829da71 100644 --- a/include/unk_02055808.h +++ b/include/unk_02055808.h @@ -1,13 +1,13 @@ #ifndef POKEPLATINUM_UNK_02055808_H #define POKEPLATINUM_UNK_02055808_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void FieldTask_FinishFieldMap(TaskManager *param0); -void FieldTask_StartFieldMap(TaskManager *param0); -void sub_020558AC(TaskManager *param0); -void sub_020558F0(TaskManager *param0); -void FieldTask_FinishFadeOut(TaskManager *param0); -void FieldTask_StartFadeIn(TaskManager *param0); +void FieldTask_FinishFieldMap(FieldTask *param0); +void FieldTask_StartFieldMap(FieldTask *param0); +void sub_020558AC(FieldTask *param0); +void sub_020558F0(FieldTask *param0); +void FieldTask_FinishFadeOut(FieldTask *param0); +void FieldTask_StartFadeIn(FieldTask *param0); #endif // POKEPLATINUM_UNK_02055808_H diff --git a/include/unk_02056B30.h b/include/unk_02056B30.h index 5e31d92377..6154b54573 100644 --- a/include/unk_02056B30.h +++ b/include/unk_02056B30.h @@ -1,11 +1,11 @@ #ifndef POKEPLATINUM_UNK_02056B30_H #define POKEPLATINUM_UNK_02056B30_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" -void sub_02056B30(TaskManager *param0, int param1, int param2, int param3, u16 param4, int param5, int param6, int param7); +#include "field_task.h" + +void sub_02056B30(FieldTask *param0, int param1, int param2, int param3, u16 param4, int param5, int param6, int param7); void sub_02056BDC(FieldSystem *fieldSystem, const int param1, const int param2, const int param3, const int param4, const int param5, const int param6); void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, const int param3, const int param4, const int param5); diff --git a/include/unk_0205749C.h b/include/unk_0205749C.h index f45ab7d07e..203cdde646 100644 --- a/include/unk_0205749C.h +++ b/include/unk_0205749C.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0205749C_H #define POKEPLATINUM_UNK_0205749C_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_0205749C(TaskManager *param0, BOOL param1); +void sub_0205749C(FieldTask *param0, BOOL param1); #endif // POKEPLATINUM_UNK_0205749C_H diff --git a/include/unk_0205DFC4.h b/include/unk_0205DFC4.h index c5a32ffb50..cd73f1f464 100644 --- a/include/unk_0205DFC4.h +++ b/include/unk_0205DFC4.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_UNK_0205DFC4_H #define POKEPLATINUM_UNK_0205DFC4_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" +#include "field_task.h" #include "savedata.h" u16 sub_0205DFC4(u32 param0); @@ -12,8 +12,8 @@ u16 sub_0205E078(u16 param0, u16 param1); u16 sub_0205E0E4(u16 param0, u16 param1); u16 sub_0205E1B4(SaveData *param0); BOOL HasAllLegendaryTitansInParty(SaveData *param0); -void sub_0205E318(TaskManager *param0, MapObject *param1, u16 param2, u16 param3, u16 param4, u16 param5); -void sub_0205E3F4(TaskManager *param0, MapObject *param1, u16 param2, u16 param3); +void sub_0205E318(FieldTask *param0, MapObject *param1, u16 param2, u16 param3, u16 param4, u16 param5); +void sub_0205E3F4(FieldTask *param0, MapObject *param1, u16 param2, u16 param3); int sub_0205E430(u8 param0, u8 param1); int sub_0205E45C(u8 param0, u8 param1); int sub_0205E488(u8 param0, u8 param1); diff --git a/include/unk_0206A8DC.h b/include/unk_0206A8DC.h deleted file mode 100644 index b103b5e456..0000000000 --- a/include/unk_0206A8DC.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0206A8DC_H -#define POKEPLATINUM_UNK_0206A8DC_H - -#include "vars_flags.h" - -void VarsFlags_SetBagAvailable(VarsFlags *param0); -BOOL sub_0206A938(VarsFlags *param0); -void sub_0206A944(VarsFlags *param0); -BOOL sub_0206A954(VarsFlags *param0); -void sub_0206A964(VarsFlags *param0); -void sub_0206A974(VarsFlags *param0); -BOOL sub_0206A984(VarsFlags *param0); -void sub_0206A994(VarsFlags *param0); -void sub_0206A9A4(VarsFlags *param0); -BOOL sub_0206A9B4(VarsFlags *param0); -void VsSeeker_SetUsedFlag(VarsFlags *param0); -void VsSeeker_ClearUsedFlag(VarsFlags *param0); -BOOL VsSeeker_GetUsedFlag(VarsFlags *param0); -void sub_0206A9F4(VarsFlags *param0); -void sub_0206AA04(VarsFlags *param0); -void sub_0206AA14(VarsFlags *param0); -void sub_0206AA20(VarsFlags *param0); -void sub_0206AA30(VarsFlags *param0); -void sub_0206AA40(VarsFlags *param0); -void sub_0206AA50(VarsFlags *param0, int param1); -BOOL sub_0206AAA8(VarsFlags *param0, int param1); -BOOL VsSeeker_HasUnlockedLevel(VarsFlags *param0, int param1); -u16 sub_0206AB68(VarsFlags *param0, int param1); -void sub_0206AD9C(VarsFlags *param0); -void CommClub_ResetAvailable(VarsFlags *param0); -BOOL CommClub_IsAvailable(VarsFlags *param0); -BOOL ContestHall_IsVisited(VarsFlags *param0); -BOOL sub_0206ADDC(VarsFlags *param0); -BOOL sub_0206ADEC(VarsFlags *param0); -BOOL sub_0206ADFC(VarsFlags *param0); -void sub_0206AE0C(VarsFlags *param0); -void sub_0206AE1C(VarsFlags *param0); -BOOL sub_0206AE2C(VarsFlags *param0); -void sub_0206AE3C(VarsFlags *param0); -void sub_0206AE4C(VarsFlags *param0); -BOOL sub_0206AE5C(VarsFlags *param0); -void sub_0206AE6C(VarsFlags *param0); -void sub_0206AE7C(VarsFlags *param0); -BOOL sub_0206AE8C(VarsFlags *param0); -void sub_0206AE9C(VarsFlags *param0); -BOOL sub_0206AEAC(VarsFlags *param0, int param1); -void sub_0206AEBC(VarsFlags *param0); -void sub_0206AECC(VarsFlags *param0); -BOOL Overworld_IsFlashActive(VarsFlags *param0); -void sub_0206AEEC(VarsFlags *param0); -void sub_0206AEFC(VarsFlags *param0); -BOOL Overworld_IsDefogActive(VarsFlags *param0); -BOOL sub_0206AF1C(VarsFlags *param0, int param1); -BOOL sub_0206AF2C(VarsFlags *param0, int param1); -BOOL sub_0206AF3C(VarsFlags *param0, int param1, u32 param2); -void sub_0206AF5C(VarsFlags *param0); -BOOL sub_0206AF6C(VarsFlags *param0, int param1, int param2); -void sub_0206AF90(VarsFlags *param0); -void sub_0206AFA0(VarsFlags *param0); -BOOL sub_0206AFB0(VarsFlags *param0, int param1, int param2); -BOOL sub_0206AFC0(VarsFlags *param0, int param1); -BOOL sub_0206AFD0(VarsFlags *param0); - -#endif // POKEPLATINUM_UNK_0206A8DC_H diff --git a/include/unk_0206B9D8.h b/include/unk_0206B9D8.h index eee48f2b60..664db38bf1 100644 --- a/include/unk_0206B9D8.h +++ b/include/unk_0206B9D8.h @@ -1,15 +1,14 @@ #ifndef POKEPLATINUM_UNK_0206B9D8_H #define POKEPLATINUM_UNK_0206B9D8_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" #include "savedata.h" -void sub_0206BBFC(TaskManager *param0, void **param1, u8 param2, u8 param3, u8 param4, u8 param5, u8 param6, u8 param7); -void sub_0206BCE4(TaskManager *param0, u16 param1, u16 param2, u16 param3); -void sub_0206BD88(TaskManager *param0, u16 param1, u16 param2); +void sub_0206BBFC(FieldTask *param0, void **param1, u8 param2, u8 param3, u8 param4, u8 param5, u8 param6, u8 param7); +void sub_0206BCE4(FieldTask *param0, u16 param1, u16 param2, u16 param3); +void sub_0206BD88(FieldTask *param0, u16 param1, u16 param2); u16 sub_0206BDBC(SaveData *param0); u16 sub_0206BF04(SaveData *param0); u32 sub_0206BFF0(u32 param0); diff --git a/include/unk_0206C660.h b/include/unk_0206C660.h index cd698b2012..ef7d51068e 100644 --- a/include/unk_0206C660.h +++ b/include/unk_0206C660.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_UNK_0206C660_H #define POKEPLATINUM_UNK_0206C660_H -#include "struct_decls/struct_020508D4_decl.h" - #include "overlay006/struct_ov6_02246204_decl.h" -void sub_0206C740(TaskManager *param0, UnkStruct_ov6_02246204 *param1, int param2, u32 param3); +#include "field_task.h" + +void sub_0206C740(FieldTask *param0, UnkStruct_ov6_02246204 *param1, int param2, u32 param3); #endif // POKEPLATINUM_UNK_0206C660_H diff --git a/include/unk_0206F314.h b/include/unk_0206F314.h index c67bd29e80..9be8a39a18 100644 --- a/include/unk_0206F314.h +++ b/include/unk_0206F314.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0206F314_H #define POKEPLATINUM_UNK_0206F314_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_020703FC(TaskManager *param0, u16 param1); +void sub_020703FC(FieldTask *param0, u16 param1); #endif // POKEPLATINUM_UNK_0206F314_H diff --git a/include/unk_0207064C.h b/include/unk_0207064C.h index cf7b1f5dcc..4230684573 100644 --- a/include/unk_0207064C.h +++ b/include/unk_0207064C.h @@ -1,13 +1,12 @@ #ifndef POKEPLATINUM_UNK_0207064C_H #define POKEPLATINUM_UNK_0207064C_H -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" +#include "field_task.h" #include "pokemon.h" void *sub_0207064C(u32 param0, FieldSystem *fieldSystem, Pokemon *param2, u16 param3, s16 param4, s16 param5); -BOOL sub_02070680(TaskManager *param0); +BOOL sub_02070680(FieldTask *param0); #endif // POKEPLATINUM_UNK_0207064C_H diff --git a/include/unk_020722AC.h b/include/unk_020722AC.h index 6b8e799c6c..88d78c6367 100644 --- a/include/unk_020722AC.h +++ b/include/unk_020722AC.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_UNK_020722AC_H #define POKEPLATINUM_UNK_020722AC_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" void sub_020722AC(void *param0, int *param1); -void sub_020736D8(TaskManager *param0); +void sub_020736D8(FieldTask *param0); #endif // POKEPLATINUM_UNK_020722AC_H diff --git a/include/unk_0207DA28.h b/include/unk_0207DA28.h index 3eb9ce9e94..d3c99835bd 100644 --- a/include/unk_0207DA28.h +++ b/include/unk_0207DA28.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_UNK_0207DA28_H #define POKEPLATINUM_UNK_0207DA28_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_0207DDC0(TaskManager *param0); -void sub_0207DDE0(TaskManager *param0, u16 *param1); +void sub_0207DDC0(FieldTask *param0); +void sub_0207DDE0(FieldTask *param0, u16 *param1); #endif // POKEPLATINUM_UNK_0207DA28_H diff --git a/include/unk_020933F8.h b/include/unk_020933F8.h index 6c0d806ac6..11591ad147 100644 --- a/include/unk_020933F8.h +++ b/include/unk_020933F8.h @@ -1,15 +1,15 @@ #ifndef POKEPLATINUM_UNK_020933F8_H #define POKEPLATINUM_UNK_020933F8_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02093800.h" #include "struct_defs/struct_02095C48.h" +#include "field_task.h" #include "journal.h" #include "savedata.h" #include "string_template.h" -void sub_020933F8(TaskManager *param0, UnkStruct_02095C48 *param1); +void sub_020933F8(FieldTask *param0, UnkStruct_02095C48 *param1); UnkStruct_02095C48 *sub_02093800(const UnkStruct_02093800 *param0); void sub_02093AD4(UnkStruct_02095C48 *param0); BOOL sub_020943B0(UnkStruct_02095C48 *param0); diff --git a/include/unk_02097B18.h b/include/unk_02097B18.h index dc49961a51..bd885fe616 100644 --- a/include/unk_02097B18.h +++ b/include/unk_02097B18.h @@ -1,9 +1,9 @@ #ifndef POKEPLATINUM_UNK_02097B18_H #define POKEPLATINUM_UNK_02097B18_H -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02097F18.h" +#include "field_task.h" #include "pokemon.h" #include "savedata.h" @@ -12,7 +12,7 @@ u8 sub_02097F18(UnkStruct_02097F18 *param0); void sub_02097F20(UnkStruct_02097F18 *param0, u8 param1); u8 sub_02097F28(UnkStruct_02097F18 *param0); void sub_02097F30(UnkStruct_02097F18 *param0, u8 param1); -void sub_020980DC(TaskManager *param0, SaveData *param1); +void sub_020980DC(FieldTask *param0, SaveData *param1); int sub_02098140(u8 param0); int sub_02098164(u8 param0); int sub_02098188(u8 param0); diff --git a/include/unk_02098218.h b/include/unk_02098218.h index a40a9cb310..db83947c67 100644 --- a/include/unk_02098218.h +++ b/include/unk_02098218.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_02098218_H #define POKEPLATINUM_UNK_02098218_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_020985AC(TaskManager *param0, void *param1); +void sub_020985AC(FieldTask *param0, void *param1); #endif // POKEPLATINUM_UNK_02098218_H diff --git a/include/unk_020985E4.h b/include/unk_020985E4.h index 5d913e2a41..18b8294c97 100644 --- a/include/unk_020985E4.h +++ b/include/unk_020985E4.h @@ -1,11 +1,10 @@ #ifndef POKEPLATINUM_UNK_020985E4_H #define POKEPLATINUM_UNK_020985E4_H -#include "struct_decls/struct_020508D4_decl.h" - +#include "field_task.h" #include "savedata.h" -void sub_020985E4(TaskManager *param0, SaveData *param1); -BOOL sub_0209862C(TaskManager *param0); +void sub_020985E4(FieldTask *param0, SaveData *param1); +BOOL sub_0209862C(FieldTask *param0); #endif // POKEPLATINUM_UNK_020985E4_H diff --git a/include/unk_0209AC14.h b/include/unk_0209AC14.h index 8dc51655ca..330a4b32d3 100644 --- a/include/unk_0209AC14.h +++ b/include/unk_0209AC14.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0209AC14_H #define POKEPLATINUM_UNK_0209AC14_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -BOOL sub_0209AC14(TaskManager *param0); +BOOL sub_0209AC14(FieldTask *param0); #endif // POKEPLATINUM_UNK_0209AC14_H diff --git a/include/unk_0209ACF4.h b/include/unk_0209ACF4.h index 0b8b197e9a..ec2501570c 100644 --- a/include/unk_0209ACF4.h +++ b/include/unk_0209ACF4.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0209ACF4_H #define POKEPLATINUM_UNK_0209ACF4_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_0209ACF4(TaskManager *param0); +void sub_0209ACF4(FieldTask *param0); #endif // POKEPLATINUM_UNK_0209ACF4_H diff --git a/include/unk_0209B344.h b/include/unk_0209B344.h index 1a73807f32..60ea40c93a 100644 --- a/include/unk_0209B344.h +++ b/include/unk_0209B344.h @@ -1,8 +1,8 @@ #ifndef POKEPLATINUM_UNK_0209B344_H #define POKEPLATINUM_UNK_0209B344_H -#include "struct_decls/struct_020508D4_decl.h" +#include "field_task.h" -void sub_0209B344(TaskManager *param0, u16 *param1); +void sub_0209B344(FieldTask *param0, u16 *param1); #endif // POKEPLATINUM_UNK_0209B344_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index a8590307f8..5894907154 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -203,7 +203,7 @@ Static main Object main.nef.p/src_unk_0204CFFC.c.o Object main.nef.p/src_unk_0204E240.c.o Object main.nef.p/src_unk_0204E378.c.o - Object main.nef.p/src_unk_0204E3CC.c.o + Object main.nef.p/src_scrcmd_system_flags.c.o Object main.nef.p/src_unk_0204E75C.c.o Object main.nef.p/src_unk_0204E974.c.o Object main.nef.p/src_unk_0204EDA4.c.o @@ -217,8 +217,8 @@ Static main Object main.nef.p/src_unk_02050548.c.o Object main.nef.p/src_unk_02050568.c.o Object main.nef.p/src_vars_flags.c.o - Object main.nef.p/src_unk_020508D4.c.o - Object main.nef.p/src_unk_02050A74.c.o + Object main.nef.p/src_field_task.c.o + Object main.nef.p/src_encounter.c.o Object main.nef.p/src_enc_effects.c.o Object main.nef.p/src_unk_02051D8C.c.o Object main.nef.p/src_unk_020528D0.c.o @@ -263,7 +263,7 @@ Static main Object main.nef.p/src_pokeradar.c.o Object main.nef.p/src_unk_02069BE0.c.o Object main.nef.p/src_unk_0206A780.c.o - Object main.nef.p/src_unk_0206A8DC.c.o + Object main.nef.p/src_system_flags.c.o Object main.nef.p/src_unk_0206AFE0.c.o Object main.nef.p/src_unk_0206B70C.c.o Object main.nef.p/src_unk_0206B9D8.c.o diff --git a/res/field/scripts/scripts_acuity_lakefront.s b/res/field/scripts/scripts_acuity_lakefront.s index 9a596a4b23..2df437a6a1 100644 --- a/res/field/scripts/scripts_acuity_lakefront.s +++ b/res/field/scripts/scripts_acuity_lakefront.s @@ -24,7 +24,7 @@ _003C: End _004E: - CheckBadge BADGE_ID_ICICLE, 0x4000 + CheckBadgeAcquired BADGE_ID_ICICLE, 0x4000 CallIfEq 0x4000, 1, _0079 GoToIfUnset 186, _002A GoToIfSet 186, _003C diff --git a/res/field/scripts/scripts_amity_square.s b/res/field/scripts/scripts_amity_square.s index 72d1cc4da2..a8ff53abd8 100644 --- a/res/field/scripts/scripts_amity_square.s +++ b/res/field/scripts/scripts_amity_square.s @@ -198,7 +198,7 @@ _02C9: ApplyMovement 0xFF, _03C8 ApplyMovement 0x8002, _03C8 WaitMovement - ScrCmd_161 + SetHasPartner ScrCmd_06D 0x8002, 48 ReleaseAll End @@ -247,7 +247,7 @@ _0365: LockAll FadeScreen 6, 1, 0, 0 WaitFadeScreen - ScrCmd_162 + ClearHasPartner GoTo _037D End diff --git a/res/field/scripts/scripts_battle_tower.s b/res/field/scripts/scripts_battle_tower.s index a3c6e7547e..688c009e6e 100644 --- a/res/field/scripts/scripts_battle_tower.s +++ b/res/field/scripts/scripts_battle_tower.s @@ -57,7 +57,7 @@ _00EB: End _00F1: - ScrCmd_266 + ShowPoketch Return _00F5: diff --git a/res/field/scripts/scripts_battle_tower_elevator.s b/res/field/scripts/scripts_battle_tower_elevator.s index 27852d7cce..acd78bdcf2 100644 --- a/res/field/scripts/scripts_battle_tower_elevator.s +++ b/res/field/scripts/scripts_battle_tower_elevator.s @@ -22,7 +22,7 @@ _0012: End _008A: - ScrCmd_265 + HidePoketch Return _008E: diff --git a/res/field/scripts/scripts_canalave_city.s b/res/field/scripts/scripts_canalave_city.s index 832974ea8c..7a6d40d379 100644 --- a/res/field/scripts/scripts_canalave_city.s +++ b/res/field/scripts/scripts_canalave_city.s @@ -396,7 +396,7 @@ _054D: LockAll FacePlayer GoToIfSet 168, _0586 - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 1, _0591 GoTo _057B End diff --git a/res/field/scripts/scripts_canalave_city_gym.s b/res/field/scripts/scripts_canalave_city_gym.s index 8883c8371a..fea8c67b1e 100644 --- a/res/field/scripts/scripts_canalave_city_gym.s +++ b/res/field/scripts/scripts_canalave_city_gym.s @@ -16,7 +16,7 @@ _0016: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 1, _0107 ScrCmd_1CD 9, 35, 0, 0, 0 Message 0 @@ -29,7 +29,7 @@ _0016: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 5 + GiveBadge BADGE_ID_MINE ScrCmd_260 23 SetTrainerFlag 232 SetTrainerFlag 0x100 @@ -88,7 +88,7 @@ _0126: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 1, _014C Message 6 WaitABXPadPress @@ -107,7 +107,7 @@ _014C: _015A: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 1, _0184 BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_canalave_city_sailor_eldritch_house.s b/res/field/scripts/scripts_canalave_city_sailor_eldritch_house.s index 3cd429eb6a..ecd833588e 100644 --- a/res/field/scripts/scripts_canalave_city_sailor_eldritch_house.s +++ b/res/field/scripts/scripts_canalave_city_sailor_eldritch_house.s @@ -16,7 +16,7 @@ _0035: _0037: GoToIfSet 0x12C, _0035 - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _0035 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _0035 diff --git a/res/field/scripts/scripts_eterna_city_gym.s b/res/field/scripts/scripts_eterna_city_gym.s index 74e1e40c2b..04a9f911ff 100644 --- a/res/field/scripts/scripts_eterna_city_gym.s +++ b/res/field/scripts/scripts_eterna_city_gym.s @@ -19,7 +19,7 @@ _0022: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_FOREST, 0x800C + CheckBadgeAcquired BADGE_ID_FOREST, 0x800C GoToIfEq 0x800C, 1, _0048 Message 13 WaitABXPadPress @@ -38,7 +38,7 @@ _0048: _0056: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_FOREST, 0x800C + CheckBadgeAcquired BADGE_ID_FOREST, 0x800C GoToIfEq 0x800C, 1, _0080 BufferRivalName 0 BufferRivalName 1 @@ -62,7 +62,7 @@ _0094: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_FOREST, 0x800C + CheckBadgeAcquired BADGE_ID_FOREST, 0x800C GoToIfEq 0x800C, 1, _0161 ScrCmd_1CD 9, 67, 0, 0, 0 Message 0 @@ -75,7 +75,7 @@ _0094: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 1 + GiveBadge BADGE_ID_FOREST ScrCmd_260 23 SetTrainerFlag 0x103 SetTrainerFlag 0x104 diff --git a/res/field/scripts/scripts_eterna_forest.s b/res/field/scripts/scripts_eterna_forest.s index 9c25c30328..b2f416d0cd 100644 --- a/res/field/scripts/scripts_eterna_forest.s +++ b/res/field/scripts/scripts_eterna_forest.s @@ -55,7 +55,7 @@ _008E: WaitABXPadPress CloseMessage SetVar 0x403F, 0x260 - ScrCmd_161 + SetHasPartner ScrCmd_06D 0, 48 ScrCmd_06C 0, 1 ReleaseAll @@ -87,7 +87,7 @@ _00F4: _0108: LockAll - ScrCmd_162 + ClearHasPartner ScrCmd_06D 0, 15 ScrCmd_06C 0, 0 ApplyMovement 0, _0190 @@ -207,7 +207,7 @@ _02CB: ApplyMovement 0, _035C WaitMovement PlayFanfare SEQ_SE_DP_KAIDAN2 - ScrCmd_162 + ClearHasPartner ScrCmd_065 0 WaitFanfare SEQ_SE_DP_KAIDAN2 SetFlag 227 diff --git a/res/field/scripts/scripts_hearthome_city.s b/res/field/scripts/scripts_hearthome_city.s index df5cc49b9b..6857c3180d 100644 --- a/res/field/scripts/scripts_hearthome_city.s +++ b/res/field/scripts/scripts_hearthome_city.s @@ -337,7 +337,7 @@ _03AC: _03F4: GoToIfSet 0x14B, _0442 - ScrCmd_15D 0x800C + CountBadgesAcquired 0x800C GoToIfLt 0x800C, 8, _0442 Message 34 SetVar 0x8004, 47 diff --git a/res/field/scripts/scripts_hearthome_city_dp_gym_leader_room.s b/res/field/scripts/scripts_hearthome_city_dp_gym_leader_room.s index 5a0c15d5bf..a1d6fda8c3 100644 --- a/res/field/scripts/scripts_hearthome_city_dp_gym_leader_room.s +++ b/res/field/scripts/scripts_hearthome_city_dp_gym_leader_room.s @@ -40,7 +40,7 @@ _0086: GoTo _0096 _0096: - CheckBadge BADGE_ID_RELIC, 0x800C + CheckBadgeAcquired BADGE_ID_RELIC, 0x800C GoToIfEq 0x800C, 1, _0173 ScrCmd_1CD 9, 100, 0, 0, 0 Message 0 @@ -53,7 +53,7 @@ _0096: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 4 + GiveBadge BADGE_ID_RELIC ScrCmd_260 23 SetTrainerFlag 0x10A SetTrainerFlag 0x118 diff --git a/res/field/scripts/scripts_hearthome_city_gym_entrance_room.s b/res/field/scripts/scripts_hearthome_city_gym_entrance_room.s index 95756c5987..2070dc475a 100644 --- a/res/field/scripts/scripts_hearthome_city_gym_entrance_room.s +++ b/res/field/scripts/scripts_hearthome_city_gym_entrance_room.s @@ -11,7 +11,7 @@ _000E: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_RELIC, 0x800C + CheckBadgeAcquired BADGE_ID_RELIC, 0x800C GoToIfEq 0x800C, 1, _006A Message 1 ScrCmd_03E 0x800C @@ -44,7 +44,7 @@ _006A: _0078: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_RELIC, 0x800C + CheckBadgeAcquired BADGE_ID_RELIC, 0x800C GoToIfEq 0x800C, 1, _00A2 BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_hearthome_city_gym_leader_room.s b/res/field/scripts/scripts_hearthome_city_gym_leader_room.s index bdaad9c5cc..f82a1d9fde 100644 --- a/res/field/scripts/scripts_hearthome_city_gym_leader_room.s +++ b/res/field/scripts/scripts_hearthome_city_gym_leader_room.s @@ -53,7 +53,7 @@ _00AB: GoTo _00BB _00BB: - CheckBadge BADGE_ID_RELIC, 0x800C + CheckBadgeAcquired BADGE_ID_RELIC, 0x800C GoToIfEq 0x800C, 1, _01A0 ScrCmd_1CD 9, 91, 0, 0, 0 Message 0 @@ -68,7 +68,7 @@ _00BB: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 4 + GiveBadge BADGE_ID_RELIC ScrCmd_260 23 SetTrainerFlag 0x10A SetTrainerFlag 0x118 diff --git a/res/field/scripts/scripts_iron_island.s b/res/field/scripts/scripts_iron_island.s index e737b03bbd..0490aca1de 100644 --- a/res/field/scripts/scripts_iron_island.s +++ b/res/field/scripts/scripts_iron_island.s @@ -97,7 +97,7 @@ _00FC: SetVar 0x8004, 0x1A7 SetVar 0x8005, 1 CallCommonScript 0x7FC - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 0, _0140 GoTo _0135 End diff --git a/res/field/scripts/scripts_iron_island_b2f_left_room.s b/res/field/scripts/scripts_iron_island_b2f_left_room.s index e8c30f36b5..39084e431e 100644 --- a/res/field/scripts/scripts_iron_island_b2f_left_room.s +++ b/res/field/scripts/scripts_iron_island_b2f_left_room.s @@ -52,7 +52,7 @@ _0064: WaitABXPadPress CloseMessage SetVar 0x403F, 0x261 - ScrCmd_161 + SetHasPartner ScrCmd_06D 4, 48 ReleaseAll End @@ -83,7 +83,7 @@ _00F3: Message 4 CloseMessage SetVar 0x4092, 0 - ScrCmd_162 + ClearHasPartner ScrCmd_06D 4, 16 GetPlayerMapPos 0x8004, 0x8005 CallIfEq 0x8005, 2, _013E @@ -151,7 +151,7 @@ _01A8: _01AA: LockAll - ScrCmd_162 + ClearHasPartner ScrCmd_06D 4, 16 GetPlayerMapPos 0x8004, 0x8005 CallIfEq 0x8005, 40, _0291 @@ -171,9 +171,9 @@ _01AA: BufferPlayerName 0 Message 8 CloseMessage - ScrCmd_161 + SetHasPartner ScrCmd_0E5 0x343, 0x344 - ScrCmd_162 + ClearHasPartner CheckWonBattle 0x800C GoToIfEq 0x800C, 0, _037D ApplyMovement 5, _0394 diff --git a/res/field/scripts/scripts_jubilife_city.s b/res/field/scripts/scripts_jubilife_city.s index b517d7fa7d..c93493706d 100644 --- a/res/field/scripts/scripts_jubilife_city.s +++ b/res/field/scripts/scripts_jubilife_city.s @@ -440,7 +440,7 @@ _058C: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _05B2 Message 29 WaitABXPadPress diff --git a/res/field/scripts/scripts_lake_verity_low_water.s b/res/field/scripts/scripts_lake_verity_low_water.s index b70cb8c962..0d812c3605 100644 --- a/res/field/scripts/scripts_lake_verity_low_water.s +++ b/res/field/scripts/scripts_lake_verity_low_water.s @@ -39,7 +39,7 @@ _005B: _006F: LockAll - ScrCmd_162 + ClearHasPartner ApplyMovement 5, _0298 ApplyMovement 0xFF, _0368 WaitMovement diff --git a/res/field/scripts/scripts_oreburgh_city.s b/res/field/scripts/scripts_oreburgh_city.s index fb50d79938..5cc362c971 100644 --- a/res/field/scripts/scripts_oreburgh_city.s +++ b/res/field/scripts/scripts_oreburgh_city.s @@ -52,7 +52,7 @@ _0090: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _00C1 GoToIfSet 122, _00CC Message 8 diff --git a/res/field/scripts/scripts_oreburgh_city_gym.s b/res/field/scripts/scripts_oreburgh_city_gym.s index ff3a2e7c66..3286c8e9ae 100644 --- a/res/field/scripts/scripts_oreburgh_city_gym.s +++ b/res/field/scripts/scripts_oreburgh_city_gym.s @@ -11,7 +11,7 @@ _000E: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _0103 ScrCmd_1CD 9, 47, 0, 0, 0 Message 0 @@ -26,7 +26,7 @@ _000E: WaitSound SetTrainerFlag 244 SetTrainerFlag 245 - ScrCmd_15C 0 + GiveBadge BADGE_ID_COAL ScrCmd_260 23 SetTrainerFlag 244 SetTrainerFlag 245 @@ -82,7 +82,7 @@ _011F: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _0145 Message 6 WaitABXPadPress @@ -101,7 +101,7 @@ _0145: _0153: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _017D BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_oreburgh_gate_1f.s b/res/field/scripts/scripts_oreburgh_gate_1f.s index 24ffc27f15..1fca70500f 100644 --- a/res/field/scripts/scripts_oreburgh_gate_1f.s +++ b/res/field/scripts/scripts_oreburgh_gate_1f.s @@ -15,7 +15,7 @@ _0014: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 0, _003A Message 2 WaitABXPadPress diff --git a/res/field/scripts/scripts_pastoria_city.s b/res/field/scripts/scripts_pastoria_city.s index 80403548f8..aa35fd3486 100644 --- a/res/field/scripts/scripts_pastoria_city.s +++ b/res/field/scripts/scripts_pastoria_city.s @@ -86,7 +86,7 @@ _00FE: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_FEN, 0x800C + CheckBadgeAcquired BADGE_ID_FEN, 0x800C GoToIfEq 0x800C, 1, _0124 Message 33 WaitABXPadPress diff --git a/res/field/scripts/scripts_pastoria_city_gym.s b/res/field/scripts/scripts_pastoria_city_gym.s index 49bc62fc82..7f9220296a 100644 --- a/res/field/scripts/scripts_pastoria_city_gym.s +++ b/res/field/scripts/scripts_pastoria_city_gym.s @@ -43,7 +43,7 @@ _0076: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_FEN, 0x800C + CheckBadgeAcquired BADGE_ID_FEN, 0x800C GoToIfEq 0x800C, 1, _0155 ScrCmd_1CD 9, 122, 0, 0, 0 Message 0 @@ -56,7 +56,7 @@ _0076: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 3 + GiveBadge BADGE_ID_FEN ScrCmd_260 23 SetTrainerFlag 0x125 SetTrainerFlag 0x153 @@ -110,7 +110,7 @@ _0171: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_FEN, 0x800C + CheckBadgeAcquired BADGE_ID_FEN, 0x800C GoToIfEq 0x800C, 1, _0197 Message 6 WaitABXPadPress @@ -129,7 +129,7 @@ _0197: _01A5: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_FEN, 0x800C + CheckBadgeAcquired BADGE_ID_FEN, 0x800C GoToIfEq 0x800C, 1, _01CF BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_pokemon_mansion_office.s b/res/field/scripts/scripts_pokemon_mansion_office.s index 4a506870a1..9d7767f7f7 100644 --- a/res/field/scripts/scripts_pokemon_mansion_office.s +++ b/res/field/scripts/scripts_pokemon_mansion_office.s @@ -194,7 +194,7 @@ _0257: _0270: GoToIfSet 0xAA2, _0304 - ScrCmd_166 0x800C + CheckGameCompleted 0x800C GoToIfEq 0x800C, 1, _02C8 ScrCmd_1B7 0x800C, 2 CallIfEq 0x800C, 0, _02BE diff --git a/res/field/scripts/scripts_poketch_co_1f.s b/res/field/scripts/scripts_poketch_co_1f.s index 1ba8e684ce..98b851804a 100644 --- a/res/field/scripts/scripts_poketch_co_1f.s +++ b/res/field/scripts/scripts_poketch_co_1f.s @@ -25,7 +25,7 @@ _0042: LockAll FacePlayer Message 0 - ScrCmd_15D 0x8000 + CountBadgesAcquired 0x8000 GoToIfEq 0x8000, 0, _0181 ScrCmd_134 2, 0x800C GoToIfEq 0x800C, 0, _00C5 @@ -40,22 +40,22 @@ _0042: GoTo _01AD _00C5: - ScrCmd_15D 0x800C + CountBadgesAcquired 0x800C GoToIfGe 0x800C, 1, _0121 GoTo _0181 _00DC: - ScrCmd_15D 0x800C + CountBadgesAcquired 0x800C GoToIfGe 0x800C, 3, _0139 GoTo _018C _00F3: - ScrCmd_15D 0x800C + CountBadgesAcquired 0x800C GoToIfGe 0x800C, 5, _0151 GoTo _0197 _010A: - ScrCmd_15D 0x800C + CountBadgesAcquired 0x800C GoToIfGe 0x800C, 7, _0169 GoTo _01A2 diff --git a/res/field/scripts/scripts_route_201.s b/res/field/scripts/scripts_route_201.s index 7cf51aa1de..0af1db3635 100644 --- a/res/field/scripts/scripts_route_201.s +++ b/res/field/scripts/scripts_route_201.s @@ -778,7 +778,7 @@ _0967: BufferPlayerName 1 Message 53 CloseMessage - ScrCmd_162 + ClearHasPartner ScrCmd_06D 2, 15 Return @@ -788,7 +788,7 @@ _097C: End _0986: - ScrCmd_161 + SetHasPartner ScrCmd_06D 2, 48 ScrCmd_06C 2, 1 Return @@ -852,7 +852,7 @@ _09E0: End _0A3B: - ScrCmd_162 + ClearHasPartner ScrCmd_06D 2, 15 ApplyMovement 0xFF, _0A7C ApplyMovement 2, _0A68 @@ -1074,7 +1074,7 @@ _0CF1: ScrCmd_065 5 SetVar 0x4086, 3 ScrCmd_06C 254, 0 - ScrCmd_162 + ClearHasPartner SetFlag 0x172 SetFlag 0x195 SetVar 0x4082, 4 @@ -1296,8 +1296,8 @@ _0F4F: WaitABXPadPress CloseMessage SetVar 0x4086, 3 - ScrCmd_164 - ScrCmd_161 + SetStepFlag + SetHasPartner ScrCmd_06D 2, 48 ScrCmd_06C 2, 1 SetFlag 0x172 diff --git a/res/field/scripts/scripts_route_213.s b/res/field/scripts/scripts_route_213.s index ebf7e60dbd..447caebf26 100644 --- a/res/field/scripts/scripts_route_213.s +++ b/res/field/scripts/scripts_route_213.s @@ -17,7 +17,7 @@ _0022: End _002F: - CheckBadge BADGE_ID_FEN, 0x4000 + CheckBadgeAcquired BADGE_ID_FEN, 0x4000 GoToIfEq 0x4000, 1, _0044 End diff --git a/res/field/scripts/scripts_route_224.s b/res/field/scripts/scripts_route_224.s index 01627552b0..2b0a33ddea 100644 --- a/res/field/scripts/scripts_route_224.s +++ b/res/field/scripts/scripts_route_224.s @@ -13,7 +13,7 @@ _001A: CallIfEq 0x4057, 1, _00AA GoToIfSet 0x12D, _0080 - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _0080 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _0080 diff --git a/res/field/scripts/scripts_sandgem_town_pokemon_research_lab.s b/res/field/scripts/scripts_sandgem_town_pokemon_research_lab.s index 60b89a7a8b..8fdc314105 100644 --- a/res/field/scripts/scripts_sandgem_town_pokemon_research_lab.s +++ b/res/field/scripts/scripts_sandgem_town_pokemon_research_lab.s @@ -245,7 +245,7 @@ _0375: _0394: Message 12 - ScrCmd_158 + GivePokedex SetFlag 144 BufferPlayerName 0 Message 13 diff --git a/res/field/scripts/scripts_snowpoint_city_gym.s b/res/field/scripts/scripts_snowpoint_city_gym.s index a7898ec62b..0494317b24 100644 --- a/res/field/scripts/scripts_snowpoint_city_gym.s +++ b/res/field/scripts/scripts_snowpoint_city_gym.s @@ -20,7 +20,7 @@ _0025: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_ICICLE, 0x800C + CheckBadgeAcquired BADGE_ID_ICICLE, 0x800C GoToIfEq 0x800C, 1, _00F8 ScrCmd_1CD 9, 167, 0, 0, 0 Message 0 @@ -33,7 +33,7 @@ _0025: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 6 + GiveBadge BADGE_ID_ICICLE ScrCmd_260 23 SetTrainerFlag 0x10C SetTrainerFlag 0x10D @@ -84,7 +84,7 @@ _0114: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_ICICLE, 0x800C + CheckBadgeAcquired BADGE_ID_ICICLE, 0x800C GoToIfEq 0x800C, 1, _013A Message 6 WaitABXPadPress @@ -103,7 +103,7 @@ _013A: _0148: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_ICICLE, 0x800C + CheckBadgeAcquired BADGE_ID_ICICLE, 0x800C GoToIfEq 0x800C, 1, _0172 BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_snowpoint_city_pokecenter_1f.s b/res/field/scripts/scripts_snowpoint_city_pokecenter_1f.s index 515e2fcc80..1f52e8c8f6 100644 --- a/res/field/scripts/scripts_snowpoint_city_pokecenter_1f.s +++ b/res/field/scripts/scripts_snowpoint_city_pokecenter_1f.s @@ -51,7 +51,7 @@ _0067: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_ICICLE, 0x800C + CheckBadgeAcquired BADGE_ID_ICICLE, 0x800C GoToIfEq 0x800C, 1, _00EC ScrCmd_1BD 0x8000 CallIfEq 0x8000, 0, _00C8 diff --git a/res/field/scripts/scripts_solaceon_town.s b/res/field/scripts/scripts_solaceon_town.s index 23fc4b9409..88f36c5fb1 100644 --- a/res/field/scripts/scripts_solaceon_town.s +++ b/res/field/scripts/scripts_solaceon_town.s @@ -42,7 +42,7 @@ _0062: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_RELIC, 0x800C + CheckBadgeAcquired BADGE_ID_RELIC, 0x800C GoToIfEq 0x800C, 1, _0088 Message 4 WaitABXPadPress diff --git a/res/field/scripts/scripts_spear_pillar.s b/res/field/scripts/scripts_spear_pillar.s index e5ff6a6df5..5d7aed4a3d 100644 --- a/res/field/scripts/scripts_spear_pillar.s +++ b/res/field/scripts/scripts_spear_pillar.s @@ -30,7 +30,7 @@ _005A: End _0062: - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _00C5 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _00C5 diff --git a/res/field/scripts/scripts_spear_pillar_dialga.s b/res/field/scripts/scripts_spear_pillar_dialga.s index 67ae4a6b36..78ba1b9a56 100644 --- a/res/field/scripts/scripts_spear_pillar_dialga.s +++ b/res/field/scripts/scripts_spear_pillar_dialga.s @@ -11,7 +11,7 @@ _000A: End _0012: - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _0075 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _0075 diff --git a/res/field/scripts/scripts_spear_pillar_palkia.s b/res/field/scripts/scripts_spear_pillar_palkia.s index 041b27c6df..4cbe53c5af 100644 --- a/res/field/scripts/scripts_spear_pillar_palkia.s +++ b/res/field/scripts/scripts_spear_pillar_palkia.s @@ -11,7 +11,7 @@ _000A: End _0012: - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _0075 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _0075 diff --git a/res/field/scripts/scripts_stark_mountain_room_2.s b/res/field/scripts/scripts_stark_mountain_room_2.s index 5784fa2422..ce818feac0 100644 --- a/res/field/scripts/scripts_stark_mountain_room_2.s +++ b/res/field/scripts/scripts_stark_mountain_room_2.s @@ -33,7 +33,7 @@ _0031: WaitABXPadPress CloseMessage SetVar 0x403F, 0x263 - ScrCmd_161 + SetHasPartner ScrCmd_06D 14, 48 ReleaseAll End @@ -101,7 +101,7 @@ _00FC: Message 4 CloseMessage SetVar 0x4094, 0 - ScrCmd_162 + ClearHasPartner ScrCmd_06D 14, 15 ApplyMovement 14, _013C WaitMovement @@ -130,7 +130,7 @@ _014C: _0154: LockAll - ScrCmd_162 + ClearHasPartner ScrCmd_06D 14, 15 ScrCmd_1BD 0x800C GoToIfEq 0x800C, 0, _0177 diff --git a/res/field/scripts/scripts_stark_mountain_room_3.s b/res/field/scripts/scripts_stark_mountain_room_3.s index a29016dfd5..d03ef1e320 100644 --- a/res/field/scripts/scripts_stark_mountain_room_3.s +++ b/res/field/scripts/scripts_stark_mountain_room_3.s @@ -21,7 +21,7 @@ _0031: _0037: GoToIfSet 0x120, _0083 - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _0083 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _0083 diff --git a/res/field/scripts/scripts_sunyshore_city.s b/res/field/scripts/scripts_sunyshore_city.s index 4e488d3ab0..6b08158bcf 100644 --- a/res/field/scripts/scripts_sunyshore_city.s +++ b/res/field/scripts/scripts_sunyshore_city.s @@ -417,7 +417,7 @@ _0530: FacePlayer GoToIfSet 154, _056C Message 8 - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 0, _0561 GoTo _056C End diff --git a/res/field/scripts/scripts_sunyshore_city_gym_room_1.s b/res/field/scripts/scripts_sunyshore_city_gym_room_1.s index e6ef72e47c..b43419f3ff 100644 --- a/res/field/scripts/scripts_sunyshore_city_gym_room_1.s +++ b/res/field/scripts/scripts_sunyshore_city_gym_room_1.s @@ -21,7 +21,7 @@ _0022: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 1, _0048 Message 0 WaitABXPadPress @@ -40,7 +40,7 @@ _0048: _0056: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 1, _007A Message 2 WaitABXPadPress diff --git a/res/field/scripts/scripts_sunyshore_city_gym_room_3.s b/res/field/scripts/scripts_sunyshore_city_gym_room_3.s index cf524c84db..4a6efd55f6 100644 --- a/res/field/scripts/scripts_sunyshore_city_gym_room_3.s +++ b/res/field/scripts/scripts_sunyshore_city_gym_room_3.s @@ -25,7 +25,7 @@ _0027: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 1, _0104 ScrCmd_1CD 9, 156, 0, 0, 0 Message 0 @@ -38,7 +38,7 @@ _0027: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 7 + GiveBadge BADGE_ID_BEACON ScrCmd_260 23 SetTrainerFlag 0x119 SetTrainerFlag 0x11D diff --git a/res/field/scripts/scripts_sunyshore_city_pokecenter_1f.s b/res/field/scripts/scripts_sunyshore_city_pokecenter_1f.s index bc6969b9bc..51e9be0e59 100644 --- a/res/field/scripts/scripts_sunyshore_city_pokecenter_1f.s +++ b/res/field/scripts/scripts_sunyshore_city_pokecenter_1f.s @@ -27,7 +27,7 @@ _0031: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 1, _0057 Message 1 WaitABXPadPress diff --git a/res/field/scripts/scripts_twinleaf_town_player_house_1f.s b/res/field/scripts/scripts_twinleaf_town_player_house_1f.s index c08699dba1..04d9af18b5 100644 --- a/res/field/scripts/scripts_twinleaf_town_player_house_1f.s +++ b/res/field/scripts/scripts_twinleaf_town_player_house_1f.s @@ -129,7 +129,7 @@ _017C: WaitTime 30, 0x800C BufferPlayerName 0 Message 7 - ScrCmd_15A + GiveRunningShoes BufferPlayerName 0 Message 8 PlaySound SEQ_FANFA4 @@ -269,7 +269,7 @@ _036C: SetVar 0x8004, 0x1B1 SetVar 0x8005, 1 CallCommonScript 0x7FC - ScrCmd_1CC + GiveJournal Message 16 ScrCmd_1BD 0x8007 GoToIfEq 0x8007, 1, _03A6 diff --git a/res/field/scripts/scripts_unk_0211.s b/res/field/scripts/scripts_unk_0211.s index 89a3f2a744..2c94c115b9 100644 --- a/res/field/scripts/scripts_unk_0211.s +++ b/res/field/scripts/scripts_unk_0211.s @@ -1205,7 +1205,7 @@ _103A: Message 43 Call _10C7 Call _01C1 - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 1, _10A2 Message 44 ApplyMovement 0xFF, _02F4 @@ -1563,7 +1563,7 @@ _14AC: GetPlayerMapPos 0x8004, 0x8005 GoToIfNe 0x8004, 31, _1570 GoToIfNe 0x8005, 52, _1570 - ScrCmd_166 0x4000 + CheckGameCompleted 0x4000 GoToIfEq 0x4000, 0, _1570 ScrCmd_22D 2, 0x4000 GoToIfEq 0x4000, 0, _1570 diff --git a/res/field/scripts/scripts_unk_0212.s b/res/field/scripts/scripts_unk_0212.s index 8a25020b55..18db192ca0 100644 --- a/res/field/scripts/scripts_unk_0212.s +++ b/res/field/scripts/scripts_unk_0212.s @@ -117,7 +117,7 @@ _0148: _014A: CallIfEq 0x40CC, 0, _0168 GoToIfEq 0x40CC, 0, _0166 - ScrCmd_265 + HidePoketch _0166: End @@ -131,7 +131,7 @@ _0168: Return _0184: - ScrCmd_266 + ShowPoketch Call _01B1 Call _0168 ScrCmd_238 7, 0x4000 diff --git a/res/field/scripts/scripts_unk_0409.s b/res/field/scripts/scripts_unk_0409.s index c2f6788c34..9b9627e509 100644 --- a/res/field/scripts/scripts_unk_0409.s +++ b/res/field/scripts/scripts_unk_0409.s @@ -26,7 +26,7 @@ _0042: FacePlayer ScrCmd_09A 0x800C, 15 GoToIfEq 0x800C, 6, _008E - CheckBadge BADGE_ID_FOREST, 0x800C + CheckBadgeAcquired BADGE_ID_FOREST, 0x800C GoToIfEq 0x800C, 0, _008E Message 0 ScrCmd_03E 0x800C @@ -131,7 +131,7 @@ _0223: ScrCmd_09A 0x800C, 249 SetVar 0x8004, 0x800C GoToIfEq 0x800C, 6, _0275 - CheckBadge BADGE_ID_COAL, 0x800C + CheckBadgeAcquired BADGE_ID_COAL, 0x800C GoToIfEq 0x800C, 0, _0275 Message 3 ScrCmd_03E 0x800C @@ -184,11 +184,11 @@ _0314: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - ScrCmd_1CF 2, 0x800C + Strength 2, 0x800C GoToIfEq 0x800C, 1, _03BD ScrCmd_09A 0x800C, 70 GoToIfEq 0x800C, 6, _0372 - CheckBadge BADGE_ID_MINE, 0x800C + CheckBadgeAcquired BADGE_ID_MINE, 0x800C GoToIfEq 0x800C, 0, _0372 Message 6 ScrCmd_03E 0x800C @@ -205,7 +205,7 @@ _0372: End _0381: - ScrCmd_1CF 1 + Strength 1 ScrCmd_09A 0x800C, 70 SetVar 0x8004, 0x800C BufferPartyMonNickname 0, 0x800C @@ -229,9 +229,9 @@ _03BD: _03CC: LockAll - ScrCmd_1CF 2, 0x800C + Strength 2, 0x800C GoToIfEq 0x800C, 1, _03BD - ScrCmd_1CF 1 + Strength 1 BufferPartyMonNickname 0, 0x8000 Message 10 CloseMessage @@ -248,9 +248,9 @@ _040E: LockAll ScrCmd_09A 0x800C, 0x1AF GoToIfEq 0x800C, 6, _0469 - CheckBadge BADGE_ID_ICICLE, 0x800C + CheckBadgeAcquired BADGE_ID_ICICLE, 0x800C GoToIfEq 0x800C, 0, _0469 - ScrCmd_160 0x800C + CheckHasPartner 0x800C GoToIfEq 0x800C, 1, _0478 Message 18 ScrCmd_03E 0x800C @@ -299,7 +299,7 @@ _04B9: _04DD: PlayFanfare SEQ_SE_CONFIRM LockAll - ScrCmd_160 0x800C + CheckHasPartner 0x800C GoToIfEq 0x800C, 1, _0512 Message 12 ScrCmd_03E 0x800C @@ -382,7 +382,7 @@ _060C: Message 16 CloseMessage ScrCmd_0C5 0x8000 - ScrCmd_1D1 1 + Defog 1 PlayFanfare SEQ_SE_DP_FBRADE ScrCmd_0C4 ScrCmd_201 0x8004 @@ -397,7 +397,7 @@ _064C: Message 26 CloseMessage ScrCmd_0C5 0x8000 - ScrCmd_1D0 1 + Flash 1 ScrCmd_0C3 WaitTime 42, 0x800C GoTo _0675 @@ -419,7 +419,7 @@ _0679: LockAll ScrCmd_09A 0x800C, 127 GoToIfEq 0x800C, 6, _06C3 - CheckBadge BADGE_ID_BEACON, 0x800C + CheckBadgeAcquired BADGE_ID_BEACON, 0x800C GoToIfEq 0x800C, 0, _06C3 Message 22 ScrCmd_03E 0x800C diff --git a/res/field/scripts/scripts_veilstone_city.s b/res/field/scripts/scripts_veilstone_city.s index 65eb7b6b94..471158f43e 100644 --- a/res/field/scripts/scripts_veilstone_city.s +++ b/res/field/scripts/scripts_veilstone_city.s @@ -1173,7 +1173,7 @@ _0D5C: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COBBLE, 0x800C + CheckBadgeAcquired BADGE_ID_COBBLE, 0x800C GoToIfEq 0x800C, 1, _0D82 Message 12 WaitABXPadPress @@ -1192,7 +1192,7 @@ _0D8D: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COBBLE, 0x800C + CheckBadgeAcquired BADGE_ID_COBBLE, 0x800C GoToIfEq 0x800C, 1, _0DB3 Message 13 WaitABXPadPress diff --git a/res/field/scripts/scripts_veilstone_city_gym.s b/res/field/scripts/scripts_veilstone_city_gym.s index 87bf3c7a8f..797f4cbae9 100644 --- a/res/field/scripts/scripts_veilstone_city_gym.s +++ b/res/field/scripts/scripts_veilstone_city_gym.s @@ -19,7 +19,7 @@ _0022: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COBBLE, 0x800C + CheckBadgeAcquired BADGE_ID_COBBLE, 0x800C GoToIfEq 0x800C, 1, _00FF ScrCmd_1CD 9, 133, 0, 0, 0 Message 0 @@ -32,7 +32,7 @@ _0022: Message 2 PlaySound SEQ_BADGE WaitSound - ScrCmd_15C 2 + GiveBadge BADGE_ID_COBBLE ScrCmd_260 23 SetTrainerFlag 0x135 SetTrainerFlag 0x136 @@ -86,7 +86,7 @@ _011E: PlayFanfare SEQ_SE_CONFIRM LockAll FacePlayer - CheckBadge BADGE_ID_COBBLE, 0x800C + CheckBadgeAcquired BADGE_ID_COBBLE, 0x800C GoToIfEq 0x800C, 1, _0144 Message 6 WaitABXPadPress @@ -105,7 +105,7 @@ _0144: _0152: PlayFanfare SEQ_SE_CONFIRM LockAll - CheckBadge BADGE_ID_COBBLE, 0x800C + CheckBadgeAcquired BADGE_ID_COBBLE, 0x800C GoToIfEq 0x800C, 1, _017C BufferRivalName 0 BufferRivalName 1 diff --git a/res/field/scripts/scripts_victory_road_1f_room_2.s b/res/field/scripts/scripts_victory_road_1f_room_2.s index 9f15891bf4..64b008f663 100644 --- a/res/field/scripts/scripts_victory_road_1f_room_2.s +++ b/res/field/scripts/scripts_victory_road_1f_room_2.s @@ -74,7 +74,7 @@ _00EC: WaitABXPadPress CloseMessage SetVar 0x403F, 0x262 - ScrCmd_161 + SetHasPartner ScrCmd_06D 28, 48 ReleaseAll End @@ -136,7 +136,7 @@ _0190: Message 4 CloseMessage SetVar 0x4090, 0 - ScrCmd_162 + ClearHasPartner ScrCmd_06D 28, 14 GetPlayerMapPos 0x8004, 0x8005 GoToIfEq 0x8005, 55, _020D @@ -242,7 +242,7 @@ _02DC: _02E4: LockAll - ScrCmd_162 + ClearHasPartner ScrCmd_06D 28, 14 ApplyMovement 0xFF, _03B4 ApplyMovement 28, _03E0 diff --git a/res/field/scripts/scripts_wayward_cave_1f.s b/res/field/scripts/scripts_wayward_cave_1f.s index a15a8a16f9..810ac9aa4c 100644 --- a/res/field/scripts/scripts_wayward_cave_1f.s +++ b/res/field/scripts/scripts_wayward_cave_1f.s @@ -36,7 +36,7 @@ _002B: WaitABXPadPress CloseMessage SetVar 0x403F, 0x264 - ScrCmd_161 + SetHasPartner ScrCmd_06D 4, 48 ReleaseAll End @@ -80,7 +80,7 @@ _00E0: _00E2: LockAll - ScrCmd_162 + ClearHasPartner ScrCmd_06D 4, 16 ScrCmd_1BD 0x800C GoToIfEq 0x800C, 2, _0103 diff --git a/src/unk_02050A74.c b/src/encounter.c similarity index 85% rename from src/unk_02050A74.c rename to src/encounter.c index aea173c69f..f1ced3000f 100644 --- a/src/unk_02050A74.c +++ b/src/encounter.c @@ -1,4 +1,4 @@ -#include "unk_02050A74.h" +#include "encounter.h" #include #include @@ -7,7 +7,6 @@ #include "consts/game_records.h" #include "struct_decls/struct_0202440C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_020797DC_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202610C.h" @@ -25,6 +24,7 @@ #include "field_comm_manager.h" #include "field_map_change.h" #include "field_overworld_state.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "journal.h" @@ -35,18 +35,17 @@ #include "pokeradar.h" #include "save_player.h" #include "script_manager.h" +#include "system_flags.h" #include "trainer_data.h" #include "unk_020041CC.h" #include "unk_02026150.h" #include "unk_0202F1D4.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02051D8C.h" #include "unk_020528D0.h" #include "unk_0205578C.h" #include "unk_02055808.h" #include "unk_020562F8.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "unk_020797C8.h" @@ -72,13 +71,13 @@ typedef struct { static void sub_020518B0(FieldSystem *fieldSystem, BattleParams *param1); static void sub_02051988(FieldSystem *fieldSystem, BattleParams *param1); -static BOOL sub_02050EE0(TaskManager *taskMan); -static BOOL sub_02051074(TaskManager *taskMan); +static BOOL sub_02050EE0(FieldTask *taskMan); +static BOOL sub_02051074(FieldTask *taskMan); -static BOOL sub_02050A74(TaskManager *taskMan) +static BOOL sub_02050A74(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - BattleParams *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + BattleParams *v1 = FieldTask_GetEnv(taskMan); int *v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -87,7 +86,7 @@ static BOOL sub_02050A74(TaskManager *taskMan) (*v2)++; break; case 1: - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { break; } @@ -97,9 +96,9 @@ static BOOL sub_02050A74(TaskManager *taskMan) return 0; } -void sub_02050ABC(TaskManager *taskMan, BattleParams *param1) +void sub_02050ABC(FieldTask *taskMan, BattleParams *param1) { - FieldTask_Start(taskMan, sub_02050A74, param1); + FieldTask_InitCall(taskMan, sub_02050A74, param1); } static UnkStruct_02050ACC *sub_02050ACC(BattleParams *param0, int param1, int param2, int *param3) @@ -147,14 +146,14 @@ static void sub_02050B1C(const BattleParams *param0, FieldSystem *fieldSystem) sub_020526E8(param0, fieldSystem); } -static BOOL sub_02050B30(TaskManager *taskMan) +static BOOL sub_02050B30(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050ACC *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -185,7 +184,7 @@ static BOOL sub_02050B30(TaskManager *taskMan) return 1; } - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData))) { HealAllPokemonInParty(Party_GetFromSavedata(fieldSystem->saveData)); } @@ -209,12 +208,12 @@ static BOOL sub_02050B30(TaskManager *taskMan) return 0; } -static void sub_02050C4C(TaskManager *taskMan, BattleParams *param1, int param2, int param3, int *param4) +static void sub_02050C4C(FieldTask *taskMan, BattleParams *param1, int param2, int param3, int *param4) { UnkStruct_02050ACC *v0; v0 = sub_02050ACC(param1, param2, param3, param4); - FieldTask_Start(taskMan, sub_02050B30, v0); + FieldTask_InitCall(taskMan, sub_02050B30, v0); } static void sub_02050C6C(int param0, FieldSystem *fieldSystem) @@ -231,14 +230,14 @@ static void sub_02050C6C(int param0, FieldSystem *fieldSystem) } } -static BOOL sub_02050CA8(TaskManager *taskMan) +static BOOL sub_02050CA8(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050ACC *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -276,14 +275,14 @@ static BOOL sub_02050CA8(TaskManager *taskMan) return 0; } -static BOOL sub_02050D4C(TaskManager *taskMan) +static BOOL sub_02050D4C(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050ACC *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -340,41 +339,41 @@ static void sub_02050DFC(UnkStruct_02050DD4 *param0) void sub_02050E10(FieldSystem *fieldSystem, BattleParams *param1) { - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData))) { UnkStruct_02050ACC *v0; v0 = sub_02050ACC(param1, EncEffects_CutInEffect(param1), EncEffects_BGM(param1), NULL); - FieldTask_Set(fieldSystem, sub_02051074, v0); + FieldSystem_CreateTask(fieldSystem, sub_02051074, v0); } else { UnkStruct_02050DD4 *v1; v1 = sub_02050DD4(param1, EncEffects_CutInEffect(param1), EncEffects_BGM(param1), NULL); - FieldTask_Set(fieldSystem, sub_02050EE0, v1); + FieldSystem_CreateTask(fieldSystem, sub_02050EE0, v1); } } -void sub_02050E78(FieldSystem *fieldSystem, TaskManager *param1, BattleParams *param2) +void sub_02050E78(FieldSystem *fieldSystem, FieldTask *param1, BattleParams *param2) { - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData))) { UnkStruct_02050ACC *v0; v0 = sub_02050ACC(param2, EncEffects_CutInEffect(param2), EncEffects_BGM(param2), NULL); - FieldTask_Change(param1, sub_02051074, v0); + FieldTask_InitJump(param1, sub_02051074, v0); } else { UnkStruct_02050DD4 *v1; v1 = sub_02050DD4(param2, EncEffects_CutInEffect(param2), EncEffects_BGM(param2), NULL); - FieldTask_Change(param1, sub_02050EE0, v1); + FieldTask_InitJump(param1, sub_02050EE0, v1); } } -static BOOL sub_02050EE0(TaskManager *taskMan) +static BOOL sub_02050EE0(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050DD4 *v1; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_00) { case 0: @@ -398,11 +397,11 @@ static BOOL sub_02050EE0(TaskManager *taskMan) if (BattleParams_PlayerWon(v1->unk_10->unk_14) == 0) { sub_02050DFC(v1); RadarChain_Clear(fieldSystem->chain); - FieldTask_Change(taskMan, sub_02052B2C, NULL); + FieldTask_InitJump(taskMan, sub_02052B2C, NULL); return 0; } - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData))) { HealAllPokemonInParty(Party_GetFromSavedata(fieldSystem->saveData)); } @@ -447,15 +446,15 @@ static BOOL sub_02050EE0(TaskManager *taskMan) return 0; } -static BOOL sub_02051074(TaskManager *taskMan) +static BOOL sub_02051074(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050ACC *v1; int *v2; u16 *v3; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); v2 = FieldTask_GetState(taskMan); v3 = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); @@ -532,13 +531,13 @@ static BOOL sub_02051074(TaskManager *taskMan) return 0; } -void sub_0205120C(TaskManager *taskMan, int *param1) +void sub_0205120C(FieldTask *taskMan, int *param1) { UnkStruct_02050ACC *v0; BattleParams *v1; FieldSystem *fieldSystem; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); RadarChain_Clear(fieldSystem->chain); v1 = sub_02051D8C(11, (0x0 | 0x0)); @@ -553,13 +552,13 @@ void sub_0205120C(TaskManager *taskMan, int *param1) sub_02050C4C(taskMan, v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), param1); } -void sub_02051270(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) +void sub_02051270(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) { UnkStruct_02050ACC *v0; BattleParams *v1; FieldSystem *fieldSystem; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); RadarChain_Clear(fieldSystem->chain); v1 = sub_02051D8C(11, (0x0 | 0x0)); @@ -575,7 +574,7 @@ void sub_02051270(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL sub_02050C4C(taskMan, v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), param3); } -void sub_020512E4(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) +void sub_020512E4(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) { UnkStruct_02050ACC *v0; BattleParams *v1; @@ -583,7 +582,7 @@ void sub_020512E4(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL Pokemon *v3; int v4; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); RadarChain_Clear(fieldSystem->chain); v1 = sub_02051D8C(11, (0x0 | 0x0)); @@ -604,14 +603,14 @@ void sub_020512E4(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL sub_02050C4C(taskMan, v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), param3); } -static BOOL sub_0205136C(TaskManager *taskMan) +static BOOL sub_0205136C(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02050ACC *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -664,16 +663,16 @@ void sub_02051450(FieldSystem *fieldSystem, BattleParams *param1) UnkStruct_02050ACC *v0; v0 = sub_02050ACC(param1, EncEffects_CutInEffect(param1), EncEffects_BGM(param1), NULL); - FieldTask_Set(fieldSystem, sub_0205136C, v0); + FieldSystem_CreateTask(fieldSystem, sub_0205136C, v0); } -void sub_02051480(TaskManager *taskMan, int param1, int param2, int *param3) +void sub_02051480(FieldTask *taskMan, int param1, int param2, int *param3) { UnkStruct_02050ACC *v0; BattleParams *v1; FieldSystem *fieldSystem; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); v1 = sub_02051D8C(11, 0x1); sub_02052314(v1, fieldSystem); @@ -688,10 +687,10 @@ void sub_02051480(TaskManager *taskMan, int param1, int param2, int *param3) sub_02050C4C(taskMan, v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), param3); } -static BOOL sub_020514E8(TaskManager *taskMan) +static BOOL sub_020514E8(FieldTask *taskMan) { - UnkStruct_02050ACC *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_02050ACC *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); int *v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -729,26 +728,26 @@ static BOOL sub_020514E8(TaskManager *taskMan) return 0; } -void sub_02051590(TaskManager *taskMan) +void sub_02051590(FieldTask *taskMan) { UnkStruct_02050ACC *v0; BattleParams *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); v1 = sub_02051F4C(11, fieldSystem); v0 = sub_02050ACC(v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), NULL); - FieldTask_Start(taskMan, sub_020514E8, v0); + FieldTask_InitCall(taskMan, sub_020514E8, v0); } -void sub_020515CC(TaskManager *taskMan, int param1, int param2, int param3, int param4, int *param5) +void sub_020515CC(FieldTask *taskMan, int param1, int param2, int param3, int param4, int *param5) { u32 v0; UnkStruct_02050ACC *v1; BattleParams *v2; FieldSystem *fieldSystem; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); if ((param2 != 0) && (param1 != param2)) { if (param3 == 0) { @@ -779,9 +778,9 @@ void sub_020515CC(TaskManager *taskMan, int param1, int param2, int param3, int sub_02050C4C(taskMan, v2, EncEffects_CutInEffect(v2), EncEffects_BGM(v2), param5); } -void sub_0205167C(TaskManager *taskMan, const u8 *param1, int param2) +void sub_0205167C(FieldTask *taskMan, const u8 *param1, int param2) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); UnkStruct_02050ACC *v1; BattleParams *v2; @@ -789,7 +788,7 @@ void sub_0205167C(TaskManager *taskMan, const u8 *param1, int param2) sub_020526CC(v2, fieldSystem, param1); v1 = sub_02050ACC(v2, EncEffects_CutInEffect(v2), EncEffects_BGM(v2), NULL); - FieldTask_Start(taskMan, sub_02050CA8, v1); + FieldTask_InitCall(taskMan, sub_02050CA8, v1); } static int sub_020516C8(const BattleRegulation *param0, int param1) @@ -813,9 +812,9 @@ static int sub_020516C8(const BattleRegulation *param0, int param1) return v0; } -void sub_020516F4(TaskManager *taskMan, int param1, int param2, int param3) +void sub_020516F4(FieldTask *taskMan, int param1, int param2, int param3) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); UnkStruct_02050ACC *v1; BattleParams *v2; int v3; @@ -849,18 +848,18 @@ void sub_020516F4(TaskManager *taskMan, int param1, int param2, int param3) v1 = sub_02050ACC(v2, EncEffects_CutInEffect(v2), EncEffects_BGM(v2), NULL); v1->unk_0C = param1; - FieldTask_Start(taskMan, sub_02050D4C, v1); + FieldTask_InitCall(taskMan, sub_02050D4C, v1); } -static BOOL sub_02051790(TaskManager *taskMan) +static BOOL sub_02051790(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02050ACC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02050ACC *v1 = FieldTask_GetEnv(taskMan); int *v2 = FieldTask_GetState(taskMan); switch (*v2) { case 0: - FieldTask_Start(taskMan, sub_02050CA8, v1); + FieldTask_InitCall(taskMan, sub_02050CA8, v1); (*v2)++; break; case 1: @@ -889,7 +888,7 @@ void sub_020517E8(FieldSystem *fieldSystem, const u8 *param1, int param2) v1->unk_18A = sub_020516C8(fieldSystem->unk_B0, param2); v0 = sub_02050ACC(v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), NULL); - FieldTask_Set(fieldSystem, sub_02051790, v0); + FieldSystem_CreateTask(fieldSystem, sub_02051790, v0); } void sub_0205184C(FieldSystem *fieldSystem, const Party *param1, int param2) @@ -906,7 +905,7 @@ void sub_0205184C(FieldSystem *fieldSystem, const Party *param1, int param2) v1->unk_18A = sub_020516C8(fieldSystem->unk_B0, param2); v0 = sub_02050ACC(v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), NULL); - FieldTask_Set(fieldSystem, sub_02051790, v0); + FieldSystem_CreateTask(fieldSystem, sub_02051790, v0); } static void sub_020518B0(FieldSystem *fieldSystem, BattleParams *param1) @@ -1002,13 +1001,13 @@ static void sub_02051988(FieldSystem *fieldSystem, BattleParams *param1) } } -void sub_02051ABC(TaskManager *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) +void sub_02051ABC(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL param4) { UnkStruct_02050ACC *v0; BattleParams *v1; FieldSystem *fieldSystem; - fieldSystem = TaskManager_FieldSystem(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); RadarChain_Clear(fieldSystem->chain); v1 = sub_02051D8C(11, (0x0 | 0x0)); diff --git a/src/field_comm_manager.c b/src/field_comm_manager.c index 316bcbade8..ccb8eec33c 100644 --- a/src/field_comm_manager.c +++ b/src/field_comm_manager.c @@ -18,6 +18,7 @@ #include "comm_player_manager.h" #include "communication_information.h" #include "communication_system.h" +#include "encounter.h" #include "field_system.h" #include "heap.h" #include "party.h" @@ -30,7 +31,6 @@ #include "unk_02033200.h" #include "unk_020363E8.h" #include "unk_020366A0.h" -#include "unk_02050A74.h" #include "unk_0205A0D8.h" #include "unk_02071D40.h" #include "unk_02099500.h" @@ -403,7 +403,7 @@ static void sub_02059B74(void) for (v0 = 0; v0 < CommSys_ConnectedCount(); v0++) { if (v0 != CommSys_CurNetId()) { if (sub_02036564(v0) == 94) { - if (sFieldCommMan->fieldSystem->taskManager == NULL) { + if (sFieldCommMan->fieldSystem->task == NULL) { for (v1 = 0; v1 < 4; v1++) { if (sFieldCommMan->trainerCard[v1]) { Heap_FreeToHeap(sFieldCommMan->trainerCard[v1]); diff --git a/src/field_map_change.c b/src/field_map_change.c index ef6904b753..3afc4cd8e1 100644 --- a/src/field_map_change.c +++ b/src/field_map_change.c @@ -8,12 +8,10 @@ #include "consts/map.h" #include "struct_decls/struct_0203A790_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/map_load_mode.h" #include "struct_defs/struct_0205EC34.h" #include "field/field_system.h" -#include "functypes/funcptr_02050904.h" #include "overlay005/ov5_021DD6FC.h" #include "overlay005/ov5_021E135C.h" #include "overlay005/save_info_window.h" @@ -29,6 +27,7 @@ #include "core_sys.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "game_overlay.h" #include "heap.h" #include "inlines.h" @@ -48,6 +47,7 @@ #include "script_manager.h" #include "strbuf.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_020041CC.h" #include "unk_02005474.h" @@ -59,7 +59,6 @@ #include "unk_0203A7D8.h" #include "unk_0203A944.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02054BD0.h" #include "unk_02054D00.h" #include "unk_020553DC.h" @@ -69,7 +68,6 @@ #include "unk_0205C22C.h" #include "unk_0205CA94.h" #include "unk_0205D8CC.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_02070428.h" #include "vars_flags.h" @@ -134,28 +132,28 @@ typedef struct MapChangeUnionData { Location location; } MapChangeUnionData; -static BOOL FieldTask_ChangeMap(TaskManager *taskMan); -static BOOL FieldTask_LoadNewGameSpawn(TaskManager *taskMan); +static BOOL FieldTask_ChangeMap(FieldTask *taskMan); +static BOOL FieldTask_LoadNewGameSpawn(FieldTask *taskMan); static void FieldMapChange_SetNewLocation(FieldSystem *fieldSystem, const Location *param1); static void FieldMapChange_InitTerrainCollisionManager(FieldSystem *fieldSystem); static void FieldMapChange_RemoveTerrainCollisionManager(FieldSystem *fieldSystem); static void FieldMapChange_CreatePlayerObject(FieldSystem *fieldSystem); static void sub_02053374(FieldSystem *fieldSystem); static void sub_020534BC(FieldSystem *fieldSystem); -static BOOL FieldTask_MapChangeFly(TaskManager *taskMan); -static void FieldTask_FinishFly(TaskManager *taskMan); -static BOOL FieldTask_FinishFieldMapFly(TaskManager *taskMan); -static void FieldTask_StartFadeInFly(TaskManager *taskMan); -static BOOL FieldTask_StartFadeInFlySub(TaskManager *taskMan); -static void FieldTask_FadeInFly(TaskManager *taskMan); -static BOOL FieldTask_WaitFadeInFly(TaskManager *taskMan); -static BOOL FieldTask_MapChangeByDig(TaskManager *taskMan); -static void FieldTask_StartFinishFieldMapDig(TaskManager *taskMan); -static BOOL FieldTask_FinishFieldMapDig(TaskManager *taskMan); -static void FieldTask_StartFadeInDig(TaskManager *taskMan); -static BOOL FieldTask_FadeInDig(TaskManager *taskMan); -static void sub_02053E5C(TaskManager *taskMan); -static BOOL sub_0205444C(TaskManager *taskMan, int param1); +static BOOL FieldTask_MapChangeFly(FieldTask *taskMan); +static void FieldTask_FinishFly(FieldTask *taskMan); +static BOOL FieldTask_FinishFieldMapFly(FieldTask *taskMan); +static void FieldTask_StartFadeInFly(FieldTask *taskMan); +static BOOL FieldTask_StartFadeInFlySub(FieldTask *taskMan); +static void FieldTask_FadeInFly(FieldTask *taskMan); +static BOOL FieldTask_WaitFadeInFly(FieldTask *taskMan); +static BOOL FieldTask_MapChangeByDig(FieldTask *taskMan); +static void FieldTask_StartFinishFieldMapDig(FieldTask *taskMan); +static BOOL FieldTask_FinishFieldMapDig(FieldTask *taskMan); +static void FieldTask_StartFadeInDig(FieldTask *taskMan); +static BOOL FieldTask_FadeInDig(FieldTask *taskMan); +static void sub_02053E5C(FieldTask *taskMan); +static BOOL sub_0205444C(FieldTask *taskMan, int param1); static const MapLoadMode sMapLoadMode[] = { { 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xC4000 }, @@ -263,7 +261,8 @@ void FieldMapChange_UpdateGameData(FieldSystem *fieldSystem, BOOL noWarp) VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); u16 weather = FieldSystem_GetWeather(fieldSystem, mapId); - if ((weather == OVERWORLD_WEATHER_FOG && Overworld_IsDefogActive(varsFlags) == TRUE) || (weather == OVERWORLD_WEATHER_DARK_FLASH && Overworld_IsFlashActive(varsFlags) == TRUE)) { + if ((weather == OVERWORLD_WEATHER_FOG && SystemFlag_CheckDefogActive(varsFlags) == TRUE) + || (weather == OVERWORLD_WEATHER_DARK_FLASH && SystemFlag_CheckFlashActive(varsFlags) == TRUE)) { weather = OVERWORLD_WEATHER_CLEAR; } @@ -446,9 +445,9 @@ static void FieldSystem_SetLocationToUnionRoomExit(FieldSystem *fieldSystem) Location_Set(exit, fieldSystem->location->mapId, -1, 8, 2, 1); } -static BOOL FieldTask_LoadNewGameSpawn(TaskManager *taskMan) +static BOOL FieldTask_LoadNewGameSpawn(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); int *state = FieldTask_GetState(taskMan); switch (*state) { @@ -474,12 +473,17 @@ void FieldSystem_SetLoadNewGameSpawnTask(FieldSystem *fieldSystem) { fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; FieldSystem_InitNewGameState(fieldSystem); - FieldTask_Set(fieldSystem, FieldTask_LoadNewGameSpawn, NULL); + FieldSystem_CreateTask(fieldSystem, FieldTask_LoadNewGameSpawn, NULL); } -static BOOL FieldTask_LoadSavedGameMap(TaskManager *taskMan) +static inline BOOL CheckJournalAcquired(VarsFlags *varsFlags) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + return SystemFlag_HandleJournalAcquired(varsFlags, HANDLE_FLAG_CHECK); +} + +static BOOL FieldTask_LoadSavedGameMap(FieldTask *taskMan) +{ + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); int *state = FieldTask_GetState(taskMan); @@ -487,22 +491,22 @@ static BOOL FieldTask_LoadSavedGameMap(TaskManager *taskMan) case 0: SaveData_LoadAndUpdateUnderground(fieldSystem->saveData); - if (Journal_CheckOpenOnContinue(SaveData_GetJournal(fieldSystem->saveData), inline_020535E8(varsFlags))) { + if (Journal_CheckOpenOnContinue(SaveData_GetJournal(fieldSystem->saveData), CheckJournalAcquired(varsFlags))) { sub_0203D30C(fieldSystem, NULL); (*state) = 4; break; } case 1: - fieldSystem->journal = Journal_GetSavedPage(SaveData_GetJournal(fieldSystem->saveData), inline_020535E8(varsFlags)); + fieldSystem->journal = Journal_GetSavedPage(SaveData_GetJournal(fieldSystem->saveData), CheckJournalAcquired(varsFlags)); - if (CommClub_IsAvailable(varsFlags)) { + if (SystemFlag_CheckCommunicationClubAccessible(varsFlags)) { FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); if (FieldSystem_IsSaveInUnionRoom(fieldSystem)) { FieldSystem_SetLocationToUnionRoomExit(fieldSystem); } - CommClub_ResetAvailable(varsFlags); + SystemFlag_ClearCommunicationClubAccessible(varsFlags); FieldMapChange_SetNewLocation(fieldSystem, FieldOverworldState_GetSpecialLocation(fieldState)); FieldMapChange_InitTerrainCollisionManager(fieldSystem); FieldMapChange_UpdateGameData(fieldSystem, 0); @@ -525,7 +529,7 @@ static BOOL FieldTask_LoadSavedGameMap(TaskManager *taskMan) case 3: return TRUE; case 4: - if (!(sub_020509B4(fieldSystem))) { + if (!(FieldSystem_IsRunningApplication(fieldSystem))) { (*state) = 1; } break; @@ -537,13 +541,13 @@ static BOOL FieldTask_LoadSavedGameMap(TaskManager *taskMan) void FieldSystem_SetLoadSavedGameMapTask(FieldSystem *fieldSystem) { fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; - FieldTask_Set(fieldSystem, FieldTask_LoadSavedGameMap, NULL); + FieldSystem_CreateTask(fieldSystem, FieldTask_LoadSavedGameMap, NULL); } -static BOOL FieldTask_LoadMapFromError(TaskManager *taskMan) +static BOOL FieldTask_LoadMapFromError(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeFromErrorData *errorData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeFromErrorData *errorData = FieldTask_GetEnv(taskMan); VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); int *state = FieldTask_GetState(taskMan); @@ -552,7 +556,7 @@ static BOOL FieldTask_LoadMapFromError(TaskManager *taskMan) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); SaveData_LoadAndUpdateUnderground(fieldSystem->saveData); - fieldSystem->journal = Journal_GetSavedPage(SaveData_GetJournal(fieldSystem->saveData), inline_020535E8(varsFlags)); + fieldSystem->journal = Journal_GetSavedPage(SaveData_GetJournal(fieldSystem->saveData), CheckJournalAcquired(varsFlags)); (*state)++; break; case 1: @@ -596,7 +600,7 @@ void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem) VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); FieldSystem_SetLocationToUnionRoomExit(fieldSystem); - sub_0206AD9C(varsFlags); + SystemFlag_SetCommunicationClubAccessible(varsFlags); } else { FieldSystem_SetLoadSavedGameMapTask(fieldSystem); return; @@ -608,13 +612,13 @@ void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem) Location_Set(&errorData->location, 466, -1, 8, 14, 0); fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNION; - FieldTask_Set(fieldSystem, FieldTask_LoadMapFromError, errorData); + FieldSystem_CreateTask(fieldSystem, FieldTask_LoadMapFromError, errorData); } -static BOOL FieldTask_ChangeMap(TaskManager *taskMan) +static BOOL FieldTask_ChangeMap(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeData *mapChangeData = FieldTask_GetEnv(taskMan); Location *location = &mapChangeData->nextLocation; switch (mapChangeData->state) { @@ -645,20 +649,20 @@ static BOOL FieldTask_ChangeMap(TaskManager *taskMan) return FALSE; } -void FieldSystem_StartChangeMapTask(TaskManager *taskMan, const Location *nextLocation) +void FieldSystem_StartChangeMapTask(FieldTask *taskMan, const Location *nextLocation) { MapChangeData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeData)); mapChangeData->state = 0; mapChangeData->nextLocation = *nextLocation; - FieldTask_Start(taskMan, FieldTask_ChangeMap, mapChangeData); + FieldTask_InitCall(taskMan, FieldTask_ChangeMap, mapChangeData); } -static BOOL FieldTask_ChangeMapSub(TaskManager *taskMan) +static BOOL FieldTask_ChangeMapSub(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeSubData *mapChangeSub = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); switch (mapChangeSub->state) { case 0: @@ -682,9 +686,9 @@ static BOOL FieldTask_ChangeMapSub(TaskManager *taskMan) return 0; } -void FieldTask_ChangeMapByLocation(TaskManager *taskMan, const Location *nextLocation) +void FieldTask_ChangeMapByLocation(FieldTask *taskMan, const Location *nextLocation) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); MapChangeSubData *mapChangeSub = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); if (FieldSystem_HasParentProcess(fieldSystem)) { @@ -695,10 +699,10 @@ void FieldTask_ChangeMapByLocation(TaskManager *taskMan, const Location *nextLoc mapChangeSub->state = 0; mapChangeSub->nextLocation = *nextLocation; - FieldTask_Start(taskMan, FieldTask_ChangeMapSub, mapChangeSub); + FieldTask_InitCall(taskMan, FieldTask_ChangeMapSub, mapChangeSub); } -void FieldTask_ChangeMapToLocation(TaskManager *taskMan, int param1, int param2, int param3, int param4, int param5) +void FieldTask_ChangeMapToLocation(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5) { Location location; @@ -706,10 +710,10 @@ void FieldTask_ChangeMapToLocation(TaskManager *taskMan, int param1, int param2, FieldTask_ChangeMapByLocation(taskMan, &location); } -static BOOL FieldTask_ChangeMapFull(TaskManager *taskMan) +static BOOL FieldTask_ChangeMapFull(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeSubData *mapChangeSub = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); Location *nextLocation = &mapChangeSub->nextLocation; switch (mapChangeSub->state) { @@ -739,14 +743,14 @@ static BOOL FieldTask_ChangeMapFull(TaskManager *taskMan) return FALSE; } -void FieldTask_StartMapChangeFull(TaskManager *taskMan, int mapId, int param2, int x, int z, int dir) +void FieldTask_StartMapChangeFull(FieldTask *taskMan, int mapId, int param2, int x, int z, int dir) { MapChangeSubData *mapChangeSub = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); mapChangeSub->state = 0; Location_Set(&mapChangeSub->nextLocation, mapId, param2, x, z, dir); - FieldTask_Start(taskMan, FieldTask_ChangeMapFull, mapChangeSub); + FieldTask_InitCall(taskMan, FieldTask_ChangeMapFull, mapChangeSub); } void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param2, int param3, int param4, int param5) @@ -761,10 +765,10 @@ void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param mapChangeData->task = NULL; mapChangeData->location = location; - FieldTask_Set(fieldSystem, FieldTask_MapChangeFly, mapChangeData); + FieldSystem_CreateTask(fieldSystem, FieldTask_MapChangeFly, mapChangeData); } -void FieldTask_ChangeMapChangeFly(TaskManager *taskMan, int param1, int param2, int param3, int param4, int param5) +void FieldTask_ChangeMapChangeFly(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5) { Location location; @@ -776,13 +780,13 @@ void FieldTask_ChangeMapChangeFly(TaskManager *taskMan, int param1, int param2, mapChangeData->task = NULL; mapChangeData->location = location; - FieldTask_Change(taskMan, FieldTask_MapChangeFly, mapChangeData); + FieldTask_InitJump(taskMan, FieldTask_MapChangeFly, mapChangeData); } -static BOOL FieldTask_MapChangeFly(TaskManager *taskMan) +static BOOL FieldTask_MapChangeFly(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeFlyData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); Location *location = &mapChangeData->location; switch (mapChangeData->state) { @@ -814,12 +818,12 @@ static BOOL FieldTask_MapChangeFly(TaskManager *taskMan) return 0; } -static void FieldTask_FinishFly(TaskManager *taskMan) +static void FieldTask_FinishFly(FieldTask *taskMan) { - FieldTask_Start(taskMan, FieldTask_FinishFieldMapFly, NULL); + FieldTask_InitCall(taskMan, FieldTask_FinishFieldMapFly, NULL); } -static BOOL FieldTask_FinishFieldMapFly(TaskManager *taskMan) +static BOOL FieldTask_FinishFieldMapFly(FieldTask *taskMan) { int *state = FieldTask_GetState(taskMan); @@ -835,16 +839,16 @@ static BOOL FieldTask_FinishFieldMapFly(TaskManager *taskMan) return FALSE; } -static void FieldTask_StartFadeInFly(TaskManager *taskMan) +static void FieldTask_StartFadeInFly(FieldTask *taskMan) { - MapChangeFlyData *mapChangeData = TaskManager_Environment(taskMan); - FieldTask_Start(taskMan, FieldTask_StartFadeInFlySub, mapChangeData); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldTask_InitCall(taskMan, FieldTask_StartFadeInFlySub, mapChangeData); } -static BOOL FieldTask_StartFadeInFlySub(TaskManager *taskMan) +static BOOL FieldTask_StartFadeInFlySub(FieldTask *taskMan) { int *state = FieldTask_GetState(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); switch (*state) { case 0: @@ -863,10 +867,10 @@ static BOOL FieldTask_StartFadeInFlySub(TaskManager *taskMan) return FALSE; } -static void FieldTask_FadeInFly(TaskManager *taskMan) +static void FieldTask_FadeInFly(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeFlyData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -874,12 +878,12 @@ static void FieldTask_FadeInFly(TaskManager *taskMan) } mapChangeData->task = FieldTask_InitFlyLandingTask(fieldSystem, PlayerAvatar_Gender(fieldSystem->playerAvatar)); - FieldTask_Start(taskMan, FieldTask_WaitFadeInFly, mapChangeData); + FieldTask_InitCall(taskMan, FieldTask_WaitFadeInFly, mapChangeData); } -static BOOL FieldTask_WaitFadeInFly(TaskManager *taskMan) +static BOOL FieldTask_WaitFadeInFly(FieldTask *taskMan) { - MapChangeFlyData *mapChangeData = TaskManager_Environment(taskMan); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); if (ov6_02245CF0(mapChangeData->task) == 1) { ov6_02245CFC(mapChangeData->task); @@ -889,7 +893,7 @@ static BOOL FieldTask_WaitFadeInFly(TaskManager *taskMan) return FALSE; } -void FieldTask_ChangeMapChangeByDig(TaskManager *taskMan, const Location *location, u32 param2) +void FieldTask_ChangeMapChangeByDig(FieldTask *taskMan, const Location *location, u32 param2) { MapChangeDigData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeDigData)); @@ -898,13 +902,13 @@ void FieldTask_ChangeMapChangeByDig(TaskManager *taskMan, const Location *locati mapChangeData->task = NULL; mapChangeData->location = *location; - FieldTask_Change(taskMan, FieldTask_MapChangeByDig, mapChangeData); + FieldTask_InitJump(taskMan, FieldTask_MapChangeByDig, mapChangeData); } -static BOOL FieldTask_MapChangeByDig(TaskManager *taskMan) +static BOOL FieldTask_MapChangeByDig(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeDigData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); Location *location = &mapChangeData->location; switch (mapChangeData->state) { @@ -944,12 +948,12 @@ static BOOL FieldTask_MapChangeByDig(TaskManager *taskMan) return FALSE; } -static void FieldTask_StartFinishFieldMapDig(TaskManager *taskMan) +static void FieldTask_StartFinishFieldMapDig(FieldTask *taskMan) { - FieldTask_Start(taskMan, FieldTask_FinishFieldMapDig, NULL); + FieldTask_InitCall(taskMan, FieldTask_FinishFieldMapDig, NULL); } -static BOOL FieldTask_FinishFieldMapDig(TaskManager *taskMan) +static BOOL FieldTask_FinishFieldMapDig(FieldTask *taskMan) { int *state = FieldTask_GetState(taskMan); @@ -965,17 +969,17 @@ static BOOL FieldTask_FinishFieldMapDig(TaskManager *taskMan) return FALSE; } -static void FieldTask_StartFadeInDig(TaskManager *taskMan) +static void FieldTask_StartFadeInDig(FieldTask *taskMan) { - MapChangeDigData *mapChangeData = TaskManager_Environment(taskMan); - FieldTask_Start(taskMan, FieldTask_FadeInDig, mapChangeData); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldTask_InitCall(taskMan, FieldTask_FadeInDig, mapChangeData); } -static BOOL FieldTask_FadeInDig(TaskManager *taskMan) +static BOOL FieldTask_FadeInDig(FieldTask *taskMan) { int *state = FieldTask_GetState(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeDigData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); switch (*state) { case 0: @@ -994,10 +998,10 @@ static BOOL FieldTask_FadeInDig(TaskManager *taskMan) return FALSE; } -static void sub_02053E5C(TaskManager *taskMan) +static void sub_02053E5C(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeDigData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -1005,13 +1009,13 @@ static void sub_02053E5C(TaskManager *taskMan) } void *v2 = ov6_022472C8(fieldSystem, 4, mapChangeData->unk_04); - FieldTask_Start(taskMan, ov6_022472E8, v2); + FieldTask_InitCall(taskMan, ov6_022472E8, v2); } -static BOOL FieldTask_MapChangeWarp(TaskManager *taskMan) +static BOOL FieldTask_MapChangeWarp(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeWarpData *mapChangeWarpData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeWarpData *mapChangeWarpData = FieldTask_GetEnv(taskMan); Location *nextLocation = &mapChangeWarpData->nextLocation; switch (mapChangeWarpData->state) { @@ -1066,7 +1070,7 @@ void FieldSystem_StartMapChangeWarpTask(FieldSystem *fieldSystem, int param1, in Location_Set(&nextLocation, param1, param2, 0, 0, PlayerAvatar_GetDir(fieldSystem->playerAvatar)); mapChangeWarpData->nextLocation = nextLocation; - FieldTask_Set(fieldSystem, FieldTask_MapChangeWarp, mapChangeWarpData); + FieldSystem_CreateTask(fieldSystem, FieldTask_MapChangeWarp, mapChangeWarpData); } void *sub_02053FAC(FieldSystem *fieldSystem) @@ -1128,13 +1132,13 @@ void FieldTask_SetUndergroundMapChange(FieldSystem *fieldSystem) return; } - FieldTask_Set(fieldSystem, FieldMapChange_GetMapChangeUndergroundTask(fieldSystem), mapChangeUndergroundData); + FieldSystem_CreateTask(fieldSystem, FieldMapChange_GetMapChangeUndergroundTask(fieldSystem), mapChangeUndergroundData); } -BOOL FieldTask_MapChangeToUnderground(TaskManager *taskMan) +BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); switch (mapChangeUndergroundData->state) { case 0: @@ -1250,10 +1254,10 @@ BOOL FieldTask_MapChangeToUnderground(TaskManager *taskMan) return 0; } -BOOL FieldTask_MapChangeFromUnderground(TaskManager *taskMan) +BOOL FieldTask_MapChangeFromUnderground(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); int v2 = 0; switch (mapChangeUndergroundData->state) { @@ -1311,7 +1315,7 @@ BOOL FieldTask_MapChangeFromUnderground(TaskManager *taskMan) return 0; } -FieldTask FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem) +FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem) { if (fieldSystem->mapLoadType == MAP_LOAD_TYPE_OVERWORLD) { return FieldTask_MapChangeToUnderground; @@ -1323,10 +1327,10 @@ FieldTask FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSys } } -static BOOL sub_0205444C(TaskManager *taskMan, int param1) +static BOOL sub_0205444C(FieldTask *taskMan, int param1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); BOOL ret = 0; switch (mapChangeUndergroundData->unk_04) { @@ -1346,10 +1350,10 @@ static BOOL sub_0205444C(TaskManager *taskMan, int param1) return ret; } -static BOOL sub_02054494(TaskManager *taskMan) +static BOOL sub_02054494(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeSubData *mapChangeSub = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); switch (mapChangeSub->state) { case 0: @@ -1370,9 +1374,9 @@ static BOOL sub_02054494(TaskManager *taskMan) return 0; } -void sub_020544F0(TaskManager *taskMan, const Location *nextLocation) +void sub_020544F0(FieldTask *taskMan, const Location *nextLocation) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); MapChangeSubData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); if (FieldSystem_HasParentProcess(fieldSystem)) { @@ -1383,13 +1387,13 @@ void sub_020544F0(TaskManager *taskMan, const Location *nextLocation) mapChangeData->state = 0; mapChangeData->nextLocation = *nextLocation; - FieldTask_Start(taskMan, sub_02054494, mapChangeData); + FieldTask_InitCall(taskMan, sub_02054494, mapChangeData); } -static BOOL sub_02054538(TaskManager *taskMan) +static BOOL sub_02054538(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeUnionData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeUnionData *mapChangeData = FieldTask_GetEnv(taskMan); int *state = FieldTask_GetState(taskMan); Location *v3 = &mapChangeData->location; @@ -1442,14 +1446,14 @@ void sub_020545EC(FieldSystem *fieldSystem) sub_0205C2E0(fieldSystem->unk_80); fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; - FieldTask_Set(fieldSystem, sub_02054538, mapChangeData); + FieldSystem_CreateTask(fieldSystem, sub_02054538, mapChangeData); fieldSystem->unk_7C = NULL; } -static BOOL sub_02054648(TaskManager *taskMan) +static BOOL sub_02054648(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeUnionData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeUnionData *mapChangeData = FieldTask_GetEnv(taskMan); int *state = FieldTask_GetState(taskMan); Location *v3 = &mapChangeData->location; @@ -1494,9 +1498,9 @@ static BOOL sub_02054648(TaskManager *taskMan) return FALSE; } -void sub_02054708(TaskManager *taskMan) +void sub_02054708(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); MapChangeUnionData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeUnionData)); @@ -1509,13 +1513,13 @@ void sub_02054708(TaskManager *taskMan) fieldSystem->unk_80 = sub_0205C22C(fieldSystem->unk_7C); fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNION; - FieldTask_Start(taskMan, sub_02054648, mapChangeData); + FieldTask_InitCall(taskMan, sub_02054648, mapChangeData); } -static BOOL FieldTask_ChangeMapColosseum(TaskManager *taskMan) +static BOOL FieldTask_ChangeMapColosseum(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - MapChangeData *mapChangeData = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + MapChangeData *mapChangeData = FieldTask_GetEnv(taskMan); Location *location = &mapChangeData->nextLocation; switch (mapChangeData->state) { @@ -1546,10 +1550,10 @@ static BOOL FieldTask_ChangeMapColosseum(TaskManager *taskMan) return FALSE; } -void sub_02054800(TaskManager *taskMan, int mapId, int param2, int x, int z, int param5) +void sub_02054800(FieldTask *taskMan, int mapId, int param2, int x, int z, int param5) { Location nextLocation; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); Location_SetToPlayerLocation(location, fieldSystem); @@ -1563,14 +1567,14 @@ void sub_02054800(TaskManager *taskMan, int mapId, int param2, int x, int z, int mapChangeData->state = 0; mapChangeData->nextLocation = nextLocation; - FieldTask_Start(taskMan, FieldTask_ChangeMapColosseum, mapChangeData); + FieldTask_InitCall(taskMan, FieldTask_ChangeMapColosseum, mapChangeData); } -void sub_02054864(TaskManager *taskMan) +void sub_02054864(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; - FieldSystem_StartChangeMapTask(fieldSystem->taskManager, location); + FieldSystem_StartChangeMapTask(fieldSystem->task, location); } diff --git a/src/field_menu.c b/src/field_menu.c index f3a7fe87d3..f944d3bd5a 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -6,7 +6,6 @@ #include "constants/field/map_load.h" #include "struct_decls/pokedexdata_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0207AE68_decl.h" #include "struct_decls/struct_0207CB08_decl.h" #include "struct_decls/struct_0209747C_decl.h" @@ -26,7 +25,6 @@ #include "field/field_system.h" #include "functypes/funcptr_0203B7C0.h" #include "functypes/funcptr_0203BC5C.h" -#include "functypes/funcptr_02050904.h" #include "gmm/message_bank_unk_0367.h" #include "overlay005/fieldmap.h" #include "overlay005/ov5_021D2F14.h" @@ -39,6 +37,7 @@ #include "cell_actor.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "font.h" #include "game_records.h" #include "gx_layers.h" @@ -62,6 +61,7 @@ #include "strbuf.h" #include "string_list.h" #include "string_template.h" +#include "system_flags.h" #include "text.h" #include "trainer_info.h" #include "unk_020041CC.h" @@ -75,7 +75,6 @@ #include "unk_02033200.h" #include "unk_020366A0.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_020553DC.h" #include "unk_020559DC.h" #include "unk_020562F8.h" @@ -83,7 +82,6 @@ #include "unk_0205C22C.h" #include "unk_0205F180.h" #include "unk_020683F4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206B9D8.h" #include "unk_0207064C.h" @@ -151,43 +149,43 @@ static void sub_0203B558(CellActor *graphicElement, u32 param1); static void sub_0203B588(CellActor *graphicElement, u16 param1, u16 param2); static void sub_0203B5B4(FieldMenu *menu, u16 param1, u16 param2); static void sub_0203B5E8(CellActor *graphicElement); -static BOOL sub_0203AC44(TaskManager *taskMan); -static void sub_0203ADFC(TaskManager *taskMan); -static BOOL FieldMenu_Select(TaskManager *taskMan); +static BOOL sub_0203AC44(FieldTask *taskMan); +static void sub_0203ADFC(FieldTask *taskMan); +static BOOL FieldMenu_Select(FieldTask *taskMan); static u32 FieldMenu_MakeList(FieldMenu *menu, u8 *param1); static void FieldMenu_Close(FieldMenu *menu); static void sub_0203B2EC(FieldMenu *menu, FieldSystem *param1); -static void sub_0203B094(TaskManager *taskMan); -static void sub_0203B200(TaskManager *taskMan); -static void FieldMenu_ApplicationStart(TaskManager *taskMan); -static void FieldMenu_ApplicationRun(TaskManager *taskMan); -static BOOL FieldMenu_SelectPokedex(TaskManager *taskMan); -static BOOL FieldMenu_Pokedex(TaskManager *taskMan); -static BOOL FieldMenu_PokedexEnd(TaskManager *taskMan); -static BOOL FieldMenu_SelectTrainerCard(TaskManager *taskMan); -static BOOL FieldMenu_TrainerCard(TaskManager *taskMan); -static BOOL sub_0203BF00(TaskManager *taskMan); -static BOOL FieldMenu_SelectOptions(TaskManager *taskMan); -static BOOL FieldMenu_Options(TaskManager *taskMan); -static BOOL sub_0203C050(TaskManager *taskMan); -static BOOL FieldMenu_SelectChat(TaskManager *taskMan); -static BOOL sub_0203C0A0(TaskManager *taskMan); -static BOOL sub_0203C0F8(TaskManager *taskMan); -static BOOL FieldMenu_SelectPokemon(TaskManager *taskMan); -static BOOL sub_0203B78C(TaskManager *taskMan); -static BOOL FieldMenu_SelectBag(TaskManager *taskMan); -static BOOL FieldMenu_Bag(TaskManager *taskMan); -static BOOL sub_0203BC5C(TaskManager *taskMan); -static BOOL FieldMenu_SelectSave(TaskManager *taskMan); -static void FieldMenu_SaveWait(TaskManager *taskMan); -static void FieldMenu_Save(TaskManager *taskMan); -static BOOL sub_0203C1C8(TaskManager *taskMan); -static void sub_0203C2D8(TaskManager *taskMan, u16 param1); -static BOOL sub_0203C390(TaskManager *taskMan); -BOOL sub_0203C434(TaskManager *taskMan); -static void FieldMenu_EvolveInit(TaskManager *taskMan); -static void FieldMenu_Evolve(TaskManager *taskMan); -static BOOL FieldMenu_SelectRetire(TaskManager *taskMan); +static void sub_0203B094(FieldTask *taskMan); +static void sub_0203B200(FieldTask *taskMan); +static void FieldMenu_ApplicationStart(FieldTask *taskMan); +static void FieldMenu_ApplicationRun(FieldTask *taskMan); +static BOOL FieldMenu_SelectPokedex(FieldTask *taskMan); +static BOOL FieldMenu_Pokedex(FieldTask *taskMan); +static BOOL FieldMenu_PokedexEnd(FieldTask *taskMan); +static BOOL FieldMenu_SelectTrainerCard(FieldTask *taskMan); +static BOOL FieldMenu_TrainerCard(FieldTask *taskMan); +static BOOL sub_0203BF00(FieldTask *taskMan); +static BOOL FieldMenu_SelectOptions(FieldTask *taskMan); +static BOOL FieldMenu_Options(FieldTask *taskMan); +static BOOL sub_0203C050(FieldTask *taskMan); +static BOOL FieldMenu_SelectChat(FieldTask *taskMan); +static BOOL sub_0203C0A0(FieldTask *taskMan); +static BOOL sub_0203C0F8(FieldTask *taskMan); +static BOOL FieldMenu_SelectPokemon(FieldTask *taskMan); +static BOOL sub_0203B78C(FieldTask *taskMan); +static BOOL FieldMenu_SelectBag(FieldTask *taskMan); +static BOOL FieldMenu_Bag(FieldTask *taskMan); +static BOOL sub_0203BC5C(FieldTask *taskMan); +static BOOL FieldMenu_SelectSave(FieldTask *taskMan); +static void FieldMenu_SaveWait(FieldTask *taskMan); +static void FieldMenu_Save(FieldTask *taskMan); +static BOOL sub_0203C1C8(FieldTask *taskMan); +static void sub_0203C2D8(FieldTask *taskMan, u16 param1); +static BOOL sub_0203C390(FieldTask *taskMan); +BOOL sub_0203C434(FieldTask *taskMan); +static void FieldMenu_EvolveInit(FieldTask *taskMan); +static void FieldMenu_Evolve(FieldTask *taskMan); +static BOOL FieldMenu_SelectRetire(FieldTask *taskMan); static const u32 Unk_020EA05C[][2] = { { pl_msg_00000367_00000, (u32)FieldMenu_SelectPokedex }, @@ -271,9 +269,9 @@ void FieldMenu_Init(FieldSystem *fieldSystem) { FieldMenu *menu = FieldMenu_Alloc(); - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { menu->unk_224 = sub_0203AC24(fieldSystem); - } else if (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + } else if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { menu->unk_224 = sub_0203AC28(fieldSystem); } else if (sub_0206C0D0(fieldSystem) == 1) { menu->unk_224 = sub_0203AC2C(fieldSystem); @@ -287,7 +285,7 @@ void FieldMenu_Init(FieldSystem *fieldSystem) sub_0205F5E4(fieldSystem->playerAvatar, PlayerAvatar_GetDir(fieldSystem->playerAvatar)); } - FieldTask_Set(fieldSystem, sub_0203AC44, menu); + FieldSystem_CreateTask(fieldSystem, sub_0203AC44, menu); } void sub_0203AA78(FieldSystem *fieldSystem) @@ -301,7 +299,7 @@ void sub_0203AA78(FieldSystem *fieldSystem) sub_0205F5E4(fieldSystem->playerAvatar, PlayerAvatar_GetDir(fieldSystem->playerAvatar)); } - FieldTask_Set(fieldSystem, sub_0203AC44, menu); + FieldSystem_CreateTask(fieldSystem, sub_0203AC44, menu); } void sub_0203AABC(FieldSystem *fieldSystem) @@ -315,7 +313,7 @@ void sub_0203AABC(FieldSystem *fieldSystem) sub_0205F5E4(fieldSystem->playerAvatar, PlayerAvatar_GetDir(fieldSystem->playerAvatar)); } - FieldTask_Set(fieldSystem, sub_0203AC44, menu); + FieldSystem_CreateTask(fieldSystem, sub_0203AC44, menu); } void sub_0203AB00(FieldSystem *fieldSystem) @@ -327,9 +325,9 @@ void sub_0203AB00(FieldSystem *fieldSystem) menu->unk_228 = 0; - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { menu->unk_224 = sub_0203AC24(fieldSystem); - } else if (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + } else if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { menu->unk_224 = sub_0203AC28(fieldSystem); } else if (sub_0206C0D0(fieldSystem) == 1) { menu->unk_224 = sub_0203AC2C(fieldSystem); @@ -342,7 +340,7 @@ void sub_0203AB00(FieldSystem *fieldSystem) menu->unk_224 = sub_0203ABD0(fieldSystem); } - FieldTask_Change(fieldSystem->taskManager, sub_0203AC44, menu); + FieldTask_InitJump(fieldSystem->task, sub_0203AC44, menu); } static FieldMenu *FieldMenu_Alloc(void) @@ -370,7 +368,7 @@ static u32 sub_0203ABD0(FieldSystem *fieldSystem) v0 |= 0x2; } - if (VarsFlags_CheckBagAvailable(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) { + if (SystemFlag_CheckBagAcquired(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) { v0 |= 0x4; } @@ -410,13 +408,13 @@ static u32 sub_0203AC3C(FieldSystem *fieldSystem) return 0x10 | 0x1 | 0x80 | 0x100; } -static BOOL sub_0203AC44(TaskManager *taskMan) +static BOOL sub_0203AC44(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); switch (menu->state) { case FIELD_MENU_STATE_INIT: @@ -451,7 +449,7 @@ static BOOL sub_0203AC44(TaskManager *taskMan) FieldMenu_Evolve(taskMan); break; case FIELD_MENU_STATE_12: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { MapObjectMan_PauseAllMovement(fieldSystem->mapObjMan); sub_0203ADFC(taskMan); sub_0203B094(taskMan); @@ -460,7 +458,7 @@ static BOOL sub_0203AC44(TaskManager *taskMan) } break; case FIELD_MENU_STATE_8: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { ov5_021D1744(1); menu->state = FIELD_MENU_STATE_9; } @@ -474,7 +472,7 @@ static BOOL sub_0203AC44(TaskManager *taskMan) } break; case FIELD_MENU_STATE_10: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { MapObjectMan_PauseAllMovement(fieldSystem->mapObjMan); ov5_021D1744(1); menu->state = FIELD_MENU_STATE_11; @@ -482,7 +480,7 @@ static BOOL sub_0203AC44(TaskManager *taskMan) break; case FIELD_MENU_STATE_11: if (IsScreenTransitionDone()) { - FieldTask_Change(taskMan, menu->unk_22C, menu->unk_25C); + FieldTask_InitJump(taskMan, menu->unk_22C, menu->unk_25C); Heap_FreeToHeap(menu); } break; @@ -515,7 +513,7 @@ static BOOL sub_0203AC44(TaskManager *taskMan) return FALSE; } -static void sub_0203ADFC(TaskManager *taskMan) +static void sub_0203ADFC(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -523,8 +521,8 @@ static void sub_0203ADFC(TaskManager *taskMan) MenuTemplate v3; u32 v4, v5; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v5 = FieldMenu_MakeList(menu, menu->unk_30); Window_Add(fieldSystem->bgConfig, &menu->unk_00, 3, 20, 1, 11, v5 * 3, 12, ((((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4)) - (11 * 22))); @@ -647,7 +645,7 @@ static void FieldMenu_Close(FieldMenu *menu) menu->unk_20 = NULL; } -static void sub_0203B094(TaskManager *taskMan) +static void sub_0203B094(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -657,12 +655,12 @@ static void sub_0203B094(TaskManager *taskMan) Strbuf *v5; u8 v6; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { v6 = 0; - } else if (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + } else if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { v6 = 1; } else { return; @@ -708,15 +706,15 @@ static void sub_0203B094(TaskManager *taskMan) Window_ScheduleCopyToVRAM(&menu->unk_10); } -static void sub_0203B200(TaskManager *taskMan) +static void sub_0203B200(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); - if ((sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) && (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0)) { + if ((SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0) && (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == 0)) { return; } @@ -724,14 +722,14 @@ static void sub_0203B200(TaskManager *taskMan) Window_Remove(&menu->unk_10); } -static BOOL FieldMenu_Select(TaskManager *taskMan) +static BOOL FieldMenu_Select(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; u16 v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = Menu_GetCursorPos(menu->unk_20); menu->unk_2C = Menu_ProcessInputWithSound(menu->unk_20, 1504); @@ -755,7 +753,7 @@ static BOOL FieldMenu_Select(TaskManager *taskMan) if (Unk_020EA05C[menu->unk_2C][1] == 0xfffffffe) { menu->state = FIELD_MENU_STATE_END; } else if (Unk_020EA05C[menu->unk_2C][1] != 0xffffffff) { - FieldTask v3 = (FieldTask)Unk_020EA05C[menu->unk_2C][1]; + FieldTaskFunc v3 = (FieldTaskFunc)Unk_020EA05C[menu->unk_2C][1]; return v3(taskMan); } @@ -884,7 +882,7 @@ static void sub_0203B5E8(CellActor *graphicElement) } } -static void FieldMenu_ApplicationStart(TaskManager *taskMan) +static void FieldMenu_ApplicationStart(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -893,8 +891,8 @@ static void FieldMenu_ApplicationStart(TaskManager *taskMan) return; } - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); FieldMenu_Close(menu); Window_Remove(&menu->unk_00); @@ -904,15 +902,15 @@ static void FieldMenu_ApplicationStart(TaskManager *taskMan) menu->state = FIELD_MENU_STATE_APP_RUN; } -static void FieldMenu_ApplicationRun(TaskManager *taskMan) +static void FieldMenu_ApplicationRun(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return; } @@ -925,11 +923,11 @@ void sub_0203B674(FieldMenu *menu, void *param1) menu->state = FIELD_MENU_STATE_APP_RUN; } -static BOOL FieldMenu_SelectPokedex(TaskManager *taskMan) +static BOOL FieldMenu_SelectPokedex(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -939,7 +937,7 @@ static BOOL FieldMenu_SelectPokedex(TaskManager *taskMan) return TRUE; } -static BOOL FieldMenu_Pokedex(TaskManager *taskMan) +static BOOL FieldMenu_Pokedex(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -948,8 +946,8 @@ static BOOL FieldMenu_Pokedex(TaskManager *taskMan) TrainerInfo *v4; VarsFlags *v5; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = Heap_AllocFromHeap(11, sizeof(UnkStruct_ov21_021D0D80)); v3 = SaveData_Pokedex(fieldSystem->saveData); v4 = SaveData_GetTrainerInfo(fieldSystem->saveData); @@ -972,15 +970,15 @@ static BOOL FieldMenu_Pokedex(TaskManager *taskMan) return 0; } -static BOOL FieldMenu_PokedexEnd(TaskManager *taskMan) +static BOOL FieldMenu_PokedexEnd(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); if (menu->unk_25C != NULL) { Heap_FreeToHeapExplicit(11, menu->unk_25C); @@ -991,11 +989,11 @@ static BOOL FieldMenu_PokedexEnd(TaskManager *taskMan) return 0; } -static BOOL FieldMenu_SelectPokemon(TaskManager *taskMan) +static BOOL FieldMenu_SelectPokemon(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -1005,13 +1003,13 @@ static BOOL FieldMenu_SelectPokemon(TaskManager *taskMan) return TRUE; } -static BOOL sub_0203B78C(TaskManager *taskMan) +static BOOL sub_0203B78C(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0203D390(fieldSystem, &menu->unk_24C, 0); menu->unk_22C = sub_0203B7C0; @@ -1019,14 +1017,14 @@ static BOOL sub_0203B78C(TaskManager *taskMan) return 0; } -BOOL sub_0203B7C0(TaskManager *taskMan) +BOOL sub_0203B7C0(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; PartyManagementData *partyMan; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); partyMan = (PartyManagementData *)Heap_AllocFromHeap(11, sizeof(PartyManagementData)); memcpy(partyMan, menu->unk_25C, sizeof(PartyManagementData)); @@ -1225,7 +1223,7 @@ BOOL sub_0203B7C0(TaskManager *taskMan) menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); sub_0203B674(menu, sub_0203BC5C); } else { - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->state = FIELD_MENU_STATE_12; } } @@ -1235,11 +1233,11 @@ BOOL sub_0203B7C0(TaskManager *taskMan) return 0; } -static BOOL FieldMenu_SelectBag(TaskManager *taskMan) +static BOOL FieldMenu_SelectBag(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -1249,10 +1247,10 @@ static BOOL FieldMenu_SelectBag(TaskManager *taskMan) return TRUE; } -static BOOL FieldMenu_Bag(TaskManager *taskMan) +static BOOL FieldMenu_Bag(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - FieldMenu *menu = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldMenu *menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); sub_0207CB70(menu->unk_25C, 0); @@ -1263,14 +1261,14 @@ static BOOL FieldMenu_Bag(TaskManager *taskMan) return FALSE; } -static BOOL sub_0203BC5C(TaskManager *taskMan) +static BOOL sub_0203BC5C(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; UnkStruct_0207CB08 *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = sub_0207CB08(11); memcpy(v2, menu->unk_25C, sub_0207CB20()); @@ -1362,7 +1360,7 @@ static BOOL sub_0203BC5C(TaskManager *taskMan) } break; case 5: default: - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->state = FIELD_MENU_STATE_12; } @@ -1371,11 +1369,11 @@ static BOOL sub_0203BC5C(TaskManager *taskMan) return 0; } -static BOOL FieldMenu_SelectTrainerCard(TaskManager *taskMan) +static BOOL FieldMenu_SelectTrainerCard(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -1385,13 +1383,13 @@ static BOOL FieldMenu_SelectTrainerCard(TaskManager *taskMan) return TRUE; } -static BOOL FieldMenu_TrainerCard(TaskManager *taskMan) +static BOOL FieldMenu_TrainerCard(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_02071F04(11); @@ -1402,26 +1400,26 @@ static BOOL FieldMenu_TrainerCard(TaskManager *taskMan) return 0; } -static BOOL sub_0203BF00(TaskManager *taskMan) +static BOOL sub_0203BF00(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); sub_020721D4(fieldSystem, (TrainerCard *)menu->unk_25C); sub_02071F20((TrainerCard *)menu->unk_25C); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->state = FIELD_MENU_STATE_12; return 0; } -static BOOL FieldMenu_SelectSave(TaskManager *taskMan) +static BOOL FieldMenu_SelectSave(FieldTask *taskMan) { - FieldMenu *menu = TaskManager_Environment(taskMan); + FieldMenu *menu = FieldTask_GetEnv(taskMan); FieldMenu_Close(menu); Window_EraseStandardFrame(&menu->unk_00, 1); @@ -1434,16 +1432,16 @@ static BOOL FieldMenu_SelectSave(TaskManager *taskMan) return TRUE; } -static void FieldMenu_Save(TaskManager *taskMan) +static void FieldMenu_Save(FieldTask *taskMan) { - FieldMenu *menu = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldMenu *menu = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); SaveMenu *saveMenu; if (SaveData_OverwriteCheck(fieldSystem->saveData)) { ScriptManager_Start(taskMan, 2034, NULL, NULL); } else { - menu->unk_25C = Heap_AllocFromHeap(32, sizeof(SaveMenu)); + menu->unk_25C = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(SaveMenu)); saveMenu = menu->unk_25C; saveMenu->unk_04 = 0; @@ -1453,10 +1451,10 @@ static void FieldMenu_Save(TaskManager *taskMan) menu->state = FIELD_MENU_STATE_SAVE_WAIT; } -static void FieldMenu_SaveWait(TaskManager *taskMan) +static void FieldMenu_SaveWait(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - FieldMenu *menu = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldMenu *menu = FieldTask_GetEnv(taskMan); SaveMenu *saveMenu = menu->unk_25C; if (SaveData_OverwriteCheck(fieldSystem->saveData)) { @@ -1472,11 +1470,11 @@ static void FieldMenu_SaveWait(TaskManager *taskMan) } } -static BOOL FieldMenu_SelectOptions(TaskManager *taskMan) +static BOOL FieldMenu_SelectOptions(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -1486,13 +1484,13 @@ static BOOL FieldMenu_SelectOptions(TaskManager *taskMan) return TRUE; } -static BOOL FieldMenu_Options(TaskManager *taskMan) +static BOOL FieldMenu_Options(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = FieldSystem_OpenOptionsMenu(fieldSystem); menu->unk_22C = sub_0203C050; @@ -1500,27 +1498,27 @@ static BOOL FieldMenu_Options(TaskManager *taskMan) return FALSE; } -static BOOL sub_0203C050(TaskManager *taskMan) +static BOOL sub_0203C050(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); Heap_FreeToHeap(menu->unk_25C); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->state = FIELD_MENU_STATE_12; return 0; } -static BOOL FieldMenu_SelectChat(TaskManager *taskMan) +static BOOL FieldMenu_SelectChat(FieldTask *taskMan) { FieldMenu *menu; - menu = TaskManager_Environment(taskMan); + menu = FieldTask_GetEnv(taskMan); ov5_021D1744(0); @@ -1530,14 +1528,14 @@ static BOOL FieldMenu_SelectChat(TaskManager *taskMan) return 1; } -static BOOL sub_0203C0A0(TaskManager *taskMan) +static BOOL sub_0203C0A0(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; Sentence v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0209747C(2, 0, fieldSystem->saveData, 11); @@ -1550,14 +1548,14 @@ static BOOL sub_0203C0A0(TaskManager *taskMan) return 0; } -static BOOL sub_0203C0F8(TaskManager *taskMan) +static BOOL sub_0203C0F8(FieldTask *taskMan) { Sentence sentence; FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); if (sub_02097528(menu->unk_25C) == 0) { sub_02097540(menu->unk_25C, &sentence); @@ -1573,19 +1571,19 @@ static BOOL sub_0203C0F8(TaskManager *taskMan) } sub_020974EC((UnkStruct_0209747C *)menu->unk_25C); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); sub_0205C2B0(fieldSystem->unk_80); return 0; } -static BOOL FieldMenu_SelectRetire(TaskManager *taskMan) +static BOOL FieldMenu_SelectRetire(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); FieldMenu_Close(menu); Window_EraseStandardFrame(&menu->unk_00, 1); @@ -1593,7 +1591,7 @@ static BOOL FieldMenu_SelectRetire(TaskManager *taskMan) Window_Remove(&menu->unk_00); sub_0203B200(taskMan); - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { ScriptManager_Change(taskMan, 8821, NULL); } else { ScriptManager_Change(taskMan, 4, NULL); @@ -1603,14 +1601,14 @@ static BOOL FieldMenu_SelectRetire(TaskManager *taskMan) return 0; } -static BOOL sub_0203C1C8(TaskManager *taskMan) +static BOOL sub_0203C1C8(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; PokemonSummary *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = Heap_AllocFromHeap(11, sizeof(PokemonSummary)); memcpy(v2, menu->unk_25C, sizeof(PokemonSummary)); @@ -1662,7 +1660,7 @@ static BOOL sub_0203C1C8(TaskManager *taskMan) return 0; } -static void sub_0203C2D8(TaskManager *taskMan, u16 param1) +static void sub_0203C2D8(FieldTask *taskMan, u16 param1) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -1670,8 +1668,8 @@ static void sub_0203C2D8(TaskManager *taskMan, u16 param1) u8 v3; u8 v4, v5, v6; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_020972FC(11); v2 = SaveData_GetBag(fieldSystem->saveData); @@ -1694,14 +1692,14 @@ static void sub_0203C2D8(TaskManager *taskMan, u16 param1) sub_0203B674(menu, sub_0203C390); } -static BOOL sub_0203C390(TaskManager *taskMan) +static BOOL sub_0203C390(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; u8 v2, v3; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); sub_02097390(menu->unk_25C, &v2, &v3); sub_0207D9C8(fieldSystem->unk_98, 4, v3, v2); @@ -1713,13 +1711,13 @@ static BOOL sub_0203C390(TaskManager *taskMan) return 0; } -BOOL sub_0203C3F4(TaskManager *taskMan) +BOOL sub_0203C3F4(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); Heap_FreeToHeapExplicit(11, menu->unk_25C); menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); @@ -1728,15 +1726,15 @@ BOOL sub_0203C3F4(TaskManager *taskMan) return 0; } -BOOL sub_0203C434(TaskManager *taskMan) +BOOL sub_0203C434(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; UnkStruct_0203D8AC *v2; u32 v3; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v3 = *((u32 *)menu->unk_260); Heap_FreeToHeapExplicit(11, menu->unk_260); @@ -1758,7 +1756,7 @@ BOOL sub_0203C434(TaskManager *taskMan) Journal_SaveData(fieldSystem->journal, v6, 1); Heap_FreeToHeapExplicit(11, menu->unk_25C); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->unk_22C = sub_02070680; menu->unk_25C = v5; @@ -1768,13 +1766,13 @@ BOOL sub_0203C434(TaskManager *taskMan) return 0; } -BOOL sub_0203C50C(TaskManager *taskMan) +BOOL sub_0203C50C(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); sub_0203B674(menu, sub_0203BC5C); @@ -1795,14 +1793,14 @@ void *sub_0203C540(u16 fieldSystem, u8 param1, u8 param2) return (void *)v0; } -BOOL sub_0203C558(TaskManager *taskMan) +BOOL sub_0203C558(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; UnkStruct_0203C540 *v2; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = menu->unk_260; switch (v2->unk_03) { @@ -1868,13 +1866,13 @@ static void sub_0203C668(FieldSystem *fieldSystem, FieldMenu *param1, u8 param2) sub_0203B674(param1, sub_0203B7C0); } -BOOL sub_0203C710(TaskManager *taskMan) +BOOL sub_0203C710(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); sub_02098AF0(menu->unk_25C); @@ -1884,13 +1882,13 @@ BOOL sub_0203C710(TaskManager *taskMan) return 0; } -BOOL sub_0203C750(TaskManager *taskMan) +BOOL sub_0203C750(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); sub_0203B674(menu, sub_0203BC5C); @@ -1898,13 +1896,13 @@ BOOL sub_0203C750(TaskManager *taskMan) return 0; } -BOOL sub_0203C784(TaskManager *taskMan) +BOOL sub_0203C784(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); menu->unk_25C = sub_0203D20C(fieldSystem, &menu->unk_230); sub_0203B674(menu, sub_0203BC5C); @@ -1912,7 +1910,7 @@ BOOL sub_0203C784(TaskManager *taskMan) return 0; } -static void FieldMenu_EvolveInit(TaskManager *taskMan) +static void FieldMenu_EvolveInit(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; @@ -1921,8 +1919,8 @@ static void FieldMenu_EvolveInit(TaskManager *taskMan) Pokemon *v4; UnkStruct_0207AE68 *v5; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); v2 = menu->unk_25C; sub_0200569C(); @@ -1950,13 +1948,13 @@ static void FieldMenu_EvolveInit(TaskManager *taskMan) menu->state = FIELD_MENU_STATE_EVOLVE; } -static void FieldMenu_Evolve(TaskManager *taskMan) +static void FieldMenu_Evolve(FieldTask *taskMan) { FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(taskMan); - menu = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + menu = FieldTask_GetEnv(taskMan); if (sub_0207B0D0(menu->unk_25C) == 1) { sub_0207B0E0(menu->unk_25C); diff --git a/src/field_script_context.c b/src/field_script_context.c index da300ab97b..174e47bcdb 100644 --- a/src/field_script_context.c +++ b/src/field_script_context.c @@ -27,7 +27,7 @@ void ScriptContext_Init(ScriptContext *ctx, const ScrCmdFunc *cmdTable, u32 cmdT ctx->stack[i] = NULL; } - ctx->taskManager = NULL; + ctx->task = NULL; } BOOL ScriptContext_Start(ScriptContext *ctx, const u8 *ptr) @@ -50,9 +50,9 @@ void ScriptContext_Stop(ScriptContext *ctx) ctx->scriptPtr = NULL; } -void ScriptContext_SetTaskManager(ScriptContext *ctx, TaskManager *taskManager) +void ScriptContext_SetTask(ScriptContext *ctx, FieldTask *task) { - ctx->taskManager = taskManager; + ctx->task = task; } BOOL ScriptContext_Run(ScriptContext *ctx) diff --git a/src/field_system.c b/src/field_system.c index 1a2b39b8f5..6eceb48f8b 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -25,6 +25,7 @@ #include "field_map_change.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "game_overlay.h" #include "heap.h" #include "main.h" @@ -33,7 +34,6 @@ #include "pokeradar.h" #include "savedata.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_0205F180.h" #include "unk_0209ACBC.h" #include "unk_0209C370.h" @@ -105,7 +105,7 @@ const OverlayManagerTemplate gFieldSystemContinueTemplate = { .overlayID = FS_OVERLAY_ID_NONE, }; -void FieldSystem_StartFieldMap(FieldSystem *fieldSystem) +void FieldSystem_StartFieldMapInner(FieldSystem *fieldSystem) { GF_ASSERT(fieldSystem->processManager->child == NULL); GF_ASSERT(fieldSystem->processManager->parent == NULL); @@ -126,7 +126,7 @@ BOOL FieldSystem_HasParentProcess(FieldSystem *fieldSystem) return fieldSystem->processManager->parent != NULL; } -BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSystem) +BOOL FieldSystem_IsRunningFieldMapInner(FieldSystem *fieldSystem) { return fieldSystem->processManager->parent != NULL && fieldSystem->runningFieldMap; } @@ -146,7 +146,7 @@ void FieldSystem_StartChildProcess(FieldSystem *fieldSystem, const OverlayManage static FieldSystem *InitFieldSystem(OverlayManager *ovyManager) { Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_FIELDMAP, HEAP_SIZE_FIELDMAP); - Heap_Create(HEAP_ID_APPLICATION, 32, 0x4000); + Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_FIELD_TASK, HEAP_SIZE_FIELD_TASK); Heap_Create(HEAP_ID_SYSTEM, 91, 0x300); FieldSystem *fieldSystem = OverlayManager_NewData(ovyManager, sizeof(FieldSystem), HEAP_ID_FIELDMAP); @@ -158,7 +158,7 @@ static FieldSystem *InitFieldSystem(OverlayManager *ovyManager) fieldSystem->processManager->pause = FALSE; fieldSystem->processManager->kill = FALSE; fieldSystem->saveData = ((ApplicationArgs *)OverlayManager_Args(ovyManager))->saveData; - fieldSystem->taskManager = NULL; + fieldSystem->task = NULL; fieldSystem->location = FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); fieldSystem->unk_2C = sub_02039D6C(); @@ -204,7 +204,7 @@ static void ExecuteAndCleanupIfDone(OverlayManager **ovyManagerPtr) static BOOL HandleInputsEventsAndProcesses(FieldSystem *fieldSystem) { HandleFieldInput(fieldSystem); - if (sub_02050958(fieldSystem) == TRUE && fieldSystem->unk_04 != NULL) { + if (FieldTask_Run(fieldSystem) == TRUE && fieldSystem->unk_04 != NULL) { ov5_021EA714(fieldSystem, POKETCH_EVENT_SLEEP, 0); } @@ -220,7 +220,7 @@ static BOOL HandleInputsEventsAndProcesses(FieldSystem *fieldSystem) // Does not match with return (expression) if (fieldSystem->processManager->kill - && !fieldSystem->taskManager + && !fieldSystem->task && !fieldSystem->processManager->parent && !fieldSystem->processManager->child) { return TRUE; @@ -232,7 +232,7 @@ static BOOL HandleInputsEventsAndProcesses(FieldSystem *fieldSystem) static void HandleFieldInput(FieldSystem *fieldSystem) { BOOL processInput = FALSE; - if (!fieldSystem->processManager->pause && fieldSystem->runningFieldMap && sub_020509A4(fieldSystem) == FALSE) { + if (!fieldSystem->processManager->pause && fieldSystem->runningFieldMap && FieldSystem_IsRunningTask(fieldSystem) == FALSE) { processInput = TRUE; } diff --git a/src/field_task.c b/src/field_task.c new file mode 100644 index 0000000000..573a58aa9a --- /dev/null +++ b/src/field_task.c @@ -0,0 +1,166 @@ +#include "field_task.h" + +#include +#include + +#include "field/field_system.h" + +#include "field_system.h" +#include "heap.h" + +typedef struct FieldTaskEnv { + int state; + const OverlayManagerTemplate *overlayTemplate; + void *overlayArgs; +} FieldTaskEnv; + +static FieldTask *CreateTaskManager(FieldSystem *fieldSys, FieldTaskFunc taskFunc, void *taskEnv) +{ + FieldTask *task = Heap_AllocFromHeapAtEnd(HEAP_ID_FIELD_TASK, sizeof(FieldTask)); + task->prev = NULL; + task->func = taskFunc; + task->state = 0; + task->env = taskEnv; + task->dummy10 = 0; + task->dummy14 = NULL; + task->fieldSys = fieldSys; + task->dummy1C = Heap_AllocFromHeapAtEnd(HEAP_ID_FIELD_TASK, sizeof(u32)); + + return task; +} + +FieldTask *FieldSystem_CreateTask(FieldSystem *fieldSys, FieldTaskFunc taskFunc, void *taskEnv) +{ + GF_ASSERT(fieldSys->task == NULL); + + FieldTask *task = CreateTaskManager(fieldSys, taskFunc, taskEnv); + fieldSys->task = task; + + return task; +} + +void FieldTask_InitJump(FieldTask *task, FieldTaskFunc taskFunc, void *taskEnv) +{ + task->func = taskFunc; + task->state = 0; + task->env = taskEnv; + + if (task->dummy14 != 0 || task->dummy14 != NULL) { // Double-comparison required to match + Heap_FreeToHeap(task->dummy14); + task->dummy10 = 0; + task->dummy14 = NULL; + } +} + +FieldTask *FieldTask_InitCall(FieldTask *task, FieldTaskFunc taskFunc, void *taskEnv) +{ + FieldTask *next = CreateTaskManager(task->fieldSys, taskFunc, taskEnv); + next->prev = task; + task->fieldSys->task = next; + + return next; +} + +BOOL FieldTask_Run(FieldSystem *fieldSys) +{ + if (fieldSys->task == NULL) { + return FALSE; + } + + // Run invocations through the call-stack until it is empty. + while (fieldSys->task->func(fieldSys->task) == TRUE) { + FieldTask *prev = fieldSys->task->prev; + + if (fieldSys->task->dummy14) { + Heap_FreeToHeap(fieldSys->task->dummy14); + } + + Heap_FreeToHeap(fieldSys->task->dummy1C); + Heap_FreeToHeap(fieldSys->task); + + fieldSys->task = prev; + if (prev == NULL) { + return TRUE; + } + } + + return FALSE; +} + +BOOL FieldSystem_IsRunningTask(FieldSystem *fieldSys) +{ + return fieldSys->task != NULL; +} + +BOOL FieldSystem_IsRunningApplication(FieldSystem *fieldSys) +{ + return FieldSystem_HasParentProcess(fieldSys) || FieldSystem_HasChildProcess(fieldSys); +} + +void FieldSystem_StartFieldMap(FieldSystem *fieldSys) +{ + FieldSystem_StartFieldMapInner(fieldSys); +} + +BOOL FieldSystem_IsRunningFieldMap(FieldSystem *fieldSys) +{ + // Explicit conditional-branch required to match. + if (FieldSystem_IsRunningFieldMapInner(fieldSys)) { + return TRUE; + } else { + return FALSE; + } +} + +static BOOL RunChildApplication(FieldTask *task) +{ + FieldSystem *fieldSys = FieldTask_GetFieldSystem(task); + FieldTaskEnv *env = FieldTask_GetEnv(task); + + switch (env->state) { + case 0: + FieldSystem_StartChildProcess(fieldSys, env->overlayTemplate, env->overlayArgs); + env->state++; + break; + + case 1: + if (FieldSystem_IsRunningApplication(fieldSys)) { + break; + } + + Heap_FreeToHeap(env); + return TRUE; + } + + return FALSE; +} + +void FieldTask_RunApplication(FieldTask *task, const OverlayManagerTemplate *overlayTemplate, void *overlayArgs) +{ + FieldTaskEnv *env = Heap_AllocFromHeapAtEnd(HEAP_ID_FIELD_TASK, sizeof(FieldTaskEnv)); + env->state = 0; + env->overlayTemplate = overlayTemplate; + env->overlayArgs = overlayArgs; + + FieldTask_InitCall(task, RunChildApplication, env); +} + +FieldSystem *FieldTask_GetFieldSystem(FieldTask *task) +{ + return task->fieldSys; +} + +void *FieldTask_GetEnv(FieldTask *task) +{ + return task->env; +} + +int *FieldTask_GetState(FieldTask *task) +{ + return &task->state; +} + +u32 FieldTask_GetDummy1CVal(FieldTask *task) +{ + return *task->dummy1C; +} diff --git a/src/game_start.c b/src/game_start.c index 5bbd92b9de..9b69db865f 100644 --- a/src/game_start.c +++ b/src/game_start.c @@ -16,11 +16,11 @@ #include "savedata.h" #include "savedata_misc.h" #include "system_data.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02017428.h" #include "unk_0201D15C.h" #include "unk_0205C980.h" -#include "unk_0206A8DC.h" #include "unk_0206B9D8.h" #include "vars_flags.h" @@ -182,5 +182,5 @@ static void StartNewSave(int unused, SaveData *saveData) SaveData_Clear(saveData); InitPlayerStartLocation(saveData); TrainerInfo_SetMoney(SaveData_GetTrainerInfo(saveData), 3000); - VarsFlags_SetBagAvailable(SaveData_GetVarsFlags(saveData)); + SystemFlag_SetBagAcquired(SaveData_GetVarsFlags(saveData)); } diff --git a/src/meson.build b/src/meson.build index df40c166d0..ae7a44165e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -192,7 +192,7 @@ pokeplatinum_c = files( 'unk_0204CFFC.c', 'unk_0204E240.c', 'unk_0204E378.c', - 'unk_0204E3CC.c', + 'scrcmd_system_flags.c', 'unk_0204E75C.c', 'unk_0204E974.c', 'unk_0204EDA4.c', @@ -206,8 +206,8 @@ pokeplatinum_c = files( 'unk_02050548.c', 'unk_02050568.c', 'vars_flags.c', - 'unk_020508D4.c', - 'unk_02050A74.c', + 'field_task.c', + 'encounter.c', 'unk_02051D8C.c', 'unk_020528D0.c', 'unk_02052C6C.c', @@ -250,7 +250,7 @@ pokeplatinum_c = files( 'pokeradar.c', 'unk_02069BE0.c', 'unk_0206A780.c', - 'unk_0206A8DC.c', + 'system_flags.c', 'unk_0206AFE0.c', 'unk_0206B70C.c', 'unk_0206B9D8.c', diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 81dbf0a55f..f8154351e3 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -21,7 +21,6 @@ #include "overlay005/ov5_021EF4BC.h" #include "overlay005/ov5_021EFB0C.h" #include "overlay005/ov5_021F8370.h" -#include "overlay005/struct_ov5_021D219C.h" #include "overlay005/vs_seeker.h" #include "overlay006/ov6_02240C9C.h" #include "overlay006/ov6_02246BF4.h" @@ -33,6 +32,7 @@ #include "communication_information.h" #include "communication_system.h" #include "core_sys.h" +#include "encounter.h" #include "field_comm_manager.h" #include "field_map_change.h" #include "field_menu.h" @@ -49,13 +49,13 @@ #include "pokeradar.h" #include "save_player.h" #include "script_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02005474.h" #include "unk_020261E4.h" #include "unk_02030EE0.h" #include "unk_020366A0.h" #include "unk_0203C954.h" -#include "unk_02050A74.h" #include "unk_02054884.h" #include "unk_02054D00.h" #include "unk_020562F8.h" @@ -66,7 +66,6 @@ #include "unk_0205F180.h" #include "unk_02067A84.h" #include "unk_020683F4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_02071B10.h" #include "vars_flags.h" @@ -182,7 +181,7 @@ BOOL FieldInput_Process(const FieldInput *input, FieldSystem *fieldSystem) if (input->dummy5 == FALSE) { BOOL hasTwoAliveMons = Party_HasTwoAliveMons(Party_GetFromSavedata(fieldSystem->saveData)); - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { hasTwoAliveMons = TRUE; } @@ -197,7 +196,7 @@ BOOL FieldInput_Process(const FieldInput *input, FieldSystem *fieldSystem) } if (input->movement) { - sub_0206A9A4(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_ClearStep(SaveData_GetVarsFlags(fieldSystem->saveData)); if (Field_ProcessStep(fieldSystem) == TRUE) { return TRUE; @@ -208,7 +207,7 @@ BOOL FieldInput_Process(const FieldInput *input, FieldSystem *fieldSystem) int playerEvent = PLAYER_EVENT_NONE; int direction = sub_02061308(fieldSystem->playerAvatar, input->pressedKeys, input->heldKeys); - if (inline_0204E650_2(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_HandleStrengthActive(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK)) { playerEvent |= PLAYER_EVENT_USED_STRENGTH; } @@ -547,7 +546,7 @@ static BOOL Field_CheckWildEncounter(FieldSystem *fieldSystem) Field_GetPlayerPos(fieldSystem, &playerX, &playerZ); - if (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { + if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { if (sub_02056374(fieldSystem, playerX, playerZ) == TRUE) { sub_02051450(fieldSystem, sub_0205639C(fieldSystem)); return TRUE; @@ -923,7 +922,7 @@ static BOOL Field_UpdatePoison(FieldSystem *fieldSystem) static BOOL Field_UpdateSafari(FieldSystem *fieldSystem) { - if (sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)) == FALSE) { + if (SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)) == FALSE) { return FALSE; } diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index 5c0f7ab5d8..53dc805e74 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -56,6 +56,7 @@ #include "field_map_change.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "game_overlay.h" #include "gx_layers.h" #include "heap.h" @@ -79,7 +80,6 @@ #include "unk_0202419C.h" #include "unk_02027F50.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_020553DC.h" #include "unk_020556C4.h" #include "unk_020559DC.h" @@ -497,7 +497,7 @@ void ov5_021D12D0(FieldSystem *fieldSystem, u32 param1) static void ov5_021D134C(FieldSystem *fieldSystem, u8 param1) { - if (sub_020509A4(fieldSystem) == 0) { + if (FieldSystem_IsRunningTask(fieldSystem) == 0) { sub_020559DC(fieldSystem); } diff --git a/src/overlay005/ov5_021D1A94.c b/src/overlay005/ov5_021D1A94.c index c842570526..8cb8da7fe8 100644 --- a/src/overlay005/ov5_021D1A94.c +++ b/src/overlay005/ov5_021D1A94.c @@ -74,7 +74,7 @@ static void ov5_021D1B24(SysTask *param0, void *param1) { UnkStruct_ov5_021D1BEC *v0 = param1; - if (FieldSystem_IsRunningFieldMap(v0->unk_00->fieldSystem)) { + if (FieldSystem_IsRunningFieldMapInner(v0->unk_00->fieldSystem)) { if (v0->unk_0C->unk_10) { v0->unk_0C->unk_10(v0, v0->unk_00->fieldSystem, v0->unk_10); } @@ -85,7 +85,7 @@ static void ov5_021D1B48(SysTask *param0, void *param1) { UnkStruct_ov5_021D1BEC *v0 = param1; - if (FieldSystem_IsRunningFieldMap(v0->unk_00->fieldSystem)) { + if (FieldSystem_IsRunningFieldMapInner(v0->unk_00->fieldSystem)) { if (v0->unk_0C->unk_14) { v0->unk_0C->unk_14(v0, v0->unk_00->fieldSystem, v0->unk_10); } diff --git a/src/overlay005/ov5_021D431C.c b/src/overlay005/ov5_021D431C.c index b733ea5673..2b1d7ae8f7 100644 --- a/src/overlay005/ov5_021D431C.c +++ b/src/overlay005/ov5_021D431C.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_defs/struct_02055130.h" @@ -16,12 +15,12 @@ #include "overlay005/struct_ov5_021E1890_decl.h" #include "camera.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "player_avatar.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_02056B30.h" #include "unk_020655F4.h" @@ -296,7 +295,7 @@ BOOL ov5_021D453C(FieldSystem *fieldSystem, UnkStruct_ov5_021D432C *param1) (param1->unk_00)++; } break; case 1: - sub_02056B30(fieldSystem->taskManager, 0, 9, 1, 0x0, 6, 1, 11); + sub_02056B30(fieldSystem->task, 0, 9, 1, 0x0, 6, 1, 11); { int v9; int v10; @@ -687,11 +686,11 @@ BOOL ov5_021D4A24(FieldSystem *fieldSystem, UnkStruct_ov5_021D432C *param1, cons return 0; } -static BOOL ov5_021D4BC8(TaskManager *param0) +static BOOL ov5_021D4BC8(FieldTask *param0) { BOOL v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - u8 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + u8 *v2 = FieldTask_GetEnv(param0); v0 = ov5_021D42F0(fieldSystem->unk_54, *v2); @@ -814,7 +813,7 @@ void ov5_021D4D48(FieldSystem *fieldSystem, const u8 param1) u8 *v0 = Heap_AllocFromHeapAtEnd(4, sizeof(u8)); *v0 = param1; - FieldTask_Start(fieldSystem->taskManager, ov5_021D4BC8, v0); + FieldTask_InitCall(fieldSystem->task, ov5_021D4BC8, v0); } void ov5_021D4D68(FieldSystem *fieldSystem, const u8 param1) @@ -863,11 +862,11 @@ UnkStruct_ov5_021D4E00 *ov5_021D4E00(void) return v0; } -BOOL ov5_021D4E10(TaskManager *param0) +BOOL ov5_021D4E10(FieldTask *param0) { MapObject *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021D4E00 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021D4E00 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_00) { case 0: @@ -921,10 +920,10 @@ BOOL ov5_021D4E10(TaskManager *param0) return 0; } -BOOL ov5_021D4F14(TaskManager *param0) +BOOL ov5_021D4F14(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021D4E00 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021D4E00 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: { @@ -958,10 +957,10 @@ BOOL ov5_021D4F14(TaskManager *param0) return 0; } -BOOL ov5_021D4FA0(TaskManager *param0) +BOOL ov5_021D4FA0(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021D4E00 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021D4E00 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: { @@ -989,11 +988,11 @@ BOOL ov5_021D4FA0(TaskManager *param0) return 0; } -BOOL ov5_021D5020(TaskManager *param0) +BOOL ov5_021D5020(FieldTask *param0) { MapObject *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021D4E00 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021D4E00 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_00) { case 0: { @@ -1068,11 +1067,11 @@ BOOL ov5_021D5020(TaskManager *param0) return 0; } -BOOL ov5_021D5150(TaskManager *param0) +BOOL ov5_021D5150(FieldTask *param0) { MapObject *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021D4E00 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021D4E00 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_00) { case 0: { diff --git a/src/overlay005/ov5_021DDAE4.c b/src/overlay005/ov5_021DDAE4.c index 1ebaf3c753..cce5fa1013 100644 --- a/src/overlay005/ov5_021DDAE4.c +++ b/src/overlay005/ov5_021DDAE4.c @@ -3,19 +3,17 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "field/field_system_sub2_t.h" #include "overlay024/ov24_02253CE0.h" #include "overlay025/poketch_system.h" +#include "field_task.h" #include "game_overlay.h" #include "heap.h" #include "poketch_data.h" #include "unk_0200A784.h" #include "unk_0200A9DC.h" -#include "unk_020508D4.h" FS_EXTERN_OVERLAY(overlay24); FS_EXTERN_OVERLAY(overlay25); @@ -24,10 +22,10 @@ typedef struct { int unk_00; } UnkStruct_ov5_021DDBC8; -static BOOL ov5_021DDAE4(TaskManager *param0) +static BOOL ov5_021DDAE4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021DDBC8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021DDBC8 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -66,10 +64,10 @@ static BOOL ov5_021DDAE4(TaskManager *param0) return 0; } -void ov5_021DDBC8(TaskManager *param0) +void ov5_021DDBC8(FieldTask *param0) { UnkStruct_ov5_021DDBC8 *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov5_021DDBC8)); v0->unk_00 = 0; - FieldTask_Start(param0, ov5_021DDAE4, v0); + FieldTask_InitCall(param0, ov5_021DDAE4, v0); } diff --git a/src/overlay005/ov5_021DFB54.c b/src/overlay005/ov5_021DFB54.c index aede4f8984..63351b9c74 100644 --- a/src/overlay005/ov5_021DFB54.c +++ b/src/overlay005/ov5_021DFB54.c @@ -6,7 +6,6 @@ #include "consts/game_records.h" #include "struct_decls/struct_020216E0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061830_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -29,6 +28,8 @@ #include "overlay101/struct_ov101_021D5D90_decl.h" #include "core_sys.h" +#include "encounter.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "map_object.h" @@ -39,8 +40,6 @@ #include "sys_task.h" #include "sys_task_manager.h" #include "unk_02005474.h" -#include "unk_020508D4.h" -#include "unk_02050A74.h" #include "unk_020553DC.h" #include "unk_0205DAC8.h" #include "unk_0205F180.h" @@ -139,22 +138,22 @@ static int ov5_021DFE68(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, in static int ov5_021DFEF4(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2, int param3); static int ov5_021DFF1C(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2, int param3); static void ov5_021DFF88(int param0, FieldSystem *param1, PlayerAvatar *playerAvatar, MapObject *param3); -static BOOL ov5_021DFFBC(TaskManager *param0); +static BOOL ov5_021DFFBC(FieldTask *param0); static void ov5_021E00B0(FieldSystem *fieldSystem, int param1, const UnkStruct_ov5_021E1050 *param2); -static BOOL ov5_021E0160(TaskManager *param0); +static BOOL ov5_021E0160(FieldTask *param0); static int ov5_021E032C(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2, int param3); static void ov5_021E0390(int param0, FieldSystem *param1, PlayerAvatar *playerAvatar); -static BOOL ov5_021E03C8(TaskManager *param0); +static BOOL ov5_021E03C8(FieldTask *param0); static int ov5_021E04A8(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2, int param3); static int ov5_021E04EC(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2, int param3); static void ov5_021E0534(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar); -static BOOL ov5_021E0560(TaskManager *param0); +static BOOL ov5_021E0560(FieldTask *param0); static int ov5_021E067C(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2); static int ov5_021E06A8(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar); static void ov5_021E06F8(FieldSystem *fieldSystem, int param1, const UnkStruct_ov5_021E1050 *param2); -static BOOL ov5_021E07A0(TaskManager *param0); +static BOOL ov5_021E07A0(FieldTask *param0); static UnkStruct_ov5_021F9B10 *ov5_021E0948(FieldSystem *fieldSystem, int param1, const UnkStruct_ov5_021E1050 *param2); -static BOOL ov5_021E09D4(TaskManager *param0); +static BOOL ov5_021E09D4(FieldTask *param0); static SysTask *ov5_021E0F54(FieldSystem *fieldSystem, u32 param1); static void ov5_021E0FC0(SysTask *param0); static void ov5_021E0FF0(SysTask *param0, void *param1); @@ -168,7 +167,7 @@ static void *ov5_021E1110(int param0); static void ov5_021E1134(void *param0); static Pokemon *ov5_021E1140(FieldSystem *fieldSystem, int param1); static void ov5_021E0DE0(FieldSystem *fieldSystem); -static BOOL ov5_021E0E10(TaskManager *param0); +static BOOL ov5_021E0E10(FieldTask *param0); static void (*const sPlayerAvatarRequestStateTbl[10])(PlayerAvatar *); int (*const Unk_ov5_021F9B54[])(UnkStruct_ov5_021F9B54 *); @@ -509,13 +508,13 @@ static void ov5_021DFF88(int param0, FieldSystem *fieldSystem, PlayerAvatar *pla v0->unk_10 = param3; v0->playerAvatar = playerAvatar; - FieldTask_Set(fieldSystem, ov5_021DFFBC, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021DFFBC, v0); GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(fieldSystem->saveData), RECORD_UNK_055); } -static BOOL ov5_021DFFBC(TaskManager *param0) +static BOOL ov5_021DFFBC(FieldTask *param0) { - UnkStruct_ov5_021DFF88 *v0 = TaskManager_Environment(param0); + UnkStruct_ov5_021DFF88 *v0 = FieldTask_GetEnv(param0); MapObject *v1 = Player_MapObject(v0->playerAvatar); MapObject *v2 = v0->unk_10; @@ -588,13 +587,13 @@ static void ov5_021E00B0(FieldSystem *fieldSystem, int param1, const UnkStruct_o v0->unk_24 = Player_MapObject(v0->playerAvatar); v0->unk_0C = *param2; - FieldTask_Start(fieldSystem->taskManager, ov5_021E0160, v0); + FieldTask_InitCall(fieldSystem->task, ov5_021E0160, v0); } -void ov5_021E00EC(TaskManager *taskMan, int param1, int param2) +void ov5_021E00EC(FieldTask *taskMan, int param1, int param2) { UnkStruct_ov5_021E1050 v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); Pokemon *v2 = ov5_021E1140(fieldSystem, param2); ov5_021E1028(fieldSystem, v2, &v0); @@ -618,9 +617,9 @@ int ov5_021E0118(PlayerAvatar *playerAvatar, u32 param1, u32 param2) return 0; } -static BOOL ov5_021E0160(TaskManager *taskMan) +static BOOL ov5_021E0160(FieldTask *taskMan) { - UnkStruct_ov5_021E00B0 *v0 = TaskManager_Environment(taskMan); + UnkStruct_ov5_021E00B0 *v0 = FieldTask_GetEnv(taskMan); switch (v0->unk_00) { case 0: @@ -746,12 +745,12 @@ static void ov5_021E0390(int param0, FieldSystem *fieldSystem, PlayerAvatar *par v0->unk_10 = Player_MapObject(param2); v0->unk_14 = sub_0205EC04(param2); - FieldTask_Set(fieldSystem, ov5_021E03C8, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021E03C8, v0); } -static BOOL ov5_021E03C8(TaskManager *param0) +static BOOL ov5_021E03C8(FieldTask *param0) { - UnkStruct_ov5_021E0390 *v0 = TaskManager_Environment(param0); + UnkStruct_ov5_021E0390 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -843,13 +842,13 @@ static void ov5_021E0534(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar) v0->fieldSystem = fieldSystem; v0->playerAvatar = playerAvatar; - FieldTask_Set(fieldSystem, ov5_021E0560, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021E0560, v0); GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(fieldSystem->saveData), RECORD_UNK_056); } -static BOOL ov5_021E0560(TaskManager *param0) +static BOOL ov5_021E0560(FieldTask *param0) { - UnkStruct_ov5_021E0534 *v0 = TaskManager_Environment(param0); + UnkStruct_ov5_021E0534 *v0 = FieldTask_GetEnv(param0); MapObject *v1 = Player_MapObject(v0->playerAvatar); switch (v0->unk_00) { @@ -887,7 +886,7 @@ static BOOL ov5_021E0560(TaskManager *param0) u8 v7 = sub_02062BE8(v1); if (sub_0205DD0C(v7) == 1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); BattleParams *v9; if (ov6_022413E4(fieldSystem, &v9) == 1) { @@ -969,13 +968,13 @@ static void ov5_021E06F8(FieldSystem *fieldSystem, int param1, const UnkStruct_o v0->unk_14 = Player_MapObject(v0->playerAvatar); v0->unk_1C = *param2; - FieldTask_Start(fieldSystem->taskManager, ov5_021E07A0, v0); + FieldTask_InitCall(fieldSystem->task, ov5_021E07A0, v0); } -void ov5_021E0734(TaskManager *param0, int param1, int param2) +void ov5_021E0734(FieldTask *param0, int param1, int param2) { UnkStruct_ov5_021E1050 v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); Pokemon *v2 = ov5_021E1140(fieldSystem, param2); ov5_021E1028(fieldSystem, v2, &v0); @@ -1002,10 +1001,10 @@ int ov5_021E0760(u32 param0, int param1) return 0; } -static BOOL ov5_021E07A0(TaskManager *param0) +static BOOL ov5_021E07A0(FieldTask *param0) { int v0; - UnkStruct_ov5_021F9B54 *v1 = TaskManager_Environment(param0); + UnkStruct_ov5_021F9B54 *v1 = FieldTask_GetEnv(param0); do { v0 = Unk_ov5_021F9B54[v1->unk_00](v1); @@ -1155,27 +1154,27 @@ static UnkStruct_ov5_021F9B10 *ov5_021E0948(FieldSystem *fieldSystem, int param1 void ov5_021E097C(FieldSystem *fieldSystem, int param1) { UnkStruct_ov5_021F9B10 *v0 = ov5_021E0948(fieldSystem, param1, NULL); - FieldTask_Set(fieldSystem, ov5_021E09D4, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021E09D4, v0); } -void ov5_021E0998(TaskManager *param0, int param1, int param2) +void ov5_021E0998(FieldTask *param0, int param1, int param2) { UnkStruct_ov5_021E1050 v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); Pokemon *v2 = ov5_021E1140(fieldSystem, param2); ov5_021E1028(fieldSystem, v2, &v0); { UnkStruct_ov5_021F9B10 *v3 = ov5_021E0948(fieldSystem, param1, &v0); - FieldTask_Start(param0, ov5_021E09D4, v3); + FieldTask_InitCall(param0, ov5_021E09D4, v3); } } -static BOOL ov5_021E09D4(TaskManager *param0) +static BOOL ov5_021E09D4(FieldTask *param0) { int v0; - UnkStruct_ov5_021F9B10 *v1 = TaskManager_Environment(param0); + UnkStruct_ov5_021F9B10 *v1 = FieldTask_GetEnv(param0); do { if (v1->unk_04 == 0) { @@ -1506,9 +1505,9 @@ static const MapObjectAnimCmd Unk_ov5_021F9C00[] = { { 0xfe, 0x0 } }; -void ov5_021E0DD4(TaskManager *param0) +void ov5_021E0DD4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); ov5_021E0DE0(fieldSystem); } @@ -1521,12 +1520,12 @@ static void ov5_021E0DE0(FieldSystem *fieldSystem) v0->unk_08 = Player_MapObject(v0->playerAvatar); v0->unk_10 = PlayerAvatar_Gender(v0->playerAvatar); - FieldTask_Start(fieldSystem->taskManager, ov5_021E0E10, v0); + FieldTask_InitCall(fieldSystem->task, ov5_021E0E10, v0); } -static BOOL ov5_021E0E10(TaskManager *param0) +static BOOL ov5_021E0E10(FieldTask *param0) { - UnkStruct_ov5_021E0DE0 *v0 = TaskManager_Environment(param0); + UnkStruct_ov5_021E0DE0 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_0C) { case 0: diff --git a/src/overlay005/ov5_021E1154.c b/src/overlay005/ov5_021E1154.c index 9450eead0f..accb0d690c 100644 --- a/src/overlay005/ov5_021E1154.c +++ b/src/overlay005/ov5_021E1154.c @@ -3,17 +3,16 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "player_avatar.h" #include "unk_02005474.h" -#include "unk_020508D4.h" #include "unk_0205DAC8.h" #include "unk_0205F180.h" #include "unk_020655F4.h" @@ -28,7 +27,7 @@ typedef struct { } UnkStruct_ov5_021E11B0; static void ov5_021E11B0(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, int param2); -static BOOL ov5_021E120C(TaskManager *param0); +static BOOL ov5_021E120C(FieldTask *param0); static void *ov5_021E132C(int param0); static void ov5_021E1350(void *param0); @@ -63,7 +62,7 @@ static void ov5_021E11B0(FieldSystem *fieldSystem, PlayerAvatar *playerAvatar, i v0->unk_00 = param2; Sound_PlayEffect(1624); - FieldTask_Set(fieldSystem, ov5_021E120C, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021E120C, v0); } static int ov5_021E11E0(int param0) @@ -82,9 +81,9 @@ static int ov5_021E11E0(int param0) return 0; } -static BOOL ov5_021E120C(TaskManager *param0) +static BOOL ov5_021E120C(FieldTask *param0) { - UnkStruct_ov5_021E11B0 *v0 = TaskManager_Environment(param0); + UnkStruct_ov5_021E11B0 *v0 = FieldTask_GetEnv(param0); MapObject *v1 = Player_MapObject(v0->playerAvatar); u8 v2 = sub_02062BE8(v1); diff --git a/src/overlay005/ov5_021EA714.c b/src/overlay005/ov5_021EA714.c index 1c393a6d3e..378c67decc 100644 --- a/src/overlay005/ov5_021EA714.c +++ b/src/overlay005/ov5_021EA714.c @@ -9,8 +9,8 @@ #include "game_overlay.h" #include "poketch_data.h" +#include "system_flags.h" #include "unk_0200A784.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" FS_EXTERN_OVERLAY(overlay24); @@ -29,7 +29,7 @@ void ov5_021EA728(FieldSystem *fieldSystem) VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); if (PoketchData_IsEnabled(poketchData) - && (sub_0206AE2C(v1) == 0)) { + && (SystemFlag_CheckPoketchHidden(v1) == 0)) { Overlay_LoadByID(FS_OVERLAY_ID(overlay25), 2); PoketchSystem_Create(fieldSystem, &fieldSystem->unk_04->poketchSys, fieldSystem->saveData, fieldSystem->bgConfig, sub_0200A914(1)); } else { @@ -44,7 +44,7 @@ void ov5_021EA790(FieldSystem *fieldSystem) VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); if (PoketchData_IsEnabled(poketchData) - && (sub_0206AE2C(v1) == 0)) { + && (SystemFlag_CheckPoketchHidden(v1) == 0)) { PoketchSystem_StartShutdown(fieldSystem->unk_04->poketchSys); } else { ov24_02253DA4(fieldSystem->bgConfig); @@ -57,7 +57,7 @@ u8 ov5_021EA7CC(FieldSystem *fieldSystem) VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); if (PoketchData_IsEnabled(poketchData) - && (sub_0206AE2C(v1) == 0)) { + && (SystemFlag_CheckPoketchHidden(v1) == 0)) { if (PoketchSystem_IsSystemShutdown(fieldSystem->unk_04->poketchSys)) { fieldSystem->unk_04->poketchSys = NULL; Overlay_UnloadByID(FS_OVERLAY_ID(overlay25)); diff --git a/src/overlay005/ov5_021EA874.c b/src/overlay005/ov5_021EA874.c index 37796a5465..c328fde223 100644 --- a/src/overlay005/ov5_021EA874.c +++ b/src/overlay005/ov5_021EA874.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0202B370_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" @@ -13,6 +12,7 @@ #include "communication_information.h" #include "communication_system.h" #include "field_system.h" +#include "field_task.h" #include "game_options.h" #include "heap.h" #include "list_menu.h" @@ -30,7 +30,6 @@ #include "unk_0202ACE0.h" #include "unk_0203061C.h" #include "unk_0203909C.h" -#include "unk_020508D4.h" #include "unk_0205D8CC.h" typedef struct { @@ -371,10 +370,10 @@ static BOOL ov5_021EAD38(UnkStruct_ov5_021EAE78 *param0) return 0; } -static BOOL ov5_021EADB4(TaskManager *param0) +static BOOL ov5_021EADB4(FieldTask *param0) { - UnkStruct_ov5_021EAE78 *v0 = TaskManager_Environment(param0); - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + UnkStruct_ov5_021EAE78 *v0 = FieldTask_GetEnv(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); switch (v0->unk_48) { case 0: @@ -466,7 +465,7 @@ static void ov5_021EAF1C(UnkStruct_ov5_021EAE78 *param0) void ov5_021EAF50(FieldSystem *fieldSystem) { UnkStruct_ov5_021EAE78 *v0; - TaskManager *v1 = fieldSystem->taskManager; + FieldTask *v1 = fieldSystem->task; v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov5_021EAE78)); ov5_021EAEE0(v0); @@ -476,9 +475,9 @@ void ov5_021EAF50(FieldSystem *fieldSystem) v0->unk_48 = 0; if (v1 == NULL) { - FieldTask_Set(fieldSystem, ov5_021EADB4, v0); + FieldSystem_CreateTask(fieldSystem, ov5_021EADB4, v0); } else { - FieldTask_Start(v1, ov5_021EADB4, v0); + FieldTask_InitCall(v1, ov5_021EADB4, v0); } } diff --git a/src/overlay005/ov5_021F007C.c b/src/overlay005/ov5_021F007C.c index 8ac533500b..a46ce6dc50 100644 --- a/src/overlay005/ov5_021F007C.c +++ b/src/overlay005/ov5_021F007C.c @@ -3,8 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "field/field_system_sub2_t.h" #include "overlay005/ov5_021D1A94.h" @@ -14,6 +12,7 @@ #include "overlay006/struct_ov6_0223E6EC.h" #include "bg_window.h" +#include "field_task.h" #include "graphics.h" #include "gx_layers.h" #include "heap.h" @@ -22,7 +21,6 @@ #include "player_avatar.h" #include "script_manager.h" #include "unk_02005474.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" typedef struct { @@ -431,10 +429,10 @@ u32 ov5_021F0484(void) return sizeof(UnkStruct_ov5_021F0468); } -BOOL ov5_021F0488(TaskManager *param0) +BOOL ov5_021F0488(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov5_021F0468 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov5_021F0468 *v1 = FieldTask_GetEnv(param0); BOOL v2; switch (v1->unk_0C) { diff --git a/src/overlay005/ov5_021F08CC.c b/src/overlay005/ov5_021F08CC.c index c1efad966c..d4141a68d7 100644 --- a/src/overlay005/ov5_021F08CC.c +++ b/src/overlay005/ov5_021F08CC.c @@ -5,7 +5,6 @@ #include "consts/game_records.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -18,6 +17,8 @@ #include "bg_window.h" #include "core_sys.h" +#include "encounter.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "map_object.h" @@ -33,8 +34,6 @@ #include "sys_task_manager.h" #include "unk_02005474.h" #include "unk_0201D15C.h" -#include "unk_020508D4.h" -#include "unk_02050A74.h" #include "unk_02051D8C.h" #include "unk_0205D8CC.h" #include "unk_020655F4.h" @@ -95,10 +94,10 @@ void *ov5_021F08CC(FieldSystem *fieldSystem, u32 param1, int param2) return v0; } -BOOL ov5_021F08F8(TaskManager *taskMan) +BOOL ov5_021F08F8(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov5_021F08CC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov5_021F08CC *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_00) { case 0: diff --git a/src/overlay005/ov5_021F101C.c b/src/overlay005/ov5_021F101C.c index a3d48fd983..cf0f871c67 100644 --- a/src/overlay005/ov5_021F101C.c +++ b/src/overlay005/ov5_021F101C.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_020711C8.h" #include "field/field_system.h" @@ -11,20 +10,20 @@ #include "overlay005/struct_ov5_021F0468_decl.h" #include "overlay006/ov6_02243258.h" +#include "field_task.h" #include "heap.h" #include "player_avatar.h" #include "sys_task_manager.h" -#include "unk_020508D4.h" typedef struct { SysTask *unk_00; UnkStruct_ov5_021F0468 *unk_04; } UnkStruct_ov5_021F101C; -BOOL ov5_021F101C(TaskManager *param0) +BOOL ov5_021F101C(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020711C8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020711C8 *v1 = FieldTask_GetEnv(param0); int *v2 = FieldTask_GetState(param0); UnkStruct_ov5_021F101C *v3 = v1->unk_04; @@ -54,7 +53,7 @@ BOOL ov5_021F101C(TaskManager *param0) } break; case 4: - FieldTask_Start(param0, ov5_021F0488, v3->unk_04); + FieldTask_InitCall(param0, ov5_021F0488, v3->unk_04); (*v2)++; break; case 5: diff --git a/src/overlay005/ov5_021F8370.c b/src/overlay005/ov5_021F8370.c index 6e97349a8b..c5e1ac054c 100644 --- a/src/overlay005/ov5_021F8370.c +++ b/src/overlay005/ov5_021F8370.c @@ -15,8 +15,8 @@ #include "heap.h" #include "savedata_misc.h" #include "script_manager.h" +#include "system_flags.h" #include "unk_02027F50.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef struct UnkStruct_ov5_021F8480_t UnkStruct_ov5_021F8480; @@ -174,7 +174,7 @@ static void ov5_021F8480(UnkStruct_ov5_021F8480 *param0, const u32 param1) static BOOL ov5_021F8508(FieldSystem *fieldSystem, u32 param1) { - return sub_0206AF6C(SaveData_GetVarsFlags(fieldSystem->saveData), 2, param1); + return SystemFlag_HandleOwnsVillaFurniture(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, param1); } static BOOL ov5_021F851C(int param0, int param1, const UnkStruct_ov5_0220192C *param2, FieldSystem *fieldSystem) diff --git a/src/overlay005/vs_seeker.c b/src/overlay005/vs_seeker.c index b676858b6f..e9ddd239b8 100644 --- a/src/overlay005/vs_seeker.c +++ b/src/overlay005/vs_seeker.c @@ -5,7 +5,6 @@ #include "consts/sdat.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" @@ -13,6 +12,7 @@ #include "overlay005/ov5_021DFB54.h" #include "bag.h" +#include "field_task.h" #include "heap.h" #include "map_header_data.h" #include "map_object.h" @@ -21,11 +21,10 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_02005474.h" #include "unk_0201D15C.h" -#include "unk_020508D4.h" #include "unk_020655F4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "vars_flags.h" @@ -100,7 +99,7 @@ typedef struct VsSeekerAnimationTask { } VsSeekerAnimationTask; static BOOL VsSeeker_IsMoveCodeHidden(u32 moveCode); -static BOOL VsSeeker_ExecuteTask(TaskManager *taskMan); +static BOOL VsSeeker_ExecuteTask(FieldTask *taskMan); static enum VsSeekerUsability VsSeekerSystem_CheckUsability(VsSeekerSystem *vsSeeker); static void VsSeekerSystem_SetState(VsSeekerSystem *vsSeeker, enum VsSeekerState state); static void VsSeekerSystem_CollectViableNpcs(VsSeekerSystem *vsSeeker); @@ -375,9 +374,9 @@ static const MapObjectAnimCmd sVsSeekerAnimSingleExclamationMark[] = { { 0xfe, 0x0 } }; -void VsSeeker_Start(TaskManager *taskMan, StringTemplate *template, u16 *outResult) +void VsSeeker_Start(FieldTask *taskMan, StringTemplate *template, u16 *outResult) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); VsSeekerSystem *vsSeeker = Heap_AllocFromHeap(4, sizeof(VsSeekerSystem)); if (vsSeeker == NULL) { @@ -392,15 +391,15 @@ void VsSeeker_Start(TaskManager *taskMan, StringTemplate *template, u16 *outResu vsSeeker->result = outResult; vsSeeker->template = template; - FieldTask_Start(taskMan, VsSeeker_ExecuteTask, vsSeeker); + FieldTask_InitCall(taskMan, VsSeeker_ExecuteTask, vsSeeker); return; } -static BOOL VsSeeker_ExecuteTask(TaskManager *taskMan) +static BOOL VsSeeker_ExecuteTask(FieldTask *taskMan) { s32 missingBattery, numDigits; enum VsSeekerUsability usability; - VsSeekerSystem *vsSeeker = TaskManager_Environment(taskMan); + VsSeekerSystem *vsSeeker = FieldTask_GetEnv(taskMan); switch (vsSeeker->state) { case VS_SEEKER_STATE_WAIT_FOR_NPCS: @@ -582,7 +581,7 @@ BOOL VsSeeker_UpdateStepCount(FieldSystem *fieldSystem) VsSeeker_SetBattery(varsFlags, battery); } - if (VsSeeker_GetUsedFlag(varsFlags) == TRUE) { + if (SystemFlag_CheckVsSeekerUsed(varsFlags) == TRUE) { if (activeStepCount < VS_SEEKER_MAX_NUM_ACTIVE_STEPS) { activeStepCount++; VsSeeker_SetActiveStepCount(varsFlags, activeStepCount); @@ -682,7 +681,7 @@ static BOOL VsSeekerSystem_PickRematchTrainers(VsSeekerSystem *vsSeeker) } anyAvailable = TRUE; - VsSeeker_SetUsedFlag(varsFlags); + SystemFlag_SetVsSeekerUsed(varsFlags); } } } @@ -748,7 +747,7 @@ static u16 VsSeeker_AdjustRematchLevel(FieldSystem *fieldSystem, u16 rematchData { VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - if (level != 0 && VsSeeker_HasUnlockedLevel(varsFlags, level) == FALSE) { + if (level != 0 && SystemFlag_CheckUnlockedVsSeekerLevel(varsFlags, level) == FALSE) { level = VsSeeker_GetNextLowerRematchLevel(rematchDataIndex, level); } diff --git a/src/overlay006/ov6_0223E140.c b/src/overlay006/ov6_0223E140.c index 1e287da073..5e5ced3bb8 100644 --- a/src/overlay006/ov6_0223E140.c +++ b/src/overlay006/ov6_0223E140.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_defs/struct_02099F80.h" @@ -26,6 +25,7 @@ #include "core_sys.h" #include "easy3d_object.h" #include "field_system.h" +#include "field_task.h" #include "graphics.h" #include "gx_layers.h" #include "heap.h" @@ -36,7 +36,6 @@ #include "sys_task_manager.h" #include "unk_02005474.h" #include "unk_0201D15C.h" -#include "unk_020508D4.h" #include "unk_020655F4.h" void include_unk_ov6_02248F30(); @@ -499,10 +498,10 @@ static void ov6_0223E318(FieldSystem *fieldSystem, u32 param1, BOOL param2) } } -static BOOL ov6_0223E33C(TaskManager *taskMan) +static BOOL ov6_0223E33C(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_0223E33C *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_0223E33C *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_0C) { case 0: @@ -521,16 +520,16 @@ static BOOL ov6_0223E33C(TaskManager *taskMan) return 0; } -void ov6_0223E384(TaskManager *taskMan) +void ov6_0223E384(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); UnkStruct_ov6_0223E33C *v1 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov6_0223E33C)); memset(v1, 0, sizeof(UnkStruct_ov6_0223E33C)); v1->unk_00 = ov6_0223FDE4(4); ov6_0223FE1C(v1->unk_00, (FX32_CONST(2.0f)), 0, 1, 16, fieldSystem->camera); - FieldTask_Start(taskMan, ov6_0223E33C, v1); + FieldTask_InitCall(taskMan, ov6_0223E33C, v1); } static void ov6_0223E3D8(UnkStruct_ov6_0223E33C *param0) @@ -549,10 +548,10 @@ static void ov6_0223E3D8(UnkStruct_ov6_0223E33C *param0) } } -static BOOL ov6_0223E408(TaskManager *param0) +static BOOL ov6_0223E408(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov6_0223E33C *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov6_0223E33C *v1 = FieldTask_GetEnv(param0); switch (v1->unk_0C) { case 0: @@ -608,9 +607,9 @@ static BOOL ov6_0223E408(TaskManager *param0) return 0; } -void ov6_0223E4EC(TaskManager *param0) +void ov6_0223E4EC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_ov6_0223E33C *v1 = Heap_AllocFromHeap(4, sizeof(UnkStruct_ov6_0223E33C)); memset(v1, 0, sizeof(UnkStruct_ov6_0223E33C)); @@ -619,7 +618,7 @@ void ov6_0223E4EC(TaskManager *param0) ov6_0223FE1C(v1->unk_00, (FX32_CONST(4.0f)), 0, 1, 24, fieldSystem->camera); v1->unk_08 = ov6_0223FFF4(v1->unk_00); - FieldTask_Start(param0, ov6_0223E408, v1); + FieldTask_InitCall(param0, ov6_0223E408, v1); } static void ov6_0223E548(UnkStruct_ov5_021D1BEC *param0, FieldSystem *fieldSystem, void *param2) diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index cc064acc3b..9e0659d3b9 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -12,7 +12,6 @@ #include "consts/items.h" #include "consts/pokemon.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202D7B0.h" #include "struct_defs/struct_0206C638.h" @@ -28,8 +27,10 @@ #include "overlay006/ov6_022477B8.h" #include "overlay006/wild_encounters.h" +#include "encounter.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "map_header.h" @@ -42,18 +43,17 @@ #include "roaming_pokemon.h" #include "rtc.h" #include "save_player.h" +#include "system_flags.h" #include "trainer_data.h" #include "trainer_info.h" #include "unk_0201D15C.h" #include "unk_0202631C.h" #include "unk_0202D7A8.h" -#include "unk_02050A74.h" #include "unk_02051D8C.h" #include "unk_02054884.h" #include "unk_02054D00.h" #include "unk_020559DC.h" #include "unk_0205DAC8.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "vars_flags.h" @@ -286,7 +286,7 @@ BOOL ov6_02240D5C(FieldSystem *fieldSystem) return FALSE; } - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData))) { v8 = TRUE; } else { v8 = FALSE; @@ -311,7 +311,7 @@ BOOL ov6_02240D5C(FieldSystem *fieldSystem) } if (!v8) { - v9 = sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)); + v9 = SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); ov6_02242328(fieldSystem, v9, &battleParams); } else { battleParams = sub_02051D8C(11, BATTLE_TYPE_AI_PARTNER); @@ -396,7 +396,7 @@ BOOL ov6_0224106C(FieldSystem *fieldSystem, const int fishingRodType, BattlePara return FALSE; } - BOOL v2 = sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)); + BOOL v2 = SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); ov6_02242328(fieldSystem, v2, battleParams); @@ -445,7 +445,7 @@ BOOL ov6_0224106C(FieldSystem *fieldSystem, const int fishingRodType, BattlePara return TRUE; } -BOOL ov6_022411C8(FieldSystem *fieldSystem, TaskManager *param1) +BOOL ov6_022411C8(FieldSystem *fieldSystem, FieldTask *param1) { BattleParams *battleParams; Pokemon *firstPartyMon; @@ -478,7 +478,7 @@ BOOL ov6_022411C8(FieldSystem *fieldSystem, TaskManager *param1) memset(&v9, 0, sizeof(UnkStruct_ov6_02241674)); - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData))) { v6 = TRUE; } else { v6 = FALSE; @@ -499,7 +499,7 @@ BOOL ov6_022411C8(FieldSystem *fieldSystem, TaskManager *param1) } if (!v6) { - v7 = sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)); + v7 = SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); ov6_02242328(fieldSystem, v7, &battleParams); } else { battleParams = sub_02051D8C(11, BATTLE_TYPE_AI_PARTNER); @@ -604,7 +604,7 @@ BOOL ov6_022413E4(FieldSystem *fieldSystem, BattleParams **battleParams) memset(&v9, 0, sizeof(UnkStruct_ov6_02241674)); v9.unk_0C = FALSE; - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData))) { v7 = TRUE; } else { v7 = FALSE; @@ -628,7 +628,7 @@ BOOL ov6_022413E4(FieldSystem *fieldSystem, BattleParams **battleParams) } if (!v7) { - v8 = sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData)); + v8 = SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); ov6_02242328(fieldSystem, v8, battleParams); } else { *battleParams = sub_02051D8C(11, BATTLE_TYPE_AI_PARTNER); diff --git a/src/overlay006/ov6_02242AF0.c b/src/overlay006/ov6_02242AF0.c index 6e48f09317..2c91d437ac 100644 --- a/src/overlay006/ov6_02242AF0.c +++ b/src/overlay006/ov6_02242AF0.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_02027860_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" @@ -15,12 +14,12 @@ #include "overlay006/struct_ov6_02242AF0.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "player_avatar.h" #include "savedata_misc.h" #include "unk_02005474.h" #include "unk_02027F50.h" -#include "unk_020508D4.h" #include "unk_020655F4.h" typedef struct UnkStruct_ov6_02242B58_t UnkStruct_ov6_02242B58; @@ -38,7 +37,7 @@ typedef struct UnkStruct_ov6_02242B58_t { int unk_10; } UnkStruct_ov6_02242B58; -static BOOL ov6_02242C5C(TaskManager *taskMan); +static BOOL ov6_02242C5C(FieldTask *taskMan); static BOOL ov6_02242D94(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3); static BOOL ov6_02242E60(FieldSystem *fieldSystem, UnkStruct_ov6_02242B58 *param1, const fx32 *param2, VecFx32 *param3); @@ -176,7 +175,7 @@ void ov6_02242B58(FieldSystem *fieldSystem, const u16 param1, const u16 param2) v2->unk_00 = ov6_02242E60; } - FieldTask_Start(fieldSystem->taskManager, ov6_02242C5C, v2); + FieldTask_InitCall(fieldSystem->task, ov6_02242C5C, v2); } u32 ov6_02242C3C(FieldSystem *fieldSystem, const u16 param1) @@ -194,10 +193,10 @@ u32 ov6_02242C3C(FieldSystem *fieldSystem, const u16 param1) } } -static BOOL ov6_02242C5C(TaskManager *taskMan) +static BOOL ov6_02242C5C(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_02242B58 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_02242B58 *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_05) { case 0: diff --git a/src/overlay006/ov6_02246A30.c b/src/overlay006/ov6_02246A30.c index b8b151ff32..a0721f620e 100644 --- a/src/overlay006/ov6_02246A30.c +++ b/src/overlay006/ov6_02246A30.c @@ -3,16 +3,18 @@ #include #include +#include "constants/savedata/vars_flags.h" + #include "struct_decls/pokedexdata_decl.h" #include "field/field_system.h" #include "inlines.h" #include "save_player.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0201D15C.h" #include "unk_0202631C.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef BOOL (*UnkStruct_ov6_022494B0)(FieldSystem *); @@ -96,37 +98,37 @@ static BOOL ov6_02246A34(FieldSystem *fieldSystem) static BOOL ov6_02246A38(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 7); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_JUBILIFE_CITY); } static BOOL ov6_02246A4C(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 2); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FLOAROMA_TOWN); } static BOOL ov6_02246A60(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 9); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_OREBURGH_CITY); } static BOOL ov6_02246A74(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 10); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_ETERNA_CITY); } static BOOL ov6_02246A88(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 11); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_HEARTHOME_CITY); } static BOOL ov6_02246A9C(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 17); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } static BOOL ov6_02246AB0(FieldSystem *fieldSystem) @@ -155,7 +157,7 @@ static BOOL ov6_02246AD8(FieldSystem *fieldSystem) static BOOL ov6_02246AE8(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return sub_0206A954(v0); + return SystemFlag_CheckGameCompleted(v0); } static int ov6_02246AF8(FieldSystem *fieldSystem, u8 *param1) diff --git a/src/overlay006/ov6_02246C24.c b/src/overlay006/ov6_02246C24.c index 84dbfbdd23..a15db87844 100644 --- a/src/overlay006/ov6_02246C24.c +++ b/src/overlay006/ov6_02246C24.c @@ -3,18 +3,16 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/ov5_021E15F4.h" #include "overlay005/ov5_021EF75C.h" #include "overlay005/struct_ov5_021E1890_decl.h" +#include "field_task.h" #include "heap.h" #include "unk_02005474.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" typedef struct { @@ -26,7 +24,7 @@ typedef struct { u8 unk_10[6]; } UnkStruct_ov6_02246C24; -static BOOL ov6_02246C9C(TaskManager *param0); +static BOOL ov6_02246C9C(FieldTask *param0); static VecFx32 Unk_ov6_0224989C[6] = { { -((FX32_ONE * 4) + (FX32_ONE / 2)), FX32_ONE * 12, -((FX32_ONE * 4) + (FX32_ONE / 2)) }, @@ -64,16 +62,16 @@ void ov6_02246C24(FieldSystem *fieldSystem, const u8 param1) v4->unk_00.z += v5.z; } - FieldTask_Start(fieldSystem->taskManager, ov6_02246C9C, v4); + FieldTask_InitCall(fieldSystem->task, ov6_02246C9C, v4); } else { GF_ASSERT(FALSE); } } -static BOOL ov6_02246C9C(TaskManager *param0) +static BOOL ov6_02246C9C(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov6_02246C24 *v1 = (UnkStruct_ov6_02246C24 *)TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov6_02246C24 *v1 = (UnkStruct_ov6_02246C24 *)FieldTask_GetEnv(param0); switch (v1->unk_0F) { case 0: { diff --git a/src/overlay006/ov6_02246F00.c b/src/overlay006/ov6_02246F00.c index bfda633b7d..e5f90a45a5 100644 --- a/src/overlay006/ov6_02246F00.c +++ b/src/overlay006/ov6_02246F00.c @@ -3,17 +3,15 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/ov5_021E15F4.h" #include "overlay005/ov5_021EF75C.h" #include "overlay005/struct_ov5_021E1890_decl.h" +#include "field_task.h" #include "heap.h" #include "unk_02005474.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" typedef struct { @@ -23,7 +21,7 @@ typedef struct { u8 unk_03; } UnkStruct_ov6_02246F00; -static BOOL ov6_02246F40(TaskManager *param0); +static BOOL ov6_02246F40(FieldTask *param0); void ov6_02246F00(FieldSystem *fieldSystem, const u8 param1, const u8 param2) { @@ -38,16 +36,16 @@ void ov6_02246F00(FieldSystem *fieldSystem, const u8 param1, const u8 param2) v1->unk_01 = param1; v1->unk_02 = 0; - FieldTask_Start(fieldSystem->taskManager, ov6_02246F40, v1); + FieldTask_InitCall(fieldSystem->task, ov6_02246F40, v1); } else { GF_ASSERT(FALSE); } } -static BOOL ov6_02246F40(TaskManager *param0) +static BOOL ov6_02246F40(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov6_02246F00 *v1 = (UnkStruct_ov6_02246F00 *)TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov6_02246F00 *v1 = (UnkStruct_ov6_02246F00 *)FieldTask_GetEnv(param0); switch (v1->unk_02) { case 0: { diff --git a/src/overlay006/ov6_02247100.c b/src/overlay006/ov6_02247100.c index 29b17622c5..267f7d9316 100644 --- a/src/overlay006/ov6_02247100.c +++ b/src/overlay006/ov6_02247100.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0203A790_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" @@ -14,6 +13,7 @@ #include "field_map_change.h" #include "field_overworld_state.h" +#include "field_task.h" #include "heap.h" #include "journal.h" #include "location.h" @@ -23,7 +23,6 @@ #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_0203A7D8.h" -#include "unk_020508D4.h" #include "unk_020655F4.h" typedef struct { @@ -41,9 +40,9 @@ typedef struct { static void *ov6_02247590(u32 param0, u32 param1); static void ov6_0224732C(FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param1); -int (*const Unk_ov6_022495CC[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *); -int (*const Unk_ov6_022495BC[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *); -int (*const Unk_ov6_022495F0[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *); +int (*const Unk_ov6_022495CC[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *); +int (*const Unk_ov6_022495BC[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *); +int (*const Unk_ov6_022495F0[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *); const MapObjectAnimCmd Unk_ov6_02249608[]; const MapObjectAnimCmd Unk_ov6_022495DC[]; @@ -60,11 +59,11 @@ void *ov6_02247100(FieldSystem *fieldSystem, u32 param1) return v0; } -BOOL ov6_02247120(TaskManager *taskMan) +BOOL ov6_02247120(FieldTask *taskMan) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); do { v0 = Unk_ov6_022495CC[v2->unk_00](taskMan, fieldSystem, v2); @@ -77,7 +76,7 @@ BOOL ov6_02247120(TaskManager *taskMan) return 0; } -static int ov6_0224715C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224715C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { param2->unk_14 = ov5_021F0EB0(fieldSystem, 4); ov5_021F0F10(param2->unk_14, 1, (FX32_ONE * -150), 15); @@ -99,7 +98,7 @@ static int ov6_0224715C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 0; } -static int ov6_022471C0(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022471C0(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -124,7 +123,7 @@ static int ov6_022471C0(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 0; } -static int ov6_02247244(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247244(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 1) { MapObject_FinishAnimation(param2->unk_0C); @@ -143,7 +142,7 @@ static int ov6_02247244(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 1; } -static int ov6_02247288(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247288(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData); @@ -162,7 +161,7 @@ static int ov6_02247288(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 2; } -static int (*const Unk_ov6_022495CC[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *) = { +static int (*const Unk_ov6_022495CC[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *) = { ov6_0224715C, ov6_022471C0, ov6_02247244, @@ -180,11 +179,11 @@ void *ov6_022472C8(FieldSystem *fieldSystem, u32 param1, int param2) return v0; } -BOOL ov6_022472E8(TaskManager *taskMan) +BOOL ov6_022472E8(FieldTask *taskMan) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); do { v0 = Unk_ov6_022495BC[v2->unk_00](taskMan, fieldSystem, v2); @@ -212,7 +211,7 @@ static void ov6_0224732C(FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param Journal_SaveData(fieldSystem->journal, v0, 1); } -static int ov6_02247354(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247354(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (param2->unk_08 == 2) { StartScreenTransition(0, 1, 1, 0x0, 6, 1, 4); @@ -228,7 +227,7 @@ static int ov6_02247354(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 0; } -static int ov6_022473C8(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022473C8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 1) { MapObject_FinishAnimation(param2->unk_0C); @@ -245,7 +244,7 @@ static int ov6_022473C8(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 1; } -static int ov6_0224740C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224740C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -265,7 +264,7 @@ static int ov6_0224740C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 0; } -static int ov6_02247458(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247458(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -281,7 +280,7 @@ static int ov6_02247458(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 2; } -static int (*const Unk_ov6_022495BC[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *) = { +static int (*const Unk_ov6_022495BC[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *) = { ov6_02247354, ov6_022473C8, ov6_0224740C, @@ -300,11 +299,11 @@ void *ov6_02247488(FieldSystem *fieldSystem, Pokemon *param1, u32 param2) return v0; } -BOOL ov6_022474AC(TaskManager *taskMan) +BOOL ov6_022474AC(FieldTask *taskMan) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); do { v0 = Unk_ov6_022495F0[v2->unk_00](taskMan, fieldSystem, v2); @@ -317,7 +316,7 @@ BOOL ov6_022474AC(TaskManager *taskMan) return 0; } -static int ov6_022474E8(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022474E8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { int v0 = PlayerAvatar_Gender(fieldSystem->playerAvatar); @@ -327,7 +326,7 @@ static int ov6_022474E8(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 0; } -static int ov6_0224750C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224750C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (ov6_02243FBC(param2->unk_10) == 0) { return 0; @@ -338,7 +337,7 @@ static int ov6_0224750C(TaskManager *taskMan, FieldSystem *fieldSystem, UnkStruc return 1; } -static int (*const Unk_ov6_022495F0[])(TaskManager *, FieldSystem *, UnkStruct_ov6_02247100 *) = { +static int (*const Unk_ov6_022495F0[])(FieldTask *, FieldSystem *, UnkStruct_ov6_02247100 *) = { ov6_022474E8, ov6_0224750C, ov6_0224715C, @@ -359,11 +358,11 @@ void *ov6_02247530(FieldSystem *fieldSystem, Pokemon *param1, u32 param2) return v0; } -BOOL ov6_02247554(TaskManager *taskMan) +BOOL ov6_02247554(FieldTask *taskMan) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); do { v0 = Unk_ov6_022495F0[v2->unk_00](taskMan, fieldSystem, v2); diff --git a/src/overlay006/ov6_02247A0C.c b/src/overlay006/ov6_02247A0C.c index 067ee187b2..fd136c6716 100644 --- a/src/overlay006/ov6_02247A0C.c +++ b/src/overlay006/ov6_02247A0C.c @@ -3,13 +3,12 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "bg_window.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "font.h" #include "heap.h" #include "message.h" @@ -20,7 +19,6 @@ #include "string_template.h" #include "text.h" #include "unk_0202F108.h" -#include "unk_020508D4.h" typedef struct { Window unk_00; @@ -40,7 +38,7 @@ typedef struct { } UnkStruct_ov6_02247A0C; static int ov6_02247CF4(const Strbuf *param0, int param1, int param2, int param3); -static BOOL ov6_02247A34(TaskManager *param0); +static BOOL ov6_02247A34(FieldTask *param0); static const UnkStruct_ov6_022496F4 Unk_ov6_022496F4[] = { { 0x2, 0x8, 0x38 }, @@ -90,20 +88,20 @@ static const UnkStruct_ov6_022496F4 Unk_ov6_0224971C[][4] = { }, }; -void ov6_02247A0C(TaskManager *param0) +void ov6_02247A0C(FieldTask *param0) { UnkStruct_ov6_02247A0C *v0; v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov6_02247A0C)); MI_CpuClear8(v0, sizeof(UnkStruct_ov6_02247A0C)); - FieldTask_Start(param0, ov6_02247A34, v0); + FieldTask_InitCall(param0, ov6_02247A34, v0); } -static BOOL ov6_02247A34(TaskManager *param0) +static BOOL ov6_02247A34(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov6_02247A0C *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov6_02247A0C *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: diff --git a/src/overlay006/ov6_02247D30.c b/src/overlay006/ov6_02247D30.c index a47fa3103a..8d5b7c04b2 100644 --- a/src/overlay006/ov6_02247D30.c +++ b/src/overlay006/ov6_02247D30.c @@ -3,17 +3,15 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/ov5_021E15F4.h" #include "overlay005/ov5_021EF75C.h" #include "overlay005/struct_ov5_021E1890_decl.h" +#include "field_task.h" #include "heap.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" typedef struct { @@ -25,7 +23,7 @@ typedef struct { u8 unk_10[6]; } UnkStruct_ov6_02247D30; -static BOOL ov6_02247DAC(TaskManager *param0); +static BOOL ov6_02247DAC(FieldTask *param0); static VecFx32 Unk_ov6_022498E4[6] = { { -((FX32_ONE * 4) + (FX32_ONE / 2)), FX32_ONE * 12, -((FX32_ONE * 4) + (FX32_ONE / 2)) }, @@ -62,16 +60,16 @@ void ov6_02247D30(FieldSystem *fieldSystem, const u8 param1) v4->unk_00.z += v5.z; } - FieldTask_Start(fieldSystem->taskManager, ov6_02247DAC, v4); + FieldTask_InitCall(fieldSystem->task, ov6_02247DAC, v4); } else { GF_ASSERT(FALSE); } } -static BOOL ov6_02247DAC(TaskManager *param0) +static BOOL ov6_02247DAC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov6_02247D30 *v1 = (UnkStruct_ov6_02247D30 *)TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov6_02247D30 *v1 = (UnkStruct_ov6_02247D30 *)FieldTask_GetEnv(param0); switch (v1->unk_0F) { case 0: { diff --git a/src/overlay006/ov6_02247F5C.c b/src/overlay006/ov6_02247F5C.c index d06a35a8de..42f8e699e7 100644 --- a/src/overlay006/ov6_02247F5C.c +++ b/src/overlay006/ov6_02247F5C.c @@ -3,23 +3,21 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/ov5_021D37AC.h" #include "overlay005/struct_ov5_021D3CE4_decl.h" -#include "unk_020508D4.h" -#include "unk_0206A8DC.h" +#include "field_task.h" +#include "system_flags.h" #include "vars_flags.h" -static BOOL ov6_02247FD0(TaskManager *param0); +static BOOL ov6_02247FD0(FieldTask *param0); void ov6_02247F5C(FieldSystem *fieldSystem) { UnkStruct_ov5_021D3CE4 *v0; - if (!sub_0206ADEC(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (!SystemFlag_CheckFreedGalacticHQPokemon(SaveData_GetVarsFlags(fieldSystem->saveData))) { v0 = ov5_021D3DE4(496, 1, fieldSystem->unk_50); ov5_021D3F08(v0, 1); ov5_021D3E40(v0, 1); @@ -35,14 +33,14 @@ void ov6_02247F5C(FieldSystem *fieldSystem) void ov6_02247FBC(FieldSystem *fieldSystem) { - FieldTask_Start(fieldSystem->taskManager, ov6_02247FD0, NULL); + FieldTask_InitCall(fieldSystem->task, ov6_02247FD0, NULL); } -static BOOL ov6_02247FD0(TaskManager *param0) +static BOOL ov6_02247FD0(FieldTask *param0) { int *v0; UnkStruct_ov5_021D3CE4 *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); v0 = FieldTask_GetState(param0); diff --git a/src/overlay007/ov7_0224B4E8.c b/src/overlay007/ov7_0224B4E8.c index f5ee46038c..b12090cbe4 100644 --- a/src/overlay007/ov7_0224B4E8.c +++ b/src/overlay007/ov7_0224B4E8.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02098700_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202610C.h" @@ -12,6 +11,7 @@ #include "bg_window.h" #include "core_sys.h" +#include "field_task.h" #include "font.h" #include "heap.h" #include "list_menu.h" @@ -26,7 +26,6 @@ #include "unk_02005474.h" #include "unk_0202602C.h" #include "unk_02026150.h" -#include "unk_020508D4.h" #include "unk_0205D8CC.h" #include "unk_0207A2A8.h" @@ -450,10 +449,10 @@ static BOOL ov7_0224BBC4(UnkStruct_ov7_0224B4E8 *param0) return 0; } -static BOOL ov7_0224BC74(TaskManager *param0) +static BOOL ov7_0224BC74(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov7_0224B4E8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov7_0224B4E8 *v1 = FieldTask_GetEnv(param0); int v2; switch (v1->unk_7C) { @@ -569,11 +568,11 @@ static UnkStruct_ov7_0224B4E8 *ov7_0224BE10(FieldSystem *fieldSystem) return v0; } -void ov7_0224BE7C(TaskManager *param0, u16 *param1) +void ov7_0224BE7C(FieldTask *param0, u16 *param1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_ov7_0224B4E8 *v1 = ov7_0224BE10(fieldSystem); v1->unk_70 = param1; - FieldTask_Start(param0, ov7_0224BC74, v1); + FieldTask_InitCall(param0, ov7_0224BC74, v1); } diff --git a/src/overlay007/ov7_0224CD28.c b/src/overlay007/ov7_0224CD28.c index 4903036a0c..8cba367376 100644 --- a/src/overlay007/ov7_0224CD28.c +++ b/src/overlay007/ov7_0224CD28.c @@ -5,8 +5,6 @@ #include "consts/game_records.h" -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/fieldmap.h" #include "overlay005/ov5_021D2F14.h" @@ -19,6 +17,7 @@ #include "camera.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_task.h" #include "font.h" #include "game_options.h" #include "game_records.h" @@ -50,7 +49,6 @@ #include "unk_0202C9F4.h" #include "unk_0202D05C.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_020573FC.h" #include "unk_0205D8CC.h" #include "unk_0206AFE0.h" @@ -90,7 +88,7 @@ static u8 ov7_0224E5B0(UnkStruct_ov7_0224D008 *param0); static u8 ov7_0224EA2C(UnkStruct_ov7_0224D008 *param0); static void ov7_0224EA54(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param1); static void ov7_0224EC20(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param1); -static void ov7_0224EC38(TaskManager *param0); +static void ov7_0224EC38(FieldTask *param0); static u8 ov7_0224EC9C(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param1); static void ov7_0224EAD0(UnkStruct_ov7_0224D008 *param0); static void ov7_0224EB14(UnkStruct_ov7_0224D008 *param0); @@ -181,7 +179,7 @@ static UnkStruct_ov7_0224D008 *ov7_0224CD88(void) return v0; } -void ov7_0224CDA4(TaskManager *param0, FieldSystem *fieldSystem, u16 *param2, u8 param3, BOOL param4) +void ov7_0224CDA4(FieldTask *param0, FieldSystem *fieldSystem, u16 *param2, u8 param3, BOOL param4) { UnkStruct_ov7_0224D008 *v0 = ov7_0224CD88(); @@ -210,7 +208,7 @@ void ov7_0224CDA4(TaskManager *param0, FieldSystem *fieldSystem, u16 *param2, u8 } ov7_0224CD28(v0, param2); - FieldTask_Start(param0, ov7_0224CEAC, v0); + FieldTask_InitCall(param0, ov7_0224CEAC, v0); } static u8 ov7_0224CE90(FieldSystem *fieldSystem) @@ -224,13 +222,13 @@ static u8 ov7_0224CE90(FieldSystem *fieldSystem) return 8; } -BOOL ov7_0224CEAC(TaskManager *param0) +BOOL ov7_0224CEAC(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_ov7_0224D008 *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); switch (v1->unk_297) { case 0: @@ -1523,7 +1521,7 @@ static void ov7_0224EC20(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param param1->unk_297 = 15; } -static void ov7_0224EC38(TaskManager *param0) +static void ov7_0224EC38(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_ov7_0224D008 *v1; @@ -1532,8 +1530,8 @@ static void ov7_0224EC38(TaskManager *param0) return; } - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); ov7_0224D21C(v1); @@ -1547,7 +1545,7 @@ static void ov7_0224EC38(TaskManager *param0) } sub_0203D1E4(fieldSystem, v1->unk_04); - FieldTask_Change(param0, sub_0209AC14, v1); + FieldTask_InitJump(param0, sub_0209AC14, v1); v1->unk_297 = 16; } diff --git a/src/overlay008/ov8_02249960.c b/src/overlay008/ov8_02249960.c index 55c8972f08..91499074c6 100644 --- a/src/overlay008/ov8_02249960.c +++ b/src/overlay008/ov8_02249960.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_02027860_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061830_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -39,6 +38,7 @@ #include "camera.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "map_header_data.h" #include "map_object.h" @@ -56,7 +56,6 @@ #include "unk_02005474.h" #include "unk_0201D15C.h" #include "unk_02027F50.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_0205D8CC.h" #include "unk_0205DAC8.h" @@ -302,16 +301,16 @@ void include_ov8_02249960(void); static u8 ov8_02249960(const u8 param0, const int param1); static void ov8_0224996C(const u8 param0, int *param1); -static BOOL ov8_02249A94(TaskManager *param0); -static BOOL ov8_02249B74(TaskManager *param0); -static BOOL ov8_02249CD8(TaskManager *param0); +static BOOL ov8_02249A94(FieldTask *param0); +static BOOL ov8_02249B74(FieldTask *param0); +static BOOL ov8_02249CD8(FieldTask *param0); static void ov8_02249F14(const u8 param0, UnkStruct_ov5_021D3CAC *param1); -static BOOL ov8_0224A018(TaskManager *param0); -static BOOL ov8_0224A0E8(TaskManager *param0); -static BOOL ov8_0224A4FC(TaskManager *param0); -static BOOL ov8_0224A620(TaskManager *param0); -static BOOL ov8_0224A770(TaskManager *param0); -static BOOL ov8_0224ADE8(TaskManager *param0); +static BOOL ov8_0224A018(FieldTask *param0); +static BOOL ov8_0224A0E8(FieldTask *param0); +static BOOL ov8_0224A4FC(FieldTask *param0); +static BOOL ov8_0224A620(FieldTask *param0); +static BOOL ov8_0224A770(FieldTask *param0); +static BOOL ov8_0224ADE8(FieldTask *param0); static void ov8_0224B8D0(UnkStruct_ov8_0224B8D0 *param0); static void ov8_0224B958(UnkStruct_ov8_0224B8D0 *param0); static void ov8_0224BFCC(FieldSystem *fieldSystem, UnkStruct_ov8_0224C098 *param1, UnkStruct_ov8_0224B80C *param2, int param3); @@ -367,13 +366,13 @@ void ov8_0224997C(FieldSystem *fieldSystem) v6->unk_00 = 0; if (v4 == 239) { - FieldTask_Start(fieldSystem->taskManager, ov8_02249CD8, v6); + FieldTask_InitCall(fieldSystem->task, ov8_02249CD8, v6); v8->unk_00 = 2; } else if (v4 == 240) { - FieldTask_Start(fieldSystem->taskManager, ov8_02249B74, v6); + FieldTask_InitCall(fieldSystem->task, ov8_02249B74, v6); v8->unk_00 = 1; } else if (v4 == 241) { - FieldTask_Start(fieldSystem->taskManager, ov8_02249A94, v6); + FieldTask_InitCall(fieldSystem->task, ov8_02249A94, v6); v8->unk_00 = 0; } else { GF_ASSERT(FALSE); @@ -408,11 +407,11 @@ BOOL ov8_02249A40(FieldSystem *fieldSystem, const int param1, const int param2, return 0; } -static BOOL ov8_02249A94(TaskManager *taskMan) +static BOOL ov8_02249A94(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -460,11 +459,11 @@ static BOOL ov8_02249A94(TaskManager *taskMan) return 0; } -static BOOL ov8_02249B74(TaskManager *taskMan) +static BOOL ov8_02249B74(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -547,11 +546,11 @@ static BOOL ov8_02249B74(TaskManager *taskMan) return 0; } -static BOOL ov8_02249CD8(TaskManager *taskMan) +static BOOL ov8_02249CD8(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -762,20 +761,20 @@ void ov8_02249FB8(FieldSystem *fieldSystem) PlayerAvatar_PosVectorOut(fieldSystem->playerAvatar, &v1); if (v1.y == (FX32_ONE * 16 * 0)) { - FieldTask_Start(fieldSystem->taskManager, ov8_0224A018, v0); + FieldTask_InitCall(fieldSystem->task, ov8_0224A018, v0); v3->unk_00 = 1; } else { - FieldTask_Start(fieldSystem->taskManager, ov8_0224A0E8, v0); + FieldTask_InitCall(fieldSystem->task, ov8_0224A0E8, v0); v3->unk_00 = 0; } } } -static BOOL ov8_0224A018(TaskManager *taskMan) +static BOOL ov8_0224A018(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -817,11 +816,11 @@ static BOOL ov8_0224A018(TaskManager *taskMan) return 0; } -static BOOL ov8_0224A0E8(TaskManager *taskMan) +static BOOL ov8_0224A0E8(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -1267,7 +1266,7 @@ static void ov8_0224A254(UnkStruct_ov8_0224A1E4 *param0, const u8 param1) param0->unk_40[param1] = Unk_ov8_0224CB68[param1].unk_07; } - FieldTask_Set(param0->fieldSystem, ov8_0224A620, v2); + FieldSystem_CreateTask(param0->fieldSystem, ov8_0224A620, v2); } else if (v0 == 294) { if (v1) { param0->unk_F0 = 2; @@ -1279,7 +1278,7 @@ static void ov8_0224A254(UnkStruct_ov8_0224A1E4 *param0, const u8 param1) param0->unk_40[param1] = Unk_ov8_0224CB68[param1].unk_07; } - FieldTask_Set(param0->fieldSystem, ov8_0224A770, v2); + FieldSystem_CreateTask(param0->fieldSystem, ov8_0224A770, v2); } else { if (v1) { param0->unk_F0 = 1; @@ -1292,7 +1291,7 @@ static void ov8_0224A254(UnkStruct_ov8_0224A1E4 *param0, const u8 param1) param0->unk_40[param1] = Unk_ov8_0224CB68[param1].unk_07; } - FieldTask_Set(param0->fieldSystem, ov8_0224A4FC, v2); + FieldSystem_CreateTask(param0->fieldSystem, ov8_0224A4FC, v2); } } @@ -1331,11 +1330,11 @@ static void ov8_0224A434(UnkStruct_ov8_0224A1E4 *param0, const fx32 param1) } } -static BOOL ov8_0224A4FC(TaskManager *taskMan) +static BOOL ov8_0224A4FC(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(taskMan); UnkStruct_ov8_0224A1E4 *v3; v3 = (UnkStruct_ov8_0224A1E4 *)fieldSystem->unk_04->unk_24; @@ -1397,12 +1396,12 @@ static BOOL ov8_0224A4FC(TaskManager *taskMan) return 0; } -static BOOL ov8_0224A620(TaskManager *taskMan) +static BOOL ov8_0224A620(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; MapObject *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v3 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v3 = FieldTask_GetEnv(taskMan); UnkStruct_ov8_0224A1E4 *v4; v4 = (UnkStruct_ov8_0224A1E4 *)fieldSystem->unk_04->unk_24; @@ -1479,12 +1478,12 @@ static BOOL ov8_0224A620(TaskManager *taskMan) return 0; } -static BOOL ov8_0224A770(TaskManager *taskMan) +static BOOL ov8_0224A770(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; MapObject *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224997C *v3 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224997C *v3 = FieldTask_GetEnv(taskMan); UnkStruct_ov8_0224A1E4 *v4; v4 = (UnkStruct_ov8_0224A1E4 *)fieldSystem->unk_04->unk_24; @@ -2207,15 +2206,15 @@ void ov8_0224AD34(FieldSystem *fieldSystem, const u8 param1) v1->unk_13 = v4; Sound_PlayEffect(1599); - FieldTask_Start(fieldSystem->taskManager, ov8_0224ADE8, v0); + FieldTask_InitCall(fieldSystem->task, ov8_0224ADE8, v0); } } -static BOOL ov8_0224ADE8(TaskManager *param0) +static BOOL ov8_0224ADE8(FieldTask *param0) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov8_0224997C *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov8_0224997C *v2 = FieldTask_GetEnv(param0); UnkStruct_ov8_0224ABD4 *v3; v3 = (UnkStruct_ov8_0224ABD4 *)fieldSystem->unk_04->unk_24; @@ -2712,11 +2711,11 @@ static BOOL ov8_0224B370(UnkStruct_ov8_0224AF00 *param0, const fx32 param1, cons return v0; } -static BOOL ov8_0224B3D4(TaskManager *param0) +static BOOL ov8_0224B3D4(FieldTask *param0) { BOOL v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov8_0224B67C *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov8_0224B67C *v2 = FieldTask_GetEnv(param0); UnkStruct_02071BD0 *v3 = v2->unk_14; UnkStruct_ov8_0224AF00 *v4 = v2->unk_18; @@ -2906,7 +2905,7 @@ BOOL ov8_0224B67C(FieldSystem *fieldSystem, Window *param1, MessageLoader *param v2->unk_14 = v1; v2->unk_18 = v3; - FieldTask_Start(fieldSystem->taskManager, ov8_0224B3D4, v2); + FieldTask_InitCall(fieldSystem->task, ov8_0224B3D4, v2); } return 1; @@ -3213,11 +3212,11 @@ static u32 ov8_0224BAA0(UnkStruct_ov8_0224B8D0 *param0, int param1, int param2, return v0; } -static BOOL ov8_0224BAF4(TaskManager *taskMan) +static BOOL ov8_0224BAF4(FieldTask *taskMan) { MapObject *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_ov8_0224C098 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_ov8_0224C098 *v2 = FieldTask_GetEnv(taskMan); UnkStruct_ov8_0224B8D0 *v3 = v2->unk_3C; v0 = Player_MapObject(fieldSystem->playerAvatar); @@ -3242,12 +3241,12 @@ static BOOL ov8_0224BAF4(TaskManager *taskMan) return 0; } -static BOOL ov8_0224BB78(TaskManager *taskMan) +static BOOL ov8_0224BB78(FieldTask *taskMan) { int v0; UnkStruct_ov8_0224C098 *v1; - v1 = TaskManager_Environment(taskMan); + v1 = FieldTask_GetEnv(taskMan); do { v0 = Unk_ov8_0224C818[v1->unk_00](v1); @@ -3511,13 +3510,13 @@ static UnkStruct_ov8_0224C098 *ov8_0224BED8(UnkStruct_ov8_0224B8D0 *param0, UnkS static void ov8_0224BF0C(FieldSystem *fieldSystem, UnkStruct_ov8_0224B8D0 *param1, UnkStruct_ov8_0224BCA8 *param2, int param3) { UnkStruct_ov8_0224C098 *v0 = ov8_0224BED8(param1, param2, param3); - FieldTask_Set(fieldSystem, ov8_0224BAF4, v0); + FieldSystem_CreateTask(fieldSystem, ov8_0224BAF4, v0); } static void ov8_0224BF2C(FieldSystem *fieldSystem, UnkStruct_ov8_0224B8D0 *param1, UnkStruct_ov8_0224BCA8 *param2, int param3) { UnkStruct_ov8_0224C098 *v0 = ov8_0224BED8(param1, param2, param3); - FieldTask_Set(fieldSystem, ov8_0224BB78, v0); + FieldSystem_CreateTask(fieldSystem, ov8_0224BB78, v0); } BOOL ov8_0224BF4C(FieldSystem *fieldSystem) diff --git a/src/overlay009/ov9_02249960.c b/src/overlay009/ov9_02249960.c index 9b42dbd7cd..7746850b92 100644 --- a/src/overlay009/ov9_02249960.c +++ b/src/overlay009/ov9_02249960.c @@ -6,7 +6,6 @@ #include "struct_decls/struct_020216E0_decl.h" #include "struct_decls/struct_02027860_decl.h" #include "struct_decls/struct_02039E30_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061830_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -43,6 +42,7 @@ #include "camera.h" #include "cell_actor.h" #include "field_system.h" +#include "field_task.h" #include "gx_layers.h" #include "heap.h" #include "map_header_data.h" @@ -56,6 +56,7 @@ #include "sprite_resource.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_02005474.h" #include "unk_020093B4.h" #include "unk_0200A328.h" @@ -65,11 +66,9 @@ #include "unk_02020AEC.h" #include "unk_02027F50.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_0205DAC8.h" #include "unk_0205F180.h" #include "unk_020655F4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_020711EC.h" #include "unk_02073838.h" @@ -526,7 +525,7 @@ typedef struct { u8 unk_0C[160]; } UnkFuncPtr_ov9_0224E33C; -typedef int (*UnkFuncPtr_ov9_02253BE4)(UnkStruct_ov9_02249B04 *, TaskManager *, u16 *, const void *); +typedef int (*UnkFuncPtr_ov9_02253BE4)(UnkStruct_ov9_02249B04 *, FieldTask *, u16 *, const void *); typedef struct { s16 unk_00; @@ -724,7 +723,7 @@ typedef struct { struct UnkStruct_ov9_0224F6EC_t { UnkStruct_ov9_02249B04 *unk_00; FieldSystem *fieldSystem; - TaskManager *unk_08; + FieldTask *unk_08; MapObject *unk_0C; u16 unk_10; u16 unk_12; @@ -917,7 +916,7 @@ static void ov9_0224A8C0(UnkStruct_ov9_02249B04 *param0); static void ov9_0224A9E8(UnkStruct_ov9_02249B04 *param0); static BOOL ov9_0224AA00(UnkStruct_ov9_02249B04 *param0, int param1, int param2, int param3, int param4); static void ov9_0224AA34(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_0224AA00 *param1); -static BOOL ov9_0224AAD4(TaskManager *param0); +static BOOL ov9_0224AAD4(FieldTask *param0); static BOOL ov9_0224AC58(UnkStruct_ov9_0224AC58 *param0, MapObject *param1); static void ov9_0224ADC0(UnkStruct_ov9_02249B04 *param0); static void ov9_0224AED8(UnkStruct_ov9_02249B04 *param0); @@ -1032,7 +1031,7 @@ static void ov9_0224CC50(UnkStruct_ov9_02249B04 *param0, UnkStruct_ov9_0224E0DC static BOOL ov9_0224CC7C(UnkStruct_ov9_02249B04 *param0); static BOOL ov9_0224D040(UnkStruct_ov9_02249B04 *param0, int param1, int param2, int param3); static void ov9_0224D078(UnkStruct_ov9_02249B04 *param0, UnkStruct_ov9_0224E0DC *param1); -static BOOL ov9_0224D098(TaskManager *param0); +static BOOL ov9_0224D098(FieldTask *param0); static const UnkStruct_ov9_022530A4 *ov9_0224D720(int param0); static void ov9_0224D744(UnkStruct_ov9_02249B04 *param0); static void ov9_0224D780(UnkStruct_ov9_02249B04 *param0, u32 param1); @@ -1084,11 +1083,11 @@ static void ov9_0224E34C(UnkStruct_ov9_02249B04 *param0); static void ov9_0224E350(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02251438 *param1); static void *ov9_0224E37C(UnkStruct_ov9_02249B04 *param0, u32 param1); static void *ov9_0224E39C(UnkStruct_ov9_02249B04 *param0); -static BOOL ov9_0224E3A0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1); +static BOOL ov9_0224E3A0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1); static BOOL ov9_0224E434(UnkStruct_ov9_02249B04 *param0, int param1, int param2, int param3); static void ov9_0224E498(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02251438 *param1); static void ov9_0224E4B0(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02252044 *param1); -static BOOL ov9_0224E4BC(TaskManager *param0); +static BOOL ov9_0224E4BC(FieldTask *param0); static void ov9_0224E8B4(UnkStruct_ov9_02249B04 *param0); static void ov9_0224E8EC(UnkStruct_ov9_02249B04 *param0); static void ov9_0224E91C(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02252414 *param1); @@ -1356,7 +1355,7 @@ static void ov9_02249CC4(UnkStruct_ov9_02249B04 *param0) ov9_02249D68(param0, v2); } - if (sub_0206AFC0(v1, 2) == 0) { + if (SystemFlag_HandleDistortionWorldPuzzleFinished(v1, HANDLE_FLAG_CHECK) == FALSE) { v0->unk_0C |= ((1 << 0) | (1 << 1) | (1 << 2)); } else { v0->unk_0C |= ((1 << 10) | (1 << 11) | (1 << 12) | (1 << 6) | (1 << 7) | (1 << 8)); @@ -2343,13 +2342,13 @@ static void ov9_0224AA34(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_022 v0->unk_28.z = -v0->unk_28.z; } - FieldTask_Set(param0->fieldSystem, ov9_0224AAD4, param0); + FieldSystem_CreateTask(param0->fieldSystem, ov9_0224AAD4, param0); } -static BOOL ov9_0224AAD4(TaskManager *param0) +static BOOL ov9_0224AAD4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov9_02249B04 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov9_02249B04 *v1 = FieldTask_GetEnv(param0); UnkStruct_ov9_0224AC58 *v2 = ov9_0224A598(v1); PlayerAvatar *playerAvatar = fieldSystem->playerAvatar; MapObject *v4 = Player_MapObject(playerAvatar); @@ -4909,13 +4908,13 @@ static void ov9_0224D078(UnkStruct_ov9_02249B04 *param0, UnkStruct_ov9_0224E0DC v0 = ov9_0224A578(param0, sizeof(UnkStruct_ov9_0224D078)); v0->unk_64 = param1; - FieldTask_Set(param0->fieldSystem, ov9_0224D098, param0); + FieldSystem_CreateTask(param0->fieldSystem, ov9_0224D098, param0); } -static BOOL ov9_0224D098(TaskManager *param0) +static BOOL ov9_0224D098(FieldTask *param0) { int v0; - UnkStruct_ov9_02249B04 *v1 = TaskManager_Environment(param0); + UnkStruct_ov9_02249B04 *v1 = FieldTask_GetEnv(param0); UnkStruct_ov9_0224D078 *v2 = ov9_0224A598(v1); do { @@ -6072,7 +6071,7 @@ static int ov9_0224E1CC(UnkStruct_ov101_021D5D90 *param0, void *param1) if (v2->unk_08 == 1) { VarsFlags *v5 = SaveData_GetVarsFlags(v2->unk_0C->fieldSystem->saveData); - if (sub_0206AFD0(v5) == 0) { + if (SystemFlag_CheckDistortionWorldSteppingStones(v5) == 0) { v1->unk_02 = 0; v1->unk_00 = 1; v1->unk_01 = 1; @@ -6102,7 +6101,7 @@ static void ov9_0224E294(UnkStruct_ov101_021D5D90 *param0, void *param1) v1 = SaveData_GetVarsFlags(v0->unk_10.unk_0C->fieldSystem->saveData); - if (sub_0206AFD0(v1) == 1) { + if (SystemFlag_CheckDistortionWorldSteppingStones(v1) == 1) { v0->unk_01 = 0; if (v0->unk_02 < 31) { @@ -6197,7 +6196,7 @@ static void *ov9_0224E39C(UnkStruct_ov9_02249B04 *param0) return v0; } -static BOOL ov9_0224E3A0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1) +static BOOL ov9_0224E3A0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1) { int v0; int v1; @@ -6276,7 +6275,7 @@ static BOOL ov9_0224E434(UnkStruct_ov9_02249B04 *param0, int param1, int param2, static void ov9_0224E498(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02251438 *param1) { ov9_0224E350(param0, param1); - FieldTask_Set(param0->fieldSystem, ov9_0224E4BC, param0); + FieldSystem_CreateTask(param0->fieldSystem, ov9_0224E4BC, param0); } static void ov9_0224E4B0(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_02252044 *param1) @@ -6284,9 +6283,9 @@ static void ov9_0224E4B0(UnkStruct_ov9_02249B04 *param0, const UnkStruct_ov9_022 ov9_0224E498(param0, param1->unk_0C); } -static BOOL ov9_0224E4BC(TaskManager *param0) +static BOOL ov9_0224E4BC(FieldTask *param0) { - UnkStruct_ov9_02249B04 *v0 = TaskManager_Environment(param0); + UnkStruct_ov9_02249B04 *v0 = FieldTask_GetEnv(param0); if (ov9_0224E3A0(v0, param0) == 1) { return 1; @@ -6295,7 +6294,7 @@ static BOOL ov9_0224E4BC(TaskManager *param0) return 0; } -static int ov9_0224E4D8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E4D8(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_0224E4D8 *v0 = ov9_0224E37C(param0, sizeof(UnkStruct_ov9_0224E4D8)); @@ -6303,7 +6302,7 @@ static int ov9_0224E4D8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 1; } -static int ov9_0224E4E8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E4E8(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { MapObject *v0; const UnkStruct_ov9_0224E4E8 *v1 = param3; @@ -6320,7 +6319,7 @@ static int ov9_0224E4E8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224E520(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E520(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { MapObject *v0; const UnkStruct_ov9_0224E4E8 *v1 = param3; @@ -6342,7 +6341,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251360[3] = { ov9_0224E520 }; -static int ov9_0224E550(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E550(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_0224E550 *v0 = param3; UnkStruct_ov9_0224E5EC *v1 = ov9_0224E37C(param0, sizeof(UnkStruct_ov9_0224E5EC)); @@ -6379,7 +6378,7 @@ static int ov9_0224E550(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224E5EC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E5EC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { MapObject *v0 = NULL; const UnkStruct_ov9_0224E550 *v1 = param3; @@ -6437,7 +6436,7 @@ static int ov9_0224E5EC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224E6B0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E6B0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { VecFx32 v0 = { 0, 0, 0 }; const UnkStruct_ov9_0224E550 *v1 = param3; @@ -6491,7 +6490,7 @@ static int ov9_0224E6B0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224E798(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E798(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_0224E550 *v0 = param3; @@ -6535,7 +6534,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_022513E8[4] = { ov9_0224E798 }; -static int ov9_0224E860(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E860(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_0224E860 *v0 = param3; @@ -6547,7 +6546,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251258[1] = { ov9_0224E860 }; -static int ov9_0224E870(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224E870(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_0224E870 *v0 = param3; @@ -7406,7 +7405,7 @@ BOOL ov9_0224F2B0(const MapObject *param0) return ov9_0224F284(param0, &v0); } -UnkStruct_ov9_0224F6EC *ov9_0224F2BC(FieldSystem *fieldSystem, TaskManager *param1, MapObject *param2) +UnkStruct_ov9_0224F6EC *ov9_0224F2BC(FieldSystem *fieldSystem, FieldTask *param1, MapObject *param2) { UnkStruct_ov9_0224F6EC *v0; @@ -7639,7 +7638,7 @@ static BOOL ov9_0224F3BC(UnkStruct_ov9_0224F6EC *param0) if (v17 >= 3) { VarsFlags *v18 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - sub_0206AFC0(v18, 1); + SystemFlag_HandleDistortionWorldPuzzleFinished(v18, HANDLE_FLAG_SET); } } @@ -8025,7 +8024,7 @@ static void ov9_0224FA94(UnkStruct_ov9_02249B04 *param0, UnkStruct_ov9_0224FA94 } } -static int ov9_0224FB3C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224FB3C(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { VecFx32 v0; UnkStruct_ov9_0224F930 *v1; @@ -8088,7 +8087,7 @@ static int ov9_0224FB3C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224FC2C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224FC2C(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { MapObject *v0 = Player_MapObject(param0->fieldSystem->playerAvatar); UnkStruct_ov9_0224FA94 *v1 = ov9_0224E39C(param0); @@ -8159,7 +8158,7 @@ static int ov9_0224FC2C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224FD74(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224FD74(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { int v0; UnkStruct_ov101_021D5D90 *v1 = sub_0205EC04(param0->fieldSystem->playerAvatar); @@ -8235,7 +8234,7 @@ static int ov9_0224FD74(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0224FEDC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0224FEDC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { int v0; UnkStruct_ov101_021D5D90 *v1 = sub_0205EC04(param0->fieldSystem->playerAvatar); @@ -8322,7 +8321,7 @@ static int ov9_0224FEDC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022500E0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022500E0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { u32 v0[2] = { 0xa, 0x6 }; UnkStruct_ov9_0224FA94 *v1 = ov9_0224E39C(param0); @@ -8369,7 +8368,7 @@ static void ov9_02250138(UnkStruct_ov9_02249B04 *param0, UnkStruct_ov9_02250138 } } -static int ov9_02250170(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250170(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { VecFx32 v0; UnkStruct_ov9_0224F930 *v1; @@ -8432,7 +8431,7 @@ static int ov9_02250170(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250260(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250260(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { MapObject *v0 = Player_MapObject(param0->fieldSystem->playerAvatar); UnkStruct_ov9_02250138 *v1 = ov9_0224E39C(param0); @@ -8500,7 +8499,7 @@ static int ov9_02250260(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250388(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250388(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { int v0; UnkStruct_ov101_021D5D90 *v1 = sub_0205EC04(param0->fieldSystem->playerAvatar); @@ -8553,7 +8552,7 @@ static int ov9_02250388(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250468(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250468(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { int v0; UnkStruct_ov101_021D5D90 *v1 = sub_0205EC04(param0->fieldSystem->playerAvatar); @@ -8635,7 +8634,7 @@ static int ov9_02250468(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250650(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250650(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { u32 v0[3] = { 0x97, 0x93, 0x73 }; UnkStruct_ov9_02250138 *v1 = ov9_0224E39C(param0); @@ -8662,7 +8661,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_0225151C[5] = { ov9_02250650 }; -static int ov9_022506AC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022506AC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_022506AC *v0 = param3; @@ -8671,7 +8670,7 @@ static int ov9_022506AC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022506CC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022506CC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { return 2; } @@ -8681,7 +8680,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_022512C0[2] = { ov9_022506CC }; -static int ov9_022506D0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022506D0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_022506D0 *v0 = param3; VarsFlags *v1 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); @@ -8694,12 +8693,12 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251238[1] = { ov9_022506D0 }; -static int ov9_022506EC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022506EC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_022506EC *v0 = param3; VarsFlags *v1 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - sub_0206AFB0(v1, 1, v0->unk_00); + SystemFlag_HandleGiratinaAnimation(v1, HANDLE_FLAG_SET, v0->unk_00); return 2; } @@ -8707,7 +8706,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_0225121C[1] = { ov9_022506EC }; -static int ov9_02250704(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250704(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_02250704 *v0 = param3; @@ -8719,7 +8718,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251270[1] = { ov9_02250704 }; -static int ov9_02250710(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250710(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_02250704 *v0 = param3; @@ -8731,7 +8730,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251254[1] = { ov9_02250710 }; -static int ov9_0225071C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0225071C(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { const UnkStruct_ov9_02252414 *v0 = param3; @@ -8740,7 +8739,7 @@ static int ov9_0225071C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250730(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250730(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { if (ov9_0224E964(param0) == 1) { ov9_0224E988(param0); @@ -8799,7 +8798,7 @@ void ov9_02250780(FieldSystem *fieldSystem) } } -static int ov9_022507C4(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022507C4(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_0225074C *v0; @@ -8813,7 +8812,7 @@ static int ov9_022507C4(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022507FC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022507FC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_020216E0 *v0; UnkStruct_ov9_0225074C *v1; @@ -8838,7 +8837,7 @@ static int ov9_022507FC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250854(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250854(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_0225074C *v0; @@ -8866,7 +8865,7 @@ static int ov9_02250854(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022508C0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022508C0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_020216E0 *v0; NNSG3dResMdl *v1; @@ -8887,7 +8886,7 @@ static int ov9_022508C0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022508F4(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022508F4(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_0225074C *v0; @@ -8910,7 +8909,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251490[5] = { ov9_022508F4 }; -static int ov9_02250918(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250918(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; @@ -8924,7 +8923,7 @@ static int ov9_02250918(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_0225094C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_0225094C(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; fx32 v1 = (FX32_ONE * 2); @@ -8945,7 +8944,7 @@ static int ov9_0225094C(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250994(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250994(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; @@ -8961,7 +8960,7 @@ static int ov9_02250994(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_022509D4(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_022509D4(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; fx32 v1[8] = { 0x0, 0x800, 0x1000, 0x2000, 0x4000, 0x6000, 0x7000, 0x8000 }; @@ -8988,7 +8987,7 @@ static int ov9_022509D4(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250A58(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250A58(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; @@ -9004,7 +9003,7 @@ static int ov9_02250A58(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250A90(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250A90(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250918 *v0; @@ -9047,7 +9046,7 @@ static const MapObjectAnimCmd Unk_ov9_02251E74[] = { { 0xfe, 0x0 } }; -static int ov9_02250AFC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250AFC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250AFC *v0; @@ -9060,7 +9059,7 @@ static int ov9_02250AFC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250B30(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250B30(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250AFC *v0; fx32 v1 = (FX32_ONE * 2); @@ -9083,7 +9082,7 @@ static int ov9_02250B30(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250B84(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250B84(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250AFC *v0; @@ -9098,7 +9097,7 @@ static int ov9_02250B84(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250BAC(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250BAC(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250AFC *v0; @@ -9218,7 +9217,7 @@ static const MapObjectAnimCmd Unk_ov9_02252E64[] = { { 0xfe, 0x0 } }; -static int ov9_02250C14(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250C14(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250C14 *v0; @@ -9230,7 +9229,7 @@ static int ov9_02250C14(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250C48(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250C48(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250C14 *v0; fx32 v1 = (FX32_ONE * 2); @@ -9266,7 +9265,7 @@ static int ov9_02250C48(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250CD8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250CD8(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250C14 *v0; @@ -9282,7 +9281,7 @@ static int ov9_02250CD8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250D10(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250D10(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250C14 *v0; @@ -9323,7 +9322,7 @@ const UnkStruct_ov9_0224A8A0 Unk_ov9_02251D68 = { 0x14 }; -static int ov9_02250D78(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250D78(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250D78 *v0; @@ -9338,7 +9337,7 @@ static int ov9_02250D78(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 1; } -static int ov9_02250DA0(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250DA0(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250D78 *v0 = ov9_0224E39C(param0); @@ -9363,7 +9362,7 @@ static const UnkFuncPtr_ov9_02253BE4 Unk_ov9_02251340[2] = { ov9_02250DA0 }; -static int ov9_02250DE8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250DE8(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250DE8 *v0; @@ -9375,7 +9374,7 @@ static int ov9_02250DE8(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 1; } -static int ov9_02250E00(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250E00(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250DE8 *v0 = ov9_0224E39C(param0); @@ -9396,7 +9395,7 @@ static int ov9_02250E00(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 return 0; } -static int ov9_02250E50(UnkStruct_ov9_02249B04 *param0, TaskManager *param1, u16 *param2, const void *param3) +static int ov9_02250E50(UnkStruct_ov9_02249B04 *param0, FieldTask *param1, u16 *param2, const void *param3) { UnkStruct_ov9_02250DE8 *v0 = ov9_0224E39C(param0); @@ -9642,7 +9641,7 @@ static BOOL ov9_02251104(UnkStruct_ov9_02249B04 *param0, u32 param1, u32 param2) } break; case 7: - if (sub_0206AFB0(v0, 2, param2) == 0) { + if (SystemFlag_HandleGiratinaAnimation(v0, HANDLE_FLAG_CHECK, param2) == FALSE) { return 1; } break; diff --git a/src/overlay023/ov23_0223E140.c b/src/overlay023/ov23_0223E140.c index 11fa515090..cb1647fad3 100644 --- a/src/overlay023/ov23_0223E140.c +++ b/src/overlay023/ov23_0223E140.c @@ -32,6 +32,7 @@ #include "communication_system.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "game_records.h" #include "graphics.h" #include "gx_layers.h" @@ -46,6 +47,7 @@ #include "strbuf.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "text.h" #include "trainer_info.h" #include "unk_020041CC.h" @@ -64,9 +66,7 @@ #include "unk_0202854C.h" #include "unk_020393C8.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "vars_flags.h" @@ -1567,12 +1567,12 @@ static void ov23_0223F118(SysTask *param0, void *param1) if (IsScreenTransitionDone()) { sub_02039794(); ov23_0223F020(v0); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); (v0->unk_00)++; } break; case 20: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { fieldSystem->unk_6C = ov23_02249404(fieldSystem); sub_02039734(); sub_020594FC(); @@ -1675,7 +1675,7 @@ static void ov23_0223F70C(FieldSystem *fieldSystem) v0->fieldSystem = fieldSystem; HBlankSystem_Stop(fieldSystem->unk_04->hBlankSystem); - sub_0206AA04(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_SetDiggingForFossils(SaveData_GetVarsFlags(fieldSystem->saveData)); Unk_ov23_02257740->unk_8CC = SysTask_Start(ov23_0223F118, v0, 100); } diff --git a/src/overlay023/ov23_022416A8.c b/src/overlay023/ov23_022416A8.c index 57398ae1eb..81a3108a72 100644 --- a/src/overlay023/ov23_022416A8.c +++ b/src/overlay023/ov23_022416A8.c @@ -27,10 +27,10 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_02005474.h" #include "unk_0202854C.h" #include "unk_02054D00.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef struct { @@ -401,7 +401,7 @@ void ov23_02241AE8(int param0, int param1, int param2, int param3) ov23_02250128(param0); Sound_PlayEffect(1585); - sub_0206AA14(SaveData_GetVarsFlags(Unk_ov23_02257744->fieldSystem->saveData)); + SystemFlag_SetSphereAcquired(SaveData_GetVarsFlags(Unk_ov23_02257744->fieldSystem->saveData)); GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(Unk_ov23_02257744->fieldSystem->saveData), RECORD_UNK_047); ov5_021F57C8(Unk_ov23_02257744->fieldSystem, param2, param3); diff --git a/src/overlay023/ov23_02241F74.c b/src/overlay023/ov23_02241F74.c index 88c8266985..42d89f6139 100644 --- a/src/overlay023/ov23_02241F74.c +++ b/src/overlay023/ov23_02241F74.c @@ -44,12 +44,12 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0202854C.h" #include "unk_02030EE0.h" #include "unk_020366A0.h" #include "unk_02054D00.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef BOOL (*UnkFuncPtr_ov23_02242540)(int, int); @@ -153,7 +153,7 @@ static void CommManUnderground_Init(CommManUnderground *param0, FieldSystem *fie sCommManUnderground->unk_DC[v1] = NULL; } - sub_0206A9F4(SaveData_GetVarsFlags(sCommManUnderground->fieldSystem->saveData)); + SystemFlag_SetEnteredUnderground(SaveData_GetVarsFlags(sCommManUnderground->fieldSystem->saveData)); sCommManUnderground->unk_14 = SysTask_Start(ov23_02243310, NULL, 0); sub_02032110(ov23_022433F4); } @@ -1192,7 +1192,7 @@ BOOL ov23_02243298(int param0) return 0; } - if (sCommManUnderground->fieldSystem->taskManager) { + if (sCommManUnderground->fieldSystem->task) { sCommManUnderground->unk_130++; if (sCommManUnderground->unk_130 > 100) { diff --git a/src/overlay023/ov23_0224340C.c b/src/overlay023/ov23_0224340C.c index 0eb753464e..0f80699426 100644 --- a/src/overlay023/ov23_0224340C.c +++ b/src/overlay023/ov23_0224340C.c @@ -7,7 +7,6 @@ #include "struct_decls/struct_0202855C_decl.h" #include "struct_decls/struct_020298B0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0200C738.h" #include "field/field_system.h" @@ -31,6 +30,7 @@ #include "communication_system.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "game_records.h" #include "graphics.h" #include "gx_layers.h" @@ -122,7 +122,7 @@ typedef struct { CellActorResourceData unk_238; CellActor *unk_25C[32]; CellActor *unk_2DC[4]; - TaskManager *unk_2EC; + FieldTask *unk_2EC; SysTask *unk_2F0; SysTask *unk_2F4; SysTask *unk_2F8; diff --git a/src/overlay023/ov23_022499E4.c b/src/overlay023/ov23_022499E4.c index 43e59fa1b7..e664cdae7c 100644 --- a/src/overlay023/ov23_022499E4.c +++ b/src/overlay023/ov23_022499E4.c @@ -24,9 +24,9 @@ #include "heap.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_02033200.h" #include "unk_020366A0.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" static void ov97_0222D19C(SysTask *param0, void *param1); @@ -81,7 +81,7 @@ void ov23_022499E8(FieldSystem *fieldSystem) v0 = FieldCommMan_Get(); Heap_Create(3, 33, 0xe800); - if (!sub_0206ADDC(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { + if (!SystemFlag_CheckUndergroundFirstEntered(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { sub_02036894(); } } @@ -273,7 +273,7 @@ static void ov23_02249C34(void) ov23_02243AF0(); ov23_0224C21C(); - if (!sub_0206ADDC(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { + if (!SystemFlag_CheckUndergroundFirstEntered(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { ov23_02249C24(ov23_02249C98, 0); } else { sub_02059524(); @@ -285,7 +285,7 @@ static void ov23_02249C98(void) { FieldCommunicationManager *v0 = FieldCommMan_Get(); - if (!sub_0206ADDC(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { + if (!SystemFlag_CheckUndergroundFirstEntered(SaveData_GetVarsFlags(v0->fieldSystem->saveData))) { return; } @@ -391,7 +391,7 @@ static void ov23_02249E18(void) ov23_02242B14(); - if (v0->fieldSystem->taskManager != NULL) { + if (v0->fieldSystem->task != NULL) { return; } @@ -579,7 +579,7 @@ static void ov23_0224A09C(void) ov23_02242B14(); sub_02059524(); - if (v0->fieldSystem->taskManager != NULL) { + if (v0->fieldSystem->task != NULL) { return; } diff --git a/src/overlay023/ov23_0224A1D0.c b/src/overlay023/ov23_0224A1D0.c index bd90cc1df7..d14b48f7d8 100644 --- a/src/overlay023/ov23_0224A1D0.c +++ b/src/overlay023/ov23_0224A1D0.c @@ -34,11 +34,11 @@ #include "strbuf.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0202854C.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "unk_020711EC.h" @@ -473,7 +473,7 @@ void ov23_0224A77C(int param0, int param1, void *param2, void *param3) u8 v6 = sub_0202958C(v5); sub_020295C0(v5); - sub_0206AA40(SaveData_GetVarsFlags(commPlayerMan->fieldSystem->saveData)); + SystemFlag_SetDeliveredStolenFlag(SaveData_GetVarsFlags(commPlayerMan->fieldSystem->saveData)); if (commPlayerMan->unk_290[v1->unk_01]) { sub_0206DAB8(commPlayerMan->fieldSystem, commPlayerMan->unk_290[v1->unk_01]); diff --git a/src/overlay023/ov23_0224B05C.c b/src/overlay023/ov23_0224B05C.c index 6088d3e265..365a82c914 100644 --- a/src/overlay023/ov23_0224B05C.c +++ b/src/overlay023/ov23_0224B05C.c @@ -8,7 +8,6 @@ #include "struct_decls/struct_0202855C_decl.h" #include "struct_decls/struct_02029894_decl.h" #include "struct_decls/struct_020298B0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" #include "overlay005/ov5_021E15F4.h" @@ -34,6 +33,7 @@ #include "core_sys.h" #include "field_map_change.h" #include "field_system.h" +#include "field_task.h" #include "font.h" #include "game_records.h" #include "graphics.h" @@ -50,6 +50,7 @@ #include "string_list.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200F174.h" @@ -57,12 +58,10 @@ #include "unk_02030EE0.h" #include "unk_02033200.h" #include "unk_020366A0.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020573FC.h" #include "unk_0205F180.h" #include "unk_020655F4.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef struct { @@ -960,7 +959,7 @@ static UnkStruct_ov23_0224BA48 *ov23_0224BCC4(FieldSystem *fieldSystem, int para { UnkStruct_ov23_0224BA48 *v0 = NULL; - if (fieldSystem->taskManager == NULL) { + if (fieldSystem->task == NULL) { v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov23_0224BA48)); MI_CpuClear8(v0, sizeof(UnkStruct_ov23_0224BA48)); @@ -1522,10 +1521,10 @@ static void ov23_0224C6E8(void) } } -static BOOL ov23_0224C708(TaskManager *param0) +static BOOL ov23_0224C708(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_0224BA48 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_0224BA48 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_10) { case 0: @@ -1543,18 +1542,18 @@ static BOOL ov23_0224C708(TaskManager *param0) return 0; } -static BOOL ov23_0224C74C(TaskManager *param0) +static BOOL ov23_0224C74C(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_0224BA48 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_0224BA48 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_10) { case 0: - FieldSystem_StartFieldMap(fieldSystem); + FieldSystem_StartFieldMapInner(fieldSystem); (v1->unk_10)++; break; case 1: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { v1->unk_10 = 0; return 1; } @@ -1564,10 +1563,10 @@ static BOOL ov23_0224C74C(TaskManager *param0) return 0; } -static BOOL ov23_0224C790(TaskManager *param0) +static BOOL ov23_0224C790(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_0224BA48 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_0224BA48 *v1 = FieldTask_GetEnv(param0); Location v2; int v3 = 0, v4 = 0; @@ -1736,7 +1735,7 @@ static void ov23_0224CAF0(FieldSystem *fieldSystem, int param1, int param2, int if (v0) { v0->unk_2D = param5; - FieldTask_Set(fieldSystem, ov23_0224C790, v0); + FieldSystem_CreateTask(fieldSystem, ov23_0224C790, v0); } } @@ -2165,7 +2164,7 @@ static void ov23_0224D238(void) v16[0][0] = 16; v16[0][1] = 12; - sub_0206AA20(SaveData_GetVarsFlags(Unk_ov23_022577AC->fieldSystem->saveData)); + SystemFlag_SetCreatedSecretBase(SaveData_GetVarsFlags(Unk_ov23_022577AC->fieldSystem->saveData)); sub_020292CC(v0); sub_02028B34(v1); CommSys_Seed(&v15); diff --git a/src/overlay023/ov23_0225128C.c b/src/overlay023/ov23_0225128C.c index 6837eaf285..be629b836f 100644 --- a/src/overlay023/ov23_0225128C.c +++ b/src/overlay023/ov23_0225128C.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_020298B0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" #include "overlay023/funcptr_ov23_022515D8.h" @@ -30,6 +29,7 @@ #include "communication_system.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "list_menu.h" #include "location.h" @@ -43,14 +43,13 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_02005474.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_0202854C.h" #include "unk_02033200.h" -#include "unk_020508D4.h" #include "unk_0206A780.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef struct { @@ -604,10 +603,10 @@ static void ov23_02251A84(BOOL param0, FieldSystem *fieldSystem) Camera_Move(&v0, fieldSystem->camera); } -static BOOL ov23_02251ACC(TaskManager *param0) +static BOOL ov23_02251ACC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02251ACC *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02251ACC *v1 = FieldTask_GetEnv(param0); Location v2; u32 v3; BOOL v4 = 0; @@ -643,7 +642,7 @@ static BOOL ov23_02251ACC(TaskManager *param0) case 5: if (IsScreenTransitionDone()) { ov23_0224B2C8(fieldSystem); - sub_0206AA30(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_SetDecoratedSecretBase(SaveData_GetVarsFlags(fieldSystem->saveData)); ov23_02251F94(fieldSystem); Heap_FreeToHeap(v1); return 1; @@ -783,12 +782,12 @@ static void ov23_02251C04(SysTask *param0, void *param1) } break; case 3: - if (v0->fieldSystem->taskManager == NULL) { + if (v0->fieldSystem->task == NULL) { v2 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov23_02251ACC)); MI_CpuClear8(v2, sizeof(UnkStruct_ov23_02251ACC)); v2->unk_00 = 0; v2->unk_04 = 0; - FieldTask_Set(v0->fieldSystem, ov23_02251ACC, v2); + FieldSystem_CreateTask(v0->fieldSystem, ov23_02251ACC, v2); } ov23_02251BB4(param0, v0); diff --git a/src/overlay023/ov23_02254A14.c b/src/overlay023/ov23_02254A14.c index 181fd995fe..a1ec13b49b 100644 --- a/src/overlay023/ov23_02254A14.c +++ b/src/overlay023/ov23_02254A14.c @@ -5,7 +5,6 @@ #include "struct_decls/struct_02029894_decl.h" #include "struct_decls/struct_020298B0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -24,13 +23,13 @@ #include "core_sys.h" #include "easy3d.h" +#include "field_task.h" #include "heap.h" #include "text.h" #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_02017728.h" #include "unk_0202854C.h" -#include "unk_020508D4.h" #include "unk_020573FC.h" typedef struct { @@ -113,12 +112,12 @@ typedef struct { u8 unk_522; } UnkStruct_ov23_02256098; -static BOOL ov23_02254C84(TaskManager *param0); -static BOOL ov23_02254AD4(TaskManager *param0); -static BOOL ov23_02254DF8(TaskManager *param0); -static BOOL ov23_02255100(TaskManager *param0); -static BOOL ov23_02255580(TaskManager *param0); -static BOOL ov23_02255850(TaskManager *param0); +static BOOL ov23_02254C84(FieldTask *param0); +static BOOL ov23_02254AD4(FieldTask *param0); +static BOOL ov23_02254DF8(FieldTask *param0); +static BOOL ov23_02255100(FieldTask *param0); +static BOOL ov23_02255580(FieldTask *param0); +static BOOL ov23_02255850(FieldTask *param0); static void ov23_02254A14(FieldSystem *fieldSystem, const int param1, UnkStruct_ov23_02256098 *param2); static void ov23_02254A94(FieldSystem *fieldSystem, const int param1); static void ov23_02254AA4(const int param0, UnkStruct_ov23_02256098 *param1); @@ -205,10 +204,10 @@ static void ov23_02254AA4(const int param0, UnkStruct_ov23_02256098 *param1) param1->unk_3C = (*v0); } -static BOOL ov23_02254AD4(TaskManager *param0) +static BOOL ov23_02254AD4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -233,19 +232,19 @@ static BOOL ov23_02254AD4(TaskManager *param0) } break; case 3: - FieldTask_Start(param0, ov23_02254C84, v1); + FieldTask_InitCall(param0, ov23_02254C84, v1); break; case 4: - FieldTask_Start(param0, ov23_02254DF8, v1); + FieldTask_InitCall(param0, ov23_02254DF8, v1); break; case 5: - FieldTask_Start(param0, ov23_02255100, v1); + FieldTask_InitCall(param0, ov23_02255100, v1); break; case 6: - FieldTask_Start(param0, ov23_02255580, v1); + FieldTask_InitCall(param0, ov23_02255580, v1); break; case 7: - FieldTask_Start(param0, ov23_02255850, v1); + FieldTask_InitCall(param0, ov23_02255850, v1); break; case 8: if (Text_IsPrinterActive(v1->unk_08) == 0) { @@ -274,11 +273,11 @@ static BOOL ov23_02254AD4(TaskManager *param0) return 0; } -static BOOL ov23_02254C84(TaskManager *param0) +static BOOL ov23_02254C84(FieldTask *param0) { BOOL v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v2 = FieldTask_GetEnv(param0); v0 = ov23_02254318(v2->unk_504); @@ -335,7 +334,7 @@ static BOOL ov23_02254C84(TaskManager *param0) return 0; } -void ov23_02254D98(FieldSystem *fieldSystem, TaskManager *param1) +void ov23_02254D98(FieldSystem *fieldSystem, FieldTask *param1) { UnkStruct_ov23_02256098 *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_ov23_02256098)); @@ -346,17 +345,17 @@ void ov23_02254D98(FieldSystem *fieldSystem, TaskManager *param1) v0->unk_50C = ov5_021D1B6C(fieldSystem->unk_04->unk_04, &Unk_ov23_02256B88); v0->unk_4FC = ov5_021D1C2C(v0->unk_50C); - FieldTask_Start(param1, ov23_02254AD4, v0); + FieldTask_InitCall(param1, ov23_02254AD4, v0); } -static BOOL ov23_02254DF8(TaskManager *param0) +static BOOL ov23_02254DF8(FieldTask *param0) { fx32 v0, v1; UnkStruct_ov5_021E1890 *v2; BOOL v3; BOOL v4; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v6 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v6 = FieldTask_GetEnv(param0); switch (v6->unk_04) { case 0: { @@ -526,15 +525,15 @@ static BOOL ov23_02254DF8(TaskManager *param0) return 0; } -static BOOL ov23_02255100(TaskManager *param0) +static BOOL ov23_02255100(FieldTask *param0) { BOOL v0; UnkStruct_ov23_02255C30 v1; fx32 v2, v3; BOOL v4; BOOL v5; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v7 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v7 = FieldTask_GetEnv(param0); switch (v7->unk_04) { case 0: @@ -763,15 +762,15 @@ static BOOL ov23_02255100(TaskManager *param0) return 0; } -static BOOL ov23_02255580(TaskManager *param0) +static BOOL ov23_02255580(FieldTask *param0) { BOOL v0; UnkStruct_ov23_02255C30 v1; fx32 v2, v3; BOOL v4; BOOL v5; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v7 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v7 = FieldTask_GetEnv(param0); switch (v7->unk_04) { case 0: @@ -916,14 +915,14 @@ static BOOL ov23_02255580(TaskManager *param0) return 0; } -static BOOL ov23_02255850(TaskManager *param0) +static BOOL ov23_02255850(FieldTask *param0) { fx32 v0, v1; UnkStruct_ov5_021E1890 *v2; BOOL v3; BOOL v4; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_ov23_02256098 *v6 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_ov23_02256098 *v6 = FieldTask_GetEnv(param0); switch (v6->unk_04) { case 0: diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index bc205fbc8b..4b1dec3440 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -13,6 +13,7 @@ #include "bg_window.h" #include "enums.h" #include "field_system.h" +#include "field_task.h" #include "game_overlay.h" #include "gender.h" #include "heap.h" @@ -24,7 +25,6 @@ #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0201E3D8.h" -#include "unk_020508D4.h" #include "unk_02099D44.h" FS_EXTERN_OVERLAY(overlay26); @@ -716,7 +716,7 @@ BOOL PoketchSystem_GetDisplayTappedCoords(u32 *x, u32 *y) BOOL ov25_0225450C(const PoketchSystem *poketchSys) { - return sub_020509A4(poketchSys->fieldSystem); + return FieldSystem_IsRunningTask(poketchSys->fieldSystem); } void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager *buttonManager) diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index b5b82ac694..dcbc40e30d 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -18,6 +18,7 @@ #include "bg_window.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_task.h" #include "font.h" #include "graphics.h" #include "gx_layers.h" @@ -40,7 +41,6 @@ #include "unk_02017728.h" #include "unk_02027F84.h" #include "unk_02033200.h" -#include "unk_020508D4.h" #include "unk_0205B33C.h" #include "unk_0205D8CC.h" @@ -703,7 +703,7 @@ static void ov56_02256D04(UnkStruct_ov56_02256468 *param0) { int v0 = 0xffffffff; - if (!sub_020509A4(param0->fieldSystem)) { + if (!FieldSystem_IsRunningTask(param0->fieldSystem)) { int v1; v1 = ov56_02256A68(param0); @@ -880,7 +880,7 @@ static void ov56_02257098(UnkStruct_ov56_02256468 *param0) TrainerInfo *v5; Sentence v6; - if (sub_020509A4(param0->fieldSystem)) { + if (FieldSystem_IsRunningTask(param0->fieldSystem)) { return; } diff --git a/src/overlay064/ov64_0222DCE0.c b/src/overlay064/ov64_0222DCE0.c index de1955b48c..fdd3694e14 100644 --- a/src/overlay064/ov64_0222DCE0.c +++ b/src/overlay064/ov64_0222DCE0.c @@ -3,6 +3,7 @@ #include #include #include +#include "constants/savedata/vars_flags.h" #include "struct_decls/struct_0202B370_decl.h" #include "struct_decls/struct_0203068C_decl.h" @@ -45,6 +46,7 @@ #include "strbuf.h" #include "string_list.h" #include "string_template.h" +#include "system_flags.h" #include "text.h" #include "trainer_info.h" #include "unk_02005474.h" @@ -3149,7 +3151,7 @@ static void ov64_0223087C (UnkStruct_ov64_02230620 * param0, UnkStruct_ov64_0222 static void ov64_022308DC (UnkStruct_ov64_02230904 * param0, UnkStruct_ov64_0222E060 * param1, UnkStruct_ov64_0222E21C * param2, u32 param3) { - param0->unk_10 = inline_0208BE68(SaveData_GetVarsFlags(param1->unk_00), 53); + param0->unk_10 = SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(param1->unk_00), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_BATTLE_PARK); ov64_02230B1C(param0, param1, param2, param3); } diff --git a/src/overlay065/ov65_0222DCE0.c b/src/overlay065/ov65_0222DCE0.c index 6b80666988..76ee88bec3 100644 --- a/src/overlay065/ov65_0222DCE0.c +++ b/src/overlay065/ov65_0222DCE0.c @@ -61,6 +61,7 @@ #include "strbuf.h" #include "string_list.h" #include "string_template.h" +#include "system_flags.h" #include "text.h" #include "touch_screen.h" #include "trainer_info.h" @@ -387,7 +388,7 @@ static const WindowTemplate Unk_ov65_0223894C = { static BOOL ov65_0222DCE0 (UnkStruct_ov65_0222EBE0 * param0) { - return inline_0208BE68(SaveData_GetVarsFlags(param0->unk_160), 53); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(param0->unk_160), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_BATTLE_PARK); } static BOOL ov65_0222DCF8 (UnkStruct_ov65_0222EBE0 * param0) diff --git a/src/overlay098/ov98_02246C20.c b/src/overlay098/ov98_02246C20.c index 0f891c1d44..49e596947f 100644 --- a/src/overlay098/ov98_02246C20.c +++ b/src/overlay098/ov98_02246C20.c @@ -21,13 +21,13 @@ #include "overlay_manager.h" #include "save_player.h" #include "strbuf.h" +#include "system_flags.h" #include "unk_020041CC.h" #include "unk_02017728.h" #include "unk_02030CE8.h" #include "unk_02033200.h" #include "unk_02038FFC.h" #include "unk_020393C8.h" -#include "unk_0206A8DC.h" #include "unk_020890F4.h" #include "unk_02099550.h" #include "vars_flags.h" @@ -445,7 +445,7 @@ static void ov98_02247198(UnkStruct_ov98_02246E88 *param0) v0 = param0->unk_98; if (sub_02039074(param0->unk_04)) { - sub_0206AF5C(SaveData_GetVarsFlags(param0->unk_04)); + SystemFlag_SetConnectedToWiFi(SaveData_GetVarsFlags(param0->unk_04)); } Heap_FreeToHeap(param0->unk_98); diff --git a/src/pokemon_summary_app.c b/src/pokemon_summary_app.c index c39d7e9d26..a2a51eda4e 100644 --- a/src/pokemon_summary_app.c +++ b/src/pokemon_summary_app.c @@ -28,6 +28,7 @@ #include "savedata.h" #include "strbuf.h" #include "string_template.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_020041CC.h" #include "unk_02005474.h" @@ -41,7 +42,6 @@ #include "unk_0201DBEC.h" #include "unk_0201E3D8.h" #include "unk_020393C8.h" -#include "unk_0206A8DC.h" #include "unk_0208C098.h" #include "unk_0208EA44.h" #include "unk_0208FCF8.h" @@ -130,7 +130,7 @@ const OverlayManagerTemplate Unk_020F410C = { BOOL PokemonSummary_ShowContestData(SaveData *param0) { - return ContestHall_IsVisited(SaveData_GetVarsFlags(param0)); + return SystemFlag_CheckContestHallVisited(SaveData_GetVarsFlags(param0)); } static int sub_0208C330(OverlayManager *param0, int *param1) diff --git a/src/pokeradar.c b/src/pokeradar.c index 738e0dd280..3e5c95413c 100644 --- a/src/pokeradar.c +++ b/src/pokeradar.c @@ -6,7 +6,6 @@ #include "constants/battle.h" #include "consts/sdat.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0201CFEC.h" #include "struct_defs/struct_020698E4.h" @@ -16,6 +15,7 @@ #include "overlay101/struct_ov101_021D5D90_decl.h" #include "bag.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "map_object.h" @@ -26,7 +26,6 @@ #include "unk_0201CED8.h" #include "unk_0202D7A8.h" #include "unk_02039C80.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020553DC.h" #include "unk_0205DAC8.h" @@ -271,7 +270,7 @@ void sub_0206979C(FieldSystem *fieldSystem) GrassPatch *patch; int patchRing; - if (!fieldSystem->chain->active || fieldSystem->taskManager != NULL) { + if (!fieldSystem->chain->active || fieldSystem->task != NULL) { return; } @@ -416,10 +415,10 @@ static BOOL CheckPatchContinueChain(const u8 patchRing, const int battleResult) } } -BOOL RefreshRadarChain(TaskManager *taskMan) +BOOL RefreshRadarChain(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - int *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + int *v1 = FieldTask_GetEnv(taskMan); switch (*v1) { case 0: diff --git a/src/scrcmd.c b/src/scrcmd.c index 30692d735a..0aa4dc511c 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -95,11 +95,13 @@ #include "comm_player_manager.h" #include "communication_system.h" #include "core_sys.h" +#include "encounter.h" #include "field_comm_manager.h" #include "field_map_change.h" #include "field_overworld_state.h" #include "field_script_context.h" #include "field_system.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "inlines.h" @@ -122,12 +124,14 @@ #include "rtc.h" #include "save_player.h" #include "savedata.h" +#include "scrcmd_system_flags.h" #include "script_manager.h" #include "strbuf.h" #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" #include "system_data.h" +#include "system_flags.h" #include "text.h" #include "trainer_data.h" #include "trainer_info.h" @@ -170,7 +174,6 @@ #include "unk_0204CFFC.h" #include "unk_0204E240.h" #include "unk_0204E378.h" -#include "unk_0204E3CC.h" #include "unk_0204E75C.h" #include "unk_0204E974.h" #include "unk_0204EDA4.h" @@ -180,8 +183,6 @@ #include "unk_0204FAB4.h" #include "unk_0205003C.h" #include "unk_02050568.h" -#include "unk_020508D4.h" -#include "unk_02050A74.h" #include "unk_020528D0.h" #include "unk_02052C6C.h" #include "unk_020553DC.h" @@ -195,7 +196,6 @@ #include "unk_0205DFC4.h" #include "unk_020655F4.h" #include "unk_02069BE0.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206B70C.h" #include "unk_0206C0E8.h" @@ -556,7 +556,7 @@ static BOOL ScrCmd_1C2(ScriptContext *ctx); static BOOL ScrCmd_1C3(ScriptContext *ctx); static BOOL ScrCmd_1C4(ScriptContext *ctx); static BOOL ScrCmd_1C5(ScriptContext *ctx); -static BOOL ScrCmd_1CC(ScriptContext *ctx); +static BOOL ScrCmd_GiveJournal(ScriptContext *ctx); static BOOL ScrCmd_1CD(ScriptContext *ctx); static BOOL ScrCmd_1CE(ScriptContext *ctx); static BOOL ScrCmd_1D2(ScriptContext *ctx); @@ -638,8 +638,8 @@ static BOOL ScrCmd_260(ScriptContext *ctx); static BOOL ScrCmd_262(ScriptContext *ctx); static BOOL ScrCmd_263(ScriptContext *ctx); static BOOL ScrCmd_264(ScriptContext *ctx); -static BOOL ScrCmd_265(ScriptContext *ctx); -static BOOL ScrCmd_266(ScriptContext *ctx); +static BOOL ScrCmd_HidePoketch(ScriptContext *ctx); +static BOOL ScrCmd_ShowPoketch(ScriptContext *ctx); static BOOL ScrCmd_267(ScriptContext *ctx); static BOOL ScrCmd_268(ScriptContext *ctx); static BOOL ScrCmd_269(ScriptContext *ctx); @@ -1106,23 +1106,23 @@ const ScrCmdFunc Unk_020EAC58[] = { ScrCmd_154, ScrCmd_155, ScrCmd_156, - ScrCmd_157, - ScrCmd_158, - ScrCmd_159, - ScrCmd_15A, - ScrCmd_CheckBadge, - ScrCmd_15C, - ScrCmd_15D, - ScrCmd_15E, - ScrCmd_15F, - ScrCmd_160, - ScrCmd_161, - ScrCmd_162, - ScrCmd_163, - ScrCmd_164, - ScrCmd_165, - ScrCmd_166, - ScrCmd_167, + ScrCmd_CheckPokedexAcquired, + ScrCmd_GivePokedex, + ScrCmd_CheckRunningShoesAcquired, + ScrCmd_GiveRunningShoes, + ScrCmd_CheckBadgeAcquired, + ScrCmd_GiveBadge, + ScrCmd_CountBadgesAcquired, + ScrCmd_CheckBagAcquired, + ScrCmd_GiveBag, + ScrCmd_CheckHasPartner, + ScrCmd_SetHasPartner, + ScrCmd_ClearHasPartner, + ScrCmd_CheckStepFlag, + ScrCmd_SetStepFlag, + ScrCmd_ClearStepFlag, + ScrCmd_CheckGameCompleted, + ScrCmd_SetGameCompleted, ScrCmd_168, ScrCmd_169, ScrCmd_16A, @@ -1223,12 +1223,12 @@ const ScrCmdFunc Unk_020EAC58[] = { ScrCmd_1C9, ScrCmd_1CA, ScrCmd_1CB, - ScrCmd_1CC, + ScrCmd_GiveJournal, ScrCmd_1CD, ScrCmd_1CE, - ScrCmd_1CF, - ScrCmd_1D0, - ScrCmd_1D1, + ScrCmd_Strength, + ScrCmd_Flash, + ScrCmd_Defog, ScrCmd_1D2, ScrCmd_1D3, ScrCmd_1D4, @@ -1376,8 +1376,8 @@ const ScrCmdFunc Unk_020EAC58[] = { ScrCmd_262, ScrCmd_263, ScrCmd_264, - ScrCmd_265, - ScrCmd_266, + ScrCmd_HidePoketch, + ScrCmd_ShowPoketch, ScrCmd_267, ScrCmd_268, ScrCmd_269, @@ -1898,19 +1898,15 @@ static BOOL ScrCmd_017(ScriptContext *ctx) static BOOL ScrCmd_018(ScriptContext *ctx) { - u8 v0; - s32 v1; - u32 v2; - - v2 = sub_02050A6C(ctx->taskManager); - v0 = ScriptContext_ReadByte(ctx); - v1 = (s32)ScriptContext_ReadWord(ctx); + u32 taskVal = FieldTask_GetDummy1CVal(ctx->task); + u8 val = ScriptContext_ReadByte(ctx); + s32 offset = (s32)ScriptContext_ReadWord(ctx); - if (v2 == v0) { - ScriptContext_Jump(ctx, (u8 *)(ctx->scriptPtr + v1)); + if (taskVal == val) { + ScriptContext_Jump(ctx, (u8 *)(ctx->scriptPtr + offset)); } - return 0; + return FALSE; } static BOOL ScrCmd_019(ScriptContext *ctx) @@ -3106,7 +3102,7 @@ static BOOL ScrCmd_LockAll(ScriptContext *ctx) MapObject *object = sub_02062570(fieldSystem->mapObjMan, 0x30); if (object - && sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1 + && SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1 && MapObject_IsMoving(object) != FALSE) { sub_02062DDC(object); @@ -3219,7 +3215,7 @@ static BOOL ScrCmd_LockLastTalked(ScriptContext *ctx) } if (v3) { - if (sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1 && MapObject_IsMoving(v3) != FALSE) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1 && MapObject_IsMoving(v3) != FALSE) { inline_020410F4_2(1 << 1); sub_02062DDC(v3); } @@ -3558,7 +3554,7 @@ static BOOL ScrCmd_192(ScriptContext *ctx) void **v0; v0 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, 19); - *v0 = sub_0203D50C(ctx->fieldSystem->taskManager, 32); + *v0 = sub_0203D50C(ctx->fieldSystem->task, 32); return 1; } @@ -3859,7 +3855,7 @@ BOOL sub_02041CC8(ScriptContext *ctx) v0 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, 19); - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } @@ -3879,7 +3875,7 @@ static BOOL sub_02041CF4(ScriptContext *ctx) v0 = FieldSystem_GetScriptMemberPtr(fieldSystem, 19); v2 = *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } @@ -3916,7 +3912,7 @@ BOOL sub_02041D60(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } @@ -3925,13 +3921,13 @@ BOOL sub_02041D60(ScriptContext *ctx) static BOOL ScrCmd_0A1(ScriptContext *ctx) { - FieldTask_StartFieldMap(ctx->fieldSystem->taskManager); + FieldTask_StartFieldMap(ctx->fieldSystem->task); return 1; } static BOOL ScrCmd_1F8(ScriptContext *ctx) { - FieldTask_FinishFieldMap(ctx->fieldSystem->taskManager); + FieldTask_FinishFieldMap(ctx->fieldSystem->task); return 1; } @@ -3981,7 +3977,7 @@ static BOOL ScrCmd_0A2(ScriptContext *ctx) static BOOL ScrCmd_0A3(ScriptContext *ctx) { - sub_0207DDC0(ctx->taskManager); + sub_0207DDC0(ctx->task); return 1; } @@ -4087,7 +4083,7 @@ static BOOL ScrCmd_20A(ScriptContext *ctx) u16 v0 = ScriptContext_ReadHalfWord(ctx); StringTemplate **v1 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_STR_TEMPLATE); - VsSeeker_Start(ctx->taskManager, *v1, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); + VsSeeker_Start(ctx->task, *v1, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); return 1; } @@ -4106,7 +4102,7 @@ static BOOL ScrCmd_20B(ScriptContext *ctx) static BOOL ScrCmd_0A5(ScriptContext *ctx) { - sub_0209ACF4(ctx->taskManager); + sub_0209ACF4(ctx->task); return 1; } @@ -4114,7 +4110,7 @@ static BOOL ScrCmd_30E(ScriptContext *ctx) { u16 *v0 = ScriptContext_GetVarPointer(ctx); - sub_0209B344(ctx->taskManager, v0); + sub_0209B344(ctx->task, v0); return 1; } @@ -4124,7 +4120,7 @@ static BOOL ScrCmd_0A6(ScriptContext *ctx) u16 *v1 = ScriptContext_GetVarPointer(ctx); u16 v2 = ScriptContext_GetVar(ctx); - sub_0203DAC0(ctx->fieldSystem->taskManager, v1, ctx->fieldSystem->saveData, v0, v2); + sub_0203DAC0(ctx->fieldSystem->task, v1, ctx->fieldSystem->saveData, v0, v2); return 1; } @@ -4235,7 +4231,7 @@ static BOOL ScrCmd_310(ScriptContext *ctx) static BOOL ScrCmd_OpenSealCapsuleEditor(ScriptContext *ctx) { - sub_020980DC(ctx->taskManager, ctx->fieldSystem->saveData); + sub_020980DC(ctx->task, ctx->fieldSystem->saveData); return TRUE; } @@ -4339,7 +4335,7 @@ static BOOL ScrCmd_0AD(ScriptContext *ctx) static BOOL ScrCmd_0AE(ScriptContext *ctx) { - sub_0203DDDC(ctx->fieldSystem->taskManager); + sub_0203DDDC(ctx->fieldSystem->task); return 1; } @@ -4355,7 +4351,7 @@ static BOOL ScrCmd_0AF(ScriptContext *ctx) static BOOL ScrCmd_0B0(ScriptContext *ctx) { - sub_02052E58(ctx->fieldSystem->taskManager); + sub_02052E58(ctx->fieldSystem->task); return 1; } @@ -4407,7 +4403,7 @@ static BOOL ScrCmd_0B3(ScriptContext *ctx) { u16 v0 = ScriptContext_ReadHalfWord(ctx); - sub_0207DDE0(ctx->taskManager, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); + sub_0207DDE0(ctx->task, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); return 1; } @@ -4482,7 +4478,7 @@ static BOOL ScrCmd_0BA(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; - sub_0203DFE8(ctx->taskManager, 0, 0, 7, 0, NULL, ScriptContext_GetVarPointer(ctx)); + sub_0203DFE8(ctx->task, 0, 0, 7, 0, NULL, ScriptContext_GetVarPointer(ctx)); return 1; } @@ -4496,14 +4492,14 @@ static BOOL ScrCmd_0BB(ScriptContext *ctx) v1 = Party_GetPokemonBySlotIndex(Party_GetFromSavedata(fieldSystem->saveData), v3); Pokemon_GetValue(v1, MON_DATA_NICKNAME, v0); - sub_0203DFE8(ctx->taskManager, 1, Pokemon_GetValue(v1, MON_DATA_SPECIES, NULL), 10, v3, v0, ScriptContext_GetVarPointer(ctx)); + sub_0203DFE8(ctx->task, 1, Pokemon_GetValue(v1, MON_DATA_SPECIES, NULL), 10, v3, v0, ScriptContext_GetVarPointer(ctx)); return 1; } static BOOL ScrCmd_271(ScriptContext *ctx) { - sub_0203DFE8(ctx->taskManager, 6, 0, 10, 0, NULL, ScriptContext_GetVarPointer(ctx)); + sub_0203DFE8(ctx->task, 6, 0, 10, 0, NULL, ScriptContext_GetVarPointer(ctx)); return 1; } @@ -4540,7 +4536,7 @@ static BOOL ScrCmd_243(ScriptContext *ctx) u16 *v2 = ScriptContext_GetVarPointer(ctx); *v2 = 0xffff; - sub_0203D80C(ctx->fieldSystem->taskManager, v1, v2, NULL); + sub_0203D80C(ctx->fieldSystem->task, v1, v2, NULL); return 1; } @@ -4555,7 +4551,7 @@ static BOOL ScrCmd_244(ScriptContext *ctx) *v2 = 0xffff; *v3 = 0xffff; - sub_0203D80C(ctx->fieldSystem->taskManager, v1, v2, v3); + sub_0203D80C(ctx->fieldSystem->task, v1, v2, v3); return 1; } @@ -4603,7 +4599,7 @@ static BOOL ScrCmd_Warp(ScriptContext *ctx) u16 z = ScriptContext_GetVar(ctx); u16 direction = ScriptContext_GetVar(ctx); - FieldTask_StartMapChangeFull(ctx->taskManager, mapID, -1, x, z, direction); + FieldTask_StartMapChangeFull(ctx->task, mapID, -1, x, z, direction); return TRUE; } @@ -4620,14 +4616,14 @@ static BOOL ScrCmd_203(ScriptContext *ctx) v3 = ScriptContext_ReadHalfWord(ctx); v4 = -1; - sub_02054800(ctx->fieldSystem->taskManager, v0, v4, v1, v2, v3); + sub_02054800(ctx->fieldSystem->task, v0, v4, v1, v2, v3); return 1; } static BOOL ScrCmd_204(ScriptContext *ctx) { - sub_02054864(ctx->fieldSystem->taskManager); + sub_02054864(ctx->fieldSystem->task); return 1; } @@ -4651,7 +4647,7 @@ static BOOL ScrCmd_201(ScriptContext *ctx) static BOOL ScrCmd_0BF(ScriptContext *ctx) { - ov5_021E0734(ctx->taskManager, PlayerAvatar_GetDir(ctx->fieldSystem->playerAvatar), ScriptContext_GetVar(ctx)); + ov5_021E0734(ctx->task, PlayerAvatar_GetDir(ctx->fieldSystem->playerAvatar), ScriptContext_GetVar(ctx)); return 1; } @@ -4668,7 +4664,7 @@ static BOOL ScrCmd_0C0(ScriptContext *ctx) v0 = PlayerAvatar_GetMoveDir(ctx->fieldSystem->playerAvatar); } - ov5_021E00EC(ctx->taskManager, v0, ScriptContext_GetVar(ctx)); + ov5_021E00EC(ctx->task, v0, ScriptContext_GetVar(ctx)); } return 1; @@ -4676,7 +4672,7 @@ static BOOL ScrCmd_0C0(ScriptContext *ctx) static BOOL ScrCmd_0C1(ScriptContext *ctx) { - ov5_021E0998(ctx->taskManager, PlayerAvatar_GetDir(ctx->fieldSystem->playerAvatar), ScriptContext_GetVar(ctx)); + ov5_021E0998(ctx->task, PlayerAvatar_GetDir(ctx->fieldSystem->playerAvatar), ScriptContext_GetVar(ctx)); return 1; } @@ -4739,7 +4735,7 @@ static BOOL sub_02042C80(ScriptContext *ctx) static BOOL ScrCmd_0C6(ScriptContext *ctx) { - ov5_021E0DD4(ctx->taskManager); + ov5_021E0DD4(ctx->task); return 1; } @@ -4926,7 +4922,7 @@ static BOOL ScrCmd_0F6(ScriptContext *ctx) v1 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, 19); v0 = *v1; - sub_0205167C(ctx->fieldSystem->taskManager, v0->unk_2C, (0x4 | 0x1)); + sub_0205167C(ctx->fieldSystem->task, v0->unk_2C, (0x4 | 0x1)); Heap_FreeToHeap(v0); *v1 = NULL; @@ -5030,7 +5026,7 @@ static BOOL ScrCmd_123(ScriptContext *ctx) if (v2 == 0) { v4 = sub_02026F58(v0); - *v3 = sub_0205E078(v4, inline_0208BE68(SaveData_GetVarsFlags(ctx->fieldSystem->saveData), 10)); + *v3 = sub_0205E078(v4, SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(ctx->fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_ETERNA_CITY)); } else { v4 = sub_02026F20(v0); *v3 = sub_0205E0E4(v4, TrainerInfo_Gender(v1)); @@ -5045,7 +5041,7 @@ static BOOL ScrCmd_124(ScriptContext *ctx) u16 v1 = ScriptContext_GetVar(ctx); u8 v2 = (u8)ScriptContext_GetVar(ctx); - sub_02051270(ctx->taskManager, v1, v2, v0, 0); + sub_02051270(ctx->task, v1, v2, v0, 0); return 1; } @@ -5056,7 +5052,7 @@ static BOOL ScrCmd_2BD(ScriptContext *ctx) u16 v1 = ScriptContext_GetVar(ctx); u8 v2 = (u8)ScriptContext_GetVar(ctx); - sub_02051270(ctx->taskManager, v1, v2, v0, 1); + sub_02051270(ctx->task, v1, v2, v0, 1); return 1; } @@ -5067,7 +5063,7 @@ static BOOL ScrCmd_319(ScriptContext *ctx) u16 v1 = ScriptContext_GetVar(ctx); u8 v2 = (u8)ScriptContext_GetVar(ctx); - sub_02051ABC(ctx->taskManager, v1, v2, v0, 1); + sub_02051ABC(ctx->task, v1, v2, v0, 1); return 1; } @@ -5077,7 +5073,7 @@ static BOOL ScrCmd_318(ScriptContext *ctx) u16 v1 = ScriptContext_GetVar(ctx); u8 v2 = (u8)ScriptContext_GetVar(ctx); - sub_020512E4(ctx->taskManager, v1, v2, v0, 1); + sub_020512E4(ctx->task, v1, v2, v0, 1); return 1; } @@ -5087,13 +5083,13 @@ static BOOL ScrCmd_125(ScriptContext *ctx) BOOL *v1 = FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_MANAGER_BATTLE_RESULT); u16 v2 = ScriptContext_GetVar(ctx); - sub_02051480(ctx->taskManager, v2, 11, v1); + sub_02051480(ctx->task, v2, 11, v1); return 1; } static BOOL ScrCmd_126(ScriptContext *ctx) { - sub_02051590(ctx->taskManager); + sub_02051590(ctx->task); return 1; } @@ -5119,7 +5115,7 @@ static BOOL ScrCmd_129(ScriptContext *ctx) FieldSystem *fieldSystem = ctx->fieldSystem; BOOL *v1 = FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_MANAGER_BATTLE_RESULT); - sub_0205120C(ctx->taskManager, v1); + sub_0205120C(ctx->task, v1); return 1; } @@ -5181,7 +5177,7 @@ static BOOL ScrCmd_2D7(ScriptContext *ctx) static BOOL ScrCmd_131(ScriptContext *ctx) { - ov5_021DDBC8(ctx->taskManager); + ov5_021DDBC8(ctx->task); return 1; } @@ -5490,7 +5486,7 @@ static BOOL sub_02043A4C(ScriptContext *ctx) static BOOL ScrCmd_153(ScriptContext *ctx) { - sub_02054708(ctx->fieldSystem->taskManager); + sub_02054708(ctx->fieldSystem->task); return 1; } @@ -5537,7 +5533,7 @@ static BOOL ScrCmd_156(ScriptContext *ctx) static BOOL ScrCmd_14B(ScriptContext *ctx) { - sub_02052C5C(ctx->taskManager); + sub_02052C5C(ctx->task); return 1; } @@ -5561,7 +5557,7 @@ static BOOL ScrCmd_GetPlayerGender(ScriptContext *ctx) static BOOL ScrCmd_HealParty(ScriptContext *ctx) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(ctx->taskManager); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(ctx->task); HealAllPokemonInParty(Party_GetFromSavedata(fieldSystem->saveData)); return FALSE; @@ -5999,7 +5995,7 @@ static BOOL ScrCmd_1B2(ScriptContext *ctx) static BOOL ScrCmd_1B3(ScriptContext *ctx) { - sub_020736D8(ctx->taskManager); + sub_020736D8(ctx->task); return 1; } @@ -6017,7 +6013,7 @@ static BOOL ScrCmd_1B5(ScriptContext *ctx) { u16 v0 = ScriptContext_GetVar(ctx); - sub_020703FC(ctx->taskManager, v0); + sub_020703FC(ctx->task, v0); return 1; } @@ -6102,15 +6098,15 @@ static BOOL ScrCmd_1C5(ScriptContext *ctx) return 0; } -static BOOL ScrCmd_1CC(ScriptContext *ctx) +static BOOL ScrCmd_GiveJournal(ScriptContext *ctx) { FieldSystem *fieldSystem = ctx->fieldSystem; - inline_02044528(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_HandleJournalAcquired(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_SET); fieldSystem->journal = Journal_GetSavedPage(SaveData_GetJournal(fieldSystem->saveData), 1); sub_02053494(fieldSystem); - return 0; + return FALSE; } static BOOL ScrCmd_1CD(ScriptContext *ctx) @@ -6394,13 +6390,13 @@ static BOOL ScrCmd_202(ScriptContext *ctx) switch (v5) { case 0: - sub_0206AE3C(v3); + SystemFlag_SetSafariGameActive(v3); sub_0206D000(v4); *v0 = 30; *v1 = 0; break; case 1: - sub_0206AE4C(v3); + SystemFlag_ClearSafariGameActive(v3); sub_0206D720(ctx->fieldSystem); { void *v6 = sub_0202BDE0(4); @@ -6560,7 +6556,7 @@ static BOOL ScrCmd_229(ScriptContext *ctx) void **v0 = FieldSystem_GetScriptMemberPtr(ctx->fieldSystem, SCRIPT_MANAGER_DATA_PTR); u16 v1 = ScriptContext_GetVar(ctx); - sub_0206C740(ctx->taskManager, (UnkStruct_ov6_02246204 *)*v0, v1, 11); + sub_0206C740(ctx->task, (UnkStruct_ov6_02246204 *)*v0, v1, 11); return 1; } @@ -6638,7 +6634,7 @@ static BOOL ScrCmd_239(ScriptContext *ctx) { u16 v0 = ScriptContext_ReadHalfWord(ctx); - ov7_0224BE7C(ctx->taskManager, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); + ov7_0224BE7C(ctx->task, FieldSystem_GetVarPointer(ctx->fieldSystem, v0)); return 1; } @@ -6951,27 +6947,25 @@ static BOOL ScrCmd_264(ScriptContext *ctx) return 1; } -static BOOL ScrCmd_265(ScriptContext *ctx) +static BOOL ScrCmd_HidePoketch(ScriptContext *ctx) { - VarsFlags *v0 = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); - - sub_0206AE0C(v0); - return 0; + VarsFlags *varsFlags = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); + SystemFlag_SetPoketchHidden(varsFlags); + return FALSE; } -static BOOL ScrCmd_266(ScriptContext *ctx) +static BOOL ScrCmd_ShowPoketch(ScriptContext *ctx) { - VarsFlags *v0 = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); - - sub_0206AE1C(v0); - return 0; + VarsFlags *varsFlags = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); + SystemFlag_ClearPoketchHidden(varsFlags); + return FALSE; } static BOOL ScrCmd_267(ScriptContext *ctx) { u16 v0 = ScriptContext_GetVar(ctx); - sub_0203E414(ctx->fieldSystem->taskManager, v0); + sub_0203E414(ctx->fieldSystem->task, v0); return 1; } @@ -6998,7 +6992,7 @@ static BOOL ScrCmd_269(ScriptContext *ctx) GF_ASSERT(FALSE); } - sub_0205E318(ctx->taskManager, v0, v2, v3, v4, v5); + sub_0205E318(ctx->task, v0, v2, v3, v4, v5); return 1; } @@ -7015,7 +7009,7 @@ static BOOL ScrCmd_26A(ScriptContext *ctx) GF_ASSERT(FALSE); } - sub_0205E3F4(ctx->taskManager, v0, v2, v3); + sub_0205E3F4(ctx->task, v0, v2, v3); return 1; } @@ -7579,9 +7573,9 @@ static BOOL ScrCmd_29F(ScriptContext *ctx) u16 v0 = ScriptContext_GetVar(ctx); if (v0 == 0) { - ov6_0223E384(ctx->fieldSystem->taskManager); + ov6_0223E384(ctx->fieldSystem->task); } else { - ov6_0223E4EC(ctx->fieldSystem->taskManager); + ov6_0223E4EC(ctx->fieldSystem->task); } return 1; @@ -7796,7 +7790,7 @@ static BOOL ScrCmd_2C4(ScriptContext *ctx) v2->unk_10 = ctx->fieldSystem->unk_98; v2->unk_20 = ctx->fieldSystem->unk_BC; - sub_02050A38(ctx->taskManager, &Unk_020F8BE0, v2); + FieldTask_RunApplication(ctx->task, &Unk_020F8BE0, v2); ScriptContext_Pause(ctx, sub_02041CC8); return 1; @@ -7894,7 +7888,7 @@ static BOOL ScrCmd_2D8(ScriptContext *ctx) v2, }; - ov7_0224CDA4(ctx->taskManager, ctx->fieldSystem, (u16 *)v3[v0], 3, 0); + ov7_0224CDA4(ctx->task, ctx->fieldSystem, (u16 *)v3[v0], 3, 0); return 1; } @@ -8086,7 +8080,7 @@ static BOOL ScrCmd_2F7(ScriptContext *ctx) u16 *v1 = FieldSystem_GetVarPointer(ctx->fieldSystem, v0); if (sub_02039074(ctx->fieldSystem->saveData)) { - sub_0205749C(ctx->taskManager, *v1); + sub_0205749C(ctx->task, *v1); } return 1; @@ -8094,7 +8088,7 @@ static BOOL ScrCmd_2F7(ScriptContext *ctx) static BOOL ScrCmd_2FB(ScriptContext *ctx) { - sub_020985E4(ctx->taskManager, ctx->fieldSystem->saveData); + sub_020985E4(ctx->task, ctx->fieldSystem->saveData); return 1; } diff --git a/src/scrcmd_system_flags.c b/src/scrcmd_system_flags.c new file mode 100644 index 0000000000..fe27bbfe28 --- /dev/null +++ b/src/scrcmd_system_flags.c @@ -0,0 +1,238 @@ +#include "scrcmd_system_flags.h" + +#include "consts/badges.h" + +#include "struct_decls/pokedexdata_decl.h" +#include "struct_decls/struct_0203A790_decl.h" +#include "struct_defs/struct_0205EC34.h" + +#include "field_overworld_state.h" +#include "field_script_context.h" +#include "inlines.h" +#include "player_avatar.h" +#include "save_player.h" +#include "system_flags.h" +#include "trainer_info.h" +#include "unk_0202631C.h" +#include "vars_flags.h" + +BOOL ScrCmd_CheckPokedexAcquired(ScriptContext *ctx) +{ + const PokedexData *pokedex = SaveData_Pokedex(ctx->fieldSystem->saveData); + u16 *destVar = ScriptContext_GetVarPointer(ctx); + *destVar = Pokedex_IsObtained(pokedex); + return FALSE; +} + +BOOL ScrCmd_GivePokedex(ScriptContext *ctx) +{ + PokedexData *pokedex = SaveData_Pokedex(ctx->fieldSystem->saveData); + Pokedex_FlagObtained(pokedex); + return FALSE; +} + +BOOL ScrCmd_CheckRunningShoesAcquired(ScriptContext *ctx) +{ + u16 *destVar = ScriptContext_GetVarPointer(ctx); + FieldOverworldState *overworldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + PlayerData *playerData = FieldOverworldState_GetPlayerData(overworldState); + *destVar = PlayerData_HasRunningShoes(playerData); + return FALSE; +} + +BOOL ScrCmd_GiveRunningShoes(ScriptContext *ctx) +{ + FieldOverworldState *overworldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + PlayerData *playerData = FieldOverworldState_GetPlayerData(overworldState); + PlayerData_SetRunningShoes(playerData, TRUE); + return FALSE; +} + +BOOL ScrCmd_CheckBadgeAcquired(ScriptContext *ctx) +{ + u16 badgeNum = ScriptContext_GetVar(ctx); + u16 *destVar = ScriptContext_GetVarPointer(ctx); + + GF_ASSERT(badgeNum < MAX_BADGES); + *destVar = TrainerInfo_HasBadge(SaveData_GetTrainerInfo(ctx->fieldSystem->saveData), badgeNum); + + return FALSE; +} + +BOOL ScrCmd_GiveBadge(ScriptContext *ctx) +{ + u16 badgeNum = ScriptContext_GetVar(ctx); + + GF_ASSERT(badgeNum < MAX_BADGES); + TrainerInfo_SetBadge(SaveData_GetTrainerInfo(ctx->fieldSystem->saveData), badgeNum); + + return FALSE; +} + +BOOL ScrCmd_CheckBagAcquired(ScriptContext *ctx) +{ + u16 *destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckBagAcquired(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +// Game Freak moment. +static const u8 sBadgeIDs[MAX_BADGES] = { + BADGE_ID_COAL, + BADGE_ID_FOREST, + BADGE_ID_COBBLE, + BADGE_ID_FEN, + BADGE_ID_RELIC, + BADGE_ID_MINE, + BADGE_ID_ICICLE, + BADGE_ID_BEACON, +}; + +BOOL ScrCmd_CountBadgesAcquired(ScriptContext *ctx) +{ + u16 i, count; + u16 *destVar = ScriptContext_GetVarPointer(ctx); + for (i = 0, count = 0; i < MAX_BADGES; i++) { + if (TrainerInfo_HasBadge(SaveData_GetTrainerInfo(ctx->fieldSystem->saveData), sBadgeIDs[i]) == TRUE) { + count++; + } + } + + *destVar = count; + return FALSE; +} + +BOOL ScrCmd_GiveBag(ScriptContext *ctx) +{ + SystemFlag_SetBagAcquired(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_CheckHasPartner(ScriptContext *ctx) +{ + u16 *destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_SetHasPartner(ScriptContext *ctx) +{ + SystemFlag_SetHasPartner(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_ClearHasPartner(ScriptContext *ctx) +{ + SystemFlag_ClearHasPartner(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_CheckStepFlag(ScriptContext *ctx) +{ + u16 *destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckStep(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_SetStepFlag(ScriptContext *ctx) +{ + SystemFlag_SetStep(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_ClearStepFlag(ScriptContext *ctx) +{ + SystemFlag_ClearStep(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_CheckGameCompleted(ScriptContext *ctx) +{ + u16 *destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_SetGameCompleted(ScriptContext *ctx) +{ + SystemFlag_SetGameCompleted(SaveData_GetVarsFlags(ctx->fieldSystem->saveData)); + return FALSE; +} + +BOOL ScrCmd_Strength(ScriptContext *ctx) +{ + u16 *destVar; + VarsFlags *varsFlags = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); + + switch (ScriptContext_ReadByte(ctx)) { + case 1: + SystemFlag_HandleStrengthActive(varsFlags, HANDLE_FLAG_SET); + break; + + case 0: + SystemFlag_HandleStrengthActive(varsFlags, HANDLE_FLAG_CLEAR); + break; + + case 2: + destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_HandleStrengthActive(varsFlags, HANDLE_FLAG_CHECK); + break; + + default: + GF_ASSERT(FALSE); + } + + return FALSE; +} + +BOOL ScrCmd_Flash(ScriptContext *ctx) +{ + u16 *destVar; + VarsFlags *varsFlags = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); + + switch (ScriptContext_ReadByte(ctx)) { + case 1: + SystemFlag_SetFlashActive(varsFlags); + break; + + case 0: + SystemFlag_ClearFlashActive(varsFlags); + break; + + case 2: + destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckFlashActive(varsFlags); + break; + + default: + GF_ASSERT(FALSE); + } + + return FALSE; +} + +BOOL ScrCmd_Defog(ScriptContext *ctx) +{ + u16 *destVar; + VarsFlags *varsFlags = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); + + switch (ScriptContext_ReadByte(ctx)) { + case 1: + SystemFlag_SetDefogActive(varsFlags); + break; + + case 0: + SystemFlag_ClearDefogActive(varsFlags); + break; + + case 2: + destVar = ScriptContext_GetVarPointer(ctx); + *destVar = SystemFlag_CheckDefogActive(varsFlags); + break; + + default: + GF_ASSERT(FALSE); + } + + return FALSE; +} diff --git a/src/script_manager.c b/src/script_manager.c index 675ffa7523..7a74edd884 100644 --- a/src/script_manager.c +++ b/src/script_manager.c @@ -11,6 +11,7 @@ #include "field/scripts/scr_seq.naix" #include "field_menu.h" +#include "field_task.h" #include "heap.h" #include "map_header.h" #include "map_header_data.h" @@ -21,13 +22,12 @@ #include "strbuf.h" #include "trainer_data.h" #include "unk_0201D15C.h" -#include "unk_020508D4.h" #include "vars_flags.h" #include "constdata/const_020EAB80.h" #include "constdata/const_020EAC58.h" -static BOOL FieldTask_RunScript(TaskManager *taskManager); +static BOOL FieldTask_RunScript(FieldTask *taskManager); static ScriptManager *ScriptManager_New(); static void ScriptContext_Free(ScriptContext *ctx); static void sub_0203EA68(FieldSystem *fieldSystem, ScriptManager *scriptManager, u16 scriptID, MapObject *object, void *saveType); @@ -47,12 +47,12 @@ void ScriptManager_Set(FieldSystem *fieldSystem, u16 scriptID, MapObject *object ScriptManager *scriptManager = ScriptManager_New(); sub_0203EA68(fieldSystem, scriptManager, scriptID, object, NULL); - FieldTask_Set(fieldSystem, FieldTask_RunScript, scriptManager); + FieldSystem_CreateTask(fieldSystem, FieldTask_RunScript, scriptManager); } void ScriptManager_SetApproachingTrainer(FieldSystem *fieldSystem, MapObject *object, int sightRange, int direction, int scriptID, int trainerID, int trainerType, int approachNum) { - ScriptManager *scriptManager = TaskManager_Environment(fieldSystem->taskManager); + ScriptManager *scriptManager = FieldTask_GetEnv(fieldSystem->task); ApproachingTrainer *trainer = &scriptManager->trainers[approachNum]; trainer->sightRange = sightRange; @@ -63,31 +63,31 @@ void ScriptManager_SetApproachingTrainer(FieldSystem *fieldSystem, MapObject *ob trainer->object = object; } -void ScriptManager_Start(TaskManager *taskManager, u16 scriptID, MapObject *object, void *saveType) +void ScriptManager_Start(FieldTask *taskManager, u16 scriptID, MapObject *object, void *saveType) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskManager); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskManager); ScriptManager *scriptManager = ScriptManager_New(); sub_0203EA68(fieldSystem, scriptManager, scriptID, object, saveType); - FieldTask_Start(taskManager, FieldTask_RunScript, scriptManager); + FieldTask_InitCall(taskManager, FieldTask_RunScript, scriptManager); } -void ScriptManager_Change(TaskManager *taskManager, u16 scriptID, MapObject *object) +void ScriptManager_Change(FieldTask *taskManager, u16 scriptID, MapObject *object) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskManager); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskManager); ScriptManager *scriptManager = ScriptManager_New(); sub_0203EA68(fieldSystem, scriptManager, scriptID, object, NULL); - FieldTask_Change(taskManager, FieldTask_RunScript, scriptManager); + FieldTask_InitJump(taskManager, FieldTask_RunScript, scriptManager); } -static BOOL FieldTask_RunScript(TaskManager *taskManager) +static BOOL FieldTask_RunScript(FieldTask *taskManager) { int i; FieldSysFunc scriptFunction; ScriptContext *ctx = NULL; - ScriptManager *scriptManager = TaskManager_Environment(taskManager); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskManager); + ScriptManager *scriptManager = FieldTask_GetEnv(taskManager); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskManager); switch (scriptManager->state) { case 0: @@ -187,7 +187,7 @@ static void sub_0203EAF4(FieldSystem *fieldSystem, ScriptContext *ctx, u16 scrip ScriptContext_Start(ctx, ctx->scripts); sub_0203F0E4(ctx, offsetID); - ScriptContext_SetTaskManager(ctx, fieldSystem->taskManager); + ScriptContext_SetTask(ctx, fieldSystem->task); } static u16 ScriptContext_LoadAndOffsetID(FieldSystem *fieldSystem, ScriptContext *ctx, u16 scriptID) @@ -434,7 +434,7 @@ void *ScriptManager_GetMemberPtr(ScriptManager *scriptManager, u32 member) void *FieldSystem_GetScriptMemberPtr(FieldSystem *fieldSystem, u32 member) { - ScriptManager *script = TaskManager_Environment(fieldSystem->taskManager); + ScriptManager *script = FieldTask_GetEnv(fieldSystem->task); GF_ASSERT(script->magic == SCRIPT_MANAGER_MAGIC_NUMBER); @@ -443,7 +443,7 @@ void *FieldSystem_GetScriptMemberPtr(FieldSystem *fieldSystem, u32 member) void sub_0203F0C0(FieldSystem *fieldSystem) { - ScriptManager *scriptManager = TaskManager_Environment(fieldSystem->taskManager); + ScriptManager *scriptManager = FieldTask_GetEnv(fieldSystem->task); if (sub_0203A9C8(fieldSystem) == 1) { scriptManager->function = sub_0203AB00; diff --git a/src/system_flags.c b/src/system_flags.c new file mode 100644 index 0000000000..c244aa0be5 --- /dev/null +++ b/src/system_flags.c @@ -0,0 +1,521 @@ +#include "system_flags.h" + +#include "constants/savedata/vars_flags.h" +#include "consts/map.h" +#include "consts/pokemon.h" +#include "consts/sdat.h" + +#include "rtc.h" +#include "vars_flags.h" + +static void SetFlag(VarsFlags *varsFlags, u16 flagID); +static void ClearFlag(VarsFlags *varsFlags, u16 flagID); +static BOOL CheckFlag(VarsFlags *varsFlags, u16 flagID); +static BOOL HandleFlag(VarsFlags *varsFlags, enum HandleFlagOp op, u32 flagID); + +static void SetFlag(VarsFlags *varsFlags, u16 flagID) +{ + VarsFlags_SetFlag(varsFlags, flagID); +} + +static void ClearFlag(VarsFlags *varsFlags, u16 flagID) +{ + VarsFlags_ClearFlag(varsFlags, flagID); +} + +static BOOL CheckFlag(VarsFlags *varsFlags, u16 flagID) +{ + return VarsFlags_CheckFlag(varsFlags, flagID); +} + +static BOOL HandleFlag(VarsFlags *varsFlags, enum HandleFlagOp op, u32 flagID) +{ + switch (op) { + case HANDLE_FLAG_SET: + SetFlag(varsFlags, flagID); + break; + + case HANDLE_FLAG_CLEAR: + ClearFlag(varsFlags, flagID); + break; + + case HANDLE_FLAG_CHECK: + return CheckFlag(varsFlags, flagID); + + default: + GF_ASSERT(FALSE); + } + + return FALSE; +} + +void SystemFlag_SetBagAcquired(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_BAG_ACQUIRED); +} + +BOOL SystemFlag_CheckBagAcquired(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_BAG_ACQUIRED); +} + +void SystemFlag_SetGameCompleted(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_GAME_COMPLETED); +} + +BOOL SystemFlag_CheckGameCompleted(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_GAME_COMPLETED); +} + +void SystemFlag_SetHasPartner(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_HAS_PARTNER); +} + +void SystemFlag_ClearHasPartner(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_HAS_PARTNER); +} + +BOOL SystemFlag_CheckHasPartner(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_HAS_PARTNER); +} + +void SystemFlag_SetStep(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_STEP); +} + +void SystemFlag_ClearStep(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_STEP); +} + +BOOL SystemFlag_CheckStep(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_STEP); +} + +void SystemFlag_SetVsSeekerUsed(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_VS_SEEKER_USED); +} + +void SystemFlag_ClearVsSeekerUsed(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_VS_SEEKER_USED); +} + +BOOL SystemFlag_CheckVsSeekerUsed(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_VS_SEEKER_USED); +} + +void SystemFlag_SetEnteredUnderground(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_ENTERED_UNDERGROUND); +} + +void SystemFlag_SetDiggingForFossils(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_DIGGING_FOR_FOSSILS); +} + +void SystemFlag_SetSphereAcquired(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_SPHERE_ACQUIRED); +} + +void SystemFlag_SetCreatedSecretBase(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_CREATED_SECRET_BASE); +} + +void SystemFlag_SetDecoratedSecretBase(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_DECORATED_SECRET_BASE); +} + +void SystemFlag_SetDeliveredStolenFlag(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_DELIVERED_STOLEN_FLAG); +} + +void SystemFlag_SetContestMaster(VarsFlags *varsFlags, enum PokemonContestType contestType) +{ + switch (contestType) { + case CONTEST_TYPE_COOL: + SetFlag(varsFlags, FLAG_CONTEST_MASTER_COOL); + break; + + case CONTEST_TYPE_CUTE: + SetFlag(varsFlags, FLAG_CONTEST_MASTER_CUTE); + break; + + case CONTEST_TYPE_BEAUTY: + SetFlag(varsFlags, FLAG_CONTEST_MASTER_BEAUTY); + break; + + case CONTEST_TYPE_SMART: + SetFlag(varsFlags, FLAG_CONTEST_MASTER_SMART); + break; + + case CONTEST_TYPE_TOUGH: + SetFlag(varsFlags, FLAG_CONTEST_MASTER_TOUGH); + break; + } +} + +BOOL SystemFlag_CheckContestMaster(VarsFlags *varsFlags, enum PokemonContestType contestType) +{ + BOOL result; + switch (contestType) { + case CONTEST_TYPE_COOL: + result = CheckFlag(varsFlags, FLAG_CONTEST_MASTER_COOL); + break; + + case CONTEST_TYPE_CUTE: + result = CheckFlag(varsFlags, FLAG_CONTEST_MASTER_CUTE); + break; + + case CONTEST_TYPE_BEAUTY: + result = CheckFlag(varsFlags, FLAG_CONTEST_MASTER_BEAUTY); + break; + + case CONTEST_TYPE_SMART: + result = CheckFlag(varsFlags, FLAG_CONTEST_MASTER_SMART); + break; + + case CONTEST_TYPE_TOUGH: + result = CheckFlag(varsFlags, FLAG_CONTEST_MASTER_TOUGH); + break; + } + + return result; +} + +BOOL SystemFlag_CheckUnlockedVsSeekerLevel(VarsFlags *varsFlags, int level) +{ + BOOL result = FALSE; + + switch (level) { + case 1: + result = CheckFlag(varsFlags, FLAG_UNLOCKED_VS_SEEKER_LVL_1); + break; + + case 2: + result = CheckFlag(varsFlags, FLAG_UNLOCKED_VS_SEEKER_LVL_2); + break; + + case 3: + result = CheckFlag(varsFlags, FLAG_UNLOCKED_VS_SEEKER_LVL_3); + break; + + case 4: + result = CheckFlag(varsFlags, FLAG_UNLOCKED_VS_SEEKER_LVL_4); + break; + + case 5: + result = CheckFlag(varsFlags, FLAG_UNLOCKED_VS_SEEKER_LVL_5); + break; + } + + return result; +} + +u16 SystemFlag_GetAltMusicForHeader(VarsFlags *varsFlags, enum MapHeader mapHeader) +{ + u16 sdatID = 0; + switch (mapHeader) { + case MAP_HEADER_LAKE_VALOR_DRAINED: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_LAKE_VALOR) == TRUE) { + sdatID = SEQ_D_LAKE; + } + break; + + case MAP_HEADER_VALOR_CAVERN: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_LAKE_VALOR) == TRUE) { + sdatID = SEQ_D_RYAYHY; + } + break; + + case MAP_HEADER_LAKE_VERITY: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_LAKE_VERITY) == TRUE) { + sdatID = SEQ_D_LAKE; + } + break; + + case MAP_HEADER_LAKE_ACUITY: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_LAKE_ACUITY) == TRUE) { + sdatID = SEQ_D_LAKE; + } + break; + + case MAP_HEADER_PAL_PARK: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_PAL_PARK) == TRUE) { + sdatID = SEQ_D_SAFARI; + } + break; + + case MAP_HEADER_SANDGEM_TOWN_POKEMON_RESEARCH_LAB: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_ROWANS_LAB) == TRUE) { + sdatID = SEQ_OPENING2; + } + break; + + case MAP_HEADER_GALACTIC_HQ_1F: + case MAP_HEADER_GALACTIC_HQ_2F: + case MAP_HEADER_GALACTIC_HQ_3F: + case MAP_HEADER_GALACTIC_HQ_4F: + case MAP_HEADER_GALACTIC_HQ_B1F: + case MAP_HEADER_GALACTIC_HQ_B2F: + case MAP_HEADER_GALACTIC_HQ_CONTROL_ROOM: + case MAP_HEADER_GALACTIC_HQ_LABORATORY: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_GALACTIC_HQ) == TRUE) { + if (!IsNight()) { + sdatID = SEQ_CITY07_D; + } else { + sdatID = SEQ_CITY07_N; + } + break; + } + + if (mapHeader == MAP_HEADER_GALACTIC_HQ_1F) { + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_GALACTIC_HQ_1F) == TRUE) { + sdatID = SEQ_D_AGITO; + } + } + break; + + case MAP_HEADER_TEAM_GALACTIC_ETERNA_BUILDING_1F: + case MAP_HEADER_TEAM_GALACTIC_ETERNA_BUILDING_2F: + case MAP_HEADER_TEAM_GALACTIC_ETERNA_BUILDING_3F: + case MAP_HEADER_TEAM_GALACTIC_ETERNA_BUILDING_4F: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_GALACTIC_ETERNA_BUILDING) == TRUE) { + if (!IsNight()) { + sdatID = SEQ_CITY04_D; + } else { + sdatID = SEQ_CITY04_N; + } + } + break; + + case MAP_HEADER_VALLEY_WINDWORKS_BUILDING: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_VALLEY_WINDWORKS_BUILDING) == TRUE) { + if (!IsNight()) { + sdatID = SEQ_ROAD_C_D; + } else { + sdatID = SEQ_ROAD_C_N; + } + } + break; + + case MAP_HEADER_FLOAROMA_MEADOW: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_FLOAROMA_MEADOW) == TRUE) { + if (!IsNight()) { + sdatID = SEQ_TOWN03_D; + } else { + sdatID = SEQ_TOWN03_N; + } + } + break; + + case MAP_HEADER_ROUTE_224: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_ROUTE_224) == TRUE) { + if (!IsNight()) { + sdatID = SEQ_TOWN03_D; + } else { + sdatID = SEQ_TOWN03_N; + } + } + break; + + case MAP_HEADER_POKEMON_LEAGUE_CHAMPION_ROOM: + if (CheckFlag(varsFlags, FLAG_ALT_MUSIC_CHAMPION_ROOM) == TRUE) { + sdatID = SEQ_SILENCE_FIELD; + } + break; + + default: + break; + } + + return sdatID; +} + +void SystemFlag_SetCommunicationClubAccessible(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_COMMUNICATION_CLUB_ACCESSIBLE); + return; +} + +void SystemFlag_ClearCommunicationClubAccessible(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_COMMUNICATION_CLUB_ACCESSIBLE); + return; +} + +BOOL SystemFlag_CheckCommunicationClubAccessible(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_COMMUNICATION_CLUB_ACCESSIBLE); +} + +BOOL SystemFlag_CheckContestHallVisited(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_CONTEST_HALL_VISITED); +} + +BOOL SystemFlag_CheckUndergroundFirstEntered(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_UNDERGROUND_FIRST_ENTERED); +} + +BOOL SystemFlag_CheckFreedGalacticHQPokemon(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_FREED_GALACTIC_HQ_POKEMON); +} + +BOOL SystemFlag_CheckMetBebe(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_MET_BEBE); +} + +void SystemFlag_SetPoketchHidden(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_POKETCH_HIDDEN); +} + +void SystemFlag_ClearPoketchHidden(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_POKETCH_HIDDEN); +} + +BOOL SystemFlag_CheckPoketchHidden(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_POKETCH_HIDDEN); +} + +void SystemFlag_SetSafariGameActive(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_SAFARI_GAME_ACTIVE); +} + +void SystemFlag_ClearSafariGameActive(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_SAFARI_GAME_ACTIVE); +} + +BOOL SystemFlag_CheckSafariGameActive(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_SAFARI_GAME_ACTIVE); +} + +void SystemFlag_SetInPalPark(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_IN_PAL_PARK); +} + +void SystemFlag_ClearInPalPark(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_IN_PAL_PARK); +} + +BOOL SystemFlag_CheckInPalPark(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_IN_PAL_PARK); +} + +void SystemFlag_CheckOnCyclingRoad(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_ON_CYCLING_ROAD); +} + +BOOL SystemFlag_HandleStrengthActive(VarsFlags *varsFlags, enum HandleFlagOp op) +{ + return HandleFlag(varsFlags, op, FLAG_STRENGTH_ACTIVE); +} + +void SystemFlag_SetFlashActive(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_FLASH_ACTIVE); +} + +void SystemFlag_ClearFlashActive(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_FLASH_ACTIVE); +} + +BOOL SystemFlag_CheckFlashActive(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_FLASH_ACTIVE); +} + +void SystemFlag_SetDefogActive(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_DEFOG_ACTIVE); +} + +void SystemFlag_ClearDefogActive(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_DEFOG_ACTIVE); +} + +BOOL SystemFlag_CheckDefogActive(VarsFlags *varsFlags) +{ + return CheckFlag(varsFlags, FLAG_DEFOG_ACTIVE); +} + +BOOL SystemFlag_HandleForceBikingInGate(VarsFlags *varsFlags, enum HandleFlagOp op) +{ + return HandleFlag(varsFlags, op, FLAG_FORCE_BIKING_IN_GATE); +} + +BOOL SystemFlag_HandleJournalAcquired(VarsFlags *varsFlags, enum HandleFlagOp op) +{ + return HandleFlag(varsFlags, op, FLAG_JOURNAL_ACQUIRED); +} + +BOOL SystemFlag_HandleFirstArrivalToZone(VarsFlags *varsFlags, enum HandleFlagOp op, u32 firstArrival) +{ + GF_ASSERT(firstArrival < FIRST_ARRIVAL_MAX); + return HandleFlag(varsFlags, op, SYSTEM_FLAGS_FIRST_ARRIVAL_TO_ZONE + firstArrival); +} + +void SystemFlag_SetConnectedToWiFi(VarsFlags *varsFlags) +{ + SetFlag(varsFlags, FLAG_CONNECTED_TO_WIFI); +} + +BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurniture furniture) +{ + GF_ASSERT(furniture < VILLA_FURNITURE_MAX); + return HandleFlag(varsFlags, op, SYSTEM_FLAGS_VILLA_FURNITURE_START + furniture); +} + +void SystemFlag_ClearVillaVisitorInside(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_VILLA_VISITOR_INSIDE); +} + +void SystemFlag_ClearVillaVisitorOutside(VarsFlags *varsFlags) +{ + ClearFlag(varsFlags, FLAG_VILLA_VISITOR_OUTSIDE); +} + +BOOL SystemFlag_HandleGiratinaAnimation(VarsFlags *varsFlags, enum HandleFlagOp op, enum GiratinaShadowAnimation anim) +{ + return HandleFlag(varsFlags, op, SYSTEM_FLAGS_GIRATINA_ANIM_START + anim); +} + +BOOL SystemFlag_HandleDistortionWorldPuzzleFinished(VarsFlags *varsFlags, enum HandleFlagOp op) +{ + return HandleFlag(varsFlags, op, FLAG_DISTORTION_WORLD_PUZZLE_FINISHED); +} + +BOOL SystemFlag_CheckDistortionWorldSteppingStones(VarsFlags *varsFlags) +{ + return HandleFlag(varsFlags, HANDLE_FLAG_CHECK, FLAG_DISTORTION_WORLD_STEPPING_STONES); +} diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c index 091a33805f..0cc60f1ced 100644 --- a/src/unk_0202631C.c +++ b/src/unk_0202631C.c @@ -1183,10 +1183,10 @@ BOOL Pokedex_IsObtained(const PokedexData *pokedex) return pokedex->pokedexObtained; } -void sub_02027540(PokedexData *param0) +void Pokedex_FlagObtained(PokedexData *pokedex) { - CheckPokedexIntegrity(param0); - param0->pokedexObtained = 1; + CheckPokedexIntegrity(pokedex); + pokedex->pokedexObtained = TRUE; } PokedexData *SaveData_Pokedex(SaveData *saveData) diff --git a/src/unk_0203A7D8.c b/src/unk_0203A7D8.c index e0127822e4..420dfb1f27 100644 --- a/src/unk_0203A7D8.c +++ b/src/unk_0203A7D8.c @@ -3,10 +3,13 @@ #include #include +#include "constants/savedata/vars_flags.h" + #include "field/field_system.h" #include "inlines.h" #include "location.h" +#include "system_flags.h" #include "vars_flags.h" typedef struct { @@ -22,26 +25,26 @@ typedef struct { } UnkStruct_020E97B4; static const UnkStruct_020E97B4 Unk_020E97B4[] = { - { 0x19E, 0x8, 0x8, 0x19B, 0x74, 0x376, 0x1, 0x1, 0x0 }, - { 0x1A4, 0x8, 0x6, 0x1A2, 0xB1, 0x34B, 0x1, 0x1, 0x1 }, - { 0x1AC, 0x8, 0x6, 0x1AA, 0xB0, 0x29B, 0x1, 0x1, 0x2 }, - { 0x1B3, 0x8, 0x6, 0x1B1, 0x236, 0x291, 0x1, 0x1, 0x3 }, - { 0x1BB, 0x8, 0x6, 0x1BA, 0x1D8, 0x21B, 0x1, 0x1, 0x4 }, - { 0x6, 0x8, 0x6, 0x3, 0xB4, 0x309, 0x1, 0x1, 0x7 }, - { 0x24, 0x8, 0x6, 0x21, 0x3A, 0x2D3, 0x1, 0x1, 0x8 }, - { 0x30, 0x8, 0x6, 0x2D, 0x12F, 0x2F5, 0x1, 0x1, 0x9 }, - { 0x45, 0x8, 0x6, 0x41, 0x131, 0x213, 0x1, 0x1, 0xA }, - { 0x65, 0x8, 0x6, 0x56, 0x1D1, 0x2BA, 0x1, 0x1, 0xB }, - { 0x7B, 0x8, 0x6, 0x78, 0x258, 0x330, 0x1, 0x1, 0xC }, - { 0x86, 0x8, 0x6, 0x84, 0x2CD, 0x264, 0x1, 0x1, 0xD }, - { 0x97, 0x8, 0x6, 0x96, 0x35C, 0x311, 0x1, 0x1, 0xE }, - { 0xA8, 0x8, 0x6, 0xA5, 0x17B, 0xEA, 0x1, 0x1, 0xF }, - { 0xAD, 0x8, 0x6, 0xAC, 0x34A, 0x257, 0x1, 0x0, 0x10 }, - { 0xBD, 0x8, 0x6, 0xBC, 0x287, 0x1AE, 0x1, 0x1, 0x11 }, - { 0x1C4, 0x8, 0x6, 0x1C2, 0x293, 0x153, 0x1, 0x1, 0x5 }, - { 0x1CB, 0x8, 0x6, 0x1C9, 0x322, 0x1D9, 0x1, 0x1, 0x6 }, - { 0x189, 0x8, 0x6, 0x188, 0x132, 0x38E, 0x0, 0x0, 0x42 }, - { 0xAF, 0x4, 0x3, 0xAC, 0x34F, 0x230, 0x1, 0x0, 0x44 } + { 0x19E, 0x8, 0x8, 0x19B, 0x74, 0x376, 0x1, 0x1, FIRST_ARRIVAL_TWINLEAF_TOWN }, + { 0x1A4, 0x8, 0x6, 0x1A2, 0xB1, 0x34B, 0x1, 0x1, FIRST_ARRIVAL_SANDGEM_TOWN }, + { 0x1AC, 0x8, 0x6, 0x1AA, 0xB0, 0x29B, 0x1, 0x1, FIRST_ARRIVAL_FLOAROMA_TOWN }, + { 0x1B3, 0x8, 0x6, 0x1B1, 0x236, 0x291, 0x1, 0x1, FIRST_ARRIVAL_SOLACEON_TOWN }, + { 0x1BB, 0x8, 0x6, 0x1BA, 0x1D8, 0x21B, 0x1, 0x1, FIRST_ARRIVAL_CELESTIC_TOWN }, + { 0x6, 0x8, 0x6, 0x3, 0xB4, 0x309, 0x1, 0x1, FIRST_ARRIVAL_JUBILIFE_CITY }, + { 0x24, 0x8, 0x6, 0x21, 0x3A, 0x2D3, 0x1, 0x1, FIRST_ARRIVAL_CANALAVE_CITY }, + { 0x30, 0x8, 0x6, 0x2D, 0x12F, 0x2F5, 0x1, 0x1, FIRST_ARRIVAL_OREBURGH_CITY }, + { 0x45, 0x8, 0x6, 0x41, 0x131, 0x213, 0x1, 0x1, FIRST_ARRIVAL_ETERNA_CITY }, + { 0x65, 0x8, 0x6, 0x56, 0x1D1, 0x2BA, 0x1, 0x1, FIRST_ARRIVAL_HEARTHOME_CITY }, + { 0x7B, 0x8, 0x6, 0x78, 0x258, 0x330, 0x1, 0x1, FIRST_ARRIVAL_PASTORIA_CITY }, + { 0x86, 0x8, 0x6, 0x84, 0x2CD, 0x264, 0x1, 0x1, FIRST_ARRIVAL_VEILSTONE_CITY }, + { 0x97, 0x8, 0x6, 0x96, 0x35C, 0x311, 0x1, 0x1, FIRST_ARRIVAL_SUNYSHORE_CITY }, + { 0xA8, 0x8, 0x6, 0xA5, 0x17B, 0xEA, 0x1, 0x1, FIRST_ARRIVAL_SNOWPOINT_CITY }, + { 0xAD, 0x8, 0x6, 0xAC, 0x34A, 0x257, 0x1, 0x0, FIRST_ARRIVAL_OUTSIDE_VICTORY_ROAD }, + { 0xBD, 0x8, 0x6, 0xBC, 0x287, 0x1AE, 0x1, 0x1, FIRST_ARRIVAL_FIGHT_AREA }, + { 0x1C4, 0x8, 0x6, 0x1C2, 0x293, 0x153, 0x1, 0x1, FIRST_ARRIVAL_SURVIVAL_AREA }, + { 0x1CB, 0x8, 0x6, 0x1C9, 0x322, 0x1D9, 0x1, 0x1, FIRST_ARRIVAL_RESORT_AREA }, + { 0x189, 0x8, 0x6, 0x188, 0x132, 0x38E, 0x0, 0x0, FIRST_ARRIVAL_ROUTE_221 }, + { 0xAF, 0x4, 0x3, 0xAC, 0x34F, 0x230, 0x1, 0x0, FIRST_ARRIVAL_POKEMON_LEAGUE } }; static int sub_0203A7D8(int param0) @@ -134,7 +137,7 @@ void sub_0203A8E8(FieldSystem *fieldSystem, int param1) for (v0 = 0; v0 < NELEMS(Unk_020E97B4); v0++) { if ((Unk_020E97B4[v0].unk_06 == param1) && Unk_020E97B4[v0].unk_0D) { - inline_0203A8E8(SaveData_GetVarsFlags(fieldSystem->saveData), Unk_020E97B4[v0].unk_0E); + SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_SET, Unk_020E97B4[v0].unk_0E); return; } } @@ -143,5 +146,5 @@ void sub_0203A8E8(FieldSystem *fieldSystem, int param1) BOOL sub_0203A920(FieldSystem *fieldSystem, int param1) { int v0 = sub_0203A7D8(param1); - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), Unk_020E97B4[v0].unk_0E); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, Unk_020E97B4[v0].unk_0E); } diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index a376f11f3e..c575aaf18c 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -9,7 +9,6 @@ #include "struct_decls/struct_02029D04_decl.h" #include "struct_decls/struct_0202A750_decl.h" #include "struct_decls/struct_0202C834_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0207AE68_decl.h" #include "struct_decls/struct_0209747C_decl.h" #include "struct_decls/struct_party_decl.h" @@ -91,6 +90,7 @@ #include "coins.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "game_options.h" #include "game_records.h" #include "heap.h" @@ -107,6 +107,7 @@ #include "savedata_misc.h" #include "strbuf.h" #include "system_data.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02017498.h" #include "unk_0201D15C.h" @@ -121,12 +122,10 @@ #include "unk_0202DA40.h" #include "unk_020366A0.h" #include "unk_02038FFC.h" -#include "unk_020508D4.h" #include "unk_020553DC.h" #include "unk_02055808.h" #include "unk_020559DC.h" #include "unk_0205B33C.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206B70C.h" #include "unk_0206CCB0.h" @@ -227,7 +226,7 @@ typedef struct { UnkStruct_0203E348 unk_0C; } UnkStruct_0203E35C; -static void sub_0203DF68(TaskManager *taskMan); +static void sub_0203DF68(FieldTask *taskMan); static u8 sub_0203E484(SaveData *saveData, u8 param1); static BOOL OverlayInit_Battle(OverlayManager *ovyManager, int *state) @@ -454,14 +453,14 @@ int sub_0203D440(void *param0) return v0->pos; } -static BOOL sub_0203D444(TaskManager *param0) +static BOOL sub_0203D444(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_0203D444 *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); v2 = FieldTask_GetState(param0); switch (*v2) { @@ -470,7 +469,7 @@ static BOOL sub_0203D444(TaskManager *param0) *v2 = 1; break; case 1: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { switch (v1->unk_04->unk_22) { case 7: sub_0205BAAC(2); @@ -492,7 +491,7 @@ static BOOL sub_0203D444(TaskManager *param0) *v2 = 3; break; case 3: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { Heap_FreeToHeap(v1->unk_08); *v2 = 0; } @@ -505,11 +504,11 @@ static BOOL sub_0203D444(TaskManager *param0) return 0; } -void *sub_0203D50C(TaskManager *taskMan, int param1) +void *sub_0203D50C(FieldTask *taskMan, int param1) { UnkStruct_0203D444 *v0; PartyManagementData *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); v0 = Heap_AllocFromHeap(param1, sizeof(UnkStruct_0203D444)); v0->unk_00 = param1; @@ -520,7 +519,7 @@ void *sub_0203D50C(TaskManager *taskMan, int param1) v1->unk_14 = NULL; v0->unk_04 = v1; - FieldTask_Start(taskMan, sub_0203D444, v0); + FieldTask_InitCall(taskMan, sub_0203D444, v0); return v1; } @@ -656,11 +655,11 @@ void sub_0203D754(FieldSystem *fieldSystem, UnkStruct_02042434 *param1) FieldSystem_StartChildProcess(fieldSystem, &v0, param1); } -static BOOL sub_0203D764(TaskManager *taskMan) +static BOOL sub_0203D764(FieldTask *taskMan) { int *v0 = FieldTask_GetState(taskMan); - UnkStruct_0203D764 *v1 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0203D764 *v1 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); switch (*v0) { case 0: @@ -668,7 +667,7 @@ static BOOL sub_0203D764(TaskManager *taskMan) (*v0)++; break; case 1: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { (*v0)++; } break; @@ -698,12 +697,12 @@ static BOOL sub_0203D764(TaskManager *taskMan) return 0; } -void sub_0203D80C(TaskManager *taskMan, u16 *param1, u16 *param2, u16 *param3) +void sub_0203D80C(FieldTask *taskMan, u16 *param1, u16 *param2, u16 *param3) { UnkStruct_0203D764 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0203D764)); + v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0203D764)); v0->unk_00 = param1; v0->unk_04 = param2; v0->unk_08 = param3; @@ -716,7 +715,7 @@ void sub_0203D80C(TaskManager *taskMan, u16 *param1, u16 *param2, u16 *param3) sub_020974F8(v0->unk_0C, *param2, *param3); } - FieldTask_Start(taskMan, sub_0203D764, v0); + FieldTask_InitCall(taskMan, sub_0203D764, v0); } void sub_0203D874(FieldSystem *fieldSystem, UnkStruct_0209747C *param1) @@ -886,10 +885,10 @@ static UnkStruct_0203DA00 *sub_0203DA00(int param0, SaveData *param1, int param2 return v0; } -static BOOL sub_0203DA64(TaskManager *param0) +static BOOL sub_0203DA64(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0203DA64 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0203DA64 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -897,7 +896,7 @@ static BOOL sub_0203DA64(TaskManager *param0) v1->unk_00++; break; case 1: - if (sub_020509B4(fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(fieldSystem) == 0) { if (v1->unk_08 == 1) { *v1->unk_04 = 1; } else { @@ -915,17 +914,17 @@ static BOOL sub_0203DA64(TaskManager *param0) return 0; } -void sub_0203DAC0(TaskManager *param0, u16 *param1, SaveData *param2, u16 param3, u16 param4) +void sub_0203DAC0(FieldTask *param0, u16 *param1, SaveData *param2, u16 param3, u16 param4) { UnkStruct_0203DA64 *v0; - v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0203DA64)); + v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0203DA64)); memset(v0, 0, sizeof(UnkStruct_0203DA64)); v0->unk_0C = sub_0203DA00(32, param2, param3, &v0->unk_08, param4); v0->unk_04 = param1; - FieldTask_Start(param0, sub_0203DA64, v0); + FieldTask_InitCall(param0, sub_0203DA64, v0); } BOOL sub_0203DB10(FieldSystem *fieldSystem, void *param1) @@ -986,9 +985,9 @@ static void sub_0203DB38(UnkStruct_ov88_0223C370 *param0, FieldSystem *fieldSyst param0->unk_10 = fieldSystem->saveData; param0->unk_1C = fieldSystem->journal; param0->records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); - param0->unk_38 = Heap_AllocFromHeap(32, TrainerInfo_Size()); - param0->unk_3C = Heap_AllocFromHeap(32, Pokemon_GetStructSize()); - param0->unk_40 = Heap_AllocFromHeap(32, Pokemon_GetStructSize()); + param0->unk_38 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, TrainerInfo_Size()); + param0->unk_3C = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, Pokemon_GetStructSize()); + param0->unk_40 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, Pokemon_GetStructSize()); param0->fieldSystem = fieldSystem; param0->unk_34 = 0; } @@ -1011,11 +1010,11 @@ static void sub_0203DBC0(UnkStruct_ov88_0223C370 *param0) } } -BOOL sub_0203DBF0(TaskManager *param0) +BOOL sub_0203DBF0(FieldTask *param0) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0203DBF0 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0203DBF0 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_00) { case 0: @@ -1029,7 +1028,7 @@ BOOL sub_0203DBF0(TaskManager *param0) sub_0203DB38(&(v2->unk_04), fieldSystem); v2->unk_00++; case 2: - sub_02050A38(param0, &Unk_02100AA4, &v2->unk_04); + FieldTask_RunApplication(param0, &Unk_02100AA4, &v2->unk_04); v2->unk_00++; break; case 3: @@ -1067,7 +1066,7 @@ BOOL sub_0203DBF0(TaskManager *param0) v2->unk_48.unk_0C = 3; } - sub_02050A38(param0, &Unk_020EA268, &v2->unk_48); + FieldTask_RunApplication(param0, &Unk_020EA268, &v2->unk_48); v2->unk_00 = 5; break; case 5: { @@ -1109,12 +1108,12 @@ BOOL sub_0203DBF0(TaskManager *param0) return 0; } -void sub_0203DDDC(TaskManager *param0) +void sub_0203DDDC(FieldTask *param0) { - UnkStruct_0203DBF0 *v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0203DBF0)); + UnkStruct_0203DBF0 *v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0203DBF0)); v0->unk_00 = 0; - FieldTask_Start(param0, sub_0203DBF0, v0); + FieldTask_InitCall(param0, sub_0203DBF0, v0); } const OverlayManagerTemplate Unk_020EA258 = { @@ -1133,7 +1132,7 @@ const OverlayManagerTemplate Unk_020EA248 = { void sub_0203DDFC(FieldSystem *fieldSystem) { - UnkStruct_0203DDFC *v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0203DDFC)); + UnkStruct_0203DDFC *v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0203DDFC)); v0->unk_00 = fieldSystem->unk_80; v0->unk_04 = fieldSystem->journal; @@ -1174,11 +1173,11 @@ void sub_0203DE88(FieldSystem *fieldSystem, SaveData *param1) FieldSystem_StartChildProcess(fieldSystem, &Unk_020F2FCC, fieldSystem); } -static BOOL sub_0203DE98(TaskManager *param0) +static BOOL sub_0203DE98(FieldTask *param0) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0203DE98 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0203DE98 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_00) { case 0: @@ -1186,7 +1185,7 @@ static BOOL sub_0203DE98(TaskManager *param0) v2->unk_00++; break; case 1: - sub_02050A38(param0, &Unk_020F2DAC, v2->unk_0C); + FieldTask_RunApplication(param0, &Unk_020F2DAC, v2->unk_0C); v2->unk_00++; break; case 2: @@ -1225,10 +1224,10 @@ static BOOL sub_0203DE98(TaskManager *param0) return 0; } -static void sub_0203DF68(TaskManager *param0) +static void sub_0203DF68(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0203DE98 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0203DE98 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_0C->unk_00) { case 0: { @@ -1255,10 +1254,10 @@ static void sub_0203DF68(TaskManager *param0) return; } -void sub_0203DFE8(TaskManager *param0, int param1, int param2, int param3, int param4, const u16 *param5, u16 *param6) +void sub_0203DFE8(FieldTask *param0, int param1, int param2, int param3, int param4, const u16 *param5, u16 *param6) { Pokemon *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0203DE98 *v2 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_0203DE98)); v2->unk_00 = 0; @@ -1287,7 +1286,7 @@ void sub_0203DFE8(TaskManager *param0, int param1, int param2, int param3, int p break; } - FieldTask_Start(param0, sub_0203DE98, v2); + FieldTask_InitCall(param0, sub_0203DE98, v2); } void sub_0203E09C(FieldSystem *fieldSystem, TrainerCard *param1) @@ -1531,7 +1530,7 @@ void sub_0203E2FC(FieldSystem *fieldSystem) v0.unk_08 = SaveData_GetTrainerInfo(fieldSystem->saveData); v0.unk_0C = sub_02055428(fieldSystem, fieldSystem->location->mapId); - sub_020985AC(fieldSystem->taskManager, &v0); + sub_020985AC(fieldSystem->task, &v0); } BOOL sub_0203E348(FieldSystem *fieldSystem, UnkStruct_0203E348 *param1) @@ -1549,11 +1548,11 @@ BOOL sub_0203E348(FieldSystem *fieldSystem, UnkStruct_0203E348 *param1) return 1; } -static BOOL sub_0203E35C(TaskManager *param0) +static BOOL sub_0203E35C(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); - UnkStruct_0203E35C *v2 = TaskManager_Environment(param0); + UnkStruct_0203E35C *v2 = FieldTask_GetEnv(param0); int *v3 = FieldTask_GetState(param0); int v4; @@ -1563,7 +1562,7 @@ static BOOL sub_0203E35C(TaskManager *param0) (*v3)++; break; case 1: - if (sub_020509B4(fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(fieldSystem) == 0) { u16 *v5 = SaveData_GetCoins(fieldSystem->saveData); s64 v6 = GetTimestamp(); @@ -1585,11 +1584,11 @@ static BOOL sub_0203E35C(TaskManager *param0) return 0; } -void sub_0203E414(TaskManager *param0, int param1) +void sub_0203E414(FieldTask *param0, int param1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); Options *v1 = SaveData_Options(fieldSystem->saveData); - UnkStruct_0203E35C *v2 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0203E35C)); + UnkStruct_0203E35C *v2 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0203E35C)); v2->unk_0C.unk_00 = &v2->unk_00; v2->unk_00 = Coins_GetValue(SaveData_GetCoins(fieldSystem->saveData)); @@ -1600,7 +1599,7 @@ void sub_0203E414(TaskManager *param0, int param1) v2->unk_0C.unk_04 = sub_0203E484(fieldSystem->saveData, param1); GameRecords_IncrementTrainerScore(SaveData_GetGameRecordsPtr(fieldSystem->saveData), TRAINER_SCORE_EVENT_UNK_05); - FieldTask_Start(param0, sub_0203E35C, v2); + FieldTask_InitCall(param0, sub_0203E35C, v2); } static u8 sub_0203E484(SaveData *param0, u8 param1) @@ -1642,9 +1641,9 @@ static u8 sub_0203E484(SaveData *param0, u8 param1) return v3[param1]; } -static BOOL sub_0203E4F8(TaskManager *param0) +static BOOL sub_0203E4F8(FieldTask *param0) { - UnkStruct_ov7_0224BEFC *v0 = TaskManager_Environment(param0); + UnkStruct_ov7_0224BEFC *v0 = FieldTask_GetEnv(param0); if (ov7_0224BF2C(v0) == 1) { ov7_0224BEFC(v0); @@ -1654,12 +1653,12 @@ static BOOL sub_0203E4F8(TaskManager *param0) return 0; } -void sub_0203E518(TaskManager *param0) +void sub_0203E518(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_ov7_0224BEFC *v1 = ov7_0224BE9C(4, fieldSystem->saveData, fieldSystem->bgConfig); - FieldTask_Start(param0, sub_0203E4F8, v1); + FieldTask_InitCall(param0, sub_0203E4F8, v1); } void *sub_0203E53C(FieldSystem *fieldSystem, int param1, int param2) @@ -1776,7 +1775,7 @@ void *sub_0203E63C(int param0, FieldSystem *fieldSystem, u16 param2, u16 param3) v0->mode = 2; v0->ribbons = sub_0202D79C(fieldSystem->saveData); v0->dexMode = sub_0207A274(fieldSystem->saveData); - v0->contest = ContestHall_IsVisited(SaveData_GetVarsFlags(fieldSystem->saveData)); + v0->contest = SystemFlag_CheckContestHallVisited(SaveData_GetVarsFlags(fieldSystem->saveData)); v0->chatotCry = NULL; PokemonSummary_FlagVisiblePages(v0, Unk_020EA15C); diff --git a/src/unk_02046AD4.c b/src/unk_02046AD4.c index 53ec505582..bc277da1bb 100644 --- a/src/unk_02046AD4.c +++ b/src/unk_02046AD4.c @@ -64,7 +64,7 @@ BOOL ScrCmd_147(ScriptContext *param0) v0[v3] = 0xffff; - ov7_0224CDA4(param0->taskManager, param0->fieldSystem, v0, 0, 0); + ov7_0224CDA4(param0->task, param0->fieldSystem, v0, 0, 0); return 1; } @@ -79,7 +79,7 @@ BOOL ScrCmd_148(ScriptContext *param0) v1 = 0; } - ov7_0224CDA4(param0->taskManager, param0->fieldSystem, (u16 *)PokeMartSpecialties[v0], 0, v1); + ov7_0224CDA4(param0->task, param0->fieldSystem, (u16 *)PokeMartSpecialties[v0], 0, v1); return 1; } @@ -94,7 +94,7 @@ BOOL ScrCmd_149(ScriptContext *param0) v1 = 0; } - ov7_0224CDA4(param0->taskManager, param0->fieldSystem, (u16 *)VeilstoneDeptStoreDecorationStocks[v0], 1, v1); + ov7_0224CDA4(param0->task, param0->fieldSystem, (u16 *)VeilstoneDeptStoreDecorationStocks[v0], 1, v1); return 1; } @@ -102,12 +102,12 @@ BOOL ScrCmd_14A(ScriptContext *param0) { u16 v0 = ScriptContext_GetVar(param0); - ov7_0224CDA4(param0->taskManager, param0->fieldSystem, (u16 *)SunyshoreMarketDailyStocks[v0], 2, 0); + ov7_0224CDA4(param0->task, param0->fieldSystem, (u16 *)SunyshoreMarketDailyStocks[v0], 2, 0); return 1; } BOOL ScrCmd_257(ScriptContext *param0) { - sub_0203E518(param0->fieldSystem->taskManager); + sub_0203E518(param0->fieldSystem->task); return 1; } diff --git a/src/unk_02046C7C.c b/src/unk_02046C7C.c index 1e35deaabe..0f637a1795 100644 --- a/src/unk_02046C7C.c +++ b/src/unk_02046C7C.c @@ -17,11 +17,11 @@ #include "script_manager.h" #include "strbuf.h" #include "string_template.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0202631C.h" #include "unk_020298BC.h" #include "unk_0202CC64.h" -#include "unk_0206A8DC.h" #include "unk_020933F8.h" #include "vars_flags.h" @@ -106,7 +106,7 @@ BOOL ScrCmd_0FA(ScriptContext *param0) v8.unk_00 = v5; v8.unk_01 = v4; v8.unk_02 = v6; - v8.unk_03 = sub_0206A954(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); + v8.unk_03 = SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); v8.unk_04 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(param0->fieldSystem->saveData)); v8.unk_05 = v7; v8.unk_08 = v1; @@ -204,7 +204,7 @@ BOOL ScrCmd_101(ScriptContext *param0) { void **v0 = FieldSystem_GetScriptMemberPtr(param0->fieldSystem, SCRIPT_MANAGER_DATA_PTR); - sub_020933F8(param0->taskManager, *v0); + sub_020933F8(param0->task, *v0); return 1; } @@ -428,6 +428,6 @@ BOOL ScrCmd_115(ScriptContext *param0) BOOL ScrCmd_116(ScriptContext *param0) { - ov6_02247A0C(param0->taskManager); + ov6_02247A0C(param0->task); return 1; } diff --git a/src/unk_02048614.c b/src/unk_02048614.c index 93f1f0a8cd..745a3cc56c 100644 --- a/src/unk_02048614.c +++ b/src/unk_02048614.c @@ -6,20 +6,20 @@ #include "field/field_system.h" +#include "encounter.h" #include "field_script_context.h" #include "inlines.h" #include "map_object.h" #include "party.h" #include "script_manager.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "unk_020041CC.h" -#include "unk_02050A74.h" #include "unk_02051D8C.h" #include "unk_020528D0.h" #include "unk_02054884.h" #include "unk_020553DC.h" #include "unk_02067A84.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "vars_flags.h" @@ -148,11 +148,11 @@ BOOL ScrCmd_0E5(ScriptContext *param0) v6 = 0; - if (sub_0206A984(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) { v6 = sub_0206B034(SaveData_GetVarsFlags(fieldSystem->saveData)); } - sub_020515CC(param0->taskManager, v4, v5, v6, 11, v3); + sub_020515CC(param0->task, v4, v5, v6, 11, v3); return 1; } @@ -164,7 +164,7 @@ BOOL ScrCmd_2A0(ScriptContext *param0) u16 v3 = ScriptContext_GetVar(param0); u16 v4 = ScriptContext_GetVar(param0); - sub_020515CC(param0->taskManager, v3, v4, v2, 11, v1); + sub_020515CC(param0->task, v3, v4, v2, 11, v1); return 1; } @@ -257,7 +257,7 @@ BOOL ScrCmd_0EA(ScriptContext *param0) BOOL ScrCmd_0EB(ScriptContext *param0) { - sub_02052C5C(param0->taskManager); + sub_02052C5C(param0->task); return 1; } @@ -301,7 +301,7 @@ BOOL ScrCmd_0EF(ScriptContext *param0) FieldSystem *fieldSystem = param0->fieldSystem; BOOL *v1 = FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_MANAGER_BATTLE_RESULT); - sub_020515CC(param0->taskManager, 1, 0, 0, 11, v1); + sub_020515CC(param0->task, 1, 0, 0, 11, v1); return 1; } diff --git a/src/unk_02048BD0.c b/src/unk_02048BD0.c index 246416bf82..28781caef1 100644 --- a/src/unk_02048BD0.c +++ b/src/unk_02048BD0.c @@ -63,7 +63,7 @@ BOOL ScrCmd_21D(ScriptContext *param0) const u16 *v11; v11 = RecordMixedRNG_GetEntryName(v1, 0, 0); - sub_0203DFE8(param0->taskManager, 5, 0, 7, 0, v11, ScriptContext_GetVarPointer(param0)); + sub_0203DFE8(param0->task, 5, 0, 7, 0, v11, ScriptContext_GetVarPointer(param0)); } return 1; case 5: { diff --git a/src/unk_020494DC.c b/src/unk_020494DC.c index 655171c988..cef0401fb2 100644 --- a/src/unk_020494DC.c +++ b/src/unk_020494DC.c @@ -115,11 +115,11 @@ BOOL ScrCmd_1DD(ScriptContext *param0) *v3 = sub_0204A100(param0->fieldSystem->saveData); break; case 16: - sub_0206BCE4(param0->taskManager, v1, v2, *v3); + sub_0206BCE4(param0->task, v1, v2, *v3); return 1; case (30 + 0): v5 = FieldSystem_GetScriptMemberPtr(param0->fieldSystem, 19); - sub_0204A358(v6, param0->taskManager, v5); + sub_0204A358(v6, param0->task, v5); return 1; case (30 + 1): v5 = FieldSystem_GetScriptMemberPtr(param0->fieldSystem, 19); @@ -299,7 +299,7 @@ BOOL ScrCmd_1E2(ScriptContext *param0) v0 = ScriptContext_ReadHalfWord(param0); if (sub_0205E6D8(param0->fieldSystem->saveData) == 1) { - sub_0206BD88(param0->fieldSystem->taskManager, v1, v0); + sub_0206BD88(param0->fieldSystem->task, v1, v0); } else { v2->unk_8DA = v0; v2->unk_8D5 = v1; diff --git a/src/unk_02049D08.c b/src/unk_02049D08.c index be3885eb9d..b3af969a05 100644 --- a/src/unk_02049D08.c +++ b/src/unk_02049D08.c @@ -10,7 +10,6 @@ #include "struct_decls/struct_0202D750_decl.h" #include "struct_decls/struct_0202D764_decl.h" #include "struct_decls/struct_0203068C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_02098C44.h" @@ -20,6 +19,7 @@ #include "savedata/save_table.h" #include "field_overworld_state.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "inlines.h" @@ -30,13 +30,13 @@ #include "pokemon.h" #include "save_player.h" #include "savedata.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0201D15C.h" #include "unk_0202D05C.h" #include "unk_0203061C.h" #include "unk_0204AEE8.h" #include "unk_0205DFC4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206B9D8.h" #include "unk_0206CCB0.h" @@ -227,14 +227,14 @@ void sub_02049FA8(FieldSystem *fieldSystem) Location *v0 = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); Location_Set(v0, fieldSystem->location->mapId, -1, Player_GetXPos(fieldSystem->playerAvatar), Player_GetZPos(fieldSystem->playerAvatar), 0); - sub_0206AD9C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_SetCommunicationClubAccessible(SaveData_GetVarsFlags(fieldSystem->saveData)); return; } void sub_02049FE8(FieldSystem *fieldSystem) { - CommClub_ResetAvailable(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_ClearCommunicationClubAccessible(SaveData_GetVarsFlags(fieldSystem->saveData)); } u16 sub_02049FF8(SaveData *param0, u16 param1) @@ -422,7 +422,7 @@ void sub_0204A32C(UnkStruct_0204AFC4 *param0) param0 = NULL; } -void sub_0204A358(UnkStruct_0204AFC4 *param0, TaskManager *param1, void **param2) +void sub_0204A358(UnkStruct_0204AFC4 *param0, FieldTask *param1, void **param2) { sub_0206BBFC(param1, param2, 17, 0, param0->unk_0E, param0->unk_0E, 100, 0); } diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 0a705b58e9..751c348b9b 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -14,12 +14,12 @@ #include "inlines.h" #include "pokemon.h" #include "save_player.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0202631C.h" #include "unk_0202EEC0.h" #include "unk_0202F180.h" #include "unk_020562F8.h" -#include "unk_0206A8DC.h" #include "unk_020797C8.h" #include "unk_02092494.h" #include "vars_flags.h" @@ -30,10 +30,10 @@ BOOL ScrCmd_253(ScriptContext *param0) u16 v1 = ScriptContext_GetVar(param0); if (v1 == 0) { - sub_0206AE6C(v0); + SystemFlag_SetInPalPark(v0); sub_020562F8(param0->fieldSystem); } else if (v1 == 1) { - sub_0206AE7C(v0); + SystemFlag_ClearInPalPark(v0); sub_02056328(param0->fieldSystem); } else { GF_ASSERT(0); diff --git a/src/unk_0204E3CC.c b/src/unk_0204E3CC.c deleted file mode 100644 index ffc669bacb..0000000000 --- a/src/unk_0204E3CC.c +++ /dev/null @@ -1,256 +0,0 @@ -#include "unk_0204E3CC.h" - -#include -#include -#include - -#include "consts/badges.h" - -#include "struct_decls/pokedexdata_decl.h" -#include "struct_decls/struct_0203A790_decl.h" -#include "struct_defs/struct_0205EC34.h" - -#include "field_overworld_state.h" -#include "field_script_context.h" -#include "inlines.h" -#include "player_avatar.h" -#include "save_player.h" -#include "trainer_info.h" -#include "unk_0202631C.h" -#include "unk_0206A8DC.h" -#include "vars_flags.h" - -BOOL ScrCmd_157(ScriptContext *param0) -{ - const PokedexData *pokedex = SaveData_Pokedex(param0->fieldSystem->saveData); - u16 *v1 = ScriptContext_GetVarPointer(param0); - - *v1 = Pokedex_IsObtained(pokedex); - return FALSE; -} - -BOOL ScrCmd_158(ScriptContext *param0) -{ - PokedexData *v0 = SaveData_Pokedex(param0->fieldSystem->saveData); - - sub_02027540(v0); - return 0; -} - -BOOL ScrCmd_159(ScriptContext *param0) -{ - FieldOverworldState *v0; - PlayerData *v1; - u16 *v2 = ScriptContext_GetVarPointer(param0); - - v0 = SaveData_GetFieldOverworldState(param0->fieldSystem->saveData); - v1 = FieldOverworldState_GetPlayerData(v0); - *v2 = PlayerData_HasRunningShoes(v1); - - return 0; -} - -BOOL ScrCmd_15A(ScriptContext *param0) -{ - FieldOverworldState *v0; - PlayerData *v1; - - v0 = SaveData_GetFieldOverworldState(param0->fieldSystem->saveData); - v1 = FieldOverworldState_GetPlayerData(v0); - - PlayerData_SetRunningShoes(v1, 1); - return 0; -} - -BOOL ScrCmd_CheckBadge(ScriptContext *ctx) -{ - u16 badgeNum = ScriptContext_GetVar(ctx); - u16 *destVar = ScriptContext_GetVarPointer(ctx); - - GF_ASSERT(badgeNum < MAX_BADGES); - *destVar = TrainerInfo_HasBadge(SaveData_GetTrainerInfo(ctx->fieldSystem->saveData), badgeNum); - - return FALSE; -} - -BOOL ScrCmd_15C(ScriptContext *param0) -{ - u16 v0 = ScriptContext_GetVar(param0); - - GF_ASSERT(v0 < 8); - TrainerInfo_SetBadge(SaveData_GetTrainerInfo(param0->fieldSystem->saveData), v0); - - return 0; -} - -BOOL ScrCmd_15E(ScriptContext *param0) -{ - u16 *v0 = ScriptContext_GetVarPointer(param0); - - *v0 = VarsFlags_CheckBagAvailable(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -const u8 Unk_020EC064[8] = { - 0x0, - 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x6, - 0x7 -}; - -BOOL ScrCmd_15D(ScriptContext *param0) -{ - u16 v0, v1; - u16 *v2 = ScriptContext_GetVarPointer(param0); - - for (v0 = 0, v1 = 0; v0 < 8; v0++) { - if (TrainerInfo_HasBadge(SaveData_GetTrainerInfo(param0->fieldSystem->saveData), Unk_020EC064[v0]) == 1) { - v1++; - } - } - - *v2 = v1; - return 0; -} - -BOOL ScrCmd_15F(ScriptContext *param0) -{ - VarsFlags_SetBagAvailable(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_160(ScriptContext *param0) -{ - u16 *v0 = ScriptContext_GetVarPointer(param0); - - *v0 = sub_0206A984(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_161(ScriptContext *param0) -{ - sub_0206A964(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_162(ScriptContext *param0) -{ - sub_0206A974(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_163(ScriptContext *param0) -{ - u16 *v0 = ScriptContext_GetVarPointer(param0); - - *v0 = sub_0206A9B4(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_164(ScriptContext *param0) -{ - sub_0206A994(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_165(ScriptContext *param0) -{ - sub_0206A9A4(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_166(ScriptContext *param0) -{ - u16 *v0 = ScriptContext_GetVarPointer(param0); - - *v0 = sub_0206A954(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_167(ScriptContext *param0) -{ - sub_0206A944(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - return 0; -} - -BOOL ScrCmd_1CF(ScriptContext *param0) -{ - u8 v0; - u16 *v1; - VarsFlags *v2 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - - v0 = ScriptContext_ReadByte(param0); - - switch (v0) { - case 1: - inline_0204E650(v2); - break; - case 0: - inline_0204E650_1(v2); - break; - case 2: - v1 = ScriptContext_GetVarPointer(param0); - *v1 = inline_0204E650_2(v2); - break; - default: - GF_ASSERT(0); - } - - return 0; -} - -BOOL ScrCmd_1D0(ScriptContext *param0) -{ - u8 v0; - u16 *v1; - VarsFlags *v2 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - - v0 = ScriptContext_ReadByte(param0); - - switch (v0) { - case 1: - sub_0206AEBC(v2); - break; - case 0: - sub_0206AECC(v2); - break; - case 2: - v1 = ScriptContext_GetVarPointer(param0); - *v1 = Overworld_IsFlashActive(v2); - break; - default: - GF_ASSERT(0); - } - - return 0; -} - -BOOL ScrCmd_1D1(ScriptContext *param0) -{ - u8 v0; - u16 *v1; - VarsFlags *v2 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - - v0 = ScriptContext_ReadByte(param0); - - switch (v0) { - case 1: - sub_0206AEEC(v2); - break; - case 0: - sub_0206AEFC(v2); - break; - case 2: - v1 = ScriptContext_GetVarPointer(param0); - *v1 = Overworld_IsDefogActive(v2); - break; - default: - GF_ASSERT(0); - } - - return 0; -} diff --git a/src/unk_0204EDA4.c b/src/unk_0204EDA4.c index 9be5ae86c0..0739f815d1 100644 --- a/src/unk_0204EDA4.c +++ b/src/unk_0204EDA4.c @@ -117,7 +117,7 @@ BOOL ScrCmd_224(ScriptContext *param0) u16 *v3; v0 = Party_GetPokemonBySlotIndex(Party_GetFromSavedata(param0->fieldSystem->saveData), v1); - v3 = Heap_AllocFromHeap(32, (1 + 1) * 2); + v3 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, (1 + 1) * 2); *(v3 + 0) = v2; *(v3 + 1) = 0xffff; diff --git a/src/unk_0204F13C.c b/src/unk_0204F13C.c index 7b8ff301a4..7666f7bcf2 100644 --- a/src/unk_0204F13C.c +++ b/src/unk_0204F13C.c @@ -10,7 +10,6 @@ #include "struct_decls/struct_0203026C_decl.h" #include "struct_decls/struct_0203068C_decl.h" #include "struct_decls/struct_020308A0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/pokemon_summary.h" #include "struct_defs/struct_0204AFC4.h" @@ -23,6 +22,7 @@ #include "communication_system.h" #include "field_script_context.h" #include "field_system.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "inlines.h" @@ -40,7 +40,6 @@ #include "unk_0203061C.h" #include "unk_02030880.h" #include "unk_0204FA34.h" -#include "unk_020508D4.h" #include "unk_0205DFC4.h" #include "unk_0207A274.h" #include "unk_02099500.h" @@ -69,11 +68,11 @@ static BOOL sub_0204F268(u16 param0, SaveData *param1); BOOL ScrCmd_2D1(ScriptContext *param0); BOOL ScrCmd_2CF(ScriptContext *param0); -void sub_0204F3D0(TaskManager *param0, u16 param1, u16 *param2); -static BOOL sub_0204F414(TaskManager *param0); +void sub_0204F3D0(FieldTask *param0, u16 param1, u16 *param2); +static BOOL sub_0204F414(FieldTask *param0); -void sub_0204F470(TaskManager *param0, void **param1, u8 param2); -static BOOL sub_0204F4A4(TaskManager *param0); +void sub_0204F470(FieldTask *param0, void **param1, u8 param2); +static BOOL sub_0204F4A4(FieldTask *param0); static int sub_0204F50C(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem, int param2); static int sub_0204F5D8(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem); static int sub_0204F628(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem, int param2); @@ -139,7 +138,7 @@ BOOL ScrCmd_2CC(ScriptContext *param0) } ; - sub_0204F470(param0->taskManager, v8, v0); + sub_0204F470(param0->task, v8, v0); return 1; default:; @@ -233,11 +232,11 @@ BOOL ScrCmd_2CF(ScriptContext *param0) ; ; - sub_0204F3D0(param0->taskManager, v0, v1); + sub_0204F3D0(param0->task, v0, v1); return 1; } -void sub_0204F3D0(TaskManager *param0, u16 param1, u16 *param2) +void sub_0204F3D0(FieldTask *param0, u16 param1, u16 *param2) { UnkStruct_0204F3D0 *v0; @@ -249,13 +248,13 @@ void sub_0204F3D0(TaskManager *param0, u16 param1, u16 *param2) CommFieldCmd_Init(v0); - FieldTask_Start(param0, sub_0204F414, v0); + FieldTask_InitCall(param0, sub_0204F414, v0); return; } -static BOOL sub_0204F414(TaskManager *param0) +static BOOL sub_0204F414(FieldTask *param0) { - UnkStruct_0204F3D0 *v0 = TaskManager_Environment(param0); + UnkStruct_0204F3D0 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -287,23 +286,23 @@ static BOOL sub_0204F414(TaskManager *param0) return 0; } -void sub_0204F470(TaskManager *param0, void **param1, u8 param2) +void sub_0204F470(FieldTask *param0, void **param1, u8 param2) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0204F470 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0204F470)); MI_CpuClear8(v1, sizeof(UnkStruct_0204F470)); v1->unk_04 = param2; v1->unk_08 = param1; - FieldTask_Start(fieldSystem->taskManager, sub_0204F4A4, v1); + FieldTask_InitCall(fieldSystem->task, sub_0204F4A4, v1); return; } -static BOOL sub_0204F4A4(TaskManager *param0) +static BOOL sub_0204F4A4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0204F470 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0204F470 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case UnkEnum_0204F13C_1: @@ -375,7 +374,7 @@ static int sub_0204F5D8(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem) int v0; PartyManagementData *v1; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return UnkEnum_0204F13C_2; } @@ -447,7 +446,7 @@ static int sub_0204F6B0(UnkStruct_0204F470 *param0, FieldSystem *fieldSystem) { PokemonSummary *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return UnkEnum_0204F13C_4; } diff --git a/src/unk_0204FAB4.c b/src/unk_0204FAB4.c index 3462cdf507..0e3592cc87 100644 --- a/src/unk_0204FAB4.c +++ b/src/unk_0204FAB4.c @@ -6,7 +6,6 @@ #include "struct_decls/struct_020302DC_decl.h" #include "struct_decls/struct_0203041C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/pokemon_summary.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_0204FCF8.h" @@ -18,6 +17,7 @@ #include "communication_system.h" #include "field_script_context.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "party.h" @@ -30,7 +30,6 @@ #include "unk_020302D0.h" #include "unk_0203061C.h" #include "unk_02049D08.h" -#include "unk_020508D4.h" #include "unk_0205DFC4.h" #include "unk_0207A274.h" #include "unk_02099500.h" @@ -49,15 +48,15 @@ typedef struct { BOOL ScrCmd_2D2(ScriptContext *param0); BOOL ScrCmd_2D5(ScriptContext *param0); static void sub_0204FBEC(SaveData *param0, UnkStruct_0203041C *param1, u8 param2); -static void sub_0204FDB4(TaskManager *param0, void **param1, u8 param2); -static BOOL sub_0204FDE8(TaskManager *param0); +static void sub_0204FDB4(FieldTask *param0, void **param1, u8 param2); +static BOOL sub_0204FDE8(FieldTask *param0); static int sub_0204FE50(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem, int param2); static int sub_0204FF1C(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem); static int sub_0204FF6C(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem, int param2); static int sub_0204FFF4(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem); BOOL ScrCmd_2D3(ScriptContext *param0); -static void sub_0204FCF8(TaskManager *param0, u16 param1, u16 param2, u16 *param3); -static BOOL sub_0204FD38(TaskManager *param0); +static void sub_0204FCF8(FieldTask *param0, u16 param1, u16 param2, u16 *param3); +static BOOL sub_0204FD38(FieldTask *param0); BOOL ScrCmd_2D2(ScriptContext *param0) { @@ -104,7 +103,7 @@ BOOL ScrCmd_2D2(ScriptContext *param0) v0 = 2; } - sub_0204FDB4(param0->taskManager, v8, v0); + sub_0204FDB4(param0->task, v8, v0); return 1; default: GF_ASSERT(FALSE); @@ -157,11 +156,11 @@ BOOL ScrCmd_2D3(ScriptContext *param0) u16 v1 = ScriptContext_GetVar(param0); u16 *v2 = ScriptContext_GetVarPointer(param0); - sub_0204FCF8(param0->taskManager, v0, v1, v2); + sub_0204FCF8(param0->task, v0, v1, v2); return 1; } -static void sub_0204FCF8(TaskManager *param0, u16 param1, u16 param2, u16 *param3) +static void sub_0204FCF8(FieldTask *param0, u16 param1, u16 param2, u16 *param3) { UnkStruct_0204FCF8 *v0; @@ -173,14 +172,14 @@ static void sub_0204FCF8(TaskManager *param0, u16 param1, u16 param2, u16 *param v0->unk_0C = param3; CommFieldCmd_Init(v0); - FieldTask_Start(param0, sub_0204FD38, v0); + FieldTask_InitCall(param0, sub_0204FD38, v0); return; } -static BOOL sub_0204FD38(TaskManager *param0) +static BOOL sub_0204FD38(FieldTask *param0) { - UnkStruct_0204FCF8 *v0 = TaskManager_Environment(param0); + UnkStruct_0204FCF8 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -211,9 +210,9 @@ static BOOL sub_0204FD38(TaskManager *param0) return 0; } -static void sub_0204FDB4(TaskManager *param0, void **param1, u8 param2) +static void sub_0204FDB4(FieldTask *param0, void **param1, u8 param2) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0204FE50 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0204FE50)); MI_CpuClear8(v1, sizeof(UnkStruct_0204FE50)); @@ -221,14 +220,14 @@ static void sub_0204FDB4(TaskManager *param0, void **param1, u8 param2) v1->unk_04 = param2; v1->unk_0C = param1; - FieldTask_Start(fieldSystem->taskManager, sub_0204FDE8, v1); + FieldTask_InitCall(fieldSystem->task, sub_0204FDE8, v1); return; } -static BOOL sub_0204FDE8(TaskManager *param0) +static BOOL sub_0204FDE8(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0204FE50 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0204FE50 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -293,7 +292,7 @@ static int sub_0204FF1C(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem) int v0; PartyManagementData *v1; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 1; } @@ -352,7 +351,7 @@ static int sub_0204FFF4(UnkStruct_0204FE50 *param0, FieldSystem *fieldSystem) { PokemonSummary *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 3; } diff --git a/src/unk_0205003C.c b/src/unk_0205003C.c index e1d483235d..eb36249f41 100644 --- a/src/unk_0205003C.c +++ b/src/unk_0205003C.c @@ -6,7 +6,6 @@ #include "struct_decls/struct_020304A0_decl.h" #include "struct_decls/struct_020305B8_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/pokemon_summary.h" #include "struct_defs/struct_0204AFC4.h" #include "struct_defs/struct_02050224.h" @@ -18,6 +17,7 @@ #include "communication_system.h" #include "field_script_context.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "party.h" @@ -30,7 +30,6 @@ #include "unk_02030494.h" #include "unk_0203061C.h" #include "unk_02049D08.h" -#include "unk_020508D4.h" #include "unk_0205DFC4.h" #include "unk_0207A274.h" #include "unk_02099500.h" @@ -49,15 +48,15 @@ typedef struct { BOOL ScrCmd_2D9(ScriptContext *param0); BOOL ScrCmd_2DC(ScriptContext *param0); static void sub_02050174(SaveData *param0, UnkStruct_020305B8 *param1, u8 param2); -void sub_020502E0(TaskManager *param0, void **param1, u8 param2); -static BOOL sub_02050314(TaskManager *param0); +void sub_020502E0(FieldTask *param0, void **param1, u8 param2); +static BOOL sub_02050314(FieldTask *param0); static int sub_0205037C(UnkStruct_0205037C *param0, FieldSystem *fieldSystem, int param2); static int sub_02050448(UnkStruct_0205037C *param0, FieldSystem *fieldSystem); static int sub_02050498(UnkStruct_0205037C *param0, FieldSystem *fieldSystem, int param2); static int sub_02050520(UnkStruct_0205037C *param0, FieldSystem *fieldSystem); BOOL ScrCmd_2DA(ScriptContext *param0); -void sub_02050224(TaskManager *param0, u16 param1, u16 param2, u16 *param3); -static BOOL sub_02050264(TaskManager *param0); +void sub_02050224(FieldTask *param0, u16 param1, u16 param2, u16 *param3); +static BOOL sub_02050264(FieldTask *param0); BOOL ScrCmd_2D9(ScriptContext *param0) { @@ -104,7 +103,7 @@ BOOL ScrCmd_2D9(ScriptContext *param0) v0 = 2; } - sub_020502E0(param0->taskManager, v8, v0); + sub_020502E0(param0->task, v8, v0); return 1; default: GF_ASSERT(FALSE); @@ -149,11 +148,11 @@ BOOL ScrCmd_2DA(ScriptContext *param0) u16 v1 = ScriptContext_GetVar(param0); u16 *v2 = ScriptContext_GetVarPointer(param0); - sub_02050224(param0->taskManager, v0, v1, v2); + sub_02050224(param0->task, v0, v1, v2); return 1; } -void sub_02050224(TaskManager *param0, u16 param1, u16 param2, u16 *param3) +void sub_02050224(FieldTask *param0, u16 param1, u16 param2, u16 *param3) { UnkStruct_02050224 *v0; @@ -165,12 +164,12 @@ void sub_02050224(TaskManager *param0, u16 param1, u16 param2, u16 *param3) v0->unk_0C = param3; CommFieldCmd_Init(v0); - FieldTask_Start(param0, sub_02050264, v0); + FieldTask_InitCall(param0, sub_02050264, v0); } -static BOOL sub_02050264(TaskManager *param0) +static BOOL sub_02050264(FieldTask *param0) { - UnkStruct_02050224 *v0 = TaskManager_Environment(param0); + UnkStruct_02050224 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -201,9 +200,9 @@ static BOOL sub_02050264(TaskManager *param0) return 0; } -void sub_020502E0(TaskManager *param0, void **param1, u8 param2) +void sub_020502E0(FieldTask *param0, void **param1, u8 param2) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0205037C *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0205037C)); MI_CpuClear8(v1, sizeof(UnkStruct_0205037C)); @@ -211,14 +210,14 @@ void sub_020502E0(TaskManager *param0, void **param1, u8 param2) v1->unk_04 = param2; v1->unk_0C = param1; - FieldTask_Start(fieldSystem->taskManager, sub_02050314, v1); + FieldTask_InitCall(fieldSystem->task, sub_02050314, v1); return; } -static BOOL sub_02050314(TaskManager *param0) +static BOOL sub_02050314(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205037C *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205037C *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -281,7 +280,7 @@ static int sub_02050448(UnkStruct_0205037C *param0, FieldSystem *fieldSystem) int v0; PartyManagementData *v1; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 1; } @@ -340,7 +339,7 @@ static int sub_02050520(UnkStruct_0205037C *param0, FieldSystem *fieldSystem) { PokemonSummary *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 3; } diff --git a/src/unk_02050568.c b/src/unk_02050568.c index 8e56ab622b..807a36e10c 100644 --- a/src/unk_02050568.c +++ b/src/unk_02050568.c @@ -4,7 +4,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0205E884_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -15,16 +14,16 @@ #include "camera.h" #include "core_sys.h" #include "field_map_change.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "location.h" #include "map_object.h" #include "player_avatar.h" +#include "system_flags.h" #include "unk_02005474.h" -#include "unk_020508D4.h" #include "unk_02055808.h" #include "unk_02056B30.h" -#include "unk_0206A8DC.h" #include "unk_02070428.h" #include "vars_flags.h" @@ -36,7 +35,7 @@ typedef struct { u8 unk_09[3]; } UnkStruct_02050568; -static BOOL sub_020505A0(TaskManager *taskMan); +static BOOL sub_020505A0(FieldTask *taskMan); static void sub_0205074C(PlayerAvatar *playerAvatar, BOOL param1); static void sub_0205075C(FieldSystem *fieldSystem); @@ -45,13 +44,13 @@ void sub_02050568(FieldSystem *fieldSystem) UnkStruct_02050568 *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_02050568)); memset(v0, 0, sizeof(UnkStruct_02050568)); - FieldTask_Start(fieldSystem->taskManager, sub_020505A0, v0); + FieldTask_InitCall(fieldSystem->task, sub_020505A0, v0); } -static BOOL sub_020505A0(TaskManager *taskMan) +static BOOL sub_020505A0(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02050568 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02050568 *v1 = FieldTask_GetEnv(taskMan); VarsFlags *v2 = SaveData_GetVarsFlags(fieldSystem->saveData); switch (v1->unk_08) { @@ -67,7 +66,7 @@ static BOOL sub_020505A0(TaskManager *taskMan) v1->unk_08++; break; case 2: - sub_0206AE0C(v2); + SystemFlag_SetPoketchHidden(v2); { Location v3; @@ -103,7 +102,7 @@ static BOOL sub_020505A0(TaskManager *taskMan) v1->unk_08++; break; case 8: - sub_0206AE1C(v2); + SystemFlag_ClearPoketchHidden(v2); { Location v4; diff --git a/src/unk_020508D4.c b/src/unk_020508D4.c deleted file mode 100644 index d7ca31ed43..0000000000 --- a/src/unk_020508D4.c +++ /dev/null @@ -1,191 +0,0 @@ -#include "unk_020508D4.h" - -#include -#include - -#include "field/field_system.h" -#include "functypes/funcptr_02050904.h" -#include "overlay005/struct_ov5_021D219C.h" - -#include "field_system.h" -#include "heap.h" - -typedef struct UnkStruct_020508D4_t { - TaskManager *unk_00; - FieldTask unk_04; - int unk_08; - void *unk_0C; - int unk_10; - void *unk_14; - FieldSystem *fieldSystem; - UnkStruct_ov5_021D219C *unk_1C; -} TaskManager; - -typedef struct { - int unk_00; - const OverlayManagerTemplate *unk_04; - void *unk_08; -} UnkStruct_020509F0; - -static TaskManager *sub_020508D4(FieldSystem *fieldSystem, FieldTask param1, void *param2) -{ - TaskManager *v0; - - v0 = Heap_AllocFromHeapAtEnd(32, sizeof(TaskManager)); - v0->unk_00 = NULL; - v0->unk_04 = param1; - v0->unk_08 = 0; - v0->unk_0C = param2; - v0->unk_10 = 0; - v0->unk_14 = NULL; - v0->fieldSystem = fieldSystem; - v0->unk_1C = Heap_AllocFromHeapAtEnd(32, sizeof(UnkStruct_ov5_021D219C)); - - return v0; -} - -TaskManager *FieldTask_Set(FieldSystem *fieldSystem, FieldTask param1, void *param2) -{ - TaskManager *v0; - - GF_ASSERT(fieldSystem->taskManager == NULL); - - v0 = sub_020508D4(fieldSystem, param1, param2); - fieldSystem->taskManager = v0; - - return v0; -} - -void FieldTask_Change(TaskManager *param0, FieldTask param1, void *param2) -{ - param0->unk_04 = param1; - param0->unk_08 = 0; - param0->unk_0C = param2; - - if ((param0->unk_14 != 0) || (param0->unk_14 != NULL)) { - Heap_FreeToHeap(param0->unk_14); - param0->unk_10 = 0; - param0->unk_14 = NULL; - } -} - -TaskManager *FieldTask_Start(TaskManager *param0, FieldTask param1, void *param2) -{ - TaskManager *v0; - - v0 = sub_020508D4(param0->fieldSystem, param1, param2); - v0->unk_00 = param0; - - param0->fieldSystem->taskManager = v0; - - return v0; -} - -BOOL sub_02050958(FieldSystem *fieldSystem) -{ - if (fieldSystem->taskManager == NULL) { - return 0; - } - - while (fieldSystem->taskManager->unk_04(fieldSystem->taskManager) == 1) { - TaskManager *v0; - - v0 = fieldSystem->taskManager->unk_00; - - if (fieldSystem->taskManager->unk_14) { - Heap_FreeToHeap(fieldSystem->taskManager->unk_14); - } - - Heap_FreeToHeap(fieldSystem->taskManager->unk_1C); - Heap_FreeToHeap(fieldSystem->taskManager); - - fieldSystem->taskManager = v0; - - if (v0 == NULL) { - return 1; - } - } - - return 0; -} - -BOOL sub_020509A4(FieldSystem *fieldSystem) -{ - return fieldSystem->taskManager != NULL; -} - -BOOL sub_020509B4(FieldSystem *fieldSystem) -{ - if (FieldSystem_HasParentProcess(fieldSystem) || FieldSystem_HasChildProcess(fieldSystem)) { - return 1; - } else { - return 0; - } -} - -void sub_020509D4(FieldSystem *fieldSystem) -{ - FieldSystem_StartFieldMap(fieldSystem); -} - -BOOL sub_020509DC(FieldSystem *fieldSystem) -{ - if (FieldSystem_IsRunningFieldMap(fieldSystem)) { - return 1; - } else { - return 0; - } -} - -static BOOL sub_020509F0(TaskManager *param0) -{ - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020509F0 *v1 = TaskManager_Environment(param0); - - switch (v1->unk_00) { - case 0: - FieldSystem_StartChildProcess(fieldSystem, v1->unk_04, v1->unk_08); - v1->unk_00++; - break; - case 1: - if (sub_020509B4(fieldSystem)) { - break; - } - - Heap_FreeToHeap(v1); - return 1; - } - - return 0; -} - -void sub_02050A38(TaskManager *param0, const OverlayManagerTemplate *param1, void *param2) -{ - UnkStruct_020509F0 *v0 = Heap_AllocFromHeapAtEnd(32, sizeof(UnkStruct_020509F0)); - - v0->unk_00 = 0; - v0->unk_04 = param1; - v0->unk_08 = param2; - - FieldTask_Start(param0, sub_020509F0, v0); -} - -FieldSystem *TaskManager_FieldSystem(TaskManager *param0) -{ - return param0->fieldSystem; -} - -void *TaskManager_Environment(TaskManager *param0) -{ - return param0->unk_0C; -} - -int *FieldTask_GetState(TaskManager *param0) -{ - return ¶m0->unk_08; -} - -u32 sub_02050A6C(TaskManager *param0) -{ - return param0->unk_1C->unk_00; -} diff --git a/src/unk_02051D8C.c b/src/unk_02051D8C.c index fe4cd1be95..226b4e12d6 100644 --- a/src/unk_02051D8C.c +++ b/src/unk_02051D8C.c @@ -41,6 +41,7 @@ #include "savedata.h" #include "strbuf.h" #include "system_data.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0202602C.h" #include "unk_0202631C.h" @@ -53,7 +54,6 @@ #include "unk_020559DC.h" #include "unk_0205C980.h" #include "unk_0205DAC8.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "vars_flags.h" @@ -280,7 +280,7 @@ void sub_020521B8(BattleParams *param0, const FieldSystem *fieldSystem, SaveData param0->unk_130 = MapHeader_GetMapLabelTextID(param3); param0->unk_13C = MapHeader_GetMapEvolutionMethod(param3); param0->unk_140 = PokemonSummary_ShowContestData(param2); - param0->unk_144 = sub_0206ADFC(SaveData_GetVarsFlags(param2)); + param0->unk_144 = SystemFlag_CheckMetBebe(SaveData_GetVarsFlags(param2)); param0->unk_14C = FieldOverworldState_GetWeather(v6); param0->unk_E4 = param5; param0->unk_190 = param6; diff --git a/src/unk_020528D0.c b/src/unk_020528D0.c index cdfa7fcfc8..254f8b3e80 100644 --- a/src/unk_020528D0.c +++ b/src/unk_020528D0.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0203A790_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02099F80.h" #include "field/field_system.h" @@ -14,6 +13,7 @@ #include "field_map_change.h" #include "field_overworld_state.h" #include "field_system.h" +#include "field_task.h" #include "font.h" #include "graphics.h" #include "gx_layers.h" @@ -32,7 +32,6 @@ #include "unk_0200A9DC.h" #include "unk_0200F174.h" #include "unk_0203A7D8.h" -#include "unk_020508D4.h" #include "unk_020553DC.h" #include "unk_02055808.h" #include "unk_02070428.h" @@ -46,8 +45,8 @@ typedef struct { StringTemplate *unk_20; } UnkStruct_02052AA4; -static void sub_02052914(FieldSystem *fieldSystem, TaskManager *param1); -static BOOL sub_020529C4(TaskManager *param0); +static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1); +static BOOL sub_020529C4(FieldTask *param0); static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 param3); static const WindowTemplate Unk_020EC2F0 = { @@ -102,7 +101,7 @@ static void sub_020528D0(BgConfig *param0) Graphics_LoadPalette(14, 6, 0, 13 * 0x20, 0x20, 11); } -static void sub_02052914(FieldSystem *fieldSystem, TaskManager *param1) +static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1) { UnkStruct_02052AA4 *v0; @@ -133,14 +132,14 @@ static void sub_02052914(FieldSystem *fieldSystem, TaskManager *param1) } Window_CopyToVRAM(&v0->unk_0C); - FieldTask_Start(param1, sub_020529C4, v0); + FieldTask_InitCall(param1, sub_020529C4, v0); return; } -static BOOL sub_020529C4(TaskManager *param0) +static BOOL sub_020529C4(FieldTask *param0) { - UnkStruct_02052AA4 *v0 = TaskManager_Environment(param0); + UnkStruct_02052AA4 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -200,12 +199,12 @@ static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 p return; } -BOOL sub_02052B2C(TaskManager *param0) +BOOL sub_02052B2C(FieldTask *param0) { FieldSystem *fieldSystem; int *v1; - fieldSystem = TaskManager_FieldSystem(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); v1 = FieldTask_GetState(param0); switch (*v1) { @@ -266,7 +265,7 @@ BOOL sub_02052B2C(TaskManager *param0) return 0; } -void sub_02052C5C(TaskManager *param0) +void sub_02052C5C(FieldTask *param0) { - FieldTask_Start(param0, sub_02052B2C, NULL); + FieldTask_InitCall(param0, sub_02052B2C, NULL); } diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index 480b946b64..bfc2ba29ac 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -5,7 +5,6 @@ #include "consts/game_records.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202DF8C.h" #include "struct_defs/struct_0203E234.h" @@ -17,6 +16,7 @@ #include "bg_window.h" #include "field_overworld_state.h" +#include "field_task.h" #include "game_options.h" #include "game_records.h" #include "gx_layers.h" @@ -31,17 +31,16 @@ #include "savedata.h" #include "strbuf.h" #include "string_template.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_0202631C.h" #include "unk_0202DF8C.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02054884.h" #include "unk_020559DC.h" #include "unk_0205D8CC.h" -#include "unk_0206A8DC.h" #include "unk_02096420.h" #include "vars_flags.h" @@ -84,12 +83,12 @@ static void sub_02052C6C(FieldSystem *fieldSystem, BOOL param1) Heap_FreeToHeap(v0); } -static BOOL sub_02052CBC(TaskManager *param0) +static BOOL sub_02052CBC(FieldTask *param0) { Location *v0; VarsFlags *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205300C *v3 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205300C *v3 = FieldTask_GetEnv(param0); int *v4 = FieldTask_GetState(param0); UnkStruct_0203E234 *v5 = &v3->unk_04; @@ -99,7 +98,7 @@ static BOOL sub_02052CBC(TaskManager *param0) (*v4)++; break; case 1: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { Heap_Create(3, 4, 0x20000); sub_02052F28(fieldSystem, v3); StartScreenTransition(3, 1, 1, 0x0, 8, 1, 32); @@ -158,7 +157,7 @@ static BOOL sub_02052CBC(TaskManager *param0) } break; case 9: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { Heap_FreeToHeap(v3); Heap_Destroy(4); OS_ResetSystem(0); @@ -170,7 +169,7 @@ static BOOL sub_02052CBC(TaskManager *param0) return 0; } -void sub_02052E58(TaskManager *param0) +void sub_02052E58(FieldTask *param0) { FieldSystem *fieldSystem; Location *v1, *v2; @@ -180,22 +179,22 @@ void sub_02052E58(TaskManager *param0) GameRecords *v6; Party *v7; - fieldSystem = TaskManager_FieldSystem(param0); - v5 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0205300C)); + fieldSystem = FieldTask_GetFieldSystem(param0); + v5 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0205300C)); v3 = SaveData_GetVarsFlags(fieldSystem->saveData); v4 = SaveData_GetTrainerInfo(fieldSystem->saveData); v1 = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); v2 = sub_0203A72C(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - v5->unk_00 = sub_0206A954(v3); + v5->unk_00 = SystemFlag_CheckGameCompleted(v3); v5->unk_04.unk_00 = SaveData_GetTrainerInfo(fieldSystem->saveData); v5->unk_04.unk_04 = Party_GetFromSavedata(fieldSystem->saveData); v5->unk_04.playTime = SaveData_GetPlayTime(fieldSystem->saveData); v5->unk_10.unk_00 = TrainerInfo_Gender(SaveData_GetTrainerInfo(fieldSystem->saveData)); - v5->unk_10.unk_04 = sub_0206A954(v3); + v5->unk_10.unk_04 = SystemFlag_CheckGameCompleted(v3); v5->unk_10.unk_08 = SaveData_Pokedex(fieldSystem->saveData); - if (sub_0206A954(v3) == 0) { + if (SystemFlag_CheckGameCompleted(v3) == 0) { sub_02055C2C(fieldSystem); } @@ -204,14 +203,14 @@ void sub_02052E58(TaskManager *param0) Party_GiveChampionRibbons(v7); SetPlayerStartLocation(v1); SetPlayerFirstRespawnLocation(v2); - sub_0206AD9C(v3); - sub_0206A944(v3); + SystemFlag_SetCommunicationClubAccessible(v3); + SystemFlag_SetGameCompleted(v3); TrainerInfo_SetMainStoryCleared(v4); v6 = SaveData_GetGameRecordsPtr(fieldSystem->saveData); GameRecords_IncrementRecordValue(v6, RECORD_UNK_073); - FieldTask_Start(param0, sub_02052CBC, v5); + FieldTask_InitCall(param0, sub_02052CBC, v5); } static void sub_02052F28(FieldSystem *fieldSystem, UnkStruct_0205300C *param1) diff --git a/src/unk_020553DC.c b/src/unk_020553DC.c index 8f3cfb52f3..ceb2e37537 100644 --- a/src/unk_020553DC.c +++ b/src/unk_020553DC.c @@ -14,10 +14,10 @@ #include "player_avatar.h" #include "pokeradar.h" #include "rtc.h" +#include "system_flags.h" #include "trainer_data.h" #include "unk_020041CC.h" #include "unk_02005474.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" const static u16 Unk_020EC3E0[][2] = { @@ -191,7 +191,7 @@ u16 sub_020554A4(FieldSystem *fieldSystem, int headerID) sdatID = MapHeader_GetNightMusicID(headerID); } - u16 v1 = sub_0206AB68(SaveData_GetVarsFlags(fieldSystem->saveData), headerID); + u16 v1 = SystemFlag_GetAltMusicForHeader(SaveData_GetVarsFlags(fieldSystem->saveData), headerID); if (v1 != 0) { sdatID = v1; diff --git a/src/unk_0205578C.c b/src/unk_0205578C.c index 4b2cb0d652..0637c73a94 100644 --- a/src/unk_0205578C.c +++ b/src/unk_0205578C.c @@ -1,14 +1,12 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system_decl.h" #include "overlay005/encounter_effect.h" +#include "field_task.h" #include "heap.h" #include "unk_020041CC.h" -#include "unk_020508D4.h" typedef struct { int unk_00; @@ -17,15 +15,15 @@ typedef struct { int unk_0C; } UnkStruct_0205578C; -void sub_020557DC(TaskManager *param0, int param1, int param2); +void sub_020557DC(FieldTask *param0, int param1, int param2); -static BOOL sub_0205578C(TaskManager *param0) +static BOOL sub_0205578C(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_0205578C *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -44,7 +42,7 @@ static BOOL sub_0205578C(TaskManager *param0) return 0; } -void sub_020557DC(TaskManager *param0, int param1, int param2) +void sub_020557DC(FieldTask *param0, int param1, int param2) { UnkStruct_0205578C *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_0205578C)); @@ -53,5 +51,5 @@ void sub_020557DC(TaskManager *param0, int param1, int param2) v0->unk_08 = param1; v0->unk_0C = param2; - FieldTask_Start(param0, sub_0205578C, v0); + FieldTask_InitCall(param0, sub_0205578C, v0); } diff --git a/src/unk_02055808.c b/src/unk_02055808.c index 61f6c4fffe..88123e4764 100644 --- a/src/unk_02055808.c +++ b/src/unk_02055808.c @@ -3,18 +3,16 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/ov5_021DD6FC.h" #include "field_system.h" +#include "field_task.h" #include "unk_0200F174.h" -#include "unk_020508D4.h" -static BOOL sub_02055808(TaskManager *param0) +static BOOL sub_02055808(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); if (!FieldSystem_HasParentProcess(fieldSystem)) { return 1; @@ -23,9 +21,9 @@ static BOOL sub_02055808(TaskManager *param0) return 0; } -void FieldTask_FinishFieldMap(TaskManager *param0) +void FieldTask_FinishFieldMap(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -33,34 +31,34 @@ void FieldTask_FinishFieldMap(TaskManager *param0) } FieldSystem_FlagNotRunningFieldMap(fieldSystem); - FieldTask_Start(param0, sub_02055808, NULL); + FieldTask_InitCall(param0, sub_02055808, NULL); } -static BOOL sub_02055850(TaskManager *param0) +static BOOL sub_02055850(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { return 1; } return 0; } -void FieldTask_StartFieldMap(TaskManager *param0) +void FieldTask_StartFieldMap(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); if (FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); return; } - sub_020509D4(fieldSystem); - FieldTask_Start(param0, sub_02055850, NULL); + FieldSystem_StartFieldMap(fieldSystem); + FieldTask_InitCall(param0, sub_02055850, NULL); } -static BOOL sub_02055898(TaskManager *param0) +static BOOL sub_02055898(FieldTask *param0) { if (IsScreenTransitionDone()) { return 1; @@ -69,9 +67,9 @@ static BOOL sub_02055898(TaskManager *param0) return 0; } -void sub_020558AC(TaskManager *param0) +void sub_020558AC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -80,13 +78,13 @@ void sub_020558AC(TaskManager *param0) { StartScreenTransition(0, 0, 0, 0x0, 6, 1, 4); - FieldTask_Start(param0, sub_02055898, NULL); + FieldTask_InitCall(param0, sub_02055898, NULL); } } -void sub_020558F0(TaskManager *param0) +void sub_020558F0(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -95,11 +93,11 @@ void sub_020558F0(TaskManager *param0) { StartScreenTransition(0, 1, 1, 0x0, 6, 1, 4); - FieldTask_Start(param0, sub_02055898, NULL); + FieldTask_InitCall(param0, sub_02055898, NULL); } } -static BOOL sub_02055934(TaskManager *param0) +static BOOL sub_02055934(FieldTask *param0) { int *v0 = FieldTask_GetState(param0); @@ -119,15 +117,15 @@ static BOOL sub_02055934(TaskManager *param0) return 0; } -void FieldTask_FinishFadeOut(TaskManager *param0) +void FieldTask_FinishFadeOut(FieldTask *param0) { - FieldTask_Start(param0, sub_02055934, NULL); + FieldTask_InitCall(param0, sub_02055934, NULL); } -static BOOL sub_02055984(TaskManager *param0) +static BOOL sub_02055984(FieldTask *param0) { int *v0 = FieldTask_GetState(param0); - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); switch (*v0) { case 0: @@ -146,7 +144,7 @@ static BOOL sub_02055984(TaskManager *param0) return 0; } -void FieldTask_StartFadeIn(TaskManager *param0) +void FieldTask_StartFadeIn(FieldTask *param0) { - FieldTask_Start(param0, sub_02055984, NULL); + FieldTask_InitCall(param0, sub_02055984, NULL); } diff --git a/src/unk_02055C50.c b/src/unk_02055C50.c index ad3e9b59c1..fe3be42d41 100644 --- a/src/unk_02055C50.c +++ b/src/unk_02055C50.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02055CBC_decl.h" #include "struct_decls/struct_02061AB4_decl.h" @@ -18,13 +17,13 @@ #include "berry_patches.h" #include "core_sys.h" #include "easy3d.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "player_avatar.h" #include "savedata_misc.h" #include "sys_task_manager.h" #include "unk_0201CED8.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020655F4.h" #include "unk_020677F4.h" @@ -382,10 +381,10 @@ static void sub_0205610C(FieldSystem *fieldSystem, UnkStruct_020562AC *param1, c param1->unk_0C = MapObject_StartAnimation(v0, param2); } -static BOOL sub_02056124(TaskManager *taskMan) +static BOOL sub_02056124(FieldTask *taskMan) { - FieldSystem *v0 = TaskManager_FieldSystem(taskMan); - UnkStruct_020562AC *v1 = TaskManager_Environment(taskMan); + FieldSystem *v0 = FieldTask_GetFieldSystem(taskMan); + UnkStruct_020562AC *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_00) { case 0: @@ -466,13 +465,13 @@ void sub_020562AC(FieldSystem *fieldSystem) { UnkStruct_020562AC *v0; - v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_020562AC)); + v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_020562AC)); v0->unk_00 = 0; v0->unk_0C = NULL; v0->unk_04 = PlayerAvatar_GetDir(fieldSystem->playerAvatar); - FieldTask_Start(fieldSystem->taskManager, sub_02056124, v0); + FieldTask_InitCall(fieldSystem->task, sub_02056124, v0); } void sub_020562D8(FieldSystem *fieldSystem) diff --git a/src/unk_02056B30.c b/src/unk_02056B30.c index 0804be2c92..4da9537980 100644 --- a/src/unk_02056B30.c +++ b/src/unk_02056B30.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" @@ -19,6 +18,7 @@ #include "camera.h" #include "field_map_change.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "location.h" @@ -27,7 +27,6 @@ #include "player_avatar.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020553DC.h" #include "unk_02055808.h" @@ -53,19 +52,19 @@ typedef struct { int unk_1C; } UnkStruct_02056B30; -static BOOL sub_02056B70(TaskManager *taskMan); -static BOOL sub_02056CFC(TaskManager *taskMan); -static BOOL sub_02056DE4(TaskManager *taskMan); -static BOOL sub_02056E20(TaskManager *taskMan); -static BOOL sub_02056EA4(TaskManager *taskMan); -static BOOL sub_02056F1C(TaskManager *taskMan); -static BOOL sub_02056FC0(TaskManager *taskMan); -static BOOL sub_02057008(TaskManager *taskMan); -static BOOL sub_02057050(TaskManager *taskMan); -static BOOL sub_0205711C(TaskManager *taskMan); -static BOOL sub_020571A0(TaskManager *taskMan); -static BOOL sub_02057218(TaskManager *taskMan); -static BOOL sub_020572B8(TaskManager *taskMan); +static BOOL sub_02056B70(FieldTask *taskMan); +static BOOL sub_02056CFC(FieldTask *taskMan); +static BOOL sub_02056DE4(FieldTask *taskMan); +static BOOL sub_02056E20(FieldTask *taskMan); +static BOOL sub_02056EA4(FieldTask *taskMan); +static BOOL sub_02056F1C(FieldTask *taskMan); +static BOOL sub_02056FC0(FieldTask *taskMan); +static BOOL sub_02057008(FieldTask *taskMan); +static BOOL sub_02057050(FieldTask *taskMan); +static BOOL sub_0205711C(FieldTask *taskMan); +static BOOL sub_020571A0(FieldTask *taskMan); +static BOOL sub_02057218(FieldTask *taskMan); +static BOOL sub_020572B8(FieldTask *taskMan); static void sub_02057300(FieldSystem *fieldSystem); static void sub_02057368(FieldSystem *fieldSystem); @@ -99,7 +98,7 @@ static const UnkFuncPtr_020EC57C Unk_020EC57C[7] = { NULL }; -void sub_02056B30(TaskManager *taskMan, int param1, int param2, int param3, u16 param4, int param5, int param6, int param7) +void sub_02056B30(FieldTask *taskMan, int param1, int param2, int param3, u16 param4, int param5, int param6, int param7) { UnkStruct_02056B30 *v0 = Heap_AllocFromHeap(param7, sizeof(UnkStruct_02056B30)); @@ -112,13 +111,13 @@ void sub_02056B30(TaskManager *taskMan, int param1, int param2, int param3, u16 v0->unk_1C = param7; v0->unk_00 = 0; - FieldTask_Start(taskMan, sub_02056B70, v0); + FieldTask_InitCall(taskMan, sub_02056B70, v0); } -static BOOL sub_02056B70(TaskManager *taskMan) +static BOOL sub_02056B70(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056B30 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056B30 *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_00) { case 0: @@ -148,7 +147,7 @@ void sub_02056BDC(FieldSystem *fieldSystem, const int param1, const int param2, v0->unk_20 = param6; - FieldTask_Set(fieldSystem, sub_02056CFC, v0); + FieldSystem_CreateTask(fieldSystem, sub_02056CFC, v0); } void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, const int param3, const int param4, const int param5) @@ -199,20 +198,20 @@ void sub_02056C18(FieldSystem *fieldSystem, const int param1, const int param2, v2->unk_20 = v1; - FieldTask_Set(fieldSystem, sub_02056CFC, v2); + FieldSystem_CreateTask(fieldSystem, sub_02056CFC, v2); } -static BOOL sub_02056CFC(TaskManager *taskMan) +static BOOL sub_02056CFC(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); Location *v2 = &v1->unk_08; switch (v1->unk_00) { case 0: v1->unk_04 = 0; Sound_TryFadeInBGM(fieldSystem, v2->mapId); - FieldTask_Start(taskMan, Unk_020EC560[v1->unk_20], v1); + FieldTask_InitCall(taskMan, Unk_020EC560[v1->unk_20], v1); (v1->unk_00)++; break; case 1: @@ -243,7 +242,7 @@ static BOOL sub_02056CFC(TaskManager *taskMan) FieldSystem_RequestLocationName(fieldSystem); v1->unk_04 = 0; - FieldTask_Start(taskMan, Unk_020EC544[v1->unk_20], v1); + FieldTask_InitCall(taskMan, Unk_020EC544[v1->unk_20], v1); (v1->unk_00)++; break; case 6: @@ -254,10 +253,10 @@ static BOOL sub_02056CFC(TaskManager *taskMan) return 0; } -static BOOL sub_02056DE4(TaskManager *taskMan) +static BOOL sub_02056DE4(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_04) { case 0: @@ -273,10 +272,10 @@ static BOOL sub_02056DE4(TaskManager *taskMan) return 0; } -static BOOL sub_02056E20(TaskManager *taskMan) +static BOOL sub_02056E20(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); UnkStruct_ov5_021D432C *v2; switch (v1->unk_04) { @@ -305,10 +304,10 @@ static BOOL sub_02056E20(TaskManager *taskMan) return 0; } -static BOOL sub_02056EA4(TaskManager *taskMan) +static BOOL sub_02056EA4(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); UnkStruct_ov5_021D432C *v2; switch (v1->unk_04) { @@ -333,10 +332,10 @@ static BOOL sub_02056EA4(TaskManager *taskMan) return 0; } -static BOOL sub_02056F1C(TaskManager *taskMan) +static BOOL sub_02056F1C(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); MapObject *v2; switch (v1->unk_04) { @@ -378,10 +377,10 @@ static BOOL sub_02056F1C(TaskManager *taskMan) return 0; } -static BOOL sub_02056FC0(TaskManager *taskMan) +static BOOL sub_02056FC0(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); MapObject *v2 = Player_MapObject(fieldSystem->playerAvatar); switch (v1->unk_04) { @@ -389,7 +388,7 @@ static BOOL sub_02056FC0(TaskManager *taskMan) UnkStruct_ov5_021D4E00 *v3; v3 = ov5_021D4E00(); - FieldTask_Start(taskMan, ov5_021D4FA0, v3); + FieldTask_InitCall(taskMan, ov5_021D4FA0, v3); v1->unk_04++; } break; case 1: @@ -399,10 +398,10 @@ static BOOL sub_02056FC0(TaskManager *taskMan) return 0; } -static BOOL sub_02057008(TaskManager *taskMan) +static BOOL sub_02057008(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); MapObject *v2 = Player_MapObject(fieldSystem->playerAvatar); switch (v1->unk_04) { @@ -410,7 +409,7 @@ static BOOL sub_02057008(TaskManager *taskMan) UnkStruct_ov5_021D4E00 *v3; v3 = ov5_021D4E00(); - FieldTask_Start(taskMan, ov5_021D4F14, v3); + FieldTask_InitCall(taskMan, ov5_021D4F14, v3); v1->unk_04++; } break; case 1: @@ -420,11 +419,11 @@ static BOOL sub_02057008(TaskManager *taskMan) return 0; } -static BOOL sub_02057050(TaskManager *taskMan) +static BOOL sub_02057050(FieldTask *taskMan) { MapObject *mapObj; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v2 = FieldTask_GetEnv(taskMan); UnkStruct_ov5_021D432C *v3; switch (v2->unk_04) { @@ -441,7 +440,7 @@ static BOOL sub_02057050(TaskManager *taskMan) UnkStruct_ov5_021D4E00 *v6; v6 = ov5_021D4E00(); - FieldTask_Start(taskMan, ov5_021D5020, v6); + FieldTask_InitCall(taskMan, ov5_021D5020, v6); (v2->unk_04) = 3; } } break; @@ -471,11 +470,11 @@ static BOOL sub_02057050(TaskManager *taskMan) return 0; } -static BOOL sub_0205711C(TaskManager *taskMan) +static BOOL sub_0205711C(FieldTask *taskMan) { MapObject *mapObj; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v2 = FieldTask_GetEnv(taskMan); UnkStruct_ov5_021D432C *v3; switch (v2->unk_04) { @@ -488,12 +487,12 @@ static BOOL sub_0205711C(TaskManager *taskMan) if (sub_0205DAEC(v4)) { MapObject_SetHidden(v5, 1); v2->unk_04 = 1; - FieldTask_Change(taskMan, sub_02057050, v2); + FieldTask_InitJump(taskMan, sub_02057050, v2); } else { UnkStruct_ov5_021D4E00 *v6; v6 = ov5_021D4E00(); - FieldTask_Start(taskMan, ov5_021D5150, v6); + FieldTask_InitCall(taskMan, ov5_021D5150, v6); (v2->unk_04)++; } } break; @@ -504,10 +503,10 @@ static BOOL sub_0205711C(TaskManager *taskMan) return 0; } -static BOOL sub_020571A0(TaskManager *taskMan) +static BOOL sub_020571A0(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); UnkStruct_ov5_021D432C *v2; switch (v1->unk_04) { @@ -532,10 +531,10 @@ static BOOL sub_020571A0(TaskManager *taskMan) return 0; } -static BOOL sub_02057218(TaskManager *taskMan) +static BOOL sub_02057218(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); MapObject *v2; switch (v1->unk_04) { @@ -582,10 +581,10 @@ static BOOL sub_02057218(TaskManager *taskMan) return 0; } -static BOOL sub_020572B8(TaskManager *taskMan) +static BOOL sub_020572B8(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_02056BDC *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_02056BDC *v1 = FieldTask_GetEnv(taskMan); MapObject *v2 = Player_MapObject(fieldSystem->playerAvatar); switch (v1->unk_04) { @@ -593,7 +592,7 @@ static BOOL sub_020572B8(TaskManager *taskMan) UnkStruct_ov5_021D4E00 *v3; v3 = ov5_021D4E00(); - FieldTask_Start(taskMan, ov5_021D4E10, v3); + FieldTask_InitCall(taskMan, ov5_021D4E10, v3); v1->unk_04++; } break; case 1: diff --git a/src/unk_0205749C.c b/src/unk_0205749C.c index e5e2032e61..818ec606ab 100644 --- a/src/unk_0205749C.c +++ b/src/unk_0205749C.c @@ -3,14 +3,12 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay066/ov66_0222DCE0.h" #include "overlay066/struct_ov66_0222DCE0.h" +#include "field_task.h" #include "heap.h" -#include "unk_020508D4.h" FS_EXTERN_OVERLAY(overlay66); @@ -20,7 +18,7 @@ typedef struct { UnkStruct_ov66_0222DCE0 unk_04; } UnkStruct_0205749C; -static BOOL sub_020574CC(TaskManager *param0); +static BOOL sub_020574CC(FieldTask *param0); static const OverlayManagerTemplate Unk_020ED4CC = { ov66_0222DCE0, @@ -29,7 +27,7 @@ static const OverlayManagerTemplate Unk_020ED4CC = { FS_OVERLAY_ID(overlay66) }; -void sub_0205749C(TaskManager *param0, BOOL param1) +void sub_0205749C(FieldTask *param0, BOOL param1) { UnkStruct_0205749C *v0; @@ -37,20 +35,20 @@ void sub_0205749C(TaskManager *param0, BOOL param1) memset(v0, 0, sizeof(UnkStruct_0205749C)); v0->unk_02 = param1; - FieldTask_Start(param0, sub_020574CC, v0); + FieldTask_InitCall(param0, sub_020574CC, v0); } -static BOOL sub_020574CC(TaskManager *param0) +static BOOL sub_020574CC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205749C *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205749C *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: { v1->unk_04.unk_04 = fieldSystem->saveData; v1->unk_04.unk_08 = v1->unk_02; v1->unk_04.unk_00 = &fieldSystem->unk_C4; - sub_02050A38(param0, &Unk_020ED4CC, &v1->unk_04); + FieldTask_RunApplication(param0, &Unk_020ED4CC, &v1->unk_04); v1->unk_00++; } break; case 1: diff --git a/src/unk_0205A0D8.c b/src/unk_0205A0D8.c index bc3f95b8ed..bd545d7ec6 100644 --- a/src/unk_0205A0D8.c +++ b/src/unk_0205A0D8.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/pokemon_summary.h" #include "struct_defs/struct_02072014.h" @@ -22,6 +21,7 @@ #include "core_sys.h" #include "field_comm_manager.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "message.h" @@ -43,7 +43,6 @@ #include "unk_020363E8.h" #include "unk_020366A0.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_0205D8CC.h" #include "unk_020655F4.h" #include "unk_0207A274.h" @@ -186,7 +185,7 @@ static BOOL sub_0205A258(UnkStruct_0205A0D8 *param0, FieldSystem *fieldSystem) { int v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } @@ -215,7 +214,7 @@ static BOOL sub_0205A2B0(UnkStruct_0205A0D8 *param0, FieldSystem *fieldSystem) { PokemonSummary *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } @@ -228,7 +227,7 @@ static BOOL sub_0205A2B0(UnkStruct_0205A0D8 *param0, FieldSystem *fieldSystem) static BOOL sub_0205A2DC(UnkStruct_0205A0D8 *param0) { - if (sub_020509DC(param0->fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(param0->fieldSystem)) { ov5_021D1744(1); CommPlayerMan_Restart(); return 1; @@ -252,10 +251,10 @@ static BOOL sub_0205A2FC(void) return 0; } -static BOOL sub_0205A324(TaskManager *param0) +static BOOL sub_0205A324(FieldTask *param0) { - UnkStruct_0205A0D8 *v0 = TaskManager_Environment(param0); - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + UnkStruct_0205A0D8 *v0 = FieldTask_GetEnv(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); switch (v0->unk_34) { case 0: @@ -386,7 +385,7 @@ static BOOL sub_0205A324(TaskManager *param0) } break; case 19: - sub_020509D4(v0->fieldSystem); + FieldSystem_StartFieldMap(v0->fieldSystem); if (v0->unk_88 != 3) { v0->unk_43 = 5; @@ -404,7 +403,7 @@ static BOOL sub_0205A324(TaskManager *param0) } break; case 20: - sub_020509D4(v0->fieldSystem); + FieldSystem_StartFieldMap(v0->fieldSystem); if (v0->unk_88 != 3) { v0->unk_34 = 22; @@ -558,7 +557,7 @@ static BOOL sub_0205A324(TaskManager *param0) break; case 34: if (sub_0205A2B0(v0, v0->fieldSystem)) { - sub_020509D4(v0->fieldSystem); + FieldSystem_StartFieldMap(v0->fieldSystem); v0->unk_34 = 35; } break; @@ -655,7 +654,7 @@ static void sub_0205AAA0(UnkStruct_0205A0D8 *param0, BOOL param1) void sub_0205AB10(FieldSystem *fieldSystem, UnkFuncPtr_0205AB10 *param1) { UnkStruct_0205A0D8 *v0; - TaskManager *v1 = fieldSystem->taskManager; + FieldTask *v1 = fieldSystem->task; if (v1) { return; @@ -710,7 +709,7 @@ void sub_0205AB10(FieldSystem *fieldSystem, UnkFuncPtr_0205AB10 *param1) break; } - FieldTask_Set(fieldSystem, sub_0205A324, v0); + FieldSystem_CreateTask(fieldSystem, sub_0205A324, v0); } static void sub_0205AC28(UnkStruct_0205A0D8 *param0) @@ -738,7 +737,7 @@ static void sub_0205AC28(UnkStruct_0205A0D8 *param0) static UnkStruct_0205A0D8 *sub_0205AC74(FieldSystem *fieldSystem) { - return TaskManager_Environment(fieldSystem->taskManager); + return FieldTask_GetEnv(fieldSystem->task); } static void sub_0205AC80(UnkStruct_0205A0D8 *param0, BOOL param1) @@ -1004,10 +1003,10 @@ void sub_0205B110(int param0, int param1, void *param2, void *param3) } } -static BOOL sub_0205B140(TaskManager *param0) +static BOOL sub_0205B140(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205B2D4 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205B2D4 *v1 = FieldTask_GetEnv(param0); TrainerCard *v2 = (TrainerCard *)sub_02059EBC(v1->unk_24, NULL, 0); switch (v1->unk_28) { @@ -1050,16 +1049,16 @@ static BOOL sub_0205B140(TaskManager *param0) v1->unk_28++; break; case 4: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v1->unk_28++; } break; case 5: - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_28++; break; case 6: - if (!sub_020509DC(fieldSystem)) { + if (!FieldSystem_IsRunningFieldMap(fieldSystem)) { ov5_021D1744(1); CommPlayerMan_Restart(); v1->unk_28++; @@ -1094,7 +1093,7 @@ void sub_0205B2D4(FieldSystem *fieldSystem) v4->unk_24 = v0; v4->unk_28 = 0; - FieldTask_Set(fieldSystem, sub_0205B140, v4); + FieldSystem_CreateTask(fieldSystem, sub_0205B140, v4); FieldSystem_PauseProcessing(); break; } diff --git a/src/unk_0205B33C.c b/src/unk_0205B33C.c index b3dacd9d1d..e9f1e620d2 100644 --- a/src/unk_0205B33C.c +++ b/src/unk_0205B33C.c @@ -15,6 +15,7 @@ #include "communication_information.h" #include "communication_system.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "journal.h" #include "message.h" @@ -30,7 +31,6 @@ #include "unk_0201D15C.h" #include "unk_02033200.h" #include "unk_020366A0.h" -#include "unk_020508D4.h" #include "unk_0205C980.h" #include "unk_02071D40.h" #include "unk_02095E98.h" @@ -355,7 +355,7 @@ static void sub_0205B634(UnkStruct_0205B43C *param0) static void sub_0205B694(UnkStruct_0205B43C *param0) { - if (!sub_020509A4(param0->fieldSystem)) { + if (!FieldSystem_IsRunningTask(param0->fieldSystem)) { sub_02036AC4(); sub_0205C160(param0); sub_0205BEA8(0); diff --git a/src/unk_0205C22C.c b/src/unk_0205C22C.c index b07638a670..d20e5f9a6b 100644 --- a/src/unk_0205C22C.c +++ b/src/unk_0205C22C.c @@ -18,6 +18,7 @@ #include "overlay005/ov5_021F134C.h" #include "overlay005/ov5_021F600C.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "player_avatar.h" @@ -30,7 +31,6 @@ #include "unk_02014A84.h" #include "unk_02027F84.h" #include "unk_020366A0.h" -#include "unk_020508D4.h" #include "unk_0205B33C.h" #include "unk_020655F4.h" #include "unk_020711EC.h" @@ -111,7 +111,7 @@ static void sub_0205C304(SysTask *task, void *param1) UnkStruct_0205C22C *v0 = (UnkStruct_0205C22C *)param1; UnkStruct_0205B43C *v1 = v0->unk_00; - if (!sub_020509A4(v0->fieldSystem)) { + if (!FieldSystem_IsRunningTask(v0->fieldSystem)) { v0->playerAvatar = v0->fieldSystem->playerAvatar; sub_0205C44C(v0, v1, v0->fieldSystem->mapObjMan, v0->unk_474); sub_0205C51C(v0, v0->fieldSystem->mapObjMan); diff --git a/src/unk_0205DFC4.c b/src/unk_0205DFC4.c index 7ec015fc37..0a9df27cb3 100644 --- a/src/unk_0205DFC4.c +++ b/src/unk_0205DFC4.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_decls/struct_party_decl.h" @@ -12,6 +11,7 @@ #include "communication_information.h" #include "communication_system.h" +#include "field_task.h" #include "heap.h" #include "map_object.h" #include "party.h" @@ -20,7 +20,6 @@ #include "savedata.h" #include "trainer_info.h" #include "unk_0201D15C.h" -#include "unk_020508D4.h" typedef struct { MapObject *unk_00; @@ -288,11 +287,11 @@ BOOL HasAllLegendaryTitansInParty(SaveData *param0) return 0; } -static BOOL sub_0205E268(TaskManager *param0) +static BOOL sub_0205E268(FieldTask *param0) { VecFx32 v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205E268 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205E268 *v2 = FieldTask_GetEnv(param0); v0.x = FX32_CONST(8); v0.z = FX32_CONST(8); @@ -319,9 +318,9 @@ static BOOL sub_0205E268(TaskManager *param0) return 0; } -void sub_0205E318(TaskManager *param0, MapObject *param1, u16 param2, u16 param3, u16 param4, u16 param5) +void sub_0205E318(FieldTask *param0, MapObject *param1, u16 param2, u16 param3, u16 param4, u16 param5) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0205E268 *v1 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_0205E268)); MI_CpuClear8(v1, sizeof(UnkStruct_0205E268)); @@ -332,13 +331,13 @@ void sub_0205E318(TaskManager *param0, MapObject *param1, u16 param2, u16 param3 v1->unk_10 = param3; v1->unk_00 = param1; - FieldTask_Start(fieldSystem->taskManager, sub_0205E268, v1); + FieldTask_InitCall(fieldSystem->task, sub_0205E268, v1); } -static BOOL sub_0205E3AC(TaskManager *param0) +static BOOL sub_0205E3AC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0205E3AC *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0205E3AC *v1 = FieldTask_GetEnv(param0); MapObject_SetHidden(v1->unk_00, v1->unk_09); @@ -355,9 +354,9 @@ static BOOL sub_0205E3AC(TaskManager *param0) return 0; } -void sub_0205E3F4(TaskManager *param0, MapObject *param1, u16 param2, u16 param3) +void sub_0205E3F4(FieldTask *param0, MapObject *param1, u16 param2, u16 param3) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0205E3AC *v1 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_0205E3AC)); MI_CpuClear8(v1, sizeof(UnkStruct_0205E3AC)); @@ -367,7 +366,7 @@ void sub_0205E3F4(TaskManager *param0, MapObject *param1, u16 param2, u16 param3 v1->unk_00 = param1; v1->unk_09 = 0; - FieldTask_Start(fieldSystem->taskManager, sub_0205E3AC, v1); + FieldTask_InitCall(fieldSystem->task, sub_0205E3AC, v1); } int sub_0205E430(u8 param0, u8 param1) diff --git a/src/unk_020683F4.c b/src/unk_020683F4.c index 21b02046dc..49896c1c27 100644 --- a/src/unk_020683F4.c +++ b/src/unk_020683F4.c @@ -3,7 +3,8 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" +#include "constants/savedata/vars_flags.h" + #include "struct_decls/struct_02061AB4_decl.h" #include "struct_defs/struct_0203D9B8.h" #include "struct_defs/struct_020684D0.h" @@ -30,6 +31,7 @@ #include "field_map_change.h" #include "field_menu.h" #include "field_system.h" +#include "field_task.h" #include "game_options.h" #include "heap.h" #include "item.h" @@ -44,19 +46,18 @@ #include "save_player.h" #include "script_manager.h" #include "strbuf.h" +#include "system_flags.h" #include "unk_0200F174.h" #include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_0203C954.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020553DC.h" #include "unk_02055C50.h" #include "unk_0205D8CC.h" #include "unk_0205DAC8.h" #include "unk_0205F180.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "unk_0206B9D8.h" #include "unk_0207CB08.h" @@ -156,12 +157,12 @@ static u32 sub_02068D68(const UnkStruct_020684D0 *param0); static u32 sub_02068E94(const UnkStruct_020684D0 *param0); static u32 sub_020690C4(const UnkStruct_020684D0 *param0); static u32 sub_02069130(const UnkStruct_020684D0 *param0); -static BOOL sub_02068884(TaskManager *param0); -static BOOL sub_02068F48(TaskManager *param0); +static BOOL sub_02068884(FieldTask *param0); +static BOOL sub_02068F48(FieldTask *param0); static void sub_020693F8(UnkStruct_02068870 *param0, UnkFuncPtr_02068870 param1); -static BOOL sub_0206932C(TaskManager *param0); -static BOOL sub_020690F0(TaskManager *param0); -static BOOL sub_020685AC(TaskManager *param0); +static BOOL sub_0206932C(FieldTask *param0); +static BOOL sub_020690F0(FieldTask *param0); +static BOOL sub_020685AC(FieldTask *param0); static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1); static const UnkStruct_020EF79C Unk_020EF79C[] = { @@ -215,7 +216,7 @@ void sub_0206842C(FieldSystem *fieldSystem, UnkStruct_020684D0 *param1) param1->fieldSystem = fieldSystem; param1->unk_00 = fieldSystem->location->mapId; - param1->unk_04 = sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData)); + param1->unk_04 = SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)); param1->unk_08 = PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar); v0 = Player_GetXPos(fieldSystem->playerAvatar); @@ -251,7 +252,7 @@ static void sub_020684D0(FieldSystem *fieldSystem, UnkStruct_020684D0 *param1) { param1->fieldSystem = fieldSystem; param1->unk_00 = fieldSystem->location->mapId; - param1->unk_04 = sub_0206A984(SaveData_GetVarsFlags(fieldSystem->saveData)); + param1->unk_04 = SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(fieldSystem->saveData)); param1->unk_08 = PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar); param1->unk_0E = sub_02061760(fieldSystem->playerAvatar); @@ -268,7 +269,7 @@ static UnkStruct_0206851C *sub_0206851C(u32 param0, u16 param1, u16 param2, u16 { UnkStruct_0206851C *v0; - v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0206851C)); + v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0206851C)); v0->unk_00 = param0; v0->unk_04 = param1; @@ -284,10 +285,10 @@ static void sub_02068540(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = sub_020685AC; v1->unk_25C = sub_0206851C(param2, param0->unk_04, 0, 0, 0); @@ -297,13 +298,13 @@ static void sub_02068540(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p static void sub_02068584(UnkStruct_02068870 *param0, u32 param1) { void *v0 = sub_0206851C(param1, param0->unk_28, 0, 0, 0); - FieldTask_Set(param0->fieldSystem, sub_020685AC, v0); + FieldSystem_CreateTask(param0->fieldSystem, sub_020685AC, v0); } -static BOOL sub_020685AC(TaskManager *taskMan) +static BOOL sub_020685AC(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_0206851C *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_0206851C *v1 = FieldTask_GetEnv(taskMan); int *v2 = FieldTask_GetState(taskMan); MapObject *v3; @@ -333,8 +334,8 @@ static void sub_02068630(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; PartyManagementData *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = Heap_AllocFromHeap(11, sizeof(PartyManagementData)); memset(v2, 0, sizeof(PartyManagementData)); @@ -361,8 +362,8 @@ static void sub_020686C8(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v1->unk_25C = sub_0203D8AC(fieldSystem); sub_0203B674(v1, sub_0203C3F4); @@ -384,10 +385,10 @@ static void sub_02068710(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = FieldTask_MapChangeToUnderground; v1->unk_25C = sub_02053FAC(fieldSystem); @@ -401,7 +402,7 @@ static BOOL sub_02068750(UnkStruct_02068870 *param0) void *v0 = sub_02053FAC(param0->fieldSystem); MapObjectMan_PauseAllMovement(param0->fieldSystem->mapObjMan); - FieldTask_Set(param0->fieldSystem, FieldTask_MapChangeToUnderground, v0); + FieldSystem_CreateTask(param0->fieldSystem, FieldTask_MapChangeToUnderground, v0); param0->fieldSystem->unk_90 = 0; return 0; @@ -421,7 +422,7 @@ static u32 sub_0206877C(const UnkStruct_020684D0 *param0) return -1; } - if ((sub_0206AE5C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) || (sub_0206AE8C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1)) { + if ((SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) || (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1)) { return -1; } @@ -456,10 +457,10 @@ static void sub_0206883C(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = sub_02068884; v1->unk_25C = NULL; @@ -468,16 +469,16 @@ static void sub_0206883C(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p static BOOL sub_02068870(UnkStruct_02068870 *param0) { - FieldTask_Set(param0->fieldSystem, sub_02068884, NULL); + FieldSystem_CreateTask(param0->fieldSystem, sub_02068884, NULL); return 0; } -static BOOL sub_02068884(TaskManager *param0) +static BOOL sub_02068884(FieldTask *param0) { FieldSystem *fieldSystem; int *v1; - fieldSystem = TaskManager_FieldSystem(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); v1 = FieldTask_GetState(param0); switch (*v1) { @@ -525,7 +526,7 @@ static u32 sub_02068948(const UnkStruct_020684D0 *param0) return 2; } - if (sub_0206AF1C(v0, 2) == 1) { + if (SystemFlag_HandleForceBikingInGate(v0, HANDLE_FLAG_CHECK) == TRUE) { return 1; } @@ -561,8 +562,8 @@ static void sub_020689EC(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); sub_0203D30C(fieldSystem, NULL); sub_0203B674(v1, sub_0203C50C); @@ -586,8 +587,8 @@ static void sub_02068A34(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; PartyManagementData *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = Heap_AllocFromHeap(11, sizeof(PartyManagementData)); memset(v2, 0, sizeof(PartyManagementData)); @@ -615,8 +616,8 @@ static void sub_02068ACC(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; UnkStruct_02097728 *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = sub_0203D94C(fieldSystem, 3, Item_MailNumber(param0->unk_04), 11); v1->unk_260 = sub_0203C540(param0->unk_04, 3, 0); @@ -636,8 +637,8 @@ static void sub_02068B1C(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; MapObject *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); if (param1->unk_10 & 0x1) { sub_02068540(param0, param1, 2801); @@ -661,8 +662,8 @@ static void sub_02068B5C(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; UnkStruct_0203D9B8 *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = sub_0203D9B8(fieldSystem, 11); v1->unk_25C = v2; @@ -685,8 +686,8 @@ static void sub_02068BA8(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); sub_0203DE78(fieldSystem, fieldSystem->saveData); v1->unk_25C = NULL; @@ -711,12 +712,12 @@ static void sub_02068BF8(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; int *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = Heap_AllocFromHeapAtEnd(11, sizeof(int)); (*v2) = 0; - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = RefreshRadarChain; v1->unk_25C = v2; @@ -728,7 +729,7 @@ static BOOL sub_02068C38(UnkStruct_02068870 *param0) int *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(int)); *v0 = 0; - FieldTask_Set(param0->fieldSystem, RefreshRadarChain, v0); + FieldSystem_CreateTask(param0->fieldSystem, RefreshRadarChain, v0); return 0; } @@ -795,10 +796,10 @@ static void sub_02068CF0(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p UnkStruct_ov5_021F0468 *v2; int v3; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v3 = ov5_021F0484(); v2 = Heap_AllocFromHeapAtEnd(11, v3); @@ -837,10 +838,10 @@ static void sub_02068D80(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = ov5_021F08F8; v1->unk_25C = ov5_021F08CC(fieldSystem, 11, 0); @@ -851,7 +852,7 @@ static BOOL sub_02068DBC(UnkStruct_02068870 *param0) { void *v0 = ov5_021F08CC(param0->fieldSystem, 4, 0); - FieldTask_Set(param0->fieldSystem, ov5_021F08F8, v0); + FieldSystem_CreateTask(param0->fieldSystem, ov5_021F08F8, v0); return 0; } @@ -860,10 +861,10 @@ static void sub_02068DDC(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = ov5_021F08F8; v1->unk_25C = ov5_021F08CC(fieldSystem, 11, 1); @@ -874,7 +875,7 @@ static BOOL sub_02068E18(UnkStruct_02068870 *param0) { void *v0 = ov5_021F08CC(param0->fieldSystem, 4, 1); - FieldTask_Set(param0->fieldSystem, ov5_021F08F8, v0); + FieldSystem_CreateTask(param0->fieldSystem, ov5_021F08F8, v0); return 0; } @@ -883,10 +884,10 @@ static void sub_02068E38(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = ov5_021F08F8; v1->unk_25C = ov5_021F08CC(fieldSystem, 11, 2); @@ -897,7 +898,7 @@ static BOOL sub_02068E74(UnkStruct_02068870 *param0) { void *v0 = ov5_021F08CC(param0->fieldSystem, 4, 2); - FieldTask_Set(param0->fieldSystem, ov5_021F08F8, v0); + FieldSystem_CreateTask(param0->fieldSystem, ov5_021F08F8, v0); return 0; } @@ -934,18 +935,18 @@ static BOOL sub_02068EFC(UnkStruct_02068870 *param0) v0->unk_10 = Strbuf_Init(128, 11); sub_0207CC10(param0->fieldSystem->saveData, v0->unk_10, Bag_GetRegisteredItem(SaveData_GetBag(param0->fieldSystem->saveData)), 11); - FieldTask_Set(param0->fieldSystem, sub_02068F48, v0); + FieldSystem_CreateTask(param0->fieldSystem, sub_02068F48, v0); return 0; } -static BOOL sub_02068F48(TaskManager *param0) +static BOOL sub_02068F48(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_02068EFC *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); switch (v1->unk_16) { case 0: @@ -986,8 +987,8 @@ static void sub_02068FEC(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; PartyManagementData *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = Heap_AllocFromHeap(11, sizeof(PartyManagementData)); memset(v2, 0, sizeof(PartyManagementData)); @@ -1013,10 +1014,10 @@ static void sub_02069080(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - menu = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->unk_22C = sub_020690F0; menu->unk_25C = NULL; @@ -1038,12 +1039,12 @@ static u32 sub_020690C4(const UnkStruct_020684D0 *param0) return -1; } -static BOOL sub_020690F0(TaskManager *param0) +static BOOL sub_020690F0(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); void *v1 = ov6_02247100(fieldSystem, 11); - FieldTask_Change(param0, ov6_02247120, v1); + FieldTask_InitJump(param0, ov6_02247120, v1); return 0; } @@ -1062,7 +1063,7 @@ static u32 sub_02069130(const UnkStruct_020684D0 *param0) { VarsFlags *v0 = SaveData_GetVarsFlags(param0->fieldSystem->saveData); - if (sub_0206A954(v0) == 0) { + if (SystemFlag_CheckGameCompleted(v0) == 0) { return -1; } @@ -1086,8 +1087,8 @@ static void sub_02069188(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); sub_0203DE88(fieldSystem, fieldSystem->saveData); v1->unk_25C = NULL; @@ -1114,8 +1115,8 @@ static void sub_020691E0(UnkStruct_02068630 *param0, const UnkStruct_020684D0 *p FieldMenu *v1; PartyManagementData *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v1->unk_25C = sub_0203E598(fieldSystem, 11, 466); @@ -1146,7 +1147,7 @@ BOOL sub_02069238(FieldSystem *fieldSystem) return 0; } - if (sub_0206AE8C(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { return 0; } @@ -1196,16 +1197,16 @@ static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1) v0->unk_10 = Strbuf_Init(128, 11); sub_0207CD34(SaveData_GetTrainerInfo(param0->fieldSystem->saveData), v0->unk_10, param0->unk_28, param1, 11); - FieldTask_Set(param0->fieldSystem, sub_02068F48, v0); + FieldSystem_CreateTask(param0->fieldSystem, sub_02068F48, v0); } -static BOOL sub_0206932C(TaskManager *taskMan) +static BOOL sub_0206932C(FieldTask *taskMan) { FieldSystem *fieldSystem; UnkStruct_02068870 *v1; - fieldSystem = TaskManager_FieldSystem(taskMan); - v1 = TaskManager_Environment(taskMan); + fieldSystem = FieldTask_GetFieldSystem(taskMan); + v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_2A) { case 0: @@ -1220,7 +1221,7 @@ static BOOL sub_0206932C(TaskManager *taskMan) } break; case 2: - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { break; } @@ -1232,11 +1233,11 @@ static BOOL sub_0206932C(TaskManager *taskMan) } } - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_2A = 3; break; case 3: - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { MapObjectMan_PauseAllMovement(fieldSystem->mapObjMan); ov5_021D1744(1); v1->unk_2A = 4; @@ -1257,5 +1258,5 @@ static BOOL sub_0206932C(TaskManager *taskMan) static void sub_020693F8(UnkStruct_02068870 *param0, UnkFuncPtr_02068870 param1) { param0->unk_20 = param1; - FieldTask_Set(param0->fieldSystem, sub_0206932C, param0); + FieldSystem_CreateTask(param0->fieldSystem, sub_0206932C, param0); } diff --git a/src/unk_0206A8DC.c b/src/unk_0206A8DC.c deleted file mode 100644 index 95d3c3653f..0000000000 --- a/src/unk_0206A8DC.c +++ /dev/null @@ -1,510 +0,0 @@ -#include "unk_0206A8DC.h" - -#include -#include - -#include "rtc.h" -#include "vars_flags.h" - -static void sub_0206A8DC(VarsFlags *param0, u16 param1); -static void sub_0206A8E4(VarsFlags *param0, u16 param1); -static BOOL sub_0206A8EC(VarsFlags *param0, u16 param1); -static BOOL sub_0206A8F4(VarsFlags *param0, int param1, u32 param2); - -static void sub_0206A8DC(VarsFlags *param0, u16 param1) -{ - VarsFlags_SetFlag(param0, param1); - return; -} - -static void sub_0206A8E4(VarsFlags *param0, u16 param1) -{ - VarsFlags_ClearFlag(param0, param1); - return; -} - -static BOOL sub_0206A8EC(VarsFlags *param0, u16 param1) -{ - return VarsFlags_CheckFlag(param0, param1); -} - -static BOOL sub_0206A8F4(VarsFlags *param0, int param1, u32 param2) -{ - switch (param1) { - case 1: - sub_0206A8DC(param0, param2); - break; - case 0: - sub_0206A8E4(param0, param2); - break; - case 2: - return sub_0206A8EC(param0, param2); - default: - GF_ASSERT(0); - } - - return 0; -} - -void VarsFlags_SetBagAvailable(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 0)); - return; -} - -BOOL VarsFlags_CheckBagAvailable(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 0)); -} - -void sub_0206A944(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 4)); - return; -} - -BOOL sub_0206A954(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 4)); -} - -void sub_0206A964(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 1)); - return; -} - -void sub_0206A974(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 1)); - return; -} - -BOOL sub_0206A984(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 1)); -} - -void sub_0206A994(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 5)); - return; -} - -void sub_0206A9A4(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 5)); - return; -} - -BOOL sub_0206A9B4(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 5)); -} - -void VsSeeker_SetUsedFlag(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 13)); -} - -void VsSeeker_ClearUsedFlag(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 13)); -} - -BOOL VsSeeker_GetUsedFlag(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 13)); -} - -void sub_0206A9F4(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 14)); - return; -} - -void sub_0206AA04(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 15)); - return; -} - -void sub_0206AA14(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 16)); - return; -} - -void sub_0206AA20(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 17)); - return; -} - -void sub_0206AA30(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 18)); - return; -} - -void sub_0206AA40(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 19)); - return; -} - -void sub_0206AA50(VarsFlags *param0, int param1) -{ - switch (param1) { - case 0: - sub_0206A8DC(param0, (2400 + 8)); - break; - case 1: - sub_0206A8DC(param0, (2400 + 9)); - break; - case 2: - sub_0206A8DC(param0, (2400 + 10)); - break; - case 3: - sub_0206A8DC(param0, (2400 + 11)); - break; - case 4: - sub_0206A8DC(param0, (2400 + 12)); - break; - } - - return; -} - -BOOL sub_0206AAA8(VarsFlags *param0, int param1) -{ - int v0; - - switch (param1) { - case 0: - v0 = sub_0206A8EC(param0, (2400 + 8)); - break; - case 1: - v0 = sub_0206A8EC(param0, (2400 + 9)); - break; - case 2: - v0 = sub_0206A8EC(param0, (2400 + 10)); - break; - case 3: - v0 = sub_0206A8EC(param0, (2400 + 11)); - break; - case 4: - v0 = sub_0206A8EC(param0, (2400 + 12)); - break; - } - - return v0; -} - -BOOL VsSeeker_HasUnlockedLevel(VarsFlags *param0, int param1) -{ - int v0 = 0; - - switch (param1) { - case 1: - v0 = sub_0206A8EC(param0, (2400 + 31)); - break; - case 2: - v0 = sub_0206A8EC(param0, (2400 + 32)); - break; - case 3: - v0 = sub_0206A8EC(param0, (2400 + 33)); - break; - case 4: - v0 = sub_0206A8EC(param0, (2400 + 34)); - break; - case 5: - v0 = sub_0206A8EC(param0, (2400 + 35)); - break; - } - - return v0; -} - -u16 sub_0206AB68(VarsFlags *param0, int param1) -{ - u16 v0 = 0; - - switch (param1) { - case 314: - if (sub_0206A8EC(param0, (2400 + 36)) == 1) { - v0 = 1070; - } - break; - case 316: - if (sub_0206A8EC(param0, (2400 + 36)) == 1) { - v0 = 1065; - } - break; - case 312: - if (sub_0206A8EC(param0, (2400 + 46)) == 1) { - v0 = 1070; - } - break; - case 318: - if (sub_0206A8EC(param0, (2400 + 47)) == 1) { - v0 = 1070; - } - break; - case 251: - if (sub_0206A8EC(param0, (2400 + 53)) == 1) { - v0 = 1069; - } - break; - case 422: - if (sub_0206A8EC(param0, (2400 + 51)) == 1) { - v0 = 1098; - } - break; - case 305: - case 306: - case 307: - case 308: - case 309: - case 310: - case 494: - case 497: - if (sub_0206A8EC(param0, (2400 + 37)) == 1) { - if (IsNight() == 0) { - v0 = 1016; - } else { - v0 = 1045; - } - break; - } - - if (param1 == 305) { - if (sub_0206A8EC(param0, (2400 + 38)) == 1) { - v0 = 1067; - } - } - break; - case 72: - case 73: - case 74: - case 75: - if (sub_0206A8EC(param0, (2400 + 39)) == 1) { - if (IsNight() == 0) { - v0 = 1013; - } else { - v0 = 1042; - } - } - break; - case 201: - if (sub_0206A8EC(param0, (2400 + 40)) == 1) { - if (IsNight() == 0) { - v0 = 1023; - } else { - v0 = 1052; - } - } - break; - case 256: - if (sub_0206A8EC(param0, (2400 + 41)) == 1) { - if (IsNight() == 0) { - v0 = 1006; - } else { - v0 = 1035; - } - } - break; - case 399: - if (sub_0206A8EC(param0, (2400 + 42)) == 1) { - if (IsNight() == 0) { - v0 = 1006; - } else { - v0 = 1035; - } - } - break; - case 185: - if (sub_0206A8EC(param0, (2400 + 43)) == 1) { - v0 = 1001; - } - break; - } - - return v0; -} - -void sub_0206AD9C(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 6)); - return; -} - -void CommClub_ResetAvailable(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 6)); - return; -} - -BOOL CommClub_IsAvailable(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 6)); -} - -BOOL ContestHall_IsVisited(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 24)); -} - -BOOL sub_0206ADDC(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 50)); -} - -BOOL sub_0206ADEC(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 29)); -} - -BOOL sub_0206ADFC(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 30)); -} - -void sub_0206AE0C(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 28)); -} - -void sub_0206AE1C(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 28)); -} - -BOOL sub_0206AE2C(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 28)); -} - -void sub_0206AE3C(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 7)); -} - -void sub_0206AE4C(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 7)); -} - -BOOL sub_0206AE5C(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 7)); -} - -void sub_0206AE6C(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 25)); -} - -void sub_0206AE7C(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 25)); -} - -BOOL sub_0206AE8C(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 25)); -} - -void sub_0206AE9C(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 52)); -} - -BOOL sub_0206AEAC(VarsFlags *param0, int param1) -{ - return sub_0206A8F4(param0, param1, (2400 + 2)); -} - -void sub_0206AEBC(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 26)); -} - -void sub_0206AECC(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 26)); -} - -BOOL Overworld_IsFlashActive(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 26)); -} - -void sub_0206AEEC(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 27)); -} - -void sub_0206AEFC(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 27)); -} - -BOOL Overworld_IsDefogActive(VarsFlags *param0) -{ - return sub_0206A8EC(param0, (2400 + 27)); -} - -BOOL sub_0206AF1C(VarsFlags *param0, int param1) -{ - return sub_0206A8F4(param0, param1, (2400 + 54)); -} - -BOOL sub_0206AF2C(VarsFlags *param0, int param1) -{ - return sub_0206A8F4(param0, param1, (2400 + 3)); -} - -BOOL sub_0206AF3C(VarsFlags *param0, int param1, u32 param2) -{ - GF_ASSERT(param2 < 69); - return sub_0206A8F4(param0, param1, (2400 + 80) + param2); -} - -void sub_0206AF5C(VarsFlags *param0) -{ - sub_0206A8DC(param0, (2400 + 44)); -} - -BOOL sub_0206AF6C(VarsFlags *param0, int param1, int param2) -{ - GF_ASSERT(param2 < 20); - return sub_0206A8F4(param0, param1, (2400 + 55) + param2); -} - -void sub_0206AF90(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 75)); - return; -} - -void sub_0206AFA0(VarsFlags *param0) -{ - sub_0206A8E4(param0, (2400 + 76)); - return; -} - -BOOL sub_0206AFB0(VarsFlags *param0, int param1, int param2) -{ - return sub_0206A8F4(param0, param1, (2400 + 78) + param2); -} - -BOOL sub_0206AFC0(VarsFlags *param0, int param1) -{ - return sub_0206A8F4(param0, param1, (2400 + 77)); -} - -BOOL sub_0206AFD0(VarsFlags *param0) -{ - return sub_0206A8F4(param0, 2, (2400 + 23)); -} diff --git a/src/unk_0206AFE0.c b/src/unk_0206AFE0.c index f255f4352b..73f2f0cc4e 100644 --- a/src/unk_0206AFE0.c +++ b/src/unk_0206AFE0.c @@ -3,14 +3,17 @@ #include #include +#include "constants/savedata/vars_flags.h" +#include "consts/map.h" + #include "struct_decls/struct_0203A790_decl.h" #include "field_overworld_state.h" #include "location.h" #include "record_mixed_rng.h" #include "savedata.h" +#include "system_flags.h" #include "unk_0201D15C.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" static BOOL sub_0206AFE0(VarsFlags *param0, u16 param1, u16 param2); @@ -115,7 +118,7 @@ BOOL sub_0206B0C4(VarsFlags *param0, u16 param1) void VsSeeker_Reset(VarsFlags *param0) { - VsSeeker_ClearUsedFlag(param0); + SystemFlag_ClearVsSeekerUsed(param0); VsSeeker_SetActiveStepCount(param0, 0); } @@ -426,8 +429,8 @@ static u8 sub_0206B4A4(VarsFlags *param0) v1 = 0; - for (v0 = 0; v0 < 20; v0++) { - if (sub_0206AF6C(param0, 2, v0) == 1) { + for (v0 = 0; v0 < VILLA_FURNITURE_MAX; v0++) { + if (SystemFlag_HandleOwnsVillaFurniture(param0, HANDLE_FLAG_CHECK, v0) == TRUE) { v1++; } } @@ -457,9 +460,9 @@ void sub_0206B514(SaveData *param0) FieldOverworldState *v2 = SaveData_GetFieldOverworldState(param0); Location *location = FieldOverworldState_GetPlayerLocation(v2); - if ((location->mapId != 457) && (location->mapId != 464)) { - sub_0206AF90(v1); - sub_0206AFA0(v1); + if ((location->mapId != MAP_HEADER_RESORT_AREA) && (location->mapId != MAP_HEADER_VILLA)) { + SystemFlag_ClearVillaVisitorInside(v1); + SystemFlag_ClearVillaVisitorOutside(v1); sub_0206B558(v1, sub_0206B4A4(v1)); } diff --git a/src/unk_0206B70C.c b/src/unk_0206B70C.c index c92848ab5b..7fbaacea3a 100644 --- a/src/unk_0206B70C.c +++ b/src/unk_0206B70C.c @@ -3,6 +3,8 @@ #include #include +#include "constants/savedata/vars_flags.h" + #include "struct_decls/struct_0203A790_decl.h" #include "struct_defs/struct_0203D8AC.h" #include "struct_defs/struct_020556C4.h" @@ -19,6 +21,7 @@ #include "player_avatar.h" #include "save_player.h" #include "script_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02039C80.h" #include "unk_0206AFE0.h" @@ -47,26 +50,26 @@ static const int Unk_020EFA98[10][4] = { }; static const u8 Unk_020EFA84[20] = { - 0x0, - 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x6, - 0x7, - 0x8, - 0x9, - 0xA, - 0xB, - 0xC, - 0xD, - 0xE, - 0xF, - 0x11, - 0x43, - 0x10, - 0x44 + FIRST_ARRIVAL_TWINLEAF_TOWN, + FIRST_ARRIVAL_SANDGEM_TOWN, + FIRST_ARRIVAL_FLOAROMA_TOWN, + FIRST_ARRIVAL_SOLACEON_TOWN, + FIRST_ARRIVAL_CELESTIC_TOWN, + FIRST_ARRIVAL_SURVIVAL_AREA, + FIRST_ARRIVAL_RESORT_AREA, + FIRST_ARRIVAL_JUBILIFE_CITY, + FIRST_ARRIVAL_CANALAVE_CITY, + FIRST_ARRIVAL_OREBURGH_CITY, + FIRST_ARRIVAL_ETERNA_CITY, + FIRST_ARRIVAL_HEARTHOME_CITY, + FIRST_ARRIVAL_PASTORIA_CITY, + FIRST_ARRIVAL_VEILSTONE_CITY, + FIRST_ARRIVAL_SUNYSHORE_CITY, + FIRST_ARRIVAL_SNOWPOINT_CITY, + FIRST_ARRIVAL_FIGHT_AREA, + FIRST_ARRIVAL_POKE_PARK_FRONT_GATE, + FIRST_ARRIVAL_OUTSIDE_VICTORY_ROAD, + FIRST_ARRIVAL_POKEMON_LEAGUE, }; void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int param2) @@ -139,7 +142,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para } for (v1 = 0; v1 < 20; v1++) { - param1->unk_124[v1] = inline_0208BE68(v8, Unk_020EFA84[v1]); + param1->unk_124[v1] = SystemFlag_HandleFirstArrivalToZone(v8, HANDLE_FLAG_CHECK, Unk_020EFA84[v1]); } sub_0206B878(fieldSystem, param1, "data/tmap_flags.dat"); @@ -177,7 +180,7 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c switch (v4->unk_00) { case 1: - v5->val1_2 = inline_0208BE68(v6, v4->unk_01); + v5->val1_2 = SystemFlag_HandleFirstArrivalToZone(v6, HANDLE_FLAG_CHECK, v4->unk_01); v5->val1_0 = 1; break; case 2: @@ -188,7 +191,7 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c switch (v4->unk_02) { case 1: - v5->val1_6 = inline_0208BE68(v6, v4->unk_03); + v5->val1_6 = SystemFlag_HandleFirstArrivalToZone(v6, HANDLE_FLAG_CHECK, v4->unk_03); v5->val1_4 = 1; break; case 2: diff --git a/src/unk_0206B9D8.c b/src/unk_0206B9D8.c index 073014a71e..c3929cfcaa 100644 --- a/src/unk_0206B9D8.c +++ b/src/unk_0206B9D8.c @@ -9,7 +9,6 @@ #include "struct_decls/struct_0202D060_decl.h" #include "struct_decls/struct_0202D750_decl.h" #include "struct_decls/struct_0203068C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/pokemon_summary.h" #include "struct_defs/struct_0206BC70.h" #include "struct_defs/struct_02098C44.h" @@ -19,6 +18,7 @@ #include "bag.h" #include "communication_system.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "party.h" #include "pokemon_summary_app.h" @@ -34,7 +34,6 @@ #include "unk_02038FFC.h" #include "unk_0203D1B8.h" #include "unk_0204AEE8.h" -#include "unk_020508D4.h" #include "unk_0207A274.h" #include "constdata/const_020F1E88.h" @@ -102,7 +101,7 @@ static int sub_0206BA84(UnkStruct_0206B9D8 *param0, FieldSystem *fieldSystem) int v0; PartyManagementData *v1; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 1; } @@ -162,7 +161,7 @@ static int sub_0206BB6C(UnkStruct_0206B9D8 *param0, FieldSystem *fieldSystem) { PokemonSummary *v0; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 3; } @@ -174,10 +173,10 @@ static int sub_0206BB6C(UnkStruct_0206B9D8 *param0, FieldSystem *fieldSystem) return 0; } -static BOOL sub_0206BB94(TaskManager *param0) +static BOOL sub_0206BB94(FieldTask *param0) { - FieldSystem *v0 = TaskManager_FieldSystem(param0); - UnkStruct_0206B9D8 *v1 = TaskManager_Environment(param0); + FieldSystem *v0 = FieldTask_GetFieldSystem(param0); + UnkStruct_0206B9D8 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: @@ -200,9 +199,9 @@ static BOOL sub_0206BB94(TaskManager *param0) return 0; } -void sub_0206BBFC(TaskManager *param0, void **param1, u8 param2, u8 param3, u8 param4, u8 param5, u8 param6, u8 param7) +void sub_0206BBFC(FieldTask *param0, void **param1, u8 param2, u8 param3, u8 param4, u8 param5, u8 param6, u8 param7) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0206B9D8 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0206B9D8)); MI_CpuClear8(v1, sizeof(UnkStruct_0206B9D8)); @@ -215,7 +214,7 @@ void sub_0206BBFC(TaskManager *param0, void **param1, u8 param2, u8 param3, u8 p v1->unk_0D = param7; v1->unk_14 = param1; - FieldTask_Start(fieldSystem->taskManager, sub_0206BB94, v1); + FieldTask_InitCall(fieldSystem->task, sub_0206BB94, v1); } static int sub_0206BC48(UnkStruct_0206BC48 *param0, FieldSystem *fieldSystem) @@ -236,7 +235,7 @@ static int sub_0206BC70(UnkStruct_0206BC48 *param0, FieldSystem *fieldSystem) u8 v0; UnkStruct_0206BC70 *v1; - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 1; } @@ -246,11 +245,11 @@ static int sub_0206BC70(UnkStruct_0206BC48 *param0, FieldSystem *fieldSystem) return 2; } -static BOOL sub_0206BC94(TaskManager *param0) +static BOOL sub_0206BC94(FieldTask *param0) { u16 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0206BC48 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0206BC48 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_04) { case 0: @@ -269,9 +268,9 @@ static BOOL sub_0206BC94(TaskManager *param0) return 0; } -void sub_0206BCE4(TaskManager *param0, u16 param1, u16 param2, u16 param3) +void sub_0206BCE4(FieldTask *param0, u16 param1, u16 param2, u16 param3) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0206BC48 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0206BC48)); MI_CpuClear8(v1, sizeof(UnkStruct_0206BC48)); @@ -280,15 +279,15 @@ void sub_0206BCE4(TaskManager *param0, u16 param1, u16 param2, u16 param3) v1->unk_14 = param3; v1->unk_10 = param2; - FieldTask_Start(fieldSystem->taskManager, sub_0206BC94, v1); + FieldTask_InitCall(fieldSystem->task, sub_0206BC94, v1); } -static BOOL sub_0206BD1C(TaskManager *param0) +static BOOL sub_0206BD1C(FieldTask *param0) { u16 *v0; const void *v1; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0206BD88 *v3 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0206BD88 *v3 = FieldTask_GetEnv(param0); v1 = sub_0203664C(1 - CommSys_CurNetId()); @@ -313,9 +312,9 @@ static BOOL sub_0206BD1C(TaskManager *param0) return 1; } -void sub_0206BD88(TaskManager *param0, u16 param1, u16 param2) +void sub_0206BD88(FieldTask *param0, u16 param1, u16 param2) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0206BD88 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0206BD88)); MI_CpuClear8(v1, sizeof(UnkStruct_0206BD88)); @@ -323,7 +322,7 @@ void sub_0206BD88(TaskManager *param0, u16 param1, u16 param2) v1->unk_00 = param1; v1->unk_02 = param2; - FieldTask_Start(fieldSystem->taskManager, sub_0206BD1C, v1); + FieldTask_InitCall(fieldSystem->task, sub_0206BD1C, v1); } u16 sub_0206BDBC(SaveData *param0) diff --git a/src/unk_0206C0E8.c b/src/unk_0206C0E8.c index 889f37f23f..ed9d9bf05b 100644 --- a/src/unk_0206C0E8.c +++ b/src/unk_0206C0E8.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "field/field_system.h" @@ -15,15 +14,15 @@ #include "core_sys.h" #include "field_map_change.h" +#include "field_task.h" #include "heap.h" #include "location.h" #include "map_object.h" #include "player_avatar.h" +#include "system_flags.h" #include "unk_02005474.h" -#include "unk_020508D4.h" #include "unk_02055808.h" #include "unk_02056B30.h" -#include "unk_0206A8DC.h" #include "unk_02070428.h" #include "vars_flags.h" @@ -36,7 +35,7 @@ typedef struct { u8 unk_0E; } UnkStruct_0206C0E8; -static BOOL sub_0206C120(TaskManager *taskMan); +static BOOL sub_0206C120(FieldTask *taskMan); void sub_0206C0E8(FieldSystem *fieldSystem) { @@ -47,13 +46,13 @@ void sub_0206C0E8(FieldSystem *fieldSystem) v0->unk_0C = 0; v0->unk_0D = 0; - FieldTask_Start(fieldSystem->taskManager, sub_0206C120, v0); + FieldTask_InitCall(fieldSystem->task, sub_0206C120, v0); } -static BOOL sub_0206C120(TaskManager *taskMan) +static BOOL sub_0206C120(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_0206C0E8 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_0206C0E8 *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_0C) { case 0: @@ -71,9 +70,9 @@ static BOOL sub_0206C120(TaskManager *taskMan) VarsFlags *v2 = SaveData_GetVarsFlags(fieldSystem->saveData); if (v1->unk_0D == 0) { - sub_0206AE0C(v2); + SystemFlag_SetPoketchHidden(v2); } else if (v1->unk_0D == 5) { - sub_0206AE1C(v2); + SystemFlag_ClearPoketchHidden(v2); } } diff --git a/src/unk_0206C660.c b/src/unk_0206C660.c index ac150a1ae1..9b0f391068 100644 --- a/src/unk_0206C660.c +++ b/src/unk_0206C660.c @@ -3,17 +3,15 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay006/ov6_02246184.h" #include "overlay006/struct_ov6_02246204_decl.h" #include "overlay006/struct_ov6_02246254.h" #include "overlay095/ov95_02246C20.h" +#include "field_task.h" #include "heap.h" #include "pokemon.h" -#include "unk_020508D4.h" #include "unk_02055808.h" FS_EXTERN_OVERLAY(overlay95); @@ -27,13 +25,13 @@ typedef struct { Pokemon *unk_28; } UnkStruct_0206C660; -static BOOL sub_0206C680(TaskManager *param0); -static void sub_0206C660(TaskManager *param0); +static BOOL sub_0206C680(FieldTask *param0); +static void sub_0206C660(FieldTask *param0); -void sub_0206C660(TaskManager *param0) +void sub_0206C660(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0206C660 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0206C660 *v1 = FieldTask_GetEnv(param0); { FS_EXTERN_OVERLAY(overlay95); @@ -45,14 +43,14 @@ void sub_0206C660(TaskManager *param0) FS_OVERLAY_ID(overlay95), }; - sub_02050A38(param0, &v2, &v1->unk_0C); + FieldTask_RunApplication(param0, &v2, &v1->unk_0C); } } -static BOOL sub_0206C680(TaskManager *param0) +static BOOL sub_0206C680(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0206C660 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0206C660 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: @@ -90,7 +88,7 @@ static BOOL sub_0206C680(TaskManager *param0) return 0; } -void sub_0206C740(TaskManager *param0, UnkStruct_ov6_02246204 *param1, int param2, u32 param3) +void sub_0206C740(FieldTask *param0, UnkStruct_ov6_02246204 *param1, int param2, u32 param3) { UnkStruct_0206C660 *v0 = Heap_AllocFromHeap(param3, sizeof(UnkStruct_0206C660)); @@ -102,5 +100,5 @@ void sub_0206C740(TaskManager *param0, UnkStruct_ov6_02246204 *param1, int param v0->unk_24 = Pokemon_New(param3); v0->unk_28 = Pokemon_New(param3); - FieldTask_Start(param0, sub_0206C680, v0); + FieldTask_InitCall(param0, sub_0206C680, v0); } diff --git a/src/unk_0206C784.c b/src/unk_0206C784.c index 9108ab4229..809b0c41e4 100644 --- a/src/unk_0206C784.c +++ b/src/unk_0206C784.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02055130.h" #include "struct_defs/struct_0206C8D4.h" @@ -17,13 +16,13 @@ #include "camera.h" #include "field_map_change.h" +#include "field_task.h" #include "heap.h" #include "player_avatar.h" #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_020553DC.h" #include "unk_02055808.h" @@ -50,8 +49,8 @@ typedef struct { } UnkStruct_0206CAD0; static void sub_0206C8D4(FieldSystem *fieldSystem, const u8 param1, UnkStruct_ov5_021D5894 *param2); -static BOOL sub_0206C8F8(TaskManager *param0); -static BOOL sub_0206C964(TaskManager *param0); +static BOOL sub_0206C8F8(FieldTask *param0); +static BOOL sub_0206C964(FieldTask *param0); static BOOL sub_0206CAD0(UnkStruct_0206CAD0 *param0); static BOOL sub_0206CB8C(const fx32 *param0, const fx32 *param1, u8 *param2); static void sub_0206CBA0(FieldSystem *fieldSystem); @@ -127,7 +126,7 @@ void sub_0206C784(FieldSystem *fieldSystem, const u8 param1, const u8 param2, co v0->unk_00 = 2; } - FieldTask_Start(fieldSystem->taskManager, sub_0206C964, v0); + FieldTask_InitCall(fieldSystem->task, sub_0206C964, v0); } static void sub_0206C8D4(FieldSystem *fieldSystem, const u8 param1, UnkStruct_ov5_021D5894 *param2) @@ -139,13 +138,13 @@ static void sub_0206C8D4(FieldSystem *fieldSystem, const u8 param1, UnkStruct_ov v0->unk_04 = param2; v0->unk_00 = param1; - FieldTask_Start(fieldSystem->taskManager, sub_0206C8F8, v0); + FieldTask_InitCall(fieldSystem->task, sub_0206C8F8, v0); } -static BOOL sub_0206C8F8(TaskManager *taskMan) +static BOOL sub_0206C8F8(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_0206C8D4 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_0206C8D4 *v1 = FieldTask_GetEnv(taskMan); int *v2 = FieldTask_GetState(taskMan); switch (*v2) { @@ -157,7 +156,7 @@ static BOOL sub_0206C8F8(TaskManager *taskMan) } break; case 1: - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 0; } break; @@ -170,10 +169,10 @@ static BOOL sub_0206C8F8(TaskManager *taskMan) return 0; } -static BOOL sub_0206C964(TaskManager *taskMan) +static BOOL sub_0206C964(FieldTask *taskMan) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_0206CAD0 *v1 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_0206CAD0 *v1 = FieldTask_GetEnv(taskMan); switch (v1->unk_00) { case 0: diff --git a/src/unk_0206CCB0.c b/src/unk_0206CCB0.c index 12fb90045a..4b54670dc3 100644 --- a/src/unk_0206CCB0.c +++ b/src/unk_0206CCB0.c @@ -4,6 +4,7 @@ #include #include "constants/overworld_weather.h" +#include "constants/savedata/vars_flags.h" #include "constants/species.h" #include "struct_decls/pokedexdata_decl.h" @@ -48,6 +49,7 @@ #include "savedata_misc.h" #include "strbuf.h" #include "string_template.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0201D15C.h" #include "unk_0202631C.h" @@ -57,7 +59,6 @@ #include "unk_0203A944.h" #include "unk_02054884.h" #include "unk_0205DFC4.h" -#include "unk_0206A8DC.h" #include "unk_02071CFC.h" #include "unk_020923C0.h" #include "unk_02094EDC.h" @@ -1243,7 +1244,7 @@ static int sub_0206DB38(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206DB48(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 6); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_RESORT_AREA); } void sub_0206DB5C(FieldSystem *fieldSystem, u8 param1) @@ -1268,7 +1269,7 @@ static int sub_0206DB74(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206DB9C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 6); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_RESORT_AREA); } void sub_0206DBB0(SaveData *param0, u32 param1, Pokemon *param2, BOOL param3) @@ -1307,7 +1308,7 @@ static BOOL sub_0206DC3C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param return 0; } - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 17); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } void sub_0206DC6C(FieldSystem *fieldSystem, u32 param1, Pokemon *param2) @@ -1576,7 +1577,7 @@ static int sub_0206E018(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E04C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 17); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } void sub_0206E060(SaveData *param0) @@ -1606,7 +1607,7 @@ static int sub_0206E098(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E0CC(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 9); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_OREBURGH_CITY); } void sub_0206E0E0(FieldSystem *fieldSystem, u16 param1) @@ -1640,7 +1641,7 @@ static int sub_0206E118(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E160(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 17); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } void sub_0206E174(FieldSystem *fieldSystem, u16 param1) @@ -1902,7 +1903,7 @@ static int sub_0206E5E4(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E654(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 17); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } void sub_0206E668(FieldSystem *fieldSystem, u16 param1) @@ -2031,7 +2032,7 @@ static int sub_0206E7AC(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E834(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - return inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 17); + return SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_FIGHT_AREA); } static const u8 Unk_020EFD34[] = { @@ -2257,24 +2258,24 @@ static BOOL sub_0206EBE4(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param } static const u16 Unk_020EFD3C[] = { - 0x0, - 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x6, - 0x7, - 0x8, - 0x9, - 0xA, - 0xB, - 0xC, - 0xD, - 0xE, - 0xF, - 0x10, - 0x11 + FIRST_ARRIVAL_TWINLEAF_TOWN, + FIRST_ARRIVAL_SANDGEM_TOWN, + FIRST_ARRIVAL_FLOAROMA_TOWN, + FIRST_ARRIVAL_SOLACEON_TOWN, + FIRST_ARRIVAL_CELESTIC_TOWN, + FIRST_ARRIVAL_SURVIVAL_AREA, + FIRST_ARRIVAL_RESORT_AREA, + FIRST_ARRIVAL_JUBILIFE_CITY, + FIRST_ARRIVAL_CANALAVE_CITY, + FIRST_ARRIVAL_OREBURGH_CITY, + FIRST_ARRIVAL_ETERNA_CITY, + FIRST_ARRIVAL_HEARTHOME_CITY, + FIRST_ARRIVAL_PASTORIA_CITY, + FIRST_ARRIVAL_VEILSTONE_CITY, + FIRST_ARRIVAL_SUNYSHORE_CITY, + FIRST_ARRIVAL_SNOWPOINT_CITY, + FIRST_ARRIVAL_OUTSIDE_VICTORY_ROAD, + FIRST_ARRIVAL_FIGHT_AREA, }; static const u16 Unk_020F0074[] = { @@ -2524,7 +2525,7 @@ static int sub_0206EBE8(FieldSystem *fieldSystem) VarsFlags *v4 = SaveData_GetVarsFlags(fieldSystem->saveData); for (v2 = 0; v2 < NELEMS(Unk_020EFD3C); v2++) { - v0[v2] = inline_0208BE68(v4, Unk_020EFD3C[v2]); + v0[v2] = SystemFlag_HandleFirstArrivalToZone(v4, HANDLE_FLAG_CHECK, Unk_020EFD3C[v2]); } for (v2 = 0, v3 = 0; v2 < NELEMS(Unk_020F0074) / 2; v2++) { @@ -2565,7 +2566,7 @@ static int sub_0206EC90(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206ECFC(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - return inline_0208BE68(v0, 9); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_OREBURGH_CITY); } static BOOL sub_0206ED10(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) @@ -2736,13 +2737,13 @@ static int sub_0206EF7C(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr v0 = 0; - if (sub_0206A954(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(fieldSystem->saveData)) == 1) { v0 = (LCRNG_Next() % 8); - } else if (inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 11) == 1) { + } else if (SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_HEARTHOME_CITY) == TRUE) { v0 = (LCRNG_Next() % 5); - } else if (inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 10) == 1) { + } else if (SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_ETERNA_CITY) == TRUE) { v0 = (LCRNG_Next() % 4); - } else if (inline_0208BE68(SaveData_GetVarsFlags(fieldSystem->saveData), 18) == 1) { + } else if (SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_OREBURGH_MINE) == TRUE) { v0 = (LCRNG_Next() % 2); } diff --git a/src/unk_0206F314.c b/src/unk_0206F314.c index 2c008db6ae..6334e66a6a 100644 --- a/src/unk_0206F314.c +++ b/src/unk_0206F314.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0202E8C0_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/sprite_template.h" #include "struct_defs/struct_0200D0F4.h" #include "struct_defs/struct_0202EE10.h" @@ -18,6 +17,7 @@ #include "bg_window.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_task.h" #include "font.h" #include "game_options.h" #include "heap.h" @@ -35,7 +35,6 @@ #include "unk_02005474.h" #include "unk_0200C6E4.h" #include "unk_0202E840.h" -#include "unk_020508D4.h" typedef struct { MessageLoader *unk_00; @@ -841,10 +840,10 @@ static void sub_02070288(UnkStruct_0206F7F8 *param0) SpriteActor_EnableObject(param0->unk_2FC[1], 0); } -static BOOL sub_020702D0(TaskManager *param0) +static BOOL sub_020702D0(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0206F314 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0206F314 *v1 = FieldTask_GetEnv(param0); UnkStruct_0206F7F8 *v2 = v1->unk_08; switch (v1->unk_00) { @@ -903,14 +902,14 @@ static BOOL sub_020702D0(TaskManager *param0) return 0; } -void sub_020703FC(TaskManager *param0, u16 param1) +void sub_020703FC(FieldTask *param0, u16 param1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_0206F314 *v1 = Heap_AllocFromHeap(11, sizeof(UnkStruct_0206F314)); v1->unk_00 = 0; v1->unk_04 = param1; v1->unk_08 = NULL; - FieldTask_Start(fieldSystem->taskManager, sub_020702D0, v1); + FieldTask_InitCall(fieldSystem->task, sub_020702D0, v1); } diff --git a/src/unk_02070428.c b/src/unk_02070428.c index 3f880a6701..876057db5b 100644 --- a/src/unk_02070428.c +++ b/src/unk_02070428.c @@ -16,10 +16,10 @@ #include "map_header.h" #include "roaming_pokemon.h" #include "save_player.h" +#include "system_flags.h" #include "unk_0202D7A8.h" #include "unk_0203A7D8.h" #include "unk_020556C4.h" -#include "unk_0206A8DC.h" #include "unk_0206AFE0.h" #include "vars_flags.h" @@ -34,16 +34,16 @@ void sub_02070428(FieldSystem *fieldSystem, BOOL param1) void FieldSystem_InitFlagsOnMapChange(FieldSystem *fieldSystem) { sub_020705DC(fieldSystem); - sub_0206AF1C(SaveData_GetVarsFlags(fieldSystem->saveData), 0); + SystemFlag_HandleForceBikingInGate(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); - inline_0204E650_1(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_HandleStrengthActive(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); sub_0203A8E8(fieldSystem, fieldSystem->location->mapId); sub_0202D9EC(sub_0202D834(fieldSystem->saveData), 0); fieldSystem->unk_78.unk_00 = 0; - if (!sub_0206AE5C(SaveData_GetVarsFlags(fieldSystem->saveData))) { + if (!SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData))) { UnkStruct_0202D7B0 *v0; v0 = sub_0202D834(fieldSystem->saveData); @@ -62,10 +62,10 @@ void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem) sub_02070610(fieldSystem); } - sub_0206AF1C(SaveData_GetVarsFlags(fieldSystem->saveData), 0); - sub_0206AE9C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_HandleForceBikingInGate(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); + SystemFlag_CheckOnCyclingRoad(SaveData_GetVarsFlags(fieldSystem->saveData)); - inline_0204E650_1(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_HandleStrengthActive(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CLEAR); sub_0203A8E8(fieldSystem, fieldSystem->location->mapId); sub_0202D9EC(sub_0202D834(fieldSystem->saveData), 0); @@ -82,8 +82,8 @@ void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem) if (!MapHeader_IsCave(fieldSystem->location->mapId)) { VarsFlags *v1 = SaveData_GetVarsFlags(fieldSystem->saveData); - sub_0206AECC(v1); - sub_0206AEFC(v1); + SystemFlag_ClearFlashActive(v1); + SystemFlag_ClearDefogActive(v1); } { @@ -106,26 +106,26 @@ void FieldSystem_InitFlagsWarp(FieldSystem *fieldSystem) void sub_0207056C(FieldSystem *fieldSystem) { - sub_0206AE4C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_ClearSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); sub_0206C354(sub_0202D834(fieldSystem->saveData)); } void FieldSystem_SetTeleportFlags(FieldSystem *fieldSystem) { - sub_0206AE4C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_ClearSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); sub_0206C354(sub_0202D834(fieldSystem->saveData)); } void FieldSystem_SetEscapeFlags(FieldSystem *fieldSystem) { - sub_0206AE4C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_ClearSafariGameActive(SaveData_GetVarsFlags(fieldSystem->saveData)); } void sub_020705B4(FieldSystem *fieldSystem) { VarsFlags *v0 = SaveData_GetVarsFlags(fieldSystem->saveData); - sub_0206A974(v0); + SystemFlag_ClearHasPartner(v0); sub_0206B024(v0, 0); } diff --git a/src/unk_0207064C.c b/src/unk_0207064C.c index f7d2138782..d5e2da9c3a 100644 --- a/src/unk_0207064C.c +++ b/src/unk_0207064C.c @@ -3,19 +3,17 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay006/ov6_02243258.h" #include "field_map_change.h" +#include "field_task.h" #include "heap.h" #include "location.h" #include "player_avatar.h" #include "pokemon.h" #include "sys_task_manager.h" #include "unk_0203A7D8.h" -#include "unk_020508D4.h" typedef struct { FieldSystem *fieldSystem; @@ -42,10 +40,10 @@ void *sub_0207064C(u32 param0, FieldSystem *fieldSystem, Pokemon *param2, u16 pa return v0; } -BOOL sub_02070680(TaskManager *param0) +BOOL sub_02070680(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0207064C *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0207064C *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: diff --git a/src/unk_0207070C.c b/src/unk_0207070C.c index effce0785c..e26b34d04e 100644 --- a/src/unk_0207070C.c +++ b/src/unk_0207070C.c @@ -5,7 +5,6 @@ #include "constants/field/map_load.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_02061AB4_decl.h" #include "struct_defs/struct_0203D8AC.h" #include "struct_defs/struct_020708E0.h" @@ -22,6 +21,7 @@ #include "field_menu.h" #include "field_overworld_state.h" +#include "field_task.h" #include "heap.h" #include "inlines.h" #include "journal.h" @@ -30,14 +30,13 @@ #include "player_avatar.h" #include "save_player.h" #include "script_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0203C954.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" #include "unk_0205DAC8.h" #include "unk_0205F180.h" -#include "unk_0206A8DC.h" #include "unk_0206B70C.h" #include "unk_020711C8.h" #include "unk_02071B10.h" @@ -59,39 +58,39 @@ static int sub_02070950(const UnkStruct_02070950 *param0); static void sub_020709CC(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); static int sub_02070EEC(const UnkStruct_02070950 *param0); static void sub_02070F54(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070F94(TaskManager *taskMan); +static BOOL sub_02070F94(FieldTask *taskMan); static int sub_02070A24(const UnkStruct_02070950 *param0); static void sub_02070A80(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070AB4(TaskManager *taskMan); +static BOOL sub_02070AB4(FieldTask *taskMan); static int sub_02070CF8(const UnkStruct_02070950 *param0); static void sub_02070D30(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070D64(TaskManager *taskMan); +static BOOL sub_02070D64(FieldTask *taskMan); static int sub_02070DA0(const UnkStruct_02070950 *param0); static void sub_02070DEC(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070E20(TaskManager *taskMan); +static BOOL sub_02070E20(FieldTask *taskMan); static int sub_02070E5C(const UnkStruct_02070950 *param0); static void sub_02070E7C(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070EB0(TaskManager *taskMan); +static BOOL sub_02070EB0(FieldTask *taskMan); static int sub_02070B98(const UnkStruct_02070950 *param0); static void sub_02070BD0(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070C04(TaskManager *taskMan); +static BOOL sub_02070C04(FieldTask *taskMan); static int sub_02070C40(const UnkStruct_02070950 *param0); static void sub_02070C88(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070CBC(TaskManager *taskMan); +static BOOL sub_02070CBC(FieldTask *taskMan); static int sub_02070AF0(const UnkStruct_02070950 *param0); static void sub_02070B28(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070B5C(TaskManager *taskMan); +static BOOL sub_02070B5C(FieldTask *taskMan); static int sub_02070FCC(const UnkStruct_02070950 *param0); static void sub_02071010(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02071050(TaskManager *taskMan); +static BOOL sub_02071050(FieldTask *taskMan); static int sub_020710A4(const UnkStruct_02070950 *param0); static void sub_020710D4(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); static int sub_02071130(const UnkStruct_02070950 *param0); static void sub_02071150(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_0207118C(TaskManager *taskMan); +static BOOL sub_0207118C(FieldTask *taskMan); static int sub_020708AC(const UnkStruct_02070950 *param0); static void sub_020708E0(UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1); -static BOOL sub_02070914(TaskManager *taskMan); +static BOOL sub_02070914(FieldTask *taskMan); static const UnkStruct_020F0368 Unk_020F0368[] = { { sub_020708E0, sub_020708AC }, @@ -125,12 +124,12 @@ static inline BOOL inline_02070950(const UnkStruct_02070950 *param0, int param1) static inline BOOL inline_02070A24(const UnkStruct_02070950 *param0) { - return sub_0206A984(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); + return SystemFlag_CheckHasPartner(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); } static inline BOOL inline_02070EEC(const UnkStruct_02070950 *param0) { - if ((sub_0206AE5C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) || (sub_0206AE8C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1)) { + if ((SystemFlag_CheckSafariGameActive(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) || (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1)) { return 1; } @@ -139,7 +138,7 @@ static inline BOOL inline_02070EEC(const UnkStruct_02070950 *param0) static inline BOOL inline_020710A4(const UnkStruct_02070950 *param0) { - if (sub_0206AE8C(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) { + if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(param0->fieldSystem->saveData)) == 1) { return 1; } @@ -242,7 +241,7 @@ static void sub_02070838(FieldSystem *fieldSystem, UnkStruct_02070950 *param1) static UnkStruct_0207086C *sub_0207086C(const UnkStruct_020709CC *param0, const UnkStruct_02070950 *param1) { - UnkStruct_0207086C *v0 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0207086C)); + UnkStruct_0207086C *v0 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0207086C)); v0->unk_00 = 0x19740205; v0->unk_04 = param1->unk_08; @@ -279,20 +278,20 @@ static void sub_020708E0(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070914; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070914(TaskManager *taskMan) +static BOOL sub_02070914(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10008, v0->unk_04); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -331,8 +330,8 @@ static void sub_020709CC(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - menu = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); u32 *v2 = (u32 *)Heap_AllocFromHeap(11, 4); *v2 = param0->unk_04; @@ -375,20 +374,20 @@ static void sub_02070A80(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070AB4; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070AB4(TaskManager *taskMan) +static BOOL sub_02070AB4(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10012, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -419,20 +418,20 @@ static void sub_02070B28(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070B5C; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070B5C(TaskManager *param0) +static BOOL sub_02070B5C(FieldTask *param0) { - UnkStruct_0207086C *v0 = TaskManager_Environment(param0); - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); ScriptManager_Change(param0, 10010, v0->unk_04); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -463,20 +462,20 @@ static void sub_02070BD0(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070C04; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070C04(TaskManager *taskMan) +static BOOL sub_02070C04(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10014, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -511,20 +510,20 @@ static void sub_02070C88(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070CBC; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070CBC(TaskManager *taskMan) +static BOOL sub_02070CBC(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10009, v0->unk_04); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -555,20 +554,20 @@ static void sub_02070D30(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070D64; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070D64(TaskManager *param0) +static BOOL sub_02070D64(FieldTask *param0) { - UnkStruct_0207086C *v0 = TaskManager_Environment(param0); - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); ScriptManager_Change(param0, 10013, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -603,20 +602,20 @@ static void sub_02070DEC(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070E20; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070E20(TaskManager *taskMan) +static BOOL sub_02070E20(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10011, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -643,20 +642,20 @@ static void sub_02070E7C(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v1; - menu = TaskManager_Environment(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v1 = sub_0207086C(param0, param1); - sub_020509D4(param1->fieldSystem); + FieldSystem_StartFieldMap(param1->fieldSystem); menu->unk_22C = sub_02070EB0; menu->unk_25C = v1; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070EB0(TaskManager *taskMan) +static BOOL sub_02070EB0(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 10015, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); @@ -691,10 +690,10 @@ static void sub_02070F54(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldSystem *fieldSystem; FieldMenu *menu; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - menu = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); UnkStruct_020711C8 *v2; @@ -705,14 +704,14 @@ static void sub_02070F54(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_02070F94(TaskManager *param0) +static BOOL sub_02070F94(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020711C8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020711C8 *v1 = FieldTask_GetEnv(param0); void *v2 = ov6_02247530(fieldSystem, v1->unk_00, 4); Heap_FreeToHeap(v1); - FieldTask_Change(param0, ov6_02247554, v2); + FieldTask_InitJump(param0, ov6_02247554, v2); return 0; } @@ -739,10 +738,10 @@ static void sub_02071010(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldSystem *fieldSystem; FieldMenu *v1; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); { UnkStruct_020711C8 *v2; @@ -755,10 +754,10 @@ static void sub_02071010(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p } } -static BOOL sub_02071050(TaskManager *param0) +static BOOL sub_02071050(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020711C8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020711C8 *v1 = FieldTask_GetEnv(param0); void *v2 = ov6_02247488(fieldSystem, v1->unk_00, 11); { @@ -767,7 +766,7 @@ static BOOL sub_02071050(TaskManager *param0) } Heap_FreeToHeap(v1); - FieldTask_Change(param0, ov6_022474AC, v2); + FieldTask_InitJump(param0, ov6_022474AC, v2); return 0; } @@ -793,11 +792,11 @@ static void sub_020710D4(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p int v3; void *v4; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - v1 = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + v1 = FieldTask_GetEnv(param0->unk_00); v2 = sub_020711C8(11, param0->unk_04, fieldSystem->saveData); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); v1->unk_22C = ov5_021F101C; v1->unk_25C = v2; @@ -822,21 +821,21 @@ static void sub_02071150(UnkStruct_020709CC *param0, const UnkStruct_02070950 *p FieldMenu *menu; UnkStruct_0207086C *v2; - fieldSystem = TaskManager_FieldSystem(param0->unk_00); - menu = TaskManager_Environment(param0->unk_00); + fieldSystem = FieldTask_GetFieldSystem(param0->unk_00); + menu = FieldTask_GetEnv(param0->unk_00); v2 = sub_0207086C(param0, param1); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); menu->unk_22C = sub_0207118C; menu->unk_25C = v2; menu->state = FIELD_MENU_STATE_10; } -static BOOL sub_0207118C(TaskManager *taskMan) +static BOOL sub_0207118C(FieldTask *taskMan) { - UnkStruct_0207086C *v0 = TaskManager_Environment(taskMan); - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); + UnkStruct_0207086C *v0 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); ScriptManager_Change(taskMan, 8900, NULL); FieldSystem_SetScriptParameters(fieldSystem, v0->unk_08.unk_04, 0, 0, 0); diff --git a/src/unk_0207160C.c b/src/unk_0207160C.c index fa2dbd3555..4e4b6c2f53 100644 --- a/src/unk_0207160C.c +++ b/src/unk_0207160C.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_02027860_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" @@ -13,12 +12,12 @@ #include "overlay005/struct_ov5_021E1890_decl.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "player_avatar.h" #include "savedata_misc.h" #include "unk_02005474.h" #include "unk_02027F50.h" -#include "unk_020508D4.h" #include "unk_02054D00.h" typedef struct { @@ -43,8 +42,8 @@ typedef struct { int unk_0C; } UnkStruct_020718D8; -static BOOL sub_020718D8(TaskManager *taskMan); -static BOOL sub_020719D8(TaskManager *taskMan); +static BOOL sub_020718D8(FieldTask *taskMan); +static BOOL sub_020719D8(FieldTask *taskMan); static void sub_02071ACC(const int param0); static void sub_02071AEC(const int param0); @@ -306,21 +305,21 @@ void sub_0207183C(FieldSystem *fieldSystem) if (v1->unk_00 == 0) { v2->unk_04 = Unk_020F03F4[v1->unk_02].unk_00[1]; - FieldTask_Start(fieldSystem->taskManager, sub_020718D8, v2); + FieldTask_InitCall(fieldSystem->task, sub_020718D8, v2); v1->unk_00 = 1; } else { v2->unk_04 = Unk_020F03F4[v1->unk_02].unk_00[0]; - FieldTask_Start(fieldSystem->taskManager, sub_020719D8, v2); + FieldTask_InitCall(fieldSystem->task, sub_020719D8, v2); v1->unk_00 = 0; } } } -static BOOL sub_020718D8(TaskManager *taskMan) +static BOOL sub_020718D8(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_020718D8 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_020718D8 *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: @@ -377,11 +376,11 @@ static BOOL sub_020718D8(TaskManager *taskMan) return 0; } -static BOOL sub_020719D8(TaskManager *taskMan) +static BOOL sub_020719D8(FieldTask *taskMan) { UnkStruct_ov5_021E1890 *v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(taskMan); - UnkStruct_020718D8 *v2 = TaskManager_Environment(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + UnkStruct_020718D8 *v2 = FieldTask_GetEnv(taskMan); switch (v2->unk_00) { case 0: diff --git a/src/unk_02071D40.c b/src/unk_02071D40.c index 5191b6dd4b..2c9960c265 100644 --- a/src/unk_02071D40.c +++ b/src/unk_02071D40.c @@ -9,28 +9,27 @@ #include "struct_decls/struct_0202C834_decl.h" #include "struct_decls/struct_0202C844_decl.h" #include "struct_decls/struct_0203068C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02072014.h" #include "field/field_system.h" #include "charcode_util.h" #include "field_system.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "play_time.h" #include "save_player.h" #include "savedata.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_0202631C.h" #include "unk_0202854C.h" #include "unk_0202C7FC.h" #include "unk_0203061C.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_020559DC.h" #include "unk_0205B33C.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" typedef struct { @@ -43,7 +42,7 @@ static void sub_02072038(const u16 param0, const u8 param1, const u16 *param2, c static void sub_0207207C(const u8 param0, const PlayTime *playTime, const RTCDate *param2, const RTCDate *param3, const RTCTime *param4, const u8 param5, TrainerCard *param6); static void sub_02072120(const u32 param0, const u32 param1, const u32 param2, const u32 param3, const u8 *param4, TrainerCard *param5); static void sub_0207216C(TrainerInfo *param0, FieldSystem *fieldSystem, TrainerCard *param2); -static BOOL sub_02072230(TaskManager *param0); +static BOOL sub_02072230(FieldTask *param0); void sub_02071D40(const u8 param0, const u8 param1, const u8 param2, const u8 param3, FieldSystem *fieldSystem, TrainerCard *param5) { @@ -76,7 +75,7 @@ void sub_02071D40(const u8 param0, const u8 param1, const u8 param2, const u8 pa sub_02055BF4(fieldSystem, &v4, &v6); sub_02055C10(fieldSystem, &v5, &v6); - sub_0207207C(sub_0206A954(SaveData_GetVarsFlags(fieldSystem->saveData)), playTime, &v4, &v5, &v6, param1, param5); + sub_0207207C(SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(fieldSystem->saveData)), playTime, &v4, &v5, &v6, param1, param5); } { @@ -137,7 +136,7 @@ u8 sub_02071F28(FieldSystem *fieldSystem) v5 = sub_0203068C(v1); v0 = 0; - if (sub_0206A954(v3)) { + if (SystemFlag_CheckGameCompleted(v3)) { v0++; } @@ -149,7 +148,7 @@ u8 sub_02071F28(FieldSystem *fieldSystem) v0++; } - if (sub_0206AAA8(v3, 0) || sub_0206AAA8(v3, 1) || sub_0206AAA8(v3, 3) || sub_0206AAA8(v3, 4) || sub_0206AAA8(v3, 2)) { + if (SystemFlag_CheckContestMaster(v3, 0) || SystemFlag_CheckContestMaster(v3, 1) || SystemFlag_CheckContestMaster(v3, 3) || SystemFlag_CheckContestMaster(v3, 4) || SystemFlag_CheckContestMaster(v3, 2)) { v0++; } @@ -282,13 +281,13 @@ void sub_02072204(FieldSystem *fieldSystem) v0->unk_00 = 0; v0->unk_04 = (TrainerCard *)sub_0205C17C(fieldSystem->unk_7C); - FieldTask_Start(fieldSystem->taskManager, sub_02072230, v0); + FieldTask_InitCall(fieldSystem->task, sub_02072230, v0); } -static BOOL sub_02072230(TaskManager *param0) +static BOOL sub_02072230(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_02072204 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_02072204 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -304,7 +303,7 @@ static BOOL sub_02072230(TaskManager *param0) v1->unk_00 = 11; break; case 11: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { sub_0205C1F0(fieldSystem->unk_7C); Heap_FreeToHeap(v1); return 1; diff --git a/src/unk_020722AC.c b/src/unk_020722AC.c index 5cf0b63254..2d9384263d 100644 --- a/src/unk_020722AC.c +++ b/src/unk_020722AC.c @@ -2,7 +2,6 @@ #include #include "struct_decls/struct_02028430_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202818C.h" #include "struct_defs/struct_0206A844.h" @@ -18,6 +17,7 @@ #include "bg_window.h" #include "core_sys.h" #include "field_system.h" +#include "field_task.h" #include "font.h" #include "game_options.h" #include "heap.h" @@ -41,7 +41,6 @@ #include "unk_0200F174.h" #include "unk_02028124.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_0206A780.h" #include "unk_02097624.h" @@ -117,7 +116,7 @@ typedef struct { int unk_04; } UnkStruct_020736D8; -void sub_020736D8(TaskManager *param0); +void sub_020736D8(FieldTask *param0); void sub_020722AC(void *param0, int *param1); static void sub_02072334(UnkStruct_02072334 *param0); static void sub_02072364(SysTask *param0, void *param1); @@ -1163,11 +1162,11 @@ static int sub_02073480(UnkStruct_02072334 *param0) { switch (param0->unk_12) { case 0: - sub_020509D4(param0->fieldSystem); + FieldSystem_StartFieldMap(param0->fieldSystem); param0->unk_12++; break; case 1: - if (!sub_020509DC(param0->fieldSystem)) { + if (!FieldSystem_IsRunningFieldMap(param0->fieldSystem)) { break; } @@ -1227,7 +1226,7 @@ static int sub_02073524(UnkStruct_02072334 *param0, int param1) param0->unk_12++; break; case 1: - if (sub_020509B4(param0->fieldSystem)) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem)) { break; } @@ -1253,7 +1252,7 @@ static int sub_020735E8(UnkStruct_02072334 *param0) param0->unk_12++; break; case 1: - if (sub_020509B4(param0->fieldSystem)) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem)) { break; } @@ -1274,10 +1273,10 @@ static int sub_020735E8(UnkStruct_02072334 *param0) return 0; } -static BOOL sub_02073694(TaskManager *param0) +static BOOL sub_02073694(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020736D8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020736D8 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: @@ -1296,13 +1295,13 @@ static BOOL sub_02073694(TaskManager *param0) return 0; } -void sub_020736D8(TaskManager *param0) +void sub_020736D8(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); UnkStruct_020736D8 *v1 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_020736D8)); v1->unk_00 = 0; v1->unk_04 = 0; - FieldTask_Start(fieldSystem->taskManager, sub_02073694, v1); + FieldTask_InitCall(fieldSystem->task, sub_02073694, v1); } diff --git a/src/unk_0207DA28.c b/src/unk_0207DA28.c index 23e751ce8a..c66c037c6c 100644 --- a/src/unk_0207DA28.c +++ b/src/unk_0207DA28.c @@ -6,7 +6,6 @@ #include "consts/game_records.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0207DE04.h" #include "field/field_system.h" @@ -22,15 +21,15 @@ #include "overlay117/struct_ov117_02260440.h" #include "communication_system.h" +#include "encounter.h" #include "field_system.h" +#include "field_task.h" #include "game_overlay.h" #include "game_records.h" #include "heap.h" +#include "system_flags.h" #include "unk_02038FFC.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" -#include "unk_02050A74.h" -#include "unk_0206A8DC.h" #include "unk_02099550.h" #include "unk_02099604.h" #include "unk_0209BA18.h" @@ -53,7 +52,7 @@ typedef struct { } UnkStruct_0207DE40; void sub_02099570(void); -static BOOL sub_0207DA28(TaskManager *param0); +static BOOL sub_0207DA28(FieldTask *param0); static void sub_0207DE04(UnkStruct_0207DE40 *param0, FieldSystem *fieldSystem, u32 param2, u32 param3); static u32 sub_0207DE40(UnkStruct_0207DE40 *param0); static UnkStruct_ov115_02260440 *sub_0207DE90(FieldSystem *fieldSystem, u32 param1, u32 param2); @@ -85,11 +84,11 @@ static const u8 Unk_020F1B64[4] = { 0x4 }; -static BOOL sub_0207DA28(TaskManager *param0) +static BOOL sub_0207DA28(FieldTask *param0) { int v0; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0207DE40 *v2 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0207DE40 *v2 = FieldTask_GetEnv(param0); switch (v2->unk_04) { case 0: @@ -105,12 +104,12 @@ static BOOL sub_0207DA28(TaskManager *param0) } break; case 2: - sub_02050A38(param0, &Unk_020F1B98, v2->unk_00); + FieldTask_RunApplication(param0, &Unk_020F1B98, v2->unk_00); v2->unk_04++; break; case 3: if (sub_02039074(fieldSystem->saveData)) { - sub_0206AF5C(SaveData_GetVarsFlags(fieldSystem->saveData)); + SystemFlag_SetConnectedToWiFi(SaveData_GetVarsFlags(fieldSystem->saveData)); } switch (v2->unk_00->unk_04) { @@ -206,7 +205,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 13: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = sub_0207DE40(v2); } break; @@ -215,7 +214,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 15: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { Heap_FreeToHeap(v2->unk_10); v2->unk_04 = 2; } @@ -226,7 +225,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 17: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { Heap_FreeToHeap(v2->unk_10); v2->unk_04 = 2; } @@ -236,7 +235,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 19: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = sub_0207DE40(v2); } break; @@ -246,7 +245,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 21: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = 2; sub_0207DED8(v2->unk_10); } @@ -256,7 +255,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 23: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = sub_0207DE40(v2); } break; @@ -266,7 +265,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 25: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = 2; sub_0207DF2C(v2->unk_10); } @@ -276,7 +275,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 27: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = sub_0207DE40(v2); } break; @@ -286,7 +285,7 @@ static BOOL sub_0207DA28(TaskManager *param0) v2->unk_04++; break; case 29: - if (!sub_020509B4(fieldSystem)) { + if (!FieldSystem_IsRunningApplication(fieldSystem)) { v2->unk_04 = 2; sub_0207DF88(v2->unk_10); } @@ -308,22 +307,22 @@ static UnkStruct_0207DE40 *sub_0207DD94(void) return v0; } -void sub_0207DDC0(TaskManager *param0) +void sub_0207DDC0(FieldTask *param0) { UnkStruct_0207DE40 *v0 = sub_0207DD94(); v0->unk_00->unk_04 = 2; - FieldTask_Start(param0, sub_0207DA28, v0); + FieldTask_InitCall(param0, sub_0207DA28, v0); } -void sub_0207DDE0(TaskManager *param0, u16 *param1) +void sub_0207DDE0(FieldTask *param0, u16 *param1) { UnkStruct_0207DE40 *v0 = sub_0207DD94(); v0->unk_00->unk_04 = 1; v0->unk_08 = param1; - FieldTask_Start(param0, sub_0207DA28, v0); + FieldTask_InitCall(param0, sub_0207DA28, v0); } static void sub_0207DE04(UnkStruct_0207DE40 *param0, FieldSystem *fieldSystem, u32 param2, u32 param3) diff --git a/src/unk_0208BA78.c b/src/unk_0208BA78.c index 8501dec94e..d21f40807a 100644 --- a/src/unk_0208BA78.c +++ b/src/unk_0208BA78.c @@ -19,6 +19,7 @@ #include "journal.h" #include "overlay_manager.h" #include "savedata.h" +#include "system_flags.h" #include "unk_020041CC.h" #include "unk_0202F1D4.h" #include "unk_02051D8C.h" @@ -411,7 +412,7 @@ BOOL sub_0208BE68(UnkStruct_0208C06C *param0) VarsFlags *v0; v0 = SaveData_GetVarsFlags(param0->unk_830); - return inline_0208BE68(v0, 53); + return SystemFlag_HandleFirstArrivalToZone(v0, HANDLE_FLAG_CHECK, FIRST_ARRIVAL_BATTLE_PARK); } static BOOL sub_0208BE80(int param0) diff --git a/src/unk_020933F8.c b/src/unk_020933F8.c index e38993e2db..b57cb99ddd 100644 --- a/src/unk_020933F8.c +++ b/src/unk_020933F8.c @@ -4,13 +4,14 @@ #include #include "consts/game_records.h" +#include "consts/map.h" +#include "consts/pokemon.h" #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_0202440C_decl.h" #include "struct_decls/struct_02029C88_decl.h" #include "struct_decls/struct_02029D04_decl.h" #include "struct_decls/struct_0202A750_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_02093800.h" #include "struct_defs/struct_02093BBC.h" #include "struct_defs/struct_02094A58.h" @@ -29,6 +30,7 @@ #include "assert.h" #include "communication_information.h" #include "communication_system.h" +#include "field_task.h" #include "game_records.h" #include "heap.h" #include "journal.h" @@ -40,6 +42,7 @@ #include "string_template.h" #include "sys_task.h" #include "sys_task_manager.h" +#include "system_flags.h" #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200A9DC.h" @@ -49,9 +52,7 @@ #include "unk_0202CC64.h" #include "unk_0202F108.h" #include "unk_020363E8.h" -#include "unk_020508D4.h" #include "unk_02055808.h" -#include "unk_0206A8DC.h" #include "unk_0206CCB0.h" #include "unk_020923C0.h" #include "unk_02094EDC.h" @@ -84,8 +85,8 @@ void sub_02093AD4(UnkStruct_02095C48 *param0); void sub_02094630(UnkStruct_02095C48 *param0, int param1, StringTemplate *param2, u32 param3); void sub_02094648(UnkStruct_02095C48 *param0, int param1, StringTemplate *param2, u32 param3); void sub_02094680(UnkStruct_02095C48 *param0, int param1, StringTemplate *param2, u32 param3); -static BOOL sub_02093448(TaskManager *param0); -static BOOL sub_020935EC(TaskManager *param0); +static BOOL sub_02093448(FieldTask *param0); +static BOOL sub_020935EC(FieldTask *param0); void sub_02093BBC(UnkStruct_02095C48 *param0); void sub_02093C54(UnkStruct_02095C48 *param0); static void sub_020944E8(UnkStruct_02095C48 *param0); @@ -150,7 +151,7 @@ __attribute__((aligned(4))) static const u8 Unk_020F55D0[][6] = { { 0xF, 0xF, 0x8, 0x8, 0x14, 0xFF } }; -void sub_020933F8(TaskManager *param0, UnkStruct_02095C48 *param1) +void sub_020933F8(FieldTask *param0, UnkStruct_02095C48 *param1) { UnkStruct_020933F8 *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_020933F8)); @@ -161,18 +162,18 @@ void sub_020933F8(TaskManager *param0, UnkStruct_02095C48 *param1) case 0: case 1: case 2: - FieldTask_Start(param0, sub_02093448, v0); + FieldTask_InitCall(param0, sub_02093448, v0); break; default: - FieldTask_Start(param0, sub_020935EC, v0); + FieldTask_InitCall(param0, sub_020935EC, v0); break; } } -static BOOL sub_02093448(TaskManager *param0) +static BOOL sub_02093448(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020933F8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020933F8 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: @@ -202,7 +203,7 @@ static BOOL sub_02093448(TaskManager *param0) break; case 4: sub_02093BBC(v1->unk_00); - sub_02050A38(param0, &Unk_020F55FC, v1->unk_00->unk_199C); + FieldTask_RunApplication(param0, &Unk_020F55FC, v1->unk_00->unk_199C); v1->unk_04++; break; case 5: @@ -221,25 +222,25 @@ static BOOL sub_02093448(TaskManager *param0) } break; case 7: - sub_02050A38(param0, &Unk_020F55EC, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F55EC, v1->unk_00); v1->unk_04++; break; case 8: if ((v1->unk_00->unk_00.unk_111 == 1) || (v1->unk_00->unk_00.unk_111 == 2)) { - sub_02050A38(param0, &Unk_020F561C, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F561C, v1->unk_00); } v1->unk_04++; break; case 9: if ((v1->unk_00->unk_00.unk_111 == 0) || (v1->unk_00->unk_00.unk_111 == 2)) { - sub_02050A38(param0, &Unk_020F560C, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F560C, v1->unk_00); } v1->unk_04++; break; case 10: - sub_02050A38(param0, &Unk_020F55DC, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F55DC, v1->unk_00); v1->unk_04++; break; case 11: @@ -259,10 +260,10 @@ static BOOL sub_02093448(TaskManager *param0) return 0; } -static BOOL sub_020935EC(TaskManager *param0) +static BOOL sub_020935EC(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_020933F8 *v1 = TaskManager_Environment(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_020933F8 *v1 = FieldTask_GetEnv(param0); switch (v1->unk_04) { case 0: @@ -274,7 +275,7 @@ static BOOL sub_020935EC(TaskManager *param0) case 3: case 4: sub_02093BBC(v1->unk_00); - sub_02050A38(param0, &Unk_020F55FC, v1->unk_00->unk_199C); + FieldTask_RunApplication(param0, &Unk_020F55FC, v1->unk_00->unk_199C); break; } @@ -297,7 +298,7 @@ static BOOL sub_020935EC(TaskManager *param0) switch (v1->unk_00->unk_00.unk_111) { case 3: case 4: - sub_02050A38(param0, &Unk_020F55EC, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F55EC, v1->unk_00); break; } @@ -308,7 +309,7 @@ static BOOL sub_020935EC(TaskManager *param0) case 5: case 6: sub_02095338(v1->unk_00); - sub_02050A38(param0, &Unk_020F561C, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F561C, v1->unk_00); break; } @@ -318,7 +319,7 @@ static BOOL sub_020935EC(TaskManager *param0) switch (v1->unk_00->unk_00.unk_111) { case 7: case 8: - sub_02050A38(param0, &Unk_020F560C, v1->unk_00); + FieldTask_RunApplication(param0, &Unk_020F560C, v1->unk_00); break; } @@ -1595,8 +1596,8 @@ void sub_02094C44(UnkStruct_02095C48 *param0, SaveData *param1, u32 param2, Jour v1 = SaveData_GetVarsFlags(param0->unk_1970); if ((param0->unk_00.unk_111 == 2) && (param0->unk_00.unk_110 >= 3) && (sub_02094790(param0) == 0)) { - if (sub_0206AAA8(v1, param0->unk_00.unk_10F) == 0) { - sub_0206AA50(v1, param0->unk_00.unk_10F); + if (SystemFlag_CheckContestMaster(v1, param0->unk_00.unk_10F) == 0) { + SystemFlag_SetContestMaster(v1, param0->unk_00.unk_10F); } } } diff --git a/src/unk_0209747C.c b/src/unk_0209747C.c index e1d3be8647..0b4d0df9db 100644 --- a/src/unk_0209747C.c +++ b/src/unk_0209747C.c @@ -12,10 +12,10 @@ #include "heap.h" #include "save_player.h" #include "savedata.h" +#include "system_flags.h" #include "unk_02014A84.h" #include "unk_02014D38.h" #include "unk_0202631C.h" -#include "unk_0206A8DC.h" #include "vars_flags.h" struct UnkStruct_0209747C_t { @@ -41,7 +41,7 @@ UnkStruct_0209747C *sub_0209747C(u32 param0, u32 param1, SaveData *param2, u32 p v0->unk_01 = param1; v0->unk_0C = SaveData_Pokedex(param2); v0->unk_10 = sub_02014EC4(param2); - v0->unk_04 = sub_0206A954(SaveData_GetVarsFlags(param2)); + v0->unk_04 = SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(param2)); v0->unk_05 = 0; v0->unk_02 = 1; v0->unk_03 = 0; diff --git a/src/unk_02097B18.c b/src/unk_02097B18.c index e40821d04c..63b3643117 100644 --- a/src/unk_02097B18.c +++ b/src/unk_02097B18.c @@ -4,7 +4,6 @@ #include #include "struct_decls/struct_0202440C_decl.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0202CA28.h" #include "struct_defs/struct_0202CA64.h" #include "struct_defs/struct_02097F18.h" @@ -19,6 +18,7 @@ #include "bag.h" #include "bg_window.h" +#include "field_task.h" #include "game_options.h" #include "game_overlay.h" #include "gx_layers.h" @@ -41,7 +41,6 @@ #include "unk_02024220.h" #include "unk_02028124.h" #include "unk_0202C9F4.h" -#include "unk_020508D4.h" #include "unk_02055808.h" #include "unk_0206CCB0.h" @@ -309,11 +308,11 @@ void sub_02097F30(UnkStruct_02097F18 *param0, u8 param1) param0->unk_2D = param1; } -static BOOL sub_02097F38(TaskManager *param0) +static BOOL sub_02097F38(FieldTask *param0) { - UnkStruct_02097F38 *v0 = TaskManager_Environment(param0); + UnkStruct_02097F38 *v0 = FieldTask_GetEnv(param0); UnkStruct_02097F18 *v1 = v0->unk_08; - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); switch (v0->unk_14) { case 0: @@ -341,7 +340,7 @@ static BOOL sub_02097F38(TaskManager *param0) v0->unk_14 = 1; break; case 1: - sub_02050A38(param0, &Unk_020F64C0, v1); + FieldTask_RunApplication(param0, &Unk_020F64C0, v1); v0->unk_14 = 2; break; case 2: { @@ -372,7 +371,7 @@ static BOOL sub_02097F38(TaskManager *param0) v6->unk_20 = 15; v6->unk_0C = v1->unk_24; - sub_02050A38(param0, &Unk_020F1E88, v6); + FieldTask_RunApplication(param0, &Unk_020F1E88, v6); v0->unk_14 = 4; } break; case 4: { @@ -417,7 +416,7 @@ static BOOL sub_02097F38(TaskManager *param0) return 0; } -void sub_020980DC(TaskManager *param0, SaveData *param1) +void sub_020980DC(FieldTask *param0, SaveData *param1) { UnkStruct_02097F38 *v0 = Heap_AllocFromHeapAtEnd(11, sizeof(UnkStruct_02097F38)); @@ -430,7 +429,7 @@ void sub_020980DC(TaskManager *param0, SaveData *param1) v0->unk_0C = Heap_AllocFromHeap(11, sizeof(PartyManagementData)); memset(v0->unk_0C, 0, sizeof(PartyManagementData)); - FieldTask_Start(param0, sub_02097F38, v0); + FieldTask_InitCall(param0, sub_02097F38, v0); } typedef struct { diff --git a/src/unk_02098218.c b/src/unk_02098218.c index 03f1624907..5a91cafa35 100644 --- a/src/unk_02098218.c +++ b/src/unk_02098218.c @@ -6,7 +6,6 @@ #include "consts/game_records.h" #include "consts/species.h" -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_0203E2FC.h" #include "struct_defs/struct_0209843C.h" @@ -18,6 +17,7 @@ #include "bg_window.h" #include "field_system.h" +#include "field_task.h" #include "game_options.h" #include "game_records.h" #include "gx_layers.h" @@ -37,7 +37,6 @@ #include "unk_0201DBEC.h" #include "unk_02024220.h" #include "unk_0202F180.h" -#include "unk_020508D4.h" #include "unk_02055808.h" #include "unk_0208694C.h" #include "unk_02092494.h" @@ -195,9 +194,9 @@ static int sub_02098388(OverlayManager *param0, int *param1) return 1; } -static BOOL sub_0209843C(TaskManager *param0) +static BOOL sub_0209843C(FieldTask *param0) { - UnkStruct_0209843C *v0 = TaskManager_Environment(param0); + UnkStruct_0209843C *v0 = FieldTask_GetEnv(param0); switch (v0->unk_00) { case 0: @@ -206,11 +205,11 @@ static BOOL sub_0209843C(TaskManager *param0) v0->unk_00++; break; case 1: - sub_02050A38(param0, &Unk_020F67FC, v0); + FieldTask_RunApplication(param0, &Unk_020F67FC, v0); v0->unk_00++; break; case 2: { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); { Pokemon *v2 = v0->unk_0C.unk_00; @@ -236,7 +235,7 @@ static BOOL sub_0209843C(TaskManager *param0) } } break; case 3: { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); int v9; v9 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_SPECIES, 0); @@ -244,7 +243,7 @@ static BOOL sub_0209843C(TaskManager *param0) v0->unk_08 = sub_0208712C(11, 1, v9, 10, SaveData_Options(FieldSystem_GetSaveData(fieldSystem))); v0->unk_08->unk_10 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_GENDER, NULL); v0->unk_08->unk_08 = Pokemon_GetValue(v0->unk_0C.unk_00, MON_DATA_FORM, NULL); - sub_02050A38(param0, &Unk_020F2DAC, v0->unk_08); + FieldTask_RunApplication(param0, &Unk_020F2DAC, v0->unk_08); v0->unk_00++; } break; case 4: @@ -252,7 +251,7 @@ static BOOL sub_0209843C(TaskManager *param0) Pokemon_SetValue(v0->unk_0C.unk_00, MON_DATA_NICKNAME_STRBUF_AND_FLAG, v0->unk_08->unk_18); { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); GameRecords *v11 = SaveData_GetGameRecordsPtr(FieldSystem_GetSaveData(fieldSystem)); GameRecords_IncrementRecordValue(v11, RECORD_UNK_049); @@ -274,7 +273,7 @@ static BOOL sub_0209843C(TaskManager *param0) return 0; } -void sub_020985AC(TaskManager *param0, void *param1) +void sub_020985AC(FieldTask *param0, void *param1) { UnkStruct_0209843C *v0; UnkStruct_0203E2FC *v1; @@ -285,5 +284,5 @@ void sub_020985AC(TaskManager *param0, void *param1) v1 = (UnkStruct_0203E2FC *)param1; v0->unk_0C = *v1; - FieldTask_Start(param0, sub_0209843C, v0); + FieldTask_InitCall(param0, sub_0209843C, v0); } diff --git a/src/unk_020985E4.c b/src/unk_020985E4.c index ea069de5c6..ebfff1f92c 100644 --- a/src/unk_020985E4.c +++ b/src/unk_020985E4.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_defs/struct_020985E4.h" #include "struct_defs/struct_0209862C.h" @@ -12,16 +11,16 @@ #include "overlay100/ov100_021D0D80.h" #include "field_system.h" +#include "field_task.h" #include "heap.h" #include "save_player.h" #include "savedata.h" #include "trainer_info.h" #include "unk_0200F174.h" -#include "unk_020508D4.h" FS_EXTERN_OVERLAY(overlay100); -void sub_020985E4(TaskManager *param0, SaveData *param1) +void sub_020985E4(FieldTask *param0, SaveData *param1) { UnkStruct_0209862C *v0; UnkStruct_020985E4 *v1; @@ -36,16 +35,16 @@ void sub_020985E4(TaskManager *param0, SaveData *param1) v0->unk_00 = 0; v0->unk_04 = v1; - FieldTask_Start(param0, sub_0209862C, v0); + FieldTask_InitCall(param0, sub_0209862C, v0); } -BOOL sub_0209862C(TaskManager *param0) +BOOL sub_0209862C(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_0209862C *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); switch (v1->unk_00) { case 0: @@ -69,13 +68,13 @@ BOOL sub_0209862C(TaskManager *param0) } break; case 2: - if (sub_020509B4(fieldSystem) == 0) { - sub_020509D4(fieldSystem); + if (FieldSystem_IsRunningApplication(fieldSystem) == 0) { + FieldSystem_StartFieldMap(fieldSystem); v1->unk_00++; } break; case 3: - if (sub_020509DC(fieldSystem) == 0) { + if (FieldSystem_IsRunningFieldMap(fieldSystem) == 0) { v1->unk_00++; } break; diff --git a/src/unk_0209AC14.c b/src/unk_0209AC14.c index ff88d50ed8..d3a939bc78 100644 --- a/src/unk_0209AC14.c +++ b/src/unk_0209AC14.c @@ -3,27 +3,25 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" - #include "field/field_system.h" #include "overlay005/fieldmap.h" #include "overlay007/ov7_0224CD28.h" #include "overlay007/struct_ov7_0224D008.h" +#include "field_task.h" #include "heap.h" -#include "unk_020508D4.h" #include "unk_0207CB08.h" static u8 sub_0209AC50(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param1); -static void sub_0209AC80(TaskManager *param0); +static void sub_0209AC80(FieldTask *param0); -BOOL sub_0209AC14(TaskManager *param0) +BOOL sub_0209AC14(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_ov7_0224D008 *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); switch (v1->unk_297) { case 16: @@ -39,29 +37,29 @@ BOOL sub_0209AC14(TaskManager *param0) static u8 sub_0209AC50(FieldSystem *fieldSystem, UnkStruct_ov7_0224D008 *param1) { - if (sub_020509B4(fieldSystem)) { + if (FieldSystem_IsRunningApplication(fieldSystem)) { return 16; } param1->unk_2A8 = sub_0207CBAC(param1->unk_04); Heap_FreeToHeap(param1->unk_04); - sub_020509D4(fieldSystem); + FieldSystem_StartFieldMap(fieldSystem); return 17; } -static void sub_0209AC80(TaskManager *param0) +static void sub_0209AC80(FieldTask *param0) { FieldSystem *fieldSystem; UnkStruct_ov7_0224D008 *v1; - fieldSystem = TaskManager_FieldSystem(param0); - v1 = TaskManager_Environment(param0); + fieldSystem = FieldTask_GetFieldSystem(param0); + v1 = FieldTask_GetEnv(param0); - if (sub_020509DC(fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(fieldSystem)) { ov5_021D1744(1); - FieldTask_Change(param0, ov7_0224CEAC, v1); + FieldTask_InitJump(param0, ov7_0224CEAC, v1); v1->unk_297 = 18; } } diff --git a/src/unk_0209ACF4.c b/src/unk_0209ACF4.c index c4402c05ce..a84006e7c7 100644 --- a/src/unk_0209ACF4.c +++ b/src/unk_0209ACF4.c @@ -3,7 +3,6 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0209747C_decl.h" #include "struct_defs/sentence.h" @@ -13,6 +12,7 @@ #include "bg_window.h" #include "colored_arrow.h" #include "core_sys.h" +#include "field_task.h" #include "heap.h" #include "message.h" #include "render_window.h" @@ -25,7 +25,6 @@ #include "unk_02014A84.h" #include "unk_0202D05C.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_0205D8CC.h" #include "unk_0209747C.h" @@ -51,7 +50,7 @@ typedef struct { static void sub_0209AD84(UnkStruct_0209AD84 *param0); static void sub_0209ADBC(UnkStruct_0209AD84 *param0); -static BOOL sub_0209AE14(TaskManager *param0); +static BOOL sub_0209AE14(FieldTask *param0); static void sub_0209B084(UnkStruct_0209AD84 *param0, int param1, BOOL param2); static BOOL sub_0209B100(UnkStruct_0209AD84 *param0); static void sub_0209B110(UnkStruct_0209AD84 *param0); @@ -61,10 +60,10 @@ static void sub_0209B1D8(UnkStruct_0209AD84 *param0); static void sub_0209B27C(UnkStruct_0209AD84 *param0); static int sub_0209B288(UnkStruct_0209AD84 *param0); -void sub_0209ACF4(TaskManager *param0) +void sub_0209ACF4(FieldTask *param0) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0209AD84 *v1 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0209AD84)); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0209AD84 *v1 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0209AD84)); v1->fieldSystem = fieldSystem; v1->unk_04 = Strbuf_Init(400, 32); @@ -81,7 +80,7 @@ void sub_0209ACF4(TaskManager *param0) v1->unk_54 = 0; - FieldTask_Start(param0, sub_0209AE14, v1); + FieldTask_InitCall(param0, sub_0209AE14, v1); } static void sub_0209AD84(UnkStruct_0209AD84 *param0) @@ -114,9 +113,9 @@ static void sub_0209ADBC(UnkStruct_0209AD84 *param0) } } -static BOOL sub_0209AE14(TaskManager *param0) +static BOOL sub_0209AE14(FieldTask *param0) { - UnkStruct_0209AD84 *v0 = TaskManager_Environment(param0); + UnkStruct_0209AD84 *v0 = FieldTask_GetEnv(param0); switch (v0->unk_54) { case 0: @@ -178,13 +177,13 @@ static BOOL sub_0209AE14(TaskManager *param0) } break; case 6: - if (sub_020509B4(v0->fieldSystem) == 0) { - sub_020509D4(v0->fieldSystem); + if (FieldSystem_IsRunningApplication(v0->fieldSystem) == 0) { + FieldSystem_StartFieldMap(v0->fieldSystem); v0->unk_54 = 7; } break; case 7: - if (sub_020509DC(v0->fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(v0->fieldSystem)) { ov5_021D1744(1); v0->unk_54 = 8; } diff --git a/src/unk_0209B344.c b/src/unk_0209B344.c index 6445c247dc..0ed768e89b 100644 --- a/src/unk_0209B344.c +++ b/src/unk_0209B344.c @@ -3,20 +3,19 @@ #include #include -#include "struct_decls/struct_020508D4_decl.h" #include "struct_decls/struct_0209747C_decl.h" #include "struct_defs/sentence.h" #include "field/field_system.h" #include "overlay005/fieldmap.h" +#include "field_task.h" #include "heap.h" #include "savedata_misc.h" #include "string_template.h" #include "unk_0200F174.h" #include "unk_02014A84.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_0209747C.h" typedef struct { @@ -31,12 +30,12 @@ typedef struct { } UnkStruct_0209B3AC; static void sub_0209B3AC(UnkStruct_0209B3AC *param0); -static BOOL sub_0209B3C4(TaskManager *param0); +static BOOL sub_0209B3C4(FieldTask *param0); -void sub_0209B344(TaskManager *param0, u16 *param1) +void sub_0209B344(FieldTask *param0, u16 *param1) { - FieldSystem *fieldSystem = TaskManager_FieldSystem(param0); - UnkStruct_0209B3AC *v1 = Heap_AllocFromHeap(32, sizeof(UnkStruct_0209B3AC)); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + UnkStruct_0209B3AC *v1 = Heap_AllocFromHeap(HEAP_ID_FIELD_TASK, sizeof(UnkStruct_0209B3AC)); v1->fieldSystem = fieldSystem; v1->unk_04 = StringTemplate_Default(32); @@ -49,7 +48,7 @@ void sub_0209B344(TaskManager *param0, u16 *param1) sub_02097520(v1->unk_10); v1->unk_18 = 0; - FieldTask_Start(param0, sub_0209B3C4, v1); + FieldTask_InitCall(param0, sub_0209B3C4, v1); return; } @@ -61,9 +60,9 @@ static void sub_0209B3AC(UnkStruct_0209B3AC *param0) Heap_FreeToHeap(param0); } -static BOOL sub_0209B3C4(TaskManager *param0) +static BOOL sub_0209B3C4(FieldTask *param0) { - UnkStruct_0209B3AC *v0 = TaskManager_Environment(param0); + UnkStruct_0209B3AC *v0 = FieldTask_GetEnv(param0); switch (v0->unk_18) { case 0: @@ -73,13 +72,13 @@ static BOOL sub_0209B3C4(TaskManager *param0) v0->unk_18 = 1; break; case 1: - if (sub_020509B4(v0->fieldSystem) == 0) { - sub_020509D4(v0->fieldSystem); + if (FieldSystem_IsRunningApplication(v0->fieldSystem) == 0) { + FieldSystem_StartFieldMap(v0->fieldSystem); v0->unk_18 = 2; } break; case 2: - if (sub_020509DC(v0->fieldSystem)) { + if (FieldSystem_IsRunningFieldMap(v0->fieldSystem)) { ov5_021D1744(1); v0->unk_18 = 3; } diff --git a/src/unk_0209C194.c b/src/unk_0209C194.c index 7b037aa474..0e8a5a22ae 100644 --- a/src/unk_0209C194.c +++ b/src/unk_0209C194.c @@ -13,6 +13,7 @@ #include "overlay109/ov109_021D3D50.h" #include "field_system.h" +#include "field_task.h" #include "game_options.h" #include "game_records.h" #include "heap.h" @@ -20,7 +21,6 @@ #include "save_player.h" #include "unk_020366A0.h" #include "unk_0203D1B8.h" -#include "unk_020508D4.h" #include "unk_0209BDF8.h" FS_EXTERN_OVERLAY(overlay109); @@ -104,7 +104,7 @@ static BOOL sub_0209C25C(UnkStruct_0209C1EC *param0) static BOOL sub_0209C280(UnkStruct_0209C1EC *param0) { - if (sub_020509B4(param0->fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem) == 0) { if (sub_0209C1E8(param0->unk_28) == 0) { param0->unk_00 = 5; } else { @@ -121,7 +121,7 @@ static BOOL sub_0209C280(UnkStruct_0209C1EC *param0) static BOOL sub_0209C2C0(UnkStruct_0209C1EC *param0) { - if (sub_020509B4(param0->fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem) == 0) { int v0 = param0->unk_30->unk_22; Heap_FreeToHeap(param0->unk_30); @@ -145,7 +145,7 @@ static BOOL sub_0209C2C0(UnkStruct_0209C1EC *param0) static BOOL sub_0209C324(UnkStruct_0209C1EC *param0) { - if (sub_020509B4(param0->fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem) == 0) { Heap_FreeToHeap(param0->unk_34); param0->unk_30 = sub_0203D644(param0->fieldSystem, param0->unk_04); param0->unk_00 = 2; @@ -156,7 +156,7 @@ static BOOL sub_0209C324(UnkStruct_0209C1EC *param0) static BOOL sub_0209C34C(UnkStruct_0209C1EC *param0) { - if (sub_020509B4(param0->fieldSystem) == 0) { + if (FieldSystem_IsRunningApplication(param0->fieldSystem) == 0) { param0->unk_00 = 5; }