diff --git a/include/constants/field_poison.h b/include/constants/field_poison.h new file mode 100644 index 0000000000..e2886ded58 --- /dev/null +++ b/include/constants/field_poison.h @@ -0,0 +1,8 @@ +#ifndef POKEPLATINUM_CONSTANTS_FIELD_POISON_H +#define POKEPLATINUM_CONSTANTS_FIELD_POISON_H + +#define FLDPSN_NONE 0 +#define FLDPSN_POISONED 1 +#define FLDPSN_FAINTED 2 + +#endif // POKEPLATINUM_CONSTANTS_FIELD_POISON_H diff --git a/include/field_map_change.h b/include/field_map_change.h index ea199b9685..314bab79b0 100644 --- a/include/field_map_change.h +++ b/include/field_map_change.h @@ -13,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(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 FieldSystem_StartChangeMapTask(FieldTask *task, const Location *param1); +void FieldTask_ChangeMapByLocation(FieldTask *task, const Location *param1); +void FieldTask_ChangeMapToLocation(FieldTask *task, int param1, int param2, int param3, int param4, int param5); +void FieldTask_StartMapChangeFull(FieldTask *task, 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(FieldTask *param0, int param1, int param2, int param3, int param4, int param5); -void FieldTask_ChangeMapChangeByDig(FieldTask *param0, const Location *param1, u32 param2); +void FieldTask_ChangeMapChangeFly(FieldTask *task, int param1, int param2, int param3, int param4, int param5); +void FieldTask_ChangeMapChangeByDig(FieldTask *task, const Location *location, u32 param2); void FieldSystem_StartMapChangeWarpTask(FieldSystem *fieldSystem, int param1, int param2); void *sub_02053FAC(FieldSystem *fieldSystem); void FieldTask_SetUndergroundMapChange(FieldSystem *fieldSystem); -BOOL FieldTask_MapChangeToUnderground(FieldTask *param0); -BOOL sub_0205430C(FieldTask *param0); +BOOL FieldTask_MapChangeToUnderground(FieldTask *task); +BOOL sub_0205430C(FieldTask *task); FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fieldSystem); -void sub_020544F0(FieldTask *param0, const Location *param1); +void sub_020544F0(FieldTask *task, const Location *param1); void sub_020545EC(FieldSystem *fieldSystem); -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); +void sub_02054708(FieldTask *task); +void sub_02054800(FieldTask *task, int param1, int param2, int param3, int param4, int param5); +void sub_02054864(FieldTask *task); #endif // POKEPLATINUM_FIELD_MAP_CHANGE_H diff --git a/include/field_overworld_state.h b/include/field_overworld_state.h index 1697751b56..c9844d0d23 100644 --- a/include/field_overworld_state.h +++ b/include/field_overworld_state.h @@ -13,28 +13,28 @@ int FieldOverworldState_Size(void); int FieldOverworldSave_Size(void); -void FieldOverworldSave_Init(FieldOverworldSave *param0); -void FieldOverworldState_Init(FieldOverworldState *param0); -Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *param0); -Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *param0); -Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *param0); -Location *sub_0203A72C(FieldOverworldState *param0); -Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *param0); -void FieldOverworldState_SetSpecialLocation(FieldOverworldState *param0, Location *param1); -u16 *sub_0203A748(FieldOverworldState *param0); -u16 FieldOverworldState_GetWeather(const FieldOverworldState *param0); -void FieldOverworldState_SetWeather(FieldOverworldState *param0, u16 param1); -u16 FieldOverworldState_GetWarpId(const FieldOverworldState *param0); -void FieldOverworldState_SetWarpId(FieldOverworldState *param0, u16 param1); -UnkStruct_020556C4 *sub_0203A76C(FieldOverworldState *param0); -int FieldOverworldState_GetCameraType(const FieldOverworldState *param0); -void FieldOverworldState_SetCameraType(FieldOverworldState *param0, int param1); -PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *param0); -u16 *sub_0203A784(FieldOverworldState *param0); -u16 *sub_0203A788(FieldOverworldState *param0); -u16 *sub_0203A78C(FieldOverworldState *param0); -FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *param0); -FieldOverworldSave *SaveData_GetFieldOverworldSave(SaveData *param0); +void FieldOverworldSave_Init(FieldOverworldSave *fieldSave); +void FieldOverworldState_Init(FieldOverworldState *fieldState); +Location *FieldOverworldState_GetPlayerLocation(FieldOverworldState *fieldState); +Location *FieldOverworldState_GetEntranceLocation(FieldOverworldState *fieldState); +Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *fieldState); +Location *FieldOverworldState_GetExitLocation(FieldOverworldState *fieldState); +Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *fieldState); +void FieldOverworldState_SetSpecialLocation(FieldOverworldState *fieldState, Location *location); +u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *fieldState); +u16 FieldOverworldState_GetWeather(const FieldOverworldState *fieldState); +void FieldOverworldState_SetWeather(FieldOverworldState *fieldState, u16 weather); +u16 FieldOverworldState_GetWarpId(const FieldOverworldState *fieldState); +void FieldOverworldState_SetWarpId(FieldOverworldState *fieldState, u16 warpId); +UnkStruct_020556C4 *sub_0203A76C(FieldOverworldState *fieldState); +int FieldOverworldState_GetCameraType(const FieldOverworldState *fieldState); +void FieldOverworldState_SetCameraType(FieldOverworldState *fieldState, int type); +PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *fieldState); +u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *fieldState); +u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *fieldState); +u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *fieldState); +FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *saveData); +FieldOverworldSave *SaveData_GetFieldOverworldSave(SaveData *saveData); void FieldSystem_SaveObjects(FieldSystem *fieldSystem); void FieldSystem_LoadObjects(FieldSystem *fieldSystem); diff --git a/include/inlines.h b/include/inlines.h index 3188ba65fd..d0955cca87 100644 --- a/include/inlines.h +++ b/include/inlines.h @@ -129,8 +129,8 @@ static inline void inline_ov61_0222C3B0_sub(SysTask *param0, void *param1) static inline void inline_ov47_0225621C_sub(FieldSystem *fieldSystem, int *param1, int *param2) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - Location *location = sub_0203A72C(v0); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); + Location *location = FieldOverworldState_GetExitLocation(fieldState); if (MapHeader_IsOnMainMatrix(fieldSystem->location->mapId)) { *param1 = fieldSystem->location->x; diff --git a/include/overlay005/ov5_021EF4BC.h b/include/overlay005/ov5_021EF4BC.h index 374b2c6c1d..13f32c4302 100644 --- a/include/overlay005/ov5_021EF4BC.h +++ b/include/overlay005/ov5_021EF4BC.h @@ -7,6 +7,6 @@ UnkStruct_ov5_021EF4F8 *ov5_021EF4BC(u32 param0, HBlankSystem *param1); void ov5_021EF4F8(UnkStruct_ov5_021EF4F8 *param0); -void ov5_021EF518(UnkStruct_ov5_021EF4F8 *param0); +void Field_DoPoisonEffect(UnkStruct_ov5_021EF4F8 *param0); #endif // POKEPLATINUM_OV5_021EF4BC_H diff --git a/include/overlay006/ov6_02247100.h b/include/overlay006/ov6_02247100.h index 2735c4e8cd..0f88a0e4d4 100644 --- a/include/overlay006/ov6_02247100.h +++ b/include/overlay006/ov6_02247100.h @@ -7,12 +7,12 @@ #include "pokemon.h" void *ov6_02247100(FieldSystem *fieldSystem, u32 param1); -BOOL ov6_02247120(FieldTask *param0); +BOOL ov6_02247120(FieldTask *task); void *ov6_022472C8(FieldSystem *fieldSystem, u32 param1, int param2); -BOOL ov6_022472E8(FieldTask *param0); +BOOL ov6_022472E8(FieldTask *task); void *ov6_02247488(FieldSystem *, Pokemon *, u32 param0); -BOOL ov6_022474AC(FieldTask *param0); +BOOL ov6_022474AC(FieldTask *task); void *ov6_02247530(FieldSystem *fieldSystem, Pokemon *param1, u32 param2); -BOOL ov6_02247554(FieldTask *param0); +BOOL ov6_02247554(FieldTask *task); #endif // POKEPLATINUM_OV6_02247100_H diff --git a/include/struct_decls/struct_0203A790_decl.h b/include/struct_decls/struct_0203A790_decl.h index 49d0f0f980..78621e74fd 100644 --- a/include/struct_decls/struct_0203A790_decl.h +++ b/include/struct_decls/struct_0203A790_decl.h @@ -1,6 +1,6 @@ #ifndef POKEPLATINUM_STRUCT_0203A790_DECL_H #define POKEPLATINUM_STRUCT_0203A790_DECL_H -typedef struct UnkStruct_0203A790_t FieldOverworldState; +typedef struct FieldOverworldState FieldOverworldState; #endif // POKEPLATINUM_STRUCT_0203A790_DECL_H diff --git a/include/unk_020528D0.h b/include/unk_020528D0.h index 4f6b25dd15..5d9afb1a8a 100644 --- a/include/unk_020528D0.h +++ b/include/unk_020528D0.h @@ -3,7 +3,7 @@ #include "field_task.h" -BOOL sub_02052B2C(FieldTask *param0); -void sub_02052C5C(FieldTask *param0); +BOOL sub_02052B2C(FieldTask *task); +void sub_02052C5C(FieldTask *task); #endif // POKEPLATINUM_UNK_020528D0_H diff --git a/include/unk_02054884.h b/include/unk_02054884.h index 256f17699e..af262b5aaf 100644 --- a/include/unk_02054884.h +++ b/include/unk_02054884.h @@ -9,16 +9,16 @@ #define PARTY_SLOT_NONE 0xFF BOOL Pokemon_CanBattle(Pokemon *mon); -BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param4, int param5, int param6); -BOOL sub_02054930(int param0, SaveData *param1, u16 param2, u8 param3, int param4, int param5); -void sub_02054988(Party *param0, int param1, int param2, u16 param3); +BOOL sub_020548B0(int heapID, SaveData *saveData, u16 param2, u8 param3, u16 param4, int param5, int param6); +BOOL sub_02054930(int unused, SaveData *saveData, u16 param2, u8 param3, int param4, int param5); +void sub_02054988(Party *party, int param1, int param2, u16 param3); int Party_HasMonWithMove(Party *party, u16 moveID); int Party_AliveMonsCount(const Party *party); Pokemon *Party_FindFirstEligibleBattler(const Party *party); Pokemon *Party_FindFirstHatchedMon(const Party *party); BOOL Party_HasTwoAliveMons(const Party *party); void Party_GiveChampionRibbons(Party *party); -int sub_02054B04(Party *param0, u16 param1); +int Pokemon_DoPoisonDamage(Party *party, u16 mapLabelTextID); BOOL Pokemon_TrySurvivePoison(Pokemon *mon); #endif // POKEPLATINUM_UNK_02054884_H diff --git a/include/unk_020553DC.h b/include/unk_020553DC.h index a30d9e5e46..5d1f0d7a23 100644 --- a/include/unk_020553DC.h +++ b/include/unk_020553DC.h @@ -4,11 +4,11 @@ #include "field/field_system_decl.h" void sub_020553DC(void); -void sub_020553F0(FieldSystem *fieldSystem, u16 param1); -u16 sub_02055404(FieldSystem *fieldSystem); +void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 sdatID); +u16 Sound_GetSpecialBGM(FieldSystem *fieldSystem); void Sound_ClearSpecialBGM(FieldSystem *fieldSystem); u16 sub_02055428(FieldSystem *fieldSystem, int param1); -u16 sub_020554A4(FieldSystem *fieldSystem, int param1); +u16 sub_020554A4(FieldSystem *fieldSystem, int headerID); BOOL sub_02055554(FieldSystem *fieldSystem, u16 param1, int param2); u16 sub_0205560C(int param0); void Sound_TryFadeInBGM(FieldSystem *fieldSystem, int param1); diff --git a/src/comm_player_manager.c b/src/comm_player_manager.c index e149394c87..9e4f6379f0 100644 --- a/src/comm_player_manager.c +++ b/src/comm_player_manager.c @@ -631,13 +631,13 @@ static int CommPlayer_Direction(u16 unused, u16 keys) BOOL CommPlayer_CheckNPCCollision(int x, int z) { int npcCnt, i; - const ObjectEvent *npcList; + const ObjectEvent *objEventList; npcCnt = MapHeaderData_GetNumObjectEvents(sCommPlayerManager->fieldSystem); - npcList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem); + objEventList = MapHeaderData_GetObjectEvents(sCommPlayerManager->fieldSystem); for (i = 0; i < npcCnt; i++) { - if ((npcList[i].x == x) && (npcList[i].z == z)) { + if ((objEventList[i].x == x) && (objEventList[i].z == z)) { return 1; } } diff --git a/src/encounter.c b/src/encounter.c index 0abdf505b2..bdb0be7235 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -457,7 +457,7 @@ static BOOL FieldTask_SafariEncounter(FieldTask *task) FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); Encounter *encounter = FieldTask_GetEnv(task); int *state = FieldTask_GetState(task); - u16 *ballCount = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *ballCount = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); switch (*state) { case 0: diff --git a/src/field_battle_data_transfer.c b/src/field_battle_data_transfer.c index d4fe908bb0..9e6175bc7c 100644 --- a/src/field_battle_data_transfer.c +++ b/src/field_battle_data_transfer.c @@ -429,7 +429,7 @@ void FieldBattleDTO_UpdateFieldSystem(const FieldBattleDTO *dto, FieldSystem *fi Party *party = Party_GetFromSavedata(fieldSystem->saveData); Bag *bag = SaveData_GetBag(fieldSystem->saveData); PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); - u16 *fieldSysSafariBalls = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *fieldSysSafariBalls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); TrainerInfo_Copy(dto->trainerInfo[BATTLER_PLAYER_SLOT_1], trainerInfo); Party_cpy(dto->parties[BATTLER_PLAYER_SLOT_1], party); diff --git a/src/field_map_change.c b/src/field_map_change.c index 63137851a4..8c4784e393 100644 --- a/src/field_map_change.c +++ b/src/field_map_change.c @@ -132,28 +132,28 @@ typedef struct MapChangeUnionData { Location location; } MapChangeUnionData; -static BOOL FieldTask_ChangeMap(FieldTask *taskMan); -static BOOL FieldTask_LoadNewGameSpawn(FieldTask *taskMan); +static BOOL FieldTask_ChangeMap(FieldTask *task); +static BOOL FieldTask_LoadNewGameSpawn(FieldTask *task); 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(FieldTask *taskMan); -static void FieldTask_FinishFly(FieldTask *taskMan); -static BOOL FieldTransition_FinishMapFly(FieldTask *taskMan); -static void FieldTransition_StartMapAndFadeInFly(FieldTask *taskMan); -static BOOL FieldTransition_StartMapAndFadeInFlySub(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 FieldTransition_FinishMapDig(FieldTask *taskMan); -static void FieldTransition_StartMapAndFadeInDig(FieldTask *taskMan); -static BOOL FieldTask_FadeInDig(FieldTask *taskMan); -static void sub_02053E5C(FieldTask *taskMan); -static BOOL sub_0205444C(FieldTask *taskMan, int param1); +static BOOL FieldTask_MapChangeFly(FieldTask *task); +static void FieldTask_FinishFly(FieldTask *task); +static BOOL FieldTransition_FinishMapFly(FieldTask *task); +static void FieldTransition_StartMapAndFadeInFly(FieldTask *task); +static BOOL FieldTransition_StartMapAndFadeInFlySub(FieldTask *task); +static void FieldTask_FadeInFly(FieldTask *task); +static BOOL FieldTask_WaitFadeInFly(FieldTask *task); +static BOOL FieldTask_MapChangeByDig(FieldTask *task); +static void FieldTask_StartFinishFieldMapDig(FieldTask *task); +static BOOL FieldTransition_FinishMapDig(FieldTask *task); +static void FieldTransition_StartMapAndFadeInDig(FieldTask *task); +static BOOL FieldTask_FadeInDig(FieldTask *task); +static void sub_02053E5C(FieldTask *task); +static BOOL sub_0205444C(FieldTask *task, int param1); static const MapLoadMode sMapLoadMode[] = { { 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xC4000 }, @@ -445,10 +445,10 @@ static void FieldSystem_SetLocationToUnionRoomExit(FieldSystem *fieldSystem) Location_Set(exit, fieldSystem->location->mapId, -1, 8, 2, 1); } -static BOOL FieldTask_LoadNewGameSpawn(FieldTask *taskMan) +static BOOL FieldTask_LoadNewGameSpawn(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - int *state = FieldTask_GetState(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + int *state = FieldTask_GetState(task); switch (*state) { case 0: @@ -459,7 +459,7 @@ static BOOL FieldTask_LoadNewGameSpawn(FieldTask *taskMan) (*state)++; break; case 1: - FieldTransition_StartMapAndFadeIn(taskMan); + FieldTransition_StartMapAndFadeIn(task); (*state)++; break; case 2: @@ -481,11 +481,11 @@ static inline BOOL CheckJournalAcquired(VarsFlags *varsFlags) return SystemFlag_HandleJournalAcquired(varsFlags, HANDLE_FLAG_CHECK); } -static BOOL FieldTask_LoadSavedGameMap(FieldTask *taskMan) +static BOOL FieldTask_LoadSavedGameMap(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - int *state = FieldTask_GetState(taskMan); + int *state = FieldTask_GetState(task); switch (*state) { case 0: @@ -523,7 +523,7 @@ static BOOL FieldTask_LoadSavedGameMap(FieldTask *taskMan) (*state) = 2; break; case 2: - FieldTransition_StartMapAndFadeIn(taskMan); + FieldTransition_StartMapAndFadeIn(task); (*state) = 3; break; case 3: @@ -544,12 +544,12 @@ void FieldSystem_SetLoadSavedGameMapTask(FieldSystem *fieldSystem) FieldSystem_CreateTask(fieldSystem, FieldTask_LoadSavedGameMap, NULL); } -static BOOL FieldTask_LoadMapFromError(FieldTask *taskMan) +static BOOL FieldTask_LoadMapFromError(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeFromErrorData *errorData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeFromErrorData *errorData = FieldTask_GetEnv(task); VarsFlags *varsFlags = SaveData_GetVarsFlags(fieldSystem->saveData); - int *state = FieldTask_GetState(taskMan); + int *state = FieldTask_GetState(task); switch (*state) { case 0: @@ -570,7 +570,7 @@ static BOOL FieldTask_LoadMapFromError(FieldTask *taskMan) case 2: fieldSystem->unk_7C = FieldSystem_InitCommUnionRoom(fieldSystem); fieldSystem->unk_80 = sub_0205C22C(fieldSystem->unk_7C); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); (*state)++; break; case 3: @@ -615,21 +615,21 @@ void FieldSystem_StartLoadMapFromErrorTask(FieldSystem *fieldSystem) FieldSystem_CreateTask(fieldSystem, FieldTask_LoadMapFromError, errorData); } -static BOOL FieldTask_ChangeMap(FieldTask *taskMan) +static BOOL FieldTask_ChangeMap(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeData *mapChangeData = FieldTask_GetEnv(task); Location *location = &mapChangeData->nextLocation; switch (mapChangeData->state) { case 0: Sound_PlayEffect(1539); Sound_TryFadeInBGM(fieldSystem, location->mapId); - FieldTransition_FadeOutAndFinishMap(taskMan); + FieldTransition_FadeOutAndFinishMap(task); mapChangeData->state++; break; case 1: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->nextLocation); + FieldTask_ChangeMapByLocation(task, &mapChangeData->nextLocation); mapChangeData->state++; break; case 2: @@ -638,7 +638,7 @@ static BOOL FieldTask_ChangeMap(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, location->mapId); - FieldTransition_StartMapAndFadeIn(taskMan); + FieldTransition_StartMapAndFadeIn(task); mapChangeData->state++; break; case 3: @@ -649,20 +649,20 @@ static BOOL FieldTask_ChangeMap(FieldTask *taskMan) return FALSE; } -void FieldSystem_StartChangeMapTask(FieldTask *taskMan, const Location *nextLocation) +void FieldSystem_StartChangeMapTask(FieldTask *task, const Location *nextLocation) { MapChangeData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeData)); mapChangeData->state = 0; mapChangeData->nextLocation = *nextLocation; - FieldTask_InitCall(taskMan, FieldTask_ChangeMap, mapChangeData); + FieldTask_InitCall(task, FieldTask_ChangeMap, mapChangeData); } -static BOOL FieldTask_ChangeMapSub(FieldTask *taskMan) +static BOOL FieldTask_ChangeMapSub(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(task); switch (mapChangeSub->state) { case 0: @@ -686,9 +686,9 @@ static BOOL FieldTask_ChangeMapSub(FieldTask *taskMan) return 0; } -void FieldTask_ChangeMapByLocation(FieldTask *taskMan, const Location *nextLocation) +void FieldTask_ChangeMapByLocation(FieldTask *task, const Location *nextLocation) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); MapChangeSubData *mapChangeSub = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); if (FieldSystem_HasParentProcess(fieldSystem)) { @@ -699,31 +699,31 @@ void FieldTask_ChangeMapByLocation(FieldTask *taskMan, const Location *nextLocat mapChangeSub->state = 0; mapChangeSub->nextLocation = *nextLocation; - FieldTask_InitCall(taskMan, FieldTask_ChangeMapSub, mapChangeSub); + FieldTask_InitCall(task, FieldTask_ChangeMapSub, mapChangeSub); } -void FieldTask_ChangeMapToLocation(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5) +void FieldTask_ChangeMapToLocation(FieldTask *task, int param1, int param2, int param3, int param4, int param5) { Location location; Location_Set(&location, param1, param2, param3, param4, param5); - FieldTask_ChangeMapByLocation(taskMan, &location); + FieldTask_ChangeMapByLocation(task, &location); } -static BOOL FieldTask_ChangeMapFull(FieldTask *taskMan) +static BOOL FieldTask_ChangeMapFull(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(task); Location *nextLocation = &mapChangeSub->nextLocation; switch (mapChangeSub->state) { case 0: Sound_TryFadeInBGM(fieldSystem, nextLocation->mapId); - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); mapChangeSub->state++; break; case 1: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeSub->nextLocation); + FieldTask_ChangeMapByLocation(task, &mapChangeSub->nextLocation); mapChangeSub->state++; break; case 2: @@ -732,7 +732,7 @@ static BOOL FieldTask_ChangeMapFull(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, nextLocation->mapId); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); mapChangeSub->state++; break; case 3: @@ -743,14 +743,14 @@ static BOOL FieldTask_ChangeMapFull(FieldTask *taskMan) return FALSE; } -void FieldTask_StartMapChangeFull(FieldTask *taskMan, int mapId, int param2, int x, int z, int dir) +void FieldTask_StartMapChangeFull(FieldTask *task, 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_InitCall(taskMan, FieldTask_ChangeMapFull, mapChangeSub); + FieldTask_InitCall(task, FieldTask_ChangeMapFull, mapChangeSub); } void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param2, int param3, int param4, int param5) @@ -768,7 +768,7 @@ void FieldTask_StartMapChangeFly(FieldSystem *fieldSystem, int param1, int param FieldSystem_CreateTask(fieldSystem, FieldTask_MapChangeFly, mapChangeData); } -void FieldTask_ChangeMapChangeFly(FieldTask *taskMan, int param1, int param2, int param3, int param4, int param5) +void FieldTask_ChangeMapChangeFly(FieldTask *task, int param1, int param2, int param3, int param4, int param5) { Location location; @@ -780,24 +780,24 @@ void FieldTask_ChangeMapChangeFly(FieldTask *taskMan, int param1, int param2, in mapChangeData->task = NULL; mapChangeData->location = location; - FieldTask_InitJump(taskMan, FieldTask_MapChangeFly, mapChangeData); + FieldTask_InitJump(task, FieldTask_MapChangeFly, mapChangeData); } -static BOOL FieldTask_MapChangeFly(FieldTask *taskMan) +static BOOL FieldTask_MapChangeFly(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(task); Location *location = &mapChangeData->location; switch (mapChangeData->state) { case 0: Sound_TryFadeInBGM(fieldSystem, location->mapId); - FieldTask_FinishFly(taskMan); + FieldTask_FinishFly(task); mapChangeData->state++; break; case 1: PlayerAvatar_SetPlayerState(fieldSystem->playerAvatar, 0x0); - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->location); + FieldTask_ChangeMapByLocation(task, &mapChangeData->location); mapChangeData->state++; break; case 2: @@ -807,7 +807,7 @@ static BOOL FieldTask_MapChangeFly(FieldTask *taskMan) Sound_PlayMapBGM(fieldSystem, location->mapId); sub_0207056C(fieldSystem); - FieldTransition_StartMapAndFadeInFly(taskMan); + FieldTransition_StartMapAndFadeInFly(task); mapChangeData->state++; break; case 3: @@ -818,18 +818,18 @@ static BOOL FieldTask_MapChangeFly(FieldTask *taskMan) return 0; } -static void FieldTask_FinishFly(FieldTask *taskMan) +static void FieldTask_FinishFly(FieldTask *task) { - FieldTask_InitCall(taskMan, FieldTransition_FinishMapFly, NULL); + FieldTask_InitCall(task, FieldTransition_FinishMapFly, NULL); } -static BOOL FieldTransition_FinishMapFly(FieldTask *taskMan) +static BOOL FieldTransition_FinishMapFly(FieldTask *task) { - int *state = FieldTask_GetState(taskMan); + int *state = FieldTask_GetState(task); switch (*state) { case 0: - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); (*state)++; break; case 1: @@ -839,25 +839,25 @@ static BOOL FieldTransition_FinishMapFly(FieldTask *taskMan) return FALSE; } -static void FieldTransition_StartMapAndFadeInFly(FieldTask *taskMan) +static void FieldTransition_StartMapAndFadeInFly(FieldTask *task) { - MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); - FieldTask_InitCall(taskMan, FieldTransition_StartMapAndFadeInFlySub, mapChangeData); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(task); + FieldTask_InitCall(task, FieldTransition_StartMapAndFadeInFlySub, mapChangeData); } -static BOOL FieldTransition_StartMapAndFadeInFlySub(FieldTask *taskMan) +static BOOL FieldTransition_StartMapAndFadeInFlySub(FieldTask *task) { - int *state = FieldTask_GetState(taskMan); - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + int *state = FieldTask_GetState(task); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); switch (*state) { case 0: - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); (*state)++; break; case 1: FieldSystem_RequestLocationName(fieldSystem); - FieldTask_FadeInFly(taskMan); + FieldTask_FadeInFly(task); (*state)++; break; case 2: @@ -867,10 +867,10 @@ static BOOL FieldTransition_StartMapAndFadeInFlySub(FieldTask *taskMan) return FALSE; } -static void FieldTask_FadeInFly(FieldTask *taskMan) +static void FieldTask_FadeInFly(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(task); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -878,12 +878,12 @@ static void FieldTask_FadeInFly(FieldTask *taskMan) } mapChangeData->task = FieldTask_InitFlyLandingTask(fieldSystem, PlayerAvatar_Gender(fieldSystem->playerAvatar)); - FieldTask_InitCall(taskMan, FieldTask_WaitFadeInFly, mapChangeData); + FieldTask_InitCall(task, FieldTask_WaitFadeInFly, mapChangeData); } -static BOOL FieldTask_WaitFadeInFly(FieldTask *taskMan) +static BOOL FieldTask_WaitFadeInFly(FieldTask *task) { - MapChangeFlyData *mapChangeData = FieldTask_GetEnv(taskMan); + MapChangeFlyData *mapChangeData = FieldTask_GetEnv(task); if (ov6_02245CF0(mapChangeData->task) == 1) { ov6_02245CFC(mapChangeData->task); @@ -893,7 +893,7 @@ static BOOL FieldTask_WaitFadeInFly(FieldTask *taskMan) return FALSE; } -void FieldTask_ChangeMapChangeByDig(FieldTask *taskMan, const Location *location, u32 param2) +void FieldTask_ChangeMapChangeByDig(FieldTask *task, const Location *location, u32 param2) { MapChangeDigData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeDigData)); @@ -902,24 +902,24 @@ void FieldTask_ChangeMapChangeByDig(FieldTask *taskMan, const Location *location mapChangeData->task = NULL; mapChangeData->location = *location; - FieldTask_InitJump(taskMan, FieldTask_MapChangeByDig, mapChangeData); + FieldTask_InitJump(task, FieldTask_MapChangeByDig, mapChangeData); } -static BOOL FieldTask_MapChangeByDig(FieldTask *taskMan) +static BOOL FieldTask_MapChangeByDig(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(task); Location *location = &mapChangeData->location; switch (mapChangeData->state) { case 0: Sound_TryFadeInBGM(fieldSystem, location->mapId); - FieldTask_StartFinishFieldMapDig(taskMan); + FieldTask_StartFinishFieldMapDig(task); mapChangeData->state++; break; case 1: PlayerAvatar_SetPlayerState(fieldSystem->playerAvatar, 0x0); - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->location); + FieldTask_ChangeMapByLocation(task, &mapChangeData->location); mapChangeData->state++; break; case 2: @@ -937,7 +937,7 @@ static BOOL FieldTask_MapChangeByDig(FieldTask *taskMan) GF_ASSERT(FALSE); } - FieldTransition_StartMapAndFadeInDig(taskMan); + FieldTransition_StartMapAndFadeInDig(task); mapChangeData->state++; break; case 3: @@ -948,18 +948,18 @@ static BOOL FieldTask_MapChangeByDig(FieldTask *taskMan) return FALSE; } -static void FieldTask_StartFinishFieldMapDig(FieldTask *taskMan) +static void FieldTask_StartFinishFieldMapDig(FieldTask *task) { - FieldTask_InitCall(taskMan, FieldTransition_FinishMapDig, NULL); + FieldTask_InitCall(task, FieldTransition_FinishMapDig, NULL); } -static BOOL FieldTransition_FinishMapDig(FieldTask *taskMan) +static BOOL FieldTransition_FinishMapDig(FieldTask *task) { - int *state = FieldTask_GetState(taskMan); + int *state = FieldTask_GetState(task); switch (*state) { case 0: - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); (*state)++; break; case 1: @@ -969,26 +969,26 @@ static BOOL FieldTransition_FinishMapDig(FieldTask *taskMan) return FALSE; } -static void FieldTransition_StartMapAndFadeInDig(FieldTask *taskMan) +static void FieldTransition_StartMapAndFadeInDig(FieldTask *task) { - MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); - FieldTask_InitCall(taskMan, FieldTask_FadeInDig, mapChangeData); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(task); + FieldTask_InitCall(task, FieldTask_FadeInDig, mapChangeData); } -static BOOL FieldTask_FadeInDig(FieldTask *taskMan) +static BOOL FieldTask_FadeInDig(FieldTask *task) { - int *state = FieldTask_GetState(taskMan); - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); + int *state = FieldTask_GetState(task); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(task); switch (*state) { case 0: - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); (*state)++; break; case 1: FieldSystem_RequestLocationName(fieldSystem); - sub_02053E5C(taskMan); + sub_02053E5C(task); (*state)++; break; case 2: @@ -998,10 +998,10 @@ static BOOL FieldTask_FadeInDig(FieldTask *taskMan) return FALSE; } -static void sub_02053E5C(FieldTask *taskMan) +static void sub_02053E5C(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeDigData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeDigData *mapChangeData = FieldTask_GetEnv(task); if (!FieldSystem_HasParentProcess(fieldSystem)) { GF_ASSERT(FALSE); @@ -1009,13 +1009,13 @@ static void sub_02053E5C(FieldTask *taskMan) } void *v2 = ov6_022472C8(fieldSystem, 4, mapChangeData->unk_04); - FieldTask_InitCall(taskMan, ov6_022472E8, v2); + FieldTask_InitCall(task, ov6_022472E8, v2); } -static BOOL FieldTask_MapChangeWarp(FieldTask *taskMan) +static BOOL FieldTask_MapChangeWarp(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeWarpData *mapChangeWarpData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeWarpData *mapChangeWarpData = FieldTask_GetEnv(task); Location *nextLocation = &mapChangeWarpData->nextLocation; switch (mapChangeWarpData->state) { @@ -1026,12 +1026,12 @@ static BOOL FieldTask_MapChangeWarp(FieldTask *taskMan) case 1: if (mapChangeWarpData->warpFinished) { Sound_TryFadeInBGM(fieldSystem, nextLocation->mapId); - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); mapChangeWarpData->state++; } break; case 2: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeWarpData->nextLocation); + FieldTask_ChangeMapByLocation(task, &mapChangeWarpData->nextLocation); mapChangeWarpData->state++; break; case 3: @@ -1040,7 +1040,7 @@ static BOOL FieldTask_MapChangeWarp(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, nextLocation->mapId); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); mapChangeWarpData->state++; break; case 4: @@ -1135,10 +1135,10 @@ void FieldTask_SetUndergroundMapChange(FieldSystem *fieldSystem) FieldSystem_CreateTask(fieldSystem, FieldMapChange_GetMapChangeUndergroundTask(fieldSystem), mapChangeUndergroundData); } -BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) +BOOL FieldTask_MapChangeToUnderground(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(task); switch (mapChangeUndergroundData->state) { case 0: @@ -1175,13 +1175,13 @@ BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) break; case 3: if (SaveData_OverwriteCheck(fieldSystem->saveData)) { - ScriptManager_Start(taskMan, 2034, NULL, NULL); + ScriptManager_Start(task, 2034, NULL, NULL); } else { sub_020287E0(fieldSystem->saveData); mapChangeUndergroundData->saveInfoWin = SaveInfoWindow_New(fieldSystem, 11, BG_LAYER_MAIN_3); SaveInfoWindow_Draw(mapChangeUndergroundData->saveInfoWin); mapChangeUndergroundData->unk_1C = 0; - ScriptManager_Start(taskMan, 2005, NULL, &mapChangeUndergroundData->unk_1C); + ScriptManager_Start(task, 2005, NULL, &mapChangeUndergroundData->unk_1C); } mapChangeUndergroundData->state = 4; @@ -1209,19 +1209,19 @@ BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) mapChangeUndergroundData->state++; break; case 7: - if (sub_0205444C(taskMan, 0)) { + if (sub_0205444C(task, 0)) { mapChangeUndergroundData->state++; } break; case 8: - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); mapChangeUndergroundData->state++; break; case 9: fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNDERGROUND; Overlay_LoadByID(FS_OVERLAY_ID(overlay23), 2); ov23_022499E8(fieldSystem); - FieldTask_ChangeMapToLocation(taskMan, mapChangeUndergroundData->mapId, -1, mapChangeUndergroundData->unk_10, mapChangeUndergroundData->unk_14, 1); + FieldTask_ChangeMapToLocation(task, mapChangeUndergroundData->mapId, -1, mapChangeUndergroundData->unk_10, mapChangeUndergroundData->unk_14, 1); mapChangeUndergroundData->state++; break; case 10: @@ -1231,11 +1231,11 @@ BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) sub_02004234(0); Sound_ClearSpecialBGM(fieldSystem); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); mapChangeUndergroundData->state++; break; case 11: - if (sub_0205444C(taskMan, 1)) { + if (sub_0205444C(task, 1)) { ov23_02249A2C(); fieldSystem->unk_6C = ov23_02249404(fieldSystem); sub_0200AAE0(30, 0, -16, GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ, 2); @@ -1254,10 +1254,10 @@ BOOL FieldTask_MapChangeToUnderground(FieldTask *taskMan) return 0; } -BOOL FieldTask_MapChangeFromUnderground(FieldTask *taskMan) +BOOL FieldTask_MapChangeFromUnderground(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(task); int v2 = 0; switch (mapChangeUndergroundData->state) { @@ -1277,18 +1277,18 @@ BOOL FieldTask_MapChangeFromUnderground(FieldTask *taskMan) } break; case 2: - if (sub_0205444C(taskMan, 2)) { + if (sub_0205444C(task, 2)) { mapChangeUndergroundData->state++; } break; case 3: - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); mapChangeUndergroundData->state++; break; case 4: fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; Overlay_UnloadByID(FS_OVERLAY_ID(overlay23)); - FieldTask_ChangeMapToLocation(taskMan, mapChangeUndergroundData->mapId, -1, mapChangeUndergroundData->unk_10, mapChangeUndergroundData->unk_14, 1); + FieldTask_ChangeMapToLocation(task, mapChangeUndergroundData->mapId, -1, mapChangeUndergroundData->unk_10, mapChangeUndergroundData->unk_14, 1); mapChangeUndergroundData->state++; break; case 5: @@ -1298,11 +1298,11 @@ BOOL FieldTask_MapChangeFromUnderground(FieldTask *taskMan) sub_02004234(0); Sound_ClearSpecialBGM(fieldSystem); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); mapChangeUndergroundData->state++; break; case 6: - if (sub_0205444C(taskMan, 3)) { + if (sub_0205444C(task, 3)) { mapChangeUndergroundData->state++; } break; @@ -1327,10 +1327,10 @@ FieldTaskFunc FieldMapChange_GetMapChangeUndergroundTask(const FieldSystem *fiel } } -static BOOL sub_0205444C(FieldTask *taskMan, int param1) +static BOOL sub_0205444C(FieldTask *task, int param1) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeUndergroundData *mapChangeUndergroundData = FieldTask_GetEnv(task); BOOL ret = 0; switch (mapChangeUndergroundData->unk_04) { @@ -1350,10 +1350,10 @@ static BOOL sub_0205444C(FieldTask *taskMan, int param1) return ret; } -static BOOL sub_02054494(FieldTask *taskMan) +static BOOL sub_02054494(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeSubData *mapChangeSub = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeSubData *mapChangeSub = FieldTask_GetEnv(task); switch (mapChangeSub->state) { case 0: @@ -1374,9 +1374,9 @@ static BOOL sub_02054494(FieldTask *taskMan) return 0; } -void sub_020544F0(FieldTask *taskMan, const Location *nextLocation) +void sub_020544F0(FieldTask *task, const Location *nextLocation) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); MapChangeSubData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeSubData)); if (FieldSystem_HasParentProcess(fieldSystem)) { @@ -1387,14 +1387,14 @@ void sub_020544F0(FieldTask *taskMan, const Location *nextLocation) mapChangeData->state = 0; mapChangeData->nextLocation = *nextLocation; - FieldTask_InitCall(taskMan, sub_02054494, mapChangeData); + FieldTask_InitCall(task, sub_02054494, mapChangeData); } -static BOOL sub_02054538(FieldTask *taskMan) +static BOOL sub_02054538(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeUnionData *mapChangeData = FieldTask_GetEnv(taskMan); - int *state = FieldTask_GetState(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeUnionData *mapChangeData = FieldTask_GetEnv(task); + int *state = FieldTask_GetState(task); Location *v3 = &mapChangeData->location; switch (*state) { @@ -1405,12 +1405,12 @@ static BOOL sub_02054538(FieldTask *taskMan) break; case 1: if (mapChangeData->unk_04) { - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); (*state)++; } break; case 2: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->location); + FieldTask_ChangeMapByLocation(task, &mapChangeData->location); (*state)++; break; case 3: @@ -1419,11 +1419,11 @@ static BOOL sub_02054538(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, v3->mapId); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); (*state)++; break; case 4: - FieldTransition_FadeIn(taskMan); + FieldTransition_FadeIn(task); (*state)++; break; case 5: @@ -1450,25 +1450,25 @@ void sub_020545EC(FieldSystem *fieldSystem) fieldSystem->unk_7C = NULL; } -static BOOL sub_02054648(FieldTask *taskMan) +static BOOL sub_02054648(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeUnionData *mapChangeData = FieldTask_GetEnv(taskMan); - int *state = FieldTask_GetState(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeUnionData *mapChangeData = FieldTask_GetEnv(task); + int *state = FieldTask_GetState(task); Location *v3 = &mapChangeData->location; switch (*state) { case 0: Sound_TryFadeInBGM(fieldSystem, v3->mapId); - FieldTransition_FadeOut(taskMan); + FieldTransition_FadeOut(task); (*state)++; break; case 1: - FieldTransition_FinishMap(taskMan); + FieldTransition_FinishMap(task); (*state)++; break; case 2: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->location); + FieldTask_ChangeMapByLocation(task, &mapChangeData->location); (*state)++; break; case 3: @@ -1477,7 +1477,7 @@ static BOOL sub_02054648(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, v3->mapId); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); (*state)++; break; case 4: @@ -1498,9 +1498,9 @@ static BOOL sub_02054648(FieldTask *taskMan) return FALSE; } -void sub_02054708(FieldTask *taskMan) +void sub_02054708(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); MapChangeUnionData *mapChangeData = Heap_AllocFromHeapAtEnd(11, sizeof(MapChangeUnionData)); @@ -1513,24 +1513,24 @@ void sub_02054708(FieldTask *taskMan) fieldSystem->unk_80 = sub_0205C22C(fieldSystem->unk_7C); fieldSystem->mapLoadType = MAP_LOAD_TYPE_UNION; - FieldTask_InitCall(taskMan, sub_02054648, mapChangeData); + FieldTask_InitCall(task, sub_02054648, mapChangeData); } -static BOOL FieldTask_ChangeMapColosseum(FieldTask *taskMan) +static BOOL FieldTask_ChangeMapColosseum(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - MapChangeData *mapChangeData = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + MapChangeData *mapChangeData = FieldTask_GetEnv(task); Location *location = &mapChangeData->nextLocation; switch (mapChangeData->state) { case 0: Sound_PlayEffect(1539); Sound_TryFadeInBGM(fieldSystem, location->mapId); - FieldTransition_FadeOutAndFinishMap(taskMan); + FieldTransition_FadeOutAndFinishMap(task); mapChangeData->state++; break; case 1: - FieldTask_ChangeMapByLocation(taskMan, &mapChangeData->nextLocation); + FieldTask_ChangeMapByLocation(task, &mapChangeData->nextLocation); mapChangeData->state++; break; case 2: @@ -1539,7 +1539,7 @@ static BOOL FieldTask_ChangeMapColosseum(FieldTask *taskMan) } Sound_PlayMapBGM(fieldSystem, location->mapId); - FieldTransition_StartMap(taskMan); + FieldTransition_StartMap(task); mapChangeData->state++; break; case 3: @@ -1550,10 +1550,10 @@ static BOOL FieldTask_ChangeMapColosseum(FieldTask *taskMan) return FALSE; } -void sub_02054800(FieldTask *taskMan, int mapId, int param2, int x, int z, int param5) +void sub_02054800(FieldTask *task, int mapId, int param2, int x, int z, int param5) { Location nextLocation; - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); Location_SetToPlayerLocation(location, fieldSystem); @@ -1567,12 +1567,12 @@ void sub_02054800(FieldTask *taskMan, int mapId, int param2, int x, int z, int p mapChangeData->state = 0; mapChangeData->nextLocation = nextLocation; - FieldTask_InitCall(taskMan, FieldTask_ChangeMapColosseum, mapChangeData); + FieldTask_InitCall(task, FieldTask_ChangeMapColosseum, mapChangeData); } -void sub_02054864(FieldTask *taskMan) +void sub_02054864(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); Location *location = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); fieldSystem->mapLoadType = MAP_LOAD_TYPE_OVERWORLD; diff --git a/src/field_menu.c b/src/field_menu.c index c310f52451..e394741610 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -686,7 +686,7 @@ static void sub_0203B094(FieldTask *taskMan) v5 = MessageLoader_GetNewStrbuf(v2, 11); if (v6 == 0) { - u16 *v7 = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *v7 = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); StringTemplate_SetNumber(v3, 0, *v7, 2, 0, 1); } else { diff --git a/src/field_overworld_state.c b/src/field_overworld_state.c index b45449dd5c..2c808f524b 100644 --- a/src/field_overworld_state.c +++ b/src/field_overworld_state.c @@ -16,23 +16,23 @@ #include "unk_0203A7D8.h" #include "unk_020556C4.h" -typedef struct UnkStruct_0203A790_t { +typedef struct FieldOverworldState { Location player; Location entrance; Location previous; Location special; - Location unk_50; - u16 unk_64; + Location exit; + u16 bgm; u16 weather; u16 warpId; u8 cameraType; UnkStruct_020556C4 unk_6C; PlayerData playerData; - u16 unk_94; - u16 unk_96; - u16 unk_98; - u16 unk_9A; - u16 unk_9C; + u16 poisonSteps; + u16 safariSteps; + u16 safariBalls; + u16 padding_9A; // unused + u16 padding_9C; // unused } FieldOverworldState; typedef struct UnkStruct_0203A79C_t { @@ -49,9 +49,9 @@ int FieldOverworldSave_Size(void) return sizeof(FieldOverworldSave); } -void FieldOverworldSave_Init(FieldOverworldSave *fieldState) +void FieldOverworldSave_Init(FieldOverworldSave *fieldSave) { - MI_CpuClear32(fieldState, sizeof(FieldOverworldSave)); + MI_CpuClear32(fieldSave, sizeof(FieldOverworldSave)); } void FieldOverworldState_Init(FieldOverworldState *fieldState) @@ -79,9 +79,9 @@ Location *FieldOverworldState_GetPrevLocation(FieldOverworldState *fieldState) return &fieldState->previous; } -Location *sub_0203A72C(FieldOverworldState *fieldState) +Location *FieldOverworldState_GetExitLocation(FieldOverworldState *fieldState) { - return &fieldState->unk_50; + return &fieldState->exit; } Location *FieldOverworldState_GetSpecialLocation(FieldOverworldState *fieldState) @@ -95,9 +95,9 @@ void FieldOverworldState_SetSpecialLocation(FieldOverworldState *fieldState, Loc return; } -u16 *sub_0203A748(FieldOverworldState *fieldState) +u16 *FieldOverworldState_GetSpecialBGM(FieldOverworldState *fieldState) { - return &fieldState->unk_64; + return &fieldState->bgm; } u16 FieldOverworldState_GetWeather(const FieldOverworldState *fieldState) @@ -140,19 +140,19 @@ PlayerData *FieldOverworldState_GetPlayerData(FieldOverworldState *fieldState) return &fieldState->playerData; } -u16 *sub_0203A784(FieldOverworldState *fieldState) +u16 *FieldOverworldState_GetSafariBallCount(FieldOverworldState *fieldState) { - return &fieldState->unk_98; + return &fieldState->safariBalls; } -u16 *sub_0203A788(FieldOverworldState *fieldState) +u16 *FieldOverworldState_GetSafariStepCount(FieldOverworldState *fieldState) { - return &fieldState->unk_96; + return &fieldState->safariSteps; } -u16 *sub_0203A78C(FieldOverworldState *fieldState) +u16 *FieldOverworldState_GetPoisonStepCount(FieldOverworldState *fieldState) { - return &fieldState->unk_94; + return &fieldState->poisonSteps; } FieldOverworldState *SaveData_GetFieldOverworldState(SaveData *saveData) diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 409c05b058..5a6d7400c2 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -3,6 +3,7 @@ #include #include +#include "constants/field_poison.h" #include "constants/player_avatar.h" #include "consts/game_records.h" #include "consts/sdat.h" @@ -896,7 +897,7 @@ static void Field_CalculateFriendship(FieldSystem *fieldSystem) static BOOL Field_UpdatePoison(FieldSystem *fieldSystem) { Party *party = Party_GetFromSavedata(fieldSystem->saveData); - u16 *poisonSteps = sub_0203A78C(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *poisonSteps = FieldOverworldState_GetPoisonStepCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); (*poisonSteps)++; (*poisonSteps) %= 4; @@ -905,14 +906,14 @@ static BOOL Field_UpdatePoison(FieldSystem *fieldSystem) return FALSE; } - switch (sub_02054B04(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) { - case 0: + switch (Pokemon_DoPoisonDamage(party, MapHeader_GetMapLabelTextID(fieldSystem->location->mapId))) { + case FLDPSN_NONE: return FALSE; - case 1: - ov5_021EF518(fieldSystem->unk_04->unk_20); + case FLDPSN_POISONED: + Field_DoPoisonEffect(fieldSystem->unk_04->unk_20); return FALSE; - case 2: - ov5_021EF518(fieldSystem->unk_04->unk_20); + case FLDPSN_FAINTED: + Field_DoPoisonEffect(fieldSystem->unk_04->unk_20); ScriptManager_Set(fieldSystem, 2003, NULL); return TRUE; } @@ -926,14 +927,14 @@ static BOOL Field_UpdateSafari(FieldSystem *fieldSystem) return FALSE; } - u16 *balls = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *balls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); if (*balls == 0) { ScriptManager_Set(fieldSystem, 8802, NULL); return TRUE; } - u16 *steps = sub_0203A788(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *steps = FieldOverworldState_GetSafariStepCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); (*steps)++; if (*steps >= 500) { @@ -1024,8 +1025,8 @@ static BOOL Field_MapConnection(const FieldSystem *fieldSystem, int playerX, int static void Field_SetMapConnection(FieldSystem *fieldSystem, const int playerX, const int playerZ, const int playerDir) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - Location *nextMap = sub_0203A72C(v0); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); + Location *nextMap = FieldOverworldState_GetExitLocation(fieldState); (*nextMap) = *(fieldSystem->location); nextMap->faceDirection = playerDir; diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index 53dc805e74..d9f99f78f7 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -400,64 +400,57 @@ static BOOL ov5_021D119C(FieldSystem *fieldSystem) static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) { u32 v0; - u32 v1; - int v2, v3; - FieldOverworldState *v4; + u32 mapId; + int x, y; + FieldOverworldState *fieldState; - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { - return 0; + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { + return FALSE; } - v2 = (Player_GetXPos(fieldSystem->playerAvatar) - ov5_021EA6AC(fieldSystem->unk_28)) / 32; - v3 = (Player_GetZPos(fieldSystem->playerAvatar) - ov5_021EA6B4(fieldSystem->unk_28)) / 32; - v0 = sub_02039E30(fieldSystem->unk_2C, v2, v3); - v1 = fieldSystem->location->mapId; + x = (Player_GetXPos(fieldSystem->playerAvatar) - ov5_021EA6AC(fieldSystem->unk_28)) / 32; + y = (Player_GetZPos(fieldSystem->playerAvatar) - ov5_021EA6B4(fieldSystem->unk_28)) / 32; + v0 = sub_02039E30(fieldSystem->unk_2C, x, y); + mapId = fieldSystem->location->mapId; - if (v0 == v1) { - return 0; + if (v0 == mapId) { + return FALSE; } - v4 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - { - fieldSystem->location->mapId = v0; + fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); - MapHeaderData_Load(fieldSystem, v0); - FieldMapChange_UpdateGameData(fieldSystem, 1); - } + fieldSystem->location->mapId = v0; - { - int v5 = MapHeaderData_GetNumObjectEvents(fieldSystem); - const ObjectEvent *v6 = MapHeaderData_GetObjectEvents(fieldSystem); + MapHeaderData_Load(fieldSystem, v0); + FieldMapChange_UpdateGameData(fieldSystem, 1); - sub_0206184C(fieldSystem->mapObjMan, v1, v0, v5, v6); - } + int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem); - { - RadarChain_Clear(fieldSystem->chain); - sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1); - sub_0203A418(fieldSystem); + sub_0206184C(fieldSystem->mapObjMan, mapId, v0, objEventCount, objEventList); - if (fieldSystem->unk_04->unk_0C != NULL) { - ov5_021D5F7C( - fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(v4)); - } - } + RadarChain_Clear(fieldSystem->chain); + sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1); + sub_0203A418(fieldSystem); - { - int v7, v8; - int v9; + if (fieldSystem->unk_04->unk_0C != NULL) { + ov5_021D5F7C( + fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState)); + } - v7 = MapHeader_GetMapLabelTextID(v1); - v8 = MapHeader_GetMapLabelTextID(v0); - v9 = MapHeader_GetMapLabelWindowID(v0); + int v7, v8; + int v9; - if (v7 != v8) { - if (v9 != 0) { - v9--; - } + v7 = MapHeader_GetMapLabelTextID(mapId); + v8 = MapHeader_GetMapLabelTextID(v0); + v9 = MapHeader_GetMapLabelWindowID(v0); - ov5_021DD9E8(fieldSystem->unk_04->unk_08, v8, v9); + if (v7 != v8) { + if (v9 != 0) { + v9--; } + + ov5_021DD9E8(fieldSystem->unk_04->unk_08, v8, v9); } return TRUE; @@ -465,33 +458,27 @@ static BOOL FieldMap_ChangeZone(FieldSystem *fieldSystem) void ov5_021D12D0(FieldSystem *fieldSystem, u32 param1) { - u32 v0; - FieldOverworldState *v1; + u32 mapId; + FieldOverworldState *fieldState; - v0 = fieldSystem->location->mapId; - v1 = SaveData_GetFieldOverworldState(fieldSystem->saveData); + mapId = fieldSystem->location->mapId; + fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); - { - fieldSystem->location->mapId = param1; + fieldSystem->location->mapId = param1; - MapHeaderData_Load(fieldSystem, param1); - FieldMapChange_UpdateGameDataDistortionWorld(fieldSystem, 1); - } + MapHeaderData_Load(fieldSystem, param1); + FieldMapChange_UpdateGameDataDistortionWorld(fieldSystem, 1); - { - int v2 = MapHeaderData_GetNumObjectEvents(fieldSystem); - const ObjectEvent *v3 = MapHeaderData_GetObjectEvents(fieldSystem); + int objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + const ObjectEvent *objEventList = MapHeaderData_GetObjectEvents(fieldSystem); - sub_0206184C(fieldSystem->mapObjMan, v0, param1, v2, v3); - } + sub_0206184C(fieldSystem->mapObjMan, mapId, param1, objEventCount, objEventList); - { - sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1); - sub_0203A418(fieldSystem); + sub_02055554(fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1); + sub_0203A418(fieldSystem); - if (fieldSystem->unk_04->unk_0C != NULL) { - ov5_021D5F7C(fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(v1)); - } + if (fieldSystem->unk_04->unk_0C != NULL) { + ov5_021D5F7C(fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState)); } } @@ -515,7 +502,7 @@ static void ov5_021D134C(FieldSystem *fieldSystem, u8 param1) if ((param1 & 2) != 0) { ov5_021E8188(fieldSystem, fieldSystem->unk_28); - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { ov9_0224CA5C(fieldSystem); } } @@ -712,7 +699,7 @@ static void ov5_021D15F4(FieldSystem *fieldSystem) sub_020241B4(); if (fieldSystem->unk_20 == 1) { - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { ov9_02249F9C(fieldSystem); } @@ -724,7 +711,7 @@ static void ov5_021D15F4(FieldSystem *fieldSystem) sub_0206979C(fieldSystem); ov5_021E91FC(fieldSystem->unk_28, fieldSystem->unk_44); - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { ov9_0224CA50(fieldSystem); } @@ -745,7 +732,7 @@ static void ov5_021D15F4(FieldSystem *fieldSystem) ov5_021DF4F8(fieldSystem->unk_40); sub_02020C08(); - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { ov9_02250780(fieldSystem); } @@ -819,7 +806,7 @@ static void ov5_021D17EC(FieldSystem *fieldSystem) { fieldSystem->unk_28 = ov5_021E9084(fieldSystem->unk_2C, fieldSystem->unk_30, fieldSystem->unk_50, fieldSystem->unk_60); - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { int v0 = 0, v1 = 0, v2 = 0; ov9_02251094(fieldSystem->location->mapId, &v0, &v1, &v2); @@ -845,7 +832,7 @@ static void ov5_021D1878(FieldSystem *fieldSystem) { int v0 = 80; - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { v0 = 112; } @@ -864,7 +851,7 @@ static void ov5_021D1878(FieldSystem *fieldSystem) if (fieldSystem->mapLoadType == MAP_LOAD_TYPE_UNDERGROUND) { v1 = Unk_ov5_021FF7D0; } else { - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { v1 = Unk_ov5_021FF6B8; } else { v1 = Unk_ov5_021FF744; @@ -916,7 +903,7 @@ static void ov5_021D1968(FieldSystem *fieldSystem) fieldSystem->unk_4C = ov5_021D521C(fieldSystem->unk_44, ov5_021EFAD8(fieldSystem->unk_30)); - if (FieldMap_InDistortionWorld(fieldSystem) == 1) { + if (FieldMap_InDistortionWorld(fieldSystem) == TRUE) { fieldSystem->unk_04->unk_0C = NULL; } else { fieldSystem->unk_04->unk_0C = ov5_021D5EB8(fieldSystem); @@ -979,8 +966,8 @@ static BOOL FieldMap_InDistortionWorld(FieldSystem *fieldSystem) int v1 = sub_02027F80(v0); if (v1 == 9) { - return 1; + return TRUE; } - return 0; + return FALSE; } diff --git a/src/overlay005/ov5_021DFB54.c b/src/overlay005/ov5_021DFB54.c index aeba553703..dad1ceafb0 100644 --- a/src/overlay005/ov5_021DFB54.c +++ b/src/overlay005/ov5_021DFB54.c @@ -624,7 +624,7 @@ static BOOL ov5_021E0160(FieldTask *taskMan) switch (v0->unk_00) { case 0: if (PlayerAvatar_MapDistortionState(v0->playerAvatar) == AVATAR_DISTORTION_STATE_NONE) { - sub_020553F0(v0->fieldSystem, 0); + Sound_SetSpecialBGM(v0->fieldSystem, 0); sub_02055554(v0->fieldSystem, 1151, 1); } diff --git a/src/overlay005/ov5_021EF4BC.c b/src/overlay005/ov5_021EF4BC.c index feacd7321a..cfea846be6 100644 --- a/src/overlay005/ov5_021EF4BC.c +++ b/src/overlay005/ov5_021EF4BC.c @@ -60,7 +60,7 @@ void ov5_021EF4F8(UnkStruct_ov5_021EF4F8 *param0) Heap_FreeToHeap(param0); } -void ov5_021EF518(UnkStruct_ov5_021EF4F8 *param0) +void Field_DoPoisonEffect(UnkStruct_ov5_021EF4F8 *param0) { GF_ASSERT(param0->unk_00 == 0); diff --git a/src/overlay005/vs_seeker.c b/src/overlay005/vs_seeker.c index 55f6668227..e51d05b154 100644 --- a/src/overlay005/vs_seeker.c +++ b/src/overlay005/vs_seeker.c @@ -500,11 +500,11 @@ static void VsSeekerSystem_CollectViableNpcs(VsSeekerSystem *vsSeeker) int trainerX, trainerZ; int numVisibleTrainers; int xMin, xMax, zMin, zMax; - u32 npcCount = MapHeaderData_GetNumObjectEvents(vsSeeker->fieldSystem); + u32 objEventCount = MapHeaderData_GetNumObjectEvents(vsSeeker->fieldSystem); numVisibleTrainers = 0; - for (int i = 0; i < npcCount; i++) { + for (int i = 0; i < objEventCount; i++) { vsSeeker->trainers[i] = NULL; } @@ -523,7 +523,7 @@ static void VsSeekerSystem_CollectViableNpcs(VsSeekerSystem *vsSeeker) zMin = 0; } - for (int i = 0; i < npcCount; i++) { + for (int i = 0; i < objEventCount; i++) { MapObject *mapObj = MapObjMan_LocalMapObjByIndex(vsSeeker->fieldSystem->mapObjMan, i); if (mapObj == NULL) { @@ -598,9 +598,9 @@ BOOL VsSeeker_UpdateStepCount(FieldSystem *fieldSystem) static void VsSeeker_ClearRematchMoveCode(FieldSystem *fieldSystem) { - u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); - for (int i = 0; i < npcCount; i++) { + for (int i = 0; i < objEventCount; i++) { MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i); if (mapObj == NULL) { @@ -812,10 +812,10 @@ void VsSeeker_SetMoveCodeForFacingDirection(FieldSystem *fieldSystem, MapObject static BOOL VsSeeker_WaitForNpcsToPause(FieldSystem *fieldSystem) { - u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); BOOL anyMoving = FALSE; - for (int i = 0; i < npcCount; i++) { + for (int i = 0; i < objEventCount; i++) { MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i); if (mapObj == NULL) { @@ -836,7 +836,7 @@ static BOOL VsSeeker_WaitForNpcsToPause(FieldSystem *fieldSystem) static MapObject *VsSeeker_GetSecondDoubleBattleTrainer(FieldSystem *fieldSystem, MapObject *trainerObj, enum VsSeeker2v2TrainerSearchMode mode) { u32 secondTrainerEventID, secondTrainerID; - u32 npcCount = MapHeaderData_GetNumObjectEvents(fieldSystem); + u32 objEventCount = MapHeaderData_GetNumObjectEvents(fieldSystem); u16 eventID = MapObject_GetEventID(trainerObj); u16 trainerID = Script_GetTrainerID(eventID); @@ -844,7 +844,7 @@ static MapObject *VsSeeker_GetSecondDoubleBattleTrainer(FieldSystem *fieldSystem return NULL; } - for (u32 i = 0; i < npcCount; i++) { + for (u32 i = 0; i < objEventCount; i++) { MapObject *mapObj = MapObjMan_LocalMapObjByIndex(fieldSystem->mapObjMan, i); if (mapObj == NULL) { diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index 16c7d992cb..186c3890fd 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -1389,7 +1389,7 @@ static void ov6_02242328(FieldSystem *fieldSystem, const BOOL param1, FieldBattl if (!param1) { *param2 = FieldBattleDTO_New(11, (0x0 | 0x0)); } else { - u16 *v0 = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *v0 = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); *param2 = FieldBattleDTO_NewSafari(11, *v0); } } diff --git a/src/overlay006/ov6_02247100.c b/src/overlay006/ov6_02247100.c index 267f7d9316..01e6a81201 100644 --- a/src/overlay006/ov6_02247100.c +++ b/src/overlay006/ov6_02247100.c @@ -59,14 +59,14 @@ void *ov6_02247100(FieldSystem *fieldSystem, u32 param1) return v0; } -BOOL ov6_02247120(FieldTask *taskMan) +BOOL ov6_02247120(FieldTask *task) { int v0; - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(task); do { - v0 = Unk_ov6_022495CC[v2->unk_00](taskMan, fieldSystem, v2); + v0 = Unk_ov6_022495CC[v2->unk_00](task, fieldSystem, v2); if (v0 == 2) { Heap_FreeToHeap(v2); @@ -76,7 +76,7 @@ BOOL ov6_02247120(FieldTask *taskMan) return 0; } -static int ov6_0224715C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224715C(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { param2->unk_14 = ov5_021F0EB0(fieldSystem, 4); ov5_021F0F10(param2->unk_14, 1, (FX32_ONE * -150), 15); @@ -98,7 +98,7 @@ static int ov6_0224715C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 0; } -static int ov6_022471C0(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022471C0(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -123,7 +123,7 @@ static int ov6_022471C0(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 0; } -static int ov6_02247244(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247244(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 1) { MapObject_FinishAnimation(param2->unk_0C); @@ -142,20 +142,20 @@ static int ov6_02247244(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 1; } -static int ov6_02247288(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247288(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(fieldSystem->saveData); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); if (param2->unk_08 == 2) { - u16 v1; - Location v2; + u16 warpId; + Location location; - v1 = FieldOverworldState_GetWarpId(v0); - sub_0203A7F0(v1, &v2); - FieldTask_ChangeMapChangeByDig(taskMan, &v2, param2->unk_08); + warpId = FieldOverworldState_GetWarpId(fieldState); + sub_0203A7F0(warpId, &location); + FieldTask_ChangeMapChangeByDig(task, &location, param2->unk_08); } else { - Location *v3 = sub_0203A72C(v0); - FieldTask_ChangeMapChangeByDig(taskMan, v3, param2->unk_08); + Location *location = FieldOverworldState_GetExitLocation(fieldState); + FieldTask_ChangeMapChangeByDig(task, location, param2->unk_08); } return 2; @@ -179,14 +179,14 @@ void *ov6_022472C8(FieldSystem *fieldSystem, u32 param1, int param2) return v0; } -BOOL ov6_022472E8(FieldTask *taskMan) +BOOL ov6_022472E8(FieldTask *task) { int v0; - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(task); do { - v0 = Unk_ov6_022495BC[v2->unk_00](taskMan, fieldSystem, v2); + v0 = Unk_ov6_022495BC[v2->unk_00](task, fieldSystem, v2); if (v0 == 2) { ov6_0224732C(fieldSystem, v2); @@ -211,7 +211,7 @@ static void ov6_0224732C(FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param Journal_SaveData(fieldSystem->journal, v0, 1); } -static int ov6_02247354(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247354(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (param2->unk_08 == 2) { StartScreenTransition(0, 1, 1, 0x0, 6, 1, 4); @@ -227,7 +227,7 @@ static int ov6_02247354(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 0; } -static int ov6_022473C8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022473C8(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 1) { MapObject_FinishAnimation(param2->unk_0C); @@ -244,7 +244,7 @@ static int ov6_022473C8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 1; } -static int ov6_0224740C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224740C(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -264,7 +264,7 @@ static int ov6_0224740C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 0; } -static int ov6_02247458(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_02247458(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (MapObject_HasAnimationEnded(param2->unk_0C) == 0) { return 0; @@ -299,14 +299,14 @@ void *ov6_02247488(FieldSystem *fieldSystem, Pokemon *param1, u32 param2) return v0; } -BOOL ov6_022474AC(FieldTask *taskMan) +BOOL ov6_022474AC(FieldTask *task) { int v0; - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(task); do { - v0 = Unk_ov6_022495F0[v2->unk_00](taskMan, fieldSystem, v2); + v0 = Unk_ov6_022495F0[v2->unk_00](task, fieldSystem, v2); if (v0 == 2) { Heap_FreeToHeap(v2); @@ -316,7 +316,7 @@ BOOL ov6_022474AC(FieldTask *taskMan) return 0; } -static int ov6_022474E8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_022474E8(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { int v0 = PlayerAvatar_Gender(fieldSystem->playerAvatar); @@ -326,7 +326,7 @@ static int ov6_022474E8(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ return 0; } -static int ov6_0224750C(FieldTask *taskMan, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) +static int ov6_0224750C(FieldTask *task, FieldSystem *fieldSystem, UnkStruct_ov6_02247100 *param2) { if (ov6_02243FBC(param2->unk_10) == 0) { return 0; @@ -358,14 +358,14 @@ void *ov6_02247530(FieldSystem *fieldSystem, Pokemon *param1, u32 param2) return v0; } -BOOL ov6_02247554(FieldTask *taskMan) +BOOL ov6_02247554(FieldTask *task) { int v0; - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_ov6_02247100 *v2 = FieldTask_GetEnv(task); do { - v0 = Unk_ov6_022495F0[v2->unk_00](taskMan, fieldSystem, v2); + v0 = Unk_ov6_022495F0[v2->unk_00](task, fieldSystem, v2); if (v0 == 2) { Heap_FreeToHeap(v2); diff --git a/src/overlay023/ov23_022521F0.c b/src/overlay023/ov23_022521F0.c index 6d3fce9a29..525f694aef 100644 --- a/src/overlay023/ov23_022521F0.c +++ b/src/overlay023/ov23_022521F0.c @@ -937,17 +937,17 @@ void ov23_022534A0(FieldSystem *fieldSystem) ov23_022431EC(v4, v4->unk_04, ov23_02251270); { - int v8, v9; - const ObjectEvent *v10; - MapObject *v11; + int objEventCount, i; + const ObjectEvent *objEventList; + MapObject *mapObj; - v8 = MapHeaderData_GetNumObjectEvents(v4->fieldSystem); - v10 = MapHeaderData_GetObjectEvents(v4->fieldSystem); + objEventCount = MapHeaderData_GetNumObjectEvents(v4->fieldSystem); + objEventList = MapHeaderData_GetObjectEvents(v4->fieldSystem); - for (v9 = 0; v9 < v8; v9++) { - if ((v10[v9].x == v1) && (v10[v9].z == v2)) { - v11 = MapObjMan_LocalMapObjByIndex(v4->fieldSystem->mapObjMan, v9); - MapObject_SetDir(v11, v3); + for (i = 0; i < objEventCount; i++) { + if (objEventList[i].x == v1 && objEventList[i].z == v2) { + mapObj = MapObjMan_LocalMapObjByIndex(v4->fieldSystem->mapObjMan, i); + MapObject_SetDir(mapObj, v3); } } } diff --git a/src/scrcmd.c b/src/scrcmd.c index 83ed723696..56f89d9a5c 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -4631,8 +4631,8 @@ static BOOL ScrCmd_204(ScriptContext *ctx) static BOOL ScrCmd_200(ScriptContext *ctx) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); - Location *location = FieldOverworldState_GetPrevLocation(v0); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + Location *location = FieldOverworldState_GetPrevLocation(fieldState); u16 *mapId = ScriptContext_GetVarPointer(ctx); *mapId = location->mapId; @@ -4692,20 +4692,20 @@ static BOOL ScrCmd_0C2(ScriptContext *ctx) static BOOL ScrCmd_0C3(ScriptContext *ctx) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); - FieldOverworldState_SetWeather(v0, OVERWORLD_WEATHER_CLEAR); - ov5_021D5F7C(ctx->fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(v0)); + FieldOverworldState_SetWeather(fieldState, OVERWORLD_WEATHER_CLEAR); + ov5_021D5F7C(ctx->fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState)); return 1; } static BOOL ScrCmd_0C4(ScriptContext *ctx) { - FieldOverworldState *v0 = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); - FieldOverworldState_SetWeather(v0, OVERWORLD_WEATHER_CLEAR); - ov5_021D5F7C(ctx->fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(v0)); + FieldOverworldState_SetWeather(fieldState, OVERWORLD_WEATHER_CLEAR); + ov5_021D5F7C(ctx->fieldSystem->unk_04->unk_0C, FieldOverworldState_GetWeather(fieldState)); return 1; } @@ -4753,14 +4753,14 @@ static BOOL ScrCmd_SetPlayerBike(ScriptContext *ctx) u8 rideBike = ScriptContext_ReadByte(ctx); if (rideBike == TRUE) { - sub_020553F0(ctx->fieldSystem, 1152); + Sound_SetSpecialBGM(ctx->fieldSystem, 1152); sub_02055554(ctx->fieldSystem, 1152, 1); PlayerAvatar_SetRequestStateBit(ctx->fieldSystem->playerAvatar, (1 << 1)); PlayerAvatar_RequestChangeState(ctx->fieldSystem->playerAvatar); } else { PlayerAvatar_SetRequestStateBit(ctx->fieldSystem->playerAvatar, (1 << 0)); PlayerAvatar_RequestChangeState(ctx->fieldSystem->playerAvatar); - sub_020553F0(ctx->fieldSystem, 0); + Sound_SetSpecialBGM(ctx->fieldSystem, 0); sub_02055554(ctx->fieldSystem, sub_02055428(ctx->fieldSystem, ctx->fieldSystem->location->mapId), 1); } @@ -4769,7 +4769,7 @@ static BOOL ScrCmd_SetPlayerBike(ScriptContext *ctx) static BOOL ScrCmd_2BF(ScriptContext *ctx) { - sub_020553F0(ctx->fieldSystem, 1189); + Sound_SetSpecialBGM(ctx->fieldSystem, 1189); return 0; } @@ -6376,13 +6376,13 @@ static BOOL ScrCmd_202(ScriptContext *ctx) { u16 *v0; u16 *v1; - FieldOverworldState *v2 = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); VarsFlags *v3 = SaveData_GetVarsFlags(ctx->fieldSystem->saveData); TVBroadcast *v4 = SaveData_TVBroadcast(ctx->fieldSystem->saveData); int v5 = ScriptContext_ReadByte(ctx); - v0 = sub_0203A784(v2); - v1 = sub_0203A788(v2); + v0 = FieldOverworldState_GetSafariBallCount(fieldState); + v1 = FieldOverworldState_GetSafariStepCount(fieldState); switch (v5) { case 0: @@ -7693,8 +7693,8 @@ static BOOL ScrCmd_2B5(ScriptContext *ctx) u16 mapId = ScriptContext_GetVar(ctx); u16 v1 = ScriptContext_GetVar(ctx); u16 v2 = ScriptContext_GetVar(ctx); - FieldOverworldState *v3 = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); - Location *location = sub_0203A72C(v3); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(ctx->fieldSystem->saveData); + Location *location = FieldOverworldState_GetExitLocation(fieldState); location->mapId = mapId; location->x = v1; diff --git a/src/unk_020482D4.c b/src/unk_020482D4.c index 2b3b7e5cb0..8c7ac51eee 100644 --- a/src/unk_020482D4.c +++ b/src/unk_020482D4.c @@ -68,7 +68,7 @@ BOOL ScrCmd_PlayDefaultMusic(ScriptContext *ctx) BOOL ScrCmd_053(ScriptContext *param0) { - sub_020553F0(param0->fieldSystem, ScriptContext_ReadHalfWord(param0)); + Sound_SetSpecialBGM(param0->fieldSystem, ScriptContext_ReadHalfWord(param0)); return 0; } diff --git a/src/unk_0204B830.c b/src/unk_0204B830.c index 5c66d666a8..dde7bed166 100644 --- a/src/unk_0204B830.c +++ b/src/unk_0204B830.c @@ -3,6 +3,7 @@ #include #include +#include "constants/heap.h" #include "constants/species.h" #include "struct_decls/struct_party_decl.h" @@ -155,7 +156,7 @@ static BOOL sub_0204BA50(FieldSystem *fieldSystem, void *param1) static void sub_0204BA68(FieldSystem *fieldSystem, void *param1) { - sub_02054930(32, fieldSystem->saveData, 490, 1, 2, 1); + sub_02054930(HEAP_ID_FIELD_TASK, fieldSystem->saveData, 490, 1, 2, 1); } static void sub_0204BA88(UnkStruct_0204B830 *param0, u16 *param1, u16 *param2) diff --git a/src/unk_0204CFFC.c b/src/unk_0204CFFC.c index 145b3e6126..f5e859a434 100644 --- a/src/unk_0204CFFC.c +++ b/src/unk_0204CFFC.c @@ -3,6 +3,8 @@ #include #include +#include "constants/heap.h" + #include "struct_decls/struct_020797DC_decl.h" #include "struct_decls/struct_party_decl.h" @@ -39,7 +41,7 @@ BOOL ScrCmd_096(ScriptContext *param0) u16 *v7 = ScriptContext_GetVarPointer(param0); v2 = Party_GetFromSavedata(fieldSystem->saveData); - *v7 = sub_020548B0(11, fieldSystem->saveData, v4, v5, v6, v0, v1); + *v7 = sub_020548B0(HEAP_ID_FIELDMAP, fieldSystem->saveData, v4, v5, v6, v0, v1); return 0; } diff --git a/src/unk_020528D0.c b/src/unk_020528D0.c index a8b9d2c47d..ef8b236703 100644 --- a/src/unk_020528D0.c +++ b/src/unk_020528D0.c @@ -45,8 +45,8 @@ typedef struct { StringTemplate *unk_20; } UnkStruct_02052AA4; -static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1); -static BOOL sub_020529C4(FieldTask *param0); +static void sub_02052914(FieldSystem *fieldSystem, FieldTask *task); +static BOOL sub_020529C4(FieldTask *task); static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 param3); static const WindowTemplate Unk_020EC2F0 = { @@ -101,11 +101,9 @@ static void sub_020528D0(BgConfig *param0) Graphics_LoadPalette(14, 6, 0, 13 * 0x20, 0x20, 11); } -static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1) +static void sub_02052914(FieldSystem *fieldSystem, FieldTask *task) { - UnkStruct_02052AA4 *v0; - - v0 = Heap_AllocFromHeap(11, sizeof(UnkStruct_02052AA4)); + UnkStruct_02052AA4 *v0 = Heap_AllocFromHeap(11, sizeof(UnkStruct_02052AA4)); if (v0 == NULL) { GF_ASSERT(FALSE); @@ -132,14 +130,14 @@ static void sub_02052914(FieldSystem *fieldSystem, FieldTask *param1) } Window_CopyToVRAM(&v0->unk_0C); - FieldTask_InitCall(param1, sub_020529C4, v0); + FieldTask_InitCall(task, sub_020529C4, v0); return; } -static BOOL sub_020529C4(FieldTask *param0) +static BOOL sub_020529C4(FieldTask *task) { - UnkStruct_02052AA4 *v0 = FieldTask_GetEnv(param0); + UnkStruct_02052AA4 *v0 = FieldTask_GetEnv(task); switch (v0->unk_00) { case 0: @@ -199,15 +197,12 @@ static void sub_02052AA4(UnkStruct_02052AA4 *param0, u16 param1, u8 param2, u8 p return; } -BOOL sub_02052B2C(FieldTask *param0) +BOOL sub_02052B2C(FieldTask *task) { - FieldSystem *fieldSystem; - int *v1; - - fieldSystem = FieldTask_GetFieldSystem(param0); - v1 = FieldTask_GetState(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + int *state = FieldTask_GetState(task); - switch (*v1) { + switch (*state) { case 0: { if ((fieldSystem != NULL) && (fieldSystem->saveData != NULL)) { Party_SetGiratinaForm(Party_GetFromSavedata(fieldSystem->saveData), 0); @@ -215,48 +210,48 @@ BOOL sub_02052B2C(FieldTask *param0) } { - Location v2; - FieldOverworldState *v3 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - u16 v4 = FieldOverworldState_GetWarpId(v3); + Location location; + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); + u16 warpId = FieldOverworldState_GetWarpId(fieldState); - sub_0203A824(v4, &v2); - sub_0203A7F0(v4, sub_0203A72C(v3)); - FieldTask_ChangeMapByLocation(param0, &v2); + sub_0203A824(warpId, &location); + sub_0203A7F0(warpId, FieldOverworldState_GetExitLocation(fieldState)); + FieldTask_ChangeMapByLocation(task, &location); sub_020705B4(fieldSystem); } - (*v1)++; + (*state)++; break; case 1: sub_0200564C(0, 20); - (*v1)++; + (*state)++; break; case 2: if (Sound_CheckFade() == 0) { sub_020553DC(); - (*v1)++; + (*state)++; } break; case 3: sub_0200AB4C(-16, ((GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD) ^ GX_BLEND_PLANEMASK_BG3), 1); sub_0200AB4C(-16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 2); - sub_02052914(fieldSystem, param0); - (*v1)++; + sub_02052914(fieldSystem, task); + (*state)++; break; case 4: - FieldTransition_StartMap(param0); - (*v1)++; + FieldTransition_StartMap(task); + (*state)++; break; case 5: sub_0200AB4C(0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 3); if (sub_0203A7EC() == FieldOverworldState_GetWarpId(SaveData_GetFieldOverworldState(fieldSystem->saveData))) { - ScriptManager_Start(param0, 2020, NULL, NULL); + ScriptManager_Start(task, 2020, NULL, NULL); } else { - ScriptManager_Start(param0, 2021, NULL, NULL); + ScriptManager_Start(task, 2021, NULL, NULL); } - (*v1)++; + (*state)++; break; case 6: return 1; @@ -265,7 +260,7 @@ BOOL sub_02052B2C(FieldTask *param0) return 0; } -void sub_02052C5C(FieldTask *param0) +void sub_02052C5C(FieldTask *task) { - FieldTask_InitCall(param0, sub_02052B2C, NULL); + FieldTask_InitCall(task, sub_02052B2C, NULL); } diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index bfc2ba29ac..cc3824b04c 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -184,7 +184,7 @@ void sub_02052E58(FieldTask *param0) v3 = SaveData_GetVarsFlags(fieldSystem->saveData); v4 = SaveData_GetTrainerInfo(fieldSystem->saveData); v1 = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - v2 = sub_0203A72C(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + v2 = FieldOverworldState_GetExitLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); v5->unk_00 = SystemFlag_CheckGameCompleted(v3); v5->unk_04.unk_00 = SaveData_GetTrainerInfo(fieldSystem->saveData); diff --git a/src/unk_02054884.c b/src/unk_02054884.c index 6f3147480f..355caf4d9e 100644 --- a/src/unk_02054884.c +++ b/src/unk_02054884.c @@ -4,6 +4,8 @@ #include #include "constants/battle/condition.h" +#include "constants/field_poison.h" +#include "constants/heap.h" #include "constants/items.h" #include "struct_decls/struct_party_decl.h" @@ -29,57 +31,56 @@ BOOL Pokemon_CanBattle(Pokemon *mon) return !Pokemon_GetValue(mon, MON_DATA_IS_EGG, NULL); } -BOOL sub_020548B0(int param0, SaveData *param1, u16 param2, u8 param3, u16 param4, int param5, int param6) +BOOL sub_020548B0(int heapID, SaveData *saveData, u16 param2, u8 param3, u16 param4, int param5, int param6) { - BOOL v0; - Pokemon *v1; + BOOL result; + Pokemon *mon; u32 v2; - Party *v3; - TrainerInfo *v4; + Party *party; + TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(saveData); - v4 = SaveData_GetTrainerInfo(param1); - v3 = Party_GetFromSavedata(param1); - v1 = Pokemon_New(param0); + party = Party_GetFromSavedata(saveData); + mon = Pokemon_New(heapID); - Pokemon_Init(v1); - Pokemon_InitWith(v1, param2, param3, 32, FALSE, 0, OTID_NOT_SET, 0); - Pokemon_SetCatchData(v1, v4, ITEM_POKE_BALL, param5, param6, param0); + Pokemon_Init(mon); + Pokemon_InitWith(mon, param2, param3, 32, FALSE, 0, OTID_NOT_SET, 0); + Pokemon_SetCatchData(mon, trainerInfo, ITEM_POKE_BALL, param5, param6, heapID); v2 = param4; - Pokemon_SetValue(v1, MON_DATA_HELD_ITEM, &v2); - v0 = Party_AddPokemon(v3, v1); + Pokemon_SetValue(mon, MON_DATA_HELD_ITEM, &v2); + result = Party_AddPokemon(party, mon); - if (v0) { - sub_0202F180(param1, v1); + if (result) { + sub_0202F180(saveData, mon); } - Heap_FreeToHeap(v1); + Heap_FreeToHeap(mon); - return v0; + return result; } -BOOL sub_02054930(int param0, SaveData *param1, u16 param2, u8 param3, int param4, int param5) +BOOL sub_02054930(int unused, SaveData *saveData, u16 param2, u8 param3, int param4, int param5) { int v0; - BOOL v1; - TrainerInfo *v2 = SaveData_GetTrainerInfo(param1); - Party *v3 = Party_GetFromSavedata(param1); - Pokemon *v4 = Pokemon_New(32); + BOOL result; + TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(saveData); + Party *party = Party_GetFromSavedata(saveData); + Pokemon *mon = Pokemon_New(HEAP_ID_FIELD_TASK); - Pokemon_Init(v4); + Pokemon_Init(mon); v0 = sub_02017070(param4, param5); - ov5_021E6CF0(v4, param2, param3, v2, 4, v0); + ov5_021E6CF0(mon, param2, param3, trainerInfo, 4, v0); - v1 = Party_AddPokemon(v3, v4); - Heap_FreeToHeap(v4); + result = Party_AddPokemon(party, mon); + Heap_FreeToHeap(mon); - return v1; + return result; } -void sub_02054988(Party *param0, int param1, int param2, u16 param3) +void sub_02054988(Party *party, int param1, int param2, u16 param3) { - Pokemon_ResetMoveSlot(Party_GetPokemonBySlotIndex(param0, param1), param3, param2); + Pokemon_ResetMoveSlot(Party_GetPokemonBySlotIndex(party, param1), param3, param2); } // In many of the functions below, C99-style iterator declaration doesn't match @@ -175,44 +176,41 @@ void Party_GiveChampionRibbons(Party *party) } } -int sub_02054B04(Party *param0, u16 param1) +int Pokemon_DoPoisonDamage(Party *party, u16 mapLabelTextID) { - int v0 = 0; - int v1 = 0; - int v2, v3; - Pokemon *v4; + int numPoisoned = 0; + int numFainted = 0; + int i, partyCount = Party_GetCurrentCount(party); + Pokemon *mon; - v3 = Party_GetCurrentCount(param0); - - for (v2 = 0; v2 < v3; v2++) { - v4 = Party_GetPokemonBySlotIndex(param0, v2); - - if (Pokemon_CanBattle(v4)) { - if (Pokemon_GetValue(v4, MON_DATA_STATUS_CONDITION, NULL) & (MON_CONDITION_TOXIC | MON_CONDITION_POISON)) { - u32 v5 = Pokemon_GetValue(v4, MON_DATA_CURRENT_HP, NULL); + for (i = 0; i < partyCount; i++) { + mon = Party_GetPokemonBySlotIndex(party, i); - if (v5 > 1) { - v5--; - } + if (Pokemon_CanBattle(mon) + && (Pokemon_GetValue(mon, MON_DATA_STATUS_CONDITION, NULL) & (MON_CONDITION_TOXIC | MON_CONDITION_POISON))) { + u32 hp = Pokemon_GetValue(mon, MON_DATA_CURRENT_HP, NULL); - Pokemon_SetValue(v4, MON_DATA_CURRENT_HP, &v5); + if (hp > 1) { + hp--; + } - if (v5 == 1) { - v1++; - Pokemon_UpdateFriendship(v4, 7, param1); - } + Pokemon_SetValue(mon, MON_DATA_CURRENT_HP, &hp); - v0++; + if (hp == 1) { + numFainted++; + Pokemon_UpdateFriendship(mon, 7, mapLabelTextID); } + + numPoisoned++; } } - if (v1) { - return 2; - } else if (v0) { - return 1; + if (numFainted) { + return FLDPSN_FAINTED; + } else if (numPoisoned) { + return FLDPSN_POISONED; } else { - return 0; + return FLDPSN_NONE; } } diff --git a/src/unk_020553DC.c b/src/unk_020553DC.c index ceb2e37537..4f76e5c83d 100644 --- a/src/unk_020553DC.c +++ b/src/unk_020553DC.c @@ -115,39 +115,34 @@ void sub_020553DC() sub_0200569C(); sub_02004A3C(); sub_02004234(0); - - return; } -void sub_020553F0(FieldSystem *fieldSystem, u16 param1) +void Sound_SetSpecialBGM(FieldSystem *fieldSystem, u16 sdatID) { - u16 *v0 = sub_0203A748(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - *v0 = param1; - return; + *bgm = sdatID; } -u16 sub_02055404(FieldSystem *fieldSystem) +u16 Sound_GetSpecialBGM(FieldSystem *fieldSystem) { - u16 *v0 = sub_0203A748(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - return *v0; + u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + return *bgm; } void Sound_ClearSpecialBGM(FieldSystem *fieldSystem) { - u16 *v0 = sub_0203A748(SaveData_GetFieldOverworldState(fieldSystem->saveData)); + u16 *bgm = FieldOverworldState_GetSpecialBGM(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - *v0 = 0; - return; + *bgm = 0; } u16 sub_02055428(FieldSystem *fieldSystem, int param1) { - PlayerAvatar *playerAvatar; + PlayerAvatar *playerAvatar = fieldSystem->playerAvatar; int v1; u16 v2, v3; - playerAvatar = fieldSystem->playerAvatar; v1 = PlayerAvatar_GetPlayerState(playerAvatar); if (v1 == 0x2) { @@ -174,8 +169,8 @@ u16 sub_02055428(FieldSystem *fieldSystem, int param1) v2 = sub_020554A4(fieldSystem, param1); - if (sub_02055404(fieldSystem) != 0) { - v2 = sub_02055404(fieldSystem); + if (Sound_GetSpecialBGM(fieldSystem) != 0) { + v2 = Sound_GetSpecialBGM(fieldSystem); } return v2; @@ -208,27 +203,27 @@ u16 sub_020554A4(FieldSystem *fieldSystem, int headerID) static u16 sub_020554E8(FieldSystem *fieldSystem, int param1) { - int v0, v1; - FieldOverworldState *v2 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - Location *location = FieldOverworldState_GetPrevLocation(v2); + int x, y; + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); + Location *location = FieldOverworldState_GetPrevLocation(fieldState); - v0 = Player_GetXPos(fieldSystem->playerAvatar); - v1 = Player_GetZPos(fieldSystem->playerAvatar); + x = Player_GetXPos(fieldSystem->playerAvatar); + y = Player_GetZPos(fieldSystem->playerAvatar); if (param1 != 350) { return 0; } if ((location->mapId == 80) || (location->mapId == 351)) { - if (v0 < 299) { + if (x < 299) { return 0; } - if (v0 > 306) { + if (x > 306) { return 0; } - if ((v1 == 576) || (v1 == 681)) { + if ((y == 576) || (y == 681)) { return 1189; } } @@ -284,21 +279,16 @@ static void sub_020555CC(FieldSystem *fieldSystem, int param1, int *param2, int *param3 = 0; break; } - - return; } u16 sub_0205560C(int param0) { - u8 v0; - u16 v1, v2; - - v0 = (u8)TrainerData_LoadParam(param0, 1); - v1 = 1101; + u8 v0 = (u8)TrainerData_LoadParam(param0, 1); + u16 i, v1 = 1101; - for (v2 = 0; v2 < 79; v2++) { - if (Unk_020EC3E0[v2][0] == v0) { - v1 = Unk_020EC3E0[v2][1]; + for (i = 0; i < 79; i++) { + if (Unk_020EC3E0[i][0] == v0) { + v1 = Unk_020EC3E0[i][1]; break; } } @@ -315,8 +305,6 @@ void Sound_TryFadeInBGM(FieldSystem *fieldSystem, int param1) if (sub_020041FC() != sub_020554A4(fieldSystem, param1)) { sub_0200564C(0, 40); } - - return; } void Sound_PlayMapBGM(FieldSystem *fieldSystem, int param1) @@ -333,18 +321,12 @@ void Sound_PlayMapBGM(FieldSystem *fieldSystem, int param1) sub_02004224(v0); sub_02004550(4, v0, 1); - - return; } void sub_020556A0(FieldSystem *fieldSystem, int param1) { - u16 v0; - - v0 = sub_02055428(fieldSystem, param1); + u16 v0 = sub_02055428(fieldSystem, param1); sub_02004224(sub_020554A4(fieldSystem, param1)); sub_02004550(4, v0, 1); - - return; } diff --git a/src/unk_020683F4.c b/src/unk_020683F4.c index 3d90c31b09..29b68334d0 100644 --- a/src/unk_020683F4.c +++ b/src/unk_020683F4.c @@ -157,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(FieldTask *param0); -static BOOL sub_02068F48(FieldTask *param0); +static BOOL sub_02068884(FieldTask *task); +static BOOL sub_02068F48(FieldTask *task); static void sub_020693F8(UnkStruct_02068870 *param0, UnkFuncPtr_02068870 param1); -static BOOL sub_0206932C(FieldTask *param0); -static BOOL sub_020690F0(FieldTask *param0); -static BOOL sub_020685AC(FieldTask *param0); +static BOOL sub_0206932C(FieldTask *task); +static BOOL sub_020690F0(FieldTask *task); +static BOOL sub_020685AC(FieldTask *task); static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1); static const UnkStruct_020EF79C Unk_020EF79C[] = { @@ -301,17 +301,17 @@ static void sub_02068584(UnkStruct_02068870 *param0, u32 param1) FieldSystem_CreateTask(param0->fieldSystem, sub_020685AC, v0); } -static BOOL sub_020685AC(FieldTask *taskMan) +static BOOL sub_020685AC(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan); - UnkStruct_0206851C *v1 = FieldTask_GetEnv(taskMan); - int *v2 = FieldTask_GetState(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_0206851C *v1 = FieldTask_GetEnv(task); + int *v2 = FieldTask_GetState(task); MapObject *v3; switch (*v2) { case 0: sub_0203C9D4(fieldSystem, &v3); - ScriptManager_Start(taskMan, v1->unk_00, v3, NULL); + ScriptManager_Start(task, v1->unk_00, v3, NULL); *(u16 *)FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_DATA_PARAMETER_0) = v1->unk_04; *(u16 *)FieldSystem_GetScriptMemberPtr(fieldSystem, SCRIPT_DATA_PARAMETER_1) = v1->unk_06; @@ -473,17 +473,14 @@ static BOOL sub_02068870(UnkStruct_02068870 *param0) return 0; } -static BOOL sub_02068884(FieldTask *param0) +static BOOL sub_02068884(FieldTask *task) { - FieldSystem *fieldSystem; - int *v1; - - fieldSystem = FieldTask_GetFieldSystem(param0); - v1 = FieldTask_GetState(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + int *state = FieldTask_GetState(task); - switch (*v1) { + switch (*state) { case 0: - (*v1)++; + (*state)++; break; case 1: if (PlayerAvatar_GetPlayerState(fieldSystem->playerAvatar) == 0x1) { @@ -491,11 +488,11 @@ static BOOL sub_02068884(FieldTask *param0) PlayerAvatar_SetRequestStateBit(fieldSystem->playerAvatar, (1 << 0)); PlayerAvatar_RequestChangeState(fieldSystem->playerAvatar); - sub_020553F0(fieldSystem, 0); + Sound_SetSpecialBGM(fieldSystem, 0); sub_02055554( fieldSystem, sub_02055428(fieldSystem, fieldSystem->location->mapId), 1); } else { - sub_020553F0(fieldSystem, 1152); + Sound_SetSpecialBGM(fieldSystem, 1152); sub_02055554(fieldSystem, 1152, 1); sub_02062DDC(Player_MapObject(fieldSystem->playerAvatar)); @@ -505,10 +502,10 @@ static BOOL sub_02068884(FieldTask *param0) RadarChain_Clear(fieldSystem->chain); } - (*v1)++; + (*state)++; break; case 2: - (*v1)++; + (*state)++; break; case 3: MapObjectMan_UnpauseAllMovement(fieldSystem->mapObjMan); @@ -940,13 +937,10 @@ static BOOL sub_02068EFC(UnkStruct_02068870 *param0) return 0; } -static BOOL sub_02068F48(FieldTask *param0) +static BOOL sub_02068F48(FieldTask *task) { - FieldSystem *fieldSystem; - UnkStruct_02068EFC *v1; - - fieldSystem = FieldTask_GetFieldSystem(param0); - v1 = FieldTask_GetEnv(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_02068EFC *v1 = FieldTask_GetEnv(task); switch (v1->unk_16) { case 0: @@ -1039,12 +1033,12 @@ static u32 sub_020690C4(const UnkStruct_020684D0 *param0) return -1; } -static BOOL sub_020690F0(FieldTask *param0) +static BOOL sub_020690F0(FieldTask *task) { - FieldSystem *fieldSystem = FieldTask_GetFieldSystem(param0); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); void *v1 = ov6_02247100(fieldSystem, 11); - FieldTask_InitJump(param0, ov6_02247120, v1); + FieldTask_InitJump(task, ov6_02247120, v1); return 0; } @@ -1200,13 +1194,10 @@ static void sub_020692E4(UnkStruct_02068870 *param0, u32 param1) FieldSystem_CreateTask(param0->fieldSystem, sub_02068F48, v0); } -static BOOL sub_0206932C(FieldTask *taskMan) +static BOOL sub_0206932C(FieldTask *task) { - FieldSystem *fieldSystem; - UnkStruct_02068870 *v1; - - fieldSystem = FieldTask_GetFieldSystem(taskMan); - v1 = FieldTask_GetEnv(taskMan); + FieldSystem *fieldSystem = FieldTask_GetFieldSystem(task); + UnkStruct_02068870 *v1 = FieldTask_GetEnv(task); switch (v1->unk_2A) { case 0: diff --git a/src/unk_0206AFE0.c b/src/unk_0206AFE0.c index ceaeb27182..2b86eb7b78 100644 --- a/src/unk_0206AFE0.c +++ b/src/unk_0206AFE0.c @@ -32,15 +32,15 @@ static BOOL sub_0206AFE0(VarsFlags *param0, u16 param1, u16 param2) if ((param1 < VARS_START) || (param1 > SPECIAL_VARS_START)) { GF_ASSERT(FALSE); - return 0; + return FALSE; } if (v0 == NULL) { - return 0; + return FALSE; } *v0 = param2; - return 1; + return TRUE; } static u16 sub_0206B010(VarsFlags *param0, u16 param1) @@ -162,11 +162,7 @@ void sub_0206B144(VarsFlags *param0, int param1) BOOL sub_0206B16C(VarsFlags *param0, int param1) { - if (sub_0206B010(param0, (19 + (((0 + VARS_START) + 32) + 16)) + param1) == sub_0206B128(param1)) { - return 1; - } else { - return 0; - } + return sub_0206B010(param0, (19 + (((0 + VARS_START) + 32) + 16)) + param1) == sub_0206B128(param1); } static int sub_0206B194(int param0) @@ -194,11 +190,7 @@ void sub_0206B1D8(VarsFlags *param0, int param1) BOOL VarFlags_HiddenLocationsUnlocked(VarsFlags *varFlags, int hiddenLocation) { - if (sub_0206B010(varFlags, (6 + (((0 + VARS_START) + 32) + 16)) + hiddenLocation) == sub_0206B194(hiddenLocation)) { - return 1; - } else { - return 0; - } + return sub_0206B010(varFlags, (6 + (((0 + VARS_START) + 32) + 16)) + hiddenLocation) == sub_0206B194(hiddenLocation); } BOOL sub_0206B218(VarsFlags *param0) @@ -213,9 +205,7 @@ u16 sub_0206B228(VarsFlags *param0) BOOL sub_0206B238(VarsFlags *param0) { - u16 v0; - - v0 = sub_0206B010(param0, (10 + (((0 + VARS_START) + 32) + 16))); + u16 v0 = sub_0206B010(param0, (10 + (((0 + VARS_START) + 32) + 16))); if (v0 < 10000) { v0++; @@ -238,30 +228,24 @@ BOOL sub_0206B270(VarsFlags *param0, u16 param1) void sub_0206B280(VarsFlags *param0, u32 param1) { - u16 v0, v1; - - v1 = (param1 >> 16) & 0xffff; - v0 = param1 & 0xffff; + u16 v1 = (param1 >> 16) & 0xffff; + u16 v0 = param1 & 0xffff; sub_0206AFE0(param0, (12 + (((0 + VARS_START) + 32) + 16)), v0); sub_0206AFE0(param0, (12 + (((0 + VARS_START) + 32) + 16)), v1); } u32 sub_0206B2A4(VarsFlags *param0) { - u16 v0, v1; - - v0 = sub_0206B010(param0, (12 + (((0 + VARS_START) + 32) + 16))); - v1 = sub_0206B010(param0, (13 + (((0 + VARS_START) + 32) + 16))); + u16 v0 = sub_0206B010(param0, (12 + (((0 + VARS_START) + 32) + 16))); + u16 v1 = sub_0206B010(param0, (13 + (((0 + VARS_START) + 32) + 16))); return (v1 << 16) | v0; } void sub_0206B2C8(VarsFlags *param0) { - u16 v0, v1; - - v0 = LCRNG_Next(); - v1 = LCRNG_Next(); + u16 v0 = LCRNG_Next(); + u16 v1 = LCRNG_Next(); sub_0206B280(param0, (v1 << 16) | v0); } @@ -269,10 +253,7 @@ void sub_0206B2C8(VarsFlags *param0) void sub_0206B2E4(SaveData *param0, u16 param1) { VarsFlags *v0 = SaveData_GetVarsFlags(param0); - u32 v1; - - v1 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0)); - v1 = v1 * 1103515245L + 12345; + u32 v1 = RecordMixedRNG_GetRand(SaveData_GetRecordMixedRNG(param0)) * 1103515245L + 12345; sub_0206B280(v0, v1); } @@ -290,18 +271,13 @@ BOOL sub_0206B324(VarsFlags *param0, u16 param1) void sub_0206B334(SaveData *param0) { VarsFlags *v0 = SaveData_GetVarsFlags(param0); - u32 v1; - - v1 = (LCRNG_Next() % 98) + 2; + u32 v1 = (LCRNG_Next() % 98) + 2; sub_0206B324(v0, v1); } u16 sub_0206B354(VarsFlags *param0) { - u16 v0; - - v0 = sub_0206B010(param0, (14 + (((0 + VARS_START) + 32) + 16))); - return v0; + return sub_0206B010(param0, (14 + (((0 + VARS_START) + 32) + 16))); } BOOL sub_0206B364(VarsFlags *param0, u16 param1) @@ -311,10 +287,7 @@ BOOL sub_0206B364(VarsFlags *param0, u16 param1) u16 sub_0206B374(VarsFlags *param0) { - u16 v0; - - v0 = sub_0206B010(param0, (25 + (((0 + VARS_START) + 32) + 16))); - return v0; + return sub_0206B010(param0, (25 + (((0 + VARS_START) + 32) + 16))); } BOOL sub_0206B384(VarsFlags *param0, u16 param1) @@ -324,10 +297,7 @@ BOOL sub_0206B384(VarsFlags *param0, u16 param1) u16 sub_0206B394(VarsFlags *param0) { - u16 v0; - - v0 = sub_0206B010(param0, (16 + (((0 + VARS_START) + 32) + 16))); - return v0; + return sub_0206B010(param0, (16 + (((0 + VARS_START) + 32) + 16))); } BOOL sub_0206B3A4(VarsFlags *param0, u16 param1) @@ -337,9 +307,7 @@ BOOL sub_0206B3A4(VarsFlags *param0, u16 param1) BOOL sub_0206B3B4(VarsFlags *param0) { - u16 v0; - - v0 = sub_0206B010(param0, (18 + (((0 + VARS_START) + 32) + 16))); + u16 v0 = sub_0206B010(param0, (18 + (((0 + VARS_START) + 32) + 16))); if (v0 < 10000) { v0++; @@ -425,9 +393,7 @@ static const u8 Unk_020EFA6C[] = { static u8 sub_0206B4A4(VarsFlags *param0) { int v0; - u16 v1, v2, v3; - - v1 = 0; + u16 v1 = 0, v2, v3; for (v0 = 0; v0 < VILLA_FURNITURE_MAX; v0++) { if (SystemFlag_HandleOwnsVillaFurniture(param0, HANDLE_FLAG_CHECK, v0) == TRUE) { @@ -455,10 +421,9 @@ static u8 sub_0206B4A4(VarsFlags *param0) void sub_0206B514(SaveData *param0) { - u32 v0; VarsFlags *v1 = SaveData_GetVarsFlags(param0); - FieldOverworldState *v2 = SaveData_GetFieldOverworldState(param0); - Location *location = FieldOverworldState_GetPlayerLocation(v2); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(param0); + Location *location = FieldOverworldState_GetPlayerLocation(fieldState); if ((location->mapId != MAP_HEADER_RESORT_AREA) && (location->mapId != MAP_HEADER_VILLA)) { SystemFlag_ClearVillaVisitorInside(v1); diff --git a/src/unk_0206B70C.c b/src/unk_0206B70C.c index 7cf3569566..3c7787f520 100644 --- a/src/unk_0206B70C.c +++ b/src/unk_0206B70C.c @@ -79,16 +79,16 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para int x, z, v6; UnkStruct_020556C4 *v7; VarsFlags *v8 = SaveData_GetVarsFlags(fieldSystem->saveData); - FieldOverworldState *v9 = SaveData_GetFieldOverworldState(fieldSystem->saveData); - Location *v10 = sub_0203A72C(v9); + FieldOverworldState *fieldState = SaveData_GetFieldOverworldState(fieldSystem->saveData); + Location *v10 = FieldOverworldState_GetExitLocation(fieldState); memset(param1, 0, sizeof(UnkStruct_0203D8AC)); x = Player_GetXPos(fieldSystem->playerAvatar); z = Player_GetZPos(fieldSystem->playerAvatar); - int v11 = 10 - 1; - Location *location = FieldOverworldState_GetPlayerLocation(v9); + int v11 = 9; + Location *location = FieldOverworldState_GetPlayerLocation(fieldState); v6 = location->mapId; @@ -153,7 +153,7 @@ void sub_0206B70C(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, int para static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, const char *param2) { FSFile v0; - int v1, v2; + int v1, i; int v3; UnkStruct_0206B878 *v4; UnkUnion_0206B878 *v5; @@ -174,8 +174,8 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c param1->unk_13A = v3; - for (v2 = 0; v2 < v3; v2++) { - v5 = &(param1->unk_5C[v2]); + for (i = 0; i < v3; i++) { + v5 = &(param1->unk_5C[i]); v1 = FS_ReadFile(&v0, v4, sizeof(UnkStruct_0206B878)); switch (v4->unk_00) { @@ -203,6 +203,4 @@ static void sub_0206B878(FieldSystem *fieldSystem, UnkStruct_0203D8AC *param1, c (void)FS_CloseFile(&v0); Heap_FreeToHeap(v4); - - return; }