From 4d1ff346c4643264432b744b5bafd092d03b4185 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:10 -0700 Subject: [PATCH 01/25] More Poketch System documentation --- include/overlay025/poketch_system.h | 2 +- src/overlay025/poketch_system.c | 126 ++++++++++++++-------------- src/overlay027/ov27_0225680C.c | 2 +- src/overlay028/ov28_0225697C.c | 2 +- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 3889ad0f9..9c180d267 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -41,7 +41,7 @@ struct PoketchSystem { UnkStruct_ov25_02254560 * unk_1C; UnkStruct_ov25_02254560_1 unk_20; void * unk_24; - PoketchButtonManager * unk_28; + PoketchButtonManager * buttonManager; u32 unk_2C; u32 unk_30; PoketchSystem ** poketchSysPtr; diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 2581670ed..d1a9a3f36 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -21,6 +21,7 @@ #include "heap.h" #include "unk_0201E3D8.h" #include "unk_02025E08.h" +#include "unk_0203CC84.h" #include "trainer_info.h" #include "unk_020508D4.h" #include "unk_02099D44.h" @@ -56,9 +57,9 @@ FS_EXTERN_OVERLAY(overlay53); FS_EXTERN_OVERLAY(overlay54); FS_EXTERN_OVERLAY(overlay55); -static PoketchSystem * ov25_02253CE0(void); +static PoketchSystem *PoketchSystem_GetFromFieldSystem(void); static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys); -static void ov25_02253E20(PoketchSystem *poketchSys); +static void PoketchSystem_Shutdown(PoketchSystem *poketchSys); static void PoketchSystem_MainTask(SysTask *param0, void * param1); static void ov25_02253E94(SysTask *param0, void * param1); static void ov25_02253E9C(PoketchSystem *poketchSys, u32 param1); @@ -73,12 +74,11 @@ static BOOL ov25_022541FC(PoketchSystem *poketchSys); static void ov25_0225420C(PoketchSystem *poketchSys); static BOOL ov25_02254228(PoketchSystem *poketchSys); static BOOL ov25_02254284(PoketchSystem *poketchSys); -static void ov25_022542C8(PoketchSystem *poketchSys); -static void ov25_022542D4(PoketchSystem *poketchSys); +static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); +static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); static void ov25_022542E4(u32 param0, u32 param1, u32 param2, void * param3); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); static inline BOOL inline_ov25_0225446C(u32 param0, u32 param1); -struct PoketchSystem * sub_0203D158(void); // the order of this array determines the app order in the poketch. static const struct { @@ -112,9 +112,9 @@ static const struct { {POKETCH_APPID_POKEMONHISTORY, FS_OVERLAY_ID(overlay54)} }; -static PoketchSystem * ov25_02253CE0 (void) +static PoketchSystem *PoketchSystem_GetFromFieldSystem(void) { - return sub_0203D158(); + return FieldSystem_PoketchSystem(); } @@ -220,30 +220,30 @@ static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) return FALSE; } -static void ov25_02253E20 (PoketchSystem * poketchSys) +static void PoketchSystem_Shutdown (PoketchSystem *poketchSys) { SysTask_Done(poketchSys->unk_38); - ov25_022542C8(poketchSys); + PoketchSystem_ButtonShutdown(poketchSys); PoketchSystem_UnloadApp(poketchSys); ov25_02254754(poketchSys->unk_1C); } +typedef void(*const PoketchEvent)(PoketchSystem *); +static PoketchEvent sPoketchEvents[] = { + ov25_02253EA4, + ov25_02253F2C, + ov25_0225406C, + ov25_022540D8 +}; + static void PoketchSystem_MainTask(SysTask *task, void *system) { - typedef void(*const PoketchEvent)(PoketchSystem *); - static PoketchEvent sPoketchEvents[] = { - ov25_02253EA4, - ov25_02253F2C, - ov25_0225406C, - ov25_022540D8 - }; - PoketchSystem *poketchSys = (PoketchSystem *)system; if (poketchSys->unk_00 < NELEMS(sPoketchEvents)) { if (poketchSys->unk_00 != 0) { - ov25_022542D4(poketchSys); + PoketchSystem_ButtonUpdate(poketchSys); } sPoketchEvents[poketchSys->unk_00](poketchSys); @@ -251,7 +251,7 @@ static void PoketchSystem_MainTask(SysTask *task, void *system) GF_ASSERT(poketchSys->unk_00 == 4); *(poketchSys->poketchSysPtr) = NULL; - ov25_02253E20(poketchSys); + PoketchSystem_Shutdown(poketchSys); Heap_FreeToHeap(poketchSys); SysTask_Done(task); Heap_Destroy(7); @@ -261,10 +261,10 @@ static void PoketchSystem_MainTask(SysTask *task, void *system) static void ov25_02253E94 (SysTask * param0, void * param1) { - PoketchSystem * v0 = param1; + PoketchSystem *poketchSys = param1; - v0->unk_04 = 0; - v0->pedometerUpdated = FALSE; + poketchSys->unk_04 = 0; + poketchSys->pedometerUpdated = FALSE; } static void ov25_02253E9C (PoketchSystem *poketchSys, u32 param1) @@ -525,11 +525,11 @@ static BOOL ov25_02254228 (PoketchSystem *poketchSys) void ov25_02254238 (UnkFuncPtr_ov25_02254238 param0, UnkFuncPtr_ov25_02254238_1 param1) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - v0->unk_3C = param0; - v0->unk_40 = param1; - v0->unk_44 = NULL; + poketchSys->unk_3C = param0; + poketchSys->unk_40 = param1; + poketchSys->unk_44 = NULL; } void ov25_0225424C (PoketchSystem *poketchSys) @@ -546,10 +546,10 @@ void ov25_02254260 (PoketchSystem *poketchSys) void ov25_02254274 (UnkFuncPtr_ov25_02254274 param0, void * param1) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - v0->unk_44 = param0; - v0->unk_48 = param1; + poketchSys->unk_44 = param0; + poketchSys->unk_48 = param1; } static BOOL ov25_02254284 (PoketchSystem *poketchSys) @@ -560,10 +560,10 @@ static BOOL ov25_02254284 (PoketchSystem *poketchSys) {16, 175, 16, 207} }; - poketchSys->unk_28 = PoketchButtonManager_New(v0, NELEMS(v0), ov25_022542E4, poketchSys, 7); + poketchSys->buttonManager = PoketchButtonManager_New(v0, NELEMS(v0), ov25_022542E4, poketchSys, 7); - if (poketchSys->unk_28 != NULL) { - PoketchButtonManager_SetButtonTimer(poketchSys->unk_28, 0, 0, 7); + if (poketchSys->buttonManager != NULL) { + PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, 0, 0, 7); poketchSys->unk_2C = 0xffffffff; poketchSys->unk_30 = 0xffffffff; return 1; @@ -572,36 +572,36 @@ static BOOL ov25_02254284 (PoketchSystem *poketchSys) return 0; } -static void ov25_022542C8 (PoketchSystem *poketchSys) +static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys) { - PoketchButtonManager_Free(poketchSys->unk_28); + PoketchButtonManager_Free(poketchSys->buttonManager); } -static void ov25_022542D4 (PoketchSystem *poketchSys) +static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys) { poketchSys->unk_08 = 0; - PoketchButtonManager_Update(poketchSys->unk_28); + PoketchButtonManager_Update(poketchSys->buttonManager); } static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) { - PoketchSystem * v0 = (PoketchSystem *)param3; + PoketchSystem * poketchSys = (PoketchSystem *)param3; - if (ov25_0225450C(v0) == 0) { + if (ov25_0225450C(poketchSys) == 0) { switch (param2) { case 1: - v0->unk_03 = 1; + poketchSys->unk_03 = 1; break; case 0: - v0->unk_03 = 0; + poketchSys->unk_03 = 0; break; } } else { - v0->unk_03 = 0; + poketchSys->unk_03 = 0; } if (param0 == 2) { - if (ov25_0225450C(v0)) { + if (ov25_0225450C(poketchSys)) { if (param2 == 1) { Sound_PlayEffect(1646); } @@ -614,7 +614,7 @@ static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) v1 = (param0 == 0) ? 8 : 11; break; case 1: - if (ov25_0225450C(v0) || v0->unk_06) { + if (ov25_0225450C(poketchSys) || poketchSys->unk_06) { v1 = (param0 == 0) ? 6 : 9; param1 = 0; } else { @@ -623,39 +623,39 @@ static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) break; } - if (v0->unk_2C != 0xffffffff) { + if (poketchSys->unk_2C != 0xffffffff) { u32 v2 = v1; - v1 = v0->unk_2C; - v0->unk_2C = v2; + v1 = poketchSys->unk_2C; + poketchSys->unk_2C = v2; } if (v1 != 0xffffffff) { - if (ov25_022543EC(v0->unk_1C, v1)) { + if (ov25_022543EC(poketchSys->unk_1C, v1)) { if ((v1 == 6) || (v1 == 7) || (v1 == 9) || (v1 == 10)) { - v0->unk_30 = v1; + poketchSys->unk_30 = v1; } } } switch (param1) { case 5: - PoketchButtonManager_ResetButtonState(v0->unk_28, 0); + PoketchButtonManager_ResetButtonState(poketchSys->buttonManager, 0); break; case 3: - if ((v0->unk_30 == 6) || (v0->unk_30 == 9)) { + if ((poketchSys->unk_30 == 6) || (poketchSys->unk_30 == 9)) { param1 = 0; } break; case 2: - if ((v0->unk_30 == 7) || (v0->unk_30 == 10)) { + if ((poketchSys->unk_30 == 7) || (poketchSys->unk_30 == 10)) { param1 = 3; } break; } - v0->unk_08 = param1; - v0->buttonDir = (param0 == 0) ? BUTTON_UP : BUTTON_DOWN; + poketchSys->unk_08 = param1; + poketchSys->buttonDir = (param0 == 0) ? BUTTON_UP : BUTTON_DOWN; } } @@ -676,24 +676,24 @@ static BOOL ov25_022543EC (UnkStruct_ov25_02254560 * param0, u32 param1) UnkStruct_ov25_02254560 * ov25_02254418 (void) { - PoketchSystem * v0 = ov25_02253CE0(); - return v0->unk_1C; + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); + return poketchSys->unk_1C; } void ov25_02254424 (u32 param0) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((v0->unk_05 == 0) && (ov25_0225450C(v0) == 0)) { + if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { Sound_PlayEffect(param0); } } void ov25_02254444 (u32 param0, u32 param1) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((v0->unk_05 == 0) && (ov25_0225450C(v0) == 0)) { + if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { sub_02005844(param0, param1); } } @@ -709,9 +709,9 @@ static inline BOOL inline_ov25_0225446C (u32 param0, u32 param1) BOOL ov25_0225446C (u32 * param0, u32 * param1) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((v0->unk_05 == 0) && (ov25_0225450C(v0) == 0)) { + if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { if (sub_020227A4(param0, param1)) { return inline_ov25_0225446C(*param0, *param1); } @@ -722,9 +722,9 @@ BOOL ov25_0225446C (u32 * param0, u32 * param1) BOOL ov25_022544BC (u32 * param0, u32 * param1) { - PoketchSystem * v0 = ov25_02253CE0(); + PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((v0->unk_05 == 0) && (ov25_0225450C(v0) == 0)) { + if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { if (sub_020227C0(param0, param1)) { return inline_ov25_0225446C(*param0, *param1); } diff --git a/src/overlay027/ov27_0225680C.c b/src/overlay027/ov27_0225680C.c index a6f247b25..3f076c738 100644 --- a/src/overlay027/ov27_0225680C.c +++ b/src/overlay027/ov27_0225680C.c @@ -61,7 +61,7 @@ static BOOL ov27_02256E90(UnkStruct_ov27_02256E90 * param0, u32 param1); static void ov27_02256EC4(BGL * param0, u32 param1); static void ov27_02256F24(SysTask * param0, void * param1); static void ov27_02256F7C(UnkStruct_ov27_0225680C * param0); -struct PoketchSystem * sub_0203D158(void); +struct PoketchSystem * FieldSystem_PoketchSystem(void); BOOL ov27_0225680C (UnkStruct_ov27_0225680C ** param0, const UnkStruct_ov27_0225680C_1 * param1, BGL * param2) { diff --git a/src/overlay028/ov28_0225697C.c b/src/overlay028/ov28_0225697C.c index 52d5e7f53..2830db19b 100644 --- a/src/overlay028/ov28_0225697C.c +++ b/src/overlay028/ov28_0225697C.c @@ -43,7 +43,7 @@ static void ov28_02256D90(BGL * param0, const UnkStruct_ov28_0225697C_1 * param1 static void ov28_02256DCC(BGL * param0); static void ov28_02256DF0(SysTask * param0, void * param1); static void ov28_02256E0C(BGL * param0, const u16 * param1); -struct PoketchSystem * sub_0203D158(void); +struct PoketchSystem * FieldSystem_PoketchSystem(void); static const u16 Unk_ov28_022578F8[32] = { 0xFB, From d3335532fc68b2bd9892890fab258312e1a1ac59 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:11 -0700 Subject: [PATCH 02/25] Resolve merge conflicts and move changes to feature branch --- include/overlay025/poketch_system.h | 54 ++++++----- src/overlay025/ov25_02254560.c | 2 +- src/overlay025/poketch_system.c | 136 ++++++++++++++-------------- src/overlay026/ov26_022561C0.c | 6 +- src/overlay027/ov27_022561C0.c | 6 +- src/overlay028/ov28_022561C0.c | 6 +- src/overlay029/ov29_022561C0.c | 6 +- src/overlay030/ov30_022561C0.c | 6 +- src/overlay031/ov31_022561C0.c | 6 +- src/overlay032/ov32_022561C0.c | 6 +- src/overlay033/ov33_022561C0.c | 6 +- src/overlay034/ov34_022561C0.c | 6 +- src/overlay035/ov35_022561C0.c | 6 +- src/overlay036/ov36_022561C0.c | 6 +- src/overlay037/ov37_022561C0.c | 6 +- src/overlay038/ov38_022561C0.c | 6 +- src/overlay039/ov39_022561C0.c | 6 +- src/overlay040/ov40_022561C0.c | 6 +- src/overlay041/ov41_022561C0.c | 6 +- src/overlay042/ov42_022561C0.c | 6 +- src/overlay043/ov43_022561C0.c | 6 +- src/overlay044/ov44_022561C0.c | 6 +- src/overlay045/ov45_022561C0.c | 6 +- src/overlay046/ov46_022561C0.c | 6 +- src/overlay049/ov49_022561C0.c | 6 +- src/overlay050/ov50_022561C0.c | 6 +- src/overlay051/ov51_022561C0.c | 6 +- src/overlay053/ov53_022561C0.c | 6 +- src/overlay054/ov54_022561C0.c | 6 +- src/overlay055/ov55_022561C0.c | 6 +- 30 files changed, 183 insertions(+), 171 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 9c180d267..40d1b2e35 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_OV25_02253CE0_H -#define POKEPLATINUM_OV25_02253CE0_H +#ifndef POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H +#define POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H #include "struct_decls/struct_02018340_decl.h" #include "field/field_system_decl.h" @@ -13,27 +13,39 @@ #include -enum ButtonDir{ +enum ButtonDir { BUTTON_UP, BUTTON_DOWN, }; +enum PoketchAppState { + POKETCH_APP_STATE_NONE, + POKETCH_APP_STATE_INIT, + POKETCH_APP_STATE_UPDATE, + POKETCH_APP_STATE_SHUTDOWN +}; + +enum PoketchBorderColor { + POKETCH_BORDER_PINK, + POKETCH_BORDER_BLUE +}; + typedef struct PoketchSystem PoketchSystem; -typedef BOOL (* UnkFuncPtr_ov25_02254238)(void **, PoketchSystem *, BGL *, u32); -typedef void (* UnkFuncPtr_ov25_02254238_1)(void *); -typedef void (* UnkFuncPtr_ov25_02254274)(void *); +typedef BOOL (* PoketchAppInitFunction)(void **, PoketchSystem *, BGL *, u32); +typedef void (* PoketchAppShutdownFunction)(void *); +typedef void (* PoketchAppSaveFunction)(void *); struct PoketchSystem { u8 unk_00; u8 unk_01; - u8 unk_02; + u8 appState; u8 unk_03; u8 unk_04; u8 unk_05; u8 unk_06; u8 pedometerUpdated; - u32 unk_08; + u32 buttonState; BOOL unk_0C; u32 unk_10; enum PoketchAppID loadedAppID; @@ -41,20 +53,20 @@ struct PoketchSystem { UnkStruct_ov25_02254560 * unk_1C; UnkStruct_ov25_02254560_1 unk_20; void * unk_24; - PoketchButtonManager * buttonManager; + PoketchButtonManager *buttonManager; u32 unk_2C; u32 unk_30; PoketchSystem ** poketchSysPtr; SysTask * unk_38; - UnkFuncPtr_ov25_02254238 unk_3C; - UnkFuncPtr_ov25_02254238_1 unk_40; - UnkFuncPtr_ov25_02254274 unk_44; + PoketchAppInitFunction currAppInit; + PoketchAppShutdownFunction currAppShutdown; + PoketchAppSaveFunction currAppSave; void * unk_48; BGL *bgl; NNSG2dOamManagerInstance * unk_50; - SaveData * saveData; - PoketchData * poketchData; - FieldSystem * fieldSystem; + SaveData *saveData; + PoketchData *poketchData; + FieldSystem *fieldSys; enum ButtonDir buttonDir; }; @@ -64,10 +76,10 @@ BOOL ov25_02253D70(PoketchSystem *poketchSys); void ov25_02253D7C(PoketchSystem *poketchSys, int param1, u32 param2); BOOL ov25_02253DD4(PoketchSystem *poketchSys); enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys); -void ov25_02254238(UnkFuncPtr_ov25_02254238 param0, UnkFuncPtr_ov25_02254238_1 param1); -void ov25_0225424C(PoketchSystem *poketchSys); -void ov25_02254260(PoketchSystem *poketchSys); -void ov25_02254274(UnkFuncPtr_ov25_02254274 param0, void * param1); +void PoketchSystem_SetAppFunctions(PoketchAppInitFunction param0, PoketchAppShutdownFunction param1); +void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); +void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys); +void ov25_02254274(PoketchAppSaveFunction param0, void * param1); UnkStruct_ov25_02254560 * ov25_02254418(void); void ov25_02254424(u32 param0); void ov25_02254444(u32 param0, u32 param1); @@ -80,6 +92,6 @@ BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys); FieldSystem * PoketchSystem_FieldSystem(const PoketchSystem *poketchSys); PoketchData * PoketchSystem_PoketchData(const PoketchSystem *poketchSys); SaveData * PoketchSystem_SaveData(const PoketchSystem *poketchSys); -int ov25_02254548(const PoketchSystem *poketchSys); +int PoketchSystem_BorderColor(const PoketchSystem *poketchSys); -#endif // POKEPLATINUM_OV25_02253CE0_H +#endif // POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H diff --git a/src/overlay025/ov25_02254560.c b/src/overlay025/ov25_02254560.c index 20b043c6e..18c661438 100644 --- a/src/overlay025/ov25_02254560.c +++ b/src/overlay025/ov25_02254560.c @@ -324,7 +324,7 @@ static void ov25_02254820 (SysTask * param0, void * param1) sub_02006E3C(12, 14, v2->unk_1F8, 4, 64, 0, 1, 7); sub_02006E60(12, 15, v2->unk_1F8, 4, 0, 0, 1, 7); - sub_02006E9C(12, 13, 4, ov25_02254548(v2->unk_1FC) * 0x20, 15 * 0x20, 0x20, 7); + sub_02006E9C(12, 13, 4, PoketchSystem_BorderColor(v2->unk_1FC) * 0x20, 15 * 0x20, 0x20, 7); sub_02019CB8(v2->unk_1F8, 5, 64 + 164, 0, 0, 32, 24, 15); sub_02019448(v2->unk_1F8, 5); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index d1a9a3f36..2c4c416b9 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -63,17 +63,17 @@ static void PoketchSystem_Shutdown(PoketchSystem *poketchSys); static void PoketchSystem_MainTask(SysTask *param0, void * param1); static void ov25_02253E94(SysTask *param0, void * param1); static void ov25_02253E9C(PoketchSystem *poketchSys, u32 param1); -static void ov25_02253EA4(PoketchSystem *poketchSys); -static void ov25_02253F2C(PoketchSystem *poketchSys); -static void ov25_0225406C(PoketchSystem *poketchSys); -static void ov25_022540D8(PoketchSystem *poketchSys); +static void PoketchEvent_InitApp(PoketchSystem *poketchSys); +static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys); +static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys); +static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys); static void PoketchSystem_LoadApp(PoketchSystem *poketchSys, int param1); static void PoketchSystem_UnloadApp(PoketchSystem *poketchSys); static void ov25_022541D8(PoketchSystem *poketchSys, u32 param1); static BOOL ov25_022541FC(PoketchSystem *poketchSys); static void ov25_0225420C(PoketchSystem *poketchSys); static BOOL ov25_02254228(PoketchSystem *poketchSys); -static BOOL ov25_02254284(PoketchSystem *poketchSys); +static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys); static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); static void ov25_022542E4(u32 param0, u32 param1, u32 param2, void * param3); @@ -178,9 +178,9 @@ void ov25_02253D7C (PoketchSystem *poketchSys, int param1, u32 param2) } break; case 4: - if (poketchSys->unk_02 == 2) { - if (poketchSys->unk_44) { - poketchSys->unk_44(poketchSys->unk_48); + if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { + if (poketchSys->currAppSave) { + poketchSys->currAppSave(poketchSys->unk_48); } } break; @@ -208,11 +208,11 @@ static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) poketchSys->unk_05 = 0; poketchSys->unk_06 = 0; poketchSys->loadedAppID = POKETCH_APPID_NONE; - poketchSys->unk_02 = 0; - poketchSys->unk_08 = 0; + poketchSys->appState = POKETCH_APP_STATE_NONE; + poketchSys->buttonState = BUTTON_MANAGER_STATE_NULL; poketchSys->buttonDir = BUTTON_UP; - if (ov25_02254284(poketchSys)) { + if (PoketchSystem_ButtonInit(poketchSys)) { return TRUE; } } @@ -231,10 +231,10 @@ static void PoketchSystem_Shutdown (PoketchSystem *poketchSys) typedef void(*const PoketchEvent)(PoketchSystem *); static PoketchEvent sPoketchEvents[] = { - ov25_02253EA4, - ov25_02253F2C, - ov25_0225406C, - ov25_022540D8 + PoketchEvent_InitApp, + PoketchEvent_UpdateApp, + PoketchEvent_OnAppChange, + PoketchEvent_OnShutdown }; static void PoketchSystem_MainTask(SysTask *task, void *system) @@ -273,7 +273,7 @@ static void ov25_02253E9C (PoketchSystem *poketchSys, u32 param1) poketchSys->unk_01 = 0; } -static void ov25_02253EA4 (PoketchSystem *poketchSys) +static void PoketchEvent_InitApp(PoketchSystem *poketchSys) { switch (poketchSys->unk_01) { case 0: @@ -304,7 +304,7 @@ static void ov25_02253EA4 (PoketchSystem *poketchSys) } } -static void ov25_02253F2C (PoketchSystem *poketchSys) +static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) { switch (poketchSys->unk_01) { case 0: @@ -312,7 +312,7 @@ static void ov25_02253F2C (PoketchSystem *poketchSys) return; } - switch (poketchSys->unk_08) { + switch (poketchSys->buttonState) { case 3: case 5: poketchSys->unk_0C = 0; @@ -323,7 +323,7 @@ static void ov25_02253F2C (PoketchSystem *poketchSys) } break; case 1: - if ((poketchSys->unk_08 == 3) || (poketchSys->unk_08 == 5)) { + if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { poketchSys->unk_0C = 1; } @@ -346,7 +346,7 @@ static void ov25_02253F2C (PoketchSystem *poketchSys) } break; case 2: - if ((poketchSys->unk_08 == 3) || (poketchSys->unk_08 == 5)) { + if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { ov25_022547D0(poketchSys->unk_1C, 12); poketchSys->unk_10 = 30; poketchSys->unk_0C = 0; @@ -362,14 +362,14 @@ static void ov25_02253F2C (PoketchSystem *poketchSys) } break; case 3: - if (ov25_02254228(poketchSys)) { + if (PoketchSystem_IsAppShutdown(poketchSys)) { PoketchSystem_UnloadApp(poketchSys); sub_02099D44(); ov25_02253E9C(poketchSys, 2); } break; case 4: - if ((poketchSys->unk_08 == 3) || (poketchSys->unk_08 == 5)) { + if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { if (poketchSys->buttonDir == BUTTON_UP) { poketchSys->unk_20.unk_00 = PoketchData_DecrementAppID(poketchSys->poketchData); } else { @@ -392,7 +392,7 @@ static void ov25_02253F2C (PoketchSystem *poketchSys) } } -static void ov25_0225406C (PoketchSystem *poketchSys) +static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) { switch (poketchSys->unk_01) { case 0: @@ -424,11 +424,11 @@ static void ov25_0225406C (PoketchSystem *poketchSys) } } -static void ov25_022540D8 (PoketchSystem *poketchSys) +static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys) { switch (poketchSys->unk_01) { case 0: - switch (poketchSys->unk_02) { + switch (poketchSys->appState) { case 1: poketchSys->unk_01 = 1; break; @@ -449,7 +449,7 @@ static void ov25_022540D8 (PoketchSystem *poketchSys) } break; case 2: - if (ov25_02254228(poketchSys)) { + if (PoketchSystem_IsAppShutdown(poketchSys)) { ov25_022547D0(poketchSys->unk_1C, 17); poketchSys->unk_01 = 3; } @@ -491,15 +491,15 @@ static void PoketchSystem_UnloadApp(PoketchSystem *poketchSys) static void ov25_022541D8 (PoketchSystem *poketchSys, u32 param1) { - GF_ASSERT(poketchSys->unk_02 == 0); + GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_NONE); - poketchSys->unk_3C(&(poketchSys->unk_24), poketchSys, poketchSys->bgl, poketchSys->loadedAppID); - poketchSys->unk_02 = 1; + poketchSys->currAppInit(&(poketchSys->unk_24), poketchSys, poketchSys->bgl, poketchSys->loadedAppID); + poketchSys->appState = POKETCH_APP_STATE_INIT; } static BOOL ov25_022541FC (PoketchSystem *poketchSys) { - if (poketchSys->unk_02 == 2) { + if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { return 1; } @@ -508,68 +508,68 @@ static BOOL ov25_022541FC (PoketchSystem *poketchSys) static void ov25_0225420C (PoketchSystem *poketchSys) { - GF_ASSERT(poketchSys->unk_02 == 2); + GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_UPDATE); - poketchSys->unk_40(poketchSys->unk_24); - poketchSys->unk_02 = 3; + poketchSys->currAppShutdown(poketchSys->unk_24); + poketchSys->appState = POKETCH_APP_STATE_SHUTDOWN; } -static BOOL ov25_02254228 (PoketchSystem *poketchSys) +static BOOL PoketchSystem_IsAppShutdown(PoketchSystem *poketchSys) { - if (poketchSys->unk_02 == 0) { + if (poketchSys->appState == POKETCH_APP_STATE_NONE) { return TRUE; } return FALSE; } -void ov25_02254238 (UnkFuncPtr_ov25_02254238 param0, UnkFuncPtr_ov25_02254238_1 param1) +void PoketchSystem_SetAppFunctions(PoketchAppInitFunction appInit, PoketchAppShutdownFunction appShutdown) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - poketchSys->unk_3C = param0; - poketchSys->unk_40 = param1; - poketchSys->unk_44 = NULL; + poketchSys->currAppInit = appInit; + poketchSys->currAppShutdown = appShutdown; + poketchSys->currAppSave = NULL; } -void ov25_0225424C (PoketchSystem *poketchSys) +void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys) { - GF_ASSERT(poketchSys->unk_02 == 1); - poketchSys->unk_02 = 2; + GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_INIT); + poketchSys->appState = POKETCH_APP_STATE_UPDATE; } -void ov25_02254260 (PoketchSystem *poketchSys) +void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys) { - GF_ASSERT(poketchSys->unk_02 == 3); - poketchSys->unk_02 = 0; + GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_SHUTDOWN); + poketchSys->appState = POKETCH_APP_STATE_NONE; } -void ov25_02254274 (UnkFuncPtr_ov25_02254274 param0, void * param1) +void ov25_02254274 (PoketchAppSaveFunction param0, void * param1) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - poketchSys->unk_44 = param0; + poketchSys->currAppSave = param0; poketchSys->unk_48 = param1; } -static BOOL ov25_02254284 (PoketchSystem *poketchSys) -{ - static const TouchScreenHitTable v0[] = { - {4 * 8, 12 * 8, 28 * 8, 255}, - {12 * 8, 20 * 8, 28 * 8, 255}, - {16, 175, 16, 207} - }; +static const TouchScreenHitTable sMainPoketchButtons[] = { + {4 * 8, 12 * 8, 28 * 8, 255}, // Top button + {12 * 8, 20 * 8, 28 * 8, 255}, // Bottom Button + {16, 175, 16, 207} // Screen +}; - poketchSys->buttonManager = PoketchButtonManager_New(v0, NELEMS(v0), ov25_022542E4, poketchSys, 7); +static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) +{ + poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), ov25_022542E4, poketchSys, 7); if (poketchSys->buttonManager != NULL) { PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, 0, 0, 7); poketchSys->unk_2C = 0xffffffff; poketchSys->unk_30 = 0xffffffff; - return 1; + return TRUE; } - return 0; + return FALSE; } static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys) @@ -579,7 +579,7 @@ static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys) static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys) { - poketchSys->unk_08 = 0; + poketchSys->buttonState = 0; PoketchButtonManager_Update(poketchSys->buttonManager); } @@ -654,7 +654,7 @@ static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) break; } - poketchSys->unk_08 = param1; + poketchSys->buttonState = param1; poketchSys->buttonDir = (param0 == 0) ? BUTTON_UP : BUTTON_DOWN; } } @@ -701,10 +701,10 @@ void ov25_02254444 (u32 param0, u32 param1) static inline BOOL inline_ov25_0225446C (u32 param0, u32 param1) { if (((u32)(param0 - 16) < (u32)(207 - 16)) & ((u32)(param1 - 16) < (u32)(175 - 16))) { - return 1; + return TRUE; } - return 0; + return FALSE; } BOOL ov25_0225446C (u32 * param0, u32 * param1) @@ -738,10 +738,10 @@ BOOL ov25_0225450C (const PoketchSystem *poketchSys) return sub_020509A4(poketchSys->fieldSystem); } -void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager * param1) +void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *buttonManager) { if ((ov25_0225450C(poketchSys) == 0) && (poketchSys->unk_05 == 0)) { - PoketchButtonManager_Update(param1); + PoketchButtonManager_Update(buttonManager); } } @@ -770,13 +770,13 @@ SaveData* PoketchSystem_SaveData(const PoketchSystem *poketchSys) return poketchSys->saveData; } -int ov25_02254548 (const PoketchSystem *poketchSys) +int PoketchSystem_BorderColor (const PoketchSystem *poketchSys) { - TrainerInfo * v0 = SaveData_GetTrainerInfo(poketchSys->saveData); + TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(poketchSys->saveData); - if (TrainerInfo_Gender(v0) == 1) { - return 0; + if (TrainerInfo_Gender(trainerInfo) == 1) { + return POKETCH_BORDER_PINK; } else { - return 1; + return POKETCH_BORDER_BLUE; } } diff --git a/src/overlay026/ov26_022561C0.c b/src/overlay026/ov26_022561C0.c index 7a537c57b..c0ec2f7a3 100644 --- a/src/overlay026/ov26_022561C0.c +++ b/src/overlay026/ov26_022561C0.c @@ -52,7 +52,7 @@ static const TouchScreenHitTable Unk_ov26_02256718[] = { static void NitroStaticInit (void) { - ov25_02254238(ov26_022561D4, ov26_022562F8); + PoketchSystem_SetAppFunctions(ov26_022561D4, ov26_022562F8); } static BOOL ov26_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -130,7 +130,7 @@ static void ov26_022562BC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov26_022562A4(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_28); + PoketchSystem_NotifyAppUnloaded(v1->unk_28); } } else { } @@ -177,7 +177,7 @@ static BOOL ov26_02256330 (UnkStruct_ov26_0225621C * param0) break; case 1: if (ov26_022564CC(param0->unk_24, 0)) { - ov25_0225424C(param0->unk_28); + PoketchSystem_NotifyAppLoaded(param0->unk_28); ov26_0225631C(param0, 1); } break; diff --git a/src/overlay027/ov27_022561C0.c b/src/overlay027/ov27_022561C0.c index ed7c0b036..ffa4b1dd5 100644 --- a/src/overlay027/ov27_022561C0.c +++ b/src/overlay027/ov27_022561C0.c @@ -68,7 +68,7 @@ static void ov27_022566D8(UnkStruct_ov27_0225621C * param0, UnkStruct_ov27_02256 static void NitroStaticInit (void) { - ov25_02254238(ov27_022561D4, ov27_02256358); + PoketchSystem_SetAppFunctions(ov27_022561D4, ov27_02256358); } static BOOL ov27_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -172,7 +172,7 @@ static void ov27_022562FC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov27_022562AC(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_64); + PoketchSystem_NotifyAppUnloaded(v1->unk_64); } } else { } @@ -206,7 +206,7 @@ static BOOL ov27_0225637C (UnkStruct_ov27_0225621C * param0) break; case 1: if (ov27_022569EC(param0->unk_60, 0)) { - ov25_0225424C(param0->unk_64); + PoketchSystem_NotifyAppLoaded(param0->unk_64); if (param0->unk_1C.unk_00) { ov27_02256360(param0, 2); diff --git a/src/overlay028/ov28_022561C0.c b/src/overlay028/ov28_022561C0.c index 7b67df64c..3ee939265 100644 --- a/src/overlay028/ov28_022561C0.c +++ b/src/overlay028/ov28_022561C0.c @@ -78,7 +78,7 @@ static const TouchScreenHitTable Unk_ov28_02257658[] = { static void NitroStaticInit (void) { - ov25_02254238(ov28_022561D4, ov28_02256324); + PoketchSystem_SetAppFunctions(ov28_022561D4, ov28_02256324); } static BOOL ov28_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -175,7 +175,7 @@ static void ov28_022562CC (SysTask * param0, void * param1) ov28_02256298(v1); Heap_FreeToHeap(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_10); + PoketchSystem_NotifyAppUnloaded(v1->unk_10); } } else { } @@ -227,7 +227,7 @@ static BOOL ov28_02256374 (UnkStruct_ov28_02256210 * param0) break; case 1: if (ov28_022569DC(param0->unk_14, 0)) { - ov25_0225424C(param0->unk_10); + PoketchSystem_NotifyAppLoaded(param0->unk_10); ov28_0225632C(param0, 1); } break; diff --git a/src/overlay029/ov29_022561C0.c b/src/overlay029/ov29_022561C0.c index d88cd20fc..460a5305b 100644 --- a/src/overlay029/ov29_022561C0.c +++ b/src/overlay029/ov29_022561C0.c @@ -50,7 +50,7 @@ static const TouchScreenHitTable Unk_ov29_02256B3C[] = { static void NitroStaticInit (void) { - ov25_02254238(ov29_022561D4, ov29_02256324); + PoketchSystem_SetAppFunctions(ov29_022561D4, ov29_02256324); } static BOOL ov29_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -117,7 +117,7 @@ static void ov29_022562AC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov29_02256288(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_16F8); + PoketchSystem_NotifyAppUnloaded(v1->unk_16F8); } } else { } @@ -160,7 +160,7 @@ static BOOL ov29_02256340 (UnkStruct_ov29_0225621C * param0) break; case 1: if (ov29_022567D8(param0->unk_16F4, 0)) { - ov25_0225424C(param0->unk_16F8); + PoketchSystem_NotifyAppLoaded(param0->unk_16F8); ov29_0225632C(param0, 1); } break; diff --git a/src/overlay030/ov30_022561C0.c b/src/overlay030/ov30_022561C0.c index d414c8a1c..c467a45ed 100644 --- a/src/overlay030/ov30_022561C0.c +++ b/src/overlay030/ov30_022561C0.c @@ -51,7 +51,7 @@ static const TouchScreenHitTable Unk_ov30_02256678[] = { static void NitroStaticInit (void) { - ov25_02254238(ov30_022561D4, ov30_022562EC); + PoketchSystem_SetAppFunctions(ov30_022561D4, ov30_022562EC); } static BOOL ov30_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -129,7 +129,7 @@ static void ov30_022562B0 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov30_02256298(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_28); + PoketchSystem_NotifyAppUnloaded(v1->unk_28); } } else { } @@ -176,7 +176,7 @@ static BOOL ov30_02256324 (UnkStruct_ov30_0225621C * param0) break; case 1: if (ov30_02256488(param0->unk_24, 0)) { - ov25_0225424C(param0->unk_28); + PoketchSystem_NotifyAppLoaded(param0->unk_28); ov30_02256310(param0, 1); } break; diff --git a/src/overlay031/ov31_022561C0.c b/src/overlay031/ov31_022561C0.c index 83ded7085..87c28a1ae 100644 --- a/src/overlay031/ov31_022561C0.c +++ b/src/overlay031/ov31_022561C0.c @@ -50,7 +50,7 @@ static BOOL ov31_02256518(UnkStruct_ov31_02256228 * param0); static void NitroStaticInit (void) { - ov25_02254238(ov31_022561D4, ov31_02256404); + PoketchSystem_SetAppFunctions(ov31_022561D4, ov31_02256404); } static BOOL ov31_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -204,7 +204,7 @@ static void ov31_022563CC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov31_02256384(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_1F0); + PoketchSystem_NotifyAppUnloaded(v1->unk_1F0); } } else { } @@ -235,7 +235,7 @@ static BOOL ov31_02256420 (UnkStruct_ov31_02256228 * param0) break; case 1: if (ov31_022565B4(param0->unk_1EC, 0)) { - ov25_0225424C(param0->unk_1F0); + PoketchSystem_NotifyAppLoaded(param0->unk_1F0); ov31_0225640C(param0, 1); } break; diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 8ee56f758..89acad2a6 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -43,7 +43,7 @@ static void ov32_022563C8(UnkStruct_ov32_02256470_1 * param0, Party * param1); static void NitroStaticInit (void) { - ov25_02254238(ov32_022561D4, ov32_022562AC); + PoketchSystem_SetAppFunctions(ov32_022561D4, ov32_022562AC); } static BOOL ov32_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -105,7 +105,7 @@ static void ov32_02256278 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov32_02256264(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_78); + PoketchSystem_NotifyAppUnloaded(v1->unk_78); } } else { } @@ -136,7 +136,7 @@ static BOOL ov32_022562C8 (UnkStruct_ov32_0225621C * param0) break; case 1: if (ov32_0225655C(param0->unk_74, 0)) { - ov25_0225424C(param0->unk_78); + PoketchSystem_NotifyAppLoaded(param0->unk_78); ov32_022562B4(param0, 1); } break; diff --git a/src/overlay033/ov33_022561C0.c b/src/overlay033/ov33_022561C0.c index f650610df..2e7834964 100644 --- a/src/overlay033/ov33_022561C0.c +++ b/src/overlay033/ov33_022561C0.c @@ -44,7 +44,7 @@ static BOOL ov33_02256440(UnkStruct_ov33_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov33_022561D4, ov33_02256374); + PoketchSystem_SetAppFunctions(ov33_022561D4, ov33_02256374); } static BOOL ov33_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -163,7 +163,7 @@ static void ov33_02256340 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov33_0225632C(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_60); + PoketchSystem_NotifyAppUnloaded(v1->unk_60); } } else { } @@ -194,7 +194,7 @@ static BOOL ov33_02256390 (UnkStruct_ov33_0225621C * param0) break; case 1: if (ov33_0225656C(param0->unk_5C, 0)) { - ov25_0225424C(param0->unk_60); + PoketchSystem_NotifyAppLoaded(param0->unk_60); ov33_0225637C(param0, 1); } break; diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index 05a383f91..e85063c46 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -43,7 +43,7 @@ static BOOL ov34_0225650C(UnkStruct_ov34_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov34_022561D4, ov34_02256294); + PoketchSystem_SetAppFunctions(ov34_022561D4, ov34_02256294); } static BOOL ov34_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -103,7 +103,7 @@ static void ov34_02256260 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov34_02256244(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_4C); + PoketchSystem_NotifyAppUnloaded(v1->unk_4C); } } else { } @@ -134,7 +134,7 @@ static BOOL ov34_022562B0 (UnkStruct_ov34_0225621C * param0) break; case 1: if (ov34_02256664(param0->unk_48, 0)) { - ov25_0225424C(param0->unk_4C); + PoketchSystem_NotifyAppLoaded(param0->unk_4C); ov34_0225629C(param0, 1); } break; diff --git a/src/overlay035/ov35_022561C0.c b/src/overlay035/ov35_022561C0.c index b3e599352..6d34d630f 100644 --- a/src/overlay035/ov35_022561C0.c +++ b/src/overlay035/ov35_022561C0.c @@ -43,7 +43,7 @@ static BOOL ov35_022563DC(UnkStruct_ov35_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov35_022561D4, ov35_022562EC); + PoketchSystem_SetAppFunctions(ov35_022561D4, ov35_022562EC); } static BOOL ov35_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -128,7 +128,7 @@ static void ov35_022562B0 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov35_0225628C(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_14); + PoketchSystem_NotifyAppUnloaded(v1->unk_14); } } else { } @@ -159,7 +159,7 @@ static BOOL ov35_02256308 (UnkStruct_ov35_0225621C * param0) break; case 1: if (ov35_0225656C(param0->unk_10, 0)) { - ov25_0225424C(param0->unk_14); + PoketchSystem_NotifyAppLoaded(param0->unk_14); ov35_022562F4(param0, 1); } break; diff --git a/src/overlay036/ov36_022561C0.c b/src/overlay036/ov36_022561C0.c index 4f195982a..b23c9b69d 100644 --- a/src/overlay036/ov36_022561C0.c +++ b/src/overlay036/ov36_022561C0.c @@ -41,7 +41,7 @@ static BOOL ov36_022563D0(UnkStruct_ov36_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov36_022561D4, ov36_022562D4); + PoketchSystem_SetAppFunctions(ov36_022561D4, ov36_022562D4); } static BOOL ov36_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -124,7 +124,7 @@ static void ov36_02256298 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov36_02256280(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_10); + PoketchSystem_NotifyAppUnloaded(v1->unk_10); } } else { } @@ -155,7 +155,7 @@ static BOOL ov36_022562F0 (UnkStruct_ov36_0225621C * param0) break; case 1: if (ov36_02256560(param0->unk_0C, 0)) { - ov25_0225424C(param0->unk_10); + PoketchSystem_NotifyAppLoaded(param0->unk_10); ov36_022562DC(param0, 1); } break; diff --git a/src/overlay037/ov37_022561C0.c b/src/overlay037/ov37_022561C0.c index 683c00770..db279d795 100644 --- a/src/overlay037/ov37_022561C0.c +++ b/src/overlay037/ov37_022561C0.c @@ -42,7 +42,7 @@ static BOOL ov37_022563A0(UnkStruct_ov37_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov37_022561D4, ov37_022562DC); + PoketchSystem_SetAppFunctions(ov37_022561D4, ov37_022562DC); } static BOOL ov37_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -119,7 +119,7 @@ static void ov37_022562A0 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov37_02256280(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -150,7 +150,7 @@ static BOOL ov37_022562F8 (UnkStruct_ov37_0225621C * param0) break; case 1: if (ov37_022564AC(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov37_022562E4(param0, 1); } break; diff --git a/src/overlay038/ov38_022561C0.c b/src/overlay038/ov38_022561C0.c index f5d50cc99..49141f057 100644 --- a/src/overlay038/ov38_022561C0.c +++ b/src/overlay038/ov38_022561C0.c @@ -36,7 +36,7 @@ static BOOL ov38_022562F8(UnkStruct_ov38_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov38_022561D4, ov38_02256288); + PoketchSystem_SetAppFunctions(ov38_022561D4, ov38_02256288); } static BOOL ov38_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -91,7 +91,7 @@ static void ov38_02256254 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov38_02256240(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -122,7 +122,7 @@ static BOOL ov38_022562A4 (UnkStruct_ov38_0225621C * param0) break; case 1: if (ov38_0225638C(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov38_02256290(param0, 1); } break; diff --git a/src/overlay039/ov39_022561C0.c b/src/overlay039/ov39_022561C0.c index 57b191cf1..7465422d8 100644 --- a/src/overlay039/ov39_022561C0.c +++ b/src/overlay039/ov39_022561C0.c @@ -42,7 +42,7 @@ static BOOL ov39_022563A8(UnkStruct_ov39_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov39_022561D4, ov39_022562C8); + PoketchSystem_SetAppFunctions(ov39_022561D4, ov39_022562C8); } static BOOL ov39_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -127,7 +127,7 @@ static void ov39_0225628C (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov39_02256268(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_28); + PoketchSystem_NotifyAppUnloaded(v1->unk_28); } } else { } @@ -158,7 +158,7 @@ static BOOL ov39_022562E4 (UnkStruct_ov39_0225621C * param0) break; case 1: if (ov39_0225643C(param0->unk_24, 0)) { - ov25_0225424C(param0->unk_28); + PoketchSystem_NotifyAppLoaded(param0->unk_28); ov39_022562D0(param0, 1); } break; diff --git a/src/overlay040/ov40_022561C0.c b/src/overlay040/ov40_022561C0.c index 288093d7c..13ed16b9c 100644 --- a/src/overlay040/ov40_022561C0.c +++ b/src/overlay040/ov40_022561C0.c @@ -47,7 +47,7 @@ static void ov40_022563D0(UnkStruct_ov40_0225645C_1 * param0, UnkStruct_02026310 static void NitroStaticInit (void) { - ov25_02254238(ov40_022561D4, ov40_022562A4); + PoketchSystem_SetAppFunctions(ov40_022561D4, ov40_022562A4); } static BOOL ov40_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -106,7 +106,7 @@ static void ov40_02256270 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov40_0225625C(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_2C); + PoketchSystem_NotifyAppUnloaded(v1->unk_2C); } } else { } @@ -137,7 +137,7 @@ static BOOL ov40_022562C0 (UnkStruct_ov40_0225621C * param0) break; case 1: if (ov40_022565EC(param0->unk_28, 0)) { - ov25_0225424C(param0->unk_2C); + PoketchSystem_NotifyAppLoaded(param0->unk_2C); ov40_022562AC(param0, 1); } break; diff --git a/src/overlay041/ov41_022561C0.c b/src/overlay041/ov41_022561C0.c index a71730d0f..8f2fa746f 100644 --- a/src/overlay041/ov41_022561C0.c +++ b/src/overlay041/ov41_022561C0.c @@ -47,7 +47,7 @@ static void ov41_02256790(UnkStruct_ov41_022567B0_1 * param0); static void NitroStaticInit (void) { - ov25_02254238(ov41_022561D4, ov41_02256310); + PoketchSystem_SetAppFunctions(ov41_022561D4, ov41_02256310); } static BOOL ov41_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -122,7 +122,7 @@ static void ov41_022562B8 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov41_02256294(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_5B80); + PoketchSystem_NotifyAppUnloaded(v1->unk_5B80); } } else { } @@ -161,7 +161,7 @@ static BOOL ov41_0225632C (UnkStruct_ov41_02256220 * param0) break; case 1: if (ov41_022568B0(param0->unk_5B7C, 0)) { - ov25_0225424C(param0->unk_5B80); + PoketchSystem_NotifyAppLoaded(param0->unk_5B80); ov41_02256318(param0, 1); } break; diff --git a/src/overlay042/ov42_022561C0.c b/src/overlay042/ov42_022561C0.c index c5b9c44d8..41375ef52 100644 --- a/src/overlay042/ov42_022561C0.c +++ b/src/overlay042/ov42_022561C0.c @@ -40,7 +40,7 @@ static BOOL ov42_02256398(void); static void NitroStaticInit (void) { - ov25_02254238(ov42_022561D4, ov42_022562B4); + PoketchSystem_SetAppFunctions(ov42_022561D4, ov42_022562B4); } static BOOL ov42_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -101,7 +101,7 @@ static void ov42_02256280 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov42_02256260(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_10); + PoketchSystem_NotifyAppUnloaded(v1->unk_10); } } else { } @@ -132,7 +132,7 @@ static BOOL ov42_022562D0 (UnkStruct_ov42_0225621C * param0) break; case 1: if (ov42_022564C4(param0->unk_0C, 0)) { - ov25_0225424C(param0->unk_10); + PoketchSystem_NotifyAppLoaded(param0->unk_10); ov42_022562BC(param0, 1); } break; diff --git a/src/overlay043/ov43_022561C0.c b/src/overlay043/ov43_022561C0.c index 3770a99b7..ef99f6613 100644 --- a/src/overlay043/ov43_022561C0.c +++ b/src/overlay043/ov43_022561C0.c @@ -46,7 +46,7 @@ static u32 ov43_022564EC(s32 param0, s32 param1, BOOL param2); static void NitroStaticInit (void) { - ov25_02254238(ov43_022561D4, ov43_02256310); + PoketchSystem_SetAppFunctions(ov43_022561D4, ov43_02256310); } static BOOL ov43_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -131,7 +131,7 @@ static void ov43_022562CC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov43_022562A8(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_18); + PoketchSystem_NotifyAppUnloaded(v1->unk_18); } } else { } @@ -170,7 +170,7 @@ static BOOL ov43_0225632C (UnkStruct_ov43_0225621C * param0) break; case 1: if (ov43_022566D4(param0->unk_14, 0)) { - ov25_0225424C(param0->unk_18); + PoketchSystem_NotifyAppLoaded(param0->unk_18); ov43_02256318(param0, 1); } break; diff --git a/src/overlay044/ov44_022561C0.c b/src/overlay044/ov44_022561C0.c index 8f87f455d..291222251 100644 --- a/src/overlay044/ov44_022561C0.c +++ b/src/overlay044/ov44_022561C0.c @@ -52,7 +52,7 @@ static BOOL ov44_02256588(UnkStruct_ov44_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov44_022561D4, ov44_02256374); + PoketchSystem_SetAppFunctions(ov44_022561D4, ov44_02256374); } static BOOL ov44_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -149,7 +149,7 @@ static void ov44_02256338 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov44_02256314(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_3C); + PoketchSystem_NotifyAppUnloaded(v1->unk_3C); } } else { } @@ -180,7 +180,7 @@ static BOOL ov44_02256390 (UnkStruct_ov44_0225621C * param0) break; case 1: if (ov44_02256768(param0->unk_38, 0)) { - ov25_0225424C(param0->unk_3C); + PoketchSystem_NotifyAppLoaded(param0->unk_3C); ov44_0225637C(param0, 1); } break; diff --git a/src/overlay045/ov45_022561C0.c b/src/overlay045/ov45_022561C0.c index ca5909cd9..cf7d27fb4 100644 --- a/src/overlay045/ov45_022561C0.c +++ b/src/overlay045/ov45_022561C0.c @@ -55,7 +55,7 @@ static BOOL ov45_022566CC(UnkStruct_ov45_022566EC_1 * param0); static void NitroStaticInit (void) { - ov25_02254238(ov45_022561D4, ov45_02256354); + PoketchSystem_SetAppFunctions(ov45_022561D4, ov45_02256354); } static BOOL ov45_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -172,7 +172,7 @@ static void ov45_02256318 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov45_022562F8(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -203,7 +203,7 @@ static BOOL ov45_02256370 (UnkStruct_ov45_022561D4 * param0) break; case 1: if (ov45_0225693C(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); if (param0->unk_03.unk_00) { ov45_0225635C(param0, 2); diff --git a/src/overlay046/ov46_022561C0.c b/src/overlay046/ov46_022561C0.c index 2b4dcb7a3..33cad1c5a 100644 --- a/src/overlay046/ov46_022561C0.c +++ b/src/overlay046/ov46_022561C0.c @@ -87,7 +87,7 @@ static void ov46_02256B10(UnkStruct_ov46_0225621C * param0, u64 param1); static void NitroStaticInit (void) { - ov25_02254238(ov46_022561D4, ov46_02256458); + PoketchSystem_SetAppFunctions(ov46_022561D4, ov46_02256458); } static BOOL ov46_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -265,7 +265,7 @@ static void ov46_02256408 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov46_022563B8(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -328,7 +328,7 @@ static BOOL ov46_022564D8 (UnkStruct_ov46_0225621C * param0) break; case 1: if (ov46_02256D48(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov46_02256460(param0, param0->unk_48.unk_44); } break; diff --git a/src/overlay049/ov49_022561C0.c b/src/overlay049/ov49_022561C0.c index 382d4975f..b14dc6e99 100644 --- a/src/overlay049/ov49_022561C0.c +++ b/src/overlay049/ov49_022561C0.c @@ -41,7 +41,7 @@ static BOOL ov49_022563A0(UnkStruct_ov49_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov49_022561D4, ov49_022562A0); + PoketchSystem_SetAppFunctions(ov49_022561D4, ov49_022562A0); } static BOOL ov49_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -99,7 +99,7 @@ static void ov49_0225626C (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov49_02256258(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -130,7 +130,7 @@ static BOOL ov49_022562BC (UnkStruct_ov49_0225621C * param0) break; case 1: if (ov49_022564B8(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov49_022562A8(param0, 1); } break; diff --git a/src/overlay050/ov50_022561C0.c b/src/overlay050/ov50_022561C0.c index 9c2cde18c..db2423c86 100644 --- a/src/overlay050/ov50_022561C0.c +++ b/src/overlay050/ov50_022561C0.c @@ -48,7 +48,7 @@ static BOOL ov50_022564D8(UnkStruct_ov50_022561D4 * param0); static void NitroStaticInit (void) { - ov25_02254238(ov50_022561D4, ov50_022563B0); + PoketchSystem_SetAppFunctions(ov50_022561D4, ov50_022563B0); } static BOOL ov50_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -195,7 +195,7 @@ static void ov50_0225636C (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov50_02256340(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_94); + PoketchSystem_NotifyAppUnloaded(v1->unk_94); } } else { } @@ -226,7 +226,7 @@ static BOOL ov50_022563CC (UnkStruct_ov50_022561D4 * param0) break; case 1: if (ov50_02256620(param0->unk_90, 0)) { - ov25_0225424C(param0->unk_94); + PoketchSystem_NotifyAppLoaded(param0->unk_94); ov50_022563B8(param0, 1); } break; diff --git a/src/overlay051/ov51_022561C0.c b/src/overlay051/ov51_022561C0.c index ed8cde9b1..b4ec7fd76 100644 --- a/src/overlay051/ov51_022561C0.c +++ b/src/overlay051/ov51_022561C0.c @@ -36,7 +36,7 @@ static BOOL ov51_022562F8(UnkStruct_ov51_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov51_022561D4, ov51_02256288); + PoketchSystem_SetAppFunctions(ov51_022561D4, ov51_02256288); } static BOOL ov51_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -91,7 +91,7 @@ static void ov51_02256254 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov51_02256240(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -122,7 +122,7 @@ static BOOL ov51_022562A4 (UnkStruct_ov51_0225621C * param0) break; case 1: if (ov51_0225638C(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov51_02256290(param0, 1); } break; diff --git a/src/overlay053/ov53_022561C0.c b/src/overlay053/ov53_022561C0.c index 674babbcd..c45f4b2a1 100644 --- a/src/overlay053/ov53_022561C0.c +++ b/src/overlay053/ov53_022561C0.c @@ -44,7 +44,7 @@ static BOOL ov53_022563EC(UnkStruct_ov53_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov53_022561D4, ov53_0225630C); + PoketchSystem_SetAppFunctions(ov53_022561D4, ov53_0225630C); } static BOOL ov53_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -145,7 +145,7 @@ static void ov53_022562D0 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov53_022562B8(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_30); + PoketchSystem_NotifyAppUnloaded(v1->unk_30); } } else { } @@ -184,7 +184,7 @@ static BOOL ov53_02256330 (UnkStruct_ov53_0225621C * param0) break; case 1: if (ov53_02256484(param0->unk_2C, 0)) { - ov25_0225424C(param0->unk_30); + PoketchSystem_NotifyAppLoaded(param0->unk_30); ov53_0225631C(param0, 1); } break; diff --git a/src/overlay054/ov54_022561C0.c b/src/overlay054/ov54_022561C0.c index 6c8e7d946..983d52dd4 100644 --- a/src/overlay054/ov54_022561C0.c +++ b/src/overlay054/ov54_022561C0.c @@ -43,7 +43,7 @@ static BOOL ov54_022563F4(UnkStruct_ov54_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov54_022561D4, ov54_02256338); + PoketchSystem_SetAppFunctions(ov54_022561D4, ov54_02256338); } static BOOL ov54_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -190,7 +190,7 @@ static void ov54_022562F4 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov54_022562D4(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_9C); + PoketchSystem_NotifyAppUnloaded(v1->unk_9C); } } else { } @@ -229,7 +229,7 @@ static BOOL ov54_02256360 (UnkStruct_ov54_0225621C * param0) break; case 1: if (ov54_02256490(param0->unk_98, 0)) { - ov25_0225424C(param0->unk_9C); + PoketchSystem_NotifyAppLoaded(param0->unk_9C); ov54_0225634C(param0, 1); } break; diff --git a/src/overlay055/ov55_022561C0.c b/src/overlay055/ov55_022561C0.c index 6e0b14814..f7a7bfd40 100644 --- a/src/overlay055/ov55_022561C0.c +++ b/src/overlay055/ov55_022561C0.c @@ -36,7 +36,7 @@ static BOOL ov55_022562F8(UnkStruct_ov55_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov55_022561D4, ov55_02256288); + PoketchSystem_SetAppFunctions(ov55_022561D4, ov55_02256288); } static BOOL ov55_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -92,7 +92,7 @@ static void ov55_02256254 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov55_02256240(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_0C); + PoketchSystem_NotifyAppUnloaded(v1->unk_0C); } } else { } @@ -123,7 +123,7 @@ static BOOL ov55_022562A4 (UnkStruct_ov55_0225621C * param0) break; case 1: if (ov55_0225639C(param0->unk_08, 0)) { - ov25_0225424C(param0->unk_0C); + PoketchSystem_NotifyAppLoaded(param0->unk_0C); ov55_02256290(param0, 1); } break; From 49b8b9f244443d70db65369c3ecc62490a3e9744 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:12 -0700 Subject: [PATCH 03/25] Documented most of the static functions in poketch_system.c --- include/overlay025/poketch_system.h | 53 +++++-- src/overlay005/ov5_021EA714.c | 2 +- src/overlay025/poketch_system.c | 220 ++++++++++++++-------------- 3 files changed, 153 insertions(+), 122 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 40d1b2e35..675edc954 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -13,11 +13,27 @@ #include +#define POKETCH_PEDOMETER_MAX 99999 + enum ButtonDir { BUTTON_UP, BUTTON_DOWN, }; +enum PoketchMainButton { + POKETCHSYSTEM_MAINBUTTON_UP, + // POKETCHSYSTEM_MAINBUTTON_DOWN, + POKETCHSYSTEM_MAINBUTTON_SCREEN = 2, +}; + +enum PoketchSystemState { + POKETCHSYSTEM_INIT, + POKETCHSYSTEM_UPDATE, + POKETCHSYSTEM_CHANGEAPP, + POKETCHSYSTEM_SHUTDOWN, + POKETCHSYSTEM_UNLOAD +}; + enum PoketchAppState { POKETCH_APP_STATE_NONE, POKETCH_APP_STATE_INIT, @@ -30,6 +46,18 @@ enum PoketchBorderColor { POKETCH_BORDER_BLUE }; +enum PoketchFieldEventID { + POKETCH_FIELDEVENT_SLEEP = 0, + POKETCH_FIELDEVENT_PLAYERMOVED, + + POKETCH_FIELDEVENT_SAVE = 4, + POKETCH_FIELDEVENT_PEDOMETER, +}; + +enum PoketchScreenCoordinates { + +}; + typedef struct PoketchSystem PoketchSystem; typedef BOOL (* PoketchAppInitFunction)(void **, PoketchSystem *, BGL *, u32); @@ -37,11 +65,11 @@ typedef void (* PoketchAppShutdownFunction)(void *); typedef void (* PoketchAppSaveFunction)(void *); struct PoketchSystem { - u8 unk_00; - u8 unk_01; + u8 systemState; + u8 subState; // each systemState has its own sub-state machine, they all share this variable u8 appState; - u8 unk_03; - u8 unk_04; + u8 touchingScreen; + u8 playerMoved; u8 unk_05; u8 unk_06; u8 pedometerUpdated; @@ -58,23 +86,26 @@ struct PoketchSystem { u32 unk_30; PoketchSystem ** poketchSysPtr; SysTask * unk_38; + PoketchAppInitFunction currAppInit; PoketchAppShutdownFunction currAppShutdown; PoketchAppSaveFunction currAppSave; - void * unk_48; + void * appSaveData; + BGL *bgl; - NNSG2dOamManagerInstance * unk_50; + NNSG2dOamManagerInstance * oamManager; + SaveData *saveData; PoketchData *poketchData; FieldSystem *fieldSys; enum ButtonDir buttonDir; }; -void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager); -void ov25_02253D5C(PoketchSystem *poketchSys); -BOOL ov25_02253D70(PoketchSystem *poketchSys); -void ov25_02253D7C(PoketchSystem *poketchSys, int param1, u32 param2); -BOOL ov25_02253DD4(PoketchSystem *poketchSys); +void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager); +void PoketchSystem_StartShutdown(PoketchSystem *poketchSys); +BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys); +void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32); +BOOL PoketchSystem_CheckTouch(PoketchSystem *poketchSys); enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys); void PoketchSystem_SetAppFunctions(PoketchAppInitFunction param0, PoketchAppShutdownFunction param1); void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); diff --git a/src/overlay005/ov5_021EA714.c b/src/overlay005/ov5_021EA714.c index e624adb57..2cfb2abea 100644 --- a/src/overlay005/ov5_021EA714.c +++ b/src/overlay005/ov5_021EA714.c @@ -19,7 +19,7 @@ FS_EXTERN_OVERLAY(overlay25); void ov5_021EA714 (FieldSystem * fieldSystem, int param1, u32 param2) { if ((fieldSystem->unk_04 != NULL) && (fieldSystem->unk_04->unk_14 != NULL)) { - ov25_02253D7C(fieldSystem->unk_04->unk_14, param1, param2); + PoketchSystem_SendFieldEvent(fieldSystem->unk_04->unk_14, param1, param2); } } diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 2c4c416b9..ba56463f0 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -61,22 +61,22 @@ static PoketchSystem *PoketchSystem_GetFromFieldSystem(void); static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys); static void PoketchSystem_Shutdown(PoketchSystem *poketchSys); static void PoketchSystem_MainTask(SysTask *param0, void * param1); -static void ov25_02253E94(SysTask *param0, void * param1); -static void ov25_02253E9C(PoketchSystem *poketchSys, u32 param1); +static void PoketchSystem_PostRender(SysTask *param0, void * param1); +static void PoketchSystem_SetState(PoketchSystem *poketchSys, u32 param1); static void PoketchEvent_InitApp(PoketchSystem *poketchSys); static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys); static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys); static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys); static void PoketchSystem_LoadApp(PoketchSystem *poketchSys, int param1); static void PoketchSystem_UnloadApp(PoketchSystem *poketchSys); -static void ov25_022541D8(PoketchSystem *poketchSys, u32 param1); -static BOOL ov25_022541FC(PoketchSystem *poketchSys); -static void ov25_0225420C(PoketchSystem *poketchSys); -static BOOL ov25_02254228(PoketchSystem *poketchSys); +static void PoketchSystem_InitApp(PoketchSystem *poketchSys, u32 param1); +static BOOL PoketchSystem_IsAppInitialized(PoketchSystem *poketchSys); +static void PoketchSystem_ShutdownApp(PoketchSystem *poketchSys); +static BOOL PoketchSystem_IsAppShutdown(PoketchSystem *poketchSys); static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys); static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); -static void ov25_022542E4(u32 param0, u32 param1, u32 param2, void * param3); +static void ov25_022542E4(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); static inline BOOL inline_ov25_0225446C(u32 param0, u32 param1); @@ -112,7 +112,7 @@ static const struct { {POKETCH_APPID_POKEMONHISTORY, FS_OVERLAY_ID(overlay54)} }; -static PoketchSystem *PoketchSystem_GetFromFieldSystem(void) +static PoketchSystem* PoketchSystem_GetFromFieldSystem(void) { return FieldSystem_PoketchSystem(); } @@ -132,44 +132,44 @@ void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, new_system->saveData = saveData; new_system->poketchData = SaveData_PoketchData(saveData); new_system->bgl = bgl; - new_system->unk_50 = oamManager; + new_system->oamManager = oamManager; if (PoketchSystem_InitInternal(new_system)) { sub_0201E3D8(); sub_0201E450(4); new_system->poketchSysPtr = poketchSys; - new_system->unk_38 = SysTask_Start(ov25_02253E94, new_system, 4); + new_system->unk_38 = SysTask_Start(PoketchSystem_PostRender, new_system, 4); SysTask_Start(PoketchSystem_MainTask, new_system, 0); } } } -void ov25_02253D5C (PoketchSystem *poketchSys) +void PoketchSystem_StartShutdown (PoketchSystem *poketchSys) { - if ((poketchSys->unk_00 != 3) && (poketchSys->unk_00 != 4)) { - ov25_02253E9C(poketchSys, 3); + if ((poketchSys->systemState != POKETCHSYSTEM_SHUTDOWN) && (poketchSys->systemState != POKETCHSYSTEM_UNLOAD)) { + PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_SHUTDOWN); } } -BOOL ov25_02253D70 (PoketchSystem *poketchSys) +BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys) { return poketchSys == NULL; } -void ov25_02253D7C (PoketchSystem *poketchSys, int param1, u32 param2) +void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32) { - switch (param1) { - case 0: + switch (eventID) { + case POKETCH_FIELDEVENT_SLEEP: break; - case 1: - poketchSys->unk_04 = 1; + case POKETCH_FIELDEVENT_PLAYERMOVED: + poketchSys->playerMoved = TRUE; break; - case 5:{ + case POKETCH_FIELDEVENT_PEDOMETER:{ u32 step_count = PoketchData_StepCount(poketchSys->poketchData); - if (++step_count > 99999) { + if (++step_count > POKETCH_PEDOMETER_MAX) { step_count = 0; } @@ -177,19 +177,19 @@ void ov25_02253D7C (PoketchSystem *poketchSys, int param1, u32 param2) poketchSys->pedometerUpdated = TRUE; } break; - case 4: + case POKETCH_FIELDEVENT_SAVE: if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { if (poketchSys->currAppSave) { - poketchSys->currAppSave(poketchSys->unk_48); + poketchSys->currAppSave(poketchSys->appSaveData); } } break; } } -BOOL ov25_02253DD4 (PoketchSystem *poketchSys) +BOOL PoketchSystem_CheckTouch(PoketchSystem *poketchSys) { - return poketchSys->unk_03; + return poketchSys->touchingScreen; } enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys) @@ -199,11 +199,11 @@ enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys) static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) { - if (ov25_02254560(&(poketchSys->unk_1C), &(poketchSys->unk_20), poketchSys->unk_50, poketchSys)) { - poketchSys->unk_00 = 0; - poketchSys->unk_01 = 0; - poketchSys->unk_03 = 0; - poketchSys->unk_04 = 0; + if (ov25_02254560(&(poketchSys->unk_1C), &(poketchSys->unk_20), poketchSys->oamManager, poketchSys)) { + poketchSys->systemState = POKETCHSYSTEM_INIT; + poketchSys->subState = 0; + poketchSys->touchingScreen = FALSE; + poketchSys->playerMoved = 0; poketchSys->pedometerUpdated = FALSE; poketchSys->unk_05 = 0; poketchSys->unk_06 = 0; @@ -241,72 +241,72 @@ static void PoketchSystem_MainTask(SysTask *task, void *system) { PoketchSystem *poketchSys = (PoketchSystem *)system; - if (poketchSys->unk_00 < NELEMS(sPoketchEvents)) { - if (poketchSys->unk_00 != 0) { + if (poketchSys->systemState < NELEMS(sPoketchEvents)) { + if (poketchSys->systemState != POKETCHSYSTEM_INIT) { PoketchSystem_ButtonUpdate(poketchSys); } - sPoketchEvents[poketchSys->unk_00](poketchSys); + sPoketchEvents[poketchSys->systemState](poketchSys); } else { - GF_ASSERT(poketchSys->unk_00 == 4); + GF_ASSERT(poketchSys->systemState == POKETCHSYSTEM_UNLOAD); *(poketchSys->poketchSysPtr) = NULL; PoketchSystem_Shutdown(poketchSys); Heap_FreeToHeap(poketchSys); SysTask_Done(task); - Heap_Destroy(7); - Heap_Destroy(8); + Heap_Destroy(HEAP_ID_POKETCH_MAIN); + Heap_Destroy(HEAP_ID_POKETCH_APP); } } -static void ov25_02253E94 (SysTask * param0, void * param1) +static void PoketchSystem_PostRender(SysTask *, void *system) { - PoketchSystem *poketchSys = param1; + PoketchSystem *poketchSys = system; - poketchSys->unk_04 = 0; + poketchSys->playerMoved = FALSE; poketchSys->pedometerUpdated = FALSE; } -static void ov25_02253E9C (PoketchSystem *poketchSys, u32 param1) +static void PoketchSystem_SetState(PoketchSystem *poketchSys, u32 state) { - poketchSys->unk_00 = param1; - poketchSys->unk_01 = 0; + poketchSys->systemState = state; + poketchSys->subState = 0; } static void PoketchEvent_InitApp(PoketchSystem *poketchSys) { - switch (poketchSys->unk_01) { + switch (poketchSys->subState) { case 0: ov25_022547D0(poketchSys->unk_1C, 0); - poketchSys->unk_01++; + poketchSys->subState++; break; case 1: if (ov25_022547F4(poketchSys->unk_1C, 0)) { u32 app_ID = PoketchData_CurrentAppID(poketchSys->poketchData); PoketchSystem_LoadApp(poketchSys, app_ID); - ov25_022541D8(poketchSys, app_ID); + PoketchSystem_InitApp(poketchSys, app_ID); - poketchSys->unk_01++; + poketchSys->subState++; } break; case 2: - if (ov25_022541FC(poketchSys) == 0) { + if (PoketchSystem_IsAppInitialized(poketchSys) == FALSE) { break; } ov25_022547D0(poketchSys->unk_1C, 1); - poketchSys->unk_01++; + poketchSys->subState++; case 3: if (ov25_022547F4(poketchSys->unk_1C, 1)) { - ov25_02253E9C(poketchSys, 1); + PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UPDATE); } } } static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) { - switch (poketchSys->unk_01) { + switch (poketchSys->subState) { case 0: if (ov25_0225450C(poketchSys)) { return; @@ -318,7 +318,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) poketchSys->unk_0C = 0; poketchSys->unk_05 = 1; ov25_022547D0(poketchSys->unk_1C, 4); - poketchSys->unk_01++; + poketchSys->subState++; break; } break; @@ -338,10 +338,10 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) ov25_022547D0(poketchSys->unk_1C, 12); poketchSys->unk_10 = 30; poketchSys->unk_0C = 0; - poketchSys->unk_01 = 4; + poketchSys->subState = 4; } else { poketchSys->unk_10 = 3; - poketchSys->unk_01 = 2; + poketchSys->subState = 2; } } break; @@ -350,22 +350,22 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) ov25_022547D0(poketchSys->unk_1C, 12); poketchSys->unk_10 = 30; poketchSys->unk_0C = 0; - poketchSys->unk_01 = 4; + poketchSys->subState = 4; break; } if (poketchSys->unk_10) { poketchSys->unk_10--; } else { - ov25_0225420C(poketchSys); - poketchSys->unk_01 = 3; + PoketchSystem_ShutdownApp(poketchSys); + poketchSys->subState = 3; } break; case 3: if (PoketchSystem_IsAppShutdown(poketchSys)) { PoketchSystem_UnloadApp(poketchSys); sub_02099D44(); - ov25_02253E9C(poketchSys, 2); + PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_CHANGEAPP); } break; case 4: @@ -385,8 +385,8 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) poketchSys->unk_10--; } else { ov25_022547D0(poketchSys->unk_1C, 14); - ov25_0225420C(poketchSys); - poketchSys->unk_01 = 3; + PoketchSystem_ShutdownApp(poketchSys); + poketchSys->subState = 3; } break; } @@ -394,7 +394,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) { - switch (poketchSys->unk_01) { + switch (poketchSys->subState) { case 0: { u32 v0; @@ -403,22 +403,22 @@ static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) v0 = PoketchData_CurrentAppID(poketchSys->poketchData); PoketchSystem_LoadApp(poketchSys, v0); - ov25_022541D8(poketchSys, v0); + PoketchSystem_InitApp(poketchSys, v0); - poketchSys->unk_01++; + poketchSys->subState++; } break; case 1: - if (ov25_022541FC(poketchSys)) { + if (PoketchSystem_IsAppInitialized(poketchSys)) { ov25_022547D0(poketchSys->unk_1C, 2); - poketchSys->unk_01++; + poketchSys->subState++; } break; case 2: if (ov25_022547F4(poketchSys->unk_1C, 2)) { poketchSys->unk_05 = 0; poketchSys->unk_06 = 0; - ov25_02253E9C(poketchSys, 1); + PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UPDATE); } break; } @@ -426,39 +426,39 @@ static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys) { - switch (poketchSys->unk_01) { + switch (poketchSys->subState) { case 0: switch (poketchSys->appState) { case 1: - poketchSys->unk_01 = 1; + poketchSys->subState = 1; break; case 2: - ov25_0225420C(poketchSys); - poketchSys->unk_01 = 2; + PoketchSystem_ShutdownApp(poketchSys); + poketchSys->subState = 2; break; case 3: case 0: - poketchSys->unk_01 = 2; + poketchSys->subState = 2; break; } break; case 1: - if (ov25_022541FC(poketchSys)) { - ov25_0225420C(poketchSys); - poketchSys->unk_01 = 2; + if (PoketchSystem_IsAppInitialized(poketchSys)) { + PoketchSystem_ShutdownApp(poketchSys); + poketchSys->subState = 2; } break; case 2: if (PoketchSystem_IsAppShutdown(poketchSys)) { ov25_022547D0(poketchSys->unk_1C, 17); - poketchSys->unk_01 = 3; + poketchSys->subState = 3; } break; case 3: if (ov25_02254800(poketchSys->unk_1C)) { PoketchSystem_UnloadApp(poketchSys); sub_0201E530(); - ov25_02253E9C(poketchSys, 4); + PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UNLOAD); } break; } @@ -489,7 +489,7 @@ static void PoketchSystem_UnloadApp(PoketchSystem *poketchSys) } } -static void ov25_022541D8 (PoketchSystem *poketchSys, u32 param1) +static void PoketchSystem_InitApp(PoketchSystem *poketchSys, u32) { GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_NONE); @@ -497,16 +497,16 @@ static void ov25_022541D8 (PoketchSystem *poketchSys, u32 param1) poketchSys->appState = POKETCH_APP_STATE_INIT; } -static BOOL ov25_022541FC (PoketchSystem *poketchSys) +static BOOL PoketchSystem_IsAppInitialized(PoketchSystem *poketchSys) { if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { - return 1; + return TRUE; } - return 0; + return FALSE; } -static void ov25_0225420C (PoketchSystem *poketchSys) +static void PoketchSystem_ShutdownApp(PoketchSystem *poketchSys) { GF_ASSERT(poketchSys->appState == POKETCH_APP_STATE_UPDATE); @@ -544,12 +544,12 @@ void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys) poketchSys->appState = POKETCH_APP_STATE_NONE; } -void ov25_02254274 (PoketchAppSaveFunction param0, void * param1) +void ov25_02254274 (PoketchAppSaveFunction saveFunction, void * saveData) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - poketchSys->currAppSave = param0; - poketchSys->unk_48 = param1; + poketchSys->currAppSave = saveFunction; + poketchSys->appSaveData = saveData; } static const TouchScreenHitTable sMainPoketchButtons[] = { @@ -583,42 +583,42 @@ static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys) PoketchButtonManager_Update(poketchSys->buttonManager); } -static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) +static void ov25_022542E4 (u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system) { - PoketchSystem * poketchSys = (PoketchSystem *)param3; + PoketchSystem * poketchSys = (PoketchSystem *)system; - if (ov25_0225450C(poketchSys) == 0) { - switch (param2) { - case 1: - poketchSys->unk_03 = 1; + if (ov25_0225450C(poketchSys) == FALSE) { + switch (touchEvent) { + case BUTTON_TOUCH_RELEASED: + poketchSys->touchingScreen = TRUE; break; - case 0: - poketchSys->unk_03 = 0; + case BUTTON_TOUCH_PRESSED: + poketchSys->touchingScreen = FALSE; break; } } else { - poketchSys->unk_03 = 0; + poketchSys->touchingScreen = FALSE; } - if (param0 == 2) { + if (buttonID == POKETCHSYSTEM_MAINBUTTON_SCREEN) { if (ov25_0225450C(poketchSys)) { - if (param2 == 1) { + if (touchEvent == BUTTON_TOUCH_RELEASED) { Sound_PlayEffect(1646); } } } else { u32 v1 = 0xffffffff; - switch (param2) { - case 0: - v1 = (param0 == 0) ? 8 : 11; + switch (touchEvent) { + case BUTTON_TOUCH_PRESSED: + v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 8 : 11; break; - case 1: + case BUTTON_TOUCH_RELEASED: if (ov25_0225450C(poketchSys) || poketchSys->unk_06) { - v1 = (param0 == 0) ? 6 : 9; - param1 = 0; + v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 6 : 9; + buttonEvent = 0; } else { - v1 = (param0 == 0) ? 7 : 10; + v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 7 : 10; } break; } @@ -638,24 +638,24 @@ static void ov25_022542E4 (u32 param0, u32 param1, u32 param2, void * param3) } } - switch (param1) { - case 5: + switch (buttonEvent) { + case BUTTON_MANAGER_STATE_TIMER0: PoketchButtonManager_ResetButtonState(poketchSys->buttonManager, 0); break; - case 3: + case BUTTON_MANAGER_STATE_TAP: if ((poketchSys->unk_30 == 6) || (poketchSys->unk_30 == 9)) { - param1 = 0; + buttonEvent = BUTTON_MANAGER_STATE_NULL; } break; - case 2: + case BUTTON_MANAGER_STATE_OUT: if ((poketchSys->unk_30 == 7) || (poketchSys->unk_30 == 10)) { - param1 = 3; + buttonEvent = BUTTON_MANAGER_STATE_TAP; } break; } - poketchSys->buttonState = param1; - poketchSys->buttonDir = (param0 == 0) ? BUTTON_UP : BUTTON_DOWN; + poketchSys->buttonState = buttonEvent; + poketchSys->buttonDir = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? BUTTON_UP : BUTTON_DOWN; } } @@ -747,7 +747,7 @@ void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *butto BOOL ov25_02254534 (const PoketchSystem *poketchSys) { - return poketchSys->unk_04; + return poketchSys->playerMoved; } BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys) From e56149fddc0d4e7a7b286e4e432c7db81f2737b1 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:12 -0700 Subject: [PATCH 04/25] Some Poketch System button functions --- include/overlay025/poketch_button.h | 2 +- include/overlay025/poketch_system.h | 13 ++++++---- include/touch_screen.h | 4 +-- src/overlay019/ov19_021D603C.c | 2 +- src/overlay025/poketch_button.c | 2 +- src/overlay025/poketch_system.c | 40 ++++++++++++++--------------- src/overlay029/ov29_022561C0.c | 4 +-- src/overlay031/ov31_022561C0.c | 4 +-- src/overlay032/ov32_022561C0.c | 2 +- src/overlay033/ov33_022561C0.c | 2 +- src/overlay034/ov34_022561C0.c | 2 +- src/overlay040/ov40_022561C0.c | 2 +- src/overlay041/ov41_022561C0.c | 4 +-- src/overlay042/ov42_022561C0.c | 2 +- src/overlay049/ov49_022561C0.c | 2 +- src/overlay056/ov56_022561C0.c | 2 +- src/overlay062/ov62_02231690.c | 4 +-- src/overlay076/ov76_0223B140.c | 2 +- src/overlay076/ov76_0223D338.c | 2 +- src/overlay111/ov111_021D0D80.c | 2 +- src/overlay116/ov116_02262A8C.c | 2 +- src/touch_screen.c | 20 +++++++-------- 22 files changed, 62 insertions(+), 59 deletions(-) diff --git a/include/overlay025/poketch_button.h b/include/overlay025/poketch_button.h index a63f11cc6..875cb8ea1 100644 --- a/include/overlay025/poketch_button.h +++ b/include/overlay025/poketch_button.h @@ -11,7 +11,7 @@ typedef void (* PoketchButtonCallback)(u32, u32, u32, void *); enum ButtonManagerState { BUTTON_MANAGER_STATE_NULL = 0, BUTTON_MANAGER_STATE_TOUCH, - BUTTON_MANAGER_STATE_OUT, + BUTTON_MANAGER_STATE_SLIDEOUT, // Slid touch off of button but did not release BUTTON_MANAGER_STATE_TAP, BUTTON_MANAGER_STATE_DOUBLETAP, BUTTON_MANAGER_STATE_TIMER0, diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 675edc954..15990a84d 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -55,7 +55,10 @@ enum PoketchFieldEventID { }; enum PoketchScreenCoordinates { - + POKETCH_SCREEN_MINX = 16, + POKETCH_SCREEN_MINY = 16, + POKETCH_SCREEN_MAXX = 207, + POKETCH_SCREEN_MAXY = 175, }; typedef struct PoketchSystem PoketchSystem; @@ -107,15 +110,15 @@ BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys); void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32); BOOL PoketchSystem_CheckTouch(PoketchSystem *poketchSys); enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys); -void PoketchSystem_SetAppFunctions(PoketchAppInitFunction param0, PoketchAppShutdownFunction param1); +void PoketchSystem_SetAppFunctions(PoketchAppInitFunction initFunction, PoketchAppShutdownFunction shutdownFunction); void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys); -void ov25_02254274(PoketchAppSaveFunction param0, void * param1); +void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *saveData); UnkStruct_ov25_02254560 * ov25_02254418(void); void ov25_02254424(u32 param0); void ov25_02254444(u32 param0, u32 param1); -BOOL ov25_0225446C(u32 * param0, u32 * param1); -BOOL ov25_022544BC(u32 * param0, u32 * param1); +BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y); +BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y); BOOL ov25_0225450C(const PoketchSystem *poketchSys); void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager * param1); BOOL ov25_02254534(const PoketchSystem *poketchSys); diff --git a/include/touch_screen.h b/include/touch_screen.h index d13ca1386..85e036d5a 100644 --- a/include/touch_screen.h +++ b/include/touch_screen.h @@ -39,8 +39,8 @@ BOOL TouchScreen_Touched(void); * @return TRUE if the touch screen is tapped, FALSE otherwise. */ BOOL TouchScreen_Tapped(void); -BOOL sub_020227A4(u32 * param0, u32 * param1); -BOOL sub_020227C0(u32 * param0, u32 * param1); +BOOL TouchScreen_TouchLocation(u32 *x, u32 *y); +BOOL TouchScreen_TapLocation(u32 *x, u32 *y); int sub_020227DC(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); BOOL sub_02022830(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); diff --git a/src/overlay019/ov19_021D603C.c b/src/overlay019/ov19_021D603C.c index cc970a4c9..0a64cfbbb 100644 --- a/src/overlay019/ov19_021D603C.c +++ b/src/overlay019/ov19_021D603C.c @@ -48,7 +48,7 @@ int ov19_021D60A8 (UnkStruct_ov19_021D6104 * param0) v0 = 1; v1 = (param0->unk_1C == 0); - if (sub_020227A4(&v2, &v3)) { + if (TouchScreen_TouchLocation(&v2, &v3)) { param0->unk_14 = v2; param0->unk_18 = v3; } diff --git a/src/overlay025/poketch_button.c b/src/overlay025/poketch_button.c index 67ed54b3c..5bae7b8ed 100644 --- a/src/overlay025/poketch_button.c +++ b/src/overlay025/poketch_button.c @@ -205,7 +205,7 @@ static u32 Button_OnPressed(PoketchButton *button, BOOL touched, BOOL tapped) } } else if (touched) { PoketchButton_ChangeState(button, BUTTON_STATE_IDLE); - return BUTTON_MANAGER_STATE_OUT; + return BUTTON_MANAGER_STATE_SLIDEOUT; } else { // We don't reset the timer because we want to check for double tap with the same timer if (button->doubleTapTime) { diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index ba56463f0..c9c95daff 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -76,9 +76,9 @@ static BOOL PoketchSystem_IsAppShutdown(PoketchSystem *poketchSys); static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys); static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); -static void ov25_022542E4(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); +static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); -static inline BOOL inline_ov25_0225446C(u32 param0, u32 param1); +static inline BOOL PoketchSystem_InsideScreenBounds(u32 param0, u32 param1); // the order of this array determines the app order in the poketch. static const struct { @@ -313,8 +313,8 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) } switch (poketchSys->buttonState) { - case 3: - case 5: + case BUTTON_MANAGER_STATE_TAP: + case BUTTON_MANAGER_STATE_TIMER0: poketchSys->unk_0C = 0; poketchSys->unk_05 = 1; ov25_022547D0(poketchSys->unk_1C, 4); @@ -544,7 +544,7 @@ void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys) poketchSys->appState = POKETCH_APP_STATE_NONE; } -void ov25_02254274 (PoketchAppSaveFunction saveFunction, void * saveData) +void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *saveData) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); @@ -560,7 +560,7 @@ static const TouchScreenHitTable sMainPoketchButtons[] = { static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) { - poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), ov25_022542E4, poketchSys, 7); + poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), PoketchSystem_OnButtonEvent, poketchSys, 7); if (poketchSys->buttonManager != NULL) { PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, 0, 0, 7); @@ -583,9 +583,9 @@ static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys) PoketchButtonManager_Update(poketchSys->buttonManager); } -static void ov25_022542E4 (u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system) +static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system) { - PoketchSystem * poketchSys = (PoketchSystem *)system; + PoketchSystem *poketchSys = (PoketchSystem *)system; if (ov25_0225450C(poketchSys) == FALSE) { switch (touchEvent) { @@ -647,7 +647,7 @@ static void ov25_022542E4 (u32 buttonID, u32 buttonEvent, u32 touchEvent, void * buttonEvent = BUTTON_MANAGER_STATE_NULL; } break; - case BUTTON_MANAGER_STATE_OUT: + case BUTTON_MANAGER_STATE_SLIDEOUT: if ((poketchSys->unk_30 == 7) || (poketchSys->unk_30 == 10)) { buttonEvent = BUTTON_MANAGER_STATE_TAP; } @@ -698,39 +698,39 @@ void ov25_02254444 (u32 param0, u32 param1) } } -static inline BOOL inline_ov25_0225446C (u32 param0, u32 param1) +static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y) { - if (((u32)(param0 - 16) < (u32)(207 - 16)) & ((u32)(param1 - 16) < (u32)(175 - 16))) { + if (((u32)(x - POKETCH_SCREEN_MINX) < (u32)(POKETCH_SCREEN_MAXX - POKETCH_SCREEN_MINX)) & ((u32)(y - POKETCH_SCREEN_MINY) < (u32)(POKETCH_SCREEN_MAXY - POKETCH_SCREEN_MINY))) { return TRUE; } return FALSE; } -BOOL ov25_0225446C (u32 * param0, u32 * param1) +BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { - if (sub_020227A4(param0, param1)) { - return inline_ov25_0225446C(*param0, *param1); + if (TouchScreen_TouchLocation(x, y)) { + return PoketchSystem_InsideScreenBounds(*x, *y); } } - return 0; + return FALSE; } -BOOL ov25_022544BC (u32 * param0, u32 * param1) +BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { - if (sub_020227C0(param0, param1)) { - return inline_ov25_0225446C(*param0, *param1); + if (TouchScreen_TapLocation(x, y)) { + return PoketchSystem_InsideScreenBounds(*x, *y); } } - return 0; + return FALSE; } BOOL ov25_0225450C (const PoketchSystem *poketchSys) @@ -770,7 +770,7 @@ SaveData* PoketchSystem_SaveData(const PoketchSystem *poketchSys) return poketchSys->saveData; } -int PoketchSystem_BorderColor (const PoketchSystem *poketchSys) +int PoketchSystem_BorderColor(const PoketchSystem *poketchSys) { TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(poketchSys->saveData); diff --git a/src/overlay029/ov29_022561C0.c b/src/overlay029/ov29_022561C0.c index 460a5305b..e34ef4b0f 100644 --- a/src/overlay029/ov29_022561C0.c +++ b/src/overlay029/ov29_022561C0.c @@ -208,7 +208,7 @@ static BOOL ov29_02256404 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -228,7 +228,7 @@ static BOOL ov29_02256460 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay031/ov31_022561C0.c b/src/overlay031/ov31_022561C0.c index 87c28a1ae..5a2ba37d9 100644 --- a/src/overlay031/ov31_022561C0.c +++ b/src/overlay031/ov31_022561C0.c @@ -61,7 +61,7 @@ static BOOL ov31_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, if (ov31_02256228(v0, param1, param2, param3)) { if (SysTask_Start(ov31_022563CC, v0, 1) != NULL) { *param0 = v0; - ov25_02254274(ov31_022563B0, v0); + PoketchSystem_SetSaveFunction(ov31_022563B0, v0); return 1; } } @@ -254,7 +254,7 @@ static BOOL ov31_0225646C (UnkStruct_ov31_02256228 * param0) if (ov31_022565B4(param0->unk_1EC, 1)) { u32 v0, v1; - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { if ((v0 >= 16) && (v1 >= 16)) { v0 = (v0 - 16) / 8; v1 = (v1 - 16) / 8; diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 89acad2a6..269c886aa 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -153,7 +153,7 @@ static BOOL ov32_02256308 (UnkStruct_ov32_0225621C * param0) } if (ov32_0225655C(param0->unk_74, 2)) { - param0->unk_04.unk_64 = ov25_0225446C(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); + param0->unk_04.unk_64 = PoketchSystem_IsTouchingDisplay(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); if (param0->unk_04.unk_64) { param0->unk_04.unk_66 = TouchScreen_Tapped(); diff --git a/src/overlay033/ov33_022561C0.c b/src/overlay033/ov33_022561C0.c index 2e7834964..4c69ef9ad 100644 --- a/src/overlay033/ov33_022561C0.c +++ b/src/overlay033/ov33_022561C0.c @@ -210,7 +210,7 @@ static BOOL ov33_022563D0 (UnkStruct_ov33_0225621C * param0) return 0; } - param0->unk_04.unk_4C = ov25_0225446C(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); + param0->unk_04.unk_4C = PoketchSystem_IsTouchingDisplay(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); if (param0->unk_04.unk_4C) { if (((u32)(param0->unk_04.unk_50 - 16) < (u32)(207 - 16)) & ((u32)(param0->unk_04.unk_54 - 16) < (u32)(175 - 16))) { diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index e85063c46..73f4303d1 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -201,7 +201,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) static BOOL ov34_022563E4 (UnkStruct_ov34_0225621C * param0, u32 * param1, u32 * param2) { if (ov25_0225450C(param0->unk_4C) == 0) { - if (sub_020227C0(param1, param2)) { + if (TouchScreen_TapLocation(param1, param2)) { if (((u32)((*param1) - 24) < (u32)(200 - 24)) & ((u32)((*param2) - 24) < (u32)(168 - 24))) { return 1; } diff --git a/src/overlay040/ov40_022561C0.c b/src/overlay040/ov40_022561C0.c index 13ed16b9c..3bdc732c7 100644 --- a/src/overlay040/ov40_022561C0.c +++ b/src/overlay040/ov40_022561C0.c @@ -193,7 +193,7 @@ static BOOL ov40_02256388 (UnkStruct_ov40_0225621C * param0) if (ov25_0225450C(param0->unk_2C) == 0) { u32 v0, v1; - if (sub_020227C0(&v0, &v1)) { + if (TouchScreen_TapLocation(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(207 - 16)) & ((u32)(v1 - 16) < (u32)(175 - 16))) { return 1; } diff --git a/src/overlay041/ov41_022561C0.c b/src/overlay041/ov41_022561C0.c index 8f2fa746f..79d8781d9 100644 --- a/src/overlay041/ov41_022561C0.c +++ b/src/overlay041/ov41_022561C0.c @@ -283,7 +283,7 @@ static BOOL ov41_02256564 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -304,7 +304,7 @@ static BOOL ov41_022565C4 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay042/ov42_022561C0.c b/src/overlay042/ov42_022561C0.c index 41375ef52..8fcea69fc 100644 --- a/src/overlay042/ov42_022561C0.c +++ b/src/overlay042/ov42_022561C0.c @@ -187,7 +187,7 @@ static BOOL ov42_02256398 (void) { u32 x, y; - if (ov25_022544BC(&x, &y)) { + if (PoketchSystem_TappedDisplay(&x, &y)) { x = (112 - x) * (112 - x); y = (144 - y) * (144 - y); diff --git a/src/overlay049/ov49_022561C0.c b/src/overlay049/ov49_022561C0.c index b14dc6e99..5d33ba8e2 100644 --- a/src/overlay049/ov49_022561C0.c +++ b/src/overlay049/ov49_022561C0.c @@ -168,7 +168,7 @@ static BOOL ov49_02256348 (UnkStruct_ov49_0225621C * param0) if (ov25_0225450C(param0->unk_0C) == 0) { u32 v0, v1; - if (sub_020227A4(&v0, &v1)) { + if (TouchScreen_TouchLocation(&v0, &v1)) { if ((136 <= v1) && (v1 < 160) && (48 <= v0) && (v0 < 184)) { u32 v2 = (v0 - 48) / 16; diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index c6da785a9..20e4bc10b 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -656,7 +656,7 @@ static int ov56_02256BC0 (UnkStruct_ov56_02256468 * param0) switch (v0) { case 0: ov56_0225717C(param0, 0); - sub_020227A4(&v1, &v2); + TouchScreen_TouchLocation(&v1, &v2); ov56_02256994(param0->unk_1FC[2], v2); if (param0->unk_2D8.unk_00 > 3) { diff --git a/src/overlay062/ov62_02231690.c b/src/overlay062/ov62_02231690.c index 90663c6c5..c56a72d75 100644 --- a/src/overlay062/ov62_02231690.c +++ b/src/overlay062/ov62_02231690.c @@ -2462,7 +2462,7 @@ void ov62_02233664 (UnkStruct_ov62_0223359C * param0) BOOL v3; BOOL v4 = 0; - v3 = sub_020227A4(&v0, &v1); + v3 = TouchScreen_TouchLocation(&v0, &v1); if (param0->unk_14) { sub_0200D33C(param0->unk_18[0]); @@ -3290,7 +3290,7 @@ static void ov62_02234440 (UnkStruct_0208C06C * param0) param0->unk_41D8.unk_00 = 1; param0->unk_41D8.unk_04 = 0; - sub_020227C0(&v0, &v1); + TouchScreen_TapLocation(&v0, &v1); sub_0208BA30(param0->unk_41D8.unk_08); sub_0208B8B0(param0->unk_41D8.unk_08, 1); sub_0208B9E0(param0->unk_41D8.unk_08, 1); diff --git a/src/overlay076/ov76_0223B140.c b/src/overlay076/ov76_0223B140.c index 2130cb46a..72eb54fb6 100644 --- a/src/overlay076/ov76_0223B140.c +++ b/src/overlay076/ov76_0223B140.c @@ -116,7 +116,7 @@ int ov76_0223B278 (UnkStruct_ov76_0223DE00 * param0, u8 param1) param0->unk_324[v0].unk_05 = 190; param0->unk_324[v0].unk_06 = 70; - sub_020227A4(&v1, &v2); + TouchScreen_TouchLocation(&v1, &v2); param0->unk_324[v0].unk_05 = v1; param0->unk_324[v0].unk_06 = v2; diff --git a/src/overlay076/ov76_0223D338.c b/src/overlay076/ov76_0223D338.c index b87fa70ad..f585427de 100644 --- a/src/overlay076/ov76_0223D338.c +++ b/src/overlay076/ov76_0223D338.c @@ -1166,7 +1166,7 @@ static BOOL ov76_0223DF94 (UnkStruct_ov76_0223DE00 * param0) BOOL v14; v13 = param0->unk_D4.unk_00; - v14 = sub_020227A4(&v11, &v12); + v14 = TouchScreen_TouchLocation(&v11, &v12); if (v14) { int v15; diff --git a/src/overlay111/ov111_021D0D80.c b/src/overlay111/ov111_021D0D80.c index 2a6e3a4e2..a37090eda 100644 --- a/src/overlay111/ov111_021D0D80.c +++ b/src/overlay111/ov111_021D0D80.c @@ -535,7 +535,7 @@ static BOOL ov111_021D10B8 (UnkStruct_ov111_021D0F7C * param0) param0->unk_15[param0->unk_0E] = v3; param0->unk_0E++; - sub_020227A4(&v0, &v1); + TouchScreen_TouchLocation(&v0, &v1); sub_0200E084(¶m0->unk_5C[15], 0); GXLayers_EngineBToggleLayers((GX_PLANEMASK_BG0), 0); param0->unk_08 = 2; diff --git a/src/overlay116/ov116_02262A8C.c b/src/overlay116/ov116_02262A8C.c index e31f55d56..b85492f56 100644 --- a/src/overlay116/ov116_02262A8C.c +++ b/src/overlay116/ov116_02262A8C.c @@ -1008,7 +1008,7 @@ void ov116_02263BA0 (UnkStruct_ov116_02262A8C * param0) u32 v0, v1; s16 v2, v3; BOOL v4; - BOOL v5 = sub_020227A4(&v0, &v1); + BOOL v5 = TouchScreen_TouchLocation(&v0, &v1); TouchScreenHitTable * v6; int v7; diff --git a/src/touch_screen.c b/src/touch_screen.c index 18fb198a5..57060e214 100644 --- a/src/touch_screen.c +++ b/src/touch_screen.c @@ -139,26 +139,26 @@ BOOL TouchScreen_Tapped(void) return gCoreSys.touchPressed; } -BOOL sub_020227A4 (u32 * param0, u32 * param1) +BOOL TouchScreen_TouchLocation(u32 *x, u32 *y) { if (gCoreSys.touchHeld) { - *param0 = gCoreSys.touchX; - *param1 = gCoreSys.touchY; - return 1; + *x = gCoreSys.touchX; + *y = gCoreSys.touchY; + return TRUE; } - return 0; + return FALSE; } -BOOL sub_020227C0 (u32 * param0, u32 * param1) +BOOL TouchScreen_TapLocation(u32 * x, u32 * y) { if (gCoreSys.touchPressed) { - *param0 = gCoreSys.touchX; - *param1 = gCoreSys.touchY; - return 1; + *x = gCoreSys.touchX; + *y = gCoreSys.touchY; + return TRUE; } - return 0; + return FALSE; } int sub_020227DC (const TouchScreenHitTable *hitTable, u32 param1, u32 param2) From c9b927ac5765427c8dbfa04a63d5392eba87f6cd Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:13 -0700 Subject: [PATCH 05/25] poketch sound effect function --- include/overlay025/poketch_system.h | 2 +- src/overlay025/poketch_system.c | 17 +++++++--------- src/overlay027/ov27_0225680C.c | 8 ++++---- src/overlay028/ov28_0225697C.c | 2 +- src/overlay029/ov29_022566C8.c | 2 +- src/overlay032/ov32_02256470.c | 2 +- src/overlay033/ov33_02256474.c | 2 +- src/overlay034/ov34_022561C0.c | 4 ++-- src/overlay035/ov35_02256410.c | 2 +- src/overlay036/ov36_02256404.c | 2 +- src/overlay037/ov37_022563D4.c | 2 +- src/overlay039/ov39_022561C0.c | 4 ++-- src/overlay041/ov41_022561C0.c | 10 +++++----- src/overlay041/ov41_022567B0.c | 2 +- src/overlay042/ov42_022563D4.c | 6 +++--- src/overlay043/ov43_02256544.c | 2 +- src/overlay044/ov44_022561C0.c | 2 +- src/overlay044/ov44_022565BC.c | 4 ++-- src/overlay045/ov45_022561C0.c | 4 ++-- src/overlay045/ov45_022566EC.c | 6 +++--- src/overlay046/ov46_022561C0.c | 30 ++++++++++++++--------------- src/overlay046/ov46_02256BCC.c | 2 +- src/overlay048/ov48_0225650C.c | 2 +- src/overlay049/ov49_022563D4.c | 2 +- src/overlay052/ov52_02256694.c | 10 +++++----- 25 files changed, 64 insertions(+), 67 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 15990a84d..68995cb2f 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -115,7 +115,7 @@ void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys); void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *saveData); UnkStruct_ov25_02254560 * ov25_02254418(void); -void ov25_02254424(u32 param0); +void PoketchSystem_PlaySoundEffect(u32 param0); void ov25_02254444(u32 param0, u32 param1); BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y); BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index c9c95daff..015aba84f 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -661,17 +661,14 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch static BOOL ov25_022543EC (UnkStruct_ov25_02254560 * param0, u32 param1) { - u32 v0; - - for (v0 = 0; v0 < 6; v0++) { - if (ov25_022547F4(param0, param1) == 0) { - return 0; + for (u32 i = 0; i < 6; i++) { + if (ov25_022547F4(param0, param1) == FALSE) { + return FALSE; } } ov25_022547D0(param0, param1); - - return 1; + return TRUE; } UnkStruct_ov25_02254560 * ov25_02254418 (void) @@ -680,12 +677,12 @@ UnkStruct_ov25_02254560 * ov25_02254418 (void) return poketchSys->unk_1C; } -void ov25_02254424 (u32 param0) +void PoketchSystem_PlaySoundEffect(u32 soundID) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { - Sound_PlayEffect(param0); + if ((poketchSys->unk_05 == FALSE) && (ov25_0225450C(poketchSys) == FALSE)) { + Sound_PlayEffect(soundID); } } diff --git a/src/overlay027/ov27_0225680C.c b/src/overlay027/ov27_0225680C.c index 3f076c738..93ca199a4 100644 --- a/src/overlay027/ov27_0225680C.c +++ b/src/overlay027/ov27_0225680C.c @@ -358,7 +358,7 @@ static void ov27_02256BE8 (SysTask * param0, void * param1) sub_02019448(v0->unk_04, 6); - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov27_02256A04(param1); } @@ -409,7 +409,7 @@ static void ov27_02256C80 (SysTask * param0, void * param1) ov25_0225524C(param1); case 1: if (ov27_02256E90(v2, 6)) { - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov27_02256EC4(v1->unk_04, v2->unk_03); sub_02019448(v1->unk_04, 6); } @@ -442,7 +442,7 @@ static void ov27_02256D00 (SysTask * param0, void * param1) ov25_0225524C(param1); case 1: if (ov27_02256E90(v2, 3)) { - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov27_02256EC4(v1->unk_04, v2->unk_03); sub_02019448(v1->unk_04, 6); } @@ -472,7 +472,7 @@ static void ov27_02256D80 (SysTask * param0, void * param1) ov25_022558C4(v1->unk_60[8], 15); ov27_02256EC4(v1->unk_04, 5); sub_02019448(v1->unk_04, 6); - ov25_02254424(1638); + PoketchSystem_PlaySoundEffect(1638); ov25_0225524C(param1); case 1: if (++(v2->unk_00) > 2) { diff --git a/src/overlay028/ov28_0225697C.c b/src/overlay028/ov28_0225697C.c index 2830db19b..3c2f96216 100644 --- a/src/overlay028/ov28_0225697C.c +++ b/src/overlay028/ov28_0225697C.c @@ -586,7 +586,7 @@ static void ov28_02256B24 (SysTask * param0, void * param1) v1 = ov25_0225523C(param1); v2 = v0->unk_00; - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); sub_020198C0(v1->unk_04, 6, Unk_ov28_0225797C[v2], Unk_ov28_02257938[v2].unk_00, Unk_ov28_02257938[v2].unk_01, Unk_ov28_02257938[v2].unk_02, Unk_ov28_02257938[v2].unk_03); sub_02019448(v1->unk_04, 6); diff --git a/src/overlay029/ov29_022566C8.c b/src/overlay029/ov29_022566C8.c index 9d5ce5126..2bd161b32 100644 --- a/src/overlay029/ov29_022566C8.c +++ b/src/overlay029/ov29_022566C8.c @@ -217,7 +217,7 @@ static void ov29_02256908 (SysTask * param0, void * param1) ov25_022558C4(v0->unk_68[1], 2); } - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov29_022567F0(param1); } diff --git a/src/overlay032/ov32_02256470.c b/src/overlay032/ov32_02256470.c index a8b6f715f..39d949e63 100644 --- a/src/overlay032/ov32_02256470.c +++ b/src/overlay032/ov32_02256470.c @@ -478,6 +478,6 @@ static void ov32_02256C54 (SysTask * param0, void * param1) sub_02019448(v0->unk_04, 6); - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov32_02256574(param1); } diff --git a/src/overlay033/ov33_02256474.c b/src/overlay033/ov33_02256474.c index d78092861..2330253a1 100644 --- a/src/overlay033/ov33_02256474.c +++ b/src/overlay033/ov33_02256474.c @@ -776,7 +776,7 @@ static void ov33_0225718C (UnkStruct_ov33_02256474 * param0, const UnkStruct_ov3 case 0: VEC_Set(&v0->unk_08, 0, 0, 0); ov33_02256C98(param0, param2); - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); v0->unk_34_val3[0]++; case 1: v0->unk_34_val3[1] += 8; diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index 73f4303d1..156014b99 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -157,7 +157,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) case 0: if (ov34_022563E4(param0, &v0, &v1)) { ov34_02256428(param0, v0, v1); - ov25_02254424(1640); + PoketchSystem_PlaySoundEffect(1640); ov34_02256640(param0->unk_48, 2); param0->unk_01 = 1; } @@ -188,7 +188,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) break; case 3: if (ov34_02256664(param0->unk_48, 2)) { - ov25_02254424(1640); + PoketchSystem_PlaySoundEffect(1640); ov34_02256640(param0->unk_48, 2); param0->unk_01 = 1; } diff --git a/src/overlay035/ov35_02256410.c b/src/overlay035/ov35_02256410.c index f8a9aca33..626c964d8 100644 --- a/src/overlay035/ov35_02256410.c +++ b/src/overlay035/ov35_02256410.c @@ -194,7 +194,7 @@ static void ov35_02256644 (SysTask * param0, void * param1) switch (v0->unk_00->unk_04) { case 0: - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov25_022558C4(v0->unk_24, 1); break; case 1: diff --git a/src/overlay036/ov36_02256404.c b/src/overlay036/ov36_02256404.c index 3b608ae56..2336c5602 100644 --- a/src/overlay036/ov36_02256404.c +++ b/src/overlay036/ov36_02256404.c @@ -198,7 +198,7 @@ static void ov36_02256638 (SysTask * param0, void * param1) switch (v0->unk_00->unk_04) { case 0: - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov25_022558C4(v0->unk_24, 1); break; case 1: diff --git a/src/overlay037/ov37_022563D4.c b/src/overlay037/ov37_022563D4.c index c1266febf..8a5a27f62 100644 --- a/src/overlay037/ov37_022563D4.c +++ b/src/overlay037/ov37_022563D4.c @@ -172,7 +172,7 @@ static void ov37_02256588 (SysTask * param0, void * param1) UnkStruct_ov37_022563D4 * v0 = ov25_0225523C(param1); const UnkStruct_ov37_022563D4_1 * v1 = ov25_02255240(param1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); if (v1->unk_00) { ov25_022558C4(v0->unk_24, 0); diff --git a/src/overlay039/ov39_022561C0.c b/src/overlay039/ov39_022561C0.c index 7465422d8..5dbacb38e 100644 --- a/src/overlay039/ov39_022561C0.c +++ b/src/overlay039/ov39_022561C0.c @@ -180,10 +180,10 @@ static BOOL ov39_02256324 (UnkStruct_ov39_0225621C * param0) if (param0->unk_04.unk_04[param0->unk_34]) { param0->unk_04.unk_1C = param0->unk_34; ov39_02256418(param0->unk_24, 2); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); param0->unk_01++; } else { - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); } } break; diff --git a/src/overlay041/ov41_022561C0.c b/src/overlay041/ov41_022561C0.c index 79d8781d9..9ba3efbe4 100644 --- a/src/overlay041/ov41_022561C0.c +++ b/src/overlay041/ov41_022561C0.c @@ -190,16 +190,16 @@ static BOOL ov41_02256378 (UnkStruct_ov41_02256220 * param0) param0->unk_04.unk_5B76 = 1; ov41_0225688C(param0->unk_5B7C, 5); ov41_0225688C(param0->unk_5B7C, 7); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); param0->unk_01 = 1; break; case 1: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 2: param0->unk_04.unk_5B76 = 1; ov41_0225688C(param0->unk_5B7C, 5); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); param0->unk_01 = 3; break; } @@ -231,7 +231,7 @@ static BOOL ov41_02256378 (UnkStruct_ov41_02256220 * param0) switch (param0->unk_5B8C) { case 2: case 0: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 1: param0->unk_04.unk_5B74 = 1; @@ -239,7 +239,7 @@ static BOOL ov41_02256378 (UnkStruct_ov41_02256220 * param0) param0->unk_04.unk_5B76 = 1; ov41_0225688C(param0->unk_5B7C, 5); ov41_0225688C(param0->unk_5B7C, 8); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); param0->unk_01 = 2; break; } diff --git a/src/overlay041/ov41_022567B0.c b/src/overlay041/ov41_022567B0.c index 0ce4eab73..7a02c5ebf 100644 --- a/src/overlay041/ov41_022567B0.c +++ b/src/overlay041/ov41_022567B0.c @@ -418,7 +418,7 @@ static void ov41_02256D1C (SysTask * param0, void * param1) break; case 1: if (ov41_022568B0(v0, 7)) { - ov25_02254424(1642); + PoketchSystem_PlaySoundEffect(1642); ov41_022568C8(param1); } break; diff --git a/src/overlay042/ov42_022563D4.c b/src/overlay042/ov42_022563D4.c index dc0bcd11b..5e14486e3 100644 --- a/src/overlay042/ov42_022563D4.c +++ b/src/overlay042/ov42_022563D4.c @@ -190,7 +190,7 @@ static void ov42_022565C4 (SysTask * param0, void * param1) switch (ov25_02255248(param1)) { case 0: - ov25_02254424(1653); + PoketchSystem_PlaySoundEffect(1653); ov25_022558C4(v0->unk_24, 0); v0->unk_3C = 144 << FX32_SHIFT; v0->unk_40 = Unk_ov42_02256720; @@ -209,10 +209,10 @@ static void ov42_022565C4 (SysTask * param0, void * param1) v0->unk_40 = -((v0->unk_40 * 56) / 100); if (v0->unk_40 < (-2 * FX32_ONE)) { - ov25_02254424(1654); + PoketchSystem_PlaySoundEffect(1654); v0->unk_3C = 144 << FX32_SHIFT; } else { - ov25_02254424(1654); + PoketchSystem_PlaySoundEffect(1654); ov25_022558C4(v0->unk_24, (v1->unk_00) ? 1 : 2); v0->unk_3C = 144 << FX32_SHIFT; ov25_0225524C(param1); diff --git a/src/overlay043/ov43_02256544.c b/src/overlay043/ov43_02256544.c index 2ae908157..dc10b1aa0 100644 --- a/src/overlay043/ov43_02256544.c +++ b/src/overlay043/ov43_02256544.c @@ -308,7 +308,7 @@ static void ov43_022568B4 (SysTask * param0, void * param1) v2 = (v1->unk_00 & 1) ? 3 : 1; ov25_022558C4(v0->unk_34[v1->unk_00], v2); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov43_022566EC(param1); } diff --git a/src/overlay044/ov44_022561C0.c b/src/overlay044/ov44_022561C0.c index 291222251..4d6ce24f2 100644 --- a/src/overlay044/ov44_022561C0.c +++ b/src/overlay044/ov44_022561C0.c @@ -217,7 +217,7 @@ static BOOL ov44_022563D0 (UnkStruct_ov44_0225621C * param0) ov44_02256744(param0->unk_38, 2); param0->unk_01 = 2; } else { - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); } break; } diff --git a/src/overlay044/ov44_022565BC.c b/src/overlay044/ov44_022565BC.c index ec460ae75..1be9f3ba7 100644 --- a/src/overlay044/ov44_022565BC.c +++ b/src/overlay044/ov44_022565BC.c @@ -279,7 +279,7 @@ static void ov44_0225686C (SysTask * param0, void * param1) v0 = ov25_0225523C(param1); v1 = ov25_02255240(param1); - ov25_02254424(1641); + PoketchSystem_PlaySoundEffect(1641); ov25_022558C4(v0->unk_24[0], 10); ov44_02256780(param1); } @@ -508,7 +508,7 @@ static BOOL ov44_02256AC8 (UnkStruct_ov44_022565BC * param0, const UnkStruct_ov4 param0->unk_70 = 2; break; case -5: - ov25_02254424(param0->unk_6C[(param0->unk_74)++]); + PoketchSystem_PlaySoundEffect(param0->unk_6C[(param0->unk_74)++]); break; case -6: ov25_022558C4(param0->unk_24[2], 6); diff --git a/src/overlay045/ov45_022561C0.c b/src/overlay045/ov45_022561C0.c index cf7d27fb4..3911ae332 100644 --- a/src/overlay045/ov45_022561C0.c +++ b/src/overlay045/ov45_022561C0.c @@ -238,7 +238,7 @@ static BOOL ov45_022563C0 (UnkStruct_ov45_022561D4 * param0) if ((param0->unk_1C == 1) && (param0->unk_18 == 1)) { param0->unk_1C = 0; - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; } @@ -304,7 +304,7 @@ static BOOL ov45_022564D0 (UnkStruct_ov45_022561D4 * param0) } if ((param0->unk_1C == 1) && (param0->unk_18 == 0)) { - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; } diff --git a/src/overlay045/ov45_022566EC.c b/src/overlay045/ov45_022566EC.c index 16d70f0ee..253836d8b 100644 --- a/src/overlay045/ov45_022566EC.c +++ b/src/overlay045/ov45_022566EC.c @@ -333,7 +333,7 @@ static void ov45_02256A40 (SysTask * param0, void * param1) UnkStruct_ov45_022566EC * v0 = ov25_0225523C(param1); const UnkStruct_ov45_022566EC_1 * v1 = ov25_02255240(param1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov25_022558C4(v0->unk_34[0], 3); ov25_022558C4(v0->unk_34[3], 5); @@ -354,7 +354,7 @@ static void ov45_02256ABC (SysTask * param0, void * param1) UnkStruct_ov45_022566EC * v0 = ov25_0225523C(param1); const UnkStruct_ov45_022566EC_1 * v1 = ov25_02255240(param1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov25_022558C4(v0->unk_34[0], 2); ov25_022558C4(v0->unk_34[3], 5); @@ -396,7 +396,7 @@ static void ov45_02256B78 (SysTask * param0, void * param1) ov25_022558C4(v0->unk_34[4], 4); ov25_022558C4(v0->unk_34[1], 1); ov25_022558C4(v0->unk_34[2], 1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov25_02254444(294, 0); v0->unk_94 = 0; v0->unk_98 = 0; diff --git a/src/overlay046/ov46_022561C0.c b/src/overlay046/ov46_022561C0.c index 33cad1c5a..85e47d049 100644 --- a/src/overlay046/ov46_022561C0.c +++ b/src/overlay046/ov46_022561C0.c @@ -355,10 +355,10 @@ static BOOL ov46_02256518 (UnkStruct_ov46_0225621C * param0) case 2: ov46_02256AF0(param0); ov46_02256D24(param0->unk_08, 5); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); break; case 0: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); if (ov46_022569CC(param0)) { ov46_0225623C(param0, 0, 0); @@ -368,7 +368,7 @@ static BOOL ov46_02256518 (UnkStruct_ov46_0225621C * param0) } break; case 1: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; } @@ -451,10 +451,10 @@ static BOOL ov46_022566A0 (UnkStruct_ov46_0225621C * param0) switch (param0->unk_14) { case 0: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 1: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 1, 0); ov46_0225623C(param0, 0, 1); ov46_02256A3C(param0); @@ -462,7 +462,7 @@ static BOOL ov46_022566A0 (UnkStruct_ov46_0225621C * param0) ov46_02256460(param0, 3); break; case 2: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 1); ov46_0225623C(param0, 1, 0); ov46_02256AF0(param0); @@ -489,17 +489,17 @@ static BOOL ov46_0225678C (UnkStruct_ov46_0225621C * param0) switch (param0->unk_14) { case 0: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 1, 1); ov46_0225623C(param0, 0, 0); ov46_02256A50(param0); ov46_02256460(param0, 2); break; case 1: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 2: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 1); ov46_0225623C(param0, 1, 0); ov46_02256AF0(param0); @@ -526,10 +526,10 @@ static BOOL ov46_02256838 (UnkStruct_ov46_0225621C * param0) switch (param0->unk_14) { case 0: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 1: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 1); ov46_0225623C(param0, 1, 0); ov46_02256D24(param0->unk_08, 7); @@ -537,7 +537,7 @@ static BOOL ov46_02256838 (UnkStruct_ov46_0225621C * param0) param0->unk_01++; break; case 2: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 1); ov46_0225623C(param0, 1, 0); ov46_02256D24(param0->unk_08, 7); @@ -562,17 +562,17 @@ static BOOL ov46_022568E0 (UnkStruct_ov46_0225621C * param0) switch (param0->unk_14) { case 0: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 0); ov46_0225623C(param0, 1, 1); ov46_02256D24(param0->unk_08, 6); ov46_02256460(param0, 4); break; case 1: - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); break; case 2: - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov46_0225623C(param0, 0, 1); ov46_0225623C(param0, 1, 0); ov46_02256AF0(param0); diff --git a/src/overlay046/ov46_02256BCC.c b/src/overlay046/ov46_02256BCC.c index c38d8c995..97b075694 100644 --- a/src/overlay046/ov46_02256BCC.c +++ b/src/overlay046/ov46_02256BCC.c @@ -435,7 +435,7 @@ static void ov46_02256F54 (SysTask * param0, void * param1) ov25_022558C4(v0->unk_34[1], 0); } - ov25_02254424(1655); + PoketchSystem_PlaySoundEffect(1655); v0->unk_A4 = 0; } break; diff --git a/src/overlay048/ov48_0225650C.c b/src/overlay048/ov48_0225650C.c index c5a52eb34..4841b9459 100644 --- a/src/overlay048/ov48_0225650C.c +++ b/src/overlay048/ov48_0225650C.c @@ -206,7 +206,7 @@ static void ov48_0225672C (SysTask * param0, void * param1) G2S_SetBGMosaicSize(v0->unk_154, v0->unk_154); G2S_SetOBJMosaicSize(v0->unk_154, v0->unk_154); - ov25_02254424(1656); + PoketchSystem_PlaySoundEffect(1656); ov25_0225524C(param1); break; case 1: diff --git a/src/overlay049/ov49_022563D4.c b/src/overlay049/ov49_022563D4.c index 9c172ac0b..6086433ab 100644 --- a/src/overlay049/ov49_022563D4.c +++ b/src/overlay049/ov49_022563D4.c @@ -174,7 +174,7 @@ static void ov49_02256594 (SysTask * param0, void * param1) UnkStruct_ov49_022563D4 * v0 = ov25_0225523C(param1); const UnkStruct_ov49_022563D4_1 * v1 = ov25_02255240(param1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov25_022546B8(0, 0); ov25_02255900(v0->unk_24, (56 + (16 * v1->unk_00)) << FX32_SHIFT, (148 << FX32_SHIFT)); ov49_022564D0(param1); diff --git a/src/overlay052/ov52_02256694.c b/src/overlay052/ov52_02256694.c index 8ae0d6c3c..28603b91f 100644 --- a/src/overlay052/ov52_02256694.c +++ b/src/overlay052/ov52_02256694.c @@ -250,7 +250,7 @@ static void ov52_022568D8 (SysTask * param0, void * param1) ov25_02255914(v0->unk_34[3], 1); ov52_02256A7C(v0); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov52_022567E0(param1); } @@ -265,7 +265,7 @@ static void ov52_0225691C (SysTask * param0, void * param1) ov25_022558C4(v0->unk_34[1], 1); ov52_02256B10(v0); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov52_022567E0(param1); } @@ -279,7 +279,7 @@ static void ov52_02256968 (SysTask * param0, void * param1) ov25_02255914(v0->unk_34[3], 1); ov25_022558C4(v0->unk_34[2], 2); ov52_02256B64(v0); - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); ov52_022567E0(param1); } @@ -293,7 +293,7 @@ static void ov52_022569B4 (SysTask * param0, void * param1) ov25_02255914(v0->unk_34[3], 1); ov25_022558C4(v0->unk_34[2], 2); ov52_02256BDC(v0); - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); ov52_022567E0(param1); } @@ -309,7 +309,7 @@ static void ov52_02256A00 (SysTask * param0, void * param1) ov25_022558C4(v0->unk_34[3], 0); ov52_02256C64(v0, v1); - ov25_02254424(1635); + PoketchSystem_PlaySoundEffect(1635); ov52_022567E0(param1); } From 75da1f3a5ea13f76f46c66610e91c4945138c807 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:13 -0700 Subject: [PATCH 06/25] more poketch system variables --- include/overlay025/poketch_system.h | 6 ++--- src/overlay025/poketch_system.c | 42 ++++++++++++++--------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 68995cb2f..62cc95ab9 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -73,12 +73,12 @@ struct PoketchSystem { u8 appState; u8 touchingScreen; u8 playerMoved; - u8 unk_05; + u8 appChanging; u8 unk_06; u8 pedometerUpdated; u32 buttonState; - BOOL unk_0C; - u32 unk_10; + BOOL skipApp; + u32 appSkipTimer; enum PoketchAppID loadedAppID; FSOverlayID loadedAppOverlayID; UnkStruct_ov25_02254560 * unk_1C; diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 015aba84f..9a78d21c1 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -205,7 +205,7 @@ static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) poketchSys->touchingScreen = FALSE; poketchSys->playerMoved = 0; poketchSys->pedometerUpdated = FALSE; - poketchSys->unk_05 = 0; + poketchSys->appChanging = FALSE; poketchSys->unk_06 = 0; poketchSys->loadedAppID = POKETCH_APPID_NONE; poketchSys->appState = POKETCH_APP_STATE_NONE; @@ -315,8 +315,8 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) switch (poketchSys->buttonState) { case BUTTON_MANAGER_STATE_TAP: case BUTTON_MANAGER_STATE_TIMER0: - poketchSys->unk_0C = 0; - poketchSys->unk_05 = 1; + poketchSys->skipApp = FALSE; + poketchSys->appChanging = TRUE; ov25_022547D0(poketchSys->unk_1C, 4); poketchSys->subState++; break; @@ -324,7 +324,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) break; case 1: if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { - poketchSys->unk_0C = 1; + poketchSys->skipApp = TRUE; } if (ov25_02254800(poketchSys->unk_1C)) { @@ -334,13 +334,13 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) poketchSys->unk_20.unk_00 = PoketchData_IncrementAppID(poketchSys->poketchData); } - if (poketchSys->unk_0C) { + if (poketchSys->skipApp) { ov25_022547D0(poketchSys->unk_1C, 12); - poketchSys->unk_10 = 30; - poketchSys->unk_0C = 0; + poketchSys->appSkipTimer = 30; + poketchSys->skipApp = FALSE; poketchSys->subState = 4; } else { - poketchSys->unk_10 = 3; + poketchSys->appSkipTimer = 3; poketchSys->subState = 2; } } @@ -348,14 +348,14 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) case 2: if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { ov25_022547D0(poketchSys->unk_1C, 12); - poketchSys->unk_10 = 30; - poketchSys->unk_0C = 0; + poketchSys->appSkipTimer = 30; + poketchSys->skipApp = FALSE; poketchSys->subState = 4; break; } - if (poketchSys->unk_10) { - poketchSys->unk_10--; + if (poketchSys->appSkipTimer) { + poketchSys->appSkipTimer--; } else { PoketchSystem_ShutdownApp(poketchSys); poketchSys->subState = 3; @@ -376,13 +376,13 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) poketchSys->unk_20.unk_00 = PoketchData_IncrementAppID(poketchSys->poketchData); } - poketchSys->unk_10 = 30; + poketchSys->appSkipTimer = 30; ov25_022547D0(poketchSys->unk_1C, 13); break; } - if (poketchSys->unk_10) { - poketchSys->unk_10--; + if (poketchSys->appSkipTimer) { + poketchSys->appSkipTimer--; } else { ov25_022547D0(poketchSys->unk_1C, 14); PoketchSystem_ShutdownApp(poketchSys); @@ -416,7 +416,7 @@ static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) break; case 2: if (ov25_022547F4(poketchSys->unk_1C, 2)) { - poketchSys->unk_05 = 0; + poketchSys->appChanging = FALSE; poketchSys->unk_06 = 0; PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UPDATE); } @@ -681,7 +681,7 @@ void PoketchSystem_PlaySoundEffect(u32 soundID) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->unk_05 == FALSE) && (ov25_0225450C(poketchSys) == FALSE)) { + if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == FALSE)) { Sound_PlayEffect(soundID); } } @@ -690,7 +690,7 @@ void ov25_02254444 (u32 param0, u32 param1) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { + if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { sub_02005844(param0, param1); } } @@ -708,7 +708,7 @@ BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { + if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { if (TouchScreen_TouchLocation(x, y)) { return PoketchSystem_InsideScreenBounds(*x, *y); } @@ -721,7 +721,7 @@ BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->unk_05 == 0) && (ov25_0225450C(poketchSys) == 0)) { + if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { if (TouchScreen_TapLocation(x, y)) { return PoketchSystem_InsideScreenBounds(*x, *y); } @@ -737,7 +737,7 @@ BOOL ov25_0225450C (const PoketchSystem *poketchSys) void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *buttonManager) { - if ((ov25_0225450C(poketchSys) == 0) && (poketchSys->unk_05 == 0)) { + if ((ov25_0225450C(poketchSys) == 0) && (poketchSys->appChanging == FALSE)) { PoketchButtonManager_Update(buttonManager); } } From df0fa9bc20a102516d208d761a905f93696f38b2 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:14 -0700 Subject: [PATCH 07/25] Poketch Player moved function --- include/overlay025/poketch_system.h | 4 ++-- src/overlay025/poketch_system.c | 2 +- src/overlay034/ov34_022561C0.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 62cc95ab9..5c9356d11 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -115,13 +115,13 @@ void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); void PoketchSystem_NotifyAppUnloaded(PoketchSystem *poketchSys); void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *saveData); UnkStruct_ov25_02254560 * ov25_02254418(void); -void PoketchSystem_PlaySoundEffect(u32 param0); +void PoketchSystem_PlaySoundEffect(u32 soundID); void ov25_02254444(u32 param0, u32 param1); BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y); BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y); BOOL ov25_0225450C(const PoketchSystem *poketchSys); void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager * param1); -BOOL ov25_02254534(const PoketchSystem *poketchSys); +BOOL PoketchSystem_PlayerMoved(const PoketchSystem *poketchSys); BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys); FieldSystem * PoketchSystem_FieldSystem(const PoketchSystem *poketchSys); PoketchData * PoketchSystem_PoketchData(const PoketchSystem *poketchSys); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 9a78d21c1..b89a61230 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -742,7 +742,7 @@ void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *butto } } -BOOL ov25_02254534 (const PoketchSystem *poketchSys) +BOOL PoketchSystem_PlayerMoved(const PoketchSystem *poketchSys) { return poketchSys->playerMoved; } diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index 156014b99..1a00e0de9 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -168,7 +168,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) break; } - if ((ov25_02254534(param0->unk_4C) == 1) || (ov25_0225450C(param0->unk_4C))) { + if ((PoketchSystem_PlayerMoved(param0->unk_4C) == 1) || (ov25_0225450C(param0->unk_4C))) { ov34_02256A0C(param0->unk_48); param0->unk_01 = 2; break; From c05a963c52bae025d0387c4bffa8727eda415af1 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:14 -0700 Subject: [PATCH 08/25] Variable names in function declarations --- src/overlay025/poketch_system.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index b89a61230..a7d2149c7 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -60,14 +60,14 @@ FS_EXTERN_OVERLAY(overlay55); static PoketchSystem *PoketchSystem_GetFromFieldSystem(void); static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys); static void PoketchSystem_Shutdown(PoketchSystem *poketchSys); -static void PoketchSystem_MainTask(SysTask *param0, void * param1); -static void PoketchSystem_PostRender(SysTask *param0, void * param1); -static void PoketchSystem_SetState(PoketchSystem *poketchSys, u32 param1); +static void PoketchSystem_MainTask(SysTask *task, void *system); +static void PoketchSystem_PostRender(SysTask *, void *system); +static void PoketchSystem_SetState(PoketchSystem *poketchSys, u32 state); static void PoketchEvent_InitApp(PoketchSystem *poketchSys); static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys); static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys); static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys); -static void PoketchSystem_LoadApp(PoketchSystem *poketchSys, int param1); +static void PoketchSystem_LoadApp(PoketchSystem *poketchSys, int appID); static void PoketchSystem_UnloadApp(PoketchSystem *poketchSys); static void PoketchSystem_InitApp(PoketchSystem *poketchSys, u32 param1); static BOOL PoketchSystem_IsAppInitialized(PoketchSystem *poketchSys); @@ -78,7 +78,7 @@ static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); -static inline BOOL PoketchSystem_InsideScreenBounds(u32 param0, u32 param1); +static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y); // the order of this array determines the app order in the poketch. static const struct { From 72f06fc7d93802a2b8ead36ed01584815298d622 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:15 -0700 Subject: [PATCH 09/25] More Poketch System documentation --- include/unk_0203CC84.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/unk_0203CC84.h diff --git a/include/unk_0203CC84.h b/include/unk_0203CC84.h new file mode 100644 index 000000000..86a80c03d --- /dev/null +++ b/include/unk_0203CC84.h @@ -0,0 +1,22 @@ +#ifndef POKEPLATINUM_UNK_0203CC84_H +#define POKEPLATINUM_UNK_0203CC84_H + +#include "struct_decls/struct_02018340_decl.h" +#include "field/field_system_decl.h" +#include "overlay_manager.h" +#include "savedata.h" +#include "overlay025/poketch_system.h" + +void sub_0203CD00(FieldSystem * param0); +void sub_0203CD44(FieldSystem * param0); +BOOL sub_0203CD4C(FieldSystem * param0); +BOOL sub_0203CD5C(FieldSystem * param0); +BOOL sub_0203CD74(FieldSystem * param0); +void sub_0203CD84(FieldSystem * param0, const OverlayManagerTemplate * param1, void * param2); +void sub_0203D128(void); +void sub_0203D140(void); +PoketchSystem * FieldSystem_PoketchSystem(void); +BGL * sub_0203D170(void * param0); +SaveData * FieldSystem_SaveData(void * param0); + +#endif // POKEPLATINUM_UNK_0203CC84_H From a170251ceeb6b51cb0c97485f2d6e0a876198e27 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:15 -0700 Subject: [PATCH 10/25] Resolve merge conflicts and move changes to feature branch --- include/overlay025/poketch_system.h | 6 +++--- include/unk_0203CC84.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 5c9356d11..0ca1f3bed 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H -#define POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H +#ifndef POKEPLATINUM_POKETCHSYSTEM_H +#define POKEPLATINUM_POKETCHSYSTEM_H #include "struct_decls/struct_02018340_decl.h" #include "field/field_system_decl.h" @@ -128,4 +128,4 @@ PoketchData * PoketchSystem_PoketchData(const PoketchSystem *poketchSys); SaveData * PoketchSystem_SaveData(const PoketchSystem *poketchSys); int PoketchSystem_BorderColor(const PoketchSystem *poketchSys); -#endif // POKEPLATINUM_PoketchSystem_GetFromFieldSystem_H +#endif // POKEPLATINUM_POKETCHSYSTEM_H diff --git a/include/unk_0203CC84.h b/include/unk_0203CC84.h index 86a80c03d..7d065f0dc 100644 --- a/include/unk_0203CC84.h +++ b/include/unk_0203CC84.h @@ -16,6 +16,7 @@ void sub_0203CD84(FieldSystem * param0, const OverlayManagerTemplate * param1, v void sub_0203D128(void); void sub_0203D140(void); PoketchSystem * FieldSystem_PoketchSystem(void); + BGL * sub_0203D170(void * param0); SaveData * FieldSystem_SaveData(void * param0); From d90c723bfb7e96f51a90990f07a35a6aa4c0a5c5 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:16 -0700 Subject: [PATCH 11/25] Some Poketch System button functions --- src/overlay025/poketch_system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index a7d2149c7..e00afd405 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -77,6 +77,7 @@ static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys); static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); +static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y); From 647fb047068dd8678ffbcdf45751ee852adae13a Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:16 -0700 Subject: [PATCH 12/25] More Poketch System documentation --- include/unk_0203CC84.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/unk_0203CC84.h b/include/unk_0203CC84.h index 7d065f0dc..86a80c03d 100644 --- a/include/unk_0203CC84.h +++ b/include/unk_0203CC84.h @@ -16,7 +16,6 @@ void sub_0203CD84(FieldSystem * param0, const OverlayManagerTemplate * param1, v void sub_0203D128(void); void sub_0203D140(void); PoketchSystem * FieldSystem_PoketchSystem(void); - BGL * sub_0203D170(void * param0); SaveData * FieldSystem_SaveData(void * param0); From 45be2b6b1501adc409a36c952b4d91234e7ec3f7 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:17 -0700 Subject: [PATCH 13/25] Some Poketch System button functions --- src/overlay025/poketch_system.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index e00afd405..a7d2149c7 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -77,7 +77,6 @@ static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys); static void PoketchSystem_ButtonShutdown(PoketchSystem *poketchSys); static void PoketchSystem_ButtonUpdate(PoketchSystem *poketchSys); static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); -static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touchEvent, void *system); static BOOL ov25_022543EC(UnkStruct_ov25_02254560 * param0, u32 param1); static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y); From fa6dff606944520b144e65768f247509094d4324 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:45:17 -0700 Subject: [PATCH 14/25] Fixups to conflicts/errors missed during branch repair --- include/field_system.h | 2 +- src/field_system.c | 4 ++-- src/overlay025/poketch_system.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/field_system.h b/include/field_system.h index bb5740d75..b9703eaf2 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -15,7 +15,7 @@ BOOL sub_0203CD74(FieldSystem * fieldSystem); void sub_0203CD84(FieldSystem * fieldSystem, const OverlayManagerTemplate * param1, void * param2); void sub_0203D128(void); void sub_0203D140(void); -PoketchSystem * sub_0203D158(void); +PoketchSystem * FieldSystem_PoketchSystem(void); BGL * sub_0203D170(void * param0); SaveData * FieldSystem_SaveData(void * param0); diff --git a/src/field_system.c b/src/field_system.c index 10519933d..14a2f954e 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -318,7 +318,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) PoketchSystem * v4 = sub_0203D158(); if (v4 != NULL) { - v3 = ov25_02253DD4(v4); + v3 = PoketchSystem_CheckTouch(v4); } PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v3); @@ -344,7 +344,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) PoketchSystem * v6 = sub_0203D158(); if (v6 != NULL) { - v5 = ov25_02253DD4(v6); + v5 = PoketchSystem_CheckTouch(v6); } PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v5); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index a7d2149c7..884472e3a 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -118,7 +118,7 @@ static PoketchSystem* PoketchSystem_GetFromFieldSystem(void) } -void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager) +void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager) { Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POKETCH_MAIN, HEAP_SIZE_POKETCH_MAIN); Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POKETCH_APP, HEAP_SIZE_POKETCH_APP); @@ -128,7 +128,7 @@ void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, if (new_system != NULL) { *poketchSys = new_system; - new_system->fieldSystem = fieldSystem; + new_system->fieldSys = fieldSys; new_system->saveData = saveData; new_system->poketchData = SaveData_PoketchData(saveData); new_system->bgl = bgl; @@ -732,7 +732,7 @@ BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y) BOOL ov25_0225450C (const PoketchSystem *poketchSys) { - return sub_020509A4(poketchSys->fieldSystem); + return sub_020509A4(poketchSys->fieldSys); } void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *buttonManager) @@ -754,7 +754,7 @@ BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys) FieldSystem* PoketchSystem_FieldSystem(const PoketchSystem *poketchSys) { - return poketchSys->fieldSystem; + return poketchSys->fieldSys; } PoketchData* PoketchSystem_PoketchData(const PoketchSystem *poketchSys) From 3ae55730cb7a3ddb11e264cf56545d3eba80d53d Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Fri, 31 May 2024 18:53:35 -0700 Subject: [PATCH 15/25] Remove (accidentally re-added) old field system header --- include/unk_0203CC84.h | 22 ---------------------- src/overlay025/poketch_system.c | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 include/unk_0203CC84.h diff --git a/include/unk_0203CC84.h b/include/unk_0203CC84.h deleted file mode 100644 index 86a80c03d..000000000 --- a/include/unk_0203CC84.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0203CC84_H -#define POKEPLATINUM_UNK_0203CC84_H - -#include "struct_decls/struct_02018340_decl.h" -#include "field/field_system_decl.h" -#include "overlay_manager.h" -#include "savedata.h" -#include "overlay025/poketch_system.h" - -void sub_0203CD00(FieldSystem * param0); -void sub_0203CD44(FieldSystem * param0); -BOOL sub_0203CD4C(FieldSystem * param0); -BOOL sub_0203CD5C(FieldSystem * param0); -BOOL sub_0203CD74(FieldSystem * param0); -void sub_0203CD84(FieldSystem * param0, const OverlayManagerTemplate * param1, void * param2); -void sub_0203D128(void); -void sub_0203D140(void); -PoketchSystem * FieldSystem_PoketchSystem(void); -BGL * sub_0203D170(void * param0); -SaveData * FieldSystem_SaveData(void * param0); - -#endif // POKEPLATINUM_UNK_0203CC84_H diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 884472e3a..833d03b2a 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -21,7 +21,7 @@ #include "heap.h" #include "unk_0201E3D8.h" #include "unk_02025E08.h" -#include "unk_0203CC84.h" +#include "field_system.h" #include "trainer_info.h" #include "unk_020508D4.h" #include "unk_02099D44.h" From c5a4ec7cf54c974dc15cc4021024a13346734be6 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Mon, 17 Jun 2024 19:23:46 -0700 Subject: [PATCH 16/25] Functions renamed to address github comments, fieldSys parameter renamed back to fieldSystem --- include/overlay025/poketch_system.h | 41 ++++++++++++-------- include/touch_screen.h | 2 +- src/field_system.c | 4 +- src/overlay005/ov5_021EA714.c | 2 +- src/overlay019/ov19_021D603C.c | 2 +- src/overlay025/ov25_02254560.c | 2 +- src/overlay025/poketch_system.c | 60 ++++++++++++++--------------- src/overlay028/ov28_022561C0.c | 2 +- src/overlay031/ov31_022561C0.c | 6 +-- src/overlay032/ov32_022561C0.c | 4 +- src/overlay034/ov34_022561C0.c | 2 +- src/overlay036/ov36_022561C0.c | 2 +- src/overlay040/ov40_022561C0.c | 2 +- src/overlay044/ov44_022561C0.c | 2 +- src/overlay045/ov45_022561C0.c | 2 +- src/overlay049/ov49_022561C0.c | 4 +- src/overlay050/ov50_022561C0.c | 2 +- src/overlay053/ov53_022561C0.c | 4 +- src/overlay054/ov54_022561C0.c | 2 +- src/overlay056/ov56_022561C0.c | 2 +- src/overlay062/ov62_02231690.c | 2 +- src/overlay076/ov76_0223B140.c | 2 +- src/overlay076/ov76_0223D338.c | 2 +- src/overlay111/ov111_021D0D80.c | 2 +- src/overlay116/ov116_02262A8C.c | 2 +- src/touch_screen.c | 2 +- 26 files changed, 84 insertions(+), 77 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 0ca1f3bed..9c1be094f 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -15,6 +15,24 @@ #define POKETCH_PEDOMETER_MAX 99999 +#define POKETCH_SCREEN_MINX 16 +#define POKETCH_SCREEN_MAXX 207 + +#define POKETCH_SCREEN_MINY 16 +#define POKETCH_SCREEN_MAXY 175 + +#define POKETCH_BUTTON_TOP_MINX 224 +#define POKETCH_BUTTON_TOP_MAXX 255 + +#define POKETCH_BUTTON_TOP_MINY 32 +#define POKETCH_BUTTON_TOP_MAXY 96 + +#define POKETCH_BUTTON_BOTTOM_MINX 224 +#define POKETCH_BUTTON_BOTTOM_MAXX 255 + +#define POKETCH_BUTTON_BOTTOM_MINY 96 +#define POKETCH_BUTTON_BOTTOM_MAXY 160 + enum ButtonDir { BUTTON_UP, BUTTON_DOWN, @@ -54,13 +72,6 @@ enum PoketchFieldEventID { POKETCH_FIELDEVENT_PEDOMETER, }; -enum PoketchScreenCoordinates { - POKETCH_SCREEN_MINX = 16, - POKETCH_SCREEN_MINY = 16, - POKETCH_SCREEN_MAXX = 207, - POKETCH_SCREEN_MAXY = 175, -}; - typedef struct PoketchSystem PoketchSystem; typedef BOOL (* PoketchAppInitFunction)(void **, PoketchSystem *, BGL *, u32); @@ -100,15 +111,15 @@ struct PoketchSystem { SaveData *saveData; PoketchData *poketchData; - FieldSystem *fieldSys; + FieldSystem *fieldSystem; enum ButtonDir buttonDir; }; -void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager); +void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager); void PoketchSystem_StartShutdown(PoketchSystem *poketchSys); BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys); -void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32); -BOOL PoketchSystem_CheckTouch(PoketchSystem *poketchSys); +void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32); +BOOL PoketchSystem_IsTapped(PoketchSystem *poketchSys); enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys); void PoketchSystem_SetAppFunctions(PoketchAppInitFunction initFunction, PoketchAppShutdownFunction shutdownFunction); void PoketchSystem_NotifyAppLoaded(PoketchSystem *poketchSys); @@ -123,9 +134,9 @@ BOOL ov25_0225450C(const PoketchSystem *poketchSys); void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager * param1); BOOL PoketchSystem_PlayerMoved(const PoketchSystem *poketchSys); BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys); -FieldSystem * PoketchSystem_FieldSystem(const PoketchSystem *poketchSys); -PoketchData * PoketchSystem_PoketchData(const PoketchSystem *poketchSys); -SaveData * PoketchSystem_SaveData(const PoketchSystem *poketchSys); -int PoketchSystem_BorderColor(const PoketchSystem *poketchSys); +FieldSystem * PoketchSystem_GetFieldSystem(const PoketchSystem *poketchSys); +PoketchData * PoketchSystem_GetPoketchData(const PoketchSystem *poketchSys); +SaveData * PoketchSystem_GetSaveData(const PoketchSystem *poketchSys); +int PoketchSystem_GetBorderColor(const PoketchSystem *poketchSys); #endif // POKEPLATINUM_POKETCHSYSTEM_H diff --git a/include/touch_screen.h b/include/touch_screen.h index 85e036d5a..5fa6f41d0 100644 --- a/include/touch_screen.h +++ b/include/touch_screen.h @@ -39,7 +39,7 @@ BOOL TouchScreen_Touched(void); * @return TRUE if the touch screen is tapped, FALSE otherwise. */ BOOL TouchScreen_Tapped(void); -BOOL TouchScreen_TouchLocation(u32 *x, u32 *y); +BOOL TouchScreen_HoldLocation(u32 *x, u32 *y); BOOL TouchScreen_TapLocation(u32 *x, u32 *y); int sub_020227DC(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); BOOL sub_02022830(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); diff --git a/src/field_system.c b/src/field_system.c index 14a2f954e..f2a6fe49e 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -318,7 +318,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) PoketchSystem * v4 = sub_0203D158(); if (v4 != NULL) { - v3 = PoketchSystem_CheckTouch(v4); + v3 = PoketchSystem_IsTapped(v4); } PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v3); @@ -344,7 +344,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) PoketchSystem * v6 = sub_0203D158(); if (v6 != NULL) { - v5 = PoketchSystem_CheckTouch(v6); + v5 = PoketchSystem_IsTapped(v6); } PlayerAvatar_MoveControl(fieldSystem->playerAvatar, fieldSystem->unk_28, -1, v1.pressedKeys, v1.heldKeys, v5); diff --git a/src/overlay005/ov5_021EA714.c b/src/overlay005/ov5_021EA714.c index 2cfb2abea..4924ba1c7 100644 --- a/src/overlay005/ov5_021EA714.c +++ b/src/overlay005/ov5_021EA714.c @@ -19,7 +19,7 @@ FS_EXTERN_OVERLAY(overlay25); void ov5_021EA714 (FieldSystem * fieldSystem, int param1, u32 param2) { if ((fieldSystem->unk_04 != NULL) && (fieldSystem->unk_04->unk_14 != NULL)) { - PoketchSystem_SendFieldEvent(fieldSystem->unk_04->unk_14, param1, param2); + PoketchSystem_SendEvent(fieldSystem->unk_04->unk_14, param1, param2); } } diff --git a/src/overlay019/ov19_021D603C.c b/src/overlay019/ov19_021D603C.c index 0a64cfbbb..97e1c24b4 100644 --- a/src/overlay019/ov19_021D603C.c +++ b/src/overlay019/ov19_021D603C.c @@ -48,7 +48,7 @@ int ov19_021D60A8 (UnkStruct_ov19_021D6104 * param0) v0 = 1; v1 = (param0->unk_1C == 0); - if (TouchScreen_TouchLocation(&v2, &v3)) { + if (TouchScreen_HoldLocation(&v2, &v3)) { param0->unk_14 = v2; param0->unk_18 = v3; } diff --git a/src/overlay025/ov25_02254560.c b/src/overlay025/ov25_02254560.c index 18c661438..1c8f76660 100644 --- a/src/overlay025/ov25_02254560.c +++ b/src/overlay025/ov25_02254560.c @@ -324,7 +324,7 @@ static void ov25_02254820 (SysTask * param0, void * param1) sub_02006E3C(12, 14, v2->unk_1F8, 4, 64, 0, 1, 7); sub_02006E60(12, 15, v2->unk_1F8, 4, 0, 0, 1, 7); - sub_02006E9C(12, 13, 4, PoketchSystem_BorderColor(v2->unk_1FC) * 0x20, 15 * 0x20, 0x20, 7); + sub_02006E9C(12, 13, 4, PoketchSystem_GetBorderColor(v2->unk_1FC) * 0x20, 15 * 0x20, 0x20, 7); sub_02019CB8(v2->unk_1F8, 5, 64 + 164, 0, 0, 32, 24, 15); sub_02019448(v2->unk_1F8, 5); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 833d03b2a..f58d01052 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -26,6 +26,8 @@ #include "unk_020508D4.h" #include "unk_02099D44.h" #include "overlay025/ov25_02254560.h" +#include "constants/sdat.h" +#include "gender.h" FS_EXTERN_OVERLAY(overlay26); FS_EXTERN_OVERLAY(overlay27); @@ -118,7 +120,7 @@ static PoketchSystem* PoketchSystem_GetFromFieldSystem(void) } -void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager) +void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager) { Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POKETCH_MAIN, HEAP_SIZE_POKETCH_MAIN); Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POKETCH_APP, HEAP_SIZE_POKETCH_APP); @@ -128,7 +130,7 @@ void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, Sav if (new_system != NULL) { *poketchSys = new_system; - new_system->fieldSys = fieldSys; + new_system->fieldSystem = fieldSystem; new_system->saveData = saveData; new_system->poketchData = SaveData_PoketchData(saveData); new_system->bgl = bgl; @@ -148,7 +150,7 @@ void PoketchSystem_Create(FieldSystem *fieldSys, PoketchSystem **poketchSys, Sav void PoketchSystem_StartShutdown (PoketchSystem *poketchSys) { - if ((poketchSys->systemState != POKETCHSYSTEM_SHUTDOWN) && (poketchSys->systemState != POKETCHSYSTEM_UNLOAD)) { + if (poketchSys->systemState != POKETCHSYSTEM_SHUTDOWN && poketchSys->systemState != POKETCHSYSTEM_UNLOAD) { PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_SHUTDOWN); } } @@ -158,7 +160,7 @@ BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys) return poketchSys == NULL; } -void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32) +void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32) { switch (eventID) { case POKETCH_FIELDEVENT_SLEEP: @@ -178,16 +180,14 @@ void PoketchSystem_SendFieldEvent(PoketchSystem *poketchSys, enum PoketchFieldEv } break; case POKETCH_FIELDEVENT_SAVE: - if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { - if (poketchSys->currAppSave) { - poketchSys->currAppSave(poketchSys->appSaveData); - } + if (poketchSys->appState == POKETCH_APP_STATE_UPDATE && poketchSys->currAppSave) { + poketchSys->currAppSave(poketchSys->appSaveData); } break; } } -BOOL PoketchSystem_CheckTouch(PoketchSystem *poketchSys) +BOOL PoketchSystem_IsTapped(PoketchSystem *poketchSys) { return poketchSys->touchingScreen; } @@ -229,7 +229,7 @@ static void PoketchSystem_Shutdown (PoketchSystem *poketchSys) ov25_02254754(poketchSys->unk_1C); } -typedef void(*const PoketchEvent)(PoketchSystem *); +typedef void (*const PoketchEvent)(PoketchSystem *); static PoketchEvent sPoketchEvents[] = { PoketchEvent_InitApp, PoketchEvent_UpdateApp, @@ -346,7 +346,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) } break; case 2: - if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { + if (poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP || poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0) { ov25_022547D0(poketchSys->unk_1C, 12); poketchSys->appSkipTimer = 30; poketchSys->skipApp = FALSE; @@ -369,7 +369,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) } break; case 4: - if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { + if (poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP || poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0) { if (poketchSys->buttonDir == BUTTON_UP) { poketchSys->unk_20.unk_00 = PoketchData_DecrementAppID(poketchSys->poketchData); } else { @@ -499,11 +499,7 @@ static void PoketchSystem_InitApp(PoketchSystem *poketchSys, u32) static BOOL PoketchSystem_IsAppInitialized(PoketchSystem *poketchSys) { - if (poketchSys->appState == POKETCH_APP_STATE_UPDATE) { - return TRUE; - } - - return FALSE; + return poketchSys->appState == POKETCH_APP_STATE_UPDATE; } static void PoketchSystem_ShutdownApp(PoketchSystem *poketchSys) @@ -553,9 +549,9 @@ void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *sa } static const TouchScreenHitTable sMainPoketchButtons[] = { - {4 * 8, 12 * 8, 28 * 8, 255}, // Top button - {12 * 8, 20 * 8, 28 * 8, 255}, // Bottom Button - {16, 175, 16, 207} // Screen + {POKETCH_BUTTON_TOP_MINY, POKETCH_BUTTON_TOP_MAXY, POKETCH_BUTTON_TOP_MINX, POKETCH_BUTTON_TOP_MAXX}, // Top button + {POKETCH_BUTTON_BOTTOM_MINY, POKETCH_BUTTON_BOTTOM_MAXY, POKETCH_BUTTON_BOTTOM_MINX, POKETCH_BUTTON_BOTTOM_MAXX}, // Bottom Button + {POKETCH_SCREEN_MINY, POKETCH_SCREEN_MAXY, POKETCH_SCREEN_MINX, POKETCH_SCREEN_MAXX} // Screen }; static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) @@ -603,7 +599,7 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch if (buttonID == POKETCHSYSTEM_MAINBUTTON_SCREEN) { if (ov25_0225450C(poketchSys)) { if (touchEvent == BUTTON_TOUCH_RELEASED) { - Sound_PlayEffect(1646); + Sound_PlayEffect(SEQ_SE_DP_BEEP); } } } else { @@ -690,14 +686,14 @@ void ov25_02254444 (u32 param0, u32 param1) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { + if (poketchSys->appChanging == FALSE && ov25_0225450C(poketchSys) == 0) { sub_02005844(param0, param1); } } static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y) { - if (((u32)(x - POKETCH_SCREEN_MINX) < (u32)(POKETCH_SCREEN_MAXX - POKETCH_SCREEN_MINX)) & ((u32)(y - POKETCH_SCREEN_MINY) < (u32)(POKETCH_SCREEN_MAXY - POKETCH_SCREEN_MINY))) { + if ((u32)(x - POKETCH_SCREEN_MINX) < (u32)(POKETCH_SCREEN_MAXX - POKETCH_SCREEN_MINX) & (u32)(y - POKETCH_SCREEN_MINY) < (u32)(POKETCH_SCREEN_MAXY - POKETCH_SCREEN_MINY)) { return TRUE; } @@ -709,7 +705,7 @@ BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y) PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { - if (TouchScreen_TouchLocation(x, y)) { + if (TouchScreen_HoldLocation(x, y)) { return PoketchSystem_InsideScreenBounds(*x, *y); } } @@ -732,12 +728,12 @@ BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y) BOOL ov25_0225450C (const PoketchSystem *poketchSys) { - return sub_020509A4(poketchSys->fieldSys); + return sub_020509A4(poketchSys->fieldSystem); } void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *buttonManager) { - if ((ov25_0225450C(poketchSys) == 0) && (poketchSys->appChanging == FALSE)) { + if (ov25_0225450C(poketchSys) == 0 && poketchSys->appChanging == FALSE) { PoketchButtonManager_Update(buttonManager); } } @@ -752,26 +748,26 @@ BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys) return poketchSys->pedometerUpdated; } -FieldSystem* PoketchSystem_FieldSystem(const PoketchSystem *poketchSys) +FieldSystem* PoketchSystem_GetFieldSystem(const PoketchSystem *poketchSys) { - return poketchSys->fieldSys; + return poketchSys->fieldSystem; } -PoketchData* PoketchSystem_PoketchData(const PoketchSystem *poketchSys) +PoketchData* PoketchSystem_GetPoketchData(const PoketchSystem *poketchSys) { return poketchSys->poketchData; } -SaveData* PoketchSystem_SaveData(const PoketchSystem *poketchSys) +SaveData* PoketchSystem_GetSaveData(const PoketchSystem *poketchSys) { return poketchSys->saveData; } -int PoketchSystem_BorderColor(const PoketchSystem *poketchSys) +int PoketchSystem_GetBorderColor(const PoketchSystem *poketchSys) { TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(poketchSys->saveData); - if (TrainerInfo_Gender(trainerInfo) == 1) { + if (TrainerInfo_Gender(trainerInfo) == GENDER_FEMALE) { return POKETCH_BORDER_PINK; } else { return POKETCH_BORDER_BLUE; diff --git a/src/overlay028/ov28_022561C0.c b/src/overlay028/ov28_022561C0.c index 3ee939265..6d581c396 100644 --- a/src/overlay028/ov28_022561C0.c +++ b/src/overlay028/ov28_022561C0.c @@ -634,7 +634,7 @@ static void ov28_02256914 (UnkStruct_ov28_02256210 * param0, const UnkStruct_ov2 PokedexData * v1; u16 v2; - v1 = SaveData_Pokedex(PoketchSystem_SaveData(param0->unk_10)); + v1 = SaveData_Pokedex(PoketchSystem_GetSaveData(param0->unk_10)); if (sub_02027474(v1)) { v2 = v0; diff --git a/src/overlay031/ov31_022561C0.c b/src/overlay031/ov31_022561C0.c index 5a2ba37d9..a2557e5f9 100644 --- a/src/overlay031/ov31_022561C0.c +++ b/src/overlay031/ov31_022561C0.c @@ -92,7 +92,7 @@ static BOOL ov31_02256228 (UnkStruct_ov31_02256228 * param0, PoketchSystem * par static void ov31_02256268 (UnkStruct_ov31_02256228 * param0, UnkStruct_ov31_02256554_1 * param1) { - PoketchData * v0 = PoketchSystem_PoketchData(param0->unk_1F0); + PoketchData * v0 = PoketchSystem_GetPoketchData(param0->unk_1F0); if (PoketchData_DotArtModified(v0)) { ov31_02256298(param0, param1, v0); @@ -178,7 +178,7 @@ static void ov31_0225635C (UnkStruct_ov31_02256554_1 * param0) static void ov31_02256384 (UnkStruct_ov31_02256228 * param0) { - ov31_022562EC(param0, ¶m0->unk_0C, PoketchSystem_PoketchData(param0->unk_1F0)); + ov31_022562EC(param0, ¶m0->unk_0C, PoketchSystem_GetPoketchData(param0->unk_1F0)); ov31_02256584(param0->unk_1EC); Heap_FreeToHeap(param0); @@ -187,7 +187,7 @@ static void ov31_02256384 (UnkStruct_ov31_02256228 * param0) static void ov31_022563B0 (void * param0) { UnkStruct_ov31_02256228 * v0 = param0; - ov31_022562EC(v0, &v0->unk_0C, PoketchSystem_PoketchData(v0->unk_1F0)); + ov31_022562EC(v0, &v0->unk_0C, PoketchSystem_GetPoketchData(v0->unk_1F0)); } static void ov31_022563CC (SysTask * param0, void * param1) diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 269c886aa..9b5789ab2 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -71,7 +71,7 @@ static BOOL ov32_0225621C (UnkStruct_ov32_0225621C * param0, PoketchSystem * par param0->unk_01 = 0; param0->unk_02 = 0; - ov32_022563C8(¶m0->unk_04, Party_GetFromSavedata(PoketchSystem_SaveData(param1))); + ov32_022563C8(¶m0->unk_04, Party_GetFromSavedata(PoketchSystem_GetSaveData(param1))); param0->unk_04.unk_64 = 0; param0->unk_04.unk_66 = 0; @@ -162,7 +162,7 @@ static BOOL ov32_02256308 (UnkStruct_ov32_0225621C * param0) u32 v0 = ov32_02256B78(param0->unk_04.unk_68, param0->unk_04.unk_6C, param0->unk_04.unk_00); if (v0 >= param0->unk_04.unk_00) { - ov32_022563C8(¶m0->unk_04, Party_GetFromSavedata(PoketchSystem_SaveData(param0->unk_78))); + ov32_022563C8(¶m0->unk_04, Party_GetFromSavedata(PoketchSystem_GetSaveData(param0->unk_78))); ov32_02256538(param0->unk_74, 2); } } diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index 1a00e0de9..324b41721 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -216,7 +216,7 @@ static void ov34_02256428 (UnkStruct_ov34_0225621C * param0, int param1, int par static const fx32 v0[] = { 8 << FX32_SHIFT, 24 << FX32_SHIFT, 48 << FX32_SHIFT, }; - UnkStruct_0203F478 * v1 = sub_0203F478(PoketchSystem_FieldSystem(param0->unk_4C), 8); + UnkStruct_0203F478 * v1 = sub_0203F478(PoketchSystem_GetFieldSystem(param0->unk_4C), 8); UnkStruct_ov34_02256540_1 * v2 = &(param0->unk_04); v2->unk_08 = 0; diff --git a/src/overlay036/ov36_022561C0.c b/src/overlay036/ov36_022561C0.c index b23c9b69d..b5cb5c072 100644 --- a/src/overlay036/ov36_022561C0.c +++ b/src/overlay036/ov36_022561C0.c @@ -74,7 +74,7 @@ static BOOL ov36_0225621C (UnkStruct_ov36_0225621C * param0, PoketchSystem * par }; param0->unk_10 = param1; - param0->unk_1C = PoketchSystem_PoketchData(param1); + param0->unk_1C = PoketchSystem_GetPoketchData(param1); param0->unk_04.unk_04 = 1; param0->unk_04.unk_00 = PoketchData_StepCount(param0->unk_1C); diff --git a/src/overlay040/ov40_022561C0.c b/src/overlay040/ov40_022561C0.c index 3bdc732c7..1b894b6e1 100644 --- a/src/overlay040/ov40_022561C0.c +++ b/src/overlay040/ov40_022561C0.c @@ -70,7 +70,7 @@ static BOOL ov40_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, static BOOL ov40_0225621C (UnkStruct_ov40_0225621C * param0, PoketchSystem * param1, BGL * param2, u32 param3) { - param0->unk_30 = sub_02026310(PoketchSystem_SaveData(param1)); + param0->unk_30 = sub_02026310(PoketchSystem_GetSaveData(param1)); ov40_022563D0(¶m0->unk_04, param0->unk_30); diff --git a/src/overlay044/ov44_022561C0.c b/src/overlay044/ov44_022561C0.c index 4d6ce24f2..c7321e342 100644 --- a/src/overlay044/ov44_022561C0.c +++ b/src/overlay044/ov44_022561C0.c @@ -75,7 +75,7 @@ static BOOL ov44_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, static BOOL ov44_0225621C (UnkStruct_ov44_0225621C * param0, PoketchSystem * param1, BGL * param2, u32 param3) { - Party * v0 = Party_GetFromSavedata(PoketchSystem_SaveData(param1)); + Party * v0 = Party_GetFromSavedata(PoketchSystem_GetSaveData(param1)); Pokemon * v1; int v2; int v3 = 0; diff --git a/src/overlay045/ov45_022561C0.c b/src/overlay045/ov45_022561C0.c index 3911ae332..15d670b8b 100644 --- a/src/overlay045/ov45_022561C0.c +++ b/src/overlay045/ov45_022561C0.c @@ -88,7 +88,7 @@ static BOOL ov45_0225621C (UnkStruct_ov45_022561D4 * param0, PoketchSystem * par }; u32 v1, v2; - param0->unk_10 = PoketchSystem_PoketchData(param1); + param0->unk_10 = PoketchSystem_GetPoketchData(param1); param0->unk_03.unk_00 = PoketchData_IsAlarmSet(param0->unk_10); PoketchData_AlarmTime(param0->unk_10, &v1, &v2); diff --git a/src/overlay049/ov49_022561C0.c b/src/overlay049/ov49_022561C0.c index 5d33ba8e2..e8a9e0e00 100644 --- a/src/overlay049/ov49_022561C0.c +++ b/src/overlay049/ov49_022561C0.c @@ -64,7 +64,7 @@ static BOOL ov49_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, static BOOL ov49_0225621C (UnkStruct_ov49_0225621C * param0, PoketchSystem * param1, BGL * param2, u32 param3) { - param0->unk_10 = PoketchSystem_PoketchData(param1); + param0->unk_10 = PoketchSystem_GetPoketchData(param1); param0->unk_04.unk_00 = PoketchData_CurrentScreenColor(param0->unk_10); param0->unk_03 = param0->unk_04.unk_00; @@ -168,7 +168,7 @@ static BOOL ov49_02256348 (UnkStruct_ov49_0225621C * param0) if (ov25_0225450C(param0->unk_0C) == 0) { u32 v0, v1; - if (TouchScreen_TouchLocation(&v0, &v1)) { + if (TouchScreen_HoldLocation(&v0, &v1)) { if ((136 <= v1) && (v1 < 160) && (48 <= v0) && (v0 < 184)) { u32 v2 = (v0 - 48) / 16; diff --git a/src/overlay050/ov50_022561C0.c b/src/overlay050/ov50_022561C0.c index db2423c86..e28c8309b 100644 --- a/src/overlay050/ov50_022561C0.c +++ b/src/overlay050/ov50_022561C0.c @@ -113,7 +113,7 @@ static BOOL ov50_0225621C (UnkStruct_ov50_022561D4 * param0, PoketchSystem * par RTCDate v1; GetCurrentDate(&v1); - param0->unk_98 = PoketchSystem_PoketchData(param1); + param0->unk_98 = PoketchSystem_GetPoketchData(param1); ov50_022562AC(&(param0->unk_04), param0, &v1); param0->unk_A8 = param0->unk_04.unk_0C[0].unk_02; diff --git a/src/overlay053/ov53_022561C0.c b/src/overlay053/ov53_022561C0.c index c45f4b2a1..d0c1d708c 100644 --- a/src/overlay053/ov53_022561C0.c +++ b/src/overlay053/ov53_022561C0.c @@ -90,7 +90,7 @@ static BOOL ov53_0225621C (UnkStruct_ov53_0225621C * param0, PoketchSystem * par FieldSystem * fieldSystem; int v2; - fieldSystem = PoketchSystem_FieldSystem(param1); + fieldSystem = PoketchSystem_GetFieldSystem(param1); param0->unk_04.unk_04 = ov6_02243140(fieldSystem); if (param0->unk_04.unk_04) { @@ -204,7 +204,7 @@ static BOOL ov53_02256370 (UnkStruct_ov53_0225621C * param0) FieldSystem * fieldSystem; int v1; - fieldSystem = PoketchSystem_FieldSystem(param0->unk_30); + fieldSystem = PoketchSystem_GetFieldSystem(param0->unk_30); param0->unk_04.unk_04 = ov6_02243140(fieldSystem); if (param0->unk_04.unk_04 == 0) { diff --git a/src/overlay054/ov54_022561C0.c b/src/overlay054/ov54_022561C0.c index 983d52dd4..34cace51f 100644 --- a/src/overlay054/ov54_022561C0.c +++ b/src/overlay054/ov54_022561C0.c @@ -143,7 +143,7 @@ static BOOL ov54_0225621C (UnkStruct_ov54_0225621C * param0, PoketchSystem * par PoketchData * v1; int v2; - v1 = PoketchSystem_PoketchData(param1); + v1 = PoketchSystem_GetPoketchData(param1); param0->unk_04.unk_90 = PoketchData_PokemonHistorySize(v1); for (v2 = 0; v2 < param0->unk_04.unk_90; v2++) { diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index 20e4bc10b..ae5670253 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -656,7 +656,7 @@ static int ov56_02256BC0 (UnkStruct_ov56_02256468 * param0) switch (v0) { case 0: ov56_0225717C(param0, 0); - TouchScreen_TouchLocation(&v1, &v2); + TouchScreen_HoldLocation(&v1, &v2); ov56_02256994(param0->unk_1FC[2], v2); if (param0->unk_2D8.unk_00 > 3) { diff --git a/src/overlay062/ov62_02231690.c b/src/overlay062/ov62_02231690.c index c56a72d75..df6d9a5a8 100644 --- a/src/overlay062/ov62_02231690.c +++ b/src/overlay062/ov62_02231690.c @@ -2462,7 +2462,7 @@ void ov62_02233664 (UnkStruct_ov62_0223359C * param0) BOOL v3; BOOL v4 = 0; - v3 = TouchScreen_TouchLocation(&v0, &v1); + v3 = TouchScreen_HoldLocation(&v0, &v1); if (param0->unk_14) { sub_0200D33C(param0->unk_18[0]); diff --git a/src/overlay076/ov76_0223B140.c b/src/overlay076/ov76_0223B140.c index 72eb54fb6..222f13d7e 100644 --- a/src/overlay076/ov76_0223B140.c +++ b/src/overlay076/ov76_0223B140.c @@ -116,7 +116,7 @@ int ov76_0223B278 (UnkStruct_ov76_0223DE00 * param0, u8 param1) param0->unk_324[v0].unk_05 = 190; param0->unk_324[v0].unk_06 = 70; - TouchScreen_TouchLocation(&v1, &v2); + TouchScreen_HoldLocation(&v1, &v2); param0->unk_324[v0].unk_05 = v1; param0->unk_324[v0].unk_06 = v2; diff --git a/src/overlay076/ov76_0223D338.c b/src/overlay076/ov76_0223D338.c index f585427de..3930db079 100644 --- a/src/overlay076/ov76_0223D338.c +++ b/src/overlay076/ov76_0223D338.c @@ -1166,7 +1166,7 @@ static BOOL ov76_0223DF94 (UnkStruct_ov76_0223DE00 * param0) BOOL v14; v13 = param0->unk_D4.unk_00; - v14 = TouchScreen_TouchLocation(&v11, &v12); + v14 = TouchScreen_HoldLocation(&v11, &v12); if (v14) { int v15; diff --git a/src/overlay111/ov111_021D0D80.c b/src/overlay111/ov111_021D0D80.c index a37090eda..5c678f77a 100644 --- a/src/overlay111/ov111_021D0D80.c +++ b/src/overlay111/ov111_021D0D80.c @@ -535,7 +535,7 @@ static BOOL ov111_021D10B8 (UnkStruct_ov111_021D0F7C * param0) param0->unk_15[param0->unk_0E] = v3; param0->unk_0E++; - TouchScreen_TouchLocation(&v0, &v1); + TouchScreen_HoldLocation(&v0, &v1); sub_0200E084(¶m0->unk_5C[15], 0); GXLayers_EngineBToggleLayers((GX_PLANEMASK_BG0), 0); param0->unk_08 = 2; diff --git a/src/overlay116/ov116_02262A8C.c b/src/overlay116/ov116_02262A8C.c index b85492f56..3473215a5 100644 --- a/src/overlay116/ov116_02262A8C.c +++ b/src/overlay116/ov116_02262A8C.c @@ -1008,7 +1008,7 @@ void ov116_02263BA0 (UnkStruct_ov116_02262A8C * param0) u32 v0, v1; s16 v2, v3; BOOL v4; - BOOL v5 = TouchScreen_TouchLocation(&v0, &v1); + BOOL v5 = TouchScreen_HoldLocation(&v0, &v1); TouchScreenHitTable * v6; int v7; diff --git a/src/touch_screen.c b/src/touch_screen.c index 57060e214..3d54b391f 100644 --- a/src/touch_screen.c +++ b/src/touch_screen.c @@ -139,7 +139,7 @@ BOOL TouchScreen_Tapped(void) return gCoreSys.touchPressed; } -BOOL TouchScreen_TouchLocation(u32 *x, u32 *y) +BOOL TouchScreen_HoldLocation(u32 *x, u32 *y) { if (gCoreSys.touchHeld) { *x = gCoreSys.touchX; From 2a1303bb0ba89a8c2daff63a9e7eb7c1de470f75 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Tue, 18 Jun 2024 00:08:35 -0700 Subject: [PATCH 17/25] FieldSystem_GetPoketchSystem --- include/field_system.h | 2 +- src/field_system.c | 6 +++--- src/overlay025/ov25_02254560.c | 2 +- src/overlay025/poketch_system.c | 2 +- src/overlay027/ov27_0225680C.c | 2 +- src/overlay028/ov28_0225697C.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/field_system.h b/include/field_system.h index b9703eaf2..a94a0b5a9 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -15,7 +15,7 @@ BOOL sub_0203CD74(FieldSystem * fieldSystem); void sub_0203CD84(FieldSystem * fieldSystem, const OverlayManagerTemplate * param1, void * param2); void sub_0203D128(void); void sub_0203D140(void); -PoketchSystem * FieldSystem_PoketchSystem(void); +PoketchSystem * FieldSystem_GetPoketchSystem(void); BGL * sub_0203D170(void * param0); SaveData * FieldSystem_SaveData(void * param0); diff --git a/src/field_system.c b/src/field_system.c index f2a6fe49e..170c629d2 100644 --- a/src/field_system.c +++ b/src/field_system.c @@ -315,7 +315,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) { BOOL v3 = 0; - PoketchSystem * v4 = sub_0203D158(); + PoketchSystem * v4 = FieldSystem_GetPoketchSystem(); if (v4 != NULL) { v3 = PoketchSystem_IsTapped(v4); @@ -341,7 +341,7 @@ void FieldSystem_Control (FieldSystem * fieldSystem) { BOOL v5 = 0; - PoketchSystem * v6 = sub_0203D158(); + PoketchSystem * v6 = FieldSystem_GetPoketchSystem(); if (v6 != NULL) { v5 = PoketchSystem_IsTapped(v6); @@ -367,7 +367,7 @@ void sub_0203D140 (void) CommSys_EnableSendMovementData(); } -struct PoketchSystem * sub_0203D158 (void) +struct PoketchSystem * FieldSystem_GetPoketchSystem (void) { if (sFieldSystem->unk_04 == NULL) { return NULL; diff --git a/src/overlay025/ov25_02254560.c b/src/overlay025/ov25_02254560.c index 1c8f76660..91b6a49ae 100644 --- a/src/overlay025/ov25_02254560.c +++ b/src/overlay025/ov25_02254560.c @@ -87,7 +87,7 @@ static void ov25_02254F40(UnkStruct_ov25_02254DD8 * param0); static void ov25_02254F68(SysTask * param0, void * param1); static void ov25_02255004(SysTask * param0, void * param1); static void ov25_02255064(SysTask * param0, void * param1); -struct PoketchSystem * sub_0203D158(void); +struct PoketchSystem * FieldSystem_GetPoketchSystem(void); SysTask * CoreSys_ExecuteAfterVBlank(SysTaskFunc param0, void * param1, u32 param2); BOOL ov25_02254560 (UnkStruct_ov25_02254560 ** param0, const UnkStruct_ov25_02254560_1 * param1, NNSG2dOamManagerInstance * param2, PoketchSystem * param3) diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index f58d01052..9af4c2781 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -116,7 +116,7 @@ static const struct { static PoketchSystem* PoketchSystem_GetFromFieldSystem(void) { - return FieldSystem_PoketchSystem(); + return FieldSystem_GetPoketchSystem(); } diff --git a/src/overlay027/ov27_0225680C.c b/src/overlay027/ov27_0225680C.c index 93ca199a4..f0d55d85b 100644 --- a/src/overlay027/ov27_0225680C.c +++ b/src/overlay027/ov27_0225680C.c @@ -61,7 +61,7 @@ static BOOL ov27_02256E90(UnkStruct_ov27_02256E90 * param0, u32 param1); static void ov27_02256EC4(BGL * param0, u32 param1); static void ov27_02256F24(SysTask * param0, void * param1); static void ov27_02256F7C(UnkStruct_ov27_0225680C * param0); -struct PoketchSystem * FieldSystem_PoketchSystem(void); +struct PoketchSystem * FieldSystem_GetPoketchSystem(void); BOOL ov27_0225680C (UnkStruct_ov27_0225680C ** param0, const UnkStruct_ov27_0225680C_1 * param1, BGL * param2) { diff --git a/src/overlay028/ov28_0225697C.c b/src/overlay028/ov28_0225697C.c index 3c2f96216..084c747a9 100644 --- a/src/overlay028/ov28_0225697C.c +++ b/src/overlay028/ov28_0225697C.c @@ -43,7 +43,7 @@ static void ov28_02256D90(BGL * param0, const UnkStruct_ov28_0225697C_1 * param1 static void ov28_02256DCC(BGL * param0); static void ov28_02256DF0(SysTask * param0, void * param1); static void ov28_02256E0C(BGL * param0, const u16 * param1); -struct PoketchSystem * FieldSystem_PoketchSystem(void); +struct PoketchSystem * FieldSystem_GetPoketchSystem(void); static const u16 Unk_ov28_022578F8[32] = { 0xFB, From c3463679f5352ed2bd4a9bafce6036081549e215 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Tue, 18 Jun 2024 00:16:12 -0700 Subject: [PATCH 18/25] More verbs added --- src/overlay025/ov25_02254560.c | 8 ++++---- src/overlay047/ov47_022561C0.c | 10 +++++----- src/overlay048/ov48_022561C0.c | 8 ++++---- src/overlay052/ov52_022561C0.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/overlay025/ov25_02254560.c b/src/overlay025/ov25_02254560.c index 91b6a49ae..361d83807 100644 --- a/src/overlay025/ov25_02254560.c +++ b/src/overlay025/ov25_02254560.c @@ -166,7 +166,7 @@ static void ov25_02254684 (UnkStruct_ov25_02254560 * param0) void ov25_022546B8 (u32 param0, u32 param1) { UnkStruct_ov25_02254560 * v0 = ov25_02254418(); - PoketchData * v1 = PoketchSystem_PoketchData(v0->unk_1FC); + PoketchData * v1 = PoketchSystem_GetPoketchData(v0->unk_1FC); u32 v2 = PoketchData_CurrentScreenColor(v1); GXS_LoadBGPltt(&v0->unk_200[v2 * 32], param0 * 0x20, 0x20); @@ -176,7 +176,7 @@ void ov25_022546B8 (u32 param0, u32 param1) void ov25_022546F0 (u32 param0, u32 param1) { UnkStruct_ov25_02254560 * v0 = ov25_02254418(); - PoketchData * v1 = PoketchSystem_PoketchData(v0->unk_1FC); + PoketchData * v1 = PoketchSystem_GetPoketchData(v0->unk_1FC); u32 v2 = PoketchData_CurrentScreenColor(v1); GXS_LoadBGPltt(&v0->unk_200[v2 * 32 + 16], 0, 0x20); @@ -186,7 +186,7 @@ void ov25_022546F0 (u32 param0, u32 param1) void ov25_02254728 (u16 * param0) { UnkStruct_ov25_02254560 * v0 = ov25_02254418(); - PoketchData * v1 = PoketchSystem_PoketchData(v0->unk_1FC); + PoketchData * v1 = PoketchSystem_GetPoketchData(v0->unk_1FC); u32 v2 = PoketchData_CurrentScreenColor(v1); MI_CpuCopy16(&v0->unk_200[v2 * 32], param0, 0x20); @@ -608,7 +608,7 @@ static void ov25_02254DE0 (UnkStruct_ov25_02254560 * param0, UnkStruct_ov25_0225 static void ov25_02254E84 (UnkStruct_ov25_02254560 * param0, u32 param1) { - PoketchData * v1 = PoketchSystem_PoketchData(param0->unk_1FC); + PoketchData * v1 = PoketchSystem_GetPoketchData(param0->unk_1FC); u32 v2 = PoketchData_CurrentScreenColor(v1); ov25_02254728(param0->unk_400); diff --git a/src/overlay047/ov47_022561C0.c b/src/overlay047/ov47_022561C0.c index 8b263bc87..6435a6d87 100644 --- a/src/overlay047/ov47_022561C0.c +++ b/src/overlay047/ov47_022561C0.c @@ -76,7 +76,7 @@ static BOOL ov47_0225621C (UnkStruct_ov47_0225621C * param0, PoketchSystem * par { int v0; - param0->unk_78 = PoketchSystem_PoketchData(param1); + param0->unk_78 = PoketchSystem_GetPoketchData(param1); for (v0 = 0; v0 < 6; v0++) { param0->unk_04.unk_0C[v0].unk_03 = 1; @@ -95,7 +95,7 @@ static BOOL ov47_0225621C (UnkStruct_ov47_0225621C * param0, PoketchSystem * par param0->unk_04.unk_08 = 0; { - VarsFlags * v1 = SaveData_GetVarsFlags(PoketchSystem_SaveData(param1)); + VarsFlags * v1 = SaveData_GetVarsFlags(PoketchSystem_GetSaveData(param1)); for (v0 = 0; v0 < 4; v0++) { param0->unk_04.unk_2C[v0] = sub_0206B1F0(v1, v0); @@ -103,7 +103,7 @@ static BOOL ov47_0225621C (UnkStruct_ov47_0225621C * param0, PoketchSystem * par } { - UnkStruct_0202D7B0 * v2 = sub_0202D834(PoketchSystem_SaveData(param1)); + UnkStruct_0202D7B0 * v2 = sub_0202D834(PoketchSystem_GetSaveData(param1)); for (v0 = 0; v0 < 6; v0++) { param0->unk_7C[v0] = sub_0202D924(v2, v0); @@ -112,7 +112,7 @@ static BOOL ov47_0225621C (UnkStruct_ov47_0225621C * param0, PoketchSystem * par } } - inline_ov47_0225621C(PoketchSystem_FieldSystem(param1), &(param0->unk_04.unk_00), &(param0->unk_04.unk_04)); + inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param1), &(param0->unk_04.unk_00), &(param0->unk_04.unk_04)); if (ov47_02256634(&(param0->unk_70), &(param0->unk_04), param2)) { param0->unk_00 = 0; @@ -302,7 +302,7 @@ static BOOL ov47_02256584 (UnkStruct_ov47_0225621C * param0) if (ov25_02254534(param0->unk_74)) { int v1, v2; - inline_ov47_0225621C(PoketchSystem_FieldSystem(param0->unk_74), &v1, &v2); + inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_74), &v1, &v2); if ((v1 != param0->unk_04.unk_00) || (v2 != param0->unk_04.unk_04)) { param0->unk_04.unk_00 = v1; diff --git a/src/overlay048/ov48_022561C0.c b/src/overlay048/ov48_022561C0.c index 6a9daed73..0477d50ae 100644 --- a/src/overlay048/ov48_022561C0.c +++ b/src/overlay048/ov48_022561C0.c @@ -196,7 +196,7 @@ static BOOL ov48_0225621C (UnkStruct_ov48_0225621C * param0, PoketchSystem * par param0->unk_AC = param1; param0->unk_04.unk_08 = ov48_02256408(param0); - inline_ov47_0225621C(PoketchSystem_FieldSystem(param0->unk_AC), &(param0->unk_04.unk_00), &(param0->unk_04.unk_04)); + inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_AC), &(param0->unk_04.unk_00), &(param0->unk_04.unk_04)); ov48_022564E0(param0, param1); @@ -312,7 +312,7 @@ static BOOL ov48_022563D0 (UnkStruct_ov48_0225621C * param0) static int ov48_02256408 (UnkStruct_ov48_0225621C * param0) { - UnkStruct_02027854 * v0 = sub_02027854(PoketchSystem_SaveData(param0->unk_AC)); + UnkStruct_02027854 * v0 = sub_02027854(PoketchSystem_GetSaveData(param0->unk_AC)); int v1, v2; for (v1 = 0, v2 = 0; v1 < (NELEMS(Unk_ov48_02256A38)); v1++) { @@ -340,7 +340,7 @@ static BOOL ov48_02256478 (UnkStruct_ov48_0225621C * param0) if (ov25_02254534(param0->unk_AC)) { int v1, v2; - inline_ov47_0225621C(PoketchSystem_FieldSystem(param0->unk_AC), &v1, &v2); + inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_AC), &v1, &v2); if ((v1 != param0->unk_04.unk_00) || (v2 != param0->unk_04.unk_04)) { param0->unk_04.unk_00 = v1; @@ -354,7 +354,7 @@ static BOOL ov48_02256478 (UnkStruct_ov48_0225621C * param0) static void ov48_022564E0 (UnkStruct_ov48_0225621C * param0, PoketchSystem * param1) { - VarsFlags * v0 = SaveData_GetVarsFlags(PoketchSystem_SaveData(param1)); + VarsFlags * v0 = SaveData_GetVarsFlags(PoketchSystem_GetSaveData(param1)); int v1; for (v1 = 0; v1 < 4; v1++) { diff --git a/src/overlay052/ov52_022561C0.c b/src/overlay052/ov52_022561C0.c index 5f91c261e..c70703ecc 100644 --- a/src/overlay052/ov52_022561C0.c +++ b/src/overlay052/ov52_022561C0.c @@ -169,7 +169,7 @@ static BOOL ov52_022562F8 (UnkStruct_ov52_0225621C * param0) case 0: if (ov52_02256554(param0)) { if (ov52_02256684(param0)) { - FieldSystem * fieldSystem = PoketchSystem_FieldSystem(param0->unk_18); + FieldSystem * fieldSystem = PoketchSystem_GetFieldSystem(param0->unk_18); ov52_022567A4(param0->unk_14, 3); @@ -409,7 +409,7 @@ static void ov52_022565EC (UnkStruct_ov52_0225621C * param0) static void ov52_0225664C (UnkStruct_ov52_0225621C * param0) { if (param0->unk_20 == 0) { - sub_02037BC0(PoketchSystem_SaveData(param0->unk_18)); + sub_02037BC0(PoketchSystem_GetSaveData(param0->unk_18)); param0->unk_20 = 1; } } From 7050988583b912055133cac8a2948b3bca2d8cd5 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Tue, 18 Jun 2024 00:37:30 -0700 Subject: [PATCH 19/25] Cleaned up function find and replaces that got messed up in rebase --- src/overlay005/ov5_021EA714.c | 4 ++-- src/overlay040/ov40_0225645C.c | 2 +- src/overlay047/ov47_022561C0.c | 12 ++++++------ src/overlay048/ov48_022561C0.c | 10 +++++----- src/overlay052/ov52_022561C0.c | 12 ++++++------ src/overlay062/ov62_02236CBC.c | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/overlay005/ov5_021EA714.c b/src/overlay005/ov5_021EA714.c index 4924ba1c7..1ba9ca101 100644 --- a/src/overlay005/ov5_021EA714.c +++ b/src/overlay005/ov5_021EA714.c @@ -46,7 +46,7 @@ void ov5_021EA790 (FieldSystem * fieldSystem) if (PoketchData_IsEnabled(v0) && (sub_0206AE2C(v1) == 0)) { - ov25_02253D5C(fieldSystem->unk_04->unk_14); + PoketchSystem_StartShutdown(fieldSystem->unk_04->unk_14); } else { ov24_02253DA4(fieldSystem->unk_08); } @@ -59,7 +59,7 @@ u8 ov5_021EA7CC (FieldSystem * fieldSystem) if (PoketchData_IsEnabled(v0) && (sub_0206AE2C(v1) == 0)) { - if (ov25_02253D70(fieldSystem->unk_04->unk_14)) { + if (PoketchSystem_IsSystemShutdown(fieldSystem->unk_04->unk_14)) { fieldSystem->unk_04->unk_14 = NULL; Overlay_UnloadByID(FS_OVERLAY_ID(overlay25)); return 1; diff --git a/src/overlay040/ov40_0225645C.c b/src/overlay040/ov40_0225645C.c index 41a7a6122..5a3a1d04d 100644 --- a/src/overlay040/ov40_0225645C.c +++ b/src/overlay040/ov40_0225645C.c @@ -319,7 +319,7 @@ static void ov40_02256704 (SysTask * param0, void * param1) v0->unk_80 = 0; v0->unk_7C = 10; ov40_022567D8(v0); - ov25_02254424(1656); + PoketchSystem_PlaySoundEffect(1656); ov25_0225524C(param1); break; case 1: diff --git a/src/overlay047/ov47_022561C0.c b/src/overlay047/ov47_022561C0.c index 6435a6d87..5d9c50892 100644 --- a/src/overlay047/ov47_022561C0.c +++ b/src/overlay047/ov47_022561C0.c @@ -51,7 +51,7 @@ static BOOL ov47_02256584(UnkStruct_ov47_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov47_022561D4, ov47_022563B8); + PoketchSystem_SetAppFunctions(ov47_022561D4, ov47_022563B8); } static BOOL ov47_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -152,7 +152,7 @@ static void ov47_02256384 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov47_0225634C(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_74); + PoketchSystem_NotifyAppUnloaded(v1->unk_74); } } else { } @@ -183,7 +183,7 @@ static BOOL ov47_022563D4 (UnkStruct_ov47_0225621C * param0) break; case 1: if (ov47_02256890(param0->unk_70, 0)) { - ov25_0225424C(param0->unk_74); + PoketchSystem_NotifyAppLoaded(param0->unk_74); ov47_022563C0(param0, 1); } break; @@ -204,7 +204,7 @@ static BOOL ov47_02256414 (UnkStruct_ov47_0225621C * param0) param0->unk_04.unk_08 = ov47_02256584(param0); param0->unk_04.unk_28 = 0; - if (ov25_022544BC(&v0, &v1)) { + if (PoketchSystem_TappedDisplay(&v0, &v1)) { int v2, v3, v4, v5; for (v2 = 0; v2 < 6; v2++) { @@ -242,7 +242,7 @@ static BOOL ov47_022564A8 (UnkStruct_ov47_0225621C * param0) param0->unk_04.unk_08 = ov47_02256584(param0); - if (ov25_0225446C(&v0, &v1)) { + if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_00 = v0; param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_01 = v1; } else { @@ -299,7 +299,7 @@ static BOOL ov47_02256584 (UnkStruct_ov47_0225621C * param0) { BOOL v0 = 0; - if (ov25_02254534(param0->unk_74)) { + if (PoketchSystem_PlayerMoved(param0->unk_74)) { int v1, v2; inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_74), &v1, &v2); diff --git a/src/overlay048/ov48_022561C0.c b/src/overlay048/ov48_022561C0.c index 0477d50ae..78245df6e 100644 --- a/src/overlay048/ov48_022561C0.c +++ b/src/overlay048/ov48_022561C0.c @@ -170,7 +170,7 @@ static void ov48_022564E0(UnkStruct_ov48_0225621C * param0, PoketchSystem * para static void NitroStaticInit (void) { - ov25_02254238(ov48_022561D4, ov48_022562F0); + PoketchSystem_SetAppFunctions(ov48_022561D4, ov48_022562F0); } static BOOL ov48_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -230,7 +230,7 @@ static void ov48_022562BC (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov48_022562A8(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_AC); + PoketchSystem_NotifyAppUnloaded(v1->unk_AC); } } else { } @@ -261,7 +261,7 @@ static BOOL ov48_0225630C (UnkStruct_ov48_0225621C * param0) break; case 1: if (ov48_0225657C(param0->unk_A8, 0)) { - ov25_0225424C(param0->unk_AC); + PoketchSystem_NotifyAppLoaded(param0->unk_AC); ov48_022562F8(param0, 1); } break; @@ -282,7 +282,7 @@ static BOOL ov48_02256358 (UnkStruct_ov48_0225621C * param0) if (ov48_0225657C(param0->unk_A8, 2)) { u32 v0, v1; - if (ov25_022544BC(&v0, &v1)) { + if (PoketchSystem_TappedDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)192) & ((u32)(v1 - 16) < (u32)192)) { param0->unk_04.unk_08 = ov48_02256408(param0); ov48_02256558(param0->unk_A8, 2); @@ -337,7 +337,7 @@ static BOOL ov48_02256478 (UnkStruct_ov48_0225621C * param0) { BOOL v0 = 0; - if (ov25_02254534(param0->unk_AC)) { + if (PoketchSystem_PlayerMoved(param0->unk_AC)) { int v1, v2; inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_AC), &v1, &v2); diff --git a/src/overlay052/ov52_022561C0.c b/src/overlay052/ov52_022561C0.c index c70703ecc..63a1bc6e9 100644 --- a/src/overlay052/ov52_022561C0.c +++ b/src/overlay052/ov52_022561C0.c @@ -56,7 +56,7 @@ static BOOL ov52_02256684(UnkStruct_ov52_0225621C * param0); static void NitroStaticInit (void) { - ov25_02254238(ov52_022561D4, ov52_0225629C); + PoketchSystem_SetAppFunctions(ov52_022561D4, ov52_0225629C); } static BOOL ov52_022561D4 (void ** param0, PoketchSystem * param1, BGL * param2, u32 param3) @@ -118,7 +118,7 @@ static void ov52_02256260 (SysTask * param0, void * param1) if (v0[v1->unk_00](v1)) { ov52_0225624C(v1); SysTask_Done(param0); - ov25_02254260(v1->unk_18); + PoketchSystem_NotifyAppUnloaded(v1->unk_18); } } else { } @@ -149,7 +149,7 @@ static BOOL ov52_022562B8 (UnkStruct_ov52_0225621C * param0) break; case 1: if (ov52_022567C8(param0->unk_14, 0)) { - ov25_0225424C(param0->unk_18); + PoketchSystem_NotifyAppLoaded(param0->unk_18); ov52_022562A4(param0, 1); } break; @@ -179,7 +179,7 @@ static BOOL ov52_022562F8 (UnkStruct_ov52_0225621C * param0) ov52_022562A4(param0, 2); } } else { - ov25_02254424(1646); + PoketchSystem_PlaySoundEffect(1646); } } break; @@ -245,7 +245,7 @@ static BOOL ov52_02256430 (UnkStruct_ov52_0225621C * param0) return 1; } - if (ov25_02254534(param0->unk_18)) { + if (PoketchSystem_PlayerMoved(param0->unk_18)) { return 1; } @@ -331,7 +331,7 @@ static BOOL ov52_02256554 (UnkStruct_ov52_0225621C * param0) if (ov25_0225450C(param0->unk_18) == 0) { u32 v0, v1; - if (sub_020227C0(&v0, &v1)) { + if (TouchScreen_TapLocation(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(207 - 16)) & ((u32)(v1 - 16) < (u32)(175 - 16))) { return 1; } diff --git a/src/overlay062/ov62_02236CBC.c b/src/overlay062/ov62_02236CBC.c index 98af967a5..2c4e6bafd 100644 --- a/src/overlay062/ov62_02236CBC.c +++ b/src/overlay062/ov62_02236CBC.c @@ -676,7 +676,7 @@ static BOOL ov62_02237AC0 (UnkStruct_0208C06C * param0) u32 v1, v2; BOOL v3 = 0; - v3 = sub_020227C0(&v1, &v2); + v3 = TouchScreen_TapLocation(&v1, &v2); if (v3) { if ((v1 > 10 * 8) && (v1 < 22 * 8) && (v2 > 19 * 8) && (v2 < 22 * 8)) { From 32815d6a729f25a1e88b22bd43910bba47ba64f0 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Tue, 18 Jun 2024 00:40:41 -0700 Subject: [PATCH 20/25] Replaced touch with hold in function name --- include/overlay025/poketch_system.h | 2 +- src/overlay025/poketch_system.c | 2 +- src/overlay029/ov29_022561C0.c | 4 ++-- src/overlay031/ov31_022561C0.c | 2 +- src/overlay032/ov32_022561C0.c | 2 +- src/overlay033/ov33_022561C0.c | 2 +- src/overlay041/ov41_022561C0.c | 4 ++-- src/overlay047/ov47_022561C0.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 9c1be094f..deb2fc308 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -128,7 +128,7 @@ void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *sa UnkStruct_ov25_02254560 * ov25_02254418(void); void PoketchSystem_PlaySoundEffect(u32 soundID); void ov25_02254444(u32 param0, u32 param1); -BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y); +BOOL PoketchSystem_IsHoldingDisplay(u32 *x, u32 *y); BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y); BOOL ov25_0225450C(const PoketchSystem *poketchSys); void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager * param1); diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 9af4c2781..13cd9aee4 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -700,7 +700,7 @@ static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y) return FALSE; } -BOOL PoketchSystem_IsTouchingDisplay(u32 *x, u32 *y) +BOOL PoketchSystem_IsHoldingDisplay(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); diff --git a/src/overlay029/ov29_022561C0.c b/src/overlay029/ov29_022561C0.c index e34ef4b0f..9107562ed 100644 --- a/src/overlay029/ov29_022561C0.c +++ b/src/overlay029/ov29_022561C0.c @@ -208,7 +208,7 @@ static BOOL ov29_02256404 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -228,7 +228,7 @@ static BOOL ov29_02256460 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay031/ov31_022561C0.c b/src/overlay031/ov31_022561C0.c index a2557e5f9..2b30ecdad 100644 --- a/src/overlay031/ov31_022561C0.c +++ b/src/overlay031/ov31_022561C0.c @@ -254,7 +254,7 @@ static BOOL ov31_0225646C (UnkStruct_ov31_02256228 * param0) if (ov31_022565B4(param0->unk_1EC, 1)) { u32 v0, v1; - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { if ((v0 >= 16) && (v1 >= 16)) { v0 = (v0 - 16) / 8; v1 = (v1 - 16) / 8; diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 9b5789ab2..3ed5145e9 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -153,7 +153,7 @@ static BOOL ov32_02256308 (UnkStruct_ov32_0225621C * param0) } if (ov32_0225655C(param0->unk_74, 2)) { - param0->unk_04.unk_64 = PoketchSystem_IsTouchingDisplay(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); + param0->unk_04.unk_64 = PoketchSystem_IsHoldingDisplay(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); if (param0->unk_04.unk_64) { param0->unk_04.unk_66 = TouchScreen_Tapped(); diff --git a/src/overlay033/ov33_022561C0.c b/src/overlay033/ov33_022561C0.c index 4c69ef9ad..16d695c16 100644 --- a/src/overlay033/ov33_022561C0.c +++ b/src/overlay033/ov33_022561C0.c @@ -210,7 +210,7 @@ static BOOL ov33_022563D0 (UnkStruct_ov33_0225621C * param0) return 0; } - param0->unk_04.unk_4C = PoketchSystem_IsTouchingDisplay(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); + param0->unk_04.unk_4C = PoketchSystem_IsHoldingDisplay(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); if (param0->unk_04.unk_4C) { if (((u32)(param0->unk_04.unk_50 - 16) < (u32)(207 - 16)) & ((u32)(param0->unk_04.unk_54 - 16) < (u32)(175 - 16))) { diff --git a/src/overlay041/ov41_022561C0.c b/src/overlay041/ov41_022561C0.c index 9ba3efbe4..2af45aa93 100644 --- a/src/overlay041/ov41_022561C0.c +++ b/src/overlay041/ov41_022561C0.c @@ -283,7 +283,7 @@ static BOOL ov41_02256564 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -304,7 +304,7 @@ static BOOL ov41_022565C4 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay047/ov47_022561C0.c b/src/overlay047/ov47_022561C0.c index 5d9c50892..9633e52e4 100644 --- a/src/overlay047/ov47_022561C0.c +++ b/src/overlay047/ov47_022561C0.c @@ -242,7 +242,7 @@ static BOOL ov47_022564A8 (UnkStruct_ov47_0225621C * param0) param0->unk_04.unk_08 = ov47_02256584(param0); - if (PoketchSystem_IsTouchingDisplay(&v0, &v1)) { + if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_00 = v0; param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_01 = v1; } else { From faf359cdc10384282b134869b76a62ef4c546a5d Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Wed, 19 Jun 2024 19:46:21 -0700 Subject: [PATCH 21/25] Some functions and variables renamed for clarity, unnecessary parentheses removed, and PoketchSystem_IsAppShutdown simplified --- include/overlay025/poketch_system.h | 26 +++++++-------- include/touch_screen.h | 4 +-- src/overlay019/ov19_021D603C.c | 2 +- src/overlay025/poketch_system.c | 52 +++++++++++++---------------- src/overlay029/ov29_022561C0.c | 4 +-- src/overlay031/ov31_022561C0.c | 2 +- src/overlay032/ov32_022561C0.c | 2 +- src/overlay033/ov33_022561C0.c | 2 +- src/overlay034/ov34_022561C0.c | 4 +-- src/overlay040/ov40_022561C0.c | 2 +- src/overlay041/ov41_022561C0.c | 4 +-- src/overlay042/ov42_022561C0.c | 2 +- src/overlay047/ov47_022561C0.c | 6 ++-- src/overlay048/ov48_022561C0.c | 4 +-- src/overlay049/ov49_022561C0.c | 2 +- src/overlay052/ov52_022561C0.c | 4 +-- src/overlay056/ov56_022561C0.c | 2 +- src/overlay062/ov62_02231690.c | 4 +-- src/overlay062/ov62_02236CBC.c | 2 +- src/overlay076/ov76_0223B140.c | 2 +- src/overlay076/ov76_0223D338.c | 2 +- src/overlay111/ov111_021D0D80.c | 2 +- src/overlay116/ov116_02262A8C.c | 2 +- src/touch_screen.c | 4 +-- 24 files changed, 68 insertions(+), 74 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index deb2fc308..28608ba08 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -39,13 +39,13 @@ enum ButtonDir { }; enum PoketchMainButton { - POKETCHSYSTEM_MAINBUTTON_UP, - // POKETCHSYSTEM_MAINBUTTON_DOWN, - POKETCHSYSTEM_MAINBUTTON_SCREEN = 2, + POKETCHSYSTEM_MAINBUTTON_UP = 0, + POKETCHSYSTEM_MAINBUTTON_DOWN, + POKETCHSYSTEM_MAINBUTTON_SCREEN, }; enum PoketchSystemState { - POKETCHSYSTEM_INIT, + POKETCHSYSTEM_INIT = 0, POKETCHSYSTEM_UPDATE, POKETCHSYSTEM_CHANGEAPP, POKETCHSYSTEM_SHUTDOWN, @@ -53,14 +53,14 @@ enum PoketchSystemState { }; enum PoketchAppState { - POKETCH_APP_STATE_NONE, + POKETCH_APP_STATE_NONE = 0, POKETCH_APP_STATE_INIT, POKETCH_APP_STATE_UPDATE, POKETCH_APP_STATE_SHUTDOWN }; enum PoketchBorderColor { - POKETCH_BORDER_PINK, + POKETCH_BORDER_PINK = 0, POKETCH_BORDER_BLUE }; @@ -74,16 +74,16 @@ enum PoketchFieldEventID { typedef struct PoketchSystem PoketchSystem; -typedef BOOL (* PoketchAppInitFunction)(void **, PoketchSystem *, BGL *, u32); -typedef void (* PoketchAppShutdownFunction)(void *); -typedef void (* PoketchAppSaveFunction)(void *); +typedef BOOL (* PoketchAppInitFunction)(void **app, PoketchSystem *poketchSys, BGL *bgl, u32 appID); +typedef void (* PoketchAppShutdownFunction)(void *app); +typedef void (* PoketchAppSaveFunction)(void *app); struct PoketchSystem { u8 systemState; u8 subState; // each systemState has its own sub-state machine, they all share this variable u8 appState; u8 touchingScreen; - u8 playerMoved; + u8 playerMoving; u8 appChanging; u8 unk_06; u8 pedometerUpdated; @@ -128,11 +128,11 @@ void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *sa UnkStruct_ov25_02254560 * ov25_02254418(void); void PoketchSystem_PlaySoundEffect(u32 soundID); void ov25_02254444(u32 param0, u32 param1); -BOOL PoketchSystem_IsHoldingDisplay(u32 *x, u32 *y); -BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y); +BOOL PoketchSystem_GetDisplayHeldCoords(u32 *x, u32 *y); +BOOL PoketchSystem_GetDisplayTappedCoords(u32 *x, u32 *y); BOOL ov25_0225450C(const PoketchSystem *poketchSys); void ov25_02254518(const PoketchSystem *poketchSys, PoketchButtonManager * param1); -BOOL PoketchSystem_PlayerMoved(const PoketchSystem *poketchSys); +BOOL PoketchSystem_IsPlayerMoving(const PoketchSystem *poketchSys); BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys); FieldSystem * PoketchSystem_GetFieldSystem(const PoketchSystem *poketchSys); PoketchData * PoketchSystem_GetPoketchData(const PoketchSystem *poketchSys); diff --git a/include/touch_screen.h b/include/touch_screen.h index 5fa6f41d0..322f63162 100644 --- a/include/touch_screen.h +++ b/include/touch_screen.h @@ -39,8 +39,8 @@ BOOL TouchScreen_Touched(void); * @return TRUE if the touch screen is tapped, FALSE otherwise. */ BOOL TouchScreen_Tapped(void); -BOOL TouchScreen_HoldLocation(u32 *x, u32 *y); -BOOL TouchScreen_TapLocation(u32 *x, u32 *y); +BOOL TouchScreen_GetHoldState(u32 *x, u32 *y); +BOOL TouchScreen_GetTapState(u32 *x, u32 *y); int sub_020227DC(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); BOOL sub_02022830(const TouchScreenHitTable *hitTable, u32 param1, u32 param2); diff --git a/src/overlay019/ov19_021D603C.c b/src/overlay019/ov19_021D603C.c index 97e1c24b4..eb0705f65 100644 --- a/src/overlay019/ov19_021D603C.c +++ b/src/overlay019/ov19_021D603C.c @@ -48,7 +48,7 @@ int ov19_021D60A8 (UnkStruct_ov19_021D6104 * param0) v0 = 1; v1 = (param0->unk_1C == 0); - if (TouchScreen_HoldLocation(&v2, &v3)) { + if (TouchScreen_GetHoldState(&v2, &v3)) { param0->unk_14 = v2; param0->unk_18 = v3; } diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index 13cd9aee4..fc34a0b07 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -166,7 +166,7 @@ void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID case POKETCH_FIELDEVENT_SLEEP: break; case POKETCH_FIELDEVENT_PLAYERMOVED: - poketchSys->playerMoved = TRUE; + poketchSys->playerMoving = TRUE; break; case POKETCH_FIELDEVENT_PEDOMETER:{ u32 step_count = PoketchData_StepCount(poketchSys->poketchData); @@ -203,7 +203,7 @@ static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) poketchSys->systemState = POKETCHSYSTEM_INIT; poketchSys->subState = 0; poketchSys->touchingScreen = FALSE; - poketchSys->playerMoved = 0; + poketchSys->playerMoving = 0; poketchSys->pedometerUpdated = FALSE; poketchSys->appChanging = FALSE; poketchSys->unk_06 = 0; @@ -263,7 +263,7 @@ static void PoketchSystem_PostRender(SysTask *, void *system) { PoketchSystem *poketchSys = system; - poketchSys->playerMoved = FALSE; + poketchSys->playerMoving = FALSE; poketchSys->pedometerUpdated = FALSE; } @@ -323,7 +323,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) } break; case 1: - if ((poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP) || (poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0)) { + if (poketchSys->buttonState == BUTTON_MANAGER_STATE_TAP || poketchSys->buttonState == BUTTON_MANAGER_STATE_TIMER0) { poketchSys->skipApp = TRUE; } @@ -512,11 +512,7 @@ static void PoketchSystem_ShutdownApp(PoketchSystem *poketchSys) static BOOL PoketchSystem_IsAppShutdown(PoketchSystem *poketchSys) { - if (poketchSys->appState == POKETCH_APP_STATE_NONE) { - return TRUE; - } - - return FALSE; + return poketchSys->appState == POKETCH_APP_STATE_NONE; } void PoketchSystem_SetAppFunctions(PoketchAppInitFunction appInit, PoketchAppShutdownFunction appShutdown) @@ -549,17 +545,17 @@ void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *sa } static const TouchScreenHitTable sMainPoketchButtons[] = { - {POKETCH_BUTTON_TOP_MINY, POKETCH_BUTTON_TOP_MAXY, POKETCH_BUTTON_TOP_MINX, POKETCH_BUTTON_TOP_MAXX}, // Top button - {POKETCH_BUTTON_BOTTOM_MINY, POKETCH_BUTTON_BOTTOM_MAXY, POKETCH_BUTTON_BOTTOM_MINX, POKETCH_BUTTON_BOTTOM_MAXX}, // Bottom Button - {POKETCH_SCREEN_MINY, POKETCH_SCREEN_MAXY, POKETCH_SCREEN_MINX, POKETCH_SCREEN_MAXX} // Screen + [POKETCHSYSTEM_MAINBUTTON_UP] = {POKETCH_BUTTON_TOP_MINY, POKETCH_BUTTON_TOP_MAXY, POKETCH_BUTTON_TOP_MINX, POKETCH_BUTTON_TOP_MAXX}, // Top button + [POKETCHSYSTEM_MAINBUTTON_DOWN] = {POKETCH_BUTTON_BOTTOM_MINY, POKETCH_BUTTON_BOTTOM_MAXY, POKETCH_BUTTON_BOTTOM_MINX, POKETCH_BUTTON_BOTTOM_MAXX}, // Bottom Button + [POKETCHSYSTEM_MAINBUTTON_SCREEN] = {POKETCH_SCREEN_MINY, POKETCH_SCREEN_MAXY, POKETCH_SCREEN_MINX, POKETCH_SCREEN_MAXX} // Screen }; static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) { - poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), PoketchSystem_OnButtonEvent, poketchSys, 7); + poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), PoketchSystem_OnButtonEvent, poketchSys, HEAP_ID_POKETCH_MAIN); if (poketchSys->buttonManager != NULL) { - PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, 0, 0, 7); + PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, POKETCHSYSTEM_MAINBUTTON_UP, 0, 7); poketchSys->unk_2C = 0xffffffff; poketchSys->unk_30 = 0xffffffff; return TRUE; @@ -597,10 +593,8 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch } if (buttonID == POKETCHSYSTEM_MAINBUTTON_SCREEN) { - if (ov25_0225450C(poketchSys)) { - if (touchEvent == BUTTON_TOUCH_RELEASED) { - Sound_PlayEffect(SEQ_SE_DP_BEEP); - } + if (ov25_0225450C(poketchSys) && touchEvent == BUTTON_TOUCH_RELEASED) { + Sound_PlayEffect(SEQ_SE_DP_BEEP); } } else { u32 v1 = 0xffffffff; @@ -639,12 +633,12 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch PoketchButtonManager_ResetButtonState(poketchSys->buttonManager, 0); break; case BUTTON_MANAGER_STATE_TAP: - if ((poketchSys->unk_30 == 6) || (poketchSys->unk_30 == 9)) { + if (poketchSys->unk_30 == 6 || poketchSys->unk_30 == 9) { buttonEvent = BUTTON_MANAGER_STATE_NULL; } break; case BUTTON_MANAGER_STATE_SLIDEOUT: - if ((poketchSys->unk_30 == 7) || (poketchSys->unk_30 == 10)) { + if (poketchSys->unk_30 == 7 || poketchSys->unk_30 == 10) { buttonEvent = BUTTON_MANAGER_STATE_TAP; } break; @@ -700,25 +694,25 @@ static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y) return FALSE; } -BOOL PoketchSystem_IsHoldingDisplay(u32 *x, u32 *y) +BOOL PoketchSystem_GetDisplayHeldCoords(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { - if (TouchScreen_HoldLocation(x, y)) { - return PoketchSystem_InsideScreenBounds(*x, *y); - } + if (poketchSys->appChanging == FALSE + && ov25_0225450C(poketchSys) == 0 + && TouchScreen_GetHoldState(x, y)) { + return PoketchSystem_InsideScreenBounds(*x, *y); } return FALSE; } -BOOL PoketchSystem_TappedDisplay(u32 *x, u32 *y) +BOOL PoketchSystem_GetDisplayTappedCoords(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { - if (TouchScreen_TapLocation(x, y)) { + if (TouchScreen_GetTapState(x, y)) { return PoketchSystem_InsideScreenBounds(*x, *y); } } @@ -738,9 +732,9 @@ void ov25_02254518 (const PoketchSystem *poketchSys, PoketchButtonManager *butto } } -BOOL PoketchSystem_PlayerMoved(const PoketchSystem *poketchSys) +BOOL PoketchSystem_IsPlayerMoving(const PoketchSystem *poketchSys) { - return poketchSys->playerMoved; + return poketchSys->playerMoving; } BOOL PoketchSystem_PedometerUpdated(const PoketchSystem *poketchSys) diff --git a/src/overlay029/ov29_022561C0.c b/src/overlay029/ov29_022561C0.c index 9107562ed..d8c847d7a 100644 --- a/src/overlay029/ov29_022561C0.c +++ b/src/overlay029/ov29_022561C0.c @@ -208,7 +208,7 @@ static BOOL ov29_02256404 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -228,7 +228,7 @@ static BOOL ov29_02256460 (UnkStruct_ov29_0225621C * param0) { u32 v0, v1; - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(172 - 16)) & ((u32)(v1 - 16) < (u32)(166 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay031/ov31_022561C0.c b/src/overlay031/ov31_022561C0.c index 2b30ecdad..796ee9aab 100644 --- a/src/overlay031/ov31_022561C0.c +++ b/src/overlay031/ov31_022561C0.c @@ -254,7 +254,7 @@ static BOOL ov31_0225646C (UnkStruct_ov31_02256228 * param0) if (ov31_022565B4(param0->unk_1EC, 1)) { u32 v0, v1; - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { if ((v0 >= 16) && (v1 >= 16)) { v0 = (v0 - 16) / 8; v1 = (v1 - 16) / 8; diff --git a/src/overlay032/ov32_022561C0.c b/src/overlay032/ov32_022561C0.c index 3ed5145e9..7292339e4 100644 --- a/src/overlay032/ov32_022561C0.c +++ b/src/overlay032/ov32_022561C0.c @@ -153,7 +153,7 @@ static BOOL ov32_02256308 (UnkStruct_ov32_0225621C * param0) } if (ov32_0225655C(param0->unk_74, 2)) { - param0->unk_04.unk_64 = PoketchSystem_IsHoldingDisplay(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); + param0->unk_04.unk_64 = PoketchSystem_GetDisplayHeldCoords(&(param0->unk_04.unk_68), &(param0->unk_04.unk_6C)); if (param0->unk_04.unk_64) { param0->unk_04.unk_66 = TouchScreen_Tapped(); diff --git a/src/overlay033/ov33_022561C0.c b/src/overlay033/ov33_022561C0.c index 16d695c16..588fbdd49 100644 --- a/src/overlay033/ov33_022561C0.c +++ b/src/overlay033/ov33_022561C0.c @@ -210,7 +210,7 @@ static BOOL ov33_022563D0 (UnkStruct_ov33_0225621C * param0) return 0; } - param0->unk_04.unk_4C = PoketchSystem_IsHoldingDisplay(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); + param0->unk_04.unk_4C = PoketchSystem_GetDisplayHeldCoords(¶m0->unk_04.unk_50, ¶m0->unk_04.unk_54); if (param0->unk_04.unk_4C) { if (((u32)(param0->unk_04.unk_50 - 16) < (u32)(207 - 16)) & ((u32)(param0->unk_04.unk_54 - 16) < (u32)(175 - 16))) { diff --git a/src/overlay034/ov34_022561C0.c b/src/overlay034/ov34_022561C0.c index 324b41721..5d5efb724 100644 --- a/src/overlay034/ov34_022561C0.c +++ b/src/overlay034/ov34_022561C0.c @@ -168,7 +168,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) break; } - if ((PoketchSystem_PlayerMoved(param0->unk_4C) == 1) || (ov25_0225450C(param0->unk_4C))) { + if ((PoketchSystem_IsPlayerMoving(param0->unk_4C) == 1) || (ov25_0225450C(param0->unk_4C))) { ov34_02256A0C(param0->unk_48); param0->unk_01 = 2; break; @@ -201,7 +201,7 @@ static BOOL ov34_022562F0 (UnkStruct_ov34_0225621C * param0) static BOOL ov34_022563E4 (UnkStruct_ov34_0225621C * param0, u32 * param1, u32 * param2) { if (ov25_0225450C(param0->unk_4C) == 0) { - if (TouchScreen_TapLocation(param1, param2)) { + if (TouchScreen_GetTapState(param1, param2)) { if (((u32)((*param1) - 24) < (u32)(200 - 24)) & ((u32)((*param2) - 24) < (u32)(168 - 24))) { return 1; } diff --git a/src/overlay040/ov40_022561C0.c b/src/overlay040/ov40_022561C0.c index 1b894b6e1..c51ef042e 100644 --- a/src/overlay040/ov40_022561C0.c +++ b/src/overlay040/ov40_022561C0.c @@ -193,7 +193,7 @@ static BOOL ov40_02256388 (UnkStruct_ov40_0225621C * param0) if (ov25_0225450C(param0->unk_2C) == 0) { u32 v0, v1; - if (TouchScreen_TapLocation(&v0, &v1)) { + if (TouchScreen_GetTapState(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(207 - 16)) & ((u32)(v1 - 16) < (u32)(175 - 16))) { return 1; } diff --git a/src/overlay041/ov41_022561C0.c b/src/overlay041/ov41_022561C0.c index 2af45aa93..36eb95040 100644 --- a/src/overlay041/ov41_022561C0.c +++ b/src/overlay041/ov41_022561C0.c @@ -283,7 +283,7 @@ static BOOL ov41_02256564 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; @@ -304,7 +304,7 @@ static BOOL ov41_022565C4 (UnkStruct_ov41_02256220 * param0) { u32 v0, v1; - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(171 - 16)) & ((u32)(v1 - 16) < (u32)(165 - 16))) { v0 = (v0 - 16) >> 1; v1 = (v1 - 16) >> 1; diff --git a/src/overlay042/ov42_022561C0.c b/src/overlay042/ov42_022561C0.c index 8fcea69fc..0c480ba0b 100644 --- a/src/overlay042/ov42_022561C0.c +++ b/src/overlay042/ov42_022561C0.c @@ -187,7 +187,7 @@ static BOOL ov42_02256398 (void) { u32 x, y; - if (PoketchSystem_TappedDisplay(&x, &y)) { + if (PoketchSystem_GetDisplayTappedCoords(&x, &y)) { x = (112 - x) * (112 - x); y = (144 - y) * (144 - y); diff --git a/src/overlay047/ov47_022561C0.c b/src/overlay047/ov47_022561C0.c index 9633e52e4..8aa3990ff 100644 --- a/src/overlay047/ov47_022561C0.c +++ b/src/overlay047/ov47_022561C0.c @@ -204,7 +204,7 @@ static BOOL ov47_02256414 (UnkStruct_ov47_0225621C * param0) param0->unk_04.unk_08 = ov47_02256584(param0); param0->unk_04.unk_28 = 0; - if (PoketchSystem_TappedDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayTappedCoords(&v0, &v1)) { int v2, v3, v4, v5; for (v2 = 0; v2 < 6; v2++) { @@ -242,7 +242,7 @@ static BOOL ov47_022564A8 (UnkStruct_ov47_0225621C * param0) param0->unk_04.unk_08 = ov47_02256584(param0); - if (PoketchSystem_IsHoldingDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayHeldCoords(&v0, &v1)) { param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_00 = v0; param0->unk_04.unk_0C[param0->unk_04.unk_24].unk_01 = v1; } else { @@ -299,7 +299,7 @@ static BOOL ov47_02256584 (UnkStruct_ov47_0225621C * param0) { BOOL v0 = 0; - if (PoketchSystem_PlayerMoved(param0->unk_74)) { + if (PoketchSystem_IsPlayerMoving(param0->unk_74)) { int v1, v2; inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_74), &v1, &v2); diff --git a/src/overlay048/ov48_022561C0.c b/src/overlay048/ov48_022561C0.c index 78245df6e..b935fa293 100644 --- a/src/overlay048/ov48_022561C0.c +++ b/src/overlay048/ov48_022561C0.c @@ -282,7 +282,7 @@ static BOOL ov48_02256358 (UnkStruct_ov48_0225621C * param0) if (ov48_0225657C(param0->unk_A8, 2)) { u32 v0, v1; - if (PoketchSystem_TappedDisplay(&v0, &v1)) { + if (PoketchSystem_GetDisplayTappedCoords(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)192) & ((u32)(v1 - 16) < (u32)192)) { param0->unk_04.unk_08 = ov48_02256408(param0); ov48_02256558(param0->unk_A8, 2); @@ -337,7 +337,7 @@ static BOOL ov48_02256478 (UnkStruct_ov48_0225621C * param0) { BOOL v0 = 0; - if (PoketchSystem_PlayerMoved(param0->unk_AC)) { + if (PoketchSystem_IsPlayerMoving(param0->unk_AC)) { int v1, v2; inline_ov47_0225621C(PoketchSystem_GetFieldSystem(param0->unk_AC), &v1, &v2); diff --git a/src/overlay049/ov49_022561C0.c b/src/overlay049/ov49_022561C0.c index e8a9e0e00..5a852ba7b 100644 --- a/src/overlay049/ov49_022561C0.c +++ b/src/overlay049/ov49_022561C0.c @@ -168,7 +168,7 @@ static BOOL ov49_02256348 (UnkStruct_ov49_0225621C * param0) if (ov25_0225450C(param0->unk_0C) == 0) { u32 v0, v1; - if (TouchScreen_HoldLocation(&v0, &v1)) { + if (TouchScreen_GetHoldState(&v0, &v1)) { if ((136 <= v1) && (v1 < 160) && (48 <= v0) && (v0 < 184)) { u32 v2 = (v0 - 48) / 16; diff --git a/src/overlay052/ov52_022561C0.c b/src/overlay052/ov52_022561C0.c index 63a1bc6e9..62bf8c0d4 100644 --- a/src/overlay052/ov52_022561C0.c +++ b/src/overlay052/ov52_022561C0.c @@ -245,7 +245,7 @@ static BOOL ov52_02256430 (UnkStruct_ov52_0225621C * param0) return 1; } - if (PoketchSystem_PlayerMoved(param0->unk_18)) { + if (PoketchSystem_IsPlayerMoving(param0->unk_18)) { return 1; } @@ -331,7 +331,7 @@ static BOOL ov52_02256554 (UnkStruct_ov52_0225621C * param0) if (ov25_0225450C(param0->unk_18) == 0) { u32 v0, v1; - if (TouchScreen_TapLocation(&v0, &v1)) { + if (TouchScreen_GetTapState(&v0, &v1)) { if (((u32)(v0 - 16) < (u32)(207 - 16)) & ((u32)(v1 - 16) < (u32)(175 - 16))) { return 1; } diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index ae5670253..8c67e13c8 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -656,7 +656,7 @@ static int ov56_02256BC0 (UnkStruct_ov56_02256468 * param0) switch (v0) { case 0: ov56_0225717C(param0, 0); - TouchScreen_HoldLocation(&v1, &v2); + TouchScreen_GetHoldState(&v1, &v2); ov56_02256994(param0->unk_1FC[2], v2); if (param0->unk_2D8.unk_00 > 3) { diff --git a/src/overlay062/ov62_02231690.c b/src/overlay062/ov62_02231690.c index df6d9a5a8..225c606d5 100644 --- a/src/overlay062/ov62_02231690.c +++ b/src/overlay062/ov62_02231690.c @@ -2462,7 +2462,7 @@ void ov62_02233664 (UnkStruct_ov62_0223359C * param0) BOOL v3; BOOL v4 = 0; - v3 = TouchScreen_HoldLocation(&v0, &v1); + v3 = TouchScreen_GetHoldState(&v0, &v1); if (param0->unk_14) { sub_0200D33C(param0->unk_18[0]); @@ -3290,7 +3290,7 @@ static void ov62_02234440 (UnkStruct_0208C06C * param0) param0->unk_41D8.unk_00 = 1; param0->unk_41D8.unk_04 = 0; - TouchScreen_TapLocation(&v0, &v1); + TouchScreen_GetTapState(&v0, &v1); sub_0208BA30(param0->unk_41D8.unk_08); sub_0208B8B0(param0->unk_41D8.unk_08, 1); sub_0208B9E0(param0->unk_41D8.unk_08, 1); diff --git a/src/overlay062/ov62_02236CBC.c b/src/overlay062/ov62_02236CBC.c index 2c4e6bafd..1aba9635a 100644 --- a/src/overlay062/ov62_02236CBC.c +++ b/src/overlay062/ov62_02236CBC.c @@ -676,7 +676,7 @@ static BOOL ov62_02237AC0 (UnkStruct_0208C06C * param0) u32 v1, v2; BOOL v3 = 0; - v3 = TouchScreen_TapLocation(&v1, &v2); + v3 = TouchScreen_GetTapState(&v1, &v2); if (v3) { if ((v1 > 10 * 8) && (v1 < 22 * 8) && (v2 > 19 * 8) && (v2 < 22 * 8)) { diff --git a/src/overlay076/ov76_0223B140.c b/src/overlay076/ov76_0223B140.c index 222f13d7e..5ece854f0 100644 --- a/src/overlay076/ov76_0223B140.c +++ b/src/overlay076/ov76_0223B140.c @@ -116,7 +116,7 @@ int ov76_0223B278 (UnkStruct_ov76_0223DE00 * param0, u8 param1) param0->unk_324[v0].unk_05 = 190; param0->unk_324[v0].unk_06 = 70; - TouchScreen_HoldLocation(&v1, &v2); + TouchScreen_GetHoldState(&v1, &v2); param0->unk_324[v0].unk_05 = v1; param0->unk_324[v0].unk_06 = v2; diff --git a/src/overlay076/ov76_0223D338.c b/src/overlay076/ov76_0223D338.c index 3930db079..f0cb928c3 100644 --- a/src/overlay076/ov76_0223D338.c +++ b/src/overlay076/ov76_0223D338.c @@ -1166,7 +1166,7 @@ static BOOL ov76_0223DF94 (UnkStruct_ov76_0223DE00 * param0) BOOL v14; v13 = param0->unk_D4.unk_00; - v14 = TouchScreen_HoldLocation(&v11, &v12); + v14 = TouchScreen_GetHoldState(&v11, &v12); if (v14) { int v15; diff --git a/src/overlay111/ov111_021D0D80.c b/src/overlay111/ov111_021D0D80.c index 5c678f77a..da265202c 100644 --- a/src/overlay111/ov111_021D0D80.c +++ b/src/overlay111/ov111_021D0D80.c @@ -535,7 +535,7 @@ static BOOL ov111_021D10B8 (UnkStruct_ov111_021D0F7C * param0) param0->unk_15[param0->unk_0E] = v3; param0->unk_0E++; - TouchScreen_HoldLocation(&v0, &v1); + TouchScreen_GetHoldState(&v0, &v1); sub_0200E084(¶m0->unk_5C[15], 0); GXLayers_EngineBToggleLayers((GX_PLANEMASK_BG0), 0); param0->unk_08 = 2; diff --git a/src/overlay116/ov116_02262A8C.c b/src/overlay116/ov116_02262A8C.c index 3473215a5..56211d697 100644 --- a/src/overlay116/ov116_02262A8C.c +++ b/src/overlay116/ov116_02262A8C.c @@ -1008,7 +1008,7 @@ void ov116_02263BA0 (UnkStruct_ov116_02262A8C * param0) u32 v0, v1; s16 v2, v3; BOOL v4; - BOOL v5 = TouchScreen_HoldLocation(&v0, &v1); + BOOL v5 = TouchScreen_GetHoldState(&v0, &v1); TouchScreenHitTable * v6; int v7; diff --git a/src/touch_screen.c b/src/touch_screen.c index 3d54b391f..db8d1cfb9 100644 --- a/src/touch_screen.c +++ b/src/touch_screen.c @@ -139,7 +139,7 @@ BOOL TouchScreen_Tapped(void) return gCoreSys.touchPressed; } -BOOL TouchScreen_HoldLocation(u32 *x, u32 *y) +BOOL TouchScreen_GetHoldState(u32 *x, u32 *y) { if (gCoreSys.touchHeld) { *x = gCoreSys.touchX; @@ -150,7 +150,7 @@ BOOL TouchScreen_HoldLocation(u32 *x, u32 *y) return FALSE; } -BOOL TouchScreen_TapLocation(u32 * x, u32 * y) +BOOL TouchScreen_GetTapState(u32 * x, u32 * y) { if (gCoreSys.touchPressed) { *x = gCoreSys.touchX; From 0580004e9f67cb067bcaaa012773fc3dab1a2c61 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Wed, 19 Jun 2024 20:27:55 -0700 Subject: [PATCH 22/25] Addressed remaining comments on PR (a couple missed extra parentheses & renaming a constant from poketch_button.h --- include/overlay025/poketch_button.h | 2 +- src/overlay025/poketch_button.c | 2 +- src/overlay025/poketch_system.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/overlay025/poketch_button.h b/include/overlay025/poketch_button.h index 875cb8ea1..533ce8754 100644 --- a/include/overlay025/poketch_button.h +++ b/include/overlay025/poketch_button.h @@ -11,7 +11,7 @@ typedef void (* PoketchButtonCallback)(u32, u32, u32, void *); enum ButtonManagerState { BUTTON_MANAGER_STATE_NULL = 0, BUTTON_MANAGER_STATE_TOUCH, - BUTTON_MANAGER_STATE_SLIDEOUT, // Slid touch off of button but did not release + BUTTON_MANAGER_STATE_DRAGGING, // Slid touch off of button but did not release BUTTON_MANAGER_STATE_TAP, BUTTON_MANAGER_STATE_DOUBLETAP, BUTTON_MANAGER_STATE_TIMER0, diff --git a/src/overlay025/poketch_button.c b/src/overlay025/poketch_button.c index 5bae7b8ed..87736978f 100644 --- a/src/overlay025/poketch_button.c +++ b/src/overlay025/poketch_button.c @@ -205,7 +205,7 @@ static u32 Button_OnPressed(PoketchButton *button, BOOL touched, BOOL tapped) } } else if (touched) { PoketchButton_ChangeState(button, BUTTON_STATE_IDLE); - return BUTTON_MANAGER_STATE_SLIDEOUT; + return BUTTON_MANAGER_STATE_DRAGGING; } else { // We don't reset the timer because we want to check for double tap with the same timer if (button->doubleTapTime) { diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index fc34a0b07..cf0be9db4 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -26,7 +26,7 @@ #include "unk_020508D4.h" #include "unk_02099D44.h" #include "overlay025/ov25_02254560.h" -#include "constants/sdat.h" +#include "consts/sdat.h" #include "gender.h" FS_EXTERN_OVERLAY(overlay26); @@ -229,7 +229,7 @@ static void PoketchSystem_Shutdown (PoketchSystem *poketchSys) ov25_02254754(poketchSys->unk_1C); } -typedef void (*const PoketchEvent)(PoketchSystem *); +typedef void (*const PoketchEvent)(PoketchSystem *poketchSys); static PoketchEvent sPoketchEvents[] = { PoketchEvent_InitApp, PoketchEvent_UpdateApp, @@ -637,7 +637,7 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch buttonEvent = BUTTON_MANAGER_STATE_NULL; } break; - case BUTTON_MANAGER_STATE_SLIDEOUT: + case BUTTON_MANAGER_STATE_DRAGGING: if (poketchSys->unk_30 == 7 || poketchSys->unk_30 == 10) { buttonEvent = BUTTON_MANAGER_STATE_TAP; } @@ -698,8 +698,8 @@ BOOL PoketchSystem_GetDisplayHeldCoords(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if (poketchSys->appChanging == FALSE - && ov25_0225450C(poketchSys) == 0 + if (!poketchSys->appChanging + && !ov25_0225450C(poketchSys) && TouchScreen_GetHoldState(x, y)) { return PoketchSystem_InsideScreenBounds(*x, *y); } @@ -711,10 +711,10 @@ BOOL PoketchSystem_GetDisplayTappedCoords(u32 *x, u32 *y) { PoketchSystem *poketchSys = PoketchSystem_GetFromFieldSystem(); - if ((poketchSys->appChanging == FALSE) && (ov25_0225450C(poketchSys) == 0)) { - if (TouchScreen_GetTapState(x, y)) { - return PoketchSystem_InsideScreenBounds(*x, *y); - } + if (!poketchSys->appChanging + && !ov25_0225450C(poketchSys) + && TouchScreen_GetTapState(x, y)) { + return PoketchSystem_InsideScreenBounds(*x, *y); } return FALSE; From 450ff9b6e2ae0c3792762965edf792547f49264b Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Wed, 19 Jun 2024 21:55:26 -0700 Subject: [PATCH 23/25] more name corrections, and renamed several consts with more underscore/word separation --- include/overlay025/poketch_button.h | 8 ++--- include/overlay025/poketch_system.h | 52 ++++++++++++++--------------- src/overlay025/poketch_button.c | 6 ++-- src/overlay025/poketch_system.c | 44 ++++++++++++------------ 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/include/overlay025/poketch_button.h b/include/overlay025/poketch_button.h index 533ce8754..eca36dca2 100644 --- a/include/overlay025/poketch_button.h +++ b/include/overlay025/poketch_button.h @@ -11,9 +11,9 @@ typedef void (* PoketchButtonCallback)(u32, u32, u32, void *); enum ButtonManagerState { BUTTON_MANAGER_STATE_NULL = 0, BUTTON_MANAGER_STATE_TOUCH, - BUTTON_MANAGER_STATE_DRAGGING, // Slid touch off of button but did not release + BUTTON_MANAGER_STATE_DRAGGING, BUTTON_MANAGER_STATE_TAP, - BUTTON_MANAGER_STATE_DOUBLETAP, + BUTTON_MANAGER_STATE_DOUBLE_TAP, BUTTON_MANAGER_STATE_TIMER0, BUTTON_MANAGER_STATE_TIMER1, BUTTON_MANAGER_STATE_REPEAT, @@ -30,8 +30,8 @@ enum ButtonTouchState { enum ButtonEventState { BUTTON_STATE_IDLE = 0, BUTTON_STATE_TAP, - BUTTON_STATE_CHECK_DOUBLETAP, - BUTTON_STATE_DOUBLETAP, + BUTTON_STATE_CHECK_DOUBLE_TAP, + BUTTON_STATE_DOUBLE_TAP, BUTTON_STATE_RESET, }; diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index 28608ba08..a3c08c7c8 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_POKETCHSYSTEM_H -#define POKEPLATINUM_POKETCHSYSTEM_H +#ifndef POKEPLATINUM_POKETCH_SYSTEM_H +#define POKEPLATINUM_POKETCH_SYSTEM_H #include "struct_decls/struct_02018340_decl.h" #include "field/field_system_decl.h" @@ -15,23 +15,23 @@ #define POKETCH_PEDOMETER_MAX 99999 -#define POKETCH_SCREEN_MINX 16 -#define POKETCH_SCREEN_MAXX 207 +#define POKETCH_SCREEN_MIN_X 16 +#define POKETCH_SCREEN_MAX_X 207 -#define POKETCH_SCREEN_MINY 16 -#define POKETCH_SCREEN_MAXY 175 +#define POKETCH_SCREEN_MIN_Y 16 +#define POKETCH_SCREEN_MAX_Y 175 -#define POKETCH_BUTTON_TOP_MINX 224 -#define POKETCH_BUTTON_TOP_MAXX 255 +#define POKETCH_BUTTON_TOP_MIN_X 224 +#define POKETCH_BUTTON_TOP_MAX_X 255 -#define POKETCH_BUTTON_TOP_MINY 32 -#define POKETCH_BUTTON_TOP_MAXY 96 +#define POKETCH_BUTTON_TOP_MIN_Y 32 +#define POKETCH_BUTTON_TOP_MAX_Y 96 -#define POKETCH_BUTTON_BOTTOM_MINX 224 -#define POKETCH_BUTTON_BOTTOM_MAXX 255 +#define POKETCH_BUTTON_BOTTOM_MIN_X 224 +#define POKETCH_BUTTON_BOTTOM_MAX_X 255 -#define POKETCH_BUTTON_BOTTOM_MINY 96 -#define POKETCH_BUTTON_BOTTOM_MAXY 160 +#define POKETCH_BUTTON_BOTTOM_MIN_Y 96 +#define POKETCH_BUTTON_BOTTOM_MAX_Y 160 enum ButtonDir { BUTTON_UP, @@ -39,17 +39,17 @@ enum ButtonDir { }; enum PoketchMainButton { - POKETCHSYSTEM_MAINBUTTON_UP = 0, - POKETCHSYSTEM_MAINBUTTON_DOWN, - POKETCHSYSTEM_MAINBUTTON_SCREEN, + POKETCH_SYSTEM_MAIN_BUTTON_UP = 0, + POKETCH_SYSTEM_MAIN_BUTTON_DOWN, + POKETCH_SYSTEM_MAIN_BUTTON_SCREEN, }; enum PoketchSystemState { - POKETCHSYSTEM_INIT = 0, - POKETCHSYSTEM_UPDATE, - POKETCHSYSTEM_CHANGEAPP, - POKETCHSYSTEM_SHUTDOWN, - POKETCHSYSTEM_UNLOAD + POKETCH_SYSTEM_INIT = 0, + POKETCH_SYSTEM_UPDATE, + POKETCH_SYSTEM_CHANGE_APP, + POKETCH_SYSTEM_SHUTDOWN, + POKETCH_SYSTEM_UNLOAD }; enum PoketchAppState { @@ -64,9 +64,9 @@ enum PoketchBorderColor { POKETCH_BORDER_BLUE }; -enum PoketchFieldEventID { +enum PoketchEventID { POKETCH_FIELDEVENT_SLEEP = 0, - POKETCH_FIELDEVENT_PLAYERMOVED, + POKETCH_FIELDEVENT_PLAYER_MOVED, POKETCH_FIELDEVENT_SAVE = 4, POKETCH_FIELDEVENT_PEDOMETER, @@ -118,7 +118,7 @@ struct PoketchSystem { void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, SaveData *saveData, BGL *bgl, NNSG2dOamManagerInstance *oamManager); void PoketchSystem_StartShutdown(PoketchSystem *poketchSys); BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys); -void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32); +void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchEventID eventID, u32); BOOL PoketchSystem_IsTapped(PoketchSystem *poketchSys); enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys); void PoketchSystem_SetAppFunctions(PoketchAppInitFunction initFunction, PoketchAppShutdownFunction shutdownFunction); @@ -139,4 +139,4 @@ PoketchData * PoketchSystem_GetPoketchData(const PoketchSystem *poketchSys); SaveData * PoketchSystem_GetSaveData(const PoketchSystem *poketchSys); int PoketchSystem_GetBorderColor(const PoketchSystem *poketchSys); -#endif // POKEPLATINUM_POKETCHSYSTEM_H +#endif // POKEPLATINUM_POKETCH_SYSTEM_H diff --git a/src/overlay025/poketch_button.c b/src/overlay025/poketch_button.c index 87736978f..8a9ffb2d3 100644 --- a/src/overlay025/poketch_button.c +++ b/src/overlay025/poketch_button.c @@ -209,7 +209,7 @@ static u32 Button_OnPressed(PoketchButton *button, BOOL touched, BOOL tapped) } else { // We don't reset the timer because we want to check for double tap with the same timer if (button->doubleTapTime) { - PoketchButton_ChangeState_NoReset(button, BUTTON_STATE_CHECK_DOUBLETAP); + PoketchButton_ChangeState_NoReset(button, BUTTON_STATE_CHECK_DOUBLE_TAP); } else { PoketchButton_ChangeState(button, BUTTON_STATE_IDLE); return BUTTON_MANAGER_STATE_TAP; @@ -230,8 +230,8 @@ static u32 Button_OnCheckDoubleTap(PoketchButton *button, BOOL touched, BOOL tap } if (button->screenTouched && tapped) { - PoketchButton_ChangeState(button, BUTTON_STATE_DOUBLETAP); - return BUTTON_MANAGER_STATE_DOUBLETAP; + PoketchButton_ChangeState(button, BUTTON_STATE_DOUBLE_TAP); + return BUTTON_MANAGER_STATE_DOUBLE_TAP; } return BUTTON_MANAGER_STATE_NULL; diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index cf0be9db4..a7a8538c9 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -150,8 +150,8 @@ void PoketchSystem_Create(FieldSystem *fieldSystem, PoketchSystem **poketchSys, void PoketchSystem_StartShutdown (PoketchSystem *poketchSys) { - if (poketchSys->systemState != POKETCHSYSTEM_SHUTDOWN && poketchSys->systemState != POKETCHSYSTEM_UNLOAD) { - PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_SHUTDOWN); + if (poketchSys->systemState != POKETCH_SYSTEM_SHUTDOWN && poketchSys->systemState != POKETCH_SYSTEM_UNLOAD) { + PoketchSystem_SetState(poketchSys, POKETCH_SYSTEM_SHUTDOWN); } } @@ -160,12 +160,12 @@ BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys) return poketchSys == NULL; } -void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchFieldEventID eventID, u32) +void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchEventID eventID, u32) { switch (eventID) { case POKETCH_FIELDEVENT_SLEEP: break; - case POKETCH_FIELDEVENT_PLAYERMOVED: + case POKETCH_FIELDEVENT_PLAYER_MOVED: poketchSys->playerMoving = TRUE; break; case POKETCH_FIELDEVENT_PEDOMETER:{ @@ -200,7 +200,7 @@ enum PoketchAppID PoketchSystem_CurrentAppID(PoketchSystem *poketchSys) static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) { if (ov25_02254560(&(poketchSys->unk_1C), &(poketchSys->unk_20), poketchSys->oamManager, poketchSys)) { - poketchSys->systemState = POKETCHSYSTEM_INIT; + poketchSys->systemState = POKETCH_SYSTEM_INIT; poketchSys->subState = 0; poketchSys->touchingScreen = FALSE; poketchSys->playerMoving = 0; @@ -220,7 +220,7 @@ static BOOL PoketchSystem_InitInternal(PoketchSystem *poketchSys) return FALSE; } -static void PoketchSystem_Shutdown (PoketchSystem *poketchSys) +static void PoketchSystem_Shutdown(PoketchSystem *poketchSys) { SysTask_Done(poketchSys->unk_38); @@ -242,13 +242,13 @@ static void PoketchSystem_MainTask(SysTask *task, void *system) PoketchSystem *poketchSys = (PoketchSystem *)system; if (poketchSys->systemState < NELEMS(sPoketchEvents)) { - if (poketchSys->systemState != POKETCHSYSTEM_INIT) { + if (poketchSys->systemState != POKETCH_SYSTEM_INIT) { PoketchSystem_ButtonUpdate(poketchSys); } sPoketchEvents[poketchSys->systemState](poketchSys); } else { - GF_ASSERT(poketchSys->systemState == POKETCHSYSTEM_UNLOAD); + GF_ASSERT(poketchSys->systemState == POKETCH_SYSTEM_UNLOAD); *(poketchSys->poketchSysPtr) = NULL; PoketchSystem_Shutdown(poketchSys); @@ -299,7 +299,7 @@ static void PoketchEvent_InitApp(PoketchSystem *poketchSys) poketchSys->subState++; case 3: if (ov25_022547F4(poketchSys->unk_1C, 1)) { - PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UPDATE); + PoketchSystem_SetState(poketchSys, POKETCH_SYSTEM_UPDATE); } } } @@ -365,7 +365,7 @@ static void PoketchEvent_UpdateApp(PoketchSystem *poketchSys) if (PoketchSystem_IsAppShutdown(poketchSys)) { PoketchSystem_UnloadApp(poketchSys); sub_02099D44(); - PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_CHANGEAPP); + PoketchSystem_SetState(poketchSys, POKETCH_SYSTEM_CHANGE_APP); } break; case 4: @@ -418,7 +418,7 @@ static void PoketchEvent_OnAppChange(PoketchSystem *poketchSys) if (ov25_022547F4(poketchSys->unk_1C, 2)) { poketchSys->appChanging = FALSE; poketchSys->unk_06 = 0; - PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UPDATE); + PoketchSystem_SetState(poketchSys, POKETCH_SYSTEM_UPDATE); } break; } @@ -458,7 +458,7 @@ static void PoketchEvent_OnShutdown(PoketchSystem *poketchSys) if (ov25_02254800(poketchSys->unk_1C)) { PoketchSystem_UnloadApp(poketchSys); sub_0201E530(); - PoketchSystem_SetState(poketchSys, POKETCHSYSTEM_UNLOAD); + PoketchSystem_SetState(poketchSys, POKETCH_SYSTEM_UNLOAD); } break; } @@ -545,9 +545,9 @@ void PoketchSystem_SetSaveFunction(PoketchAppSaveFunction saveFunction, void *sa } static const TouchScreenHitTable sMainPoketchButtons[] = { - [POKETCHSYSTEM_MAINBUTTON_UP] = {POKETCH_BUTTON_TOP_MINY, POKETCH_BUTTON_TOP_MAXY, POKETCH_BUTTON_TOP_MINX, POKETCH_BUTTON_TOP_MAXX}, // Top button - [POKETCHSYSTEM_MAINBUTTON_DOWN] = {POKETCH_BUTTON_BOTTOM_MINY, POKETCH_BUTTON_BOTTOM_MAXY, POKETCH_BUTTON_BOTTOM_MINX, POKETCH_BUTTON_BOTTOM_MAXX}, // Bottom Button - [POKETCHSYSTEM_MAINBUTTON_SCREEN] = {POKETCH_SCREEN_MINY, POKETCH_SCREEN_MAXY, POKETCH_SCREEN_MINX, POKETCH_SCREEN_MAXX} // Screen + [POKETCH_SYSTEM_MAIN_BUTTON_UP] = {POKETCH_BUTTON_TOP_MIN_Y, POKETCH_BUTTON_TOP_MAX_Y, POKETCH_BUTTON_TOP_MIN_X, POKETCH_BUTTON_TOP_MAX_X}, // Top button + [POKETCH_SYSTEM_MAIN_BUTTON_DOWN] = {POKETCH_BUTTON_BOTTOM_MIN_Y, POKETCH_BUTTON_BOTTOM_MAX_Y, POKETCH_BUTTON_BOTTOM_MIN_X, POKETCH_BUTTON_BOTTOM_MAX_X}, // Bottom Button + [POKETCH_SYSTEM_MAIN_BUTTON_SCREEN] = {POKETCH_SCREEN_MIN_Y, POKETCH_SCREEN_MAX_Y, POKETCH_SCREEN_MIN_X, POKETCH_SCREEN_MAX_X} // Screen }; static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) @@ -555,7 +555,7 @@ static BOOL PoketchSystem_ButtonInit(PoketchSystem *poketchSys) poketchSys->buttonManager = PoketchButtonManager_New(sMainPoketchButtons, NELEMS(sMainPoketchButtons), PoketchSystem_OnButtonEvent, poketchSys, HEAP_ID_POKETCH_MAIN); if (poketchSys->buttonManager != NULL) { - PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, POKETCHSYSTEM_MAINBUTTON_UP, 0, 7); + PoketchButtonManager_SetButtonTimer(poketchSys->buttonManager, POKETCH_SYSTEM_MAIN_BUTTON_UP, 0, 7); poketchSys->unk_2C = 0xffffffff; poketchSys->unk_30 = 0xffffffff; return TRUE; @@ -592,7 +592,7 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch poketchSys->touchingScreen = FALSE; } - if (buttonID == POKETCHSYSTEM_MAINBUTTON_SCREEN) { + if (buttonID == POKETCH_SYSTEM_MAIN_BUTTON_SCREEN) { if (ov25_0225450C(poketchSys) && touchEvent == BUTTON_TOUCH_RELEASED) { Sound_PlayEffect(SEQ_SE_DP_BEEP); } @@ -601,14 +601,14 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch switch (touchEvent) { case BUTTON_TOUCH_PRESSED: - v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 8 : 11; + v1 = (buttonID == POKETCH_SYSTEM_MAIN_BUTTON_UP) ? 8 : 11; break; case BUTTON_TOUCH_RELEASED: if (ov25_0225450C(poketchSys) || poketchSys->unk_06) { - v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 6 : 9; + v1 = (buttonID == POKETCH_SYSTEM_MAIN_BUTTON_UP) ? 6 : 9; buttonEvent = 0; } else { - v1 = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? 7 : 10; + v1 = (buttonID == POKETCH_SYSTEM_MAIN_BUTTON_UP) ? 7 : 10; } break; } @@ -645,7 +645,7 @@ static void PoketchSystem_OnButtonEvent(u32 buttonID, u32 buttonEvent, u32 touch } poketchSys->buttonState = buttonEvent; - poketchSys->buttonDir = (buttonID == POKETCHSYSTEM_MAINBUTTON_UP) ? BUTTON_UP : BUTTON_DOWN; + poketchSys->buttonDir = (buttonID == POKETCH_SYSTEM_MAIN_BUTTON_UP) ? BUTTON_UP : BUTTON_DOWN; } } @@ -687,7 +687,7 @@ void ov25_02254444 (u32 param0, u32 param1) static inline BOOL PoketchSystem_InsideScreenBounds(u32 x, u32 y) { - if ((u32)(x - POKETCH_SCREEN_MINX) < (u32)(POKETCH_SCREEN_MAXX - POKETCH_SCREEN_MINX) & (u32)(y - POKETCH_SCREEN_MINY) < (u32)(POKETCH_SCREEN_MAXY - POKETCH_SCREEN_MINY)) { + if ((u32)(x - POKETCH_SCREEN_MIN_X) < (u32)(POKETCH_SCREEN_MAX_X - POKETCH_SCREEN_MIN_X) & (u32)(y - POKETCH_SCREEN_MIN_Y) < (u32)(POKETCH_SCREEN_MAX_Y - POKETCH_SCREEN_MIN_Y)) { return TRUE; } From 83915aceb4ca32871aad8b2479631a346b406eee Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Thu, 20 Jun 2024 19:02:24 -0700 Subject: [PATCH 24/25] Rename Poketch Event enums --- include/overlay025/poketch_system.h | 8 ++++---- src/overlay025/poketch_system.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/overlay025/poketch_system.h b/include/overlay025/poketch_system.h index a3c08c7c8..eea042ce7 100644 --- a/include/overlay025/poketch_system.h +++ b/include/overlay025/poketch_system.h @@ -65,11 +65,11 @@ enum PoketchBorderColor { }; enum PoketchEventID { - POKETCH_FIELDEVENT_SLEEP = 0, - POKETCH_FIELDEVENT_PLAYER_MOVED, + POKETCH_EVENT_SLEEP = 0, + POKETCH_EVENT_PLAYER_MOVED, - POKETCH_FIELDEVENT_SAVE = 4, - POKETCH_FIELDEVENT_PEDOMETER, + POKETCH_EVENT_SAVE = 4, + POKETCH_EVENT_PEDOMETER, }; typedef struct PoketchSystem PoketchSystem; diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index a7a8538c9..e3965d6bc 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -26,7 +26,7 @@ #include "unk_020508D4.h" #include "unk_02099D44.h" #include "overlay025/ov25_02254560.h" -#include "consts/sdat.h" +#include "constants/sdat.h" #include "gender.h" FS_EXTERN_OVERLAY(overlay26); @@ -163,12 +163,12 @@ BOOL PoketchSystem_IsSystemShutdown(PoketchSystem *poketchSys) void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchEventID eventID, u32) { switch (eventID) { - case POKETCH_FIELDEVENT_SLEEP: + case POKETCH_EVENT_SLEEP: break; - case POKETCH_FIELDEVENT_PLAYER_MOVED: + case POKETCH_EVENT_PLAYER_MOVED: poketchSys->playerMoving = TRUE; break; - case POKETCH_FIELDEVENT_PEDOMETER:{ + case POKETCH_EVENT_PEDOMETER:{ u32 step_count = PoketchData_StepCount(poketchSys->poketchData); if (++step_count > POKETCH_PEDOMETER_MAX) { @@ -179,7 +179,7 @@ void PoketchSystem_SendEvent(PoketchSystem *poketchSys, enum PoketchEventID even poketchSys->pedometerUpdated = TRUE; } break; - case POKETCH_FIELDEVENT_SAVE: + case POKETCH_EVENT_SAVE: if (poketchSys->appState == POKETCH_APP_STATE_UPDATE && poketchSys->currAppSave) { poketchSys->currAppSave(poketchSys->appSaveData); } From 1467dddeb836930aa288b1a86543e5daa7c46ed7 Mon Sep 17 00:00:00 2001 From: Trainer Riley Date: Thu, 20 Jun 2024 19:11:51 -0700 Subject: [PATCH 25/25] Fix sdat header --- src/overlay025/poketch_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlay025/poketch_system.c b/src/overlay025/poketch_system.c index e3965d6bc..62cc2faeb 100644 --- a/src/overlay025/poketch_system.c +++ b/src/overlay025/poketch_system.c @@ -26,7 +26,7 @@ #include "unk_020508D4.h" #include "unk_02099D44.h" #include "overlay025/ov25_02254560.h" -#include "constants/sdat.h" +#include "consts/sdat.h" #include "gender.h" FS_EXTERN_OVERLAY(overlay26);