From 36a61f6a69ce672ed4eeb59302018c86eecc6571 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Sun, 29 Dec 2024 20:27:33 -0500 Subject: [PATCH 01/11] initial pal park documentation pass --- include/core_sys.h | 2 +- include/{unk_020562F8.h => pal_park.h} | 14 ++-- platinum.us/main.lsf | 2 +- src/encounter.c | 4 +- src/field_menu.c | 6 +- src/main.c | 2 +- src/meson.build | 2 +- src/overlay005/field_control.c | 2 +- src/overlay006/ov6_022477B8.c | 12 +-- src/overlay097/ov97_02233B18.c | 4 +- src/overlay097/ov97_02236380.c | 12 +-- src/{unk_020562F8.c => pal_park.c} | 104 ++++++++++++------------- src/scrcmd.c | 2 +- src/unk_02017728.c | 2 +- src/unk_0204C500.c | 10 +-- 15 files changed, 90 insertions(+), 90 deletions(-) rename include/{unk_020562F8.h => pal_park.h} (53%) rename src/{unk_020562F8.c => pal_park.c} (71%) diff --git a/include/core_sys.h b/include/core_sys.h index 68823ff51a..e867946a39 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -49,7 +49,7 @@ typedef struct CoreSys { u16 touchHeld; u8 unk_64; u8 unk_65; - u8 unk_66; + u8 gbaCartridgeVersion; u8 inhibitSleep; u8 inhibitReset; u8 padding_69[3]; diff --git a/include/unk_020562F8.h b/include/pal_park.h similarity index 53% rename from include/unk_020562F8.h rename to include/pal_park.h index 394e1b0cef..94c780de21 100644 --- a/include/unk_020562F8.h +++ b/include/pal_park.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_UNK_020562F8_H -#define POKEPLATINUM_UNK_020562F8_H +#ifndef POKEPLATINUM_PAL_PARK_H +#define POKEPLATINUM_PAL_PARK_H #include "field/field_system_decl.h" @@ -10,9 +10,9 @@ void sub_02056328(FieldSystem *fieldSystem); BOOL sub_02056374(FieldSystem *fieldSystem, int param1, int param2); FieldBattleDTO *sub_0205639C(FieldSystem *fieldSystem); void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1); -int sub_020563BC(FieldSystem *fieldSystem); -int sub_020563D0(FieldSystem *fieldSystem); -int sub_020563E0(FieldSystem *fieldSystem); -int sub_020563F0(FieldSystem *fieldSystem); +int PalPark_GetParkBallCount(FieldSystem *fieldSystem); +int PalPark_GetCatchingPoints(FieldSystem *fieldSystem); +int PalPark_GetTimePoints(FieldSystem *fieldSystem); +int PalPark_GetTypePoints(FieldSystem *fieldSystem); -#endif // POKEPLATINUM_UNK_020562F8_H +#endif // POKEPLATINUM_PAL_PARK_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 7df1d10797..fa17736745 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -232,7 +232,7 @@ Static main Object main.nef.p/src_field_transition.c.o Object main.nef.p/src_unk_020559DC.c.o Object main.nef.p/src_unk_02055C50.c.o - Object main.nef.p/src_unk_020562F8.c.o + Object main.nef.p/src_pal_park.c.o Object main.nef.p/src_poketch_data.c.o Object main.nef.p/src_unk_02056B30.c.o Object main.nef.p/src_unk_020573FC.c.o diff --git a/src/encounter.c b/src/encounter.c index a69f082a1f..9f3ffe47a6 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -34,6 +34,7 @@ #include "journal.h" #include "location.h" #include "map_object.h" +#include "pal_park.h" #include "party.h" #include "pokemon.h" #include "pokeradar.h" @@ -46,7 +47,6 @@ #include "unk_0202F1D4.h" #include "unk_0203D1B8.h" #include "unk_020528D0.h" -#include "unk_020562F8.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "unk_020797C8.h" @@ -637,7 +637,7 @@ static BOOL FieldTask_PalParkEncounter(FieldTask *task) case 6: FreeEncounter(encounter); - if (sub_020563BC(fieldSystem) == 0) { + if (PalPark_GetParkBallCount(fieldSystem) == 0) { ScriptManager_Change(task, 3, NULL); return FALSE; } else { diff --git a/src/field_menu.c b/src/field_menu.c index 00b0ebb255..6268faa6dd 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -50,6 +50,7 @@ #include "menu.h" #include "message.h" #include "narc.h" +#include "pal_park.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" @@ -77,7 +78,6 @@ #include "unk_0203D1B8.h" #include "unk_020553DC.h" #include "unk_020559DC.h" -#include "unk_020562F8.h" #include "unk_0205B33C.h" #include "unk_0205C22C.h" #include "unk_0205F180.h" @@ -691,9 +691,9 @@ static void sub_0203B094(FieldTask *taskMan) StringTemplate_SetNumber(v3, 0, *v7, 2, 0, 1); } else { - int v8 = sub_020563BC(fieldSystem); + int parkBallCount = PalPark_GetParkBallCount(fieldSystem); - StringTemplate_SetNumber(v3, 0, v8, 2, 0, 1); + StringTemplate_SetNumber(v3, 0, parkBallCount, 2, 0, 1); } StringTemplate_Format(v3, v4, v5); diff --git a/src/main.c b/src/main.c index 5e55ec2f1b..80c90c9627 100644 --- a/src/main.c +++ b/src/main.c @@ -339,7 +339,7 @@ void HandleConsoleFold(void) sleep_again: trigger = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD; - if (gCoreSys.unk_66 && !gIgnoreCartridgeForWake) { + if (gCoreSys.gbaCartridgeVersion && !gIgnoreCartridgeForWake) { trigger |= PM_TRIGGER_CARTRIDGE; } diff --git a/src/meson.build b/src/meson.build index 785fefdc3e..78d6b3aaa7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -220,7 +220,7 @@ pokeplatinum_c = files( 'field_transition.c', 'unk_020559DC.c', 'unk_02055C50.c', - 'unk_020562F8.c', + 'pal_park.c', 'poketch_data.c', 'unk_02056B30.c', 'unk_020573FC.c', diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 608138404e..ec8873b868 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -45,6 +45,7 @@ #include "map_header_data.h" #include "map_object.h" #include "map_tile_behavior.h" +#include "pal_park.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" @@ -60,7 +61,6 @@ #include "unk_0203C954.h" #include "unk_02054884.h" #include "unk_02054D00.h" -#include "unk_020562F8.h" #include "unk_02056B30.h" #include "unk_0205A0D8.h" #include "unk_0205B33C.h" diff --git a/src/overlay006/ov6_022477B8.c b/src/overlay006/ov6_022477B8.c index bac84c29dc..01d82181ab 100644 --- a/src/overlay006/ov6_022477B8.c +++ b/src/overlay006/ov6_022477B8.c @@ -13,24 +13,24 @@ void WildEncounters_ReplaceDualSlotEncounters(const WildEncounters *encounterDat return; } - switch (gCoreSys.unk_66) { - case 1: + switch (gCoreSys.gbaCartridgeVersion) { + case SAPPHIRE: (*param2) = encounterData->dualSlotSapphireEncounters[0]; (*param3) = encounterData->dualSlotSapphireEncounters[1]; break; - case 2: + case RUBY: (*param2) = encounterData->dualSlotRubyEncounters[0]; (*param3) = encounterData->dualSlotRubyEncounters[1]; break; - case 3: + case EMERALD: (*param2) = encounterData->dualSlotEmeraldEncouters[0]; (*param3) = encounterData->dualSlotEmeraldEncouters[1]; break; - case 4: + case FIRERED: (*param2) = encounterData->dualSlotFireredEncounters[0]; (*param3) = encounterData->dualSlotFireredEncounters[1]; break; - case 5: + case LEAFGREEN: (*param2) = encounterData->dualSlotLeafgreenEncounters[0]; (*param3) = encounterData->dualSlotLeafgreenEncounters[1]; break; diff --git a/src/overlay097/ov97_02233B18.c b/src/overlay097/ov97_02233B18.c index 1e6114eab4..63d1fc3440 100644 --- a/src/overlay097/ov97_02233B18.c +++ b/src/overlay097/ov97_02233B18.c @@ -704,7 +704,7 @@ static void ov97_022343A8(UnkStruct_ov97_02234A2C *param0) v1 = ov97_02234124(param0, param0->unk_E8E4, v0); v2 = ov97_02234148(param0, param0->unk_E8E4, v0); v5 = ov97_0223416C(param0, param0->unk_E8E4, v0); - v3 = gCoreSys.unk_66; + v3 = gCoreSys.gbaCartridgeVersion; v4 = GBASpeciesToDSFormId(ov97_02236DD0(v1), v5, v3); ov97_022342E4(v1, v2, v4, v0, param0->unk_20C[v0].unk_00, v6, v7); @@ -1471,7 +1471,7 @@ static void ov97_02234F88(UnkStruct_ov97_02234A2C *param0) v1 = ov97_02234124(param0, param0->unk_42C[v0].unk_08, param0->unk_42C[v0].unk_04); v2 = ov97_02234148(param0, param0->unk_42C[v0].unk_08, param0->unk_42C[v0].unk_04); v4 = ov97_0223416C(param0, param0->unk_42C[v0].unk_08, param0->unk_42C[v0].unk_04); - v3 = gCoreSys.unk_66; + v3 = gCoreSys.gbaCartridgeVersion; ov97_02234278(v1, v2, v4, v3, v0, param0->unk_478[v0]); } diff --git a/src/overlay097/ov97_02236380.c b/src/overlay097/ov97_02236380.c index 810948f205..3260185e0b 100644 --- a/src/overlay097/ov97_02236380.c +++ b/src/overlay097/ov97_02236380.c @@ -1566,19 +1566,19 @@ void BoxMonGBAToBoxMon(BoxPokemonGBA *param0, BoxPokemon *param1) } if (BoxPokemon_GetValue(param1, MON_DATA_SPECIES, NULL) == SPECIES_DEOXYS) { - switch (gCoreSys.unk_66) { + switch (gCoreSys.gbaCartridgeVersion) { default: - case 2: - case 1: + case RUBY: + case SAPPHIRE: v1 = 0; break; - case 4: + case FIRERED: v1 = 1; break; - case 5: + case LEAFGREEN: v1 = 2; break; - case 3: + case EMERALD: v1 = 3; break; } diff --git a/src/unk_020562F8.c b/src/pal_park.c similarity index 71% rename from src/unk_020562F8.c rename to src/pal_park.c index 2a08d6b9f3..354ead2343 100644 --- a/src/unk_020562F8.c +++ b/src/pal_park.c @@ -1,4 +1,4 @@ -#include "unk_020562F8.h" +#include "pal_park.h" #include #include @@ -46,12 +46,12 @@ static void sub_0205642C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1); static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkStruct_020564B4 *param2); static BOOL sub_02056554(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1, int param2, int param3); static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1); -static sub_020564B4(UnkStruct_020564B4 *param0); +static NumMonsCaptured(UnkStruct_020564B4 *param0); static void sub_020564D0(UnkStruct_020564B4 *param0); static BOOL sub_020564F4(UnkStruct_020564B4 *param0); -static u32 sub_020566AC(UnkStruct_020564B4 *param0); -static u32 sub_02056698(UnkStruct_020564B4 *param0); -static u32 sub_0205671C(UnkStruct_020564B4 *param0); +static u32 CalculateTypePoints(UnkStruct_020564B4 *param0); +static u32 CalculateCatchingPoints(UnkStruct_020564B4 *param0); +static u32 GetTimePoints(UnkStruct_020564B4 *param0); static UnkStruct_020564B4 Unk_021C07FC; @@ -103,24 +103,24 @@ void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1) sub_02056624(fieldSystem, param1, &Unk_021C07FC); } -int sub_020563BC(FieldSystem *fieldSystem) +int PalPark_GetParkBallCount(FieldSystem *fieldSystem) { - return 6 - sub_020564B4(&Unk_021C07FC); + return 6 - NumMonsCaptured(&Unk_021C07FC); } -int sub_020563D0(FieldSystem *fieldSystem) +int PalPark_GetCatchingPoints(FieldSystem *fieldSystem) { - return sub_02056698(&Unk_021C07FC); + return CalculateCatchingPoints(&Unk_021C07FC); } -int sub_020563E0(FieldSystem *fieldSystem) +int PalPark_GetTimePoints(FieldSystem *fieldSystem) { - return sub_0205671C(&Unk_021C07FC); + return GetTimePoints(&Unk_021C07FC); } -int sub_020563F0(FieldSystem *fieldSystem) +int PalPark_GetTypePoints(FieldSystem *fieldSystem) { - return sub_020566AC(&Unk_021C07FC); + return CalculateTypePoints(&Unk_021C07FC); } static void sub_02056400(u32 param0, u8 *param1) @@ -168,18 +168,18 @@ static void sub_0205642C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1) Heap_FreeToHeap(v3); } -static int sub_020564B4(UnkStruct_020564B4 *param0) +static int NumMonsCaptured(UnkStruct_020564B4 *param0) { - int v0; - int v1 = 0; + int i; + int numMonsCaptured = 0; - for (v0 = 0; v0 < 6; v0++) { - if (param0->unk_30[v0] != 0) { - v1++; + for (i = 0; i < 6; i++) { + if (param0->unk_30[i] != 0) { + numMonsCaptured++; } } - return v1; + return numMonsCaptured; } static void sub_020564D0(UnkStruct_020564B4 *param0) @@ -263,7 +263,7 @@ static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkSt { switch (param1->resultMask) { case BATTLE_RESULT_CAPTURED_MON: - param2->unk_30[param2->unk_3C] = sub_020564B4(param2) + 1; + param2->unk_30[param2->unk_3C] = NumMonsCaptured(param2) + 1; break; case BATTLE_RESULT_PLAYER_FLED: break; @@ -277,9 +277,9 @@ static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 FieldBattleDTO *v0; Pokemon *v1 = Pokemon_New(32); PalParkTransfer *v2 = SaveData_PalParkTransfer(fieldSystem->saveData); - int v3 = sub_020563BC(fieldSystem); + int parkBallCount = PalPark_GetParkBallCount(fieldSystem); - v0 = FieldBattleDTO_NewPalPark(11, v3); + v0 = FieldBattleDTO_NewPalPark(11, parkBallCount); FieldBattleDTO_Init(v0, fieldSystem); sub_0202F000(v2, param1->unk_3C, v1); @@ -289,55 +289,55 @@ static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 return v0; } -static u32 sub_02056698(UnkStruct_020564B4 *param0) +static u32 CalculateCatchingPoints(UnkStruct_020564B4 *param0) { - int v0; - u32 v1 = 0; + int i; + u32 catchingPoints = 0; - for (v0 = 0; v0 < 6; v0++) { - v1 += param0->unk_00[v0].unk_04; + for (i = 0; i < 6; i++) { + catchingPoints += param0->unk_00[i].unk_04; } - return v1; + return catchingPoints; } -static u32 sub_020566AC(UnkStruct_020564B4 *param0) +static u32 CalculateTypePoints(UnkStruct_020564B4 *param0) { - int v0, v1; - int v2, v3, v4, v5; - u32 v6 = 0; - u32 v7 = 0; - - for (v0 = 1; v0 < 6 + 1; v0++) { - for (v1 = 0; v1 < 6; v1++) { - if (param0->unk_30[v1] == v0) { - v4 = param0->unk_00[v1].unk_06; - v5 = param0->unk_00[v1].unk_07; - - if ((v0 != 1) && (v2 != v4) && (v2 != v5) && (v3 != v4) && (v3 != v5)) { - v7 += 200; + int i, j; + int typeToCheck1, typeToCheck2, typeAlreadyOwned1, typeAlreadyOwned2; + u32 distinctTypeTracker = 0; + u32 totalTypePoints = 0; + + for (i = 1; i < 6 + 1; i++) { + for (j = 0; j < 6; j++) { + if (param0->unk_30[j] == i) { + typeAlreadyOwned1 = param0->unk_00[j].unk_06; + typeAlreadyOwned2 = param0->unk_00[j].unk_07; + + if ((i != 1) && (typeToCheck1 != typeAlreadyOwned1) && (typeToCheck1 != typeAlreadyOwned2) && (typeToCheck2 != typeAlreadyOwned1) && (typeToCheck2 != typeAlreadyOwned2)) { + totalTypePoints += 200; } - v2 = v4; - v3 = v5; - v6 |= (1 << v2); - v6 |= (1 << v3); + typeToCheck1 = typeAlreadyOwned1; + typeToCheck2 = typeAlreadyOwned2; + distinctTypeTracker |= (1 << typeToCheck1); + distinctTypeTracker |= (1 << typeToCheck2); break; } } } - for (; v6 != 0; v6 >>= 1) { - if (v6 & 1) { - v7 += 50; + for (; distinctTypeTracker != 0; distinctTypeTracker >>= 1) { + if (distinctTypeTracker & 1) { + totalTypePoints += 50; } } - return v7; + return totalTypePoints; } -static u32 sub_0205671C(UnkStruct_020564B4 *param0) +static u32 GetTimePoints(UnkStruct_020564B4 *param0) { return param0->unk_48; } diff --git a/src/scrcmd.c b/src/scrcmd.c index 765ea9b49c..5a778af3a9 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -7065,7 +7065,7 @@ static BOOL ScrCmd_26E(ScriptContext *ctx) { u16 *v0 = ScriptContext_GetVarPointer(ctx); - *v0 = gCoreSys.unk_66; + *v0 = gCoreSys.gbaCartridgeVersion; return 1; } diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 8927d17fd1..3a04bcfce0 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -300,7 +300,7 @@ void InitKeypadAndTouchpad(void) void sub_02017B70(int param0) { - gCoreSys.unk_66 = param0; + gCoreSys.gbaCartridgeVersion = param0; } void SleepLock(u8 param0) diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 751c348b9b..861834f99a 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -12,6 +12,7 @@ #include "field_script_context.h" #include "heap.h" #include "inlines.h" +#include "pal_park.h" #include "pokemon.h" #include "save_player.h" #include "system_flags.h" @@ -19,7 +20,6 @@ #include "unk_0202631C.h" #include "unk_0202EEC0.h" #include "unk_0202F180.h" -#include "unk_020562F8.h" #include "unk_020797C8.h" #include "unk_02092494.h" #include "vars_flags.h" @@ -89,16 +89,16 @@ BOOL ScrCmd_256(ScriptContext *param0) switch (v0) { case 0: - *v1 = sub_020563D0(param0->fieldSystem); + *v1 = PalPark_GetCatchingPoints(param0->fieldSystem); break; case 1: - *v1 = sub_020563E0(param0->fieldSystem); + *v1 = PalPark_GetTimePoints(param0->fieldSystem); break; case 2: - *v1 = sub_020563F0(param0->fieldSystem); + *v1 = PalPark_GetTypePoints(param0->fieldSystem); break; case 3: - *v1 = sub_020563D0(param0->fieldSystem) + sub_020563F0(param0->fieldSystem) + sub_020563E0(param0->fieldSystem); + *v1 = PalPark_GetCatchingPoints(param0->fieldSystem) + PalPark_GetTypePoints(param0->fieldSystem) + PalPark_GetTimePoints(param0->fieldSystem); break; } From 1e806dc85f0aa1a3437e664bc3098bb45d9c2288 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Mon, 30 Dec 2024 17:27:46 -0500 Subject: [PATCH 02/11] continuing pal park documentation --- include/pal_park.h | 22 ++- include/struct_decls/struct_020564B4_decl.h | 6 - src/overlay005/field_control.c | 2 +- src/pal_park.c | 183 +++++++++----------- src/unk_0204C500.c | 2 +- 5 files changed, 104 insertions(+), 111 deletions(-) delete mode 100644 include/struct_decls/struct_020564B4_decl.h diff --git a/include/pal_park.h b/include/pal_park.h index 94c780de21..9dc6e57184 100644 --- a/include/pal_park.h +++ b/include/pal_park.h @@ -5,9 +5,27 @@ #include "field_battle_data_transfer.h" -void sub_020562F8(FieldSystem *fieldSystem); +typedef struct PalParkPokemon{ + u16 unk_00; + u8 encounterType; + u8 unk_03; + u16 unk_04; + u8 type1; + u8 type2; +} PalParkPokemon; + +typedef struct PalParkCatchingShowData { + PalParkPokemon palParkPokemon[6]; + u8 unk_30[6]; + int steps; + int unk_3C; + s64 unk_40; + int timePoints; +} PalParkCatchingShowData; + +void PalPark_InitCatchingShowData(FieldSystem *fieldSystem); void sub_02056328(FieldSystem *fieldSystem); -BOOL sub_02056374(FieldSystem *fieldSystem, int param1, int param2); +BOOL PalPark_CheckWildEncounter(FieldSystem *fieldSystem, int param1, int param2); FieldBattleDTO *sub_0205639C(FieldSystem *fieldSystem); void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1); int PalPark_GetParkBallCount(FieldSystem *fieldSystem); diff --git a/include/struct_decls/struct_020564B4_decl.h b/include/struct_decls/struct_020564B4_decl.h deleted file mode 100644 index c59459fe00..0000000000 --- a/include/struct_decls/struct_020564B4_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_020564B4_DECL_H -#define POKEPLATINUM_STRUCT_020564B4_DECL_H - -typedef struct UnkStruct_020564B4_t UnkStruct_020564B4; - -#endif // POKEPLATINUM_STRUCT_020564B4_DECL_H diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index ec8873b868..6abe7feb35 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -548,7 +548,7 @@ static BOOL Field_CheckWildEncounter(FieldSystem *fieldSystem) Field_GetPlayerPos(fieldSystem, &playerX, &playerZ); if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { - if (sub_02056374(fieldSystem, playerX, playerZ) == TRUE) { + if (PalPark_CheckWildEncounter(fieldSystem, playerX, playerZ) == TRUE) { Encounter_NewVsPalParkTransfer(fieldSystem, sub_0205639C(fieldSystem)); return TRUE; } else { diff --git a/src/pal_park.c b/src/pal_park.c index 354ead2343..2d686df04c 100644 --- a/src/pal_park.c +++ b/src/pal_park.c @@ -8,7 +8,6 @@ #include "consts/game_records.h" #include "struct_decls/struct_02024440_decl.h" -#include "struct_decls/struct_020564B4_decl.h" #include "field/field_system.h" #include "savedata/save_table.h" @@ -24,103 +23,85 @@ #include "unk_0202EEC0.h" #include "unk_02054D00.h" -typedef struct { - u16 unk_00; - u8 unk_02; - u8 unk_03; - u16 unk_04; - u8 unk_06; - u8 unk_07; -} UnkStruct_020564B4_sub1; - -struct UnkStruct_020564B4_t { - UnkStruct_020564B4_sub1 unk_00[6]; - u8 unk_30[6]; - int unk_38; - int unk_3C; - s64 unk_40; - int unk_48; -}; - -static void sub_0205642C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1); -static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkStruct_020564B4 *param2); -static BOOL sub_02056554(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1, int param2, int param3); -static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1); -static NumMonsCaptured(UnkStruct_020564B4 *param0); -static void sub_020564D0(UnkStruct_020564B4 *param0); -static BOOL sub_020564F4(UnkStruct_020564B4 *param0); -static u32 CalculateTypePoints(UnkStruct_020564B4 *param0); -static u32 CalculateCatchingPoints(UnkStruct_020564B4 *param0); -static u32 GetTimePoints(UnkStruct_020564B4 *param0); - -static UnkStruct_020564B4 Unk_021C07FC; - -void sub_020562F8(FieldSystem *fieldSystem) +static void InitEncounterData(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData); +static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, PalParkCatchingShowData *catchingShowData); +static BOOL TryStartEncounter(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData, int param2, int param3); +static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData); +static NumMonsCaptured(PalParkCatchingShowData *catchingShowData); +static void ResetStepCount(PalParkCatchingShowData *catchingShowData); +static BOOL CanCheckEncounter(PalParkCatchingShowData *catchingShowData); +static u32 CalculateTypePoints(PalParkCatchingShowData *catchingShowData); +static u32 CalculateCatchingPoints(PalParkCatchingShowData *catchingShowData); +static u32 GetTimePoints(PalParkCatchingShowData *catchingShowData); + +static PalParkCatchingShowData sCatchingShowData; + +void PalPark_InitCatchingShowData(FieldSystem *fieldSystem) { int v0; - UnkStruct_020564B4 *v1 = &Unk_021C07FC; + PalParkCatchingShowData *v1 = &sCatchingShowData; - MI_CpuClearFast(v1, sizeof(UnkStruct_020564B4)); + MI_CpuClearFast(v1, sizeof(PalParkCatchingShowData)); - sub_0205642C(fieldSystem, v1); - sub_020564D0(v1); + InitEncounterData(fieldSystem, v1); + ResetStepCount(v1); v1->unk_40 = GetTimestamp(); } void sub_02056328(FieldSystem *fieldSystem) { - UnkStruct_020564B4 *v0 = &Unk_021C07FC; + PalParkCatchingShowData *v0 = &sCatchingShowData; GameRecords *v1 = SaveData_GetGameRecordsPtr(fieldSystem->saveData); s64 v2 = GetTimestamp(); s64 v3 = TimeElapsed(v0->unk_40, v2); if (v3 < 1000) { - v0->unk_48 = ((1000 - v3) * 2); + v0->timePoints = ((1000 - v3) * 2); } else { - v0->unk_48 = 0; + v0->timePoints = 0; } GameRecords_IncrementTrainerScore(v1, TRAINER_SCORE_EVENT_UNK_17); } -BOOL sub_02056374(FieldSystem *fieldSystem, int param1, int param2) +BOOL PalPark_CheckWildEncounter(FieldSystem *fieldSystem, int param1, int param2) { - if (sub_020564F4(&Unk_021C07FC) == 1) { - return sub_02056554(fieldSystem, &Unk_021C07FC, param1, param2); + if (CanCheckEncounter(&sCatchingShowData) == 1) { + return TryStartEncounter(fieldSystem, &sCatchingShowData, param1, param2); } else { - return 0; + return FALSE; } } FieldBattleDTO *sub_0205639C(FieldSystem *fieldSystem) { - return sub_0205664C(fieldSystem, &Unk_021C07FC); + return sub_0205664C(fieldSystem, &sCatchingShowData); } void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1) { - sub_02056624(fieldSystem, param1, &Unk_021C07FC); + sub_02056624(fieldSystem, param1, &sCatchingShowData); } int PalPark_GetParkBallCount(FieldSystem *fieldSystem) { - return 6 - NumMonsCaptured(&Unk_021C07FC); + return 6 - NumMonsCaptured(&sCatchingShowData); } int PalPark_GetCatchingPoints(FieldSystem *fieldSystem) { - return CalculateCatchingPoints(&Unk_021C07FC); + return CalculateCatchingPoints(&sCatchingShowData); } int PalPark_GetTimePoints(FieldSystem *fieldSystem) { - return GetTimePoints(&Unk_021C07FC); + return GetTimePoints(&sCatchingShowData); } int PalPark_GetTypePoints(FieldSystem *fieldSystem) { - return CalculateTypePoints(&Unk_021C07FC); + return CalculateTypePoints(&sCatchingShowData); } static void sub_02056400(u32 param0, u8 *param1) @@ -133,48 +114,48 @@ static void sub_02056400(u32 param0, u8 *param1) NARC_ReadFromMemberByIndexPair(param1, NARC_INDEX_ARC__PPARK, 0, v0, sizeof(u8) * 6); } -static void sub_0205642C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1) +static void InitEncounterData(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData) { - int v0; + int i; u8 v1[8]; - u16 v2; - Pokemon *v3; + u16 monSpecies; + Pokemon *mon; PalParkTransfer *v4; v4 = SaveData_PalParkTransfer(fieldSystem->saveData); - v3 = Pokemon_New(4); + mon = Pokemon_New(4); - for (v0 = 0; v0 < 6; v0++) { - param1->unk_30[v0] = 0; - sub_0202F000(v4, v0, v3); + for (i = 0; i < 6; i++) { + catchingShowData->unk_30[i] = 0; + sub_0202F000(v4, i, mon); - v2 = Pokemon_GetValue(v3, MON_DATA_SPECIES, NULL); + monSpecies = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); - param1->unk_00[v0].unk_00 = v2; - sub_02056400(v2, v1); + catchingShowData->palParkPokemon[i].unk_00 = monSpecies; + sub_02056400(monSpecies, v1); if (v1[0] != 0) { - param1->unk_00[v0].unk_02 = v1[0]; + catchingShowData->palParkPokemon[i].encounterType = v1[0]; } else { - param1->unk_00[v0].unk_02 = 5 - 1 + v1[1]; + catchingShowData->palParkPokemon[i].encounterType = 5 - 1 + v1[1]; } - param1->unk_00[v0].unk_03 = v1[3]; - param1->unk_00[v0].unk_04 = v1[2]; - param1->unk_00[v0].unk_06 = Pokemon_GetValue(v3, MON_DATA_TYPE_1, NULL); - param1->unk_00[v0].unk_07 = Pokemon_GetValue(v3, MON_DATA_TYPE_2, NULL); + catchingShowData->palParkPokemon[i].unk_03 = v1[3]; + catchingShowData->palParkPokemon[i].unk_04 = v1[2]; + catchingShowData->palParkPokemon[i].type1 = Pokemon_GetValue(mon, MON_DATA_TYPE_1, NULL); + catchingShowData->palParkPokemon[i].type2 = Pokemon_GetValue(mon, MON_DATA_TYPE_2, NULL); } - Heap_FreeToHeap(v3); + Heap_FreeToHeap(mon); } -static int NumMonsCaptured(UnkStruct_020564B4 *param0) +static int NumMonsCaptured(PalParkCatchingShowData *catchingShowData) { int i; int numMonsCaptured = 0; for (i = 0; i < 6; i++) { - if (param0->unk_30[i] != 0) { + if (catchingShowData->unk_30[i] != 0) { numMonsCaptured++; } } @@ -182,21 +163,21 @@ static int NumMonsCaptured(UnkStruct_020564B4 *param0) return numMonsCaptured; } -static void sub_020564D0(UnkStruct_020564B4 *param0) +static void ResetStepCount(PalParkCatchingShowData *catchingShowData) { - param0->unk_38 = inline_020564D0(10) + 5; + catchingShowData->steps = inline_020564D0(10) + 5; } -static BOOL sub_020564F4(UnkStruct_020564B4 *param0) +static BOOL CanCheckEncounter(PalParkCatchingShowData *catchingShowData) { - param0->unk_38--; + catchingShowData->steps--; - if (param0->unk_38 == 0) { - sub_020564D0(param0); - return 1; + if (catchingShowData->steps == 0) { + ResetStepCount(catchingShowData); + return TRUE; } - return 0; + return FALSE; } static int sub_0205650C(FieldSystem *fieldSystem, int param1, int param2) @@ -216,54 +197,54 @@ static int sub_0205650C(FieldSystem *fieldSystem, int param1, int param2) return 0; } -static BOOL sub_02056554(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1, int param2, int param3) +static BOOL TryStartEncounter(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData, int param2, int param3) { int v0; int v1, v2 = 0; int v3 = sub_0205650C(fieldSystem, param2, param3); if (v3 == 0) { - return 0; + return FALSE; } for (v0 = 0; v0 < 6; v0++) { - if ((param1->unk_30[v0] == 0) && (param1->unk_00[v0].unk_02 == v3)) { - v2 += param1->unk_00[v0].unk_03; + if ((catchingShowData->unk_30[v0] == 0) && (catchingShowData->palParkPokemon[v0].encounterType == v3)) { + v2 += catchingShowData->palParkPokemon[v0].unk_03; } } if (v2 == 0) { - return 0; + return FALSE; } v1 = inline_020564D0(v2 + 20); if (v1 < 20) { - return 0; + return FALSE; } v1 -= 20; for (v0 = 0; v0 < 6; v0++) { - if ((param1->unk_30[v0] == 0) && (param1->unk_00[v0].unk_02 == v3)) { - if (v1 < param1->unk_00[v0].unk_03) { - param1->unk_3C = v0; + if ((catchingShowData->unk_30[v0] == 0) && (catchingShowData->palParkPokemon[v0].encounterType == v3)) { + if (v1 < catchingShowData->palParkPokemon[v0].unk_03) { + catchingShowData->unk_3C = v0; return 1; } else { - v1 -= param1->unk_00[v0].unk_03; + v1 -= catchingShowData->palParkPokemon[v0].unk_03; } } } GF_ASSERT(0); - return 0; + return FALSE; } -static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkStruct_020564B4 *param2) +static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, PalParkCatchingShowData *catchingShowData) { switch (param1->resultMask) { case BATTLE_RESULT_CAPTURED_MON: - param2->unk_30[param2->unk_3C] = NumMonsCaptured(param2) + 1; + catchingShowData->unk_30[catchingShowData->unk_3C] = NumMonsCaptured(catchingShowData) + 1; break; case BATTLE_RESULT_PLAYER_FLED: break; @@ -272,7 +253,7 @@ static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, UnkSt } } -static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 *param1) +static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData) { FieldBattleDTO *v0; Pokemon *v1 = Pokemon_New(32); @@ -282,26 +263,26 @@ static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, UnkStruct_020564B4 v0 = FieldBattleDTO_NewPalPark(11, parkBallCount); FieldBattleDTO_Init(v0, fieldSystem); - sub_0202F000(v2, param1->unk_3C, v1); + sub_0202F000(v2, catchingShowData->unk_3C, v1); FieldBattleDTO_AddPokemonToBattler(v0, v1, 1); Heap_FreeToHeap(v1); return v0; } -static u32 CalculateCatchingPoints(UnkStruct_020564B4 *param0) +static u32 CalculateCatchingPoints(PalParkCatchingShowData *catchingShowData) { int i; u32 catchingPoints = 0; for (i = 0; i < 6; i++) { - catchingPoints += param0->unk_00[i].unk_04; + catchingPoints += catchingShowData->palParkPokemon[i].unk_04; } return catchingPoints; } -static u32 CalculateTypePoints(UnkStruct_020564B4 *param0) +static u32 CalculateTypePoints(PalParkCatchingShowData *catchingShowData) { int i, j; int typeToCheck1, typeToCheck2, typeAlreadyOwned1, typeAlreadyOwned2; @@ -310,9 +291,9 @@ static u32 CalculateTypePoints(UnkStruct_020564B4 *param0) for (i = 1; i < 6 + 1; i++) { for (j = 0; j < 6; j++) { - if (param0->unk_30[j] == i) { - typeAlreadyOwned1 = param0->unk_00[j].unk_06; - typeAlreadyOwned2 = param0->unk_00[j].unk_07; + if (catchingShowData->unk_30[j] == i) { + typeAlreadyOwned1 = catchingShowData->palParkPokemon[j].type1; + typeAlreadyOwned2 = catchingShowData->palParkPokemon[j].type2; if ((i != 1) && (typeToCheck1 != typeAlreadyOwned1) && (typeToCheck1 != typeAlreadyOwned2) && (typeToCheck2 != typeAlreadyOwned1) && (typeToCheck2 != typeAlreadyOwned2)) { totalTypePoints += 200; @@ -337,7 +318,7 @@ static u32 CalculateTypePoints(UnkStruct_020564B4 *param0) return totalTypePoints; } -static u32 GetTimePoints(UnkStruct_020564B4 *param0) +static u32 GetTimePoints(PalParkCatchingShowData *catchingShowData) { - return param0->unk_48; + return catchingShowData->timePoints; } diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 861834f99a..fa30216719 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -31,7 +31,7 @@ BOOL ScrCmd_253(ScriptContext *param0) if (v1 == 0) { SystemFlag_SetInPalPark(v0); - sub_020562F8(param0->fieldSystem); + PalPark_InitCatchingShowData(param0->fieldSystem); } else if (v1 == 1) { SystemFlag_ClearInPalPark(v0); sub_02056328(param0->fieldSystem); From 2f645d7c83823bf9132c93777496d0e2e9b9df5d Mon Sep 17 00:00:00 2001 From: iriv24 Date: Tue, 31 Dec 2024 00:21:08 -0500 Subject: [PATCH 03/11] more documenting, notably rename pal park to catching show --- consts/game_records.json | 2 +- include/catching_show.h | 40 ++++ include/pal_park.h | 36 ---- platinum.us/main.lsf | 2 +- src/catching_show.c | 323 ++++++++++++++++++++++++++++++++ src/encounter.c | 6 +- src/field_menu.c | 4 +- src/game_records.c | 2 +- src/meson.build | 2 +- src/overlay005/field_control.c | 6 +- src/pal_park.c | 324 --------------------------------- src/unk_0204C500.c | 14 +- 12 files changed, 382 insertions(+), 379 deletions(-) create mode 100644 include/catching_show.h delete mode 100644 include/pal_park.h create mode 100644 src/catching_show.c delete mode 100644 src/pal_park.c diff --git a/consts/game_records.json b/consts/game_records.json index 319f7b107a..afe6a2f442 100644 --- a/consts/game_records.json +++ b/consts/game_records.json @@ -174,7 +174,7 @@ "TRAINER_SCORE_EVENT_UNK_14", "TRAINER_SCORE_EVENT_UNK_15", "TRAINER_SCORE_EVENT_UNK_16", - "TRAINER_SCORE_EVENT_UNK_17", + "TRAINER_SCORE_EVENT_FINISHED_CATCHING_SHOW", "TRAINER_SCORE_EVENT_UNK_18", "TRAINER_SCORE_EVENT_UNK_19", "TRAINER_SCORE_EVENT_UNK_20", diff --git a/include/catching_show.h b/include/catching_show.h new file mode 100644 index 0000000000..f0ee33ddc6 --- /dev/null +++ b/include/catching_show.h @@ -0,0 +1,40 @@ +#ifndef POKEPLATINUM_CATCHING_SHOW_H +#define POKEPLATINUM_CATCHING_SHOW_H + +#include "field/field_system_decl.h" + +#include "field_battle_data_transfer.h" + +#define CATCHING_SHOW_MONS 6 + +#define DISTINCT_TYPE_BONUS 50 + +typedef struct CatchingShowPokemon{ + u16 species; + u8 encounterType; + u8 encounterRate; + u16 catchingPoints; + u8 type1; + u8 type2; +} CatchingShowPokemon; + +typedef struct CatchingShow { + CatchingShowPokemon pokemon[CATCHING_SHOW_MONS]; + u8 capturedPokemonIndex[CATCHING_SHOW_MONS]; + int steps; + int currentEncounterIndex; + s64 startTime; + int timePoints; +} CatchingShow; + +void CatchingShow_Start(FieldSystem *fieldSystem); +void CatchingShow_End(FieldSystem *fieldSystem); +BOOL CatchingShow_CheckWildEncounter(FieldSystem *fieldSystem, int playerX, int playerY); +FieldBattleDTO *CatchingShow_GetBattleDTO(FieldSystem *fieldSystem); +void CatchingShow_UpdateBattleResult(FieldSystem *fieldSystem, FieldBattleDTO *dto); +int CatchingShow_GetParkBallCount(FieldSystem *fieldSystem); +int CatchingShow_GetCatchingPoints(FieldSystem *fieldSystem); +int CatchingShow_GetTimePoints(FieldSystem *fieldSystem); +int CatchingShow_GetTypePoints(FieldSystem *fieldSystem); + +#endif // POKEPLATINUM_CATCHING_SHOW_H diff --git a/include/pal_park.h b/include/pal_park.h deleted file mode 100644 index 9dc6e57184..0000000000 --- a/include/pal_park.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef POKEPLATINUM_PAL_PARK_H -#define POKEPLATINUM_PAL_PARK_H - -#include "field/field_system_decl.h" - -#include "field_battle_data_transfer.h" - -typedef struct PalParkPokemon{ - u16 unk_00; - u8 encounterType; - u8 unk_03; - u16 unk_04; - u8 type1; - u8 type2; -} PalParkPokemon; - -typedef struct PalParkCatchingShowData { - PalParkPokemon palParkPokemon[6]; - u8 unk_30[6]; - int steps; - int unk_3C; - s64 unk_40; - int timePoints; -} PalParkCatchingShowData; - -void PalPark_InitCatchingShowData(FieldSystem *fieldSystem); -void sub_02056328(FieldSystem *fieldSystem); -BOOL PalPark_CheckWildEncounter(FieldSystem *fieldSystem, int param1, int param2); -FieldBattleDTO *sub_0205639C(FieldSystem *fieldSystem); -void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1); -int PalPark_GetParkBallCount(FieldSystem *fieldSystem); -int PalPark_GetCatchingPoints(FieldSystem *fieldSystem); -int PalPark_GetTimePoints(FieldSystem *fieldSystem); -int PalPark_GetTypePoints(FieldSystem *fieldSystem); - -#endif // POKEPLATINUM_PAL_PARK_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index fa17736745..f4e98b3f78 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -232,7 +232,7 @@ Static main Object main.nef.p/src_field_transition.c.o Object main.nef.p/src_unk_020559DC.c.o Object main.nef.p/src_unk_02055C50.c.o - Object main.nef.p/src_pal_park.c.o + Object main.nef.p/src_catching_show.c.o Object main.nef.p/src_poketch_data.c.o Object main.nef.p/src_unk_02056B30.c.o Object main.nef.p/src_unk_020573FC.c.o diff --git a/src/catching_show.c b/src/catching_show.c new file mode 100644 index 0000000000..aa4e291fa5 --- /dev/null +++ b/src/catching_show.c @@ -0,0 +1,323 @@ +#include "catching_show.h" + +#include +#include + +#include "constants/battle.h" +#include "constants/species.h" +#include "consts/game_records.h" + +#include "struct_decls/struct_02024440_decl.h" + +#include "field/field_system.h" +#include "savedata/save_table.h" + +#include "field_battle_data_transfer.h" +#include "game_records.h" +#include "heap.h" +#include "inlines.h" +#include "map_tile_behavior.h" +#include "narc.h" +#include "pokemon.h" +#include "rtc.h" +#include "unk_0202EEC0.h" +#include "unk_02054D00.h" + +static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingShow); +static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO *dto, CatchingShow *catchingShow); +static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY); +static FieldBattleDTO *SetupBattleDTO(FieldSystem *fieldSystem, CatchingShow *catchingShow); +static NumMonsCaptured(CatchingShow *catchingShow); +static void ResetStepCount(CatchingShow *catchingShow); +static BOOL IsStepCountZero(CatchingShow *catchingShow); +static u32 CalculateTypePoints(CatchingShow *catchingShow); +static u32 CalculateTotalCatchingPoints(CatchingShow *catchingShow); +static u32 GetTimePoints(CatchingShow *catchingShow); + +static CatchingShow sCatchingShow; + +void CatchingShow_Start(FieldSystem *fieldSystem) +{ + CatchingShow *catchingShow = &sCatchingShow; + + MI_CpuClearFast(catchingShow, sizeof(CatchingShow)); + + InitEncounterData(fieldSystem, catchingShow); + ResetStepCount(catchingShow); + + catchingShow->startTime = GetTimestamp(); +} + +void CatchingShow_End(FieldSystem *fieldSystem) +{ + CatchingShow *catchingShow = &sCatchingShow; + GameRecords *records = SaveData_GetGameRecordsPtr(fieldSystem->saveData); + s64 endTime = GetTimestamp(); + s64 elapsedTime = TimeElapsed(catchingShow->startTime, endTime); + + if (elapsedTime < 1000) { + catchingShow->timePoints = ((1000 - elapsedTime) * 2); + } else { + catchingShow->timePoints = 0; + } + + GameRecords_IncrementTrainerScore(records, TRAINER_SCORE_EVENT_FINISHED_CATCHING_SHOW); +} + +BOOL CatchingShow_CheckWildEncounter(FieldSystem *fieldSystem, int playerX, int playerY) +{ + if (IsStepCountZero(&sCatchingShow) == TRUE) { + return TryStartEncounter(fieldSystem, &sCatchingShow, playerX, playerY); + } else { + return FALSE; + } +} + +FieldBattleDTO *CatchingShow_GetBattleDTO(FieldSystem *fieldSystem) +{ + return SetupBattleDTO(fieldSystem, &sCatchingShow); +} + +void CatchingShow_UpdateBattleResult(FieldSystem *fieldSystem, FieldBattleDTO *dto) +{ + UpdateBattleResultInternal(fieldSystem, dto, &sCatchingShow); +} + +int CatchingShow_GetParkBallCount(FieldSystem *fieldSystem) +{ + return CATCHING_SHOW_MONS - NumMonsCaptured(&sCatchingShow); +} + +int CatchingShow_GetCatchingPoints(FieldSystem *fieldSystem) +{ + return CalculateTotalCatchingPoints(&sCatchingShow); +} + +int CatchingShow_GetTimePoints(FieldSystem *fieldSystem) +{ + return GetTimePoints(&sCatchingShow); +} + +int CatchingShow_GetTypePoints(FieldSystem *fieldSystem) +{ + return CalculateTypePoints(&sCatchingShow); +} + +static void sub_02056400(u32 species, u8 *param1) +{ + int v0; + + GF_ASSERT(0 < species && species <= NATIONAL_DEX_COUNT); + v0 = (species - 1) * 6; + + NARC_ReadFromMemberByIndexPair(param1, NARC_INDEX_ARC__PPARK, 0, v0, sizeof(u8) * 6); +} + +static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingShow) +{ + int i; + u8 v1[8]; + u16 monSpecies; + Pokemon *mon; + PalParkTransfer *v4; + + v4 = SaveData_PalParkTransfer(fieldSystem->saveData); + mon = Pokemon_New(4); + + for (i = 0; i < CATCHING_SHOW_MONS; i++) { + catchingShow->capturedPokemonIndex[i] = 0; + sub_0202F000(v4, i, mon); + + monSpecies = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); + + catchingShow->pokemon[i].species = monSpecies; + sub_02056400(monSpecies, v1); + + if (v1[0] != 0) { + catchingShow->pokemon[i].encounterType = v1[0]; + } else { + catchingShow->pokemon[i].encounterType = 5 - 1 + v1[1]; + } + + catchingShow->pokemon[i].encounterRate = v1[3]; + catchingShow->pokemon[i].catchingPoints = v1[2]; + catchingShow->pokemon[i].type1 = Pokemon_GetValue(mon, MON_DATA_TYPE_1, NULL); + catchingShow->pokemon[i].type2 = Pokemon_GetValue(mon, MON_DATA_TYPE_2, NULL); + } + + Heap_FreeToHeap(mon); +} + +static int NumMonsCaptured(CatchingShow *catchingShow) +{ + int i; + int numMonsCaptured = 0; + + for (i = 0; i < CATCHING_SHOW_MONS; i++) { + if (catchingShow->capturedPokemonIndex[i] != 0) { + numMonsCaptured++; + } + } + + return numMonsCaptured; +} + +static void ResetStepCount(CatchingShow *catchingShow) +{ + catchingShow->steps = inline_020564D0(10) + 5; +} + +static BOOL IsStepCountZero(CatchingShow *catchingShow) +{ + catchingShow->steps--; + + if (catchingShow->steps == 0) { + ResetStepCount(catchingShow); + return TRUE; + } + + return FALSE; +} + +static int GetEncounterType(FieldSystem *fieldSystem, int playerX, int playerY) +{ + u16 tileBehavior = FieldSystem_GetTileBehavior(fieldSystem, playerX, playerY); + int v1; + + v1 = (playerX < 32) ? 0 : 1; + v1 += (playerY < 32) ? 0 : 2; + + if (TileBehavior_IsTallGrass(tileBehavior)) { + return 1 + v1; + } else if (TileBehavior_IsSurfable(tileBehavior)) { + return 5 + v1; + } + + return 0; +} + +static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY) +{ + int i; + int v1, v2 = 0; + int encounterType = GetEncounterType(fieldSystem, playerX, playerY); + + if (encounterType == 0) { + return FALSE; + } + + for (i = 0; i < CATCHING_SHOW_MONS; i++) { + if ((catchingShow->capturedPokemonIndex[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { + v2 += catchingShow->pokemon[i].encounterRate; + } + } + + if (v2 == 0) { + return FALSE; + } + + v1 = inline_020564D0(v2 + 20); + + if (v1 < 20) { + return FALSE; + } + + v1 -= 20; + + for (i = 0; i < CATCHING_SHOW_MONS; i++) { + if ((catchingShow->capturedPokemonIndex[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { + if (v1 < catchingShow->pokemon[i].encounterRate) { + catchingShow->currentEncounterIndex = i; + return 1; + } else { + v1 -= catchingShow->pokemon[i].encounterRate; + } + } + } + + GF_ASSERT(0); + return FALSE; +} + +static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO *dto, CatchingShow *catchingShow) +{ + switch (dto->resultMask) { + case BATTLE_RESULT_CAPTURED_MON: + catchingShow->capturedPokemonIndex[catchingShow->currentEncounterIndex] = NumMonsCaptured(catchingShow) + 1; + break; + case BATTLE_RESULT_PLAYER_FLED: + break; + default: + GF_ASSERT(0); + } +} + +static FieldBattleDTO *SetupBattleDTO(FieldSystem *fieldSystem, CatchingShow *catchingShow) +{ + FieldBattleDTO *dto; + Pokemon *mon = Pokemon_New(32); + PalParkTransfer *v2 = SaveData_PalParkTransfer(fieldSystem->saveData); + int parkBallCount = CatchingShow_GetParkBallCount(fieldSystem); + + dto = FieldBattleDTO_NewPalPark(11, parkBallCount); + + FieldBattleDTO_Init(dto, fieldSystem); + sub_0202F000(v2, catchingShow->currentEncounterIndex, mon); + FieldBattleDTO_AddPokemonToBattler(dto, mon, 1); + Heap_FreeToHeap(mon); + + return dto; +} + +static u32 CalculateTotalCatchingPoints(CatchingShow *catchingShow) +{ + int i; + u32 totalCatchingPoints = 0; + + for (i = 0; i < CATCHING_SHOW_MONS; i++) { + totalCatchingPoints += catchingShow->pokemon[i].catchingPoints; + } + + return totalCatchingPoints; +} + +static u32 CalculateTypePoints(CatchingShow *catchingShow) +{ + int i, j; + int previousMonType1, previousMonType2, currentMonType1, currentMonType2; + u32 distinctTypeTracker = 0; + u32 totalTypePoints = 0; + + for (i = 1; i < CATCHING_SHOW_MONS + 1; i++) { + for (j = 0; j < CATCHING_SHOW_MONS; j++) { + if (catchingShow->capturedPokemonIndex[j] == i) { + currentMonType1 = catchingShow->pokemon[j].type1; + currentMonType2 = catchingShow->pokemon[j].type2; + + if ((i != 1) && (previousMonType1 != currentMonType1) && (previousMonType1 != currentMonType2) && (previousMonType2 != currentMonType1) && (previousMonType2 != currentMonType2)) { + totalTypePoints += 200; + } + + previousMonType1 = currentMonType1; + previousMonType2 = currentMonType2; + distinctTypeTracker |= (1 << previousMonType1); + distinctTypeTracker |= (1 << previousMonType2); + + break; + } + } + } + + for (; distinctTypeTracker != 0; distinctTypeTracker >>= 1) { + if (distinctTypeTracker & 1) { + totalTypePoints += DISTINCT_TYPE_BONUS; + } + } + + return totalTypePoints; +} + +static u32 GetTimePoints(CatchingShow *catchingShow) +{ + return catchingShow->timePoints; +} diff --git a/src/encounter.c b/src/encounter.c index 9f3ffe47a6..7d7a61591a 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -34,7 +34,7 @@ #include "journal.h" #include "location.h" #include "map_object.h" -#include "pal_park.h" +#include "catching_show.h" #include "party.h" #include "pokemon.h" #include "pokeradar.h" @@ -618,7 +618,7 @@ static BOOL FieldTask_PalParkEncounter(FieldTask *task) case 3: UpdateFieldSystemFromDTO(encounter->dto, fieldSystem); - sub_020563AC(fieldSystem, encounter->dto); + CatchingShow_UpdateBattleResult(fieldSystem, encounter->dto); UpdateGameRecords(fieldSystem, encounter->dto); (*state)++; break; @@ -637,7 +637,7 @@ static BOOL FieldTask_PalParkEncounter(FieldTask *task) case 6: FreeEncounter(encounter); - if (PalPark_GetParkBallCount(fieldSystem) == 0) { + if (CatchingShow_GetParkBallCount(fieldSystem) == 0) { ScriptManager_Change(task, 3, NULL); return FALSE; } else { diff --git a/src/field_menu.c b/src/field_menu.c index 6268faa6dd..109de8787c 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -50,7 +50,7 @@ #include "menu.h" #include "message.h" #include "narc.h" -#include "pal_park.h" +#include "catching_show.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" @@ -691,7 +691,7 @@ static void sub_0203B094(FieldTask *taskMan) StringTemplate_SetNumber(v3, 0, *v7, 2, 0, 1); } else { - int parkBallCount = PalPark_GetParkBallCount(fieldSystem); + int parkBallCount = CatchingShow_GetParkBallCount(fieldSystem); StringTemplate_SetNumber(v3, 0, parkBallCount, 2, 0, 1); } diff --git a/src/game_records.c b/src/game_records.c index 2b86b58cb9..1640733738 100644 --- a/src/game_records.c +++ b/src/game_records.c @@ -273,7 +273,7 @@ static const u16 sTrainerScoreIncrements[MAX_TRAINER_SCORE_EVENTS] = { [TRAINER_SCORE_EVENT_UNK_14] = 7, [TRAINER_SCORE_EVENT_UNK_15] = 7, [TRAINER_SCORE_EVENT_UNK_16] = 10, - [TRAINER_SCORE_EVENT_UNK_17] = 10, + [TRAINER_SCORE_EVENT_FINISHED_CATCHING_SHOW] = 10, [TRAINER_SCORE_EVENT_UNK_18] = 11, [TRAINER_SCORE_EVENT_UNK_19] = 11, [TRAINER_SCORE_EVENT_UNK_20] = 11, diff --git a/src/meson.build b/src/meson.build index 78d6b3aaa7..6265238b84 100644 --- a/src/meson.build +++ b/src/meson.build @@ -220,7 +220,7 @@ pokeplatinum_c = files( 'field_transition.c', 'unk_020559DC.c', 'unk_02055C50.c', - 'pal_park.c', + 'catching_show.c', 'poketch_data.c', 'unk_02056B30.c', 'unk_020573FC.c', diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 6abe7feb35..2a8fd6c667 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -45,7 +45,7 @@ #include "map_header_data.h" #include "map_object.h" #include "map_tile_behavior.h" -#include "pal_park.h" +#include "catching_show.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" @@ -548,8 +548,8 @@ static BOOL Field_CheckWildEncounter(FieldSystem *fieldSystem) Field_GetPlayerPos(fieldSystem, &playerX, &playerZ); if (SystemFlag_CheckInPalPark(SaveData_GetVarsFlags(fieldSystem->saveData)) == TRUE) { - if (PalPark_CheckWildEncounter(fieldSystem, playerX, playerZ) == TRUE) { - Encounter_NewVsPalParkTransfer(fieldSystem, sub_0205639C(fieldSystem)); + if (CatchingShow_CheckWildEncounter(fieldSystem, playerX, playerZ) == TRUE) { + Encounter_NewVsPalParkTransfer(fieldSystem, CatchingShow_GetBattleDTO(fieldSystem)); return TRUE; } else { return FALSE; diff --git a/src/pal_park.c b/src/pal_park.c deleted file mode 100644 index 2d686df04c..0000000000 --- a/src/pal_park.c +++ /dev/null @@ -1,324 +0,0 @@ -#include "pal_park.h" - -#include -#include - -#include "constants/battle.h" -#include "constants/species.h" -#include "consts/game_records.h" - -#include "struct_decls/struct_02024440_decl.h" - -#include "field/field_system.h" -#include "savedata/save_table.h" - -#include "field_battle_data_transfer.h" -#include "game_records.h" -#include "heap.h" -#include "inlines.h" -#include "map_tile_behavior.h" -#include "narc.h" -#include "pokemon.h" -#include "rtc.h" -#include "unk_0202EEC0.h" -#include "unk_02054D00.h" - -static void InitEncounterData(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData); -static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, PalParkCatchingShowData *catchingShowData); -static BOOL TryStartEncounter(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData, int param2, int param3); -static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData); -static NumMonsCaptured(PalParkCatchingShowData *catchingShowData); -static void ResetStepCount(PalParkCatchingShowData *catchingShowData); -static BOOL CanCheckEncounter(PalParkCatchingShowData *catchingShowData); -static u32 CalculateTypePoints(PalParkCatchingShowData *catchingShowData); -static u32 CalculateCatchingPoints(PalParkCatchingShowData *catchingShowData); -static u32 GetTimePoints(PalParkCatchingShowData *catchingShowData); - -static PalParkCatchingShowData sCatchingShowData; - -void PalPark_InitCatchingShowData(FieldSystem *fieldSystem) -{ - int v0; - PalParkCatchingShowData *v1 = &sCatchingShowData; - - MI_CpuClearFast(v1, sizeof(PalParkCatchingShowData)); - - InitEncounterData(fieldSystem, v1); - ResetStepCount(v1); - - v1->unk_40 = GetTimestamp(); -} - -void sub_02056328(FieldSystem *fieldSystem) -{ - PalParkCatchingShowData *v0 = &sCatchingShowData; - GameRecords *v1 = SaveData_GetGameRecordsPtr(fieldSystem->saveData); - s64 v2 = GetTimestamp(); - s64 v3 = TimeElapsed(v0->unk_40, v2); - - if (v3 < 1000) { - v0->timePoints = ((1000 - v3) * 2); - } else { - v0->timePoints = 0; - } - - GameRecords_IncrementTrainerScore(v1, TRAINER_SCORE_EVENT_UNK_17); -} - -BOOL PalPark_CheckWildEncounter(FieldSystem *fieldSystem, int param1, int param2) -{ - if (CanCheckEncounter(&sCatchingShowData) == 1) { - return TryStartEncounter(fieldSystem, &sCatchingShowData, param1, param2); - } else { - return FALSE; - } -} - -FieldBattleDTO *sub_0205639C(FieldSystem *fieldSystem) -{ - return sub_0205664C(fieldSystem, &sCatchingShowData); -} - -void sub_020563AC(FieldSystem *fieldSystem, FieldBattleDTO *param1) -{ - sub_02056624(fieldSystem, param1, &sCatchingShowData); -} - -int PalPark_GetParkBallCount(FieldSystem *fieldSystem) -{ - return 6 - NumMonsCaptured(&sCatchingShowData); -} - -int PalPark_GetCatchingPoints(FieldSystem *fieldSystem) -{ - return CalculateCatchingPoints(&sCatchingShowData); -} - -int PalPark_GetTimePoints(FieldSystem *fieldSystem) -{ - return GetTimePoints(&sCatchingShowData); -} - -int PalPark_GetTypePoints(FieldSystem *fieldSystem) -{ - return CalculateTypePoints(&sCatchingShowData); -} - -static void sub_02056400(u32 param0, u8 *param1) -{ - int v0; - - GF_ASSERT(0 < param0 && param0 <= NATIONAL_DEX_COUNT); - v0 = (param0 - 1) * 6; - - NARC_ReadFromMemberByIndexPair(param1, NARC_INDEX_ARC__PPARK, 0, v0, sizeof(u8) * 6); -} - -static void InitEncounterData(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData) -{ - int i; - u8 v1[8]; - u16 monSpecies; - Pokemon *mon; - PalParkTransfer *v4; - - v4 = SaveData_PalParkTransfer(fieldSystem->saveData); - mon = Pokemon_New(4); - - for (i = 0; i < 6; i++) { - catchingShowData->unk_30[i] = 0; - sub_0202F000(v4, i, mon); - - monSpecies = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); - - catchingShowData->palParkPokemon[i].unk_00 = monSpecies; - sub_02056400(monSpecies, v1); - - if (v1[0] != 0) { - catchingShowData->palParkPokemon[i].encounterType = v1[0]; - } else { - catchingShowData->palParkPokemon[i].encounterType = 5 - 1 + v1[1]; - } - - catchingShowData->palParkPokemon[i].unk_03 = v1[3]; - catchingShowData->palParkPokemon[i].unk_04 = v1[2]; - catchingShowData->palParkPokemon[i].type1 = Pokemon_GetValue(mon, MON_DATA_TYPE_1, NULL); - catchingShowData->palParkPokemon[i].type2 = Pokemon_GetValue(mon, MON_DATA_TYPE_2, NULL); - } - - Heap_FreeToHeap(mon); -} - -static int NumMonsCaptured(PalParkCatchingShowData *catchingShowData) -{ - int i; - int numMonsCaptured = 0; - - for (i = 0; i < 6; i++) { - if (catchingShowData->unk_30[i] != 0) { - numMonsCaptured++; - } - } - - return numMonsCaptured; -} - -static void ResetStepCount(PalParkCatchingShowData *catchingShowData) -{ - catchingShowData->steps = inline_020564D0(10) + 5; -} - -static BOOL CanCheckEncounter(PalParkCatchingShowData *catchingShowData) -{ - catchingShowData->steps--; - - if (catchingShowData->steps == 0) { - ResetStepCount(catchingShowData); - return TRUE; - } - - return FALSE; -} - -static int sub_0205650C(FieldSystem *fieldSystem, int param1, int param2) -{ - u16 v0 = FieldSystem_GetTileBehavior(fieldSystem, param1, param2); - int v1; - - v1 = (param1 < 32) ? 0 : 1; - v1 += (param2 < 32) ? 0 : 2; - - if (TileBehavior_IsTallGrass(v0)) { - return 1 + v1; - } else if (TileBehavior_IsSurfable(v0)) { - return 5 + v1; - } - - return 0; -} - -static BOOL TryStartEncounter(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData, int param2, int param3) -{ - int v0; - int v1, v2 = 0; - int v3 = sub_0205650C(fieldSystem, param2, param3); - - if (v3 == 0) { - return FALSE; - } - - for (v0 = 0; v0 < 6; v0++) { - if ((catchingShowData->unk_30[v0] == 0) && (catchingShowData->palParkPokemon[v0].encounterType == v3)) { - v2 += catchingShowData->palParkPokemon[v0].unk_03; - } - } - - if (v2 == 0) { - return FALSE; - } - - v1 = inline_020564D0(v2 + 20); - - if (v1 < 20) { - return FALSE; - } - - v1 -= 20; - - for (v0 = 0; v0 < 6; v0++) { - if ((catchingShowData->unk_30[v0] == 0) && (catchingShowData->palParkPokemon[v0].encounterType == v3)) { - if (v1 < catchingShowData->palParkPokemon[v0].unk_03) { - catchingShowData->unk_3C = v0; - return 1; - } else { - v1 -= catchingShowData->palParkPokemon[v0].unk_03; - } - } - } - - GF_ASSERT(0); - return FALSE; -} - -static void sub_02056624(FieldSystem *fieldSystem, FieldBattleDTO *param1, PalParkCatchingShowData *catchingShowData) -{ - switch (param1->resultMask) { - case BATTLE_RESULT_CAPTURED_MON: - catchingShowData->unk_30[catchingShowData->unk_3C] = NumMonsCaptured(catchingShowData) + 1; - break; - case BATTLE_RESULT_PLAYER_FLED: - break; - default: - GF_ASSERT(0); - } -} - -static FieldBattleDTO *sub_0205664C(FieldSystem *fieldSystem, PalParkCatchingShowData *catchingShowData) -{ - FieldBattleDTO *v0; - Pokemon *v1 = Pokemon_New(32); - PalParkTransfer *v2 = SaveData_PalParkTransfer(fieldSystem->saveData); - int parkBallCount = PalPark_GetParkBallCount(fieldSystem); - - v0 = FieldBattleDTO_NewPalPark(11, parkBallCount); - - FieldBattleDTO_Init(v0, fieldSystem); - sub_0202F000(v2, catchingShowData->unk_3C, v1); - FieldBattleDTO_AddPokemonToBattler(v0, v1, 1); - Heap_FreeToHeap(v1); - - return v0; -} - -static u32 CalculateCatchingPoints(PalParkCatchingShowData *catchingShowData) -{ - int i; - u32 catchingPoints = 0; - - for (i = 0; i < 6; i++) { - catchingPoints += catchingShowData->palParkPokemon[i].unk_04; - } - - return catchingPoints; -} - -static u32 CalculateTypePoints(PalParkCatchingShowData *catchingShowData) -{ - int i, j; - int typeToCheck1, typeToCheck2, typeAlreadyOwned1, typeAlreadyOwned2; - u32 distinctTypeTracker = 0; - u32 totalTypePoints = 0; - - for (i = 1; i < 6 + 1; i++) { - for (j = 0; j < 6; j++) { - if (catchingShowData->unk_30[j] == i) { - typeAlreadyOwned1 = catchingShowData->palParkPokemon[j].type1; - typeAlreadyOwned2 = catchingShowData->palParkPokemon[j].type2; - - if ((i != 1) && (typeToCheck1 != typeAlreadyOwned1) && (typeToCheck1 != typeAlreadyOwned2) && (typeToCheck2 != typeAlreadyOwned1) && (typeToCheck2 != typeAlreadyOwned2)) { - totalTypePoints += 200; - } - - typeToCheck1 = typeAlreadyOwned1; - typeToCheck2 = typeAlreadyOwned2; - distinctTypeTracker |= (1 << typeToCheck1); - distinctTypeTracker |= (1 << typeToCheck2); - - break; - } - } - } - - for (; distinctTypeTracker != 0; distinctTypeTracker >>= 1) { - if (distinctTypeTracker & 1) { - totalTypePoints += 50; - } - } - - return totalTypePoints; -} - -static u32 GetTimePoints(PalParkCatchingShowData *catchingShowData) -{ - return catchingShowData->timePoints; -} diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index fa30216719..0a32be659d 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -12,7 +12,7 @@ #include "field_script_context.h" #include "heap.h" #include "inlines.h" -#include "pal_park.h" +#include "catching_show.h" #include "pokemon.h" #include "save_player.h" #include "system_flags.h" @@ -31,10 +31,10 @@ BOOL ScrCmd_253(ScriptContext *param0) if (v1 == 0) { SystemFlag_SetInPalPark(v0); - PalPark_InitCatchingShowData(param0->fieldSystem); + CatchingShow_Start(param0->fieldSystem); } else if (v1 == 1) { SystemFlag_ClearInPalPark(v0); - sub_02056328(param0->fieldSystem); + CatchingShow_End(param0->fieldSystem); } else { GF_ASSERT(0); } @@ -89,16 +89,16 @@ BOOL ScrCmd_256(ScriptContext *param0) switch (v0) { case 0: - *v1 = PalPark_GetCatchingPoints(param0->fieldSystem); + *v1 = CatchingShow_GetCatchingPoints(param0->fieldSystem); break; case 1: - *v1 = PalPark_GetTimePoints(param0->fieldSystem); + *v1 = CatchingShow_GetTimePoints(param0->fieldSystem); break; case 2: - *v1 = PalPark_GetTypePoints(param0->fieldSystem); + *v1 = CatchingShow_GetTypePoints(param0->fieldSystem); break; case 3: - *v1 = PalPark_GetCatchingPoints(param0->fieldSystem) + PalPark_GetTypePoints(param0->fieldSystem) + PalPark_GetTimePoints(param0->fieldSystem); + *v1 = CatchingShow_GetCatchingPoints(param0->fieldSystem) + CatchingShow_GetTypePoints(param0->fieldSystem) + CatchingShow_GetTimePoints(param0->fieldSystem); break; } From 3f0bfe4202a59469430ac7f0b14e8e8769ce7612 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Tue, 31 Dec 2024 09:49:47 -0500 Subject: [PATCH 04/11] some cleanup --- include/catching_show.h | 8 +++++--- src/catching_show.c | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/catching_show.h b/include/catching_show.h index f0ee33ddc6..e39d7091e4 100644 --- a/include/catching_show.h +++ b/include/catching_show.h @@ -5,9 +5,11 @@ #include "field_battle_data_transfer.h" -#define CATCHING_SHOW_MONS 6 - -#define DISTINCT_TYPE_BONUS 50 +#define POINTS_LOST_PER_SECOND 2 +#define CATCHING_SHOW_MONS 6 +#define DISTINCT_TYPE_BONUS 50 +#define DIFFERENT_TYPE_BONUS 200 +#define MAX_TIME_SECONDS 1000 typedef struct CatchingShowPokemon{ u16 species; diff --git a/src/catching_show.c b/src/catching_show.c index aa4e291fa5..58a280c745 100644 --- a/src/catching_show.c +++ b/src/catching_show.c @@ -27,7 +27,7 @@ static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingSh static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO *dto, CatchingShow *catchingShow); static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY); static FieldBattleDTO *SetupBattleDTO(FieldSystem *fieldSystem, CatchingShow *catchingShow); -static NumMonsCaptured(CatchingShow *catchingShow); +static int NumMonsCaptured(CatchingShow *catchingShow); static void ResetStepCount(CatchingShow *catchingShow); static BOOL IsStepCountZero(CatchingShow *catchingShow); static u32 CalculateTypePoints(CatchingShow *catchingShow); @@ -55,8 +55,8 @@ void CatchingShow_End(FieldSystem *fieldSystem) s64 endTime = GetTimestamp(); s64 elapsedTime = TimeElapsed(catchingShow->startTime, endTime); - if (elapsedTime < 1000) { - catchingShow->timePoints = ((1000 - elapsedTime) * 2); + if (elapsedTime < MAX_TIME_SECONDS) { + catchingShow->timePoints = ((MAX_TIME_SECONDS - elapsedTime) * POINTS_LOST_PER_SECOND); } else { catchingShow->timePoints = 0; } @@ -228,7 +228,7 @@ static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingSh if ((catchingShow->capturedPokemonIndex[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { if (v1 < catchingShow->pokemon[i].encounterRate) { catchingShow->currentEncounterIndex = i; - return 1; + return TRUE; } else { v1 -= catchingShow->pokemon[i].encounterRate; } @@ -295,7 +295,7 @@ static u32 CalculateTypePoints(CatchingShow *catchingShow) currentMonType2 = catchingShow->pokemon[j].type2; if ((i != 1) && (previousMonType1 != currentMonType1) && (previousMonType1 != currentMonType2) && (previousMonType2 != currentMonType1) && (previousMonType2 != currentMonType2)) { - totalTypePoints += 200; + totalTypePoints += DIFFERENT_TYPE_BONUS; } previousMonType1 = currentMonType1; From f5b84f1a60283ba7cf2a96f014d1a01eaaa87ada Mon Sep 17 00:00:00 2001 From: iriv24 Date: Tue, 31 Dec 2024 09:51:31 -0500 Subject: [PATCH 05/11] formatting --- include/catching_show.h | 12 ++++++------ src/encounter.c | 2 +- src/field_menu.c | 2 +- src/overlay005/field_control.c | 2 +- src/unk_0204C500.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/catching_show.h b/include/catching_show.h index e39d7091e4..4b299bc693 100644 --- a/include/catching_show.h +++ b/include/catching_show.h @@ -5,13 +5,13 @@ #include "field_battle_data_transfer.h" -#define POINTS_LOST_PER_SECOND 2 -#define CATCHING_SHOW_MONS 6 -#define DISTINCT_TYPE_BONUS 50 -#define DIFFERENT_TYPE_BONUS 200 -#define MAX_TIME_SECONDS 1000 +#define POINTS_LOST_PER_SECOND 2 +#define CATCHING_SHOW_MONS 6 +#define DISTINCT_TYPE_BONUS 50 +#define DIFFERENT_TYPE_BONUS 200 +#define MAX_TIME_SECONDS 1000 -typedef struct CatchingShowPokemon{ +typedef struct CatchingShowPokemon { u16 species; u8 encounterType; u8 encounterRate; diff --git a/src/encounter.c b/src/encounter.c index 7d7a61591a..1a0b746b92 100644 --- a/src/encounter.c +++ b/src/encounter.c @@ -20,6 +20,7 @@ #include "overlay006/ov6_02246034.h" #include "savedata/save_table.h" +#include "catching_show.h" #include "communication_information.h" #include "enc_effects.h" #include "enums.h" @@ -34,7 +35,6 @@ #include "journal.h" #include "location.h" #include "map_object.h" -#include "catching_show.h" #include "party.h" #include "pokemon.h" #include "pokeradar.h" diff --git a/src/field_menu.c b/src/field_menu.c index 109de8787c..05a728aa58 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -35,6 +35,7 @@ #include "bag.h" #include "bg_window.h" +#include "catching_show.h" #include "cell_actor.h" #include "field_overworld_state.h" #include "field_system.h" @@ -50,7 +51,6 @@ #include "menu.h" #include "message.h" #include "narc.h" -#include "catching_show.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 2a8fd6c667..b4201a296d 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -29,6 +29,7 @@ #include "overlay009/ov9_02249960.h" #include "overlay023/ov23_02241F74.h" +#include "catching_show.h" #include "comm_player_manager.h" #include "communication_information.h" #include "communication_system.h" @@ -45,7 +46,6 @@ #include "map_header_data.h" #include "map_object.h" #include "map_tile_behavior.h" -#include "catching_show.h" #include "party.h" #include "player_avatar.h" #include "pokemon.h" diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 0a32be659d..e2d3f535ed 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -9,10 +9,10 @@ #include "savedata/save_table.h" +#include "catching_show.h" #include "field_script_context.h" #include "heap.h" #include "inlines.h" -#include "catching_show.h" #include "pokemon.h" #include "save_player.h" #include "system_flags.h" From c2e1f975c5efc889e907af23080b3d67dfd66ae1 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Tue, 31 Dec 2024 10:00:15 -0500 Subject: [PATCH 06/11] rename to caughtMonsOrder --- include/catching_show.h | 2 +- src/catching_show.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/catching_show.h b/include/catching_show.h index 4b299bc693..cbfc74a884 100644 --- a/include/catching_show.h +++ b/include/catching_show.h @@ -22,7 +22,7 @@ typedef struct CatchingShowPokemon { typedef struct CatchingShow { CatchingShowPokemon pokemon[CATCHING_SHOW_MONS]; - u8 capturedPokemonIndex[CATCHING_SHOW_MONS]; + u8 caughtMonsOrder[CATCHING_SHOW_MONS]; int steps; int currentEncounterIndex; s64 startTime; diff --git a/src/catching_show.c b/src/catching_show.c index 58a280c745..2e2fcfaf75 100644 --- a/src/catching_show.c +++ b/src/catching_show.c @@ -125,7 +125,7 @@ static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingSh mon = Pokemon_New(4); for (i = 0; i < CATCHING_SHOW_MONS; i++) { - catchingShow->capturedPokemonIndex[i] = 0; + catchingShow->caughtMonsOrder[i] = 0; sub_0202F000(v4, i, mon); monSpecies = Pokemon_GetValue(mon, MON_DATA_SPECIES, NULL); @@ -154,7 +154,7 @@ static int NumMonsCaptured(CatchingShow *catchingShow) int numMonsCaptured = 0; for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if (catchingShow->capturedPokemonIndex[i] != 0) { + if (catchingShow->caughtMonsOrder[i] != 0) { numMonsCaptured++; } } @@ -207,7 +207,7 @@ static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingSh } for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if ((catchingShow->capturedPokemonIndex[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { + if ((catchingShow->caughtMonsOrder[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { v2 += catchingShow->pokemon[i].encounterRate; } } @@ -225,7 +225,7 @@ static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingSh v1 -= 20; for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if ((catchingShow->capturedPokemonIndex[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { + if ((catchingShow->caughtMonsOrder[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { if (v1 < catchingShow->pokemon[i].encounterRate) { catchingShow->currentEncounterIndex = i; return TRUE; @@ -243,7 +243,7 @@ static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO { switch (dto->resultMask) { case BATTLE_RESULT_CAPTURED_MON: - catchingShow->capturedPokemonIndex[catchingShow->currentEncounterIndex] = NumMonsCaptured(catchingShow) + 1; + catchingShow->caughtMonsOrder[catchingShow->currentEncounterIndex] = NumMonsCaptured(catchingShow) + 1; break; case BATTLE_RESULT_PLAYER_FLED: break; @@ -290,7 +290,7 @@ static u32 CalculateTypePoints(CatchingShow *catchingShow) for (i = 1; i < CATCHING_SHOW_MONS + 1; i++) { for (j = 0; j < CATCHING_SHOW_MONS; j++) { - if (catchingShow->capturedPokemonIndex[j] == i) { + if (catchingShow->caughtMonsOrder[j] == i) { currentMonType1 = catchingShow->pokemon[j].type1; currentMonType2 = catchingShow->pokemon[j].type2; From 484bff64d5fe90deae79b6011c307a38ca9d1bc4 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Wed, 1 Jan 2025 12:19:36 -0500 Subject: [PATCH 07/11] document macros, more cleanup --- asm/macros/scrcmd.inc | 10 +-- include/catching_show.h | 11 ++- include/unk_02017728.h | 2 +- include/unk_0204C500.h | 9 ++- res/field/scripts/scripts_pal_park_lobby.s | 16 ++-- src/catching_show.c | 88 +++++++++++----------- src/main.c | 2 +- src/overlay097/ov97_0222AE60.c | 2 +- src/overlay097/ov97_0222D30C.c | 4 +- src/scrcmd.c | 14 ++-- src/unk_02017728.c | 4 +- src/unk_0204C500.c | 26 +++---- 12 files changed, 99 insertions(+), 89 deletions(-) diff --git a/asm/macros/scrcmd.inc b/asm/macros/scrcmd.inc index 17a9908fae..fd83581cb9 100644 --- a/asm/macros/scrcmd.inc +++ b/asm/macros/scrcmd.inc @@ -3250,10 +3250,10 @@ .short 597 .endm - .macro ScrCmd_256 arg0, arg1 + .macro CalcCatchingShowPoints pointsCategory, destVarID .short 598 - .short \arg0 - .short \arg1 + .short \pointsCategory + .short \destVarID .endm .macro ScrCmd_257 @@ -3370,9 +3370,9 @@ .short \arg0 .endm - .macro ScrCmd_26E arg0 + .macro GetGBACartridgeVersion destVarID .short 622 - .short \arg0 + .short \destVarID .endm .macro ScrCmd_26F diff --git a/include/catching_show.h b/include/catching_show.h index cbfc74a884..b30eb30809 100644 --- a/include/catching_show.h +++ b/include/catching_show.h @@ -7,14 +7,21 @@ #define POINTS_LOST_PER_SECOND 2 #define CATCHING_SHOW_MONS 6 +#define WEIGHT_NO_ENCOUNTER 20 #define DISTINCT_TYPE_BONUS 50 #define DIFFERENT_TYPE_BONUS 200 #define MAX_TIME_SECONDS 1000 +enum PAL_PARK_ENCOUNTER_TYPE { + PAL_PARK_ENCOUNTER_TYPE_NONE = 0, + PAL_PARK_ENCOUNTER_LAND_ZONE_1 = 1, + PAL_PARK_ENCOUNTER_WATER_ZONE_1 = 5 +}; + typedef struct CatchingShowPokemon { u16 species; u8 encounterType; - u8 encounterRate; + u8 rarity; u16 catchingPoints; u8 type1; u8 type2; @@ -35,7 +42,7 @@ BOOL CatchingShow_CheckWildEncounter(FieldSystem *fieldSystem, int playerX, int FieldBattleDTO *CatchingShow_GetBattleDTO(FieldSystem *fieldSystem); void CatchingShow_UpdateBattleResult(FieldSystem *fieldSystem, FieldBattleDTO *dto); int CatchingShow_GetParkBallCount(FieldSystem *fieldSystem); -int CatchingShow_GetCatchingPoints(FieldSystem *fieldSystem); +int CatchingShow_CalcCatchingPoints(FieldSystem *fieldSystem); int CatchingShow_GetTimePoints(FieldSystem *fieldSystem); int CatchingShow_GetTypePoints(FieldSystem *fieldSystem); diff --git a/include/unk_02017728.h b/include/unk_02017728.h index ca0b43068a..904f4fffbc 100644 --- a/include/unk_02017728.h +++ b/include/unk_02017728.h @@ -13,7 +13,7 @@ void *ReadFileToHeap(int heapID, const char *filename); void ReadFileToBuffer(const char *filename, void **buf); void sub_02017ACC(void); void InitKeypadAndTouchpad(void); -void sub_02017B70(int param0); +void SetGBACartridgeVersion(int version); void SleepLock(u8 param0); void SleepUnlock(u8 param0); void ReadKeypadAndTouchpad(void); diff --git a/include/unk_0204C500.h b/include/unk_0204C500.h index 6f8db0d795..9fe91e0858 100644 --- a/include/unk_0204C500.h +++ b/include/unk_0204C500.h @@ -3,9 +3,16 @@ #include "field_script_context.h" +enum CATCHING_SHOW_POINTS_CATEGORY { + CATCHING_POINTS = 0, + TIME_POINTS, + TYPE_POINTS, + TOTAL_POINTS +}; + BOOL ScrCmd_253(ScriptContext *param0); BOOL ScrCmd_254(ScriptContext *param0); BOOL ScrCmd_255(ScriptContext *param0); -BOOL ScrCmd_256(ScriptContext *param0); +BOOL ScrCmd_CalcCatchingShowPoints(ScriptContext *ctx); #endif // POKEPLATINUM_UNK_0204C500_H diff --git a/res/field/scripts/scripts_pal_park_lobby.s b/res/field/scripts/scripts_pal_park_lobby.s index b4ae5519cf..8da09266a0 100644 --- a/res/field/scripts/scripts_pal_park_lobby.s +++ b/res/field/scripts/scripts_pal_park_lobby.s @@ -213,16 +213,16 @@ _02F8: SetVar 0x40F3, 0 ApplyMovement 0xFF, _03EC WaitMovement - ScrCmd_256 0, 0x800C + CalcCatchingShowPoints 0, 0x800C BufferNumber 0, 0x800C - ScrCmd_256 1, 0x800C + CalcCatchingShowPoints 1, 0x800C BufferNumber 1, 0x800C - ScrCmd_256 2, 0x800C + CalcCatchingShowPoints 2, 0x800C BufferNumber 2, 0x800C - ScrCmd_256 3, 0x800C + CalcCatchingShowPoints 3, 0x800C BufferNumber 3, 0x800C Message 38 - ScrCmd_256 3, 0x800C + CalcCatchingShowPoints 3, 0x800C GoToIfGt 0x800C, 0x40E0, _035B Message 40 Call _07BE @@ -231,7 +231,7 @@ _02F8: _035B: Message 39 Call _07BE - ScrCmd_256 3, 0x40E0 + CalcCatchingShowPoints 3, 0x40E0 GoTo _0370 _0370: @@ -507,7 +507,7 @@ _0662: LockAll FacePlayer GoToIfEq 0x4009, 1, _06CF - ScrCmd_26E 0x800C + GetGBACartridgeVersion 0x800C GoToIfEq 0x800C, 4, _06DA GoToIfEq 0x800C, 5, _0706 GoToIfEq 0x800C, 1, _0732 @@ -587,7 +587,7 @@ _07AE: End _07BE: - ScrCmd_256 3, 0x800C + CalcCatchingShowPoints 3, 0x800C CallIfLt 0x800C, 0xBB8, _07FA CallIfLt 0x800C, 0xCE4, _0870 CallIfLt 0x800C, 0xDAC, _08BF diff --git a/src/catching_show.c b/src/catching_show.c index 2e2fcfaf75..9c0ecd908d 100644 --- a/src/catching_show.c +++ b/src/catching_show.c @@ -31,7 +31,7 @@ static int NumMonsCaptured(CatchingShow *catchingShow); static void ResetStepCount(CatchingShow *catchingShow); static BOOL IsStepCountZero(CatchingShow *catchingShow); static u32 CalculateTypePoints(CatchingShow *catchingShow); -static u32 CalculateTotalCatchingPoints(CatchingShow *catchingShow); +static u32 CalcCatchingPoints(CatchingShow *catchingShow); static u32 GetTimePoints(CatchingShow *catchingShow); static CatchingShow sCatchingShow; @@ -88,9 +88,9 @@ int CatchingShow_GetParkBallCount(FieldSystem *fieldSystem) return CATCHING_SHOW_MONS - NumMonsCaptured(&sCatchingShow); } -int CatchingShow_GetCatchingPoints(FieldSystem *fieldSystem) +int CatchingShow_CalcCatchingPoints(FieldSystem *fieldSystem) { - return CalculateTotalCatchingPoints(&sCatchingShow); + return CalcCatchingPoints(&sCatchingShow); } int CatchingShow_GetTimePoints(FieldSystem *fieldSystem) @@ -105,10 +105,9 @@ int CatchingShow_GetTypePoints(FieldSystem *fieldSystem) static void sub_02056400(u32 species, u8 *param1) { - int v0; - GF_ASSERT(0 < species && species <= NATIONAL_DEX_COUNT); - v0 = (species - 1) * 6; + + int v0 = (species - 1) * 6; NARC_ReadFromMemberByIndexPair(param1, NARC_INDEX_ARC__PPARK, 0, v0, sizeof(u8) * 6); } @@ -118,11 +117,8 @@ static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingSh int i; u8 v1[8]; u16 monSpecies; - Pokemon *mon; - PalParkTransfer *v4; - - v4 = SaveData_PalParkTransfer(fieldSystem->saveData); - mon = Pokemon_New(4); + PalParkTransfer *v4 = SaveData_PalParkTransfer(fieldSystem->saveData); + Pokemon *mon = Pokemon_New(HEAP_ID_FIELD); for (i = 0; i < CATCHING_SHOW_MONS; i++) { catchingShow->caughtMonsOrder[i] = 0; @@ -136,10 +132,10 @@ static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingSh if (v1[0] != 0) { catchingShow->pokemon[i].encounterType = v1[0]; } else { - catchingShow->pokemon[i].encounterType = 5 - 1 + v1[1]; + catchingShow->pokemon[i].encounterType = PAL_PARK_ENCOUNTER_WATER_ZONE_1 - 1 + v1[1]; } - catchingShow->pokemon[i].encounterRate = v1[3]; + catchingShow->pokemon[i].rarity = v1[3]; catchingShow->pokemon[i].catchingPoints = v1[2]; catchingShow->pokemon[i].type1 = Pokemon_GetValue(mon, MON_DATA_TYPE_1, NULL); catchingShow->pokemon[i].type2 = Pokemon_GetValue(mon, MON_DATA_TYPE_2, NULL); @@ -182,55 +178,53 @@ static BOOL IsStepCountZero(CatchingShow *catchingShow) static int GetEncounterType(FieldSystem *fieldSystem, int playerX, int playerY) { u16 tileBehavior = FieldSystem_GetTileBehavior(fieldSystem, playerX, playerY); - int v1; - - v1 = (playerX < 32) ? 0 : 1; - v1 += (playerY < 32) ? 0 : 2; + int palParkZone = (playerX < 32) ? 0 : 1; + palParkZone += (playerY < 32) ? 0 : 2; if (TileBehavior_IsTallGrass(tileBehavior)) { - return 1 + v1; + return PAL_PARK_ENCOUNTER_LAND_ZONE_1 + palParkZone; } else if (TileBehavior_IsSurfable(tileBehavior)) { - return 5 + v1; + return PAL_PARK_ENCOUNTER_WATER_ZONE_1 + palParkZone; } - return 0; + return PAL_PARK_ENCOUNTER_TYPE_NONE; } static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY) { int i; - int v1, v2 = 0; + int encounterChance, totalRarity = 0; int encounterType = GetEncounterType(fieldSystem, playerX, playerY); - if (encounterType == 0) { + if (encounterType == PAL_PARK_ENCOUNTER_TYPE_NONE) { return FALSE; } for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if ((catchingShow->caughtMonsOrder[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { - v2 += catchingShow->pokemon[i].encounterRate; + if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].encounterType == encounterType) { + totalRarity += catchingShow->pokemon[i].rarity; } } - if (v2 == 0) { + if (totalRarity == 0) { return FALSE; } - v1 = inline_020564D0(v2 + 20); + encounterChance = inline_020564D0(totalRarity + WEIGHT_NO_ENCOUNTER); - if (v1 < 20) { + if (encounterChance < WEIGHT_NO_ENCOUNTER) { return FALSE; } - v1 -= 20; + encounterChance -= WEIGHT_NO_ENCOUNTER; for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if ((catchingShow->caughtMonsOrder[i] == 0) && (catchingShow->pokemon[i].encounterType == encounterType)) { - if (v1 < catchingShow->pokemon[i].encounterRate) { + if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].encounterType == encounterType) { + if (encounterChance < catchingShow->pokemon[i].rarity) { catchingShow->currentEncounterIndex = i; return TRUE; } else { - v1 -= catchingShow->pokemon[i].encounterRate; + encounterChance -= catchingShow->pokemon[i].rarity; } } } @@ -254,22 +248,20 @@ static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO static FieldBattleDTO *SetupBattleDTO(FieldSystem *fieldSystem, CatchingShow *catchingShow) { - FieldBattleDTO *dto; - Pokemon *mon = Pokemon_New(32); + Pokemon *mon = Pokemon_New(HEAP_ID_FIELD_TASK); PalParkTransfer *v2 = SaveData_PalParkTransfer(fieldSystem->saveData); int parkBallCount = CatchingShow_GetParkBallCount(fieldSystem); - - dto = FieldBattleDTO_NewPalPark(11, parkBallCount); + FieldBattleDTO *dto = FieldBattleDTO_NewPalPark(HEAP_ID_FIELDMAP, parkBallCount); FieldBattleDTO_Init(dto, fieldSystem); sub_0202F000(v2, catchingShow->currentEncounterIndex, mon); - FieldBattleDTO_AddPokemonToBattler(dto, mon, 1); + FieldBattleDTO_AddPokemonToBattler(dto, mon, BATTLER_ENEMY_SLOT_1); Heap_FreeToHeap(mon); return dto; } -static u32 CalculateTotalCatchingPoints(CatchingShow *catchingShow) +static u32 CalcCatchingPoints(CatchingShow *catchingShow) { int i; u32 totalCatchingPoints = 0; @@ -284,24 +276,28 @@ static u32 CalculateTotalCatchingPoints(CatchingShow *catchingShow) static u32 CalculateTypePoints(CatchingShow *catchingShow) { int i, j; - int previousMonType1, previousMonType2, currentMonType1, currentMonType2; + int prevMonType1, prevMonType2, currMonType1, currMonType2; u32 distinctTypeTracker = 0; u32 totalTypePoints = 0; for (i = 1; i < CATCHING_SHOW_MONS + 1; i++) { for (j = 0; j < CATCHING_SHOW_MONS; j++) { if (catchingShow->caughtMonsOrder[j] == i) { - currentMonType1 = catchingShow->pokemon[j].type1; - currentMonType2 = catchingShow->pokemon[j].type2; - - if ((i != 1) && (previousMonType1 != currentMonType1) && (previousMonType1 != currentMonType2) && (previousMonType2 != currentMonType1) && (previousMonType2 != currentMonType2)) { + currMonType1 = catchingShow->pokemon[j].type1; + currMonType2 = catchingShow->pokemon[j].type2; + + if (i != 1 + && prevMonType1 != currMonType1 + && prevMonType1 != currMonType2 + && prevMonType2 != currMonType1 + && prevMonType2 != currMonType2) { totalTypePoints += DIFFERENT_TYPE_BONUS; } - previousMonType1 = currentMonType1; - previousMonType2 = currentMonType2; - distinctTypeTracker |= (1 << previousMonType1); - distinctTypeTracker |= (1 << previousMonType2); + prevMonType1 = currMonType1; + prevMonType2 = currMonType2; + distinctTypeTracker |= (1 << prevMonType1); + distinctTypeTracker |= (1 << prevMonType2); break; } diff --git a/src/main.c b/src/main.c index 80c90c9627..cc8efe3795 100644 --- a/src/main.c +++ b/src/main.c @@ -71,7 +71,7 @@ void NitroMain(void) InitGraphics(); InitKeypadAndTouchpad(); - sub_02017B70(0); + SetGBACartridgeVersion(0); PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); InitRTC(); diff --git a/src/overlay097/ov97_0222AE60.c b/src/overlay097/ov97_0222AE60.c index a11125d4e0..e749bc951b 100644 --- a/src/overlay097/ov97_0222AE60.c +++ b/src/overlay097/ov97_0222AE60.c @@ -235,7 +235,7 @@ static void ov97_0222AF1C(UnkStruct_0222AE60 *param0) break; } - sub_02017B70(v0); + SetGBACartridgeVersion(v0); if (Pokedex_IsNationalDexObtained(param0->unk_08) == FALSE) { return; diff --git a/src/overlay097/ov97_0222D30C.c b/src/overlay097/ov97_0222D30C.c index 124b4da21e..d49864c682 100644 --- a/src/overlay097/ov97_0222D30C.c +++ b/src/overlay097/ov97_0222D30C.c @@ -1096,7 +1096,7 @@ static int ov97_0222E2DC(OverlayManager *param0, int *param1) if (ov97_02237624()) { v0->unk_1638 = 2; - sub_02017B70(gGameVersion); + SetGBACartridgeVersion(gGameVersion); ov97_02238400(1); } @@ -2445,7 +2445,7 @@ static int ov97_022301BC(OverlayManager *param0, int *param1) Heap_Destroy(86); if (v0->unk_1638 == 2) { - sub_02017B70(0); + SetGBACartridgeVersion(0); } ov97_02238400(0); diff --git a/src/scrcmd.c b/src/scrcmd.c index 5a778af3a9..16245bdc52 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -649,7 +649,7 @@ static BOOL ScrCmd_269(ScriptContext *ctx); static BOOL ScrCmd_26A(ScriptContext *ctx); static BOOL ScrCmd_26B(ScriptContext *ctx); static BOOL ScrCmd_26C(ScriptContext *ctx); -static BOOL ScrCmd_26E(ScriptContext *ctx); +static BOOL ScrCmd_GetGBACartridgeVersion(ScriptContext *ctx); static BOOL ScrCmd_270(ScriptContext *ctx); static BOOL ScrCmd_273(ScriptContext *ctx); static BOOL ScrCmd_275(ScriptContext *ctx); @@ -1364,7 +1364,7 @@ const ScrCmdFunc Unk_020EAC58[] = { ScrCmd_253, ScrCmd_254, ScrCmd_255, - ScrCmd_256, + ScrCmd_CalcCatchingShowPoints, ScrCmd_257, ScrCmd_258, ScrCmd_259, @@ -1388,7 +1388,7 @@ const ScrCmdFunc Unk_020EAC58[] = { ScrCmd_26B, ScrCmd_26C, ScrCmd_26D, - ScrCmd_26E, + ScrCmd_GetGBACartridgeVersion, ScrCmd_26F, ScrCmd_270, ScrCmd_271, @@ -7061,12 +7061,12 @@ static BOOL ScrCmd_26C(ScriptContext *ctx) return 0; } -static BOOL ScrCmd_26E(ScriptContext *ctx) +static BOOL ScrCmd_GetGBACartridgeVersion(ScriptContext *ctx) { - u16 *v0 = ScriptContext_GetVarPointer(ctx); + u16 *destVar = ScriptContext_GetVarPointer(ctx); - *v0 = gCoreSys.gbaCartridgeVersion; - return 1; + *destVar = gCoreSys.gbaCartridgeVersion; + return TRUE; } static BOOL ScrCmd_26F(ScriptContext *ctx) diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 3a04bcfce0..549b08c9d1 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -298,9 +298,9 @@ void InitKeypadAndTouchpad(void) } } -void sub_02017B70(int param0) +void SetGBACartridgeVersion(int version) { - gCoreSys.gbaCartridgeVersion = param0; + gCoreSys.gbaCartridgeVersion = version; } void SleepLock(u8 param0) diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index e2d3f535ed..e97935a62c 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -82,25 +82,25 @@ BOOL ScrCmd_255(ScriptContext *param0) return 0; } -BOOL ScrCmd_256(ScriptContext *param0) +BOOL ScrCmd_CalcCatchingShowPoints(ScriptContext *ctx) { - u16 v0 = ScriptContext_GetVar(param0); - u16 *v1 = ScriptContext_GetVarPointer(param0); + u16 pointsCategory = ScriptContext_GetVar(ctx); + u16 *destVar = ScriptContext_GetVarPointer(ctx); - switch (v0) { - case 0: - *v1 = CatchingShow_GetCatchingPoints(param0->fieldSystem); + switch (pointsCategory) { + case CATCHING_POINTS: + *destVar = CatchingShow_CalcCatchingPoints(ctx->fieldSystem); break; - case 1: - *v1 = CatchingShow_GetTimePoints(param0->fieldSystem); + case TIME_POINTS: + *destVar = CatchingShow_GetTimePoints(ctx->fieldSystem); break; - case 2: - *v1 = CatchingShow_GetTypePoints(param0->fieldSystem); + case TYPE_POINTS: + *destVar = CatchingShow_GetTypePoints(ctx->fieldSystem); break; - case 3: - *v1 = CatchingShow_GetCatchingPoints(param0->fieldSystem) + CatchingShow_GetTypePoints(param0->fieldSystem) + CatchingShow_GetTimePoints(param0->fieldSystem); + case TOTAL_POINTS: + *destVar = CatchingShow_CalcCatchingPoints(ctx->fieldSystem) + CatchingShow_GetTypePoints(ctx->fieldSystem) + CatchingShow_GetTimePoints(ctx->fieldSystem); break; } - return 0; + return FALSE; } From 6b8eb3fcad2d08bc42f3b03988607dd6d8113f46 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Wed, 1 Jan 2025 20:07:36 -0500 Subject: [PATCH 08/11] rename encounterType to area, create catching_show consts, address other comments --- asm/macros/scrcmd.inc | 1 + consts/catching_show.json | 13 ++++++ consts/meson.build | 1 + include/catching_show.h | 15 +------ include/unk_0204C500.h | 7 ---- res/field/scripts/scripts_pal_park_lobby.s | 14 +++---- src/catching_show.c | 46 +++++++++++++++------- src/unk_0204C500.c | 10 +++-- 8 files changed, 62 insertions(+), 45 deletions(-) create mode 100644 consts/catching_show.json diff --git a/asm/macros/scrcmd.inc b/asm/macros/scrcmd.inc index fd83581cb9..3648bc40b3 100644 --- a/asm/macros/scrcmd.inc +++ b/asm/macros/scrcmd.inc @@ -1,5 +1,6 @@ .include "macros/movement.inc" .include "consts/badges.inc" + .include "consts/catching_show.inc" .include "consts/game_records.inc" .include "consts/items.inc" .include "consts/journal.inc" diff --git a/consts/catching_show.json b/consts/catching_show.json new file mode 100644 index 0000000000..f6fcf687db --- /dev/null +++ b/consts/catching_show.json @@ -0,0 +1,13 @@ +{ + "definitions": { + "@CatchingShowPointsCategory": { + "type": "enum", + "values": [ + "CATCHING_SHOW_CATCHING_POINTS", + "CATCHING_SHOW_TIME_POINTS", + "CATCHING_SHOW_TYPE_POINTS", + "CATCHING_SHOW_TOTAL_POINTS" + ] + } + } +} \ No newline at end of file diff --git a/consts/meson.build b/consts/meson.build index 3208eb44ce..45a34107e8 100644 --- a/consts/meson.build +++ b/consts/meson.build @@ -4,6 +4,7 @@ consts_manifest_basenames = [ 'battle', 'battle_subscripts', 'btlcmd', + 'catching_show', 'game_records', 'gender', 'items', diff --git a/include/catching_show.h b/include/catching_show.h index b30eb30809..2d9fb96d33 100644 --- a/include/catching_show.h +++ b/include/catching_show.h @@ -5,22 +5,11 @@ #include "field_battle_data_transfer.h" -#define POINTS_LOST_PER_SECOND 2 -#define CATCHING_SHOW_MONS 6 -#define WEIGHT_NO_ENCOUNTER 20 -#define DISTINCT_TYPE_BONUS 50 -#define DIFFERENT_TYPE_BONUS 200 -#define MAX_TIME_SECONDS 1000 - -enum PAL_PARK_ENCOUNTER_TYPE { - PAL_PARK_ENCOUNTER_TYPE_NONE = 0, - PAL_PARK_ENCOUNTER_LAND_ZONE_1 = 1, - PAL_PARK_ENCOUNTER_WATER_ZONE_1 = 5 -}; +#define CATCHING_SHOW_MONS 6 typedef struct CatchingShowPokemon { u16 species; - u8 encounterType; + u8 area; u8 rarity; u16 catchingPoints; u8 type1; diff --git a/include/unk_0204C500.h b/include/unk_0204C500.h index 9fe91e0858..38b3785b74 100644 --- a/include/unk_0204C500.h +++ b/include/unk_0204C500.h @@ -3,13 +3,6 @@ #include "field_script_context.h" -enum CATCHING_SHOW_POINTS_CATEGORY { - CATCHING_POINTS = 0, - TIME_POINTS, - TYPE_POINTS, - TOTAL_POINTS -}; - BOOL ScrCmd_253(ScriptContext *param0); BOOL ScrCmd_254(ScriptContext *param0); BOOL ScrCmd_255(ScriptContext *param0); diff --git a/res/field/scripts/scripts_pal_park_lobby.s b/res/field/scripts/scripts_pal_park_lobby.s index 8da09266a0..e27db40495 100644 --- a/res/field/scripts/scripts_pal_park_lobby.s +++ b/res/field/scripts/scripts_pal_park_lobby.s @@ -213,16 +213,16 @@ _02F8: SetVar 0x40F3, 0 ApplyMovement 0xFF, _03EC WaitMovement - CalcCatchingShowPoints 0, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_CATCHING_POINTS, 0x800C BufferNumber 0, 0x800C - CalcCatchingShowPoints 1, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_TIME_POINTS, 0x800C BufferNumber 1, 0x800C - CalcCatchingShowPoints 2, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_TYPE_POINTS, 0x800C BufferNumber 2, 0x800C - CalcCatchingShowPoints 3, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_TOTAL_POINTS, 0x800C BufferNumber 3, 0x800C Message 38 - CalcCatchingShowPoints 3, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_TOTAL_POINTS, 0x800C GoToIfGt 0x800C, 0x40E0, _035B Message 40 Call _07BE @@ -231,7 +231,7 @@ _02F8: _035B: Message 39 Call _07BE - CalcCatchingShowPoints 3, 0x40E0 + CalcCatchingShowPoints CATCHING_SHOW_TOTAL_POINTS, 0x40E0 GoTo _0370 _0370: @@ -587,7 +587,7 @@ _07AE: End _07BE: - CalcCatchingShowPoints 3, 0x800C + CalcCatchingShowPoints CATCHING_SHOW_TOTAL_POINTS, 0x800C CallIfLt 0x800C, 0xBB8, _07FA CallIfLt 0x800C, 0xCE4, _0870 CallIfLt 0x800C, 0xDAC, _08BF diff --git a/src/catching_show.c b/src/catching_show.c index 9c0ecd908d..cc254078b5 100644 --- a/src/catching_show.c +++ b/src/catching_show.c @@ -23,6 +23,24 @@ #include "unk_0202EEC0.h" #include "unk_02054D00.h" +#define POINTS_LOST_PER_SECOND 2 +#define WEIGHT_NO_ENCOUNTER 20 +#define DISTINCT_TYPE_BONUS 50 +#define DIFFERENT_TYPE_BONUS 200 +#define MAX_TIME_SECONDS 1000 + +enum PAL_PARK_AREA { + PAL_PARK_AREA_NONE = 0, + PAL_PARK_AREA_LAND_NORTH_WEST, + PAL_PARK_AREA_LAND_NORTH_EAST, + PAL_PARK_AREA_LAND_SOUTH_WEST, + PAL_PARK_AREA_LAND_SOUTH_EAST, + PAL_PARK_AREA_WATER_NORTH_WEST, + PAL_PARK_AREA_WATER_NORTH_EAST, + PAL_PARK_AREA_WATER_SOUTH_WEST, + PAL_PARK_AREA_WATER_SOUTH_EAST, +}; + static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingShow); static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO *dto, CatchingShow *catchingShow); static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY); @@ -130,9 +148,9 @@ static void InitEncounterData(FieldSystem *fieldSystem, CatchingShow *catchingSh sub_02056400(monSpecies, v1); if (v1[0] != 0) { - catchingShow->pokemon[i].encounterType = v1[0]; + catchingShow->pokemon[i].area = v1[0]; } else { - catchingShow->pokemon[i].encounterType = PAL_PARK_ENCOUNTER_WATER_ZONE_1 - 1 + v1[1]; + catchingShow->pokemon[i].area = PAL_PARK_AREA_WATER_NORTH_WEST - 1 + v1[1]; } catchingShow->pokemon[i].rarity = v1[3]; @@ -175,33 +193,33 @@ static BOOL IsStepCountZero(CatchingShow *catchingShow) return FALSE; } -static int GetEncounterType(FieldSystem *fieldSystem, int playerX, int playerY) +static int GetEncounterArea(FieldSystem *fieldSystem, int playerX, int playerY) { u16 tileBehavior = FieldSystem_GetTileBehavior(fieldSystem, playerX, playerY); - int palParkZone = (playerX < 32) ? 0 : 1; - palParkZone += (playerY < 32) ? 0 : 2; + int area = (playerX < 32) ? 0 : 1; + area += (playerY < 32) ? 0 : 2; if (TileBehavior_IsTallGrass(tileBehavior)) { - return PAL_PARK_ENCOUNTER_LAND_ZONE_1 + palParkZone; + return PAL_PARK_AREA_LAND_NORTH_WEST + area; } else if (TileBehavior_IsSurfable(tileBehavior)) { - return PAL_PARK_ENCOUNTER_WATER_ZONE_1 + palParkZone; + return PAL_PARK_AREA_WATER_NORTH_WEST + area; } - return PAL_PARK_ENCOUNTER_TYPE_NONE; + return PAL_PARK_AREA_NONE; } static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingShow, int playerX, int playerY) { int i; int encounterChance, totalRarity = 0; - int encounterType = GetEncounterType(fieldSystem, playerX, playerY); + int area = GetEncounterArea(fieldSystem, playerX, playerY); - if (encounterType == PAL_PARK_ENCOUNTER_TYPE_NONE) { + if (area == PAL_PARK_AREA_NONE) { return FALSE; } for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].encounterType == encounterType) { + if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].area == area) { totalRarity += catchingShow->pokemon[i].rarity; } } @@ -219,7 +237,7 @@ static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingSh encounterChance -= WEIGHT_NO_ENCOUNTER; for (i = 0; i < CATCHING_SHOW_MONS; i++) { - if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].encounterType == encounterType) { + if (catchingShow->caughtMonsOrder[i] == 0 && catchingShow->pokemon[i].area == area) { if (encounterChance < catchingShow->pokemon[i].rarity) { catchingShow->currentEncounterIndex = i; return TRUE; @@ -229,7 +247,7 @@ static BOOL TryStartEncounter(FieldSystem *fieldSystem, CatchingShow *catchingSh } } - GF_ASSERT(0); + GF_ASSERT(FALSE); return FALSE; } @@ -242,7 +260,7 @@ static void UpdateBattleResultInternal(FieldSystem *fieldSystem, FieldBattleDTO case BATTLE_RESULT_PLAYER_FLED: break; default: - GF_ASSERT(0); + GF_ASSERT(FALSE); } } diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index e97935a62c..dc03e5c8fa 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -3,6 +3,8 @@ #include #include +#include "consts/catching_show.h" + #include "struct_decls/pokedexdata_decl.h" #include "struct_decls/struct_02024440_decl.h" #include "struct_decls/struct_020797DC_decl.h" @@ -88,16 +90,16 @@ BOOL ScrCmd_CalcCatchingShowPoints(ScriptContext *ctx) u16 *destVar = ScriptContext_GetVarPointer(ctx); switch (pointsCategory) { - case CATCHING_POINTS: + case CATCHING_SHOW_CATCHING_POINTS: *destVar = CatchingShow_CalcCatchingPoints(ctx->fieldSystem); break; - case TIME_POINTS: + case CATCHING_SHOW_TIME_POINTS: *destVar = CatchingShow_GetTimePoints(ctx->fieldSystem); break; - case TYPE_POINTS: + case CATCHING_SHOW_TYPE_POINTS: *destVar = CatchingShow_GetTypePoints(ctx->fieldSystem); break; - case TOTAL_POINTS: + case CATCHING_SHOW_TOTAL_POINTS: *destVar = CatchingShow_CalcCatchingPoints(ctx->fieldSystem) + CatchingShow_GetTypePoints(ctx->fieldSystem) + CatchingShow_GetTimePoints(ctx->fieldSystem); break; } From cc99fa5bd149052512cb97b0012ccff939d3c557 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Wed, 1 Jan 2025 20:13:13 -0500 Subject: [PATCH 09/11] new line dont look at this --- consts/catching_show.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consts/catching_show.json b/consts/catching_show.json index f6fcf687db..7562d99103 100644 --- a/consts/catching_show.json +++ b/consts/catching_show.json @@ -10,4 +10,4 @@ ] } } -} \ No newline at end of file +} From 4b59eea00ee53e9cb8ccdf81a9986c6bfa3ff78c Mon Sep 17 00:00:00 2001 From: iriv24 Date: Sat, 4 Jan 2025 22:47:48 -0500 Subject: [PATCH 10/11] add VERSION_NONE to GBA cartridge versions --- include/global/pm_version.h | 23 ++++++++++++----------- src/main.c | 2 +- src/overlay097/ov97_0222D30C.c | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/global/pm_version.h b/include/global/pm_version.h index 87eb3641a8..89652f5f58 100644 --- a/include/global/pm_version.h +++ b/include/global/pm_version.h @@ -1,17 +1,18 @@ #ifndef POKEPLATINUM_PM_VERSION_H #define POKEPLATINUM_PM_VERSION_H -#define SAPPHIRE 1 -#define RUBY 2 -#define EMERALD 3 -#define FIRERED 4 -#define LEAFGREEN 5 -#define HEARTGOLD 7 -#define SOULSILVER 8 -#define DIAMOND 10 -#define PEARL 11 -#define PLATINUM 12 -#define COLOSSEUM 15 +#define VERSION_NONE 0 +#define SAPPHIRE 1 +#define RUBY 2 +#define EMERALD 3 +#define FIRERED 4 +#define LEAFGREEN 5 +#define HEARTGOLD 7 +#define SOULSILVER 8 +#define DIAMOND 10 +#define PEARL 11 +#define PLATINUM 12 +#define COLOSSEUM 15 #define JAPANESE 1 #define ENGLISH 2 diff --git a/src/main.c b/src/main.c index cc8efe3795..d5af9148fb 100644 --- a/src/main.c +++ b/src/main.c @@ -71,7 +71,7 @@ void NitroMain(void) InitGraphics(); InitKeypadAndTouchpad(); - SetGBACartridgeVersion(0); + SetGBACartridgeVersion(VERSION_NONE); PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); InitRTC(); diff --git a/src/overlay097/ov97_0222D30C.c b/src/overlay097/ov97_0222D30C.c index d49864c682..694d772151 100644 --- a/src/overlay097/ov97_0222D30C.c +++ b/src/overlay097/ov97_0222D30C.c @@ -2445,7 +2445,7 @@ static int ov97_022301BC(OverlayManager *param0, int *param1) Heap_Destroy(86); if (v0->unk_1638 == 2) { - SetGBACartridgeVersion(0); + SetGBACartridgeVersion(VERSION_NONE); } ov97_02238400(0); From 888f52711d8c468f477fad164e26a9459bad4114 Mon Sep 17 00:00:00 2001 From: iriv24 Date: Sat, 4 Jan 2025 22:56:49 -0500 Subject: [PATCH 11/11] replace VERSION_NONE with NULL --- include/global/pm_version.h | 23 +++++++++++------------ src/main.c | 2 +- src/overlay097/ov97_0222D30C.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/global/pm_version.h b/include/global/pm_version.h index 89652f5f58..87eb3641a8 100644 --- a/include/global/pm_version.h +++ b/include/global/pm_version.h @@ -1,18 +1,17 @@ #ifndef POKEPLATINUM_PM_VERSION_H #define POKEPLATINUM_PM_VERSION_H -#define VERSION_NONE 0 -#define SAPPHIRE 1 -#define RUBY 2 -#define EMERALD 3 -#define FIRERED 4 -#define LEAFGREEN 5 -#define HEARTGOLD 7 -#define SOULSILVER 8 -#define DIAMOND 10 -#define PEARL 11 -#define PLATINUM 12 -#define COLOSSEUM 15 +#define SAPPHIRE 1 +#define RUBY 2 +#define EMERALD 3 +#define FIRERED 4 +#define LEAFGREEN 5 +#define HEARTGOLD 7 +#define SOULSILVER 8 +#define DIAMOND 10 +#define PEARL 11 +#define PLATINUM 12 +#define COLOSSEUM 15 #define JAPANESE 1 #define ENGLISH 2 diff --git a/src/main.c b/src/main.c index d5af9148fb..c59effecf2 100644 --- a/src/main.c +++ b/src/main.c @@ -71,7 +71,7 @@ void NitroMain(void) InitGraphics(); InitKeypadAndTouchpad(); - SetGBACartridgeVersion(VERSION_NONE); + SetGBACartridgeVersion(NULL); PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); InitRTC(); diff --git a/src/overlay097/ov97_0222D30C.c b/src/overlay097/ov97_0222D30C.c index 694d772151..fc69e22955 100644 --- a/src/overlay097/ov97_0222D30C.c +++ b/src/overlay097/ov97_0222D30C.c @@ -2445,7 +2445,7 @@ static int ov97_022301BC(OverlayManager *param0, int *param1) Heap_Destroy(86); if (v0->unk_1638 == 2) { - SetGBACartridgeVersion(VERSION_NONE); + SetGBACartridgeVersion(NULL); } ov97_02238400(0);