From bed9a33a0a814f51b0c83ac2329aafec0b07f455 Mon Sep 17 00:00:00 2001 From: Rachel Date: Sun, 3 Nov 2024 22:54:32 -0800 Subject: [PATCH] Document known struct fields in FieldBattleDTO --- include/field_battle_data_transfer.h | 78 ++++++------ include/struct_defs/battle_system.h | 2 +- src/battle/ov16_0223B140.c | 106 ++++++++-------- src/battle/ov16_0223DF00.c | 10 +- src/encounter.c | 72 ++++++----- src/field_battle_data_transfer.c | 183 ++++++++++++++------------- src/overlay005/encounter_effect.c | 28 ++-- src/overlay006/ov6_02240C9C.c | 2 +- src/overlay006/ov6_02246034.c | 6 +- src/overlay010/ov10_0221F800.c | 16 +-- src/overlay104/ov104_022332B4.c | 2 +- src/overlay104/ov104_02234838.c | 2 +- src/overlay104/ov104_022358E8.c | 2 +- src/overlay104/ov104_02237378.c | 4 +- src/overlay104/ov104_02239130.c | 2 +- src/overlay104/ov104_0223A0C4.c | 6 +- src/overlay104/ov104_0223A7F4.c | 8 +- src/overlay104/ov104_0223AF58.c | 8 +- src/overlay104/ov104_0223B6F4.c | 8 +- src/overlay104/ov104_0223BCBC.c | 8 +- src/unk_0202F1D4.c | 93 +++++++------- src/unk_020562F8.c | 7 +- src/unk_0207A6DC.c | 20 +-- src/unk_0208BA78.c | 6 +- 24 files changed, 349 insertions(+), 330 deletions(-) diff --git a/include/field_battle_data_transfer.h b/include/field_battle_data_transfer.h index f8752fce4..01382ca30 100644 --- a/include/field_battle_data_transfer.h +++ b/include/field_battle_data_transfer.h @@ -1,6 +1,7 @@ #ifndef POKEPLATINUM_FIELD_BATTLE_DATA_TRANSFER_H #define POKEPLATINUM_FIELD_BATTLE_DATA_TRANSFER_H +#include "constants/battle.h" #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_02027F8C_decl.h" #include "struct_decls/struct_0202C878_decl.h" @@ -18,60 +19,61 @@ #include "game_records.h" #include "journal.h" #include "poketch_data.h" +#include "rtc.h" #include "savedata.h" #include "trainer_info.h" -typedef struct FieldBattleDTO_sub1 { - int unk_00; - int unk_04; - int unk_08; -} FieldBattleDTO_sub1; +typedef struct BattleRecords { + int totalTurns; + int totalFainted; + int totalDamage; +} BattleRecords; typedef struct FieldBattleDTO { u32 battleType; - Party *parties[4]; - int unk_14; - int trainerIDs[4]; - TrainerData trainerData[4]; - TrainerInfo *unk_D0[4]; - Bag *unk_E0; - BagCursor *unk_E4; - PokedexData *unk_E8; - PCBoxes *unk_EC; - ChatotCry *unk_F0[4]; + Party *parties[MAX_BATTLERS]; + int resultMask; + int trainerIDs[MAX_BATTLERS]; + TrainerData trainerData[MAX_BATTLERS]; + TrainerInfo *trainerInfo[MAX_BATTLERS]; + Bag *bag; + BagCursor *bagCursor; + PokedexData *pokedex; + PCBoxes *pcBoxes; + ChatotCry *chatotCries[MAX_BATTLERS]; PoketchData *poketchData; UnkStruct_0202C878 *unk_104; - Options *unk_108; + Options *options; UnkStruct_0206D140 *unk_10C; - FieldBattleDTO_sub1 unk_110; + BattleRecords battleRecords; GameRecords *records; - Journal *unk_120; + Journal *journal; UnkStruct_02027F8C *unk_124; - int unk_128; - int unk_12C; - int unk_130; + int background; + enum Terrain terrain; + int mapLabelTextID; int mapHeaderID; - int unk_138; - int unk_13C; - int unk_140; - int unk_144; - int unk_148; - int unk_14C; - int unk_150; - u32 unk_154[4]; - u32 unk_164; - int unk_168; - u32 unk_16C; + enum TimeOfDay timeOfDay; + int mapEvolutionMethod; + BOOL visitedContestHall; + BOOL metBebe; + int caughtBattlerIdx; + int fieldWeather; + int leveledUpMonsMask; + u32 systemVersion[MAX_BATTLERS]; + u32 battleStatusMask; + int countSafariBalls; + u32 rulesetMask; void *unk_170; - u32 unk_174; - int unk_178[4]; - u16 unk_188; + u32 seed; + int unk_178[MAX_BATTLERS]; + u16 networkID; u8 unk_18A; - u8 unk_18B; - int unk_18C; + u8 dummy18B; + int totalTurnsElapsed; UnkStruct_0209C370 *unk_190; u8 unk_194[4]; - SaveData *unk_198; + SaveData *saveData; u32 unk_19C; } FieldBattleDTO; diff --git a/include/struct_defs/battle_system.h b/include/struct_defs/battle_system.h index e4ae62124..b7fe3c058 100644 --- a/include/struct_defs/battle_system.h +++ b/include/struct_defs/battle_system.h @@ -88,7 +88,7 @@ struct BattleSystem { PokemonAnimationSys *unk_1C4; NNSG2dCellTransferState *cellTransferState; UnkStruct_ov16_0223E0C8 unk_1CC[4]; - FieldBattleDTO_sub1 unk_20C; + BattleRecords unusedBattleRecords; GameRecords *records; u8 *unk_21C; u16 *unk_220; diff --git a/src/battle/ov16_0223B140.c b/src/battle/ov16_0223B140.c index a99801939..8734399b2 100644 --- a/src/battle/ov16_0223B140.c +++ b/src/battle/ov16_0223B140.c @@ -173,7 +173,7 @@ BOOL Battle_Main(OverlayManager *param0, int *param1) case 0: Heap_Create(3, 5, 0xb0000); - if ((v0->battleType & BATTLE_TYPE_LINK) && ((v0->unk_164 & 0x10) == 0)) { + if ((v0->battleType & BATTLE_TYPE_LINK) && ((v0->battleStatusMask & BATTLE_STATUS_RECORDING) == 0)) { *param1 = 1; } else { *param1 = 3; @@ -268,7 +268,7 @@ BOOL Battle_Main(OverlayManager *param0, int *param1) if (v2) { Heap_Create(3, 73, 0x30000); v4 = Party_GetPokemonBySlotIndex(v0->parties[0], v1); - v0->unk_170 = sub_0207AE68(v0->parties[0], v4, v2, v0->unk_108, v0->unk_140, v0->unk_E8, v0->unk_E0, v0->records, v0->poketchData, v3, 0x1 | 0x2, 73); + v0->unk_170 = sub_0207AE68(v0->parties[0], v4, v2, v0->options, v0->visitedContestHall, v0->pokedex, v0->bag, v0->records, v0->poketchData, v3, 0x1 | 0x2, 73); *param1 = 14; } else { *param1 = 15; @@ -702,8 +702,8 @@ static void ov16_0223BCB4(OverlayManager *param0) FieldBattleDTO *v1 = OverlayManager_Args(param0); int v2; - v1->unk_174 = v0->unk_2448; - v1->unk_164 = v0->battleStatusMask; + v1->seed = v0->unk_2448; + v1->battleStatusMask = v0->battleStatusMask; if ((v0->battleStatusMask & 0x10) == 0) { sub_0202F8AC(v1); @@ -724,29 +724,29 @@ static void ov16_0223BCB4(OverlayManager *param0) for (v2 = 0; v2 < 4; v2++) { Party_cpy(v0->parties[v2], v1->parties[v2]); Heap_FreeToHeap(v0->parties[v2]); - TrainerInfo_Copy(v0->trainerInfo[v2], v1->unk_D0[v2]); + TrainerInfo_Copy(v0->trainerInfo[v2], v1->trainerInfo[v2]); Heap_FreeToHeap(v0->trainerInfo[v2]); } sub_02015760(v0->unk_1AC); - Bag_Copy(v0->unk_58, v1->unk_E0); + Bag_Copy(v0->unk_58, v1->bag); Heap_FreeToHeap(v0->unk_58); - sub_02026338(v0->pokedex, v1->unk_E8); + sub_02026338(v0->pokedex, v1->pokedex); Heap_FreeToHeap(v0->pokedex); - v1->unk_EC = v0->pcBoxes; - v1->unk_E4 = v0->unk_5C; + v1->pcBoxes = v0->pcBoxes; + v1->bagCursor = v0->unk_5C; v1->unk_190 = v0->unk_1BC; v1->poketchData = v0->poketchData; v1->unk_10C = v0->unk_9C; - v1->unk_168 = v0->safariBalls; - v1->unk_14 = v0->resultMask & (0xc0 ^ 0xff); - v1->unk_148 = v0->unk_2438; - v1->unk_150 = BattleContext_Get(v0, v0->battleCtx, 4, NULL); - v1->unk_110.unk_00 += BattleContext_Get(v0, v0->battleCtx, 3, NULL); - v1->unk_110.unk_04 += (BattleContext_Get(v0, v0->battleCtx, 6, 0) + BattleContext_Get(v0, v0->battleCtx, 6, 2)); - v1->unk_110.unk_08 += (BattleContext_Get(v0, v0->battleCtx, 7, 0) + BattleContext_Get(v0, v0->battleCtx, 7, 2)); - v1->unk_18C = BattleContext_Get(v0, v0->battleCtx, 3, NULL); + v1->countSafariBalls = v0->safariBalls; + v1->resultMask = v0->resultMask & (0xc0 ^ 0xff); + v1->caughtBattlerIdx = v0->unk_2438; + v1->leveledUpMonsMask = BattleContext_Get(v0, v0->battleCtx, 4, NULL); + v1->battleRecords.totalTurns += BattleContext_Get(v0, v0->battleCtx, 3, NULL); + v1->battleRecords.totalFainted += (BattleContext_Get(v0, v0->battleCtx, 6, 0) + BattleContext_Get(v0, v0->battleCtx, 6, 2)); + v1->battleRecords.totalDamage += (BattleContext_Get(v0, v0->battleCtx, 7, 0) + BattleContext_Get(v0, v0->battleCtx, 7, 2)); + v1->totalTurnsElapsed = BattleContext_Get(v0, v0->battleCtx, 3, NULL); v1->unk_19C = v0->unk_2474_0; for (v2 = 0; v2 < 4; v2++) { @@ -1067,43 +1067,43 @@ static void ov16_0223C2C0(BattleSystem *param0, FieldBattleDTO *param1) for (v0 = 0; v0 < 4; v0++) { param0->trainerInfo[v0] = TrainerInfo_New(5); - TrainerInfo_Copy(param1->unk_D0[v0], param0->trainerInfo[v0]); - param0->unk_78[v0] = param1->unk_F0[v0]; + TrainerInfo_Copy(param1->trainerInfo[v0], param0->trainerInfo[v0]); + param0->unk_78[v0] = param1->chatotCries[v0]; } - param0->unk_2442 = param1->unk_188; + param0->unk_2442 = param1->networkID; for (v0 = 0; v0 < 4; v0++) { param0->unk_2464[v0] = param1->unk_178[v0]; } param0->unk_2430 = LCRNG_GetSeed(); - param0->unk_2444 = param1->unk_174; - param0->unk_2448 = param1->unk_174; - param0->battleStatusMask = param1->unk_164; + param0->unk_2444 = param1->seed; + param0->unk_2448 = param1->seed; + param0->battleStatusMask = param1->battleStatusMask; param0->unk_58 = Bag_New(5); - Bag_Copy(param1->unk_E0, param0->unk_58); + Bag_Copy(param1->bag, param0->unk_58); param0->pokedex = sub_02026324(5); - sub_02026338(param1->unk_E8, param0->pokedex); + sub_02026338(param1->pokedex, param0->pokedex); - param0->pcBoxes = param1->unk_EC; - param0->unk_1B0 = param1->unk_108; + param0->pcBoxes = param1->pcBoxes; + param0->unk_1B0 = param1->options; param0->unk_1B4 = param1->unk_124; - param0->unk_5C = param1->unk_E4; + param0->unk_5C = param1->bagCursor; param0->unk_1BC = param1->unk_190; param0->poketchData = param1->poketchData; - param0->unk_2420 = param1->unk_13C; + param0->unk_2420 = param1->mapEvolutionMethod; param0->unk_9C = param1->unk_10C; - param0->safariBalls = param1->unk_168; - param0->terrain = param1->unk_12C; - param0->unk_2400 = param1->unk_128; - param0->unk_2404 = param1->unk_130; - param0->time = param1->unk_138; - param0->unk_2418 = param1->unk_16C; - param0->unk_2424 = param1->unk_140; - param0->unk_242C = param1->unk_144; - param0->fieldWeather = param1->unk_14C; + param0->safariBalls = param1->countSafariBalls; + param0->terrain = param1->terrain; + param0->unk_2400 = param1->background; + param0->unk_2404 = param1->mapLabelTextID; + param0->time = param1->timeOfDay; + param0->unk_2418 = param1->rulesetMask; + param0->unk_2424 = param1->visitedContestHall; + param0->unk_242C = param1->metBebe; + param0->fieldWeather = param1->fieldWeather; param0->records = param1->records; GF_ASSERT(param1->records != NULL); @@ -1720,7 +1720,7 @@ static void ov16_0223D10C(OverlayManager *param0, FieldBattleDTO *param1) { int v4; - v4 = Options_Frame(param1->unk_108); + v4 = Options_Frame(param1->options); ReplaceTransparentTiles(v0->unk_04, 1, 1, 10, v4, 5); PaletteData_LoadBufferFromFileStart(v0->unk_0C, 14, 7, 5, 0, 0x20, 0xb * 0x10); @@ -2141,7 +2141,7 @@ static BOOL ov16_0223DB1C(OverlayManager *param0) int v3; if (((v0->battleType & BATTLE_TYPE_LINK) == 0) - || (v0->unk_164 & 0x10) + || (v0->battleStatusMask & BATTLE_STATUS_RECORDING) || (v0->battleType & BATTLE_TYPE_FRONTIER)) { return 0; } @@ -2154,23 +2154,23 @@ static BOOL ov16_0223DB1C(OverlayManager *param0) MI_CpuClearFast(v1, sizeof(UnkStruct_ov10_0221F800)); v1->unk_00 = v0; - switch (v0->unk_14) { - case 0x1: + switch (v0->resultMask) { + case BATTLE_RESULT_WIN: if (!sub_020389B8()) { GameRecords_IncrementRecordValue(v0->records, RECORD_UNK_021); } else { GameRecords_IncrementRecordValue(v0->records, RECORD_UNK_026); } break; - case 0x2: + case BATTLE_RESULT_LOSE: if (!sub_020389B8()) { GameRecords_IncrementRecordValue(v0->records, RECORD_UNK_022); } else { GameRecords_IncrementRecordValue(v0->records, RECORD_UNK_027); } break; - case 0x3: - case 0x5: + case BATTLE_RESULT_DRAW: + case BATTLE_RESULT_PLAYER_FLED: if (!sub_020389B8()) { GameRecords_IncrementRecordValue(v0->records, RECORD_UNK_023); } else { @@ -2182,29 +2182,29 @@ static BOOL ov16_0223DB1C(OverlayManager *param0) if (v0->battleType & BATTLE_TYPE_2vs2) { for (v3 = 0; v3 < 4; v3++) { v1->unk_04[sub_020362F4(v3)] = v0->parties[v3]; - v1->unk_14[sub_020362F4(v3)] = TrainerInfo_NameNewStrbuf(v0->unk_D0[v3], 5); + v1->unk_14[sub_020362F4(v3)] = TrainerInfo_NameNewStrbuf(v0->trainerInfo[v3], 5); } v1->unk_24 = 5; v1->unk_28 = 2; v1->unk_29 = 1; - if (v0->unk_14 != 0x5) { - v1->unk_2A = v0->unk_14; + if (v0->resultMask != BATTLE_RESULT_PLAYER_FLED) { + v1->unk_2A = v0->resultMask; } else { v1->unk_2A = 3; } } else { v1->unk_04[sub_020362F4(v2)] = v0->parties[v2]; v1->unk_04[sub_020362F4(v2 ^ 1)] = v0->parties[v2 ^ 1]; - v1->unk_14[sub_020362F4(v2)] = TrainerInfo_NameNewStrbuf(v0->unk_D0[v2], 5); - v1->unk_14[sub_020362F4(v2 ^ 1)] = TrainerInfo_NameNewStrbuf(v0->unk_D0[v2 ^ 1], 5); + v1->unk_14[sub_020362F4(v2)] = TrainerInfo_NameNewStrbuf(v0->trainerInfo[v2], 5); + v1->unk_14[sub_020362F4(v2 ^ 1)] = TrainerInfo_NameNewStrbuf(v0->trainerInfo[v2 ^ 1], 5); v1->unk_24 = 5; v1->unk_28 = 2; v1->unk_29 = 0; - if (v0->unk_14 != 0x5) { - v1->unk_2A = v0->unk_14; + if (v0->resultMask != BATTLE_RESULT_PLAYER_FLED) { + v1->unk_2A = v0->resultMask; } else { v1->unk_2A = 3; } @@ -2264,7 +2264,7 @@ static void ov16_0223DD90(BattleSystem *param0, FieldBattleDTO *param1) for (v0 = 0; v0 < 4; v0++) { v5[v0] = v0; - v6[v0] = param1->unk_154[v0]; + v6[v0] = param1->systemVersion[v0]; } v3 = CommSys_CurNetId(); diff --git a/src/battle/ov16_0223DF00.c b/src/battle/ov16_0223DF00.c index 2720ceeaf..575a9c021 100644 --- a/src/battle/ov16_0223DF00.c +++ b/src/battle/ov16_0223DF00.c @@ -964,14 +964,14 @@ u16 ov16_0223ECC4(FieldBattleDTO *param0, int *param1, int *param2) v1 = 0; - if ((param0->unk_14 != 0x1) && (param0->unk_14 != 0x4) && (param0->unk_14 != 0x5)) { + if ((param0->resultMask != BATTLE_RESULT_WIN) && (param0->resultMask != BATTLE_RESULT_CAPTURED_MON) && (param0->resultMask != BATTLE_RESULT_PLAYER_FLED)) { return 0; } - while (param0->unk_150) { + while (param0->leveledUpMonsMask) { for (param1[0] = 0; param1[0] < 6; param1[0]++) { - if (param0->unk_150 & FlagIndex(param1[0])) { - param0->unk_150 &= (FlagIndex(param1[0]) ^ 0xffffffff); + if (param0->leveledUpMonsMask & FlagIndex(param1[0])) { + param0->leveledUpMonsMask &= (FlagIndex(param1[0]) ^ 0xffffffff); break; } } @@ -979,7 +979,7 @@ u16 ov16_0223ECC4(FieldBattleDTO *param0, int *param1, int *param2) if (param1[0] < 6) { v0 = Party_GetPokemonBySlotIndex(param0->parties[0], param1[0]); - if ((v1 = sub_02076B94(param0->parties[0], v0, 0, param0->unk_13C, param2))) { + if ((v1 = sub_02076B94(param0->parties[0], v0, 0, param0->mapEvolutionMethod, param2))) { return v1; } } diff --git a/src/encounter.c b/src/encounter.c index 8fb447ca0..1dd4cbd74 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -4,7 +4,9 @@ #include #include "constants/battle.h" +#include "consts/battle.h" #include "consts/game_records.h" +#include "consts/map.h" #include "struct_decls/struct_0202440C_decl.h" #include "struct_decls/struct_020797DC_decl.h" @@ -129,10 +131,10 @@ static BOOL sub_02050B04(UnkStruct_02050ACC *param0) BOOL v0; if (param0->unk_00 != NULL) { - *(param0->unk_00) = param0->unk_10->unk_14; + *(param0->unk_00) = param0->unk_10->resultMask; } - v0 = FieldBattleDTO_PlayerWon(param0->unk_10->unk_14); + v0 = FieldBattleDTO_PlayerWon(param0->unk_10->resultMask); return v0; } @@ -175,7 +177,7 @@ static BOOL sub_02050B30(FieldTask *taskMan) if ((v1->unk_10->battleType == BATTLE_TYPE_WILD_MON) || (v1->unk_10->battleType == BATTLE_TYPE_ROAMER) || (v1->unk_10->battleType == BATTLE_TYPE_AI_PARTNER)) { - sub_0206D1B8(fieldSystem, v1->unk_10->unk_10C, v1->unk_10->unk_14); + sub_0206D1B8(fieldSystem, v1->unk_10->unk_10C, v1->unk_10->resultMask); } if (sub_02050B04(v1) == 0) { @@ -189,7 +191,7 @@ static BOOL sub_02050B30(FieldTask *taskMan) sub_020518B0(fieldSystem, v1->unk_10); sub_02051988(fieldSystem, v1->unk_10); - sub_0206B48C(SaveData_GetVarsFlags(fieldSystem->saveData), v1->unk_10->unk_18C); + sub_0206B48C(SaveData_GetVarsFlags(fieldSystem->saveData), v1->unk_10->totalTurnsElapsed); FieldTask_StartFieldMap(taskMan); (*v2)++; break; @@ -253,7 +255,7 @@ static BOOL sub_02050CA8(FieldTask *taskMan) (*v2)++; break; case 3: - sub_02050C6C(v1->unk_10->unk_14, fieldSystem); + sub_02050C6C(v1->unk_10->resultMask, fieldSystem); sub_02052754(v1->unk_10, fieldSystem); { @@ -292,7 +294,7 @@ static BOOL sub_02050D4C(FieldTask *taskMan) (*v2)++; break; case 1: { - sub_02050C6C(v1->unk_10->unk_14, fieldSystem); + sub_02050C6C(v1->unk_10->resultMask, fieldSystem); sub_02052754(v1->unk_10, fieldSystem); } { @@ -391,9 +393,9 @@ static BOOL sub_02050EE0(FieldTask *taskMan) break; case 3: sub_02050B1C(v1->unk_10, fieldSystem); - sub_0206D1B8(fieldSystem, v1->unk_10->unk_10C, v1->unk_10->unk_14); + sub_0206D1B8(fieldSystem, v1->unk_10->unk_10C, v1->unk_10->resultMask); - if (FieldBattleDTO_PlayerWon(v1->unk_10->unk_14) == 0) { + if (FieldBattleDTO_PlayerWon(v1->unk_10->resultMask) == 0) { sub_02050DFC(v1); RadarChain_Clear(fieldSystem->chain); FieldTask_InitJump(taskMan, sub_02052B2C, NULL); @@ -409,7 +411,7 @@ static BOOL sub_02050EE0(FieldTask *taskMan) if (GetRadarChainActive(fieldSystem->chain)) { if (sub_02069798(fieldSystem->chain)) { - if ((!(v1->unk_10->unk_14 == 0x1)) && (!(v1->unk_10->unk_14 == 0x4))) { + if ((!(v1->unk_10->resultMask == BATTLE_RESULT_WIN)) && (!(v1->unk_10->resultMask == BATTLE_RESULT_CAPTURED_MON))) { RadarChain_Clear(fieldSystem->chain); } } else { @@ -427,7 +429,7 @@ static BOOL sub_02050EE0(FieldTask *taskMan) break; case 5: if (GetRadarChainActive(fieldSystem->chain)) { - SetupGrassPatches(fieldSystem, v1->unk_10->unk_14, fieldSystem->chain); + SetupGrassPatches(fieldSystem, v1->unk_10->resultMask, fieldSystem->chain); sub_02069638(fieldSystem, fieldSystem->chain); } @@ -475,7 +477,7 @@ static BOOL sub_02051074(FieldTask *taskMan) case 3: sub_02050B1C(v1->unk_10, fieldSystem); - if (v1->unk_10->unk_14 == 0x4) { + if (v1->unk_10->resultMask == BATTLE_RESULT_CAPTURED_MON) { TVBroadcast *v4 = SaveData_TVBroadcast(fieldSystem->saveData); Pokemon *v5 = Party_GetPokemonBySlotIndex(v1->unk_10->parties[1], 0); @@ -484,7 +486,7 @@ static BOOL sub_02051074(FieldTask *taskMan) sub_020518B0(fieldSystem, v1->unk_10); - if (((*v3) == 0) && (v1->unk_10->unk_14 != 0x4)) { + if (((*v3) == 0) && (v1->unk_10->resultMask != BATTLE_RESULT_CAPTURED_MON)) { Location *v6; v6 = FieldOverworldState_GetSpecialLocation(SaveData_GetFieldOverworldState(fieldSystem->saveData)); @@ -505,7 +507,7 @@ static BOOL sub_02051074(FieldTask *taskMan) break; case 6: if ((*v3) == 0) { - if (v1->unk_10->unk_14 == 0x4) { + if (v1->unk_10->resultMask == BATTLE_RESULT_CAPTURED_MON) { ScriptManager_Start(taskMan, 8802, NULL, NULL); } else { ScriptManager_Start(taskMan, 8809, NULL, NULL); @@ -542,8 +544,8 @@ void sub_0205120C(FieldTask *taskMan, int *param1) v1 = sub_02051D8C(11, (0x0 | 0x0)); sub_02052314(v1, fieldSystem); - v1->unk_128 = 0; - v1->unk_12C = 0; + v1->background = 0; + v1->terrain = TERRAIN_PLAIN; ov6_02242034(fieldSystem, v1); @@ -566,7 +568,7 @@ void sub_02051270(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL p ov6_022420D4(fieldSystem, param1, param2, v1); if (param4) { - v1->unk_164 |= 0x8; + v1->battleStatusMask |= BATTLE_STATUS_LEGENDARY; } GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(fieldSystem->saveData), RECORD_UNK_007); @@ -595,7 +597,7 @@ void sub_020512E4(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL p Pokemon_SetValue(v3, MON_DATA_FATEFUL_ENCOUNTER, &v4); if (param4) { - v1->unk_164 |= 0x8; + v1->battleStatusMask |= BATTLE_STATUS_LEGENDARY; } GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(fieldSystem->saveData), RECORD_UNK_007); @@ -676,7 +678,7 @@ void sub_02051480(FieldTask *taskMan, int param1, int param2, int *param3) sub_02052314(v1, fieldSystem); - v1->unk_164 = 0x1; + v1->battleStatusMask = BATTLE_STATUS_FIRST_BATTLE; v1->trainerIDs[1] = param1; v1->trainerIDs[3] = 0; v1->trainerIDs[2] = 0; @@ -764,8 +766,8 @@ void sub_020515CC(FieldTask *taskMan, int param1, int param2, int param3, int pa v2 = sub_02051D8C(11, v0); sub_02052314(v2, fieldSystem); - if ((fieldSystem->location->mapId >= 573) && (fieldSystem->location->mapId <= 583)) { - v2->unk_164 |= 0x80; + if ((fieldSystem->location->mapId >= MAP_HEADER_DISTORTION_WORLD_1F) && (fieldSystem->location->mapId <= MAP_HEADER_DISTORTION_WORLD_TURNBACK_CAVE_ROOM)) { + v2->battleStatusMask |= BATTLE_STATUS_DISTORTION; } v2->trainerIDs[1] = param1; @@ -911,7 +913,7 @@ static void sub_020518B0(FieldSystem *fieldSystem, FieldBattleDTO *param1) { Pokemon *v0; u32 v1 = param1->battleType; - int v2 = param1->unk_14; + int v2 = param1->resultMask; if (v1 & 0x4) { return; @@ -924,9 +926,9 @@ static void sub_020518B0(FieldSystem *fieldSystem, FieldBattleDTO *param1) if ((v1 == BATTLE_TYPE_WILD_MON) || (v1 == BATTLE_TYPE_ROAMER) || (v1 == BATTLE_TYPE_AI_PARTNER)) { - if (v2 == 0x1) { + if (v2 == BATTLE_RESULT_WIN) { GameRecords_IncrementTrainerScore(SaveData_GetGameRecordsPtr(fieldSystem->saveData), TRAINER_SCORE_EVENT_UNK_08); - } else if (v2 == 0x4) { + } else if (v2 == BATTLE_RESULT_CAPTURED_MON) { v0 = Party_GetPokemonBySlotIndex(param1->parties[1], 0); if (sub_0207A294(0, Pokemon_GetValue(v0, MON_DATA_SPECIES, 0))) { @@ -936,11 +938,11 @@ static void sub_020518B0(FieldSystem *fieldSystem, FieldBattleDTO *param1) } } } else if ((v1 & BATTLE_TYPE_TRAINER) || (v1 & BATTLE_TYPE_TAG)) { - if (v2 == 0x1) { + if (v2 == BATTLE_RESULT_WIN) { GameRecords_IncrementTrainerScore(SaveData_GetGameRecordsPtr(fieldSystem->saveData), TRAINER_SCORE_EVENT_UNK_11); } } else if ((v1 & BATTLE_TYPE_SAFARI) || (v1 & BATTLE_TYPE_PAL_PARK)) { - if (v2 == 0x4) { + if (v2 == BATTLE_RESULT_CAPTURED_MON) { v0 = Party_GetPokemonBySlotIndex(param1->parties[1], 0); if (sub_0207A294(0, Pokemon_GetValue(v0, MON_DATA_SPECIES, 0))) { @@ -956,7 +958,7 @@ static void sub_02051988(FieldSystem *fieldSystem, FieldBattleDTO *param1) { Pokemon *v0; u32 v1 = param1->battleType; - int v2 = param1->unk_14; + int v2 = param1->resultMask; if (v1 & BATTLE_TYPE_LINK) { return; @@ -976,25 +978,25 @@ static void sub_02051988(FieldSystem *fieldSystem, FieldBattleDTO *param1) || (v1 == BATTLE_TYPE_SAFARI)) { UnkStruct_0202BE38 *v3; - if (v2 == 0x1) { + if (v2 == BATTLE_RESULT_WIN) { fieldSystem->unk_78.unk_02++; if (fieldSystem->unk_78.unk_02 >= 5) { v0 = Party_GetPokemonBySlotIndex(param1->parties[1], 0); - v3 = sub_0202BECC(SaveData_GetPlayTime(fieldSystem->saveData), Pokemon_GetValue(v0, MON_DATA_SPECIES, 0), Pokemon_GetValue(v0, MON_DATA_GENDER, 0), param1->unk_138, 11); + v3 = sub_0202BECC(SaveData_GetPlayTime(fieldSystem->saveData), Pokemon_GetValue(v0, MON_DATA_SPECIES, 0), Pokemon_GetValue(v0, MON_DATA_GENDER, 0), param1->timeOfDay, 11); Journal_SaveData(fieldSystem->journal, v3, 2); } - } else if (v2 == 0x4) { + } else if (v2 == BATTLE_RESULT_CAPTURED_MON) { int v4; - v4 = param1->unk_148; + v4 = param1->caughtBattlerIdx; v0 = Party_GetPokemonBySlotIndex(param1->parties[v4], 0); - v3 = sub_0202BE4C(SaveData_GetPlayTime(fieldSystem->saveData), Pokemon_GetValue(v0, MON_DATA_SPECIES, 0), Pokemon_GetValue(v0, MON_DATA_GENDER, 0), param1->unk_138, 11); + v3 = sub_0202BE4C(SaveData_GetPlayTime(fieldSystem->saveData), Pokemon_GetValue(v0, MON_DATA_SPECIES, 0), Pokemon_GetValue(v0, MON_DATA_GENDER, 0), param1->timeOfDay, 11); Journal_SaveData(fieldSystem->journal, v3, 2); } } else if ((v1 & BATTLE_TYPE_TRAINER) || (v1 & BATTLE_TYPE_TAG)) { - if (v2 == 0x1) { + if (v2 == BATTLE_RESULT_WIN) { sub_0202C720(fieldSystem->journal, fieldSystem->location->mapId, param1->trainerIDs[1], 11); } } @@ -1022,11 +1024,11 @@ void sub_02051ABC(FieldTask *taskMan, u16 param1, u8 param2, int *param3, BOOL p } if (param4) { - v1->unk_164 |= 0x8; + v1->battleStatusMask |= BATTLE_STATUS_LEGENDARY; } - v1->unk_164 |= 0x40 | 0x80; - v1->unk_12C = 23; + v1->battleStatusMask |= BATTLE_STATUS_GIRATINA | BATTLE_STATUS_DISTORTION; + v1->terrain = TERRAIN_GIRATINA; GameRecords_IncrementRecordValue(SaveData_GetGameRecordsPtr(fieldSystem->saveData), RECORD_UNK_007); sub_02050C4C(taskMan, v1, EncEffects_CutInEffect(v1), EncEffects_BGM(v1), param3); diff --git a/src/field_battle_data_transfer.c b/src/field_battle_data_transfer.c index 69b7e422f..7226170d4 100644 --- a/src/field_battle_data_transfer.c +++ b/src/field_battle_data_transfer.c @@ -5,6 +5,7 @@ #include "constants/battle.h" #include "constants/pokemon.h" +#include "consts/battle.h" #include "consts/species.h" #include "struct_decls/pokedexdata_decl.h" @@ -56,6 +57,8 @@ #include "unk_0206CCB0.h" #include "vars_flags.h" +#include "res/text/gmm/message_bank_location_names.h" + static void sub_0205281C(FieldBattleDTO *param0, const FieldSystem *fieldSystem); void sub_02052894(FieldBattleDTO *param0); @@ -68,53 +71,53 @@ FieldBattleDTO *sub_02051D8C(int param0, u32 param1) MI_CpuClear8(v1, sizeof(FieldBattleDTO)); v1->battleType = param1; - v1->unk_164 = 0; - v1->unk_14 = 0; + v1->battleStatusMask = 0; + v1->resultMask = 0; for (v0 = 0; v0 < 4; v0++) { v1->trainerIDs[v0] = 0; MI_CpuClear32(&v1->trainerData[v0], sizeof(TrainerData)); } - v1->unk_128 = 0; - v1->unk_12C = 24; - v1->unk_130 = 0; - v1->unk_138 = 0; - v1->unk_13C = 0; - v1->unk_140 = 1; - v1->unk_144 = 1; - v1->unk_14C = 0; + v1->background = 0; + v1->terrain = TERRAIN_MAX; + v1->mapLabelTextID = pl_msg_00000433_00000; + v1->timeOfDay = TOD_MORNING; + v1->mapEvolutionMethod = 0; + v1->visitedContestHall = 1; + v1->metBebe = 1; + v1->fieldWeather = 0; for (v0 = 0; v0 < 4; v0++) { v1->parties[v0] = Party_New(param0); } for (v0 = 0; v0 < 4; v0++) { - v1->unk_D0[v0] = TrainerInfo_New(param0); + v1->trainerInfo[v0] = TrainerInfo_New(param0); } for (v0 = 0; v0 < 4; v0++) { - v1->unk_F0[v0] = AllocateAndInitializeChatotCryData(param0); + v1->chatotCries[v0] = AllocateAndInitializeChatotCryData(param0); } - v1->unk_E0 = Bag_New(param0); - v1->unk_E8 = sub_02026324(param0); - v1->unk_108 = Options_New(param0); + v1->bag = Bag_New(param0); + v1->pokedex = sub_02026324(param0); + v1->options = Options_New(param0); v1->unk_10C = sub_0206D140(param0); - v1->unk_E4 = NULL; + v1->bagCursor = NULL; v1->unk_190 = NULL; - v1->unk_168 = 0; + v1->countSafariBalls = 0; v1->unk_104 = NULL; v1->records = NULL; - v1->unk_120 = NULL; - v1->unk_16C = 0; + v1->journal = NULL; + v1->rulesetMask = 0; { RTCDate v2; RTCTime v3; GetCurrentDateTime(&v2, &v3); - v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.vblankCounter; + v1->seed = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.vblankCounter; } if (CommSys_IsInitialized() == 1) { @@ -122,10 +125,10 @@ FieldBattleDTO *sub_02051D8C(int param0, u32 param1) v1->unk_178[v0] = sub_020362F4(v0); } - v1->unk_188 = CommSys_CurNetId(); + v1->networkID = CommSys_CurNetId(); } - MI_CpuClear8(&(v1->unk_110), sizeof(FieldBattleDTO_sub1)); + MI_CpuClear8(&(v1->battleRecords), sizeof(BattleRecords)); return v1; } @@ -134,7 +137,7 @@ FieldBattleDTO *sub_02051F24(int param0, int param1) FieldBattleDTO *v0; v0 = sub_02051D8C(param0, 0x20); - v0->unk_168 = param1; + v0->countSafariBalls = param1; return v0; } @@ -144,7 +147,7 @@ FieldBattleDTO *sub_02051F38(int param0, int param1) FieldBattleDTO *v0; v0 = sub_02051D8C(param0, 0x200); - v0->unk_168 = param1; + v0->countSafariBalls = param1; return v0; } @@ -163,15 +166,15 @@ FieldBattleDTO *sub_02051F4C(int param0, const FieldSystem *fieldSystem) v3 = Strbuf_Init(8, param0); MessageLoader_GetStrbuf(v2, TrainerInfo_Gender(v0) ^ 1, v3); - TrainerInfo_SetName(v4->unk_D0[0], Strbuf_GetData(v3)); + TrainerInfo_SetName(v4->trainerInfo[0], Strbuf_GetData(v3)); Strbuf_Free(v3); MessageLoader_Free(v2); - TrainerInfo_SetGender(v4->unk_D0[0], TrainerInfo_Gender(v0) ^ 1); + TrainerInfo_SetGender(v4->trainerInfo[0], TrainerInfo_Gender(v0) ^ 1); sub_0205281C(v4, fieldSystem); - Options_Copy(v1, v4->unk_108); + Options_Copy(v1, v4->options); - v4->unk_138 = sub_02055BA8(fieldSystem); - Bag_TryAddItem(v4->unk_E0, 4, 20, param0); + v4->timeOfDay = sub_02055BA8(fieldSystem); + Bag_TryAddItem(v4->bag, 4, 20, param0); v5 = Pokemon_New(param0); Pokemon_InitWith(v5, sub_0206B08C(SaveData_GetVarsFlags(fieldSystem->saveData)), 5, 32, FALSE, 0, OTID_NOT_SHINY, 0); @@ -180,11 +183,11 @@ FieldBattleDTO *sub_02051F4C(int param0, const FieldSystem *fieldSystem) Party_AddPokemon(v4->parties[1], v5); Heap_FreeToHeap(v5); - v4->unk_EC = SaveData_PCBoxes(fieldSystem->saveData); - v4->unk_E4 = fieldSystem->unk_98; + v4->pcBoxes = SaveData_PCBoxes(fieldSystem->saveData); + v4->bagCursor = fieldSystem->unk_98; v4->unk_190 = NULL; v4->records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); - v4->unk_120 = fieldSystem->journal; + v4->journal = fieldSystem->journal; v4->mapHeaderID = fieldSystem->location->mapId; sub_02052894(v4); @@ -202,18 +205,18 @@ void sub_020520A4(FieldBattleDTO *param0) } for (v0 = 0; v0 < 4; v0++) { - GF_ASSERT(param0->unk_D0[v0] != NULL); - Heap_FreeToHeap(param0->unk_D0[v0]); + GF_ASSERT(param0->trainerInfo[v0] != NULL); + Heap_FreeToHeap(param0->trainerInfo[v0]); } for (v0 = 0; v0 < 4; v0++) { - GF_ASSERT(param0->unk_F0[v0] != NULL); - Heap_FreeToHeap(param0->unk_F0[v0]); + GF_ASSERT(param0->chatotCries[v0] != NULL); + Heap_FreeToHeap(param0->chatotCries[v0]); } - Heap_FreeToHeap(param0->unk_E0); - Heap_FreeToHeap(param0->unk_E8); - Heap_FreeToHeap(param0->unk_108); + Heap_FreeToHeap(param0->bag); + Heap_FreeToHeap(param0->pokedex); + Heap_FreeToHeap(param0->options); sub_0206D158(param0->unk_10C); Heap_FreeToHeap(param0); } @@ -236,12 +239,12 @@ void sub_02052164(FieldBattleDTO *param0, const Party *param1, int param2) void sub_02052184(FieldBattleDTO *param0, const TrainerInfo *param1, int param2) { GF_ASSERT(param2 < 4); - TrainerInfo_Copy(param1, param0->unk_D0[param2]); + TrainerInfo_Copy(param1, param0->trainerInfo[param2]); } void sub_020521A4(FieldBattleDTO *param0, const ChatotCry *param1, int param2) { - CopyChatotCryData(param0->unk_F0[param2], param1); + CopyChatotCryData(param0->chatotCries[param2], param1); } void sub_020521B8(FieldBattleDTO *param0, const FieldSystem *fieldSystem, SaveData *param2, int param3, Journal *param4, BagCursor *param5, UnkStruct_0209C370 *param6) @@ -256,39 +259,39 @@ void sub_020521B8(FieldBattleDTO *param0, const FieldSystem *fieldSystem, SaveDa if (fieldSystem != NULL) { sub_0205281C(param0, fieldSystem); - param0->unk_138 = sub_02055BA8(fieldSystem); + param0->timeOfDay = sub_02055BA8(fieldSystem); } else { - param0->unk_128 = MapHeader_GetBattleBG(param3); - param0->unk_12C = 9; + param0->background = MapHeader_GetBattleBG(param3); + param0->terrain = TERRAIN_BUILDING; { GameTime *v7 = SaveData_GetGameTime(param2); - param0->unk_138 = TimeOfDayForHour(v7->time.hour); + param0->timeOfDay = TimeOfDayForHour(v7->time.hour); } } sub_02052184(param0, v0, 0); sub_02052164(param0, v1, 0); - Bag_Copy(v2, param0->unk_E0); - sub_02026338(v3, param0->unk_E8); - Options_Copy(v5, param0->unk_108); + Bag_Copy(v2, param0->bag); + sub_02026338(v3, param0->pokedex); + Options_Copy(v5, param0->options); sub_020521A4(param0, v4, 0); - param0->unk_EC = SaveData_PCBoxes(param2); - param0->unk_130 = MapHeader_GetMapLabelTextID(param3); - param0->unk_13C = MapHeader_GetMapEvolutionMethod(param3); - param0->unk_140 = PokemonSummaryScreen_ShowContestData(param2); - param0->unk_144 = SystemFlag_CheckMetBebe(SaveData_GetVarsFlags(param2)); - param0->unk_14C = FieldOverworldState_GetWeather(v6); - param0->unk_E4 = param5; + param0->pcBoxes = SaveData_PCBoxes(param2); + param0->mapLabelTextID = MapHeader_GetMapLabelTextID(param3); + param0->mapEvolutionMethod = MapHeader_GetMapEvolutionMethod(param3); + param0->visitedContestHall = PokemonSummaryScreen_ShowContestData(param2); + param0->metBebe = SystemFlag_CheckMetBebe(SaveData_GetVarsFlags(param2)); + param0->fieldWeather = FieldOverworldState_GetWeather(v6); + param0->bagCursor = param5; param0->unk_190 = param6; param0->poketchData = SaveData_PoketchData(param2); param0->unk_104 = sub_0202C878(param2); param0->records = SaveData_GetGameRecordsPtr(param2); - param0->unk_120 = param4; + param0->journal = param4; param0->unk_124 = sub_02027F8C(param2); param0->mapHeaderID = param3; - param0->unk_198 = param2; + param0->saveData = param2; } void sub_02052314(FieldBattleDTO *battleParams, const FieldSystem *fieldSystem) @@ -309,8 +312,8 @@ void sub_02052348(FieldBattleDTO *param0, const FieldSystem *fieldSystem, int pa Options *v7 = SaveData_Options(fieldSystem->saveData); Pokemon *v8; - param0->unk_128 = 6; - param0->unk_12C = 9; + param0->background = 6; + param0->terrain = TERRAIN_BUILDING; sub_02052184(param0, v2, 0); v8 = Pokemon_New(11); @@ -330,22 +333,22 @@ void sub_02052348(FieldBattleDTO *param0, const FieldSystem *fieldSystem, int pa } Heap_FreeToHeap(v8); - Bag_Copy(v4, param0->unk_E0); - sub_02026338(v5, param0->unk_E8); - Options_Copy(v7, param0->unk_108); + Bag_Copy(v4, param0->bag); + sub_02026338(v5, param0->pokedex); + Options_Copy(v7, param0->options); sub_020521A4(param0, v6, 0); - param0->unk_EC = SaveData_PCBoxes(fieldSystem->saveData); - param0->unk_138 = sub_02055BA8(fieldSystem); - param0->unk_E4 = fieldSystem->unk_98; + param0->pcBoxes = SaveData_PCBoxes(fieldSystem->saveData); + param0->timeOfDay = sub_02055BA8(fieldSystem); + param0->bagCursor = fieldSystem->unk_98; param0->unk_190 = fieldSystem->unk_BC; param0->poketchData = SaveData_PoketchData(fieldSystem->saveData); param0->unk_104 = sub_0202C878(fieldSystem->saveData); param0->records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); - param0->unk_120 = fieldSystem->journal; + param0->journal = fieldSystem->journal; param0->unk_124 = sub_02027F8C(fieldSystem->saveData); param0->mapHeaderID = fieldSystem->location->mapId; - param0->unk_198 = fieldSystem->saveData; + param0->saveData = fieldSystem->saveData; sub_02052894(param0); } @@ -361,8 +364,8 @@ void sub_020524E4(FieldBattleDTO *param0, const FieldSystem *fieldSystem, const int v6, v7, v8; Pokemon *v9; - param0->unk_128 = 6; - param0->unk_12C = 9; + param0->background = 6; + param0->terrain = TERRAIN_BUILDING; sub_02052184(param0, v0, 0); @@ -396,32 +399,32 @@ void sub_020524E4(FieldBattleDTO *param0, const FieldSystem *fieldSystem, const if (v5) { if (sub_02026074(v5, 12)) { - param0->unk_16C = 1; + param0->rulesetMask = 1; } } - Bag_Copy(v1, param0->unk_E0); - sub_02026338(v2, param0->unk_E8); - Options_Copy(v4, param0->unk_108); + Bag_Copy(v1, param0->bag); + sub_02026338(v2, param0->pokedex); + Options_Copy(v4, param0->options); sub_020521A4(param0, v3, 0); - param0->unk_EC = SaveData_PCBoxes(fieldSystem->saveData); - param0->unk_138 = sub_02055BA8(fieldSystem); - param0->unk_E4 = fieldSystem->unk_98; + param0->pcBoxes = SaveData_PCBoxes(fieldSystem->saveData); + param0->timeOfDay = sub_02055BA8(fieldSystem); + param0->bagCursor = fieldSystem->unk_98; param0->unk_190 = fieldSystem->unk_BC; param0->unk_104 = sub_0202C878(fieldSystem->saveData); param0->records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); - param0->unk_120 = fieldSystem->journal; + param0->journal = fieldSystem->journal; param0->mapHeaderID = fieldSystem->location->mapId; param0->unk_124 = sub_02027F8C(fieldSystem->saveData); - param0->unk_198 = fieldSystem->saveData; + param0->saveData = fieldSystem->saveData; if (sub_020326C4(sub_0203895C())) { int v11 = TrainerInfo_Appearance(v0); int v12 = TrainerInfo_Gender(v0); param0->trainerData[0].class = sub_0205CA14(v12, v11, 1); - CharCode_Copy(¶m0->trainerData[0].name[0], TrainerInfo_Name(param0->unk_D0[0])); + CharCode_Copy(¶m0->trainerData[0].name[0], TrainerInfo_Name(param0->trainerInfo[0])); param0->trainerData[2] = param0->trainerData[0]; } else { sub_02052894(param0); @@ -441,12 +444,12 @@ void sub_020526E8(const FieldBattleDTO *param0, FieldSystem *fieldSystem) PokedexData *v3 = SaveData_Pokedex(fieldSystem->saveData); u16 *v4 = sub_0203A784(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - TrainerInfo_Copy(param0->unk_D0[0], v0); + TrainerInfo_Copy(param0->trainerInfo[0], v0); Party_cpy(param0->parties[0], v1); - Bag_Copy(param0->unk_E0, v2); - sub_02026338(param0->unk_E8, v3); + Bag_Copy(param0->bag, v2); + sub_02026338(param0->pokedex, v3); - *v4 = param0->unk_168; + *v4 = param0->countSafariBalls; } void sub_02052754(const FieldBattleDTO *param0, FieldSystem *fieldSystem) @@ -456,7 +459,7 @@ void sub_02052754(const FieldBattleDTO *param0, FieldSystem *fieldSystem) Bag *v2 = SaveData_GetBag(fieldSystem->saveData); PokedexData *v3 = SaveData_Pokedex(fieldSystem->saveData); - sub_02026338(param0->unk_E8, v3); + sub_02026338(param0->pokedex, v3); } static int sub_02052780(const FieldSystem *fieldSystem, int param1) @@ -519,18 +522,18 @@ static void sub_0205281C(FieldBattleDTO *param0, const FieldSystem *fieldSystem) { PlayerData *v0 = FieldOverworldState_GetPlayerData(SaveData_GetFieldOverworldState(fieldSystem->saveData)); - param0->unk_128 = MapHeader_GetBattleBG(fieldSystem->location->mapId); + param0->background = MapHeader_GetBattleBG(fieldSystem->location->mapId); if (v0->unk_04 == 0x2) { - param0->unk_128 = 1; + param0->background = 1; } - param0->unk_12C = sub_02052780(fieldSystem, param0->unk_128); + param0->terrain = sub_02052780(fieldSystem, param0->background); } void sub_0205285C(FieldBattleDTO *param0) { - param0->unk_12C = 7; + param0->terrain = TERRAIN_WATER; } BOOL FieldBattleDTO_PlayerWon(u32 battleResult) @@ -567,7 +570,7 @@ BOOL FieldBattleDTO_PlayerDidNotCapture(u32 battleResult) void sub_02052894(FieldBattleDTO *param0) { - param0->trainerData[0].class = TrainerInfo_Gender(param0->unk_D0[0]); - CharCode_Copy(¶m0->trainerData[0].name[0], TrainerInfo_Name(param0->unk_D0[0])); + param0->trainerData[0].class = TrainerInfo_Gender(param0->trainerInfo[0]); + CharCode_Copy(¶m0->trainerData[0].name[0], TrainerInfo_Name(param0->trainerInfo[0])); param0->trainerData[2] = param0->trainerData[0]; } diff --git a/src/overlay005/encounter_effect.c b/src/overlay005/encounter_effect.c index 232c25253..4e7b616cf 100644 --- a/src/overlay005/encounter_effect.c +++ b/src/overlay005/encounter_effect.c @@ -1326,24 +1326,24 @@ u32 CutInEffects_ForBattle(const FieldBattleDTO *param0) v6 = Pokemon_GetValue(v4, MON_DATA_LEVEL, NULL); v0 = v6 - v5; - switch (param0->unk_12C) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 6: - case 8: - case 10: - case 11: - case 9: - case 24: + switch (param0->terrain) { + case TERRAIN_PLAIN: + case TERRAIN_SAND: + case TERRAIN_GRASS: + case TERRAIN_PUDDLE: + case TERRAIN_MOUNTAIN: + case TERRAIN_SNOW: + case TERRAIN_ICE: + case TERRAIN_BUILDING: + case TERRAIN_GREAT_MARSH: + case TERRAIN_BRIDGE: + case TERRAIN_MAX: v1 = 0 * 2; break; - case 7: + case TERRAIN_WATER: v1 = 1 * 2; break; - case 5: + case TERRAIN_CAVE: v1 = 2 * 2; break; } diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index bc422dca7..37d0f7ac6 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -1227,7 +1227,7 @@ void ov6_02242034(FieldSystem *fieldSystem, FieldBattleDTO *battleParams) } ov5_021F0040(fieldSystem); - battleParams->unk_164 |= 0x2; + battleParams->battleStatusMask |= BATTLE_STATUS_HONEY_TREE; ov6_02241CC0(v1, v3, 1, &encounterFieldParams, v0, battleParams); return; diff --git a/src/overlay006/ov6_02246034.c b/src/overlay006/ov6_02246034.c index dc9b9bab4..ea24e06f3 100644 --- a/src/overlay006/ov6_02246034.c +++ b/src/overlay006/ov6_02246034.c @@ -3,6 +3,8 @@ #include #include +#include "constants/battle.h" + #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202D7B0.h" #include "struct_defs/struct_0206C638.h" @@ -41,10 +43,10 @@ void ov6_02246034(FieldSystem *fieldSystem, FieldBattleDTO *param1) v0 = (u16)(Pokemon_GetValue(v6, MON_DATA_CURRENT_HP, NULL)); v1 = (u8)(Pokemon_GetValue(v6, MON_DATA_STATUS_CONDITION, NULL)); - if ((param1->unk_14 == 0x1) && (v0 == 0)) { + if ((param1->resultMask == BATTLE_RESULT_WIN) && (v0 == 0)) { sub_0202D914(&v4); sub_0206B688(SaveData_GetVarsFlags(fieldSystem->saveData), v2, 2); - } else if (param1->unk_14 == 0x4) { + } else if (param1->resultMask == BATTLE_RESULT_CAPTURED_MON) { sub_0202D914(&v4); sub_0206B688(SaveData_GetVarsFlags(fieldSystem->saveData), v2, 1); } else { diff --git a/src/overlay010/ov10_0221F800.c b/src/overlay010/ov10_0221F800.c index 939c29575..d6c09eb5e 100644 --- a/src/overlay010/ov10_0221F800.c +++ b/src/overlay010/ov10_0221F800.c @@ -397,8 +397,8 @@ void ov10_0221F800(UnkStruct_ov10_0221F800 *param0) v0->unk_BBC = sub_0202FAC0(); if (v0->unk_BBC == 1) { - if ((v0->unk_00->unk_00 != NULL) && (v0->unk_00->unk_00->unk_198 != NULL)) { - v0->unk_BBC = Bag_CanRemoveItem(SaveData_GetBag(v0->unk_00->unk_00->unk_198), 465, 1, param0->unk_24); + if ((v0->unk_00->unk_00 != NULL) && (v0->unk_00->unk_00->saveData != NULL)) { + v0->unk_BBC = Bag_CanRemoveItem(SaveData_GetBag(v0->unk_00->unk_00->saveData), 465, 1, param0->unk_24); } } } @@ -655,7 +655,7 @@ static u8 ov10_0221FD00(UnkStruct_ov10_0221FB28 *param0) BOOL v0; int v1; - v0 = sub_0202F330(param0->unk_00->unk_00->unk_198, param0->unk_00->unk_24, &v1, 0); + v0 = sub_0202F330(param0->unk_00->unk_00->saveData, param0->unk_00->unk_24, &v1, 0); param0->unk_BC0 = v1; } { @@ -1022,7 +1022,7 @@ static u8 ov10_02220700(UnkStruct_ov10_0221FB28 *param0) case 1: { int v0; - v0 = sub_0202F41C(param0->unk_00->unk_00->unk_198, param0->unk_00->unk_2C, 0, 0, ¶m0->unk_B78, ¶m0->unk_B7A); + v0 = sub_0202F41C(param0->unk_00->unk_00->saveData, param0->unk_00->unk_2C, 0, 0, ¶m0->unk_B78, ¶m0->unk_B7A); if (v0 == 2) { MessageLoader_GetStrbuf(param0->unk_BA0, 6, param0->unk_BA8); @@ -1445,8 +1445,8 @@ static void ov10_02220F1C(UnkStruct_ov10_0221FB28 *param0) { int v0; - GF_ASSERT(param0->unk_B9C == GX_BG0_AS_2D && param0->unk_00 != NULL && param0->unk_00->unk_00 != NULL && param0->unk_00->unk_00->unk_108 != NULL); - v0 = Options_Frame(param0->unk_00->unk_00->unk_108); + GF_ASSERT(param0->unk_B9C == GX_BG0_AS_2D && param0->unk_00 != NULL && param0->unk_00->unk_00 != NULL && param0->unk_00->unk_00->options != NULL); + v0 = Options_Frame(param0->unk_00->unk_00->options); LoadMessageBoxGraphics(param0->unk_0C, 0, 1, 15, v0, param0->unk_00->unk_24); PaletteData_LoadBufferFromHardware(param0->unk_08, 0, 15 * 16, 0x20 * 1); @@ -2470,7 +2470,7 @@ static void ov10_022227A4(UnkStruct_ov10_0221F800 *param0) } } - Journal_SaveData(param0->unk_00->unk_120, v0, 4); + Journal_SaveData(param0->unk_00->journal, v0, 4); } static void ov10_022229D4(UnkStruct_ov10_0221FB28 *param0) @@ -2481,7 +2481,7 @@ static void ov10_022229D4(UnkStruct_ov10_0221FB28 *param0) static BOOL ov10_02222A08(UnkStruct_ov10_0221FB28 *param0) { - if ((param0->unk_00->unk_00->unk_198 == NULL) || (sub_0202F250() == 0)) { + if ((param0->unk_00->unk_00->saveData == NULL) || (sub_0202F250() == 0)) { return 0; } diff --git a/src/overlay104/ov104_022332B4.c b/src/overlay104/ov104_022332B4.c index 4b6802330..c1fdc01e4 100644 --- a/src/overlay104/ov104_022332B4.c +++ b/src/overlay104/ov104_022332B4.c @@ -134,7 +134,7 @@ BOOL ov104_0223338C(UnkStruct_ov104_0222E930 *param0) v0 = sub_0209B978(param0->unk_00->unk_00); v1 = v0->unk_4FC; - v0->unk_14 = FieldBattleDTO_PlayerWon(v1->unk_14); + v0->unk_14 = FieldBattleDTO_PlayerWon(v1->resultMask); sub_020520A4(v1); return 0; diff --git a/src/overlay104/ov104_02234838.c b/src/overlay104/ov104_02234838.c index 9a2241ad9..166d8c81a 100644 --- a/src/overlay104/ov104_02234838.c +++ b/src/overlay104/ov104_02234838.c @@ -148,7 +148,7 @@ BOOL ov104_02234994(UnkStruct_ov104_0222E930 *param0) v0 = sub_0209B978(param0->unk_00->unk_00); v1 = v0->unk_700; - v0->unk_14 = FieldBattleDTO_PlayerWon(v1->unk_14); + v0->unk_14 = FieldBattleDTO_PlayerWon(v1->resultMask); sub_020520A4(v1); return 0; diff --git a/src/overlay104/ov104_022358E8.c b/src/overlay104/ov104_022358E8.c index e41bb6553..fa9f77624 100644 --- a/src/overlay104/ov104_022358E8.c +++ b/src/overlay104/ov104_022358E8.c @@ -188,7 +188,7 @@ BOOL ov104_02235A24(UnkStruct_ov104_0222E930 *param0) sub_0207A128(v1->unk_28, 3, v3); } - v1->unk_1C = FieldBattleDTO_PlayerWon(v2->unk_14); + v1->unk_1C = FieldBattleDTO_PlayerWon(v2->resultMask); sub_020520A4(v2); return 0; diff --git a/src/overlay104/ov104_02237378.c b/src/overlay104/ov104_02237378.c index 14f6364ec..8cf6f5518 100644 --- a/src/overlay104/ov104_02237378.c +++ b/src/overlay104/ov104_02237378.c @@ -155,8 +155,8 @@ BOOL ov104_02237460(UnkStruct_ov104_0222E930 *param0) v9 = sub_0209B978(param0->unk_00->unk_00); v10 = v9->unk_0C; - v9->unk_1D = ov104_02238538(v9, v10->parties[0], v10->parties[2], v10->unk_18C); - v9->unk_28 = FieldBattleDTO_PlayerWon(v10->unk_14); + v9->unk_1D = ov104_02238538(v9, v10->parties[0], v10->parties[2], v10->totalTurnsElapsed); + v9->unk_28 = FieldBattleDTO_PlayerWon(v10->resultMask); if (v9->unk_13 == 27) { v2 = 1; diff --git a/src/overlay104/ov104_02239130.c b/src/overlay104/ov104_02239130.c index 7b282ac6b..c451d4b2a 100644 --- a/src/overlay104/ov104_02239130.c +++ b/src/overlay104/ov104_02239130.c @@ -214,7 +214,7 @@ BOOL ov104_02239364(UnkStruct_ov104_0222E930 *param0) v2 = ov104_0222FBE4(param0); v1 = v0->unk_8D0; - v0->unk_8CC = FieldBattleDTO_PlayerWon(v1->unk_14); + v0->unk_8CC = FieldBattleDTO_PlayerWon(v1->resultMask); *v2 = v0->unk_8CC; sub_020520A4(v1); diff --git a/src/overlay104/ov104_0223A0C4.c b/src/overlay104/ov104_0223A0C4.c index 05337f67a..d24d3bcfe 100644 --- a/src/overlay104/ov104_0223A0C4.c +++ b/src/overlay104/ov104_0223A0C4.c @@ -3,6 +3,8 @@ #include #include +#include "consts/battle.h" + #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0202D764.h" #include "struct_defs/struct_0204AFC4.h" @@ -916,8 +918,8 @@ FieldBattleDTO *ov104_0223A580(UnkStruct_0204AFC4 *param0, UnkStruct_ov104_02230 sub_020521B8(v3, NULL, param1->unk_08, param1->unk_1C, param1->unk_0C, param1->unk_10, param1->unk_20); - v3->unk_128 = 18; - v3->unk_12C = 18; + v3->background = 18; + v3->terrain = TERRAIN_BATTLE_TOWER; v6 = Pokemon_New(param0->unk_04); v1 = 50; diff --git a/src/overlay104/ov104_0223A7F4.c b/src/overlay104/ov104_0223A7F4.c index 907478928..d3dac360c 100644 --- a/src/overlay104/ov104_0223A7F4.c +++ b/src/overlay104/ov104_0223A7F4.c @@ -3,6 +3,8 @@ #include #include +#include "consts/battle.h" + #include "struct_defs/struct_0204B184.h" #include "struct_defs/struct_0204B1E8.h" @@ -360,8 +362,8 @@ FieldBattleDTO *ov104_0223ABA0(UnkStruct_ov104_0223ADA0 *param0, UnkStruct_ov104 v4 = sub_02051D8C(11, ov104_0223AD74(param0->unk_04)); sub_020521B8(v4, NULL, param1->unk_08, param1->unk_1C, param1->unk_0C, param1->unk_10, param1->unk_20); - v4->unk_128 = 19; - v4->unk_12C = 19; + v4->background = 19; + v4->terrain = TERRAIN_BATTLE_FACTORY; Party_InitWithCapacity(v4->parties[0], v2); v5 = Pokemon_New(11); @@ -399,7 +401,7 @@ FieldBattleDTO *ov104_0223ABA0(UnkStruct_ov104_0223ADA0 *param0, UnkStruct_ov104 sub_02052894(v4); v10 = CommInfo_TrainerInfo(1 - CommSys_CurNetId()); - TrainerInfo_Copy(v10, v4->unk_D0[2]); + TrainerInfo_Copy(v10, v4->trainerInfo[2]); v7 = ov104_0222DD04(&v6, param0->unk_18[param0->unk_06 + 7], 11, 178); Heap_FreeToHeap(v7); diff --git a/src/overlay104/ov104_0223AF58.c b/src/overlay104/ov104_0223AF58.c index 258323741..b83b15b62 100644 --- a/src/overlay104/ov104_0223AF58.c +++ b/src/overlay104/ov104_0223AF58.c @@ -3,6 +3,8 @@ #include #include +#include "consts/battle.h" + #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0204B184.h" @@ -1591,8 +1593,8 @@ FieldBattleDTO *ov104_0223B250(UnkStruct_ov104_0223B5C0 *param0, UnkStruct_ov104 v8 = sub_02051D8C(11, ov104_0223B4D4(param0->unk_04)); sub_020521B8(v8, NULL, param1->unk_08, param1->unk_1C, param1->unk_0C, param1->unk_10, param1->unk_20); - v8->unk_128 = 22; - v8->unk_12C = 22; + v8->background = 22; + v8->terrain = TERRAIN_BATTLE_HALL; Party_InitWithCapacity(v8->parties[0], v4); v9 = Pokemon_New(11); @@ -1648,7 +1650,7 @@ FieldBattleDTO *ov104_0223B250(UnkStruct_ov104_0223B5C0 *param0, UnkStruct_ov104 sub_02052894(v8); v12 = CommInfo_TrainerInfo(1 - CommSys_CurNetId()); - TrainerInfo_Copy(v12, v8->unk_D0[2]); + TrainerInfo_Copy(v12, v8->trainerInfo[2]); v11 = ov104_0222DD04(&v10, param0->unk_18[v6 + 1], 11, 178); Heap_FreeToHeap(v11); diff --git a/src/overlay104/ov104_0223B6F4.c b/src/overlay104/ov104_0223B6F4.c index 47dbf5c05..2b1891117 100644 --- a/src/overlay104/ov104_0223B6F4.c +++ b/src/overlay104/ov104_0223B6F4.c @@ -3,6 +3,8 @@ #include #include +#include "consts/battle.h" + #include "struct_decls/struct_0203068C_decl.h" #include "struct_decls/struct_party_decl.h" #include "struct_defs/struct_0204B184.h" @@ -175,8 +177,8 @@ FieldBattleDTO *ov104_0223B810(UnkStruct_ov104_0223BA10 *param0, UnkStruct_ov104 v5 = sub_02051D8C(11, ov104_0223B9E4(param0->unk_10)); sub_020521B8(v5, NULL, param1->unk_08, param1->unk_1C, param1->unk_0C, param1->unk_10, param1->unk_20); - v5->unk_128 = 21; - v5->unk_12C = 21; + v5->background = 21; + v5->terrain = TERRAIN_BATTLE_CASTLE; Party_InitWithCapacity(v5->parties[0], v2); @@ -222,7 +224,7 @@ FieldBattleDTO *ov104_0223B810(UnkStruct_ov104_0223BA10 *param0, UnkStruct_ov104 sub_02052894(v5); v11 = CommInfo_TrainerInfo(1 - CommSys_CurNetId()); - TrainerInfo_Copy(v11, v5->unk_D0[2]); + TrainerInfo_Copy(v11, v5->trainerInfo[2]); v8 = ov104_0222DD04(&v7, param0->unk_30[param0->unk_11 + 7], 11, 178); Heap_FreeToHeap(v8); diff --git a/src/overlay104/ov104_0223BCBC.c b/src/overlay104/ov104_0223BCBC.c index 164449ded..ee8b4b712 100644 --- a/src/overlay104/ov104_0223BCBC.c +++ b/src/overlay104/ov104_0223BCBC.c @@ -180,9 +180,9 @@ FieldBattleDTO *ov104_0223BDD8(UnkStruct_ov104_0223BFFC *param0, UnkStruct_ov104 sub_020521B8(v5, NULL, param1->unk_08, param1->unk_1C, param1->unk_0C, param1->unk_10, param1->unk_20); - v5->unk_128 = 20; - v5->unk_12C = 20; - v5->unk_14C = param0->unk_14; + v5->background = 20; + v5->terrain = TERRAIN_BATTLE_ARCADE; + v5->fieldWeather = param0->unk_14; v12 = param0->unk_70; v13 = param0->unk_74; @@ -235,7 +235,7 @@ FieldBattleDTO *ov104_0223BDD8(UnkStruct_ov104_0223BFFC *param0, UnkStruct_ov104 sub_02052894(v5); v11 = CommInfo_TrainerInfo(1 - CommSys_CurNetId()); - TrainerInfo_Copy(v11, v5->unk_D0[2]); + TrainerInfo_Copy(v11, v5->trainerInfo[2]); v8 = ov104_0222DD04(&v7, param0->unk_78[param0->unk_11 + 7], 11, 178); Heap_FreeToHeap(v8); diff --git a/src/unk_0202F1D4.c b/src/unk_0202F1D4.c index 32ff521bc..e1efb2e90 100644 --- a/src/unk_0202F1D4.c +++ b/src/unk_0202F1D4.c @@ -3,6 +3,7 @@ #include #include +#include "constants/battle.h" #include "constants/species.h" #include "struct_defs/struct_0202F264.h" @@ -455,34 +456,34 @@ void sub_0202F8AC(FieldBattleDTO *param0) v2 = &v1->unk_00; v2->unk_00 = param0->battleType; - v2->unk_04 = param0->unk_14; - v2->unk_E8 = param0->unk_128; - v2->unk_EC = param0->unk_12C; - v2->unk_F0 = param0->unk_130; + v2->unk_04 = param0->resultMask; + v2->unk_E8 = param0->background; + v2->unk_EC = param0->terrain; + v2->unk_F0 = param0->mapLabelTextID; v2->unk_F4 = param0->mapHeaderID; - v2->unk_F8 = param0->unk_138; - v2->unk_FC = param0->unk_13C; - v2->unk_100 = param0->unk_140; - v2->unk_104 = param0->unk_144; - v2->unk_108 = param0->unk_148; - v2->unk_10C = param0->unk_14C; - v2->unk_110 = param0->unk_150; - v2->unk_124 = param0->unk_164; - v2->unk_128 = param0->unk_168; - v2->unk_12C = param0->unk_16C; - v2->unk_130 = param0->unk_174; - v2->unk_144 = param0->unk_188; - v2->unk_146 = param0->unk_18B; - v2->unk_148 = param0->unk_18C; + v2->unk_F8 = param0->timeOfDay; + v2->unk_FC = param0->mapEvolutionMethod; + v2->unk_100 = param0->visitedContestHall; + v2->unk_104 = param0->metBebe; + v2->unk_108 = param0->caughtBattlerIdx; + v2->unk_10C = param0->fieldWeather; + v2->unk_110 = param0->leveledUpMonsMask; + v2->unk_124 = param0->battleStatusMask; + v2->unk_128 = param0->countSafariBalls; + v2->unk_12C = param0->rulesetMask; + v2->unk_130 = param0->seed; + v2->unk_144 = param0->networkID; + v2->unk_146 = param0->dummy18B; + v2->unk_148 = param0->totalTurnsElapsed; for (v0 = 0; v0 < 4; v0++) { v2->unk_08[v0] = param0->trainerIDs[v0]; v2->unk_18[v0] = param0->trainerData[v0]; - if (param0->unk_154[v0] == 0) { + if (param0->systemVersion[v0] == 0) { v2->unk_114[v0] = 0x140; } else { - v2->unk_114[v0] = param0->unk_154[v0]; + v2->unk_114[v0] = param0->systemVersion[v0]; } v2->unk_134[v0] = param0->unk_178[v0]; @@ -491,12 +492,12 @@ void sub_0202F8AC(FieldBattleDTO *param0) for (v0 = 0; v0 < 4; v0++) { sub_0202FCE8(param0->parties[v0], &v1->unk_1150[v0]); - TrainerInfo_Copy(param0->unk_D0[v0], &v1->unk_1B68[v0]); + TrainerInfo_Copy(param0->trainerInfo[v0], &v1->unk_1B68[v0]); - v2->unk_14C[v0] = Sound_Chatter(param0->unk_F0[v0]); + v2->unk_14C[v0] = Sound_Chatter(param0->chatotCries[v0]); } - Options_Copy(param0->unk_108, &v1->unk_1BE8); + Options_Copy(param0->options, &v1->unk_1BE8); } void sub_0202FAA8(int param0, u32 param1) @@ -542,43 +543,43 @@ void sub_0202FAFC(FieldBattleDTO *param0, SaveData *param1) UnkStruct_0202F298 *v1 = &Unk_021C07A4->unk_E8; param0->battleType = v1->unk_00.unk_00; - param0->unk_128 = v1->unk_00.unk_E8; - param0->unk_12C = v1->unk_00.unk_EC; - param0->unk_130 = v1->unk_00.unk_F0; + param0->background = v1->unk_00.unk_E8; + param0->terrain = v1->unk_00.unk_EC; + param0->mapLabelTextID = v1->unk_00.unk_F0; param0->mapHeaderID = v1->unk_00.unk_F4; - param0->unk_138 = v1->unk_00.unk_F8; - param0->unk_13C = v1->unk_00.unk_FC; - param0->unk_140 = v1->unk_00.unk_100; - param0->unk_144 = v1->unk_00.unk_104; - param0->unk_148 = v1->unk_00.unk_108; - param0->unk_14C = v1->unk_00.unk_10C; - param0->unk_164 = v1->unk_00.unk_124 | 0x10; - param0->unk_168 = v1->unk_00.unk_128; - param0->unk_16C = v1->unk_00.unk_12C; - param0->unk_174 = v1->unk_00.unk_130; - param0->unk_188 = v1->unk_00.unk_144; - param0->unk_14 = 0; - param0->unk_150 = 0; + param0->timeOfDay = v1->unk_00.unk_F8; + param0->mapEvolutionMethod = v1->unk_00.unk_FC; + param0->visitedContestHall = v1->unk_00.unk_100; + param0->metBebe = v1->unk_00.unk_104; + param0->caughtBattlerIdx = v1->unk_00.unk_108; + param0->fieldWeather = v1->unk_00.unk_10C; + param0->battleStatusMask = v1->unk_00.unk_124 | BATTLE_STATUS_RECORDING; + param0->countSafariBalls = v1->unk_00.unk_128; + param0->rulesetMask = v1->unk_00.unk_12C; + param0->seed = v1->unk_00.unk_130; + param0->networkID = v1->unk_00.unk_144; + param0->resultMask = BATTLE_IN_PROGRESS; + param0->leveledUpMonsMask = 0; - sub_02026338(SaveData_Pokedex(param1), param0->unk_E8); + sub_02026338(SaveData_Pokedex(param1), param0->pokedex); for (v0 = 0; v0 < 4; v0++) { param0->trainerIDs[v0] = v1->unk_00.unk_08[v0]; param0->trainerData[v0] = v1->unk_00.unk_18[v0]; - param0->unk_154[v0] = v1->unk_00.unk_114[v0]; + param0->systemVersion[v0] = v1->unk_00.unk_114[v0]; param0->unk_178[v0] = v1->unk_00.unk_134[v0]; sub_0202FD30(&v1->unk_1150[v0], param0->parties[v0]); - TrainerInfo_Copy(&v1->unk_1B68[v0], param0->unk_D0[v0]); + TrainerInfo_Copy(&v1->unk_1B68[v0], param0->trainerInfo[v0]); param0->unk_194[v0] = v1->unk_00.unk_14C[v0]; } - Options_Copy(SaveData_Options(param1), param0->unk_108); - param0->unk_108->frame = v1->unk_1BE8.frame; + Options_Copy(SaveData_Options(param1), param0->options); + param0->options->frame = v1->unk_1BE8.frame; - if (param0->unk_108->frame >= 20) { - param0->unk_108->frame = 0; + if (param0->options->frame >= 20) { + param0->options->frame = 0; } } diff --git a/src/unk_020562F8.c b/src/unk_020562F8.c index 08a5816b1..c04b778ee 100644 --- a/src/unk_020562F8.c +++ b/src/unk_020562F8.c @@ -3,6 +3,7 @@ #include #include +#include "constants/battle.h" #include "constants/species.h" #include "consts/game_records.h" @@ -260,11 +261,11 @@ static BOOL sub_02056554(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1, i static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkStruct_020564B4 *param2) { - switch (param1->unk_14) { - case 0x4: + switch (param1->resultMask) { + case BATTLE_RESULT_CAPTURED_MON: param2->unk_30[param2->unk_3C] = sub_020564B4(param2) + 1; break; - case 0x5: + case BATTLE_RESULT_PLAYER_FLED: break; default: GF_ASSERT(0); diff --git a/src/unk_0207A6DC.c b/src/unk_0207A6DC.c index 91353ca7e..b6442d07c 100644 --- a/src/unk_0207A6DC.c +++ b/src/unk_0207A6DC.c @@ -159,9 +159,9 @@ static u8 *sub_0207A778(int param0, void *param1, int param2) UnkStruct_0207A778 *v0 = param1; if (v0->unk_00->battleType & BATTLE_TYPE_FRONTIER) { - return (u8 *)v0->unk_00->unk_D0[param0 * 2]; + return (u8 *)v0->unk_00->trainerInfo[param0 * 2]; } else { - return (u8 *)v0->unk_00->unk_D0[param0]; + return (u8 *)v0->unk_00->trainerInfo[param0]; } } @@ -192,9 +192,9 @@ static u8 *sub_0207A7D4(int param0, void *param1, int param2) UnkStruct_0207A778 *v0 = param1; if (v0->unk_00->battleType & BATTLE_TYPE_FRONTIER) { - return (u8 *)v0->unk_00->unk_F0[param0 * 2]; + return (u8 *)v0->unk_00->chatotCries[param0 * 2]; } else { - return (u8 *)v0->unk_00->unk_F0[param0]; + return (u8 *)v0->unk_00->chatotCries[param0]; } } @@ -307,8 +307,8 @@ static void sub_0207A934(int param0, int param1, void *param2, void *param3) { UnkStruct_0207A778 *v0 = (UnkStruct_0207A778 *)param3; - v0->unk_00->unk_154[param0] = *((u32 *)param2); - sub_0202FAA8(param0, v0->unk_00->unk_154[param0]); + v0->unk_00->systemVersion[param0] = *((u32 *)param2); + sub_0202FAA8(param0, v0->unk_00->systemVersion[param0]); v0->unk_1020++; } @@ -321,7 +321,7 @@ BOOL sub_0207A960(UnkStruct_0207A778 *param0) } v0 = (TrainerInfo *)¶m0->unk_20[0]; - TrainerInfo_Copy(param0->unk_00->unk_D0[0], v0); + TrainerInfo_Copy(param0->unk_00->trainerInfo[0], v0); return 1; } @@ -421,7 +421,7 @@ BOOL sub_0207AAA0(UnkStruct_0207A778 *param0) } v0 = (ChatotCry *)¶m0->unk_20[0]; - CopyChatotCryData(v0, param0->unk_00->unk_F0[0]); + CopyChatotCryData(v0, param0->unk_00->chatotCries[0]); return 1; } @@ -451,9 +451,9 @@ BOOL sub_0207AAFC(UnkStruct_0207A778 *param0) v0 = (UnkStruct_02027F8C *)¶m0->unk_20[0]; if (param0->unk_00->battleType & BATTLE_TYPE_FRONTIER) { - v1 = param0->unk_00->unk_D0[CommSys_CurNetId() * 2]; + v1 = param0->unk_00->trainerInfo[CommSys_CurNetId() * 2]; } else { - v1 = param0->unk_00->unk_D0[CommSys_CurNetId()]; + v1 = param0->unk_00->trainerInfo[CommSys_CurNetId()]; } sub_0207ADD4(v1, param0->unk_00->unk_124, (UnkStruct_02027F8C *)param0->unk_20); diff --git a/src/unk_0208BA78.c b/src/unk_0208BA78.c index dfd5fa78e..743ed9133 100644 --- a/src/unk_0208BA78.c +++ b/src/unk_0208BA78.c @@ -265,7 +265,7 @@ static BOOL sub_0208BC8C(UnkStruct_0208BC3C *param0, int param1) v0 = 1; } - param0->unk_10->unk_E4 = BagCursor_New(param1); + param0->unk_10->bagCursor = BagCursor_New(param1); param0->unk_10->records = SaveData_GetGameRecordsPtr(param0->saveData); if (Overlay_LoadByID(FS_OVERLAY_ID(overlay62), 2) == 1) { @@ -276,7 +276,7 @@ static BOOL sub_0208BC8C(UnkStruct_0208BC3C *param0, int param1) param0->unk_14->unk_874 = 1; if (v0 != 1) { - Heap_FreeToHeap(param0->unk_10->unk_E4); + Heap_FreeToHeap(param0->unk_10->bagCursor); sub_020520A4(param0->unk_10); param0->unk_00 = 0; return 1; @@ -310,7 +310,7 @@ static BOOL sub_0208BC8C(UnkStruct_0208BC3C *param0, int param1) } } - Heap_FreeToHeap(param0->unk_10->unk_E4); + Heap_FreeToHeap(param0->unk_10->bagCursor); sub_020520A4(param0->unk_10); OverlayManager_Free(param0->unk_08);