From 0b829f3f7a6307696cb03b6cbd977065b844fe89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 28 Jan 2024 17:12:18 +0100 Subject: [PATCH 1/6] main callback, hblank --- include/core_sys.h | 8 ++-- include/functypes/funcptr_02017798.h | 2 +- include/unk_02017728.h | 8 ++-- src/error_message_reset.c | 4 +- src/main.c | 10 ++--- src/overlay005/ov5_021D0D80.c | 8 ++-- src/overlay005/ov5_021EF3A8.c | 4 +- src/overlay010/ov10_0221F800.c | 12 ++--- src/overlay016/ov16_0223B140.c | 12 ++--- src/overlay016/ov16_0226871C.c | 4 +- src/overlay017/ov17_0223B140.c | 10 ++--- src/overlay017/ov17_0223CB1C.c | 10 ++--- src/overlay017/ov17_0223DAD0.c | 10 ++--- src/overlay017/ov17_0224F4D4.c | 12 ++--- src/overlay019/ov19_021D61B0.c | 6 +-- src/overlay020/ov20_021D2098.c | 6 +-- src/overlay021/ov21_021D0D80.c | 6 +-- src/overlay022/ov22_02255D44.c | 16 +++---- src/overlay022/ov22_0225B660.c | 8 ++-- src/overlay023/ov23_0223E140.c | 4 +- src/overlay058/ov58_021D0D80.c | 10 ++--- src/overlay059/ov59_021D0D80.c | 8 ++-- src/overlay061/ov61_0222BF44.c | 10 ++--- src/overlay062/ov62_0222F2C0.c | 8 ++-- src/overlay062/ov62_02237D24.c | 10 ++--- src/overlay064/ov64_0222DCE0.c | 16 +++---- src/overlay065/ov65_0222DCE0.c | 8 ++-- src/overlay065/ov65_0223648C.c | 4 +- src/overlay066/ov66_0222DCE0.c | 8 ++-- src/overlay067/ov67_0225C700.c | 16 +++---- src/overlay068/ov68_0225C700.c | 8 ++-- src/overlay069/ov69_0225C700.c | 8 ++-- src/overlay070/ov70_0225D9A4.c | 8 ++-- src/overlay071/ov71_0223B140.c | 8 ++-- src/overlay072/ov72_0223D7A0.c | 10 ++--- src/overlay073/ov73_021D0D80.c | 10 ++--- src/overlay073/ov73_021D3250.c | 8 ++-- src/overlay074/ov74_021D0D80.c | 10 ++--- src/overlay075/ov75_021D0D80.c | 8 ++-- src/overlay076/ov76_0223D338.c | 8 ++-- src/overlay077/ov77_021D0D80.c | 8 ++-- src/overlay077/ov77_021D25B0.c | 12 ++--- src/overlay078/ov78_021D0D80.c | 6 +-- src/overlay079/ov79_021D0D80.c | 8 ++-- src/overlay079/ov79_021D2268.c | 8 ++-- src/overlay080/ov80_021D0D80.c | 10 ++--- src/overlay081/ov81_021D0D80.c | 8 ++-- src/overlay083/ov83_0223B5A0.c | 8 ++-- src/overlay084/ov84_0223B5A0.c | 8 ++-- src/overlay085/ov85_02241440.c | 8 ++-- src/overlay086/ov86_0223B140.c | 2 +- src/overlay087/ov87_021D106C.c | 4 +- src/overlay088/ov88_0223B140.c | 10 ++--- src/overlay090/ov90_021D0D80.c | 10 ++--- src/overlay091/ov91_021D0D80.c | 10 ++--- src/overlay092/ov92_021D0D80.c | 6 +-- src/overlay093/ov93_021D0D80.c | 4 +- src/overlay093/ov93_021D111C.c | 4 +- src/overlay094/ov94_0223BCB0.c | 8 ++-- src/overlay095/ov95_02246C20.c | 4 +- src/overlay095/ov95_02249740.c | 2 +- src/overlay095/ov95_0224A390.c | 4 +- src/overlay096/ov96_0223B6A0.c | 8 ++-- src/overlay097/ov97_0222AE60.c | 4 +- src/overlay097/ov97_02233B18.c | 6 +-- src/overlay097/ov97_02237694.c | 4 +- src/overlay098/ov98_022471C8.c | 10 ++--- src/overlay099/ov99_021D0D80.c | 10 ++--- src/overlay100/ov100_021D0D80.c | 10 ++--- src/overlay101/ov101_021D0D80.c | 8 ++-- src/overlay102/ov102_021D0D80.c | 8 ++-- src/overlay104/ov104_0223C2D4.c | 10 ++--- src/overlay105/ov105_02241AE0.c | 8 ++-- src/overlay106/ov106_02241AE0.c | 8 ++-- src/overlay107/ov107_02241AE0.c | 8 ++-- src/overlay107/ov107_02245EB0.c | 8 ++-- src/overlay108/ov108_02241AE0.c | 8 ++-- src/overlay109/ov109_021D0D80.c | 8 ++-- src/overlay109/ov109_021D3D50.c | 8 ++-- src/overlay110/ov110_021D0D80.c | 8 ++-- src/overlay111/ov111_021D0D80.c | 8 ++-- src/overlay112/ov112_0225C700.c | 8 ++-- src/overlay113/ov113_0225C700.c | 10 ++--- src/overlay114/ov114_0225C700.c | 8 ++-- src/overlay115/ov115_02260440.c | 12 ++--- src/overlay116/ov116_022604C4.c | 8 ++-- src/overlay117/ov117_02260668.c | 6 +-- src/overlay120/ov120_021D0D80.c | 8 ++-- src/overlay121/ov121_021D0D80.c | 10 ++--- src/unk_0200F174.c | 4 +- src/unk_02017498.c | 4 +- src/unk_02017728.c | 65 ++++++++++++++-------------- src/unk_02039814.c | 4 +- src/unk_02039A64.c | 4 +- src/unk_0207AE68.c | 4 +- src/unk_0207E0B8.c | 8 ++-- src/unk_0208694C.c | 8 ++-- src/unk_020890F4.c | 6 +-- src/unk_0208C324.c | 8 ++-- src/unk_02097B18.c | 2 +- src/unk_02098218.c | 10 ++--- src/unk_02099DFC.c | 8 ++-- src/unk_0209A2C4.c | 6 +-- src/unk_0209A74C.c | 8 ++-- src/unk_0209AA74.c | 4 +- 105 files changed, 434 insertions(+), 435 deletions(-) diff --git a/include/core_sys.h b/include/core_sys.h index 5aa3de4a5a..beba2e7d3d 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -13,10 +13,10 @@ enum ButtonMode { }; typedef struct CoreSys { - UnkFuncPtr_02017798 unk_00; - void * unk_04; - UnkFuncPtr_02017798 unk_08; - void * unk_0C; + Callback mainCallback; + void * mainCallbackData; + Callback hblankCallback; + void * hblankCallbackData; UnkFuncPtr_ov23_022537D4 unk_10; UnkFuncPtr_ov23_022537D4 unk_14; UnkStruct_0201CD88 * unk_18; diff --git a/include/functypes/funcptr_02017798.h b/include/functypes/funcptr_02017798.h index e2e881b55d..97b06c4f96 100644 --- a/include/functypes/funcptr_02017798.h +++ b/include/functypes/funcptr_02017798.h @@ -1,6 +1,6 @@ #ifndef POKEPLATINUM_FUNCPTR_02017798_H #define POKEPLATINUM_FUNCPTR_02017798_H -typedef void (* UnkFuncPtr_02017798)(void *); +typedef void (* Callback)(void *); #endif // POKEPLATINUM_FUNCPTR_02017798_H diff --git a/include/unk_02017728.h b/include/unk_02017728.h index 9b55946f1c..4b08af564a 100644 --- a/include/unk_02017728.h +++ b/include/unk_02017728.h @@ -4,11 +4,11 @@ #include "functypes/funcptr_02017798.h" void sub_02017728(void); -void sub_02017798(UnkFuncPtr_02017798 param0, void * param1); -void sub_020177A4(void); -BOOL sub_020177BC(UnkFuncPtr_02017798 param0, void * param1); +void SetMainCallback(Callback cb, void * data); +void DisableHBlank(void); +BOOL SetHBlankCallback(Callback cb, void * data); void sub_0201789C(void); -void sub_020179E4(void); +void InitGraphics(void); void * ReadFileToHeap(int heapID, const char * filename); void ReadFileToBuffer(const char * filename, void ** buf); void sub_02017ACC(void); diff --git a/src/error_message_reset.c b/src/error_message_reset.c index 6519c73c00..1a8a649b0b 100644 --- a/src/error_message_reset.c +++ b/src/error_message_reset.c @@ -118,8 +118,8 @@ void ErrorMessageReset_PrintErrorAndReset (void) OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); OS_EnableIrqMask(OS_IE_V_BLANK); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/main.c b/src/main.c index 2060ec0fe7..a8ed1af397 100644 --- a/src/main.c +++ b/src/main.c @@ -67,7 +67,7 @@ extern const UnkStruct_0208BE5C Unk_ov77_021D788C; void NitroMain (void) { sub_0201789C(); - sub_020179E4(); + InitGraphics(); InitKeypadAndTouchpad(); sub_02017B70(0); @@ -155,8 +155,8 @@ void NitroMain (void) sub_0200ABF0(); sub_0200F27C(); - if (gCoreSys.unk_00 != NULL) { - gCoreSys.unk_00(gCoreSys.unk_04); + if (gCoreSys.mainCallback != NULL) { + gCoreSys.mainCallback(gCoreSys.mainCallbackData); } sub_02003BD8(); @@ -220,8 +220,8 @@ static void sub_02000EE4 (void) gCoreSys.unk_2C++; gCoreSys.unk_30 = 0; - if (gCoreSys.unk_00 != NULL) { - gCoreSys.unk_00(gCoreSys.unk_04); + if (gCoreSys.mainCallback != NULL) { + gCoreSys.mainCallback(gCoreSys.mainCallbackData); } } diff --git a/src/overlay005/ov5_021D0D80.c b/src/overlay005/ov5_021D0D80.c index 432508c447..5e4e2a10b8 100644 --- a/src/overlay005/ov5_021D0D80.c +++ b/src/overlay005/ov5_021D0D80.c @@ -163,8 +163,8 @@ static int ov5_021D0DA4 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); G2_BlendNone(); G2S_BlendNone(); @@ -350,7 +350,7 @@ static int ov5_021D0FB4 (UnkStruct_020067E8 * param0, int * param1) sub_0201DC3C(); sub_0201CBA0(); ov5_021D1AE4(v0->unk_04->unk_04); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_FreeToHeap(v0->unk_08); Heap_FreeToHeap(v0->unk_04); @@ -948,7 +948,7 @@ static void ov5_021D1968 (UnkStruct_0203CDB0 * param0) ov5_021D5CE4(param0->unk_04->unk_10, ov5_021EFA8C(param0->unk_30)); sub_02068344(param0); ov5_021EE7C0(param0); - sub_02017798(ov5_021D0D80, param0); + SetMainCallback(ov5_021D0D80, param0); } static UnkStruct_ov5_021D1A68 * ov5_021D1A14 (int param0, int param1) diff --git a/src/overlay005/ov5_021EF3A8.c b/src/overlay005/ov5_021EF3A8.c index 8b0cbdf5e2..b1dda70103 100644 --- a/src/overlay005/ov5_021EF3A8.c +++ b/src/overlay005/ov5_021EF3A8.c @@ -55,7 +55,7 @@ void ov5_021EF3DC (UnkStruct_ov5_021EF3BC * param0) { BOOL v0; - v0 = sub_020177BC(ov5_021EF47C, param0); + v0 = SetHBlankCallback(ov5_021EF47C, param0); GF_ASSERT(v0 == 1); param0->unk_00 = 1; @@ -65,7 +65,7 @@ void ov5_021EF3FC (UnkStruct_ov5_021EF3BC * param0) { BOOL v0; - v0 = sub_020177BC(NULL, NULL); + v0 = SetHBlankCallback(NULL, NULL); GF_ASSERT(v0 == 1); param0->unk_00 = 0; diff --git a/src/overlay010/ov10_0221F800.c b/src/overlay010/ov10_0221F800.c index 4aac029483..26ca6bb1aa 100644 --- a/src/overlay010/ov10_0221F800.c +++ b/src/overlay010/ov10_0221F800.c @@ -557,8 +557,8 @@ static u8 ov10_0221FB28 (UnkStruct_ov10_0221FB28 * param0) { G2_BlendNone(); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -620,7 +620,7 @@ static u8 ov10_0221FBFC (UnkStruct_ov10_0221FB28 * param0) ov10_02221C14(param0); sub_02039734(); sub_0208C120(0, param0->unk_00->unk_24); - sub_02017798(ov10_02220C64, param0); + SetMainCallback(ov10_02220C64, param0); return 1; } @@ -644,7 +644,7 @@ static u8 ov10_0221FC78 (UnkStruct_ov10_0221FB28 * param0) break; case 2: sub_0208C120(0, param0->unk_00->unk_24); - sub_02017798(ov10_02220C64, param0); + SetMainCallback(ov10_02220C64, param0); param0->unk_B76 = 0; param0->unk_B70 = 8; param0->unk_B71 = 4; @@ -696,7 +696,7 @@ static u8 ov10_0221FD00 (UnkStruct_ov10_0221FB28 * param0) break; case 2: sub_0208C120(0, param0->unk_00->unk_24); - sub_02017798(ov10_02220C64, param0); + SetMainCallback(ov10_02220C64, param0); param0->unk_B76 = 0; param0->unk_B70 = 4; param0->unk_B71 = 2; @@ -1161,7 +1161,7 @@ static u8 ov10_02220A50 (SysTask * param0, UnkStruct_ov10_0221FB28 * param1) return 0; } - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov10_02222A48(param1); if (param1->unk_00->unk_28 != 0) { diff --git a/src/overlay016/ov16_0223B140.c b/src/overlay016/ov16_0223B140.c index ccf96212f1..492623dd10 100644 --- a/src/overlay016/ov16_0223B140.c +++ b/src/overlay016/ov16_0223B140.c @@ -321,7 +321,7 @@ void ov16_0223B384 (BattleSystem * param0) void ov16_0223B3E4 (BattleSystem * param0) { - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov16_02268A14(param0->unk_198); BGL_DeleteWindow(¶m0->unk_08[0]); @@ -474,7 +474,7 @@ void ov16_0223B578 (BattleSystem * param0) GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); - sub_02017798(ov16_0223CE68, param0); + SetMainCallback(ov16_0223CE68, param0); param0->unk_23FB_1 = 1; @@ -540,7 +540,7 @@ static void ov16_0223B790 (UnkStruct_020067E8 * param0) v0->unk_00 = ov16_0223CD7C(); - sub_020177A4(); + DisableHBlank(); sub_02002BB8(2, 5); if (v0->battleType & 0x20) { @@ -958,7 +958,7 @@ static void ov16_0223C004 (BattleSystem * param0, BGL * param1) GXLayers_TurnBothDispOn(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); - sub_02017798(ov16_0223CE68, param0); + SetMainCallback(ov16_0223CE68, param0); } static void ov16_0223C210 (BattleSystem * param0) @@ -1758,7 +1758,7 @@ static void ov16_0223D10C (UnkStruct_020067E8 * param0, BattleParams * param1) MessageLoader_Free(v5); } - sub_02017798(ov16_0223CF1C, v0); + SetMainCallback(ov16_0223CF1C, v0); sub_02003178(v0->unk_0C, (0x1 | 0x4), 0xffff, 0, 16, 0, 0x0); v0->unk_1024 = sub_0200E7FC(v0->unk_08, 1); @@ -1997,7 +1997,7 @@ static void ov16_0223D7B4 (UnkStruct_020067E8 * param0) { UnkStruct_0207A778 * v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0200F344(0, 0x0); sub_02002FA0(v0->unk_0C, 0); sub_02002F54(v0->unk_0C); diff --git a/src/overlay016/ov16_0226871C.c b/src/overlay016/ov16_0226871C.c index e23341b019..c202f97016 100644 --- a/src/overlay016/ov16_0226871C.c +++ b/src/overlay016/ov16_0226871C.c @@ -1734,7 +1734,7 @@ static void ov16_02269550 (UnkStruct_ov16_02268A14 * param0, int param1) Sound_PlayEffect(1806); SysTask_Start(ov16_0226B988, v1, 1210); - v0 = sub_020177BC(ov16_0226BB94, v1); + v0 = SetHBlankCallback(ov16_0226BB94, v1); GF_ASSERT(v0 == 1); v1->unk_04 = sub_0200DA04(ov16_0226BA88, v1, 10); @@ -3541,7 +3541,7 @@ static void ov16_0226B988 (SysTask * param0, void * param1) case 1: v0->unk_00->unk_66E = 0; SysTask_Done(v0->unk_04); - sub_020177A4(); + DisableHBlank(); GXS_SetVisibleWnd(GX_WNDMASK_NONE); ov16_0226BCCC(v0->unk_00, 1); v0->unk_13++; diff --git a/src/overlay017/ov17_0223B140.c b/src/overlay017/ov17_0223B140.c index ab60f5f098..96b7548ffe 100644 --- a/src/overlay017/ov17_0223B140.c +++ b/src/overlay017/ov17_0223B140.c @@ -148,8 +148,8 @@ int ov17_0223B140 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov17_02246F24 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -262,7 +262,7 @@ int ov17_0223B140 (UnkStruct_020067E8 * param0, int * param1) GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); sub_02004550(6, 1135, 1); sub_020959F4(v0->unk_00->unk_155); - sub_02017798(ov17_0223B6BC, v0); + SetMainCallback(ov17_0223B6BC, v0); return 1; } @@ -377,8 +377,8 @@ int ov17_0223B580 (UnkStruct_020067E8 * param0, int * param1) sub_0201E530(); sub_02006830(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Destroy(21); sub_02095A24(); sub_02039794(); diff --git a/src/overlay017/ov17_0223CB1C.c b/src/overlay017/ov17_0223CB1C.c index 36418210df..d9bfe9c50e 100644 --- a/src/overlay017/ov17_0223CB1C.c +++ b/src/overlay017/ov17_0223CB1C.c @@ -128,8 +128,8 @@ int ov17_0223CB1C (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov17_02247A48 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -223,7 +223,7 @@ int ov17_0223CB1C (UnkStruct_020067E8 * param0, int * param1) sub_02004234(0); sub_02004550(6, 1135, 1); sub_020959F4(v0->unk_00->unk_155); - sub_02017798(ov17_0223D0C8, v0); + SetMainCallback(ov17_0223D0C8, v0); Sound_PlayEffect(1541); return 1; @@ -341,8 +341,8 @@ int ov17_0223CF8C (UnkStruct_020067E8 * param0, int * param1) sub_0201E530(); sub_02006830(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Destroy(22); sub_02095A24(); sub_02039794(); diff --git a/src/overlay017/ov17_0223DAD0.c b/src/overlay017/ov17_0223DAD0.c index 2d4727f535..110f003908 100644 --- a/src/overlay017/ov17_0223DAD0.c +++ b/src/overlay017/ov17_0223DAD0.c @@ -229,8 +229,8 @@ int ov17_0223DAD0 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov17_0224DF54 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -334,7 +334,7 @@ int ov17_0223DAD0 (UnkStruct_020067E8 * param0, int * param1) G2_SetBlendBrightness((GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_BD | GX_BLEND_PLANEMASK_OBJ), -6); Sound_PlayEffect(1765); - sub_02017798(ov17_0223E09C, v0); + SetMainCallback(ov17_0223E09C, v0); return 1; } @@ -450,8 +450,8 @@ int ov17_0223DF0C (UnkStruct_020067E8 * param0, int * param1) sub_0201E530(); sub_02006830(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Destroy(23); sub_02095A24(); sub_02039794(); diff --git a/src/overlay017/ov17_0224F4D4.c b/src/overlay017/ov17_0224F4D4.c index 88034325f2..cc8eedc278 100644 --- a/src/overlay017/ov17_0224F4D4.c +++ b/src/overlay017/ov17_0224F4D4.c @@ -137,8 +137,8 @@ int ov17_0224F4D4 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov17_0224FCA0 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -218,7 +218,7 @@ int ov17_0224F4D4 (UnkStruct_020067E8 * param0, int * param1) GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); sub_02004550(6, 1135, 1); sub_020959F4(v0->unk_00->unk_155); - sub_02017798(ov17_0224FA24, v0); + SetMainCallback(ov17_0224FA24, v0); v0->unk_08 = sub_0200DA04(ov17_0224FAE4, v0, 10); Sound_PlayEffect(1765); @@ -236,7 +236,7 @@ int ov17_0224F754 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: if (ScreenWipe_Done() == 1) { - sub_020177BC(ov17_0224FAAC, v0); + SetHBlankCallback(ov17_0224FAAC, v0); v0->unk_848 = ov17_0223F70C(24, v0->unk_10.unk_C0, Unk_ov17_02254AB4, NELEMS(Unk_ov17_02254AB4), 0xff, (50000 + 5000)); *param1 = 1; } @@ -333,8 +333,8 @@ int ov17_0224F86C (UnkStruct_020067E8 * param0, int * param1) GX_SetVisibleWnd(GX_WNDMASK_NONE); GXS_SetVisibleWnd(GX_WNDMASK_NONE); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Destroy(24); sub_02095A24(); diff --git a/src/overlay019/ov19_021D61B0.c b/src/overlay019/ov19_021D61B0.c index aef512cf27..e788fde08e 100644 --- a/src/overlay019/ov19_021D61B0.c +++ b/src/overlay019/ov19_021D61B0.c @@ -174,8 +174,8 @@ BOOL ov19_021D61B0 (UnkStruct_ov19_021D61B0 ** param0, const UnkStruct_ov19_021D v3 = NARC_ctor(NARC_INDEX_GRAPHIC__BOX, 10); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -245,7 +245,7 @@ static void ov19_021D6474 (SysTask * param0, void * param1) void ov19_021D64A0 (UnkStruct_ov19_021D61B0 * param0) { - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); SysTask_Done(param0->unk_00); SysTask_Done(param0->unk_04); diff --git a/src/overlay020/ov20_021D2098.c b/src/overlay020/ov20_021D2098.c index a49103d8e3..e936cad0cb 100644 --- a/src/overlay020/ov20_021D2098.c +++ b/src/overlay020/ov20_021D2098.c @@ -115,8 +115,8 @@ UnkStruct_ov20_021D2128 * ov20_021D2098 (const UnkStruct_ov20_021D16E8 * param0, if (v0) { int v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); v0->unk_18 = param0; v0->unk_1C = param1; @@ -142,7 +142,7 @@ void ov20_021D2128 (UnkStruct_ov20_021D2128 * param0) if (param0) { int v0; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); for (v0 = 0; v0 < 4; v0++) { if (param0->unk_08[v0]) { diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index 852c96453e..16d2c46973 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -146,8 +146,8 @@ int ov21_021D0D80 (UnkStruct_020067E8 * param0, int * param1) Pokedex_SetupGiratina(v4); } - sub_02017798(ov21_021D0F04, v0); - sub_020177A4(); + SetMainCallback(ov21_021D0F04, v0); + DisableHBlank(); sub_0201E3D8(); v3 = sub_0201E450(4); @@ -213,7 +213,7 @@ int ov21_021D0EC8 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov21_021D0F18 * v0 = sub_0200682C(param0); BOOL v1; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = sub_0201E530(); GF_ASSERT(v1 == 1); diff --git a/src/overlay022/ov22_02255D44.c b/src/overlay022/ov22_02255D44.c index d86f8b4f76..75bf577e3c 100644 --- a/src/overlay022/ov22_02255D44.c +++ b/src/overlay022/ov22_02255D44.c @@ -208,8 +208,8 @@ int ov22_02255D44 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200681C(param0, sizeof(UnkStruct_ov22_02255D44), 13); memset(v0, 0, sizeof(UnkStruct_ov22_02255D44)); - sub_02017798(ov22_02256940, v0); - sub_020177A4(); + SetMainCallback(ov22_02256940, v0); + DisableHBlank(); v2 = sub_02006840(param0); v0->unk_738 = v2->unk_0C; @@ -400,8 +400,8 @@ int ov22_02256098 (UnkStruct_020067E8 * param0, int * param1) ov22_022594AC(&v0->unk_3C0); ov22_022566F4(v0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); v1 = sub_0201E530(); GF_ASSERT(v1 == 1); @@ -425,8 +425,8 @@ int ov22_02256174 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200681C(param0, sizeof(UnkStruct_ov22_02255D44), 13); memset(v0, 0, sizeof(UnkStruct_ov22_02255D44)); - sub_02017798(ov22_02256940, v0); - sub_020177A4(); + SetMainCallback(ov22_02256940, v0); + DisableHBlank(); v2 = sub_02006840(param0); @@ -661,8 +661,8 @@ int ov22_02256600 (UnkStruct_020067E8 * param0, int * param1) ov22_022594AC(&v0->unk_3C0); ov22_022566F4(v0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); v1 = sub_0201E530(); GF_ASSERT(v1 == 1); diff --git a/src/overlay022/ov22_0225B660.c b/src/overlay022/ov22_0225B660.c index 6896ede20c..0d98837762 100644 --- a/src/overlay022/ov22_0225B660.c +++ b/src/overlay022/ov22_0225B660.c @@ -72,8 +72,8 @@ int ov22_0225B660 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200681C(param0, sizeof(UnkStruct_ov22_0225B85C), 13); memset(v0, 0, sizeof(UnkStruct_ov22_0225B85C)); - sub_02017798(ov22_0225B848, v0); - sub_020177A4(); + SetMainCallback(ov22_0225B848, v0); + DisableHBlank(); v1 = sub_02006840(param0); @@ -171,8 +171,8 @@ int ov22_0225B7FC (UnkStruct_020067E8 * param0, int * param1) ov22_022555FC(&v0->unk_14); ov22_022550B4(); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_02006830(param0); Heap_Destroy(13); Heap_Destroy(14); diff --git a/src/overlay023/ov23_0223E140.c b/src/overlay023/ov23_0223E140.c index 154d214429..a4b735aefe 100644 --- a/src/overlay023/ov23_0223E140.c +++ b/src/overlay023/ov23_0223E140.c @@ -1321,7 +1321,7 @@ static void ov23_0223EE80 (UnkStruct_ov23_0223EE80 * param0) v1 = sub_02018340(29); Unk_ov23_02257740->unk_04 = v1; - sub_02017798(ov23_022411E8, v1); + SetMainCallback(ov23_022411E8, v1); ov23_02253E2C(ov23_0224219C(), v1, (512 - (18 + 12)), (((512 - (18 + 12)) - 73) - (27 * 4))); ov23_0223EC34(v1); @@ -1404,7 +1404,7 @@ static void ov23_0223F020 (UnkStruct_ov23_0223EE80 * param0) sub_0201E958(); sub_0201F8B4(); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_FreeToHeap(Unk_ov23_02257740->unk_04); Unk_ov23_02257740->unk_04 = NULL; diff --git a/src/overlay058/ov58_021D0D80.c b/src/overlay058/ov58_021D0D80.c index 129f85efb4..7477c851e7 100644 --- a/src/overlay058/ov58_021D0D80.c +++ b/src/overlay058/ov58_021D0D80.c @@ -171,8 +171,8 @@ int ov58_021D0D80 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -208,7 +208,7 @@ int ov58_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_0201E3D8(); sub_0201E450(2); - sub_02017798(ov58_021D115C, v0->unk_00); + SetMainCallback(ov58_021D115C, v0->unk_00); ov58_021D12C4(v0); ov58_021D1524(); @@ -319,7 +319,7 @@ int ov58_021D1018 (UnkStruct_020067E8 * param0, int * param1) v3 = sub_0202C168(39); sub_0202B758(v1->unk_04, v3, 4); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0200A4E4(v0->unk_1D4[0][0]); sub_0200A4E4(v0->unk_1D4[1][0]); sub_0200A6DC(v0->unk_1D4[0][1]); @@ -369,7 +369,7 @@ int ov58_021D1018 (UnkStruct_020067E8 * param0, int * param1) Heap_FreeToHeap(v0->unk_08); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(39); sub_02037B58(2); diff --git a/src/overlay059/ov59_021D0D80.c b/src/overlay059/ov59_021D0D80.c index 8d40ab7da2..35a0d28a25 100644 --- a/src/overlay059/ov59_021D0D80.c +++ b/src/overlay059/ov59_021D0D80.c @@ -175,8 +175,8 @@ int ov59_021D0D80 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -206,7 +206,7 @@ int ov59_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_0200F174(0, 17, 17, 0x0, 16, 1, 51); ov59_021D1388(v0, v1); - sub_02017798(ov59_021D1100, v0); + SetMainCallback(ov59_021D1100, v0); ov59_021D1250(v0, v1); ov59_021D1474(); @@ -330,7 +330,7 @@ int ov59_021D0FF4 (UnkStruct_020067E8 * param0, int * param1) GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB); sub_0205BEA8(0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(51); return 1; diff --git a/src/overlay061/ov61_0222BF44.c b/src/overlay061/ov61_0222BF44.c index fe295ece55..c3fdd4230a 100644 --- a/src/overlay061/ov61_0222BF44.c +++ b/src/overlay061/ov61_0222BF44.c @@ -153,8 +153,8 @@ int ov61_0222BF44 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov61_0222C664 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -202,7 +202,7 @@ int ov61_0222BF44 (UnkStruct_020067E8 * param0, int * param1) sub_02002AC8(1); sub_02002AE4(0); sub_02002B20(0); - sub_02017798(ov61_0222C1FC, v0); + SetMainCallback(ov61_0222C1FC, v0); if (v0->unk_00->unk_10) { sub_02039734(); @@ -271,8 +271,8 @@ int ov61_0222C160 (UnkStruct_020067E8 * param0, int * param1) ov61_0222C70C(v0); Heap_FreeToHeap(v0->unk_04); ov61_0222C38C(v0->unk_04); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); sub_0201E530(); sub_02002AC8(0); diff --git a/src/overlay062/ov62_0222F2C0.c b/src/overlay062/ov62_0222F2C0.c index 422f9f43ef..5f31385e3d 100644 --- a/src/overlay062/ov62_0222F2C0.c +++ b/src/overlay062/ov62_0222F2C0.c @@ -52,8 +52,8 @@ static void ov62_0222F848(UnkStruct_0208C06C * param0); void ov62_0222F2C0 (UnkStruct_0208C06C * param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); @@ -86,7 +86,7 @@ void ov62_0222F2C0 (UnkStruct_0208C06C * param0) sub_02002B20(1); } - sub_02017798(ov62_0222F8E4, param0); + SetMainCallback(ov62_0222F8E4, param0); if (param0->unk_00 != 0) { ov62_02241130(param0); @@ -212,7 +212,7 @@ void ov62_0222F514 (UnkStruct_0208C06C * param0) ov62_022411EC(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0201DC3C(); } diff --git a/src/overlay062/ov62_02237D24.c b/src/overlay062/ov62_02237D24.c index 15c9ac4a3a..9f560ba124 100644 --- a/src/overlay062/ov62_02237D24.c +++ b/src/overlay062/ov62_02237D24.c @@ -308,7 +308,7 @@ static BOOL ov62_02237F08 (UnkStruct_0208C06C * param0) ov62_02234540(param0, 0); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG2, 0); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 0); - sub_02017798(ov62_022394D8, param0); + SetMainCallback(ov62_022394D8, param0); param0->unk_08++; break; case 1: @@ -480,7 +480,7 @@ static BOOL ov62_022380B0 (UnkStruct_0208C06C * param0) Heap_FreeToHeap(v0); Overlay_UnloadByID(FS_OVERLAY_ID(overlay22)); - sub_02017798(ov62_0222F8E4, param0); + SetMainCallback(ov62_0222F8E4, param0); } else { sub_02003A2C(param0->unk_14.unk_14, 1, 0x2, v0->unk_08, param0->unk_14.unk_44); sub_02003A2C(param0->unk_14.unk_14, 3, 0xC, v0->unk_08, param0->unk_14.unk_44); @@ -569,7 +569,7 @@ static BOOL ov62_022383E4 (UnkStruct_0208C06C * param0) Heap_FreeToHeap(v0); Overlay_UnloadByID(FS_OVERLAY_ID(overlay22)); - sub_02017798(ov62_0222F8E4, param0); + SetMainCallback(ov62_0222F8E4, param0); } else { sub_02003A2C(param0->unk_14.unk_14, 1, 0x2, v0->unk_08, param0->unk_14.unk_44); sub_02003A2C(param0->unk_14.unk_14, 3, 0xC, v0->unk_08, param0->unk_14.unk_44); @@ -819,7 +819,7 @@ static BOOL ov62_0223896C (UnkStruct_0208C06C * param0) Heap_FreeToHeap(v0); Overlay_UnloadByID(FS_OVERLAY_ID(overlay22)); - sub_02017798(ov62_0222F8E4, param0); + SetMainCallback(ov62_0222F8E4, param0); } else { sub_02003A2C(param0->unk_14.unk_14, 1, 0x2, v0->unk_08, param0->unk_14.unk_44); sub_02003A2C(param0->unk_14.unk_14, 3, 0xC, v0->unk_08, param0->unk_14.unk_44); @@ -922,7 +922,7 @@ static BOOL ov62_02238D04 (UnkStruct_0208C06C * param0) GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG3, 1); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG2, 0); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, 0); - sub_02017798(ov62_022394D8, param0); + SetMainCallback(ov62_022394D8, param0); param0->unk_08++; break; case 1: diff --git a/src/overlay064/ov64_0222DCE0.c b/src/overlay064/ov64_0222DCE0.c index 995ef8fbf3..c1b861184b 100644 --- a/src/overlay064/ov64_0222DCE0.c +++ b/src/overlay064/ov64_0222DCE0.c @@ -662,8 +662,8 @@ int ov64_0222DCE0 (UnkStruct_020067E8 * param0, int * param1) ov64_02230620(&v0->unk_41C, &v0->unk_28C, &v0->unk_04, 52); ov64_022308DC(&v0->unk_444, &v0->unk_28C, &v0->unk_04, 52); - sub_02017798(ov64_0222DF3C, v0); - sub_020177A4(); + SetMainCallback(ov64_0222DF3C, v0); + DisableHBlank(); return 1; } @@ -721,8 +721,8 @@ int ov64_0222DEA4 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov64_0222DFD0 * v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov64_0222EC8C(&v0->unk_2C8, &v0->unk_28C, &v0->unk_04); ov64_0222F40C(&v0->unk_304, &v0->unk_28C, &v0->unk_04); @@ -756,14 +756,14 @@ static void ov64_0222DF48 (UnkStruct_ov64_0222DFD0 * param0, u32 param1) ov64_02230680(¶m0->unk_41C, ¶m0->unk_28C, ¶m0->unk_04, param1); ov64_02230B1C(¶m0->unk_444, ¶m0->unk_28C, ¶m0->unk_04, param1); - sub_02017798(ov64_0222DF3C, param0); - sub_020177A4(); + SetMainCallback(ov64_0222DF3C, param0); + DisableHBlank(); } static void ov64_0222DFD0 (UnkStruct_ov64_0222DFD0 * param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov64_0222EE00(¶m0->unk_2C8, ¶m0->unk_28C, ¶m0->unk_04); ov64_0222F5F4(¶m0->unk_304, ¶m0->unk_28C, ¶m0->unk_04); diff --git a/src/overlay065/ov65_0222DCE0.c b/src/overlay065/ov65_0222DCE0.c index fbafa4c302..cb2f51611d 100644 --- a/src/overlay065/ov65_0222DCE0.c +++ b/src/overlay065/ov65_0222DCE0.c @@ -703,8 +703,8 @@ static void ov65_0222E01C (UnkStruct_ov65_0222EBE0 * param0) { NARC * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -726,7 +726,7 @@ static void ov65_0222E01C (UnkStruct_ov65_0222EBE0 * param0) inline_ov61_0222C3B0(¶m0->unk_E2C, v0, 4, 54); - sub_02017798(ov65_0222E5E0, param0); + SetMainCallback(ov65_0222E5E0, param0); ov65_0222EDD0(); ov65_0222EE18(param0, v0); @@ -861,7 +861,7 @@ static void ov65_0222E47C (UnkStruct_ov65_0222EBE0 * param0) { int v0; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); inline_ov61_0222C160(¶m0->unk_E2C); diff --git a/src/overlay065/ov65_0223648C.c b/src/overlay065/ov65_0223648C.c index 393b8dff2c..af68aadf37 100644 --- a/src/overlay065/ov65_0223648C.c +++ b/src/overlay065/ov65_0223648C.c @@ -434,7 +434,7 @@ int ov65_0223648C (UnkStruct_020067E8 * param0, int * param1) ov65_0223760C(v0); ov65_022367A8(v0, v1, 96); - sub_02017798(ov65_02236780, v0); + SetMainCallback(ov65_02236780, v0); sub_02039734(); v0->unk_00.unk_27 = 1; @@ -514,7 +514,7 @@ int ov65_0223668C (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov65_022367A8 * v0 = sub_0200682C(param0); UnkStruct_0207DE04 * v1 = sub_02006840(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov65_0223761C(v0); ov65_022377E8(v0); diff --git a/src/overlay066/ov66_0222DCE0.c b/src/overlay066/ov66_0222DCE0.c index 4351fa7e4a..a52c6b764b 100644 --- a/src/overlay066/ov66_0222DCE0.c +++ b/src/overlay066/ov66_0222DCE0.c @@ -54,8 +54,8 @@ int ov66_0222DCE0 (UnkStruct_020067E8 * param0, int * param1) v0->unk_04 = ov66_0222DDF0(v0->unk_00, 104); v0->unk_08 = ov66_02230C44(v1->unk_08, v1->unk_04, v1->unk_00, v0->unk_04, 104); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); v0->unk_0C = sub_0200DA3C(ov66_0222DDDC, v0, 0); @@ -88,8 +88,8 @@ int ov66_0222DD90 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); SysTask_Done(v0->unk_0C); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov66_02230C90(v0->unk_08); ov66_0222DEEC(v0->unk_04); diff --git a/src/overlay067/ov67_0225C700.c b/src/overlay067/ov67_0225C700.c index bd4e5bb732..c172766ebd 100644 --- a/src/overlay067/ov67_0225C700.c +++ b/src/overlay067/ov67_0225C700.c @@ -197,8 +197,8 @@ int ov67_0225C700 (UnkStruct_020067E8 * param0, int * param1) ov67_0225D188(&v0->unk_10, v0->unk_0C, 1, 674, 5, 1, 22, 2, (((((((((1 + (18 + 12)) + 9)) + (27 * 4))) + (23 * 16))) + (6 * 4))), v0->unk_00, 112); ov67_0225D37C(&v0->unk_10, 21); - sub_02017798(ov67_0225CE28, v0); - sub_020177A4(); + SetMainCallback(ov67_0225CE28, v0); + DisableHBlank(); return 1; } @@ -403,8 +403,8 @@ int ov67_0225CB1C (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); inline_ov61_0222C160(&v0->unk_D4); @@ -442,8 +442,8 @@ int ov67_0225CB8C (UnkStruct_020067E8 * param0, int * param1) ov67_0225D37C(&v0->unk_10, 21); sub_02039734(); - sub_02017798(ov67_0225CE28, v0); - sub_020177A4(); + SetMainCallback(ov67_0225CE28, v0); + DisableHBlank(); return 1; } @@ -540,8 +540,8 @@ int ov67_0225CDC0 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); inline_ov61_0222C160(&v0->unk_D4); diff --git a/src/overlay068/ov68_0225C700.c b/src/overlay068/ov68_0225C700.c index b4f4fe6a29..08a94ce35d 100644 --- a/src/overlay068/ov68_0225C700.c +++ b/src/overlay068/ov68_0225C700.c @@ -355,8 +355,8 @@ int ov68_0225C700 (UnkStruct_020067E8 * param0, int * param1) GF_ASSERT(v1->unk_08 < 2); Unk_ov68_0225DEB0[v1->unk_08](&v0->unk_1DC, &v0->unk_1A8, &v0->unk_00, v1, 122); - sub_02017798(ov68_0225C914, v0); - sub_020177A4(); + SetMainCallback(ov68_0225C914, v0); + DisableHBlank(); return 1; } @@ -429,8 +429,8 @@ int ov68_0225C8A8 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); v1 = sub_02006840(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Unk_ov68_0225DEA0[v1->unk_08](&v0->unk_1DC, &v0->unk_1A8, &v0->unk_00); diff --git a/src/overlay069/ov69_0225C700.c b/src/overlay069/ov69_0225C700.c index e907457d67..0380f25657 100644 --- a/src/overlay069/ov69_0225C700.c +++ b/src/overlay069/ov69_0225C700.c @@ -724,8 +724,8 @@ int ov69_0225C700 (UnkStruct_020067E8 * param0, int * param1) ov69_0225DEC0(&v0->unk_BC70, &v0->unk_20, &v0->unk_1CC, 105); ov69_0225D030(v0, v1); - sub_02017798(ov69_0225CF90, v0); - sub_020177A4(); + SetMainCallback(ov69_0225CF90, v0); + DisableHBlank(); return 1; } @@ -795,8 +795,8 @@ int ov69_0225C8FC (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); v1 = sub_02006840(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov69_0225DFBC(&v0->unk_BC70, &v0->unk_20); ov69_0225DDC8(&v0->unk_BF64); diff --git a/src/overlay070/ov70_0225D9A4.c b/src/overlay070/ov70_0225D9A4.c index 315a502458..30f63dcdcd 100644 --- a/src/overlay070/ov70_0225D9A4.c +++ b/src/overlay070/ov70_0225D9A4.c @@ -671,8 +671,8 @@ int ov70_0225D9A4 (UnkStruct_020067E8 * param0, int * param1) v0->unk_438 = ov70_02269190(v0->unk_34, v0->unk_44C, v0->unk_450, v0->unk_444, 112, 113); v0->unk_440 = ov70_0226C60C(112, v0); - sub_02017798(ov70_0225E4C8, v0); - sub_020177A4(); + SetMainCallback(ov70_0225E4C8, v0); + DisableHBlank(); return 1; } @@ -815,8 +815,8 @@ int ov70_0225DDF8 (UnkStruct_020067E8 * param0, int * param1) v1->unk_18 = v0->unk_01; } - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov70_0226C6F8(v0->unk_440); ov70_02269204(v0->unk_438); diff --git a/src/overlay071/ov71_0223B140.c b/src/overlay071/ov71_0223B140.c index d122f34f4c..ec8fcdce8c 100644 --- a/src/overlay071/ov71_0223B140.c +++ b/src/overlay071/ov71_0223B140.c @@ -149,8 +149,8 @@ int ov71_0223B140 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov71_0223B620 * v0; NARC * v1; - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -250,7 +250,7 @@ int ov71_0223B140 (UnkStruct_020067E8 * param0, int * param1) ov71_0223C288(); - sub_02017798(ov71_0223C18C, NULL); + SetMainCallback(ov71_0223C18C, NULL); sub_020397E4(); sub_0200544C(1, (127 / 3)); sub_0200F174(2, 3, 3, 0x0, 6, 1, 25); @@ -401,7 +401,7 @@ int ov71_0223B5B8 (UnkStruct_020067E8 * param0, int * param1) sub_0201E530(); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(25); sub_0200544C(1, 127); diff --git a/src/overlay072/ov72_0223D7A0.c b/src/overlay072/ov72_0223D7A0.c index d2a182d0d3..3573abe133 100644 --- a/src/overlay072/ov72_0223D7A0.c +++ b/src/overlay072/ov72_0223D7A0.c @@ -124,8 +124,8 @@ int ov72_0223D7A0 (UnkStruct_020067E8 * param0, int * param1) case 0: sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -158,7 +158,7 @@ int ov72_0223D7A0 (UnkStruct_020067E8 * param0, int * param1) sub_0201E3D8(); sub_0201E450(1); - sub_02017798(ov72_0223DA48, v0->unk_00); + SetMainCallback(ov72_0223DA48, v0->unk_00); sub_02002BB8(2, 39); ov72_0223DB98(v0); @@ -219,7 +219,7 @@ int ov72_0223D984 (UnkStruct_020067E8 * param0, int * param1) ov72_0223E9B4(v0->unk_5BFC, v0->unk_328.unk_0C); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0200A4E4(v0->unk_1DC[0][0]); sub_0200A4E4(v0->unk_1DC[1][0]); sub_0200A6DC(v0->unk_1DC[0][1]); @@ -245,7 +245,7 @@ int ov72_0223D984 (UnkStruct_020067E8 * param0, int * param1) GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(39); return 1; diff --git a/src/overlay073/ov73_021D0D80.c b/src/overlay073/ov73_021D0D80.c index aa23b3d118..7bf08d5696 100644 --- a/src/overlay073/ov73_021D0D80.c +++ b/src/overlay073/ov73_021D0D80.c @@ -182,8 +182,8 @@ int ov73_021D0E20 (UnkStruct_020067E8 * param0, int * param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -196,7 +196,7 @@ int ov73_021D0E20 (UnkStruct_020067E8 * param0, int * param1) ov73_021D12C4(v0); ov73_021D1318(v0); - sub_02017798(ov73_021D0FF0, (void *)v0); + SetMainCallback(ov73_021D0FF0, (void *)v0); GXLayers_TurnBothDispOn(); *param1 = 1; @@ -217,7 +217,7 @@ int ov73_021D0E20 (UnkStruct_020067E8 * param0, int * param1) ov73_021D1300(v0); ov73_021D1238(v0); ov73_021D1328(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = 1; } @@ -227,7 +227,7 @@ int ov73_021D0E20 (UnkStruct_020067E8 * param0, int * param1) ov73_021D1300(v0); ov73_021D1238(v0); ov73_021D1328(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); *param1 = 4; } break; diff --git a/src/overlay073/ov73_021D3250.c b/src/overlay073/ov73_021D3250.c index ce92805713..92918a8dc3 100644 --- a/src/overlay073/ov73_021D3250.c +++ b/src/overlay073/ov73_021D3250.c @@ -78,8 +78,8 @@ int ov73_021D3280 (UnkStruct_020067E8 * param0, int * param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -90,7 +90,7 @@ int ov73_021D3280 (UnkStruct_020067E8 * param0, int * param1) ov73_021D342C(v0); ov73_021D366C(v0); - sub_02017798(ov73_021D3420, (void *)v0); + SetMainCallback(ov73_021D3420, (void *)v0); GXLayers_TurnBothDispOn(); { @@ -144,7 +144,7 @@ int ov73_021D3280 (UnkStruct_020067E8 * param0, int * param1) if (ScreenWipe_Done() == 1) { ov73_021D368C(v0); ov73_021D35F4(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = 1; } diff --git a/src/overlay074/ov74_021D0D80.c b/src/overlay074/ov74_021D0D80.c index be9480b7f6..faf70d7be5 100644 --- a/src/overlay074/ov74_021D0D80.c +++ b/src/overlay074/ov74_021D0D80.c @@ -270,8 +270,8 @@ static int ov74_021D1178 (UnkStruct_ov74_021D0D80 * param0) { switch (param0->unk_08) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -294,7 +294,7 @@ static int ov74_021D1178 (UnkStruct_ov74_021D0D80 * param0) sub_0201DBEC(32, param0->unk_00); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); sub_020397E4(); - sub_02017798(ov74_021D1118, param0); + SetMainCallback(ov74_021D1118, param0); param0->unk_08 = 0; return 1; } @@ -323,8 +323,8 @@ static int ov74_021D122C (UnkStruct_ov74_021D0D80 * param0) ov74_021D135C(param0); break; case 1: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay075/ov75_021D0D80.c b/src/overlay075/ov75_021D0D80.c index 07b30d102c..97a4fd74d4 100644 --- a/src/overlay075/ov75_021D0D80.c +++ b/src/overlay075/ov75_021D0D80.c @@ -385,8 +385,8 @@ static int ov75_021D1184 (UnkStruct_ov75_021D1184 * param0) { switch (param0->unk_04) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -403,7 +403,7 @@ static int ov75_021D1184 (UnkStruct_ov75_021D1184 * param0) return 0; } - sub_02017798(ov75_021D131C, param0); + SetMainCallback(ov75_021D131C, param0); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); sub_0200F338(0); @@ -448,7 +448,7 @@ static int ov75_021D1184 (UnkStruct_ov75_021D1184 * param0) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay076/ov76_0223D338.c b/src/overlay076/ov76_0223D338.c index 3c72aaac92..070f625fbe 100644 --- a/src/overlay076/ov76_0223D338.c +++ b/src/overlay076/ov76_0223D338.c @@ -1337,8 +1337,8 @@ static BOOL ov76_0223EB1C (UnkStruct_ov76_0223DE00 * param0) void ov76_0223EB20 (int param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -1348,8 +1348,8 @@ void ov76_0223EB20 (int param0) void ov76_0223EB54 (int param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); } void ov76_0223EB64 (BGL * param0) diff --git a/src/overlay077/ov77_021D0D80.c b/src/overlay077/ov77_021D0D80.c index 24a1aab2cb..61565f342b 100644 --- a/src/overlay077/ov77_021D0D80.c +++ b/src/overlay077/ov77_021D0D80.c @@ -183,8 +183,8 @@ static int ov77_021D0D80 (UnkStruct_020067E8 * param0, int * param1) G2S_BlendNone(); G2_BlendNone(); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -206,7 +206,7 @@ static int ov77_021D0D80 (UnkStruct_020067E8 * param0, int * param1) ov77_021D17B4(v0); ov77_021D11CC(v0); - sub_02017798(ov77_021D1178, (void *)v0); + SetMainCallback(ov77_021D1178, (void *)v0); GXLayers_TurnBothDispOn(); return 1; @@ -335,7 +335,7 @@ static int ov77_021D10FC (UnkStruct_020067E8 * param0, int * param1) int v1 = v0->unk_00; int v2 = v0->unk_4E8; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov77_021D11FC(v0); ov77_021D1908(v0); diff --git a/src/overlay077/ov77_021D25B0.c b/src/overlay077/ov77_021D25B0.c index 066abb0941..82a3420907 100644 --- a/src/overlay077/ov77_021D25B0.c +++ b/src/overlay077/ov77_021D25B0.c @@ -943,8 +943,8 @@ static int ov77_021D2D08 (UnkStruct_020067E8 * param0, int * param1) sub_0200AB84(); sub_0200F344(0, 0x7fff); sub_0200F344(1, 0x7fff); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); SetAutorepeat(4, 8); @@ -1069,7 +1069,7 @@ static void ov77_021D2F0C (UnkStruct_ov77_021D2E9C * param0) param0->unk_18.unk_0C = param0->unk_0C; param0->unk_18.unk_14 = ov77_021D670C(); - sub_02017798(ov77_021D2B30, (void *)param0); + SetMainCallback(ov77_021D2B30, (void *)param0); param0->unk_18.unk_02 = 1; } @@ -1177,7 +1177,7 @@ static BOOL ov77_021D30D0 (UnkStruct_ov77_021D2F38 * param0, const int param1) static void ov77_021D3234 (UnkStruct_ov77_021D2E9C * param0) { - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); if (param0->unk_18.unk_02) { ov77_021D67B0(param0->unk_18.unk_14); @@ -1365,7 +1365,7 @@ static void ov77_021D34A8 (UnkStruct_ov77_021D2E9C * param0) NNS_G3dGlbMaterialColorSpecEmi(GX_RGB(18, 18, 18), GX_RGB(14, 14, 14), 0); NNS_G3dGlbPolygonAttr(13, GX_POLYGONMODE_MODULATE, GX_CULL_BACK, 0, 31, GX_POLYGON_ATTR_MISC_FOG); - sub_02017798(ov77_021D2B38, (void *)param0); + SetMainCallback(ov77_021D2B38, (void *)param0); sub_0200AB4C(-16, GX_BLEND_PLANEMASK_BG3, 1); param0->unk_34.unk_02 = 1; @@ -1475,7 +1475,7 @@ static void ov77_021D36F8 (UnkStruct_ov77_021D2E9C * param0) GX_SetVisibleWnd(0); GXS_SetVisibleWnd(0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); } static void ov77_021D37C0 (UnkStruct_ov77_021D37C0 * param0) diff --git a/src/overlay078/ov78_021D0D80.c b/src/overlay078/ov78_021D0D80.c index bc33512c7c..50a62f1706 100644 --- a/src/overlay078/ov78_021D0D80.c +++ b/src/overlay078/ov78_021D0D80.c @@ -298,8 +298,8 @@ int ov78_021D0D80 (UnkStruct_020067E8 * param0, int * param1) v0->unk_704 = sub_02027AC0(v1->unk_04); sub_0201DBEC(8, 47); - sub_02017798(ov78_021D1058, v0); - sub_020177A4(); + SetMainCallback(ov78_021D1058, v0); + DisableHBlank(); sub_0201E3D8(); v3 = sub_0201E450(4); @@ -395,7 +395,7 @@ int ov78_021D0FA8 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_020425E0 * v1 = sub_02006840(param0); BOOL v2; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1->unk_00 = ov78_021D291C(v0->unk_54); diff --git a/src/overlay079/ov79_021D0D80.c b/src/overlay079/ov79_021D0D80.c index 72cb9160f0..3b2ef8b894 100644 --- a/src/overlay079/ov79_021D0D80.c +++ b/src/overlay079/ov79_021D0D80.c @@ -128,8 +128,8 @@ static int ov79_021D0E1C (UnkStruct_ov79_021D0E1C * param0) switch (param0->unk_04) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -184,7 +184,7 @@ static int ov79_021D0E1C (UnkStruct_ov79_021D0E1C * param0) sub_0201E530(); sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); @@ -422,7 +422,7 @@ static int ov79_021D122C (UnkStruct_ov79_021D0E1C * param0) case 5: ov79_021D196C(param0); ov79_021D1B24(param0, param0->unk_1B, 4); - sub_02017798(ov79_021D0F7C, param0); + SetMainCallback(ov79_021D0F7C, param0); param0->unk_08 = 0; return 1; } diff --git a/src/overlay079/ov79_021D2268.c b/src/overlay079/ov79_021D2268.c index c78de4fdfc..64d8c725a1 100644 --- a/src/overlay079/ov79_021D2268.c +++ b/src/overlay079/ov79_021D2268.c @@ -209,8 +209,8 @@ int ov79_021D22E4 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -227,7 +227,7 @@ int ov79_021D22E4 (UnkStruct_020067E8 * param0, int * param1) return 0; } - sub_02017798(ov79_021D252C, v0); + SetMainCallback(ov79_021D252C, v0); break; case 2: if (v0->unk_04++ < 4) { @@ -265,7 +265,7 @@ int ov79_021D22E4 (UnkStruct_020067E8 * param0, int * param1) case 7: sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay080/ov80_021D0D80.c b/src/overlay080/ov80_021D0D80.c index a30a2f93d1..7dba9d7e1f 100644 --- a/src/overlay080/ov80_021D0D80.c +++ b/src/overlay080/ov80_021D0D80.c @@ -204,8 +204,8 @@ static int ov80_021D0EC8 (UnkStruct_ov80_021D2A08 * param0) { switch (param0->unk_0C) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -238,7 +238,7 @@ static int ov80_021D0EC8 (UnkStruct_ov80_021D2A08 * param0) ov80_021D2A08(param0); break; case 2: - sub_02017798(ov80_021D0E68, param0); + SetMainCallback(ov80_021D0E68, param0); param0->unk_38 = Unk_ov80_021D2E94[param0->unk_00].unk_10; param0->unk_0C = 0; return 1; @@ -255,8 +255,8 @@ static void ov80_021D0FF4 (UnkStruct_ov80_021D2A08 * param0) sub_0201E530(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_BG2 | GX_PLANEMASK_BG3 | GX_PLANEMASK_OBJ, 0); GXLayers_EngineBToggleLayers(GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1 | GX_PLANEMASK_BG2 | GX_PLANEMASK_BG3 | GX_PLANEMASK_OBJ, 0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov80_021D2AC0(param0); ov80_021D12D8(param0); diff --git a/src/overlay081/ov81_021D0D80.c b/src/overlay081/ov81_021D0D80.c index e25619adaf..556fb3c90d 100644 --- a/src/overlay081/ov81_021D0D80.c +++ b/src/overlay081/ov81_021D0D80.c @@ -72,8 +72,8 @@ int ov81_021D0D80 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov81_021D1610 * v0; SaveData * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -105,7 +105,7 @@ int ov81_021D0D80 (UnkStruct_020067E8 * param0, int * param1) ov81_021D164C(v0, 0); ov81_021D1434(v0); - sub_02017798(ov81_021D0F00, v0); + SetMainCallback(ov81_021D0F00, v0); GXLayers_TurnBothDispOn(); sub_02039734(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); @@ -144,7 +144,7 @@ int ov81_021D0EC4 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov81_021D1610 * v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov81_021D1634(v0); ov81_021D101C(v0->unk_00); diff --git a/src/overlay083/ov83_0223B5A0.c b/src/overlay083/ov83_0223B5A0.c index 39c2046270..a310c59f5d 100644 --- a/src/overlay083/ov83_0223B5A0.c +++ b/src/overlay083/ov83_0223B5A0.c @@ -133,8 +133,8 @@ int ov83_0223B5B0 (UnkStruct_020067E8 * param0, int * param1) v1->unk_28 = sub_02027AC0(v0->unk_10->unk_18); v1->unk_31C = 1; - sub_02017798(ov83_0223B5A0, v0); - sub_020177A4(); + SetMainCallback(ov83_0223B5A0, v0); + DisableHBlank(); sub_02004550(12, 1183, 1); return 1; @@ -221,8 +221,8 @@ int ov83_0223B710 (UnkStruct_020067E8 * param0, int * param1) ov83_0223D1EC(v2); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); MI_CpuClear8(v2, sizeof(UnkStruct_ov83_0223B784)); sub_02006830(param0); diff --git a/src/overlay084/ov84_0223B5A0.c b/src/overlay084/ov84_0223B5A0.c index 2de13cfa90..ac510e21ab 100644 --- a/src/overlay084/ov84_0223B5A0.c +++ b/src/overlay084/ov84_0223B5A0.c @@ -396,8 +396,8 @@ int ov84_0223B5A0 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov84_0223B5A0 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -451,7 +451,7 @@ int ov84_0223B5A0 (UnkStruct_020067E8 * param0, int * param1) ov84_02240328(v0); } - sub_02017798(ov84_0223BA14, v0); + SetMainCallback(ov84_0223BA14, v0); sub_02004550(51, 0, 0); sub_020397E4(); @@ -597,7 +597,7 @@ int ov84_0223B900 (UnkStruct_020067E8 * param0, int * param1) sub_0200B3F0(v0->unk_118); NARC_dtor(v0->unk_D4); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(6); SetAutorepeat(4, 8); diff --git a/src/overlay085/ov85_02241440.c b/src/overlay085/ov85_02241440.c index ce516b9469..e5c10fd1ab 100644 --- a/src/overlay085/ov85_02241440.c +++ b/src/overlay085/ov85_02241440.c @@ -218,8 +218,8 @@ int ov85_02241440 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov85_022417E4 * v0; NARC * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -256,7 +256,7 @@ int ov85_02241440 (UnkStruct_020067E8 * param0, int * param1) ov85_02242038(v0); ov85_02242218(v0); - sub_02017798(ov85_022415F4, v0); + SetMainCallback(ov85_022415F4, v0); sub_020397E4(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); NARC_dtor(v1); @@ -304,7 +304,7 @@ int ov85_022415A0 (UnkStruct_020067E8 * param0, int * param1) Heap_FreeToHeap(v0->unk_1FC); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(36); G2_BlendNone(); diff --git a/src/overlay086/ov86_0223B140.c b/src/overlay086/ov86_0223B140.c index f67c6c6d3d..2be36ad103 100644 --- a/src/overlay086/ov86_0223B140.c +++ b/src/overlay086/ov86_0223B140.c @@ -305,7 +305,7 @@ int ov86_0223B140 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov86_0223B3C8 * v0; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Create(3, 63, 196608); v0 = sub_0200681C(param0, sizeof(UnkStruct_ov86_0223B3C8), 63); diff --git a/src/overlay087/ov87_021D106C.c b/src/overlay087/ov87_021D106C.c index cd2e201a9a..a8b6876097 100644 --- a/src/overlay087/ov87_021D106C.c +++ b/src/overlay087/ov87_021D106C.c @@ -116,7 +116,7 @@ UnkStruct_ov87_021D106C * ov87_021D106C (UnkStruct_ov87_021D0D80 * param0, const v0->unk_1F8 = Strbuf_Init(256, 61); v0->unk_1FC = Pokemon_New(61); - sub_02017798(ov87_021D11AC, v0); + SetMainCallback(ov87_021D11AC, v0); } return v0; @@ -125,7 +125,7 @@ UnkStruct_ov87_021D106C * ov87_021D106C (UnkStruct_ov87_021D0D80 * param0, const void ov87_021D1140 (UnkStruct_ov87_021D106C * param0) { if (param0) { - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_FreeToHeap(param0->unk_1FC); Strbuf_Free(param0->unk_1F8); Strbuf_Free(param0->unk_1F4); diff --git a/src/overlay088/ov88_0223B140.c b/src/overlay088/ov88_0223B140.c index 0674c65ae0..16f6e74b14 100644 --- a/src/overlay088/ov88_0223B140.c +++ b/src/overlay088/ov88_0223B140.c @@ -292,8 +292,8 @@ int ov88_0223B140 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_02095E80 * v0; NARC * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -320,7 +320,7 @@ int ov88_0223B140 (UnkStruct_020067E8 * param0, int * param1) ov88_0223C17C(v0->unk_174); sub_0200F174(0, 1, 1, 0x0, 16, 1, 26); ov88_0223C504(v0, v1); - sub_02017798(ov88_0223C0E0, v0); + SetMainCallback(ov88_0223C0E0, v0); ov88_0223C63C(); ov88_0223C66C(v0, v1); ov88_0223CBA0(v0); @@ -413,7 +413,7 @@ static void ov88_0223B3C0 (UnkStruct_02095E80 * param0) sub_02021CAC(param0->unk_39C[0], 1); sub_02021CAC(param0->unk_39C[1], 1); - sub_02017798(ov88_0223C0E0, param0); + SetMainCallback(ov88_0223C0E0, param0); NARC_dtor(v0); } @@ -906,7 +906,7 @@ int ov88_0223C03C (UnkStruct_020067E8 * param0, int * param1) sub_0200B3F0(v0->unk_178); Strbuf_Free(v0->unk_18C); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(26); return 1; diff --git a/src/overlay090/ov90_021D0D80.c b/src/overlay090/ov90_021D0D80.c index 3e9309cbde..4287fe9669 100644 --- a/src/overlay090/ov90_021D0D80.c +++ b/src/overlay090/ov90_021D0D80.c @@ -228,8 +228,8 @@ static int ov90_021D0ECC (UnkStruct_ov90_021D0ECC * param0) { switch (param0->unk_04) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -262,7 +262,7 @@ static int ov90_021D0ECC (UnkStruct_ov90_021D0ECC * param0) ov90_021D1984(param0); break; case 4: - sub_02017798(ov90_021D1034, param0); + SetMainCallback(ov90_021D1034, param0); param0->unk_04 = 0; return 1; } @@ -286,8 +286,8 @@ static int ov90_021D0F98 (UnkStruct_ov90_021D0ECC * param0) ov90_021D1280(param0); break; case 1: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay091/ov91_021D0D80.c b/src/overlay091/ov91_021D0D80.c index fdf7e3356e..5b56dc004b 100644 --- a/src/overlay091/ov91_021D0D80.c +++ b/src/overlay091/ov91_021D0D80.c @@ -383,7 +383,7 @@ int ov91_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_0201A9A4(&v0->unk_08[12]); ov91_021D2594(v0); - sub_02017798(ov91_021D0F9C, v0); + SetMainCallback(ov91_021D0F9C, v0); return 1; } @@ -455,8 +455,8 @@ static void ov91_021D0ED8 (UnkStruct_ov91_021D0ED8 * param0) { NARC * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -479,7 +479,7 @@ static void ov91_021D0ED8 (UnkStruct_ov91_021D0ED8 * param0) ov91_021D1784(param0); ov91_021D1498(param0); - sub_02017798(ov91_021D0F9C, param0); + SetMainCallback(ov91_021D0F9C, param0); NARC_dtor(v0); } @@ -492,7 +492,7 @@ static void ov91_021D0F6C (UnkStruct_ov91_021D0ED8 * param0) ov91_021D20B4(param0); sub_0201DC3C(); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); } static void ov91_021D0F9C (void * param0) diff --git a/src/overlay092/ov92_021D0D80.c b/src/overlay092/ov92_021D0D80.c index 4a9ac4eb0f..1d79a4acd5 100644 --- a/src/overlay092/ov92_021D0D80.c +++ b/src/overlay092/ov92_021D0D80.c @@ -321,8 +321,8 @@ int ov92_021D0D80 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov92_021D1B24 * v0; int v1 = 50; - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -713,7 +713,7 @@ int ov92_021D1478 (UnkStruct_020067E8 * param0, int * param1) sub_0200B3F0(v0->unk_B870); sub_0201CBA0(); Heap_FreeToHeap(v0->unk_B810); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_02006830(param0); Heap_Destroy(v1); diff --git a/src/overlay093/ov93_021D0D80.c b/src/overlay093/ov93_021D0D80.c index 8f9aa4eeba..4d4901ce3e 100644 --- a/src/overlay093/ov93_021D0D80.c +++ b/src/overlay093/ov93_021D0D80.c @@ -202,8 +202,8 @@ int ov93_021D0F58 (UnkStruct_020067E8 * param0, int * param1) static void ov93_021D0FA8 (void) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay093/ov93_021D111C.c b/src/overlay093/ov93_021D111C.c index 6c2fe5c9b2..f9039065e0 100644 --- a/src/overlay093/ov93_021D111C.c +++ b/src/overlay093/ov93_021D111C.c @@ -202,8 +202,8 @@ int ov93_021D12F0 (UnkStruct_020067E8 * param0, int * param1) static void ov93_021D133C (void) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay094/ov94_0223BCB0.c b/src/overlay094/ov94_0223BCB0.c index 544c8889c2..c5f934efc5 100644 --- a/src/overlay094/ov94_0223BCB0.c +++ b/src/overlay094/ov94_0223BCB0.c @@ -97,8 +97,8 @@ int ov94_0223BCB0 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -234,7 +234,7 @@ int ov94_0223BF54 (UnkStruct_020067E8 * param0, int * param1) Heap_FreeToHeap(v0->unk_04); Heap_FreeToHeap(v0->unk_00); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(62); return 1; @@ -503,7 +503,7 @@ static void ov94_0223C4E0 (UnkStruct_ov94_0223FD4C * param0) ov94_0223C0D4(param0); ov94_0223C32C(param0); - sub_02017798(ov94_0223BFE4, param0); + SetMainCallback(ov94_0223BFE4, param0); } static void ov94_0223C508 (UnkStruct_ov94_0223FD4C * param0) diff --git a/src/overlay095/ov95_02246C20.c b/src/overlay095/ov95_02246C20.c index 71dfe21489..b8311c206b 100644 --- a/src/overlay095/ov95_02246C20.c +++ b/src/overlay095/ov95_02246C20.c @@ -183,8 +183,8 @@ int ov95_02246C20 (UnkStruct_020067E8 * param0, int * param1) v0->unk_1B6 = BoxPokemon_GetValue((BoxPokemon *)(v0->unk_00->unk_04), MON_DATA_FORM, NULL); v0->unk_1B8 = NULL; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/overlay095/ov95_02249740.c b/src/overlay095/ov95_02249740.c index 4195d5432a..2e036692af 100644 --- a/src/overlay095/ov95_02249740.c +++ b/src/overlay095/ov95_02249740.c @@ -145,7 +145,7 @@ void ov95_02249770 (void * param0) if (v0) { int v1; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov95_02249A68(v0); ov95_02249B80(v0); diff --git a/src/overlay095/ov95_0224A390.c b/src/overlay095/ov95_0224A390.c index 563b107e64..505acdc4a0 100644 --- a/src/overlay095/ov95_0224A390.c +++ b/src/overlay095/ov95_0224A390.c @@ -131,7 +131,7 @@ void * ov95_0224A390 (UnkStruct_ov95_02247628 * param0) v0->unk_0C = 0; ov95_0224A848(&(v0->unk_34)); - sub_02017798(ov95_0224AB50, v0); + SetMainCallback(ov95_0224AB50, v0); } return v0; @@ -144,7 +144,7 @@ void ov95_0224A3CC (void * param0) if (v0) { int v1; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov95_0224A678(v0); ov95_0224A7A0(v0); diff --git a/src/overlay096/ov96_0223B6A0.c b/src/overlay096/ov96_0223B6A0.c index 9097b0de95..1d31f737ac 100644 --- a/src/overlay096/ov96_0223B6A0.c +++ b/src/overlay096/ov96_0223B6A0.c @@ -71,8 +71,8 @@ int ov96_0223B6A0 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -189,7 +189,7 @@ int ov96_0223B8CC (UnkStruct_020067E8 * param0, int * param1) sub_020334CC(); Heap_FreeToHeap(v0->unk_04); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(68); return 1; @@ -403,7 +403,7 @@ static void ov96_0223BC64 (UnkStruct_ov96_0223BF40 * param0) ov96_0223B9D0(param0); ov96_0223BB0C(param0); - sub_02017798(ov96_0223B940, param0); + SetMainCallback(ov96_0223B940, param0); } static void ov96_0223BC8C (UnkStruct_ov96_0223BF40 * param0) diff --git a/src/overlay097/ov97_0222AE60.c b/src/overlay097/ov97_0222AE60.c index d563d425a6..800f9fcc09 100644 --- a/src/overlay097/ov97_0222AE60.c +++ b/src/overlay097/ov97_0222AE60.c @@ -923,7 +923,7 @@ static void ov97_0222BC9C (UnkStruct_020067E8 * param0) sub_02019044(v1->unk_00, 1); sub_02019044(v1->unk_00, 2); Heap_FreeToHeap(v1->unk_00); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); } u16 Unk_ov97_0223DF70[] = { @@ -1065,7 +1065,7 @@ static int ov97_0222BE24 (UnkStruct_020067E8 * param0, int * param1) ov97_0222B404(v1); ov97_0222B46C(v1); - sub_02017798(ov97_0222BD48, v1->unk_00); + SetMainCallback(ov97_0222BD48, v1->unk_00); ov97_0222B9BC(v1); ov97_0222BAD8(v1, v1->unk_54); diff --git a/src/overlay097/ov97_02233B18.c b/src/overlay097/ov97_02233B18.c index b480262285..5ddfc8f766 100644 --- a/src/overlay097/ov97_02233B18.c +++ b/src/overlay097/ov97_02233B18.c @@ -1546,7 +1546,7 @@ static void ov97_022351F0 (UnkStruct_ov97_02234A2C * param0) { int v0; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); for (v0 = 0; v0 < 30; v0++) { if (param0->unk_20C[v0].unk_00) { @@ -1869,7 +1869,7 @@ static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) ov97_022340B0(v3); ov97_0223468C(v3); - sub_02017798(ov97_022353CC, v3); + SetMainCallback(ov97_022353CC, v3); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 0); if (v3->unk_04 == 1) { @@ -1979,7 +1979,7 @@ static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) ov97_02234508(v3); ov97_022343A8(v3); - sub_02017798(ov97_022353CC, v3); + SetMainCallback(ov97_022353CC, v3); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); ov97_02234B0C(v3, NULL); diff --git a/src/overlay097/ov97_02237694.c b/src/overlay097/ov97_02237694.c index 7968569e81..ef344eecc7 100644 --- a/src/overlay097/ov97_02237694.c +++ b/src/overlay097/ov97_02237694.c @@ -396,7 +396,7 @@ void ov97_02237B0C (int param0, int param1, int param2, int param3, int param4, GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); } - sub_02017798(ov97_02237E58, NULL); + SetMainCallback(ov97_02237E58, NULL); } void ov97_02237C80 (fx32 param0, fx32 param1) @@ -513,7 +513,7 @@ void ov97_02237DA0 (void) sub_0201E958(); sub_0201F8B4(); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); } u32 ov97_02237E4C (int param0) diff --git a/src/overlay098/ov98_022471C8.c b/src/overlay098/ov98_022471C8.c index 816a254b2e..ecbfa8d258 100644 --- a/src/overlay098/ov98_022471C8.c +++ b/src/overlay098/ov98_022471C8.c @@ -300,8 +300,8 @@ int ov98_022471C8 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov98_02247704 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -374,7 +374,7 @@ int ov98_022471C8 (UnkStruct_020067E8 * param0, int * param1) sub_02002AC8(1); sub_02002AE4(0); sub_02002B20(0); - sub_02017798(ov98_022474E8, v0); + SetMainCallback(ov98_022474E8, v0); return 1; } @@ -434,8 +434,8 @@ int ov98_02247440 (UnkStruct_020067E8 * param0, int * param1) ov98_02247ACC(v0); Heap_FreeToHeap(v0->unk_04); ov98_022476D0(v0->unk_04); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); sub_0201E530(); sub_02002AC8(0); diff --git a/src/overlay099/ov99_021D0D80.c b/src/overlay099/ov99_021D0D80.c index c51540d96b..2c160e0f20 100644 --- a/src/overlay099/ov99_021D0D80.c +++ b/src/overlay099/ov99_021D0D80.c @@ -95,8 +95,8 @@ int ov99_021D0D80 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov99_021D2CB0 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -172,7 +172,7 @@ int ov99_021D0D80 (UnkStruct_020067E8 * param0, int * param1) v0->unk_14 = SysTask_Start(ov99_021D1244, v0, 60000); - sub_02017798(ov99_021D1350, v0); + SetMainCallback(ov99_021D1350, v0); sub_02004550(14, 1186, 1); sub_0200AB4C(-16, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 3); @@ -284,8 +284,8 @@ int ov99_021D11A8 (UnkStruct_020067E8 * param0, int * param1) ov99_021D19A0(v0); NARC_dtor(v0->unk_10F8); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); sub_0201E530(); sub_02006830(param0); diff --git a/src/overlay100/ov100_021D0D80.c b/src/overlay100/ov100_021D0D80.c index 455aa00305..1eb277c17a 100644 --- a/src/overlay100/ov100_021D0D80.c +++ b/src/overlay100/ov100_021D0D80.c @@ -62,7 +62,7 @@ int ov100_021D0D80 (UnkStruct_020067E8 * param0, int * param1) ov100_021D1034(&v0->unk_0C); sub_0200F174(0, 1, 1, 0x0, 6 * 2, 1, 111); - sub_02017798(ov100_021D13B4, v0); + SetMainCallback(ov100_021D13B4, v0); v0->unk_0C.unk_50.unk_00 = 31; v0->unk_0C.unk_50.unk_01 = 31; @@ -155,8 +155,8 @@ int ov100_021D0F44 (UnkStruct_020067E8 * param0, int * param1) v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0200E084(&v0->unk_0C.unk_30, 1); sub_0201ACF4(&v0->unk_0C.unk_30); BGL_DeleteWindow(&v0->unk_0C.unk_30); @@ -217,8 +217,8 @@ static void ov100_021D0FA0 (UnkStruct_ov100_021D46C8 * param0) static void ov100_021D1034 (UnkStruct_ov100_021D46C8 * param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); diff --git a/src/overlay101/ov101_021D0D80.c b/src/overlay101/ov101_021D0D80.c index 0353fadeb5..556b058861 100644 --- a/src/overlay101/ov101_021D0D80.c +++ b/src/overlay101/ov101_021D0D80.c @@ -83,8 +83,8 @@ int ov101_021D0D80 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov101_021D13C8 * v1; UnkStruct_0203E348 * v2; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); Heap_Create(3, 79, 0x80000); @@ -154,7 +154,7 @@ int ov101_021D0EE4 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov101_021D0F3C * v0 = sub_0200682C(param0); UnkStruct_ov101_021D13C8 * v1 = v0->unk_04; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov101_021D0F3C(v0, v1); @@ -235,7 +235,7 @@ static void ov101_021D0F9C (UnkStruct_ov101_021D13C8 * param0) G2S_SetBG3Priority(3); G2_SetBlendAlpha(GX_BLEND_PLANEMASK_BG2, GX_BLEND_PLANEMASK_OBJ, 8, 9); - sub_02017798(ov101_021D197C, param0); + SetMainCallback(ov101_021D197C, param0); } static void ov101_021D107C (UnkStruct_ov101_021D13C8 * param0) diff --git a/src/overlay102/ov102_021D0D80.c b/src/overlay102/ov102_021D0D80.c index ac6b79c11f..782a5b8a61 100644 --- a/src/overlay102/ov102_021D0D80.c +++ b/src/overlay102/ov102_021D0D80.c @@ -84,8 +84,8 @@ int ov102_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -97,7 +97,7 @@ int ov102_021D0D80 (UnkStruct_020067E8 * param0, int * param1) ov102_021D0F8C(v0); ov102_021D1174(v0); - sub_02017798(ov102_021D0F80, (void *)v0); + SetMainCallback(ov102_021D0F80, (void *)v0); GXLayers_TurnBothDispOn(); return 1; @@ -170,7 +170,7 @@ int ov102_021D0F50 (UnkStruct_020067E8 * param0, int * param1) ov102_021D1204(v0); ov102_021D10F8(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_02006830(param0); Heap_Destroy(v1); diff --git a/src/overlay104/ov104_0223C2D4.c b/src/overlay104/ov104_0223C2D4.c index 8e5db33920..0a92ef0253 100644 --- a/src/overlay104/ov104_0223C2D4.c +++ b/src/overlay104/ov104_0223C2D4.c @@ -131,8 +131,8 @@ UnkStruct_ov104_0223C4CC * ov104_0223C2D4 (UnkStruct_0209B75C * param0) v4 = sub_02025E38(v3->unk_08); v2 = v3->unk_24; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -195,7 +195,7 @@ UnkStruct_ov104_0223C4CC * ov104_0223C2D4 (UnkStruct_0209B75C * param0) sub_02002AC8(0); sub_02002B20(0); - sub_02017798(ov104_0223C6EC, v0); + SetMainCallback(ov104_0223C6EC, v0); v0->unk_A0 = sub_0200DA04(ov104_0223C71C, v0, 10); ov104_0222EB8C(v0, &v0->unk_90, v0->unk_C1); sub_02039734(); @@ -247,8 +247,8 @@ void ov104_0223C4CC (UnkStruct_ov104_0223C4CC * param0) GX_SetVisibleWnd(GX_WNDMASK_NONE); GXS_SetVisibleWnd(GX_WNDMASK_NONE); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Destroy(94); sub_02002AC8(0); diff --git a/src/overlay105/ov105_02241AE0.c b/src/overlay105/ov105_02241AE0.c index a73a84d52b..c1b886a6c9 100644 --- a/src/overlay105/ov105_02241AE0.c +++ b/src/overlay105/ov105_02241AE0.c @@ -614,7 +614,7 @@ int ov105_02241F54 (UnkStruct_020067E8 * param0, int * param1) ov105_022451B4(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(93); Overlay_UnloadByID(FS_OVERLAY_ID(overlay104)); @@ -2830,8 +2830,8 @@ static void ov105_022452A0 (UnkStruct_ov105_02241FF4 * param0) static void ov105_022452E4 (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -2880,7 +2880,7 @@ static void ov105_0224531C (UnkStruct_ov105_02241FF4 * param0) } GXLayers_TurnBothDispOn(); - sub_02017798(ov105_0224451C, (void *)param0); + SetMainCallback(ov105_0224451C, (void *)param0); return; } diff --git a/src/overlay106/ov106_02241AE0.c b/src/overlay106/ov106_02241AE0.c index 88c4537fd4..15bd9e4802 100644 --- a/src/overlay106/ov106_02241AE0.c +++ b/src/overlay106/ov106_02241AE0.c @@ -328,7 +328,7 @@ int ov106_02241CF0 (UnkStruct_020067E8 * param0, int * param1) ov106_022423E8(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(98); Overlay_UnloadByID(FS_OVERLAY_ID(overlay104)); @@ -796,8 +796,8 @@ static void ov106_0224248C (UnkStruct_ov106_02243118 * param0) static void ov106_022424C8 (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -847,7 +847,7 @@ static void ov106_02242500 (UnkStruct_ov106_02243118 * param0) sub_02039734(); } - sub_02017798(ov106_022426E0, (void *)param0); + SetMainCallback(ov106_022426E0, (void *)param0); return; } diff --git a/src/overlay107/ov107_02241AE0.c b/src/overlay107/ov107_02241AE0.c index e90286edac..23e216892c 100644 --- a/src/overlay107/ov107_02241AE0.c +++ b/src/overlay107/ov107_02241AE0.c @@ -605,7 +605,7 @@ int ov107_02241D2C (UnkStruct_020067E8 * param0, int * param1) ov107_02242E14(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(100); Overlay_UnloadByID(FS_OVERLAY_ID(overlay104)); @@ -1433,8 +1433,8 @@ static void ov107_02242E14 (UnkStruct_ov107_02241D6C * param0) static void ov107_02242F24 (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -1539,7 +1539,7 @@ static void ov107_02242F5C (UnkStruct_ov107_02241D6C * param0) sub_02039734(); } - sub_02017798(ov107_022433EC, (void *)param0); + SetMainCallback(ov107_022433EC, (void *)param0); return; } diff --git a/src/overlay107/ov107_02245EB0.c b/src/overlay107/ov107_02245EB0.c index 26955d31a0..fc6e64b5e5 100644 --- a/src/overlay107/ov107_02245EB0.c +++ b/src/overlay107/ov107_02245EB0.c @@ -399,7 +399,7 @@ int ov107_02246130 (UnkStruct_020067E8 * param0, int * param1) ov107_02246D84(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(100); Overlay_UnloadByID(FS_OVERLAY_ID(overlay104)); @@ -1109,8 +1109,8 @@ static void ov107_02246D84 (UnkStruct_ov107_02246170 * param0) static void ov107_02246EAC (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -1206,7 +1206,7 @@ static void ov107_02246EE4 (UnkStruct_ov107_02246170 * param0) sub_02039734(); } - sub_02017798(ov107_022472E8, (void *)param0); + SetMainCallback(ov107_022472E8, (void *)param0); return; } diff --git a/src/overlay108/ov108_02241AE0.c b/src/overlay108/ov108_02241AE0.c index 5d3d391351..c6ed4c9a39 100644 --- a/src/overlay108/ov108_02241AE0.c +++ b/src/overlay108/ov108_02241AE0.c @@ -427,7 +427,7 @@ int ov108_02241D70 (UnkStruct_020067E8 * param0, int * param1) sub_0201DC3C(); ov108_02242238(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(103); Overlay_UnloadByID(FS_OVERLAY_ID(overlay104)); @@ -802,8 +802,8 @@ static void ov108_02242238 (UnkStruct_ov108_02241DB0 * param0) static void ov108_02242344 (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -880,7 +880,7 @@ static void ov108_0224237C (UnkStruct_ov108_02241DB0 * param0) sub_02039734(); } - sub_02017798(ov108_02242708, (void *)param0); + SetMainCallback(ov108_02242708, (void *)param0); return; } diff --git a/src/overlay109/ov109_021D0D80.c b/src/overlay109/ov109_021D0D80.c index 2e8474d07c..caf59cc499 100644 --- a/src/overlay109/ov109_021D0D80.c +++ b/src/overlay109/ov109_021D0D80.c @@ -447,8 +447,8 @@ int ov109_021D0D80 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_0209C194 * v1 = sub_02006840(param0); sub_020388F4(1, 1); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_02017DE0(2); Heap_Create(3, 95, 0x80000); @@ -465,7 +465,7 @@ int ov109_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_0201E3D8(); sub_0201E450(4); ov109_021D1C28(v0); - sub_02017798(ov109_021D1C00, v0); + SetMainCallback(ov109_021D1C00, v0); ov109_021D29CC(v0); ov109_021D2AF0(v0); @@ -520,7 +520,7 @@ int ov109_021D0EB4 (UnkStruct_020067E8 * param0, int * param1) ov109_021D2AF8(v0); ov109_021D1C68(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0201DC3C(); NARC_dtor(v0->unk_D80); sub_02006830(param0); diff --git a/src/overlay109/ov109_021D3D50.c b/src/overlay109/ov109_021D3D50.c index f050ba55fc..8952147923 100644 --- a/src/overlay109/ov109_021D3D50.c +++ b/src/overlay109/ov109_021D3D50.c @@ -179,8 +179,8 @@ int ov109_021D3D50 (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -207,7 +207,7 @@ int ov109_021D3D50 (UnkStruct_020067E8 * param0, int * param1) ov109_021D40F0(v0->unk_14); sub_0200F174(0, 17, 17, 0x0, 16, 1, 95); ov109_021D4300(v0, v1); - sub_02017798(ov109_021D40A8, v0); + SetMainCallback(ov109_021D40A8, v0); ov109_021D41F8(v0, v1); ov109_021D43EC(); ov109_021D441C(v0, v1); @@ -322,7 +322,7 @@ int ov109_021D3F9C (UnkStruct_020067E8 * param0, int * param1) GX_SetDispSelect(GX_DISP_SELECT_MAIN_SUB); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1->unk_0C->unk_10 = v1->unk_08; v1->unk_0C->unk_08 = ov109_021D548C(); diff --git a/src/overlay110/ov110_021D0D80.c b/src/overlay110/ov110_021D0D80.c index 3684f38343..c5ede4e7b6 100644 --- a/src/overlay110/ov110_021D0D80.c +++ b/src/overlay110/ov110_021D0D80.c @@ -106,8 +106,8 @@ int ov110_021D0D80 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_ov110_021D0F78 * v1; UnkStruct_0203E564 * v2; - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -141,7 +141,7 @@ int ov110_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_02002E7C(0, 13 * 32, 114); sub_02002E98(0, 12 * 32, 114); ov110_021D2124(v1->unk_0C, v1->unk_10, ov110_021D1208(v1->unk_06)); - sub_02017798(ov110_021D1048, (void *)v1); + SetMainCallback(ov110_021D1048, (void *)v1); (*param1) = 0; return 1; @@ -191,7 +191,7 @@ int ov110_021D0EF0 (UnkStruct_020067E8 * param0, int * param1) ov110_021D11CC(v1->unk_0C); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(114); return 1; diff --git a/src/overlay111/ov111_021D0D80.c b/src/overlay111/ov111_021D0D80.c index f3a2a23397..a2aa1156cf 100644 --- a/src/overlay111/ov111_021D0D80.c +++ b/src/overlay111/ov111_021D0D80.c @@ -444,7 +444,7 @@ int ov111_021D0F40 (UnkStruct_020067E8 * param0, int * param1) ov111_021D1C0C(v1); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(115); return 1; @@ -1139,8 +1139,8 @@ static void ov111_021D1C0C (UnkStruct_ov111_021D0F7C * param0) static void ov111_021D1D30 (void) { - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -1206,7 +1206,7 @@ static void ov111_021D1D68 (UnkStruct_ov111_021D0F7C * param0) sub_0201E3D8(); sub_0201E450(1); - sub_02017798(ov111_021D2090, (void *)param0); + SetMainCallback(ov111_021D2090, (void *)param0); return; } diff --git a/src/overlay112/ov112_0225C700.c b/src/overlay112/ov112_0225C700.c index 96b678944d..c375415911 100644 --- a/src/overlay112/ov112_0225C700.c +++ b/src/overlay112/ov112_0225C700.c @@ -364,8 +364,8 @@ int ov112_0225C700 (UnkStruct_020067E8 * param0, int * param1) ov112_0225D1EC(&v0->unk_1C8, &v0->unk_08, 107); ov112_0225D57C(&v0->unk_264, &v0->unk_08, 107); - sub_02017798(ov112_0225C964, v0); - sub_020177A4(); + SetMainCallback(ov112_0225C964, v0); + DisableHBlank(); return 1; } @@ -450,8 +450,8 @@ int ov112_0225C8FC (UnkStruct_020067E8 * param0, int * param1) ov112_0225D2D0(&v0->unk_1C8); ov112_0225CC84(&v0->unk_1B0); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); ov112_0225C9F4(&v0->unk_08); diff --git a/src/overlay113/ov113_0225C700.c b/src/overlay113/ov113_0225C700.c index f3985023c5..2c7f3a43ca 100644 --- a/src/overlay113/ov113_0225C700.c +++ b/src/overlay113/ov113_0225C700.c @@ -354,8 +354,8 @@ int ov113_0225C700 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov113_0225DBCC * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -460,7 +460,7 @@ int ov113_0225C700 (UnkStruct_020067E8 * param0, int * param1) v0->unk_18 = SysTask_Start(ov113_0225CEF0, v0, 60000); - sub_02017798(ov113_0225CF18, v0); + SetMainCallback(ov113_0225CF18, v0); return 1; } @@ -671,8 +671,8 @@ int ov113_0225CDFC (UnkStruct_020067E8 * param0, int * param1) NARC_dtor(v0->unk_160); NARC_dtor(v0->unk_164); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); sub_0201E530(); sub_02002AC8(0); diff --git a/src/overlay114/ov114_0225C700.c b/src/overlay114/ov114_0225C700.c index a5e724ad39..4b1d6722d1 100644 --- a/src/overlay114/ov114_0225C700.c +++ b/src/overlay114/ov114_0225C700.c @@ -2192,13 +2192,13 @@ static void ov114_0225DF7C (UnkStruct_ov114_0225DFFC * param0, UnkStruct_ov114_0 param0->unk_304 = sub_02013B10(param2, ¶m0->unk_04[0], ¶m0->unk_04[1]); sub_02013B80(param0->unk_304, 0); - sub_020177BC(ov114_0225E0AC, param0); + SetHBlankCallback(ov114_0225E0AC, param0); } static void ov114_0225DFFC (UnkStruct_ov114_0225DFFC * param0) { if (param0->unk_304 != NULL) { - sub_020177BC(NULL, NULL); + SetHBlankCallback(NULL, NULL); sub_02013B40(param0->unk_304); param0->unk_304 = NULL; } @@ -3684,7 +3684,7 @@ static void ov114_0225F9B8 (UnkStruct_ov114_0225FAB8 * param0, UnkStruct_ov114_0 param0->battlerType.planeMask = GX_WND_PLANEMASK_BG0 | GX_WND_PLANEMASK_BG1 | GX_WND_PLANEMASK_BG2 | GX_WND_PLANEMASK_BG3; param0->battlerType.effect = 1; - sub_020177BC(ov114_0225FCF0, param0); + SetHBlankCallback(ov114_0225FCF0, param0); sub_02021D0C(param0->unk_00[1], 2); ov114_0225FC6C(param0); @@ -3770,7 +3770,7 @@ static void ov114_0225FBF0 (UnkStruct_ov114_0225FAB8 * param0) } } - sub_020177A4(); + DisableHBlank(); GX_SetVisibleWnd(param0->unk_194); G2_SetWndOutsidePlane(param0->unk_190.planeMask, param0->unk_190.effect); diff --git a/src/overlay115/ov115_02260440.c b/src/overlay115/ov115_02260440.c index 850956de1c..c846f4e55a 100644 --- a/src/overlay115/ov115_02260440.c +++ b/src/overlay115/ov115_02260440.c @@ -136,8 +136,8 @@ int ov115_0226048C (UnkStruct_020067E8 * param0, int * param1) break; } - sub_02017798(ov115_02260A50, v0); - sub_020177A4(); + SetMainCallback(ov115_02260A50, v0); + DisableHBlank(); v0->unk_38 = 0; v0->unk_3C = 0; @@ -332,8 +332,8 @@ int ov115_0226048C (UnkStruct_020067E8 * param0, int * param1) ov115_02260D78(v0->unk_34); v0->unk_34 = NULL; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); (*param1)++; break; @@ -551,8 +551,8 @@ static void ov115_02260B30 (UnkStruct_ov115_0226095C * param0) static void ov115_02260B44 (UnkStruct_ov115_0226095C * param0, UnkStruct_ov115_02260440 * param1) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); if (param0->unk_00 != NULL) { ov114_0225C838(param0->unk_00); diff --git a/src/overlay116/ov116_022604C4.c b/src/overlay116/ov116_022604C4.c index 17cdf4a462..09a108fdb7 100644 --- a/src/overlay116/ov116_022604C4.c +++ b/src/overlay116/ov116_022604C4.c @@ -66,8 +66,8 @@ static void ov116_022604C4 (UnkStruct_ov116_0226139C * param0) param0->unk_78 = LCRNG_GetSeed(); ov116_022612CC(param0); - sub_02017798(ov116_02261794, param0); - sub_020177A4(); + SetMainCallback(ov116_02261794, param0); + DisableHBlank(); sub_0201DBEC(32, 106); sub_0200966C(NNS_G2D_VRAM_TYPE_2DMAIN, GX_OBJVRAMMODE_CHAR_1D_128K); sub_02009704(NNS_G2D_VRAM_TYPE_2DMAIN); @@ -671,8 +671,8 @@ int ov116_02260CF4 (UnkStruct_020067E8 * param0, int * param1) static void ov116_022610FC (UnkStruct_ov116_0226139C * param0) { - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201DC3C(); { diff --git a/src/overlay117/ov117_02260668.c b/src/overlay117/ov117_02260668.c index 266b919154..36a3bd805b 100644 --- a/src/overlay117/ov117_02260668.c +++ b/src/overlay117/ov117_02260668.c @@ -189,7 +189,7 @@ int ov117_02260668 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov117_02261280 * v0; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); @@ -289,7 +289,7 @@ int ov117_02260668 (UnkStruct_020067E8 * param0, int * param1) sub_02003070(v0->unk_8C, 2, v2 * 16, 3 * 0x20); } - sub_02017798(ov117_02260DA0, v0); + SetMainCallback(ov117_02260DA0, v0); if (v0->unk_00->unk_3C) { ov4_021D1E74(110); @@ -442,7 +442,7 @@ int ov117_02260C10 (UnkStruct_020067E8 * param0, int * param1) ov117_022641E4(v0); ov117_02264508(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); ov117_022615E0(v0); ov117_022618E8(v0); diff --git a/src/overlay120/ov120_021D0D80.c b/src/overlay120/ov120_021D0D80.c index 79cc0e95b0..8f56dda9c8 100644 --- a/src/overlay120/ov120_021D0D80.c +++ b/src/overlay120/ov120_021D0D80.c @@ -69,8 +69,8 @@ int ov120_021D0DB0 (UnkStruct_020067E8 * param0, int * param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -83,7 +83,7 @@ int ov120_021D0DB0 (UnkStruct_020067E8 * param0, int * param1) ov120_021D0F24(v0); ov120_021D114C(v0); - sub_02017798(ov120_021D0F18, (void *)v0); + SetMainCallback(ov120_021D0F18, (void *)v0); GXLayers_TurnBothDispOn(); v0->unk_24 = 0; @@ -131,7 +131,7 @@ int ov120_021D0DB0 (UnkStruct_020067E8 * param0, int * param1) if (ScreenWipe_Done() == 1) { ov120_021D116C(v0); ov120_021D10D4(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = 1; } break; diff --git a/src/overlay121/ov121_021D0D80.c b/src/overlay121/ov121_021D0D80.c index 92c35ed224..fa92e90d46 100644 --- a/src/overlay121/ov121_021D0D80.c +++ b/src/overlay121/ov121_021D0D80.c @@ -66,8 +66,8 @@ int ov121_021D0D80 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_ov121_021D0FF4 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -102,7 +102,7 @@ int ov121_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_02002B20(0); v0->unk_08 = SysTask_Start(ov121_021D0F68, v0, 60000); - sub_02017798(ov121_021D0F7C, v0); + SetMainCallback(ov121_021D0F7C, v0); return 1; } @@ -155,8 +155,8 @@ int ov121_021D0F14 (UnkStruct_020067E8 * param0, int * param1) ov121_021D1068(v0); ov121_021D1310(v0->unk_00); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); sub_0201E530(); sub_02002AC8(0); sub_02002AE4(0); diff --git a/src/unk_0200F174.c b/src/unk_0200F174.c index 171f418b05..80cda35196 100644 --- a/src/unk_0200F174.c +++ b/src/unk_0200F174.c @@ -422,7 +422,7 @@ void sub_0200F634 (UnkStruct_0200F600 * param0, void * param1, UnkFuncPtr_0200F6 GF_ASSERT(param0->unk_08[param3] != NULL); if ((param0->unk_10[0] == 0) && (param0->unk_10[1] == 0)) { - v0 = sub_020177BC(sub_0200F61C, param0); + v0 = SetHBlankCallback(sub_0200F61C, param0); } GF_ASSERT(v0 == 1); @@ -443,7 +443,7 @@ void sub_0200F6AC (UnkStruct_0200F600 * param0, int param1) param0->unk_10[param1] = 0; if ((param0->unk_10[0] == 0) && (param0->unk_10[1] == 0)) { - sub_020177A4(); + DisableHBlank(); } param0->unk_08[param1] = sub_0200F764; diff --git a/src/unk_02017498.c b/src/unk_02017498.c index e9cd447ce0..57c184eea5 100644 --- a/src/unk_02017498.c +++ b/src/unk_02017498.c @@ -37,8 +37,8 @@ int sub_02017498 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_02017498 * v0; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 90c194df29..47563b14f3 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -17,7 +17,7 @@ typedef struct { u32 unk_04; } UnkStruct_021BF6F0; -static void sub_02017808(BOOL param0); +static void SetHBlankEnabled(BOOL param0); void sub_0201777C(void); static void ApplyButtonModeToInput(void); @@ -46,31 +46,31 @@ void sub_0201777C (void) (void)OS_EnableIrqMask(OS_IE_V_BLANK); } -void sub_02017798 (UnkFuncPtr_02017798 param0, void * param1) +void SetMainCallback (Callback cb, void * data) { - gCoreSys.unk_00 = param0; - gCoreSys.unk_04 = param1; + gCoreSys.mainCallback = cb; + gCoreSys.mainCallbackData = data; } -void sub_020177A4 (void) +void DisableHBlank (void) { - sub_02017808(0); - gCoreSys.unk_08 = NULL; - gCoreSys.unk_0C = NULL; + SetHBlankEnabled(0); + gCoreSys.hblankCallback = NULL; + gCoreSys.hblankCallbackData = NULL; } -BOOL sub_020177BC (UnkFuncPtr_02017798 param0, void * param1) +BOOL SetHBlankCallback (Callback cb, void * data) { - if (param0 == NULL) { - sub_02017808(0); - gCoreSys.unk_08 = NULL; - gCoreSys.unk_0C = NULL; + if (cb == NULL) { + SetHBlankEnabled(0); + gCoreSys.hblankCallback = NULL; + gCoreSys.hblankCallbackData = NULL; return 1; } else { - if (gCoreSys.unk_08 == NULL) { - gCoreSys.unk_0C = param1; - gCoreSys.unk_08 = param0; - sub_02017808(1); + if (gCoreSys.hblankCallback == NULL) { + gCoreSys.hblankCallbackData = data; + gCoreSys.hblankCallback = cb; + SetHBlankEnabled(1); return 1; } else { return 0; @@ -78,29 +78,28 @@ BOOL sub_020177BC (UnkFuncPtr_02017798 param0, void * param1) } } -static void sub_020177F4 (void) +static void HBlankIntr (void) { - if (gCoreSys.unk_08) { - gCoreSys.unk_08(gCoreSys.unk_0C); + if (gCoreSys.hblankCallback) { + gCoreSys.hblankCallback(gCoreSys.hblankCallbackData); } } -static void sub_02017808 (BOOL param0) +static void SetHBlankEnabled (BOOL enabled) { - OSIrqMask v0; + OSIrqMask savedMask; OS_DisableIrq( ); - if (param0 == 0) { - v0 = OS_GetIrqMask(); + if (!enabled) { + savedMask = OS_GetIrqMask(); OS_DisableIrqMask(OS_IE_H_BLANK); - (void)GX_HBlankIntr(0); + GX_HBlankIntr(0); } else { - v0 = OS_GetIrqMask(); - - OS_SetIrqFunction(OS_IE_H_BLANK, sub_020177F4); + savedMask = OS_GetIrqMask(); + OS_SetIrqFunction(OS_IE_H_BLANK, HBlankIntr); OS_EnableIrqMask(OS_IE_H_BLANK); - (void)GX_HBlankIntr(1); + GX_HBlankIntr(1); } OS_EnableIrq( ); @@ -175,8 +174,8 @@ void sub_0201789C (void) FS_LoadTable(v1, v0); } - gCoreSys.unk_00 = NULL; - gCoreSys.unk_08 = NULL; + gCoreSys.mainCallback = NULL; + gCoreSys.hblankCallback = NULL; gCoreSys.unk_10 = NULL; gCoreSys.unk_14 = NULL; gCoreSys.unk_70 = NULL; @@ -188,12 +187,12 @@ void sub_0201789C (void) sub_0201D640(0); } -void sub_020179E4 (void) +void InitGraphics (void) { GX_SetBankForLCDC(GX_VRAM_LCDC_ALL); MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE); - (void)GX_DisableBankForLCDC(); + GX_DisableBankForLCDC(); MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE); MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE); diff --git a/src/unk_02039814.c b/src/unk_02039814.c index ac56e2cf0d..e9decd2e7d 100644 --- a/src/unk_02039814.c +++ b/src/unk_02039814.c @@ -124,8 +124,8 @@ void sub_02039834 (int param0, int param1, int param2) OS_SetIrqFunction(OS_IE_V_BLANK, sub_02039814); (void)OS_EnableIrqMask(OS_IE_V_BLANK); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/unk_02039A64.c b/src/unk_02039A64.c index 7b3b6fd135..4e877b7551 100644 --- a/src/unk_02039A64.c +++ b/src/unk_02039A64.c @@ -88,8 +88,8 @@ void sub_02039A64 (int param0, int param1) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); diff --git a/src/unk_0207AE68.c b/src/unk_0207AE68.c index f711f5115d..6a23efd694 100644 --- a/src/unk_0207AE68.c +++ b/src/unk_0207AE68.c @@ -200,7 +200,7 @@ void sub_0207B0E0 (UnkStruct_0207AE68 * param0) sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_0201A928(param0->unk_04, 1); sub_02002FA0(param0->unk_14, 0); sub_02002FA0(param0->unk_14, 1); @@ -931,7 +931,7 @@ static void sub_0207C1CC (UnkStruct_0207AE68 * param0, BGL * param1) GXLayers_TurnBothDispOn(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); - sub_02017798(sub_0207C520, param0); + SetMainCallback(sub_0207C520, param0); } static void sub_0207C460 (BGL * param0) diff --git a/src/unk_0207E0B8.c b/src/unk_0207E0B8.c index 344ea2b149..11aa032cbd 100644 --- a/src/unk_0207E0B8.c +++ b/src/unk_0207E0B8.c @@ -255,8 +255,8 @@ static int sub_0207E0B8 (UnkStruct_020067E8 * param0, int * param1) GameWindowLayout * v0; NARC * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -319,7 +319,7 @@ static int sub_0207E0B8 (UnkStruct_020067E8 * param0, int * param1) GXLayers_EngineBToggleLayers(GX_PLANEMASK_BG0, 0); } - sub_02017798(sub_0207E898, v0); + SetMainCallback(sub_0207E898, v0); sub_020397E4(); NARC_dtor(v1); @@ -655,7 +655,7 @@ static int sub_0207E7E0 (UnkStruct_020067E8 * param0, int * param1) GameWindowLayout * v0 = sub_0200682C(param0); u32 v1; - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_02082FF4(v0); sub_02081B90(v0); sub_0207EA24(v0->unk_00); diff --git a/src/unk_0208694C.c b/src/unk_0208694C.c index 712495eaa2..ad2651e4e5 100644 --- a/src/unk_0208694C.c +++ b/src/unk_0208694C.c @@ -896,8 +896,8 @@ static int sub_0208694C (UnkStruct_020067E8 * param0, int * param1) switch (*param1) { case 0: - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -922,7 +922,7 @@ static int sub_0208694C (UnkStruct_020067E8 * param0, int * param1) sub_020871B0(v0, (UnkStruct_0208737C *)sub_02006840(param0)); sub_0208769C(v0, v1); sub_02002BB8(2, 18); - sub_02017798(sub_02087190, NULL); + SetMainCallback(sub_02087190, NULL); sub_0208737C(v0, param0); sub_02002BEC(0, 18); sub_020877C4(); @@ -1199,7 +1199,7 @@ static int sub_02086F3C (UnkStruct_020067E8 * param0, int * param1) MessageLoader_Free(v0->unk_16C); sub_0200B3F0(v0->unk_168); sub_02006830(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); Heap_Destroy(18); { diff --git a/src/unk_020890F4.c b/src/unk_020890F4.c index 5c74a9970d..aba182261c 100644 --- a/src/unk_020890F4.c +++ b/src/unk_020890F4.c @@ -56,8 +56,8 @@ static int sub_020890F4 (UnkStruct_020067E8 * param0, int * param1) memset(v0, 0, sizeof(UnkStruct_02089688)); v0->unk_38C = *(( UnkStruct_02089438 * )sub_02006840(param0)); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -91,7 +91,7 @@ static int sub_020890F4 (UnkStruct_020067E8 * param0, int * param1) G2_SetBlendAlpha(GX_BLEND_PLANEMASK_NONE, GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2, 15, 7); G2S_SetBlendAlpha(GX_BLEND_PLANEMASK_NONE, GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3, 7, 8); - sub_02017798(sub_020895CC, v0); + SetMainCallback(sub_020895CC, v0); return 1; } diff --git a/src/unk_0208C324.c b/src/unk_0208C324.c index c33593cd2b..ca66ff223c 100644 --- a/src/unk_0208C324.c +++ b/src/unk_0208C324.c @@ -144,8 +144,8 @@ static int sub_0208C330 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_0208D7BC * v0; NARC * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -189,7 +189,7 @@ static int sub_0208C330 (UnkStruct_020067E8 * param0, int * param1) sub_0208D678(v0); sub_020920C0(v0); sub_020917E0(v0); - sub_02017798(sub_0208C604, v0); + SetMainCallback(sub_0208C604, v0); GXLayers_TurnBothDispOn(); sub_02004550(61, 0, 0); sub_020397E4(); @@ -281,7 +281,7 @@ static int sub_0208C5A0 (UnkStruct_020067E8 * param0, int * param1) { UnkStruct_0208D7BC * v0 = sub_0200682C(param0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); sub_020917B0(v0); sub_0208EAF4(v0); sub_0208FE88(v0); diff --git a/src/unk_02097B18.c b/src/unk_02097B18.c index 7328da6306..cacf19f893 100644 --- a/src/unk_02097B18.c +++ b/src/unk_02097B18.c @@ -181,7 +181,7 @@ static int sub_02097B18 (UnkStruct_020067E8 * param0, int * param1) } ov76_0223DCC0(v0); - sub_02017798(ov76_0223ECB0, v0); + SetMainCallback(ov76_0223ECB0, v0); ov76_0223B8A8(v0); sub_02004550(59, 0, 0); diff --git a/src/unk_02098218.c b/src/unk_02098218.c index be55b39fcd..efec79f68d 100644 --- a/src/unk_02098218.c +++ b/src/unk_02098218.c @@ -64,8 +64,8 @@ static int sub_02098218 (UnkStruct_020067E8 * param0, int * param1) UnkStruct_0209843C * v0; UnkStruct_ov119_021D0FD0 * v1; - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); Heap_Create(3, 71, 0x40000); v1 = sub_0200681C(param0, sizeof(UnkStruct_ov119_021D0FD0), 71); @@ -100,7 +100,7 @@ static int sub_02098218 (UnkStruct_020067E8 * param0, int * param1) ov119_021D17B8(&v1->unk_04); sub_0200569C(); - sub_02017798(ov119_021D0FD0, v1); + SetMainCallback(ov119_021D0FD0, v1); return 1; } @@ -192,8 +192,8 @@ static int sub_02098388 (UnkStruct_020067E8 * param0, int * param1) sub_02006830(param0); Heap_Destroy(71); - sub_02017798(NULL, NULL); - sub_020177A4(); + SetMainCallback(NULL, NULL); + DisableHBlank(); return 1; } diff --git a/src/unk_02099DFC.c b/src/unk_02099DFC.c index b68ce8c3b5..78fc101dd4 100644 --- a/src/unk_02099DFC.c +++ b/src/unk_02099DFC.c @@ -121,8 +121,8 @@ int sub_02099E38 (UnkStruct_020067E8 * param0, int * param1) sub_02004234(0); sub_0200F344(0, 0x0); sub_0200F344(1, 0x0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -132,7 +132,7 @@ int sub_02099E38 (UnkStruct_020067E8 * param0, int * param1) SetAutorepeat(4, 8); sub_02099F80(v0); sub_0209A098(v0); - sub_02017798(sub_02099F74, (void *)v0); + SetMainCallback(sub_02099F74, (void *)v0); GXLayers_TurnBothDispOn(); sub_0200F174(0, 1, 1, 0, 6, 1, v0->unk_00); *param1 = 1; @@ -152,7 +152,7 @@ int sub_02099E38 (UnkStruct_020067E8 * param0, int * param1) if (ScreenWipe_Done() == TRUE) { sub_0209A0E0(v0); sub_0209A044(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = 1; } break; diff --git a/src/unk_0209A2C4.c b/src/unk_0209A2C4.c index 42e8c3077f..1fdc0ebeec 100644 --- a/src/unk_0209A2C4.c +++ b/src/unk_0209A2C4.c @@ -106,8 +106,8 @@ int sub_0209A300 (UnkStruct_020067E8 * param0, int * param1) case 0: sub_0200F344(0, 0); sub_0200F344(1, 0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); @@ -126,7 +126,7 @@ int sub_0209A300 (UnkStruct_020067E8 * param0, int * param1) case 2: sub_0209A530(v0); sub_0209A490(v0); - sub_02017798(NULL, NULL); + SetMainCallback(NULL, NULL); v1 = 1; break; } diff --git a/src/unk_0209A74C.c b/src/unk_0209A74C.c index 81b960170a..d80c182adc 100644 --- a/src/unk_0209A74C.c +++ b/src/unk_0209A74C.c @@ -83,8 +83,8 @@ void sub_0209A74C (int param0) sub_0200F344(0, 0); sub_0200F344(1, 0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); @@ -158,8 +158,8 @@ void sub_0209A8E0 (int param0) sub_0200F344(0, 0); sub_0200F344(1, 0); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); GX_SetVisiblePlane(0); diff --git a/src/unk_0209AA74.c b/src/unk_0209AA74.c index 85b234cb22..e7da45ff63 100644 --- a/src/unk_0209AA74.c +++ b/src/unk_0209AA74.c @@ -92,8 +92,8 @@ void sub_0209AA74 (int param0, int param1) sub_0200F344(0, 0); sub_0200F344(1, 0); sub_0201777C(); - sub_02017798(NULL, NULL); - sub_020177BC(NULL, NULL); + SetMainCallback(NULL, NULL); + SetHBlankCallback(NULL, NULL); GXLayers_DisableEngineALayers(); GXLayers_DisableEngineBLayers(); From 39577afb72797aba6ed2e4abacc9dab9958f325e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 28 Jan 2024 18:49:54 +0100 Subject: [PATCH 2/6] HandleConsoleFold --- include/core_sys.h | 4 +- include/unk_02000C88.h | 4 +- include/unk_0201E3D8.h | 4 +- src/error_message_reset.c | 4 +- src/main.c | 65 +++++++++++++++++---------------- src/overlay057/ov57_021D0D80.c | 6 +-- src/overlay059/ov59_021D0D80.c | 4 +- src/overlay097/ov97_02233B18.c | 4 +- src/overlay109/ov109_021D0D80.c | 4 +- src/overlay109/ov109_021D3D50.c | 4 +- src/unk_02017728.c | 8 ++-- src/unk_0201E3D8.c | 4 +- src/unk_02039A64.c | 2 +- src/unk_0209A74C.c | 4 +- src/unk_0209AA74.c | 2 +- 15 files changed, 62 insertions(+), 61 deletions(-) diff --git a/include/core_sys.h b/include/core_sys.h index beba2e7d3d..7fbf787f50 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -43,8 +43,8 @@ typedef struct CoreSys { u8 unk_64; u8 unk_65; u8 unk_66; - u8 unk_67; - u8 unk_68; + u8 inhibitSleep; + u8 inhibitReset; u8 padding_69[3]; BOOL unk_6C; u32 * unk_70; diff --git a/include/unk_02000C88.h b/include/unk_02000C88.h index 2349c5ab1e..485a2524de 100644 --- a/include/unk_02000C88.h +++ b/include/unk_02000C88.h @@ -6,7 +6,7 @@ #include void sub_02000EC4(FSOverlayID param0, const UnkStruct_0208BE5C * param1); -void sub_02001028(void); -void sub_0200106C(void); +void InitRNG(void); +void HandleConsoleFold(void); #endif // POKEPLATINUM_UNK_02000C88_H diff --git a/include/unk_0201E3D8.h b/include/unk_0201E3D8.h index 3269eef29a..9371f09234 100644 --- a/include/unk_0201E3D8.h +++ b/include/unk_0201E3D8.h @@ -11,7 +11,7 @@ u32 sub_0201E450(u32 param0); u32 sub_0201E530(void); u32 sub_0201E564(UnkStruct_ov72_0223E2A8 * param0, u32 param1, u32 param2); void sub_0201E5C0(TPData * param0, u32 param1); -void sub_0201E5FC(void); -void sub_0201E630(void); +void AfterSleep(void); +void BeforeSleep(void); #endif // POKEPLATINUM_UNK_0201E3D8_H diff --git a/src/error_message_reset.c b/src/error_message_reset.c index 1a8a649b0b..c0c4b96c8e 100644 --- a/src/error_message_reset.c +++ b/src/error_message_reset.c @@ -167,7 +167,7 @@ void ErrorMessageReset_PrintErrorAndReset (void) sub_02037DB0(); while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); sub_020349EC(); if (sub_02038AB8()) { @@ -178,7 +178,7 @@ void ErrorMessageReset_PrintErrorAndReset (void) } while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); if (PAD_Read() & PAD_BUTTON_A) { break; diff --git a/src/main.c b/src/main.c index a8ed1af397..feab5067e0 100644 --- a/src/main.c +++ b/src/main.c @@ -60,8 +60,10 @@ static void sub_02000F94(int param0, int param1); static void sub_02000F30(void); static UnkStruct_02101D28 Unk_02101D28; -static PMBackLightSwitch Unk_02101D20; -BOOL Unk_02101D24; +// This variable doesn't really makes sense. If it's set to off, the game will +// repeatedly try to restore the backlight to its saved state. +static PMBackLightSwitch sSavedBacklightState; +BOOL gIgnoreCartridgeForWake; extern const UnkStruct_0208BE5C Unk_ov77_021D788C; void NitroMain (void) @@ -71,7 +73,7 @@ void NitroMain (void) InitKeypadAndTouchpad(); sub_02017B70(0); - PM_GetBackLight(&Unk_02101D20, NULL); + PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); sub_0201378C(); sub_02000E3C(); @@ -113,19 +115,19 @@ void NitroMain (void) gCoreSys.unk_6C = 1; gCoreSys.unk_30 = 0; - sub_02001028(); + InitRNG(); sub_0200AB84(); sub_02017428(); - Unk_02101D24 = FALSE; + gIgnoreCartridgeForWake = FALSE; while (TRUE) { sub_02000F30(); - sub_0200106C(); + HandleConsoleFold(); ReadKeypadAndTouchpad(); if ((gCoreSys.heldKeysRaw & RESET_COMBO) == RESET_COMBO) { - if (gCoreSys.unk_68 == 0) { + if (gCoreSys.inhibitReset == 0) { sub_02000F60(0); } } @@ -263,7 +265,7 @@ static void sub_02000F60 (int param0) } while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); sub_02000F10(param0); } } @@ -296,7 +298,7 @@ static void sub_02000F94 (int param0, int param1) v0 = 0; while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); ReadKeypadAndTouchpad(); if (v0 >= 30) { @@ -315,7 +317,7 @@ static void sub_02000F94 (int param0, int param1) sub_02000F60(param0); } -void sub_02001028 (void) +void InitRNG (void) { RTCDate v0; RTCTime v1; @@ -329,50 +331,49 @@ void sub_02001028 (void) LCRNG_SetSeed(v2); } -void sub_0200106C (void) +void HandleConsoleFold (void) { - PMBackLightSwitch v0, v1; - PMWakeUpTrigger v2; + PMBackLightSwitch top, bottom; + PMWakeUpTrigger trigger; if (PAD_DetectFold()) { - if (gCoreSys.unk_67 == 0) { - sub_0201E630(); + if (gCoreSys.inhibitSleep == 0) { + BeforeSleep(); if (CTRDG_IsPulledOut() == TRUE) { - Unk_02101D24 = TRUE; + gIgnoreCartridgeForWake = TRUE; } -GOTOLABEL: - v2 = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD; +sleep_again: + trigger = PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD; - if (gCoreSys.unk_66 && (Unk_02101D24 == FALSE)) { - v2 |= PM_TRIGGER_CARTRIDGE; + if (gCoreSys.unk_66 && !gIgnoreCartridgeForWake) { + trigger |= PM_TRIGGER_CARTRIDGE; } - PM_GoSleepMode(v2, 0, 0); + PM_GoSleepMode(trigger, 0, 0); if (CARD_IsPulledOut()) { PM_ForceToPowerOff(); - } else { - if (PAD_DetectFold()) { - Unk_02101D24 = TRUE; - goto GOTOLABEL; - } + } else if (PAD_DetectFold()) { + // Woke up because the cartridge got pulled out + gIgnoreCartridgeForWake = TRUE; + goto sleep_again; } - sub_0201E5FC(); + AfterSleep(); } else { - PM_GetBackLight(&v0, &v1); + PM_GetBackLight(&top, &bottom); - if (v0 == PM_BACKLIGHT_ON) { + if (top == PM_BACKLIGHT_ON) { PM_SetBackLight(PM_LCD_ALL, PM_BACKLIGHT_OFF); } } } else { - PM_GetBackLight(&v0, &v1); + PM_GetBackLight(&top, &bottom); - if (v0 == PM_BACKLIGHT_OFF) { - PM_SetBackLight(PM_LCD_ALL, Unk_02101D20); + if (top == PM_BACKLIGHT_OFF) { + PM_SetBackLight(PM_LCD_ALL, sSavedBacklightState); } } } diff --git a/src/overlay057/ov57_021D0D80.c b/src/overlay057/ov57_021D0D80.c index 27a3d2c0d5..c9e52197dd 100644 --- a/src/overlay057/ov57_021D0D80.c +++ b/src/overlay057/ov57_021D0D80.c @@ -72,7 +72,7 @@ const UnkStruct_0208BE5C Unk_ov57_021D0F70 = { static int ov57_021D0D80 (UnkStruct_020067E8 * param0, int * param1) { Heap_Create(3, 77, 131072); - sub_02001028(); + InitRNG(); return 1; } @@ -96,7 +96,7 @@ static int ov57_021D0DAC (UnkStruct_020067E8 * param0, int * param1) static int ov57_021D0DC8 (UnkStruct_020067E8 * param0, int * param1) { Heap_Create(3, 77, 131072); - sub_02001028(); + InitRNG(); return 1; } @@ -121,7 +121,7 @@ static int ov57_021D0E00 (UnkStruct_020067E8 * param0, int * param1) static int ov57_021D0E1C (UnkStruct_020067E8 * param0, int * param1) { Heap_Create(3, 77, 131072); - sub_02001028(); + InitRNG(); return 1; } diff --git a/src/overlay059/ov59_021D0D80.c b/src/overlay059/ov59_021D0D80.c index 35a0d28a25..ae44f92506 100644 --- a/src/overlay059/ov59_021D0D80.c +++ b/src/overlay059/ov59_021D0D80.c @@ -1090,7 +1090,7 @@ static int ov59_021D1DC8 (UnkStruct_020961E8 * param0, int param1) { void * v0; - gCoreSys.unk_68 = 1; + gCoreSys.inhibitReset = 1; v0 = sub_0202C1B4(51); sub_0202B758(param0->unk_08->unk_10, v0, 4); @@ -1115,7 +1115,7 @@ static int ov59_021D1E0C (UnkStruct_020961E8 * param0, int param1) param0->unk_0C.unk_00 = 0; param0->unk_3B4 = 0; - gCoreSys.unk_68 = 0; + gCoreSys.inhibitReset = 0; param0->unk_4AA4 = 0; } diff --git a/src/overlay097/ov97_02233B18.c b/src/overlay097/ov97_02233B18.c index 5ddfc8f766..f7e2085ab8 100644 --- a/src/overlay097/ov97_02233B18.c +++ b/src/overlay097/ov97_02233B18.c @@ -1819,7 +1819,7 @@ static int ov97_02235624 (UnkStruct_020067E8 * param0, int * param1) return 1; } -extern int Unk_02101D24; +extern int gIgnoreCartridgeForWake; static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) { @@ -1828,7 +1828,7 @@ static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) CTRDG_IsExisting(); - if ((CTRDG_IsPulledOut() == TRUE) || Unk_02101D24) { + if ((CTRDG_IsPulledOut() == TRUE) || gIgnoreCartridgeForWake) { UnkStruct_ov97_02233B8C * v4 = &v3->unk_E8F0; if ((v4->unk_00 == 3) || (v4->unk_00 == 4)) { diff --git a/src/overlay109/ov109_021D0D80.c b/src/overlay109/ov109_021D0D80.c index caf59cc499..3de8156a48 100644 --- a/src/overlay109/ov109_021D0D80.c +++ b/src/overlay109/ov109_021D0D80.c @@ -1369,7 +1369,7 @@ static int ov109_021D1A14 (UnkStruct_ov109_021D0F70 * param0) ov109_021D2634(param0, 11); sub_020364F0(202); - gCoreSys.unk_68 = 1; + gCoreSys.inhibitReset = 1; param0->unk_00 = 44; return 0; @@ -1393,7 +1393,7 @@ static int ov109_021D1AA8 (UnkStruct_ov109_021D0F70 * param0) param0->unk_CC->unk_14.unk_08, 2, ¶m0->unk_04); if (v0) { - gCoreSys.unk_68 = 0; + gCoreSys.inhibitReset = 0; sub_0200EBA0(param0->unk_DC8); param0->unk_00 = 48; } diff --git a/src/overlay109/ov109_021D3D50.c b/src/overlay109/ov109_021D3D50.c index 8952147923..6a02f28b49 100644 --- a/src/overlay109/ov109_021D3D50.c +++ b/src/overlay109/ov109_021D3D50.c @@ -1061,7 +1061,7 @@ static int ov109_021D4CC8 (UnkStruct_ov109_021D5140 * param0, int param1) { void * v0; - gCoreSys.unk_68 = 1; + gCoreSys.inhibitReset = 1; v0 = sub_0202C1B4(95); sub_0202B758(param0->unk_0C->unk_14.unk_18, v0, 4); @@ -1088,7 +1088,7 @@ static int ov109_021D4D20 (UnkStruct_ov109_021D5140 * param0, int param1) param0->unk_1C.unk_00 = 0; param0->unk_3C4 = 0; - gCoreSys.unk_68 = 0; + gCoreSys.inhibitReset = 0; param0->unk_10->unk_24 = 0; } diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 47563b14f3..36cccfa709 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -304,12 +304,12 @@ void sub_02017B70 (int param0) void sub_02017B7C (u8 param0) { - gCoreSys.unk_67 |= param0; + gCoreSys.inhibitSleep |= param0; } void sub_02017B8C (u8 param0) { - gCoreSys.unk_67 &= ~(param0); + gCoreSys.inhibitSleep &= ~(param0); } void ReadKeypadAndTouchpad (void) @@ -475,12 +475,12 @@ void SetAutorepeat (int rate, int delay) void sub_02017DE0 (u8 param0) { - gCoreSys.unk_68 |= param0; + gCoreSys.inhibitReset |= param0; } void sub_02017DF0 (u8 param0) { - gCoreSys.unk_68 &= ~(param0); + gCoreSys.inhibitReset &= ~(param0); } void sub_02017E00 (int param0) diff --git a/src/unk_0201E3D8.c b/src/unk_0201E3D8.c index c1b9c87f90..247031d2e7 100644 --- a/src/unk_0201E3D8.c +++ b/src/unk_0201E3D8.c @@ -193,7 +193,7 @@ void sub_0201E5C0 (TPData * param0, u32 param1) } } -void sub_0201E5FC (void) +void AfterSleep (void) { u32 v0; @@ -211,7 +211,7 @@ void sub_0201E5FC (void) Unk_021C0704.unk_5A = 0; } -void sub_0201E630 (void) +void BeforeSleep (void) { u32 v0; diff --git a/src/unk_02039A64.c b/src/unk_02039A64.c index 4e877b7551..61261662cf 100644 --- a/src/unk_02039A64.c +++ b/src/unk_02039A64.c @@ -134,7 +134,7 @@ void sub_02039A64 (int param0, int param1) while (TRUE) { int v5 = PAD_Read(); - sub_0200106C(); + HandleConsoleFold(); if (v5 & PAD_BUTTON_A) { break; diff --git a/src/unk_0209A74C.c b/src/unk_0209A74C.c index d80c182adc..b9496eacd1 100644 --- a/src/unk_0209A74C.c +++ b/src/unk_0209A74C.c @@ -128,7 +128,7 @@ void sub_0209A74C (int param0) sub_0200AB4C(0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 3); while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); OS_WaitIrq(1, OS_IE_V_BLANK); } @@ -202,7 +202,7 @@ void sub_0209A8E0 (int param0) sub_0200AB4C(0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 3); while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); OS_WaitIrq(1, OS_IE_V_BLANK); } diff --git a/src/unk_0209AA74.c b/src/unk_0209AA74.c index e7da45ff63..a4351ff356 100644 --- a/src/unk_0209AA74.c +++ b/src/unk_0209AA74.c @@ -138,7 +138,7 @@ void sub_0209AA74 (int param0, int param1) sub_0200AB4C(0, (GX_BLEND_PLANEMASK_BG0 | GX_BLEND_PLANEMASK_BG1 | GX_BLEND_PLANEMASK_BG2 | GX_BLEND_PLANEMASK_BG3 | GX_BLEND_PLANEMASK_OBJ | GX_BLEND_PLANEMASK_BD), 3); while (TRUE) { - sub_0200106C(); + HandleConsoleFold(); OS_WaitIrq(1, OS_IE_V_BLANK); } From ed382036c606c8c315f9945962fef8d9593d3acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 28 Jan 2024 19:20:13 +0100 Subject: [PATCH 3/6] WaitFrame, SoftReset, UpdateSound --- include/core_sys.h | 2 +- include/unk_02003B60.h | 2 +- src/main.c | 40 ++++++++++++++++++++-------------------- src/unk_02003B60.c | 16 +--------------- src/unk_02017728.c | 2 +- src/unk_0202854C.c | 2 +- src/unk_02034198.c | 2 +- src/unk_02051D8C.c | 2 +- 8 files changed, 27 insertions(+), 41 deletions(-) diff --git a/include/core_sys.h b/include/core_sys.h index 7fbf787f50..37d99b3538 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -24,7 +24,7 @@ typedef struct CoreSys { UnkStruct_0201CD88 * unk_20; UnkStruct_0201CD88 * unk_24; u32 * unk_28; - u32 unk_2C; + u32 frameCounter; u32 unk_30; enum ButtonMode buttonMode; u32 heldKeysRaw; diff --git a/include/unk_02003B60.h b/include/unk_02003B60.h index 4e6cd564e4..bbd8f82a8d 100644 --- a/include/unk_02003B60.h +++ b/include/unk_02003B60.h @@ -8,7 +8,7 @@ #include void sub_02003B60(ChatotCry * param0, AnimationControlFlags * param1); -void sub_02003BD8(void); +void UpdateSound(void); void sub_02003D0C(int param0); UnkStruct_02003D54 * sub_02003D54(void); void * sub_02003D5C(int param0); diff --git a/src/main.c b/src/main.c index feab5067e0..47e9c32d58 100644 --- a/src/main.c +++ b/src/main.c @@ -53,9 +53,9 @@ typedef struct { static void sub_02000E3C(void); static void sub_02000E54(void); -static void sub_02000EE4(void); +static void WaitFrame(void); static void sub_02000F10(int param0); -static void sub_02000F60(int param0); +static void SoftReset(int param0); static void sub_02000F94(int param0, int param1); static void sub_02000F30(void); @@ -128,7 +128,7 @@ void NitroMain (void) if ((gCoreSys.heldKeysRaw & RESET_COMBO) == RESET_COMBO) { if (gCoreSys.inhibitReset == 0) { - sub_02000F60(0); + SoftReset(0); } } @@ -140,7 +140,7 @@ void NitroMain (void) if (!gCoreSys.unk_30) { OS_WaitIrq(1, OS_IE_V_BLANK); - gCoreSys.unk_2C++; + gCoreSys.frameCounter++; } } @@ -151,7 +151,7 @@ void NitroMain (void) OS_WaitIrq(1, OS_IE_V_BLANK); - gCoreSys.unk_2C++; + gCoreSys.frameCounter++; gCoreSys.unk_30 = 0; sub_0200ABF0(); @@ -161,7 +161,7 @@ void NitroMain (void) gCoreSys.mainCallback(gCoreSys.mainCallbackData); } - sub_02003BD8(); + UpdateSound(); sub_0201CDD4(gCoreSys.unk_20); } } @@ -213,13 +213,13 @@ void sub_02000EC4 (FSOverlayID param0, const UnkStruct_0208BE5C * param1) Unk_02101D28.unk_0C = param1; } -static void sub_02000EE4 (void) +static void WaitFrame (void) { sub_020349EC(); OS_WaitIrq(1, OS_IE_V_BLANK); - gCoreSys.unk_2C++; + gCoreSys.frameCounter++; gCoreSys.unk_30 = 0; if (gCoreSys.mainCallback != NULL) { @@ -235,7 +235,7 @@ static void sub_02000F10 (int param0) } } - sub_02000EE4(); + WaitFrame(); } static void sub_02000F30 (void) @@ -255,7 +255,7 @@ static void sub_02000F30 (void) } } -static void sub_02000F60 (int param0) +static void SoftReset (int param0) { sub_0200F344(0, 0x7fff); sub_0200F344(1, 0x7fff); @@ -272,7 +272,7 @@ static void sub_02000F60 (int param0) static void sub_02000F94 (int param0, int param1) { - int v0; + int elapsed; BOOL v1; if (param1 == 3) { @@ -292,29 +292,29 @@ static void sub_02000F94 (int param0, int param1) } sub_02037DB0(); - sub_02000EE4(); - sub_02003BD8(); + WaitFrame(); + UpdateSound(); - v0 = 0; + elapsed = 0; while (TRUE) { HandleConsoleFold(); ReadKeypadAndTouchpad(); - if (v0 >= 30) { + if (elapsed >= 30) { if (gCoreSys.pressedKeys & PAD_BUTTON_A) { break; } } - sub_02000EE4(); + WaitFrame(); - if (v0 < 30) { - v0++; + if (elapsed < 30) { + elapsed++; } } - sub_02000F60(param0); + SoftReset(param0); } void InitRNG (void) @@ -325,7 +325,7 @@ void InitRNG (void) sub_0201384C(&v0, &v1); - v2 = v0.year + v0.month * 0x100 * v0.day * 0x10000 + v1.hour * 0x10000 + (v1.minute + v1.second) * 0x1000000 + gCoreSys.unk_2C; + v2 = v0.year + v0.month * 0x100 * v0.day * 0x10000 + v1.hour * 0x10000 + (v1.minute + v1.second) * 0x1000000 + gCoreSys.frameCounter; MTRNG_SetSeed(v2); LCRNG_SetSeed(v2); diff --git a/src/unk_02003B60.c b/src/unk_02003B60.c index cac14c96b6..da55b42272 100644 --- a/src/unk_02003B60.c +++ b/src/unk_02003B60.c @@ -61,20 +61,6 @@ struct UnkStruct_02003D54_t { u8 unk_BCDD3; }; -void sub_02003B60(ChatotCry * param0, AnimationControlFlags * param1); -void sub_02003BD8(void); -void sub_02003D0C(int param0); -UnkStruct_02003D54 * sub_02003D54(void); -void * sub_02003D5C(int param0); -int sub_02004014(int * param0); -void sub_0200403C(int param0); -BOOL sub_02004050(u16 param0); -BOOL sub_02004068(u16 param0); -BOOL sub_02004080(u16 param0, u32 param1); -BOOL sub_0200409C(u16 param0); -BOOL sub_020040B4(u16 param0); -NNSSndHandle * sub_020040CC(int param0); -int sub_020040F0(int param0); static void sub_0200413C(UnkStruct_02003D54 * param0); static void sub_02004160(UnkStruct_02003D54 * param0); static void sub_0200417C(UnkStruct_02003D54 * param0); @@ -112,7 +98,7 @@ void sub_02003B60 (ChatotCry * param0, AnimationControlFlags * param1) return; } -void sub_02003BD8 (void) +void UpdateSound (void) { int v0; UnkStruct_02003D54 * v1 = sub_02003D54(); diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 36cccfa709..5c62a72ed9 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -179,7 +179,7 @@ void sub_0201789C (void) gCoreSys.unk_10 = NULL; gCoreSys.unk_14 = NULL; gCoreSys.unk_70 = NULL; - gCoreSys.unk_2C = 0; + gCoreSys.frameCounter = 0; gCoreSys.unk_65 = 0; CARD_SetCacheFlushThreshold(0x500, 0x2400); diff --git a/src/unk_0202854C.c b/src/unk_0202854C.c index ebc56ac334..49694d7d03 100644 --- a/src/unk_0202854C.c +++ b/src/unk_0202854C.c @@ -104,7 +104,7 @@ void Underground_Init (UnkStruct_020298B0 * param0) RTCTime v2; sub_0201384C(&v1, &v2); - v0 = (((((((u32)v1.year * 32ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 32ULL + v2.minute) * 32ULL + (v2.second + gCoreSys.unk_2C)); + v0 = (((((((u32)v1.year * 32ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 32ULL + v2.minute) * 32ULL + (v2.second + gCoreSys.frameCounter)); MI_CpuFill8(param0, 0, sizeof(UnkStruct_020298B0)); diff --git a/src/unk_02034198.c b/src/unk_02034198.c index b38c38a95b..7ac0bd5e39 100644 --- a/src/unk_02034198.c +++ b/src/unk_02034198.c @@ -1877,7 +1877,7 @@ void sub_020361BC (MATHRandContext32 * param0) RTCTime v2; sub_0201384C(&v1, &v2); - v0 = (((((((u64)v1.year * 16ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 64ULL + v2.minute) * 64ULL + (v2.second + gCoreSys.unk_2C)); + v0 = (((((((u64)v1.year * 16ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 64ULL + v2.minute) * 64ULL + (v2.second + gCoreSys.frameCounter)); MATH_InitRand32(param0, v0); } diff --git a/src/unk_02051D8C.c b/src/unk_02051D8C.c index b8840fe990..77cb2970ed 100644 --- a/src/unk_02051D8C.c +++ b/src/unk_02051D8C.c @@ -120,7 +120,7 @@ BattleParams * sub_02051D8C (int param0, u32 param1) RTCTime v3; sub_0201384C(&v2, &v3); - v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.unk_2C; + v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.frameCounter; } if (sub_02035E38() == 1) { From dff30403d6f0ce2bb01f5d8cb089727eeddd6215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 28 Jan 2024 19:47:36 +0100 Subject: [PATCH 4/6] HeapCanary --- include/core_sys.h | 2 +- include/unk_02017728.h | 14 +++++++------- src/main.c | 18 ++++++++--------- src/overlay062/ov62_02248408.c | 4 ++-- src/overlay088/ov88_0223B140.c | 4 ++-- src/overlay097/ov97_02233B18.c | 18 ++++++++--------- src/overlay097/ov97_02237694.c | 6 +++--- src/overlay098/ov98_02246C20.c | 2 +- src/overlay098/ov98_022471C8.c | 12 ++++++------ src/overlay104/ov104_0222FBE4.c | 12 ++++++------ src/overlay109/ov109_021D0D80.c | 4 ++-- src/unk_02017728.c | 34 +++++++++++++++++---------------- src/unk_020244AC.c | 26 ++++++++++++------------- src/unk_0202F1D4.c | 10 +++++----- src/unk_02033200.c | 4 ++-- src/unk_020366A0.c | 24 +++++++++++------------ 16 files changed, 98 insertions(+), 96 deletions(-) diff --git a/include/core_sys.h b/include/core_sys.h index 37d99b3538..c668b2113e 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -47,7 +47,7 @@ typedef struct CoreSys { u8 inhibitReset; u8 padding_69[3]; BOOL unk_6C; - u32 * unk_70; + u32 * heapCanary; } CoreSys; extern CoreSys gCoreSys; diff --git a/include/unk_02017728.h b/include/unk_02017728.h index 4b08af564a..141d6083d9 100644 --- a/include/unk_02017728.h +++ b/include/unk_02017728.h @@ -14,14 +14,14 @@ void ReadFileToBuffer(const char * filename, void ** buf); void sub_02017ACC(void); void InitKeypadAndTouchpad(void); void sub_02017B70(int param0); -void sub_02017B7C(u8 param0); -void sub_02017B8C(u8 param0); +void SleepLock(u8 param0); +void SleepUnlock(u8 param0); void ReadKeypadAndTouchpad(void); void SetAutorepeat(int rate, int delay); -void sub_02017DE0(u8 param0); -void sub_02017DF0(u8 param0); -void sub_02017E00(int param0); -void sub_02017E2C(void); -BOOL sub_02017E54(void); +void ResetLock(u8 param0); +void ResetUnlock(u8 param0); +void InitHeapCanary(int param0); +void FreeHeapCanary(void); +BOOL HeapCanaryOK(void); #endif // POKEPLATINUM_UNK_02017728_H diff --git a/src/main.c b/src/main.c index 47e9c32d58..e359b6209c 100644 --- a/src/main.c +++ b/src/main.c @@ -56,8 +56,8 @@ static void sub_02000E54(void); static void WaitFrame(void); static void sub_02000F10(int param0); static void SoftReset(int param0); -static void sub_02000F94(int param0, int param1); -static void sub_02000F30(void); +static void HeapCanaryFailed(int param0, int param1); +static void CheckHeapCanary(void); static UnkStruct_02101D28 Unk_02101D28; // This variable doesn't really makes sense. If it's set to off, the game will @@ -122,7 +122,7 @@ void NitroMain (void) gIgnoreCartridgeForWake = FALSE; while (TRUE) { - sub_02000F30(); + CheckHeapCanary(); HandleConsoleFold(); ReadKeypadAndTouchpad(); @@ -133,7 +133,7 @@ void NitroMain (void) } if (sub_020349EC()) { - sub_02000F30(); + CheckHeapCanary(); sub_02000E54(); sub_0201CDD4(gCoreSys.unk_18); sub_0201CDD4(gCoreSys.unk_24); @@ -238,19 +238,19 @@ static void sub_02000F10 (int param0) WaitFrame(); } -static void sub_02000F30 (void) +static void CheckHeapCanary (void) { int v0 = sub_020389D8(); switch (v0) { case 1: - sub_02000F94(1, v0); + HeapCanaryFailed(1, v0); break; case 2: - sub_02000F94(0, v0); + HeapCanaryFailed(0, v0); break; case 3: - sub_02000F94(1, v0); + HeapCanaryFailed(1, v0); break; } } @@ -270,7 +270,7 @@ static void SoftReset (int param0) } } -static void sub_02000F94 (int param0, int param1) +static void HeapCanaryFailed (int param0, int param1) { int elapsed; BOOL v1; diff --git a/src/overlay062/ov62_02248408.c b/src/overlay062/ov62_02248408.c index 6453e249a8..e521366081 100644 --- a/src/overlay062/ov62_02248408.c +++ b/src/overlay062/ov62_02248408.c @@ -167,7 +167,7 @@ int ov62_022486A4 (SaveData * param0, int param1) Unk_021C07A4->unk_84.unk_60.unk_00 = sub_0202486C(param0, &Unk_021C07A4->unk_84, sizeof(UnkStruct_0202F41C) - (sizeof(UnkStruct_0202F298_sub1)) - (sizeof(u64))); sub_0202F858(&Unk_021C07A4->unk_E8, sizeof(UnkStruct_0202F298) - (sizeof(UnkStruct_0202F298_sub1)), Unk_021C07A4->unk_E8.unk_1BEC.unk_00 + ((Unk_021C07A4->unk_E8.unk_1BEC.unk_00 ^ 0xffff) << 16)); - sub_02017DE0(8); + ResetLock(8); v0 = SaveData_SaveBattleRecording(param0, Unk_021C07A4, param1); @@ -175,6 +175,6 @@ int ov62_022486A4 (SaveData * param0, int param1) v0 = sub_020246E0(param0); } - sub_02017DF0(8); + ResetUnlock(8); return v0; } diff --git a/src/overlay088/ov88_0223B140.c b/src/overlay088/ov88_0223B140.c index 16f6e74b14..b04ea5ea65 100644 --- a/src/overlay088/ov88_0223B140.c +++ b/src/overlay088/ov88_0223B140.c @@ -576,7 +576,7 @@ static int ov88_0223B914 (UnkStruct_02095E80 * param0) switch (param0->unk_4C) { case 0: sub_020364F0(80); - sub_02017DE0(2); + ResetLock(2); ov88_0223E894(param0); { @@ -753,7 +753,7 @@ static int ov88_0223B914 (UnkStruct_02095E80 * param0) sub_0200E084(¶m0->unk_49C[23], 0); sub_02019CB8(param0->unk_174, 0, 0, 0, 0, 32, 24, 0); ov88_0223ECBC(¶m0->unk_49C[21], 15, 1, param0->unk_184, param0->unk_178); - sub_02017DF0(2); + ResetUnlock(2); return 1; } diff --git a/src/overlay097/ov97_02233B18.c b/src/overlay097/ov97_02233B18.c index f7e2085ab8..d068d8fad1 100644 --- a/src/overlay097/ov97_02233B18.c +++ b/src/overlay097/ov97_02233B18.c @@ -320,7 +320,7 @@ static int ov97_02233B8C (UnkStruct_ov97_02234A2C * param0) v0 = ov97_02236280(); if (v0 == 0) { - sub_02017B8C(1); + SleepUnlock(1); return 12; } @@ -337,7 +337,7 @@ static int ov97_02233B8C (UnkStruct_ov97_02234A2C * param0) v0 = ov97_022362C8(); if (v0 == 8) { - sub_02017B8C(1); + SleepUnlock(1); return 12; } } @@ -352,19 +352,19 @@ static int ov97_02233B8C (UnkStruct_ov97_02234A2C * param0) } while (v2 != 2); ov97_022362C8(); - sub_02017B7C(1); + SleepLock(1); v4->unk_00++; break; case 9: v0 = ov97_022362C8(); if (v0 == 8) { - sub_02017B8C(1); + SleepUnlock(1); return 12; } if (v0 == 0) { - sub_02017B8C(1); + SleepUnlock(1); return 11; } break; @@ -381,10 +381,10 @@ static void ov97_02233CE4 (UnkStruct_ov97_02234A2C * param0) v0 = SaveData_PalParkTransfer(param0->unk_10); sub_0202EFB8(v0, ov97_0223635C()); - sub_02017DE0(4); + ResetLock(4); v1 = sub_020246E0(param0->unk_10); - sub_02017DF0(4); + ResetUnlock(4); } static void ov97_02233D10 (UnkStruct_ov97_02234A2C * param0) @@ -2098,7 +2098,7 @@ static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) v3->unk_E8F0.unk_00 = 0; v3->unk_E8F0.unk_08 = sub_0200E7FC(&v3->unk_4FC, (0x3F0 - (18 + 12))); *param1 = 21; - sub_02017DE0(4); + ResetLock(4); break; case 2: sub_02015A54(v3->unk_E8EC); @@ -2125,7 +2125,7 @@ static int ov97_022356E8 (UnkStruct_020067E8 * param0, int * param1) ov97_02233DD0(v3, &v3->unk_490, 0); *param1 = 22; - sub_02017DF0(4); + ResetUnlock(4); } break; case 22: diff --git a/src/overlay097/ov97_02237694.c b/src/overlay097/ov97_02237694.c index ef344eecc7..6baa87cf66 100644 --- a/src/overlay097/ov97_02237694.c +++ b/src/overlay097/ov97_02237694.c @@ -850,7 +850,7 @@ int ov97_0223847C (void) switch (v1->unk_14) { case 0: - sub_02017DE0(4); + ResetLock(4); sub_02024814(v1->unk_18, 2); v1->unk_14++; break; @@ -866,7 +866,7 @@ int ov97_0223847C (void) } if ((v0 == 2) || (v0 == 3)) { - sub_02017DF0(4); + ResetUnlock(4); } return v0; @@ -897,7 +897,7 @@ void ov97_0223850C (void) sub_02024850(v0->unk_18); v0->unk_14 = 3; - sub_02017DF0(4); + ResetUnlock(4); } int ov97_02238528 (void) diff --git a/src/overlay098/ov98_02246C20.c b/src/overlay098/ov98_02246C20.c index 813f1c89e3..e69312c38f 100644 --- a/src/overlay098/ov98_02246C20.c +++ b/src/overlay098/ov98_02246C20.c @@ -198,7 +198,7 @@ static void ov98_02246E08 (UnkStruct_ov98_02246E88 * param0) sub_02099550(); sub_020995B4(); sub_02033478(); - sub_02017B8C(4); + SleepUnlock(4); } } diff --git a/src/overlay098/ov98_022471C8.c b/src/overlay098/ov98_022471C8.c index ecbfa8d258..49f9ffd423 100644 --- a/src/overlay098/ov98_022471C8.c +++ b/src/overlay098/ov98_022471C8.c @@ -1557,7 +1557,7 @@ static int ov98_0224897C (UnkStruct_ov98_02247704 * param0) DWC_CleanupInet(); sub_02039794(); - sub_02017B8C(4); + SleepUnlock(4); if (param0->unk_00->unk_11C == 1) { ov94_0223B7AC(); @@ -1593,7 +1593,7 @@ static int ov98_022489DC (UnkStruct_ov98_02247704 * param0) } break; case 2: - sub_02017B7C(4); + SleepLock(4); DWC_InitInetEx(¶m0->unk_00->unk_14, 2, 1, 20); DWC_SetAuthServer((DWC_CONNECTINET_AUTH_RELEASE)); @@ -1627,7 +1627,7 @@ static int ov98_02248A68 (UnkStruct_ov98_02247704 * param0) sub_02039794(); sub_0203859C(); - sub_02017B8C(4); + SleepUnlock(4); if (param0->unk_00->unk_11C == 1) { ov94_0223B7AC(); @@ -1707,7 +1707,7 @@ static int ov98_02248B24 (UnkStruct_ov98_02247704 * param0) sub_02039794(); sub_0203859C(); - sub_02017B8C(4); + SleepUnlock(4); if (param0->unk_00->unk_11C == 1) { ov94_0223B7AC(); @@ -2172,7 +2172,7 @@ static int ov98_02249320 (UnkStruct_ov98_02247704 * param0) sub_02039794(); sub_0203859C(); - sub_02017B8C(4); + SleepUnlock(4); if (param0->unk_00->unk_11C == 1) { ov94_0223B7AC(); @@ -2337,7 +2337,7 @@ static int ov98_022495C4 (UnkStruct_ov98_02247704 * param0) DWC_CleanupInet(); sub_02039794(); - sub_02017B8C(4); + SleepUnlock(4); if (param0->unk_00->unk_11C == 1) { ov94_0223B7AC(); diff --git a/src/overlay104/ov104_0222FBE4.c b/src/overlay104/ov104_0222FBE4.c index 27e080656f..eaad1e247a 100644 --- a/src/overlay104/ov104_0222FBE4.c +++ b/src/overlay104/ov104_0222FBE4.c @@ -1730,8 +1730,8 @@ static BOOL ov104_02230C04 (UnkStruct_ov104_0222E930 * param0) UnkStruct_ov104_02230BE4 * v1 = sub_0209B970(param0->unk_00->unk_00); u16 * v2 = ov104_0222FBE4(param0); - sub_02017DE0(4); - sub_02017E00(v0->unk_34); + ResetLock(4); + InitHeapCanary(v0->unk_34); sub_02024814(v1->unk_08, 2); ov104_0222E974(param0, ov104_02230C3C); @@ -1746,14 +1746,14 @@ static BOOL ov104_02230C3C (UnkStruct_ov104_0222E930 * param0) v0 = sub_02024828(v1->unk_08); if (v0 == 2) { - sub_02017E2C(); - sub_02017DF0(4); + FreeHeapCanary(); + ResetUnlock(4); return 1; } if (v0 == 3) { - sub_02017E2C(); - sub_02017DF0(4); + FreeHeapCanary(); + ResetUnlock(4); return 1; } diff --git a/src/overlay109/ov109_021D0D80.c b/src/overlay109/ov109_021D0D80.c index 3de8156a48..87f0aec82b 100644 --- a/src/overlay109/ov109_021D0D80.c +++ b/src/overlay109/ov109_021D0D80.c @@ -449,7 +449,7 @@ int ov109_021D0D80 (UnkStruct_020067E8 * param0, int * param1) sub_020388F4(1, 1); SetMainCallback(NULL, NULL); DisableHBlank(); - sub_02017DE0(2); + ResetLock(2); Heap_Create(3, 95, 0x80000); v0 = sub_0200681C(param0, sizeof(UnkStruct_ov109_021D0F70), 95); @@ -525,7 +525,7 @@ int ov109_021D0EB4 (UnkStruct_020067E8 * param0, int * param1) NARC_dtor(v0->unk_D80); sub_02006830(param0); Heap_Destroy(95); - sub_02017DF0(2); + ResetUnlock(2); return 1; } diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 5c62a72ed9..27394842ff 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -178,7 +178,7 @@ void sub_0201789C (void) gCoreSys.hblankCallback = NULL; gCoreSys.unk_10 = NULL; gCoreSys.unk_14 = NULL; - gCoreSys.unk_70 = NULL; + gCoreSys.heapCanary = NULL; gCoreSys.frameCounter = 0; gCoreSys.unk_65 = 0; @@ -302,12 +302,12 @@ void sub_02017B70 (int param0) gCoreSys.unk_66 = param0; } -void sub_02017B7C (u8 param0) +void SleepLock (u8 param0) { gCoreSys.inhibitSleep |= param0; } -void sub_02017B8C (u8 param0) +void SleepUnlock (u8 param0) { gCoreSys.inhibitSleep &= ~(param0); } @@ -473,36 +473,38 @@ void SetAutorepeat (int rate, int delay) gCoreSys.autorepeatDelay = delay; } -void sub_02017DE0 (u8 param0) +void ResetLock (u8 param0) { gCoreSys.inhibitReset |= param0; } -void sub_02017DF0 (u8 param0) +void ResetUnlock (u8 param0) { gCoreSys.inhibitReset &= ~(param0); } -void sub_02017E00 (int param0) +#define HEAP_CANARY 0x2f93a1bc + +void InitHeapCanary (int heapID) { - GF_ASSERT(gCoreSys.unk_70 == NULL); + GF_ASSERT(gCoreSys.heapCanary == NULL); - gCoreSys.unk_70 = Heap_AllocFromHeapAtEnd(param0, sizeof(u32)); - *(gCoreSys.unk_70) = 0x2f93a1bc; + gCoreSys.heapCanary = Heap_AllocFromHeapAtEnd(heapID, sizeof(u32)); + *(gCoreSys.heapCanary) = HEAP_CANARY; } -void sub_02017E2C (void) +void FreeHeapCanary (void) { - GF_ASSERT(gCoreSys.unk_70 != NULL); + GF_ASSERT(gCoreSys.heapCanary != NULL); - *(gCoreSys.unk_70) = 0; - Heap_FreeToHeap(gCoreSys.unk_70); - gCoreSys.unk_70 = NULL; + *(gCoreSys.heapCanary) = 0; + Heap_FreeToHeap(gCoreSys.heapCanary); + gCoreSys.heapCanary = NULL; } -BOOL sub_02017E54 (void) +BOOL HeapCanaryOK (void) { - if ((gCoreSys.unk_70 != NULL) && (*(gCoreSys.unk_70) == 0x2f93a1bc)) { + if (gCoreSys.heapCanary && *gCoreSys.heapCanary == HEAP_CANARY) { return 1; } diff --git a/src/unk_020244AC.c b/src/unk_020244AC.c index d9e7beebbc..911e1f08a9 100644 --- a/src/unk_020244AC.c +++ b/src/unk_020244AC.c @@ -193,7 +193,7 @@ BOOL sub_020245E8 (SaveData * param0) int v0, v1; u8 * v2 = Heap_AllocFromHeapAtEnd(3, 0x1000); - sub_02017B7C(1); + SleepLock(1); sub_0202516C(param0, 0, !param0->unk_20020[0]); sub_0202516C(param0, 1, !param0->unk_20020[1]); @@ -211,7 +211,7 @@ BOOL sub_020245E8 (SaveData * param0) sub_0202479C(param0); param0->unk_04 = 0; - sub_02017B8C(1); + SleepUnlock(1); return 1; } @@ -251,14 +251,14 @@ int sub_020246E0 (SaveData * param0) } if (param0->unk_08) { - sub_02017B7C(1); + SleepLock(1); sub_0202516C(param0, 0, !param0->unk_20020[0]); sub_0202516C(param0, 1, !param0->unk_20020[1]); sub_0202516C(param0, 0, param0->unk_20020[0]); sub_0202516C(param0, 1, param0->unk_20020[1]); - sub_02017B8C(1); + SleepUnlock(1); } v0 = sub_0202513C(param0); @@ -778,7 +778,7 @@ static void sub_02024EC8 (SaveData * param0, UnkStruct_020250DC * param1, int pa param1->unk_0C = param2 + 1; } - sub_02017B7C(1); + SleepLock(1); } static int sub_02024F44 (SaveData * param0, UnkStruct_020250DC * param1) @@ -872,7 +872,7 @@ static void sub_0202506C (SaveData * param0, UnkStruct_020250DC * param1, int pa param0->unk_0C = 0; } - sub_02017B8C(1); + SleepUnlock(1); } static void sub_020250DC (SaveData * param0, UnkStruct_020250DC * param1) @@ -897,7 +897,7 @@ static void sub_020250DC (SaveData * param0, UnkStruct_020250DC * param1) param1->unk_24 = 0; } - sub_02017B8C(1); + SleepUnlock(1); } BOOL sub_0202513C (SaveData * param0) @@ -1101,7 +1101,7 @@ int SaveDataExtra_Save (const SaveData * param0, int param1, void * param2) u32 v1; BOOL v2; - sub_02017B7C(1); + SleepLock(1); GF_ASSERT(param1 < gExtraSaveTableSize); v0 = &gExtraSaveTable[param1]; @@ -1130,10 +1130,10 @@ int SaveDataExtra_Save (const SaveData * param0, int param1, void * param2) } if (v2 == 1) { - sub_02017B8C(1); + SleepUnlock(1); return 2; } else { - sub_02017B8C(1); + SleepUnlock(1); return 3; } } @@ -1146,7 +1146,7 @@ int SaveDataExtra_SaveMirror (SaveData * param0, int param1, void * param2) u32 v3, v4, v5; u8 v6; - sub_02017B7C(1); + SleepLock(1); GF_ASSERT(param1 < gExtraSaveTableSize); v0 = &gExtraSaveTable[param1]; @@ -1175,10 +1175,10 @@ int SaveDataExtra_SaveMirror (SaveData * param0, int param1, void * param2) } if (v2 == 1) { - sub_02017B8C(1); + SleepUnlock(1); return 2; } else { - sub_02017B8C(1); + SleepUnlock(1); return 3; } } diff --git a/src/unk_0202F1D4.c b/src/unk_0202F1D4.c index 0629403b8f..4792fd2ba8 100644 --- a/src/unk_0202F1D4.c +++ b/src/unk_0202F1D4.c @@ -176,8 +176,8 @@ int sub_0202F3AC (SaveData * param0, BattleRecording * param1, int param2, u16 * switch (*param3) { case 0: - sub_02017DE0(8); - sub_02017E00(11); + ResetLock(8); + InitHeapCanary(11); v0 = SaveData_SaveBattleRecording(param0, param1, param2); @@ -187,15 +187,15 @@ int sub_0202F3AC (SaveData * param0, BattleRecording * param1, int param2, u16 * return 0; } - sub_02017DF0(8); + ResetUnlock(8); return v0; case 1: v0 = sub_02024828(param0); if ((v0 == 2) || (v0 == 3)) { (*param3) = 0; - sub_02017E2C(); - sub_02017DF0(8); + FreeHeapCanary(); + ResetUnlock(8); } return v0; diff --git a/src/unk_02033200.c b/src/unk_02033200.c index d77624b166..091ef6296a 100644 --- a/src/unk_02033200.c +++ b/src/unk_02033200.c @@ -201,12 +201,12 @@ static void sub_0203344C (void * param0, WVRResult param1) static void sub_02033464 (void * param0, WVRResult param1) { Unk_021C07BC = 0; - sub_02017B8C(4); + SleepUnlock(4); } void sub_02033478 (void) { - sub_02017B7C(4); + SleepLock(4); Unk_021C07BC = 1; diff --git a/src/unk_020366A0.c b/src/unk_020366A0.c index c855df2325..313d6fc93a 100644 --- a/src/unk_020366A0.c +++ b/src/unk_020366A0.c @@ -2005,7 +2005,7 @@ void sub_02038350 (void) return; } - sub_02017DF0(1); + ResetUnlock(1); sub_02032A70(); sub_02036C94(sub_020373B8, 5); } @@ -2075,14 +2075,14 @@ void sub_02038438 (SaveData * param0) Unk_021C07D4->unk_51 = 1; Unk_021C07D4->unk_28 = param0; sub_020388F4(0, 1); - sub_02017DE0(1); + ResetLock(1); } } void sub_0203848C (void) { if (Unk_021C07D4) { - sub_02017DF0(1); + ResetUnlock(1); sub_020388F4(0, 0); Heap_FreeToHeap(Unk_021C07D4); Unk_021C07D4 = NULL; @@ -2100,14 +2100,14 @@ void sub_020384C0 (SaveData * param0) Unk_021C07D4->unk_51 = 1; Unk_021C07D4->unk_28 = param0; sub_020388F4(0, 1); - sub_02017DE0(1); + ResetLock(1); } } void sub_02038514 (void) { if (Unk_021C07D4) { - sub_02017DF0(1); + ResetUnlock(1); sub_020388F4(0, 0); Heap_FreeToHeap(Unk_021C07D4); Unk_021C07D4 = NULL; @@ -2125,14 +2125,14 @@ void sub_02038548 (SaveData * param0) Unk_021C07D4->unk_51 = 1; Unk_021C07D4->unk_28 = param0; sub_020388F4(0, 1); - sub_02017DE0(1); + ResetLock(1); } } void sub_0203859C (void) { if (Unk_021C07D4) { - sub_02017DF0(1); + ResetUnlock(1); sub_020388F4(0, 0); Heap_FreeToHeap(Unk_021C07D4); Unk_021C07D4 = NULL; @@ -2230,7 +2230,7 @@ void * sub_0203871C (SaveData * param0, int param1) return NULL; } - sub_02017DE0(1); + ResetLock(1); Heap_CreateAtEnd(3, 15, 0x7080); sub_020366A0(param0, 23); Unk_021C07D4->unk_00 = Heap_AllocFromHeap(15, param1); @@ -2252,7 +2252,7 @@ void sub_0203878C (SaveData * param0, const void * param1) return; } - sub_02017DE0(1); + ResetLock(1); Heap_CreateAtEnd(3, 15, 0x7080); sub_020366A0(param0, 33); @@ -2416,7 +2416,7 @@ void sub_020389C4 (u8 param0) u8 sub_020389D8 (void) { - if (sub_02017E54()) { + if (HeapCanaryOK()) { return 0; } @@ -2459,7 +2459,7 @@ void sub_02038A20 (int param0) if (sub_02038938()) { if (sub_020360F0() || sub_020383E8() || sub_020385D0() || (Unk_021C07D4->unk_59 != 0) || sub_0203881C()) { - if (!sub_02017E54()) { + if (!HeapCanaryOK()) { if (!sub_020389D8()) { sub_0200569C(); sub_02024850(Unk_021C07D4->unk_28); @@ -2701,7 +2701,7 @@ static void sub_02038D94 (void) v0 = ov66_02232854(); if (v0) { - sub_02017DF0(1); + ResetUnlock(1); sub_02032A70(); sub_02036C94(sub_020373B8, 5); sub_020362B4(0); From 2ca8548babd6029d6280011671205d1b8520a08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Sun, 28 Jan 2024 21:30:23 +0100 Subject: [PATCH 5/6] Label the RTC code --- include/rtc.h | 28 +++++ include/unk_0201378C.h | 20 ---- platinum.us/main.lsf | 2 +- src/main.c | 8 +- src/meson.build | 2 +- src/overlay005/ov5_021D521C.c | 6 +- src/overlay005/ov5_021F134C.c | 4 +- src/overlay006/ov6_02240C9C.c | 4 +- src/overlay006/ov6_022465FC.c | 4 +- src/overlay006/ov6_02246B74.c | 4 +- src/overlay026/ov26_022561C0.c | 6 +- src/overlay030/ov30_022561C0.c | 6 +- src/overlay045/ov45_022561C0.c | 6 +- src/overlay050/ov50_022561C0.c | 4 +- src/overlay065/ov65_0222DCE0.c | 4 +- src/overlay067/ov67_0225C700.c | 4 +- src/overlay077/ov77_021D6C70.c | 4 +- src/overlay088/ov88_0223B140.c | 4 +- src/overlay097/ov97_0222C174.c | 4 +- src/overlay097/ov97_0222D30C.c | 4 +- src/pokemon.c | 12 +- src/rtc.c | 192 +++++++++++++++++++++++++++++ src/unk_0201378C.c | 212 --------------------------------- src/unk_02025CB0.c | 6 +- src/unk_0202854C.c | 4 +- src/unk_0202ACE0.c | 4 +- src/unk_0202B604.c | 10 +- src/unk_0202E2CC.c | 4 +- src/unk_0202EEC0.c | 6 +- src/unk_02034198.c | 4 +- src/unk_0203A944.c | 4 +- src/unk_0203D1B8.c | 8 +- src/unk_0203F6C4.c | 6 +- src/unk_02051D8C.c | 6 +- src/unk_02052C6C.c | 4 +- src/unk_020553DC.c | 4 +- src/unk_020559DC.c | 8 +- src/unk_020562F8.c | 8 +- src/unk_0206A8DC.c | 12 +- src/unk_02092494.c | 4 +- src/unk_020933F8.c | 4 +- 41 files changed, 319 insertions(+), 331 deletions(-) create mode 100644 include/rtc.h delete mode 100644 include/unk_0201378C.h create mode 100644 src/rtc.c delete mode 100644 src/unk_0201378C.c diff --git a/include/rtc.h b/include/rtc.h new file mode 100644 index 0000000000..fcc1a38ea2 --- /dev/null +++ b/include/rtc.h @@ -0,0 +1,28 @@ +#ifndef POKEPLATINUM_RTC_H +#define POKEPLATINUM_RTC_H + + +#include + +enum TimeOfDay { + TOD_MORNING = 0, + TOD_DAY = 1, + TOD_TWILIGHT = 2, + TOD_NIGHT = 3, + TOD_LATE_NIGHT = 4, +}; + +void InitRTC(void); +void UpdateRTC(void); +void GetCurrentDateTime(RTCDate * date, RTCTime * time); +void GetCurrentTime(RTCTime * time); +void GetCurrentDate(RTCDate * date); +int GetSecondsSinceMidnight(void); +s64 GetTimestamp(void); +int DayNumberForDate(const RTCDate * date); +BOOL IsNight(void); +enum TimeOfDay GetTimeOfDay(void); +enum TimeOfDay TimeOfDayForHour(int hour); +s64 TimeElapsed(s64 since, s64 until); + +#endif // POKEPLATINUM_RTC_H diff --git a/include/unk_0201378C.h b/include/unk_0201378C.h deleted file mode 100644 index 8e0b9d5070..0000000000 --- a/include/unk_0201378C.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0201378C_H -#define POKEPLATINUM_UNK_0201378C_H - - -#include - -void sub_0201378C(void); -void sub_020137C4(void); -void sub_0201384C(RTCDate * param0, RTCTime * param1); -void sub_02013880(RTCTime * param0); -void sub_020138A4(RTCDate * param0); -int sub_020138C8(void); -s64 sub_020138EC(void); -int sub_02013900(const RTCDate * param0); -BOOL sub_02013948(void); -int sub_02013960(void); -int sub_02013974(int param0); -s64 sub_0201398C(s64 param0, s64 param1); - -#endif // POKEPLATINUM_UNK_0201378C_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index b00b762dfe..01ae2f2eff 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -50,7 +50,7 @@ Static main Object main.nef.p/src_unk_02012480.c.o Object main.nef.p/src_unk_02012744.c.o Object main.nef.p/src_unk_020131EC.c.o - Object main.nef.p/src_unk_0201378C.c.o + Object main.nef.p/src_rtc.c.o Object main.nef.p/src_unk_02013A04.c.o Object main.nef.p/src_unk_02013B10.c.o Object main.nef.p/src_unk_02014000.c.o diff --git a/src/main.c b/src/main.c index e359b6209c..86abd36f65 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,7 @@ #include "unk_020067E8.h" #include "unk_0200A9DC.h" #include "unk_0200F174.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02017428.h" #include "unk_02017728.h" #include "unk_0201CCF0.h" @@ -75,7 +75,7 @@ void NitroMain (void) sub_02017B70(0); PM_GetBackLight(&sSavedBacklightState, NULL); sub_0202419C(); - sub_0201378C(); + InitRTC(); sub_02000E3C(); sub_02002B7C(); @@ -144,7 +144,7 @@ void NitroMain (void) } } - sub_020137C4(); + UpdateRTC(); sub_02017458(); sub_020241CC(); sub_0201CDD4(gCoreSys.unk_24); @@ -323,7 +323,7 @@ void InitRNG (void) RTCTime v1; u32 v2; - sub_0201384C(&v0, &v1); + GetCurrentDateTime(&v0, &v1); v2 = v0.year + v0.month * 0x100 * v0.day * 0x10000 + v1.hour * 0x10000 + (v1.minute + v1.second) * 0x1000000 + gCoreSys.frameCounter; diff --git a/src/meson.build b/src/meson.build index a1f8afa532..948132a3f1 100644 --- a/src/meson.build +++ b/src/meson.build @@ -46,7 +46,7 @@ pokeplatinum_c = files( 'unk_02012480.c', 'unk_02012744.c', 'unk_020131EC.c', - 'unk_0201378C.c', + 'rtc.c', 'unk_02013A04.c', 'unk_02013B10.c', 'unk_02014000.c', diff --git a/src/overlay005/ov5_021D521C.c b/src/overlay005/ov5_021D521C.c index f8d82d5761..c110bf8e80 100644 --- a/src/overlay005/ov5_021D521C.c +++ b/src/overlay005/ov5_021D521C.c @@ -5,7 +5,7 @@ #include "overlay005/struct_ov5_021D5894.h" #include "unk_02006E3C.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_0201E0A4.h" #include "overlay005/ov5_021D521C.h" @@ -39,7 +39,7 @@ UnkStruct_ov5_021D538C * ov5_021D521C (UnkStruct_ov5_021D5894 * param0, const u8 v1->unk_00 = ov5_021D53D4(param1, &v1->unk_04); v1->unk_08 = 0; - v2 = sub_020138C8() / 2; + v2 = GetSecondsSinceMidnight() / 2; for (v0 = 0; v0 < v1->unk_00; v0++) { if (v1->unk_04[v0].unk_00 > v2) { @@ -74,7 +74,7 @@ void ov5_021D5298 (UnkStruct_ov5_021D538C * param0) GF_ASSERT(param0); - v4 = sub_020138C8() / 2; + v4 = GetSecondsSinceMidnight() / 2; if (param0->unk_00 > 1) { if ((param0->unk_08 - 1) >= 0) { diff --git a/src/overlay005/ov5_021F134C.c b/src/overlay005/ov5_021F134C.c index 7422454526..9042dff90f 100644 --- a/src/overlay005/ov5_021F134C.c +++ b/src/overlay005/ov5_021F134C.c @@ -12,7 +12,7 @@ #include "overlay101/struct_ov101_021D86B0.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02061804.h" #include "unk_020711EC.h" #include "unk_02073838.h" @@ -138,7 +138,7 @@ static void ov5_021F1424 (SysTask * param0, void * param1) int v0; UnkStruct_ov5_021F1388 * v1 = param1; - v0 = sub_02013960(); + v0 = GetTimeOfDay(); switch (v1->unk_00) { case 0: diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index 6b9688fbcf..b5f6f4f219 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -17,7 +17,7 @@ #include "overlay006/struct_ov6_02242634_sub2.h" #include "narc.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_0201D15C.h" #include "unk_02025E08.h" @@ -175,7 +175,7 @@ void ov6_02240C9C (const UnkStruct_ov6_02242634 * param0, int * param1, int * pa { int v0; - v0 = sub_02013960(); + v0 = GetTimeOfDay(); if ((v0 == 1) || (v0 == 2)) { (*param1) = param0->unk_48[0]; diff --git a/src/overlay006/ov6_022465FC.c b/src/overlay006/ov6_022465FC.c index aa9537bb68..89609432e8 100644 --- a/src/overlay006/ov6_022465FC.c +++ b/src/overlay006/ov6_022465FC.c @@ -8,7 +8,7 @@ #include "struct_defs/struct_0203CDB0.h" #include "narc.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_0201D15C.h" #include "savedata/save_table.h" #include "unk_0202E2CC.h" @@ -301,7 +301,7 @@ int ov6_02246978 (UnkStruct_0203CDB0 * param0, int param1) default: GF_ASSERT(0); case 0: - switch (sub_02013960()) { + switch (GetTimeOfDay()) { case 0: return v1->unk_00; case 1: diff --git a/src/overlay006/ov6_02246B74.c b/src/overlay006/ov6_02246B74.c index d063732933..3334ce3da2 100644 --- a/src/overlay006/ov6_02246B74.c +++ b/src/overlay006/ov6_02246B74.c @@ -1,7 +1,7 @@ #include #include -#include "unk_0201378C.h" +#include "rtc.h" #include "overlay006/ov6_02246B74.h" typedef struct { @@ -126,7 +126,7 @@ int ov6_02246B74 (const int param0, const BOOL param1) return 0; } - sub_020138A4(&v2); + GetCurrentDate(&v2); GF_ASSERT(v2.month > 0); GF_ASSERT(v2.month <= 12); diff --git a/src/overlay026/ov26_022561C0.c b/src/overlay026/ov26_022561C0.c index 800ad15b51..aaaebef433 100644 --- a/src/overlay026/ov26_022561C0.c +++ b/src/overlay026/ov26_022561C0.c @@ -12,7 +12,7 @@ #include "overlay026/struct_ov26_02256404_1.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "overlay025/ov25_02253CE0.h" #include "overlay025/ov25_02255ACC.h" @@ -85,7 +85,7 @@ static BOOL ov26_0225621C (UnkStruct_ov26_0225621C * param0, UnkStruct_ov25_0225 param0->unk_07 = 0; param0->unk_14.unk_0C = 0; - sub_02013880(&(param0->unk_14.unk_00)); + GetCurrentTime(&(param0->unk_14.unk_00)); if (param0->unk_14.unk_00.hour >= 24) { param0->unk_14.unk_00.hour %= 24; @@ -203,7 +203,7 @@ static BOOL ov26_02256370 (UnkStruct_ov26_0225621C * param0) if (ov26_022564CC(param0->unk_24, 1)) { param0->unk_06 = param0->unk_14.unk_00.minute; param0->unk_05 = param0->unk_14.unk_00.hour; - sub_02013880(&(param0->unk_14.unk_00)); + GetCurrentTime(&(param0->unk_14.unk_00)); if ((param0->unk_06 != param0->unk_14.unk_00.minute) || (param0->unk_05 != param0->unk_14.unk_00.hour)) { ov26_022564A8(param0->unk_24, 1); diff --git a/src/overlay030/ov30_022561C0.c b/src/overlay030/ov30_022561C0.c index 886ec8a1d1..2b60bd750f 100644 --- a/src/overlay030/ov30_022561C0.c +++ b/src/overlay030/ov30_022561C0.c @@ -12,7 +12,7 @@ #include "overlay030/struct_ov30_022563EC_1.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "overlay025/ov25_02253CE0.h" #include "overlay025/ov25_02255ACC.h" @@ -84,7 +84,7 @@ static BOOL ov30_0225621C (UnkStruct_ov30_0225621C * param0, UnkStruct_ov25_0225 param0->unk_06 = 0; param0->unk_14.unk_0C = 0; - sub_02013880(&(param0->unk_14.unk_00)); + GetCurrentTime(&(param0->unk_14.unk_00)); if (param0->unk_14.unk_00.hour >= 24) { param0->unk_14.unk_00.hour %= 24; @@ -201,7 +201,7 @@ static BOOL ov30_02256364 (UnkStruct_ov30_0225621C * param0) if (ov30_02256488(param0->unk_24, 1)) { param0->unk_05 = param0->unk_14.unk_00.minute; - sub_02013880(&(param0->unk_14.unk_00)); + GetCurrentTime(&(param0->unk_14.unk_00)); if (param0->unk_05 != param0->unk_14.unk_00.minute) { ov30_02256464(param0->unk_24, 1); diff --git a/src/overlay045/ov45_022561C0.c b/src/overlay045/ov45_022561C0.c index a58785a8fe..2e13d3fe68 100644 --- a/src/overlay045/ov45_022561C0.c +++ b/src/overlay045/ov45_022561C0.c @@ -13,7 +13,7 @@ #include "overlay045/struct_ov45_022566EC_1.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_02056720.h" #include "overlay025/ov25_02253CE0.h" @@ -127,7 +127,7 @@ static void ov45_022562C0 (UnkStruct_ov45_022566EC_1 * param0) { RTCTime v0; - sub_02013880(&v0); + GetCurrentTime(&v0); if (v0.hour >= 24) { v0.hour %= 24; @@ -398,7 +398,7 @@ static BOOL ov45_02256664 (UnkStruct_ov45_022561D4 * param0) static void ov45_02256668 (UnkStruct_ov45_022561D4 * param0) { if (param0->unk_2C == 0) { - sub_02013880(&(param0->unk_20)); + GetCurrentTime(&(param0->unk_20)); param0->unk_30 = 1; } } diff --git a/src/overlay050/ov50_022561C0.c b/src/overlay050/ov50_022561C0.c index 876b629f69..1ef5f661b9 100644 --- a/src/overlay050/ov50_022561C0.c +++ b/src/overlay050/ov50_022561C0.c @@ -13,7 +13,7 @@ #include "overlay050/struct_ov50_02256510_1.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_02056720.h" #include "overlay025/ov25_02253CE0.h" @@ -115,7 +115,7 @@ static BOOL ov50_0225621C (UnkStruct_ov50_022561D4 * param0, UnkStruct_ov25_0225 }; RTCDate v1; - sub_020138A4(&v1); + GetCurrentDate(&v1); param0->unk_98 = ov25_02254540(param1); ov50_022562AC(&(param0->unk_04), param0, &v1); diff --git a/src/overlay065/ov65_0222DCE0.c b/src/overlay065/ov65_0222DCE0.c index cb2f51611d..a47f298111 100644 --- a/src/overlay065/ov65_0222DCE0.c +++ b/src/overlay065/ov65_0222DCE0.c @@ -64,7 +64,7 @@ #include "unk_0200DA60.h" #include "unk_0200F174.h" #include "unk_02012744.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02013A04.h" #include "unk_02017728.h" #include "heap.h" @@ -3822,7 +3822,7 @@ static void ov65_02231A0C (void) ov4_021D2584(0); if (ov65_02231A54() == 0) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1085; } else { v0 = 1086; diff --git a/src/overlay067/ov67_0225C700.c b/src/overlay067/ov67_0225C700.c index c172766ebd..c29b0122ae 100644 --- a/src/overlay067/ov67_0225C700.c +++ b/src/overlay067/ov67_0225C700.c @@ -36,7 +36,7 @@ #include "unk_0200B358.h" #include "unk_0200DA60.h" #include "unk_0200F174.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02017728.h" #include "heap.h" #include "unk_02018340.h" @@ -286,7 +286,7 @@ int ov67_0225C820 (UnkStruct_020067E8 * param0, int * param1) } { - v1->unk_0C->unk_00 = sub_020138EC(); + v1->unk_0C->unk_00 = GetTimestamp(); } v1->unk_10 = 1; diff --git a/src/overlay077/ov77_021D6C70.c b/src/overlay077/ov77_021D6C70.c index 3660536c94..3219d035b6 100644 --- a/src/overlay077/ov77_021D6C70.c +++ b/src/overlay077/ov77_021D6C70.c @@ -11,7 +11,7 @@ #include "spl.h" #include "unk_0200762C.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02014000.h" #include "heap.h" #include "unk_02020020.h" @@ -120,7 +120,7 @@ void ov77_021D6CFC (UnkStruct_ov77_021D6CFC * param0) int v6, v7; RTCTime v8; - sub_02013880(&v8); + GetCurrentTime(&v8); v6 = (v8.hour * v8.minute + v8.second) & 1; v7 = v8.second % 3; diff --git a/src/overlay088/ov88_0223B140.c b/src/overlay088/ov88_0223B140.c index b04ea5ea65..6c959d980c 100644 --- a/src/overlay088/ov88_0223B140.c +++ b/src/overlay088/ov88_0223B140.c @@ -59,7 +59,7 @@ #include "unk_0200DA60.h" #include "unk_0200F174.h" #include "unk_020131EC.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02013A04.h" #include "unk_02017728.h" #include "heap.h" @@ -336,7 +336,7 @@ int ov88_0223B140 (UnkStruct_020067E8 * param0, int * param1) sub_02038A1C(26, v0->unk_174); sub_02039734(); - if (sub_02013948() == 0) { + if (IsNight() == 0) { sub_02004550(4, 1085, 1); sub_02004A84(1085); } else { diff --git a/src/overlay097/ov97_0222C174.c b/src/overlay097/ov97_0222C174.c index 09a129a46f..308afeeea2 100644 --- a/src/overlay097/ov97_0222C174.c +++ b/src/overlay097/ov97_0222C174.c @@ -40,7 +40,7 @@ #include "unk_0200B29C.h" #include "unk_0200B358.h" #include "unk_0200DA60.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_02018340.h" #include "unk_0201D670.h" @@ -840,7 +840,7 @@ static void ov97_0222C974 (UnkStruct_ov97_0222C388 * param0) v4->unk_34A[1] = 0; v4->unk_34A[2] = 0; v4->unk_350 = 0; - sub_020138A4(&v0); + GetCurrentDate(&v0); v4->unk_354 = RTC_ConvertDateToDay(&v0); sub_0200B3F0(v2); diff --git a/src/overlay097/ov97_0222D30C.c b/src/overlay097/ov97_0222D30C.c index 1e2b1babb0..663dca0b73 100644 --- a/src/overlay097/ov97_0222D30C.c +++ b/src/overlay097/ov97_0222D30C.c @@ -50,7 +50,7 @@ #include "unk_0200D9E8.h" #include "unk_0200DA60.h" #include "unk_0200F174.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02013A04.h" #include "unk_02017728.h" #include "heap.h" @@ -460,7 +460,7 @@ static void ov97_0222D658 (UnkStruct_020067E8 * param0) v4->val2.unk_348 = 0; } - sub_020138A4(&v7); + GetCurrentDate(&v7); v4->val2.unk_354 = RTC_ConvertDateToDay(&v7); } diff --git a/src/pokemon.c b/src/pokemon.c index 166544ac21..a2e4b7d35e 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -40,7 +40,7 @@ #include "message.h" #include "unk_0200B29C.h" #include "unk_0200C6E4.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02015F84.h" #include "unk_02017038.h" #include "heap.h" @@ -3139,13 +3139,13 @@ u16 sub_02076B94(Party *party, Pokemon *mon, u8 evoTypeList, u16 evoParam, int * } break; case 2: // high friendship && daytime - if (sub_02013948() == 0 && 220 <= monFriendship) { + if (IsNight() == 0 && 220 <= monFriendship) { targetSpecies = monEvolutionData->methods[i].targetSpecies; evoTypeResult[0] = 2; } break; case 3: // high friendship && nighttime - if (sub_02013948() == 1 && 220 <= monFriendship) { + if (IsNight() == 1 && 220 <= monFriendship) { targetSpecies = monEvolutionData->methods[i].targetSpecies; evoTypeResult[0] = 3; } @@ -3212,13 +3212,13 @@ u16 sub_02076B94(Party *party, Pokemon *mon, u8 evoTypeList, u16 evoParam, int * } break; case 18: // happiny evo: hold param && daytime - if (sub_02013948() == 0 && monEvolutionData->methods[i].param == monHeldItem) { + if (IsNight() == 0 && monEvolutionData->methods[i].param == monHeldItem) { targetSpecies = monEvolutionData->methods[i].targetSpecies; evoTypeResult[0] = 18; } break; case 19: // sneasel and gligar evo: hold param && nighttime - if (sub_02013948() == 1 && monEvolutionData->methods[i].param == monHeldItem) { + if (IsNight() == 1 && monEvolutionData->methods[i].param == monHeldItem) { targetSpecies = monEvolutionData->methods[i].targetSpecies; evoTypeResult[0] = 19; } @@ -4036,7 +4036,7 @@ BOOL Pokemon_CanShayminSkyForm(Pokemon *mon) u32 monFatefulEncounter = Pokemon_GetValue(mon, MON_DATA_FATEFUL_ENCOUNTER, NULL); RTCTime rtcTime; - sub_02013880(&rtcTime); + GetCurrentTime(&rtcTime); return (monSpecies == SPECIES_SHAYMIN && monForm == 0 diff --git a/src/rtc.c b/src/rtc.c new file mode 100644 index 0000000000..6b40d23997 --- /dev/null +++ b/src/rtc.c @@ -0,0 +1,192 @@ +#include +#include +#include + +#include "inlines.h" + +#include "rtc.h" + +typedef struct { + BOOL valid; + BOOL readInProgress; + int framesSinceRead; + RTCResult status; + RTCDate date; + RTCTime time; + RTCDate tempDate; + RTCTime tempTime; +} RTCState; + +static void GetTimeCallback(RTCResult param0, void * param1); +static void StartRTCRead(RTCState * param0); + +static RTCState sRTCState; + +void InitRTC (void) +{ + RTC_Init(); + memset(&sRTCState, 0, sizeof(sRTCState)); + sRTCState.valid = 0; + sRTCState.readInProgress = 0; + sRTCState.framesSinceRead = 0; + StartRTCRead(&sRTCState); +} + +void UpdateRTC (void) +{ + if (sRTCState.readInProgress) { + return; + } + + sRTCState.framesSinceRead++; + + if (sRTCState.framesSinceRead > 10) { + sRTCState.framesSinceRead = 0; + StartRTCRead(&sRTCState); + } +} + +static void GetTimeCallback (RTCResult result, void * data) +{ + RTCState * state = data; + + state->status = result; + + GF_ASSERT(result == RTC_RESULT_SUCCESS); + + state->valid = 1; + state->date = state->tempDate; + state->time = state->tempTime; + state->readInProgress = 0; +} + +static void StartRTCRead (RTCState * param0) +{ + param0->readInProgress = 1; + param0->status = RTC_GetDateTimeAsync(¶m0->tempDate, ¶m0->tempTime, GetTimeCallback, param0); + GF_ASSERT(param0->status == RTC_RESULT_SUCCESS); +} + +void GetCurrentDateTime (RTCDate * date, RTCTime * time) +{ + GF_ASSERT(sRTCState.valid == 1); + + *date = sRTCState.date; + *time = sRTCState.time; +} + +void GetCurrentTime (RTCTime * time) +{ + GF_ASSERT(sRTCState.valid == 1); + *time = sRTCState.time; +} + +void GetCurrentDate (RTCDate * date) +{ + GF_ASSERT(sRTCState.valid == 1); + *date = sRTCState.date; +} + +int GetSecondsSinceMidnight (void) +{ + RTCTime * time = &sRTCState.time; + + return time->hour * 60 * 60 + time->minute * 60 + time->second; +} + +s64 GetTimestamp (void) +{ + return RTC_ConvertDateTimeToSecond(&sRTCState.date, &sRTCState.time); +} + +int DayNumberForDate (const RTCDate * date) +{ + int year, days; + static const u16 monthStart[12] = { + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 + }; + + days = date->day; + days += monthStart[date->month - 1]; + + if (date->month >= 3) { + year = date->year; + + if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { + days++; + } + } + + return days; +} + +BOOL IsNight (void) +{ + switch (GetTimeOfDay()) { + case TOD_LATE_NIGHT: + case TOD_NIGHT: + return 1; + } + + return 0; +} + +enum TimeOfDay GetTimeOfDay (void) +{ + RTCTime time; + + GetCurrentTime(&time); + return TimeOfDayForHour(time.hour); +} + +enum TimeOfDay TimeOfDayForHour (int hour) +{ + static const u8 lookup[24] = { + TOD_LATE_NIGHT, + TOD_LATE_NIGHT, + TOD_LATE_NIGHT, + TOD_LATE_NIGHT, + TOD_MORNING, + TOD_MORNING, + TOD_MORNING, + TOD_MORNING, + TOD_MORNING, + TOD_MORNING, + TOD_DAY, + TOD_DAY, + TOD_DAY, + TOD_DAY, + TOD_DAY, + TOD_DAY, + TOD_DAY, + TOD_TWILIGHT, + TOD_TWILIGHT, + TOD_TWILIGHT, + TOD_NIGHT, + TOD_NIGHT, + TOD_NIGHT, + TOD_NIGHT, + }; + + GF_ASSERT(0 <= hour && hour < 24); + return lookup[hour]; +} + +#define MAX_TIMESTAMP 3155759999 + +s64 TimeElapsed (s64 since, s64 until) +{ + RTCDate maxDate = {99, 12, 31, 0}; + RTCTime maxTime = {23, 59, 59}; + s64 maxTimestamp = RTC_ConvertDateTimeToSecond(&maxDate, &maxTime); + + GF_ASSERT(maxTimestamp == MAX_TIMESTAMP); + + if (since < until) { + return until - since; + } else { + // BUG: This loses one second when rolling over. + // e.g. TimeElapsed(MAX_TIMESTAMP, 0) == 0 + return until + (MAX_TIMESTAMP - since); + } +} diff --git a/src/unk_0201378C.c b/src/unk_0201378C.c deleted file mode 100644 index a6f9bf90a6..0000000000 --- a/src/unk_0201378C.c +++ /dev/null @@ -1,212 +0,0 @@ -#include -#include -#include - -#include "inlines.h" - -#include "unk_0201378C.h" - -typedef struct { - BOOL unk_00; - BOOL unk_04; - int unk_08; - RTCResult unk_0C; - RTCDate unk_10; - RTCTime unk_20; - RTCDate unk_2C; - RTCTime unk_3C; -} UnkStruct_021BF5C8; - -static void sub_020137EC(RTCResult param0, void * param1); -static void sub_02013824(UnkStruct_021BF5C8 * param0); - -static UnkStruct_021BF5C8 Unk_021BF5C8; - -void sub_0201378C (void) -{ - RTC_Init(); - memset(&Unk_021BF5C8, 0, sizeof(Unk_021BF5C8)); - Unk_021BF5C8.unk_00 = 0; - Unk_021BF5C8.unk_04 = 0; - Unk_021BF5C8.unk_08 = 0; - sub_02013824(&Unk_021BF5C8); -} - -void sub_020137C4 (void) -{ - RTCResult v0; - - if (Unk_021BF5C8.unk_04) { - return; - } - - Unk_021BF5C8.unk_08++; - - if (Unk_021BF5C8.unk_08 > 10) { - Unk_021BF5C8.unk_08 = 0; - sub_02013824(&Unk_021BF5C8); - } -} - -static void sub_020137EC (RTCResult param0, void * param1) -{ - UnkStruct_021BF5C8 * v0 = param1; - - v0->unk_0C = param0; - - GF_ASSERT(param0 == RTC_RESULT_SUCCESS); - - v0->unk_00 = 1; - v0->unk_10 = v0->unk_2C; - v0->unk_20 = v0->unk_3C; - v0->unk_04 = 0; -} - -static void sub_02013824 (UnkStruct_021BF5C8 * param0) -{ - param0->unk_04 = 1; - param0->unk_0C = RTC_GetDateTimeAsync(¶m0->unk_2C, ¶m0->unk_3C, sub_020137EC, param0); - GF_ASSERT(param0->unk_0C == RTC_RESULT_SUCCESS); -} - -static inline RTCDate * inline_0201384C (UnkStruct_021BF5C8 * param0) -{ - return ¶m0->unk_10; -} - -static inline RTCTime * inline_02013880 (UnkStruct_021BF5C8 * param0) -{ - return ¶m0->unk_20; -} - -void sub_0201384C (RTCDate * param0, RTCTime * param1) -{ - GF_ASSERT(Unk_021BF5C8.unk_00 == 1); - - *param0 = *inline_0201384C(&Unk_021BF5C8); - *param1 = *inline_02013880(&Unk_021BF5C8); -} - -void sub_02013880 (RTCTime * param0) -{ - GF_ASSERT(Unk_021BF5C8.unk_00 == 1); - *param0 = *inline_02013880(&Unk_021BF5C8); -} - -void sub_020138A4 (RTCDate * param0) -{ - GF_ASSERT(Unk_021BF5C8.unk_00 == 1); - *param0 = *inline_0201384C(&Unk_021BF5C8); -} - -int sub_020138C8 (void) -{ - RTCTime * v0; - - v0 = inline_02013880(&Unk_021BF5C8); - return v0->hour * 60 * 60 + v0->minute * 60 + v0->second; -} - -s64 sub_020138EC (void) -{ - return RTC_ConvertDateTimeToSecond(inline_0201384C(&Unk_021BF5C8), inline_02013880(&Unk_021BF5C8)); -} - -int sub_02013900 (const RTCDate * param0) -{ - int v0, v1, v2; - static const u16 v3[12] = { - 0x0, - 0x1F, - 0x3B, - 0x5A, - 0x78, - 0x97, - 0xB5, - 0xD4, - 0xF3, - 0x111, - 0x130, - 0x14E - }; - - v1 = param0->day; - v1 += v3[param0->month - 1]; - - if (param0->month >= 3) { - v0 = param0->year; - - if (((v0 % 4 == 0) && (v0 % 100 != 0)) || (v0 % 400 == 0)) { - v1++; - } - } - - return v1; -} - -BOOL sub_02013948 (void) -{ - switch (sub_02013960()) { - case 4: - case 3: - return 1; - } - - return 0; -} - -int sub_02013960 (void) -{ - RTCTime v0; - - sub_02013880(&v0); - return sub_02013974(v0.hour); -} - -int sub_02013974 (int param0) -{ - static const u8 v0[24] = { - 0x4, - 0x4, - 0x4, - 0x4, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x0, - 0x1, - 0x1, - 0x1, - 0x1, - 0x1, - 0x1, - 0x1, - 0x2, - 0x2, - 0x2, - 0x3, - 0x3, - 0x3, - 0x3 - }; - - GF_ASSERT(0 <= param0 && param0 < 24); - return v0[param0]; -} - -s64 sub_0201398C (s64 param0, s64 param1) -{ - RTCDate v0 = {99, 12, 31, 0}; - RTCTime v1 = {23, 59, 59}; - s64 v2 = RTC_ConvertDateTimeToSecond(&v0, &v1); - - GF_ASSERT(v2 == 3155759999); - - if (param0 < param1) { - return param1 - param0; - } - - return param1 + (3155759999 - param0); -} diff --git a/src/unk_02025CB0.c b/src/unk_02025CB0.c index 8d472f3ca4..38e313373d 100644 --- a/src/unk_02025CB0.c +++ b/src/unk_02025CB0.c @@ -4,7 +4,7 @@ #include "struct_decls/struct_021C0794_decl.h" #include "struct_defs/struct_02055BA8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_020244AC.h" #include "unk_02025CB0.h" @@ -113,7 +113,7 @@ void sub_02025D78 (UnkStruct_02025CCC * param0, s32 param1) void sub_02025D84 (UnkStruct_02055BA8 * param0) { param0->unk_00 = 1; - sub_0201384C(¶m0->unk_04, ¶m0->unk_14); + GetCurrentDateTime(¶m0->unk_04, ¶m0->unk_14); param0->unk_20 = RTC_ConvertDateToDay(¶m0->unk_04); param0->unk_24 = RTC_ConvertDateTimeToSecond(¶m0->unk_04, ¶m0->unk_14); param0->unk_2C = 0; @@ -145,6 +145,6 @@ void sub_02025DC8 (UnkStruct_02055BA8 * param0, int param1) void sub_02025DE8 (UnkStruct_02055BA8 * param0) { param0->unk_34 = 60 * 24; - sub_0201384C(¶m0->unk_04, ¶m0->unk_14); + GetCurrentDateTime(¶m0->unk_04, ¶m0->unk_14); param0->unk_20 = RTC_ConvertDateToDay(¶m0->unk_04); } diff --git a/src/unk_0202854C.c b/src/unk_0202854C.c index 49694d7d03..818f42eb62 100644 --- a/src/unk_0202854C.c +++ b/src/unk_0202854C.c @@ -12,7 +12,7 @@ #include "struct_defs/struct_02029894_sub2.h" #include "struct_defs/struct_020298B0.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_0201D15C.h" #include "unk_020244AC.h" @@ -103,7 +103,7 @@ void Underground_Init (UnkStruct_020298B0 * param0) RTCDate v1; RTCTime v2; - sub_0201384C(&v1, &v2); + GetCurrentDateTime(&v1, &v2); v0 = (((((((u32)v1.year * 32ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 32ULL + v2.minute) * 32ULL + (v2.second + gCoreSys.frameCounter)); MI_CpuFill8(param0, 0, sizeof(UnkStruct_020298B0)); diff --git a/src/unk_0202ACE0.c b/src/unk_0202ACE0.c index 65e81eae0a..a7554f3029 100644 --- a/src/unk_0202ACE0.c +++ b/src/unk_0202ACE0.c @@ -10,7 +10,7 @@ #include "struct_defs/struct_0202B370.h" #include "struct_defs/struct_0202B370_sub1.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "strbuf.h" #include "unk_020244AC.h" #include "unk_0202ACE0.h" @@ -251,7 +251,7 @@ void sub_0202B13C (UnkStruct_0202B370 * param0, int param1) { RTCDate v0; - sub_020138A4(&v0); + GetCurrentDate(&v0); param0->unk_1C0[param1].unk_2A = v0.year + 2000; param0->unk_1C0[param1].unk_2C = v0.month; diff --git a/src/unk_0202B604.c b/src/unk_0202B604.c index c4ee52a541..0494274dc2 100644 --- a/src/unk_0202B604.c +++ b/src/unk_0202B604.c @@ -11,7 +11,7 @@ #include "struct_defs/struct_0202BF4C.h" #include "struct_defs/struct_0202BFCC.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_020244AC.h" #include "trainer_info.h" @@ -146,7 +146,7 @@ UnkStruct_0202B628 * sub_0202B634 (UnkStruct_0202B628 * param0, BOOL param1) return NULL; } - sub_020138A4(&v0); + GetCurrentDate(&v0); if ((param0[0].unk_00.unk_00_7 != 0) && ((param0[0].unk_00.unk_00_0 != v0.year) || (param0[0].unk_00.unk_00_7 != v0.month) || (param0[0].unk_00.unk_00_14 != v0.day) || (param0[0].unk_00.unk_00_11 != v0.week))) { for (v1 = 10 - 1; v1 >= 1; v1--) { @@ -169,14 +169,14 @@ BOOL sub_0202B6A4 (UnkStruct_0202B628 * param0, BOOL param1) return 0; } - sub_020138A4(&v1); + GetCurrentDate(&v1); v0.year = param0[0].unk_00.unk_00_0; v0.month = param0[0].unk_00.unk_00_7; v0.day = param0[0].unk_00.unk_00_14; v0.week = param0[0].unk_00.unk_00_11; - v2 = sub_02013900(&v1) - sub_02013900(&v0); + v2 = DayNumberForDate(&v1) - DayNumberForDate(&v0); if (((v1.month == 12) && (v1.day == 31) && (v0.month == 1) && (v0.day == 1)) || ((v1.month == 1) && (v1.day == 1) && (v0.month == 12) && (v0.day == 31))) { s32 v3 = (s32)v1.year - (s32)v0.year; @@ -580,7 +580,7 @@ void * sub_0202BC58 (u16 param0, u32 param1) RTCDate v1; v0 = Heap_AllocFromHeap(param1, sizeof(UnkStruct_0202BC58)); - sub_020138A4(&v1); + GetCurrentDate(&v1); v0->unk_00_0 = v1.year; v0->unk_00_7 = v1.month; diff --git a/src/unk_0202E2CC.c b/src/unk_0202E2CC.c index 527c546b2b..b70e1c14cf 100644 --- a/src/unk_0202E2CC.c +++ b/src/unk_0202E2CC.c @@ -17,7 +17,7 @@ #include "struct_defs/struct_0202E828.h" #include "struct_defs/struct_0202E834.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_020244AC.h" #include "unk_0202E2CC.h" @@ -144,7 +144,7 @@ static void sub_0202E3F4 (UnkStruct_0202E4D4 * param0, int param1, const u8 * pa { RTCDate v0; - sub_020138A4(&v0); + GetCurrentDate(&v0); param0->unk_04 = inline_0202D4B0(&v0); param0->unk_00 = param1; diff --git a/src/unk_0202EEC0.c b/src/unk_0202EEC0.c index 7301143ba3..253ebf3826 100644 --- a/src/unk_0202EEC0.c +++ b/src/unk_0202EEC0.c @@ -3,7 +3,7 @@ #include "pokemon.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_0202EEC0.h" #include "pokemon.h" @@ -83,7 +83,7 @@ void sub_0202EFB8 (PalParkTransfer * param0, u32 param1) int v0 = sub_0202EF40(param0, param1); param0->unk_288[v0] = param1; - param0->unk_2D8[v0] = sub_020138EC(); + param0->unk_2D8[v0] = GetTimestamp(); param0->unk_378 = OS_GetOwnerRtcOffset(); OS_GetMacAddress(param0->unk_380); @@ -111,7 +111,7 @@ int sub_0202F028 (const PalParkTransfer * param0) int sub_0202F050 (const PalParkTransfer * param0, u32 param1) { int v0; - s64 v1 = sub_020138EC(); + s64 v1 = GetTimestamp(); for (v0 = 0; v0 < 20; v0++) { if (param0->unk_288[v0] == param1) { diff --git a/src/unk_02034198.c b/src/unk_02034198.c index 7ac0bd5e39..8650988c3f 100644 --- a/src/unk_02034198.c +++ b/src/unk_02034198.c @@ -12,7 +12,7 @@ #include "struct_defs/struct_0203233C.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_02030EE0.h" #include "unk_02032188.h" @@ -1876,7 +1876,7 @@ void sub_020361BC (MATHRandContext32 * param0) RTCDate v1; RTCTime v2; - sub_0201384C(&v1, &v2); + GetCurrentDateTime(&v1, &v2); v0 = (((((((u64)v1.year * 16ULL + v1.month) * 32ULL) + v1.day) * 32ULL + v2.hour) * 64ULL + v2.minute) * 64ULL + (v2.second + gCoreSys.frameCounter)); MATH_InitRand32(param0, v0); } diff --git a/src/unk_0203A944.c b/src/unk_0203A944.c index 784e96024d..6b339dc7df 100644 --- a/src/unk_0203A944.c +++ b/src/unk_0203A944.c @@ -6,7 +6,7 @@ #include "struct_defs/struct_0203CDB0.h" #include "struct_defs/struct_02055BA8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02025CB0.h" #include "map_header.h" #include "unk_0203A944.h" @@ -1860,7 +1860,7 @@ int sub_0203A944 (UnkStruct_0203CDB0 * param0, int param1) int v1; UnkStruct_02055BA8 * v2 = sub_02025CD8(param0->unk_0C); - v1 = sub_02013900(&v2->unk_04) - 1; + v1 = DayNumberForDate(&v2->unk_04) - 1; GF_ASSERT(v1 >= 0 && v1 < 366); if ((v2->unk_04.month > 2) && !inline_0203A944(v2->unk_04.year)) { diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index a87ac0f13e..49188aff32 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -67,7 +67,7 @@ #include "overlay088/struct_ov88_0223C370.h" #include "overlay090/struct_ov90_021D0D80.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02017498.h" #include "heap.h" #include "unk_0201D15C.h" @@ -1594,9 +1594,9 @@ static BOOL sub_0203E35C (UnkStruct_020508D4 * param0) case 1: if (sub_020509B4(v0) == 0) { u16 * v5 = sub_02025E50(v0->unk_0C); - s64 v6 = sub_020138EC(); + s64 v6 = GetTimestamp(); - sub_0206DD38(v0, Coins_GetValue(v5), v2->unk_00, sub_0201398C(v2->unk_04, v6) / 60); + sub_0206DD38(v0, Coins_GetValue(v5), v2->unk_00, TimeElapsed(v2->unk_04, v6) / 60); Coins_SetValue(sub_02025E50(v0->unk_0C), v2->unk_00); v4 = sub_0206B394(v1); @@ -1622,7 +1622,7 @@ void sub_0203E414 (UnkStruct_020508D4 * param0, int param1) v2->unk_0C.unk_00 = &v2->unk_00; v2->unk_00 = Coins_GetValue(sub_02025E50(v0->unk_0C)); - v2->unk_04 = sub_020138EC(); + v2->unk_04 = GetTimestamp(); v2->unk_0C.unk_08 = sub_0202CD88(v0->unk_0C); v2->unk_0C.unk_0C = 0; v2->unk_0C.unk_10 = sub_02027B50(v1); diff --git a/src/unk_0203F6C4.c b/src/unk_0203F6C4.c index cb097850f0..ab0c688ea0 100644 --- a/src/unk_0203F6C4.c +++ b/src/unk_0203F6C4.c @@ -77,7 +77,7 @@ #include "unk_0200D9E8.h" #include "unk_0200DA60.h" #include "unk_0200F174.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02014D38.h" #include "heap.h" #include "unk_02018340.h" @@ -6750,7 +6750,7 @@ static BOOL sub_02044EDC (UnkStruct_0203E724 * param0) RTCDate v0; u16 * v1 = inline_0204FCAC(param0); - sub_020138A4(&v0); + GetCurrentDate(&v0); *v1 = v0.week; return 0; @@ -8435,7 +8435,7 @@ static BOOL sub_0204698C (UnkStruct_0203E724 * param0) s64 v2; s64 v3; - v2 = sub_020138EC(); + v2 = GetTimestamp(); v3 = v2 - v0->unk_C4.unk_00; if (v3 >= 120) { diff --git a/src/unk_02051D8C.c b/src/unk_02051D8C.c index 77cb2970ed..7db11ce554 100644 --- a/src/unk_02051D8C.c +++ b/src/unk_02051D8C.c @@ -28,7 +28,7 @@ #include "unk_020021B0.h" #include "message.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "strbuf.h" #include "savedata/save_table.h" @@ -119,7 +119,7 @@ BattleParams * sub_02051D8C (int param0, u32 param1) RTCDate v2; RTCTime v3; - sub_0201384C(&v2, &v3); + GetCurrentDateTime(&v2, &v3); v1->unk_174 = v2.year + v2.month * 0x100 * v2.day * 0x10000 + v3.hour * 0x10000 + (v3.minute + v3.second) * 0x1000000 + gCoreSys.frameCounter; } @@ -269,7 +269,7 @@ void sub_020521B8 (BattleParams * param0, const UnkStruct_0203CDB0 * param1, Sav { UnkStruct_02055BA8 * v7 = sub_02025CD8(param2); - param0->unk_138 = sub_02013974(v7->unk_14.hour); + param0->unk_138 = TimeOfDayForHour(v7->unk_14.hour); } } diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index c92f34472d..94e459e590 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -27,7 +27,7 @@ #include "unk_0200B358.h" #include "unk_0200DA60.h" #include "unk_0200F174.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_02018340.h" #include "gx_layers.h" @@ -85,7 +85,7 @@ static void sub_02052C6C (UnkStruct_0203CDB0 * param0, BOOL param1) v1 = Party_GetFromSavedata(param0->unk_0C); - sub_020138A4(&v2); + GetCurrentDate(&v2); sub_0202DFA8(v0, v1, &v2); SaveData_SaveHallOfFame(param0->unk_0C, v0); Heap_FreeToHeap(v0); diff --git a/src/unk_020553DC.c b/src/unk_020553DC.c index 3c22e64821..e80928e273 100644 --- a/src/unk_020553DC.c +++ b/src/unk_020553DC.c @@ -9,7 +9,7 @@ #include "unk_020041CC.h" #include "unk_02005474.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "map_header.h" #include "unk_0203A6DC.h" #include "unk_020507CC.h" @@ -185,7 +185,7 @@ u16 sub_020554A4 (UnkStruct_0203CDB0 * param0, int param1) { u16 v0, v1; - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = MapHeader_GetDayMusicID(param1); } else { v0 = MapHeader_GetNightMusicID(param1); diff --git a/src/unk_020559DC.c b/src/unk_020559DC.c index 27ec35e21f..98ffb99276 100644 --- a/src/unk_020559DC.c +++ b/src/unk_020559DC.c @@ -10,7 +10,7 @@ #include "struct_defs/struct_0203CDB0.h" #include "struct_defs/struct_02055BA8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "savedata/save_table.h" #include "unk_02025CB0.h" #include "unk_0202854C.h" @@ -45,7 +45,7 @@ void sub_020559DC (UnkStruct_0203CDB0 * param0) return; } - sub_0201384C(&v0, &v1); + GetCurrentDateTime(&v0, &v1); sub_02055A14(param0, v2, &v0); inline_020559DC(param0, v2, &v0, &v1); @@ -154,7 +154,7 @@ static void sub_02055B64 (UnkStruct_0203CDB0 * param0, s32 param1, const RTCTime int sub_02055BA8 (const UnkStruct_0203CDB0 * param0) { UnkStruct_02055BA8 * v0 = sub_02025CD8(param0->unk_0C); - return sub_02013974(v0->unk_14.hour); + return TimeOfDayForHour(v0->unk_14.hour); } int sub_02055BB8 (const UnkStruct_0203CDB0 * param0) @@ -203,7 +203,7 @@ void sub_02055C2C (const UnkStruct_0203CDB0 * param0) { UnkStruct_02055BA8 * v0 = sub_02025CD8(param0->unk_0C); - v0->unk_2C = sub_020138EC(); + v0->unk_2C = GetTimestamp(); } BOOL sub_02055C40 (UnkStruct_0203CDB0 * param0) diff --git a/src/unk_020562F8.c b/src/unk_020562F8.c index ce45053df2..7518dd18fe 100644 --- a/src/unk_020562F8.c +++ b/src/unk_020562F8.c @@ -12,7 +12,7 @@ #include "overlay006/battle_params.h" #include "narc.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "savedata/save_table.h" #include "unk_0202CD50.h" @@ -64,15 +64,15 @@ void sub_020562F8 (UnkStruct_0203CDB0 * param0) sub_0205642C(param0, v1); sub_020564D0(v1); - v1->unk_40 = sub_020138EC(); + v1->unk_40 = GetTimestamp(); } void sub_02056328 (UnkStruct_0203CDB0 * param0) { UnkStruct_020564B4 * v0 = &Unk_021C07FC; UnkStruct_0202CD88 * v1 = sub_0202CD88(param0->unk_0C); - s64 v2 = sub_020138EC(); - s64 v3 = sub_0201398C(v0->unk_40, v2); + s64 v2 = GetTimestamp(); + s64 v3 = TimeElapsed(v0->unk_40, v2); if (v3 < 1000) { v0->unk_48 = ((1000 - v3) * 2); diff --git a/src/unk_0206A8DC.c b/src/unk_0206A8DC.c index 53590996a1..3023485f05 100644 --- a/src/unk_0206A8DC.c +++ b/src/unk_0206A8DC.c @@ -3,7 +3,7 @@ #include "struct_decls/struct_020507E4_decl.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_020507CC.h" #include "unk_0206A8DC.h" @@ -273,7 +273,7 @@ u16 sub_0206AB68 (UnkStruct_020507E4 * param0, int param1) case 494: case 497: if (sub_0206A8EC(param0, (2400 + 37)) == 1) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1016; } else { v0 = 1045; @@ -292,7 +292,7 @@ u16 sub_0206AB68 (UnkStruct_020507E4 * param0, int param1) case 74: case 75: if (sub_0206A8EC(param0, (2400 + 39)) == 1) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1013; } else { v0 = 1042; @@ -301,7 +301,7 @@ u16 sub_0206AB68 (UnkStruct_020507E4 * param0, int param1) break; case 201: if (sub_0206A8EC(param0, (2400 + 40)) == 1) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1023; } else { v0 = 1052; @@ -310,7 +310,7 @@ u16 sub_0206AB68 (UnkStruct_020507E4 * param0, int param1) break; case 256: if (sub_0206A8EC(param0, (2400 + 41)) == 1) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1006; } else { v0 = 1035; @@ -319,7 +319,7 @@ u16 sub_0206AB68 (UnkStruct_020507E4 * param0, int param1) break; case 399: if (sub_0206A8EC(param0, (2400 + 42)) == 1) { - if (sub_02013948() == 0) { + if (IsNight() == 0) { v0 = 1006; } else { v0 = 1035; diff --git a/src/unk_02092494.c b/src/unk_02092494.c index 80f5cff74e..71f54871e3 100644 --- a/src/unk_02092494.c +++ b/src/unk_02092494.c @@ -5,7 +5,7 @@ #include "message.h" #include "unk_0200B358.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "unk_02017038.h" #include "heap.h" #include "strbuf.h" @@ -836,7 +836,7 @@ static void SetMetLocationForBoxPokemon (BoxPokemon * param0, int param1, int pa { RTCDate v0; - sub_020138A4(&v0); + GetCurrentDate(&v0); if (param2 == 0) { BoxPokemon_SetValue(param0, 152, ¶m1); diff --git a/src/unk_020933F8.c b/src/unk_020933F8.c index 052f74bd24..3d52846b5c 100644 --- a/src/unk_020933F8.c +++ b/src/unk_020933F8.c @@ -35,7 +35,7 @@ #include "unk_0200A9DC.h" #include "unk_0200B358.h" #include "unk_0200D9E8.h" -#include "unk_0201378C.h" +#include "rtc.h" #include "heap.h" #include "unk_0201D15C.h" #include "strbuf.h" @@ -1703,7 +1703,7 @@ void sub_02094C44 (UnkStruct_02095C48 * param0, SaveData * param1, u32 param2, U static void sub_02094E7C (UnkStruct_02095C48 * param0) { - LCRNG_SetSeed((sub_020138C8() * (LCRNG_GetSeed() + 10)) & 0xffff); + LCRNG_SetSeed((GetSecondsSinceMidnight() * (LCRNG_GetSeed() + 10)) & 0xffff); } u16 sub_02094E98 (UnkStruct_02095C48 * param0) From e9eb3d898c807a21c44bdfd860700d1c2f650c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maja=20K=C4=85dzio=C5=82ka?= Date: Mon, 29 Jan 2024 19:59:54 +0100 Subject: [PATCH 6/6] Address review comments --- include/core_sys.h | 9 +++++---- include/functypes/funcptr_02017798.h | 6 ------ include/unk_02017728.h | 10 +++++----- src/unk_02017728.c | 1 - 4 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 include/functypes/funcptr_02017798.h diff --git a/include/core_sys.h b/include/core_sys.h index c668b2113e..373c58a77b 100644 --- a/include/core_sys.h +++ b/include/core_sys.h @@ -1,10 +1,11 @@ #ifndef POKEPLATINUM_CORE_SYS_H #define POKEPLATINUM_CORE_SYS_H -#include "functypes/funcptr_02017798.h" #include "struct_decls/struct_0201CD88_decl.h" #include "overlay023/funcptr_ov23_022537D4.h" +typedef void (* Callback)(void *); + enum ButtonMode { BUTTON_MODE_NORMAL = 0, BUTTON_MODE_START_IS_X = 1, @@ -14,9 +15,9 @@ enum ButtonMode { typedef struct CoreSys { Callback mainCallback; - void * mainCallbackData; + void *mainCallbackData; Callback hblankCallback; - void * hblankCallbackData; + void *hblankCallbackData; UnkFuncPtr_ov23_022537D4 unk_10; UnkFuncPtr_ov23_022537D4 unk_14; UnkStruct_0201CD88 * unk_18; @@ -47,7 +48,7 @@ typedef struct CoreSys { u8 inhibitReset; u8 padding_69[3]; BOOL unk_6C; - u32 * heapCanary; + u32 *heapCanary; } CoreSys; extern CoreSys gCoreSys; diff --git a/include/functypes/funcptr_02017798.h b/include/functypes/funcptr_02017798.h deleted file mode 100644 index 97b06c4f96..0000000000 --- a/include/functypes/funcptr_02017798.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_FUNCPTR_02017798_H -#define POKEPLATINUM_FUNCPTR_02017798_H - -typedef void (* Callback)(void *); - -#endif // POKEPLATINUM_FUNCPTR_02017798_H diff --git a/include/unk_02017728.h b/include/unk_02017728.h index 141d6083d9..c33ae273cd 100644 --- a/include/unk_02017728.h +++ b/include/unk_02017728.h @@ -1,16 +1,16 @@ #ifndef POKEPLATINUM_UNK_02017728_H #define POKEPLATINUM_UNK_02017728_H -#include "functypes/funcptr_02017798.h" +#include "core_sys.h" void sub_02017728(void); -void SetMainCallback(Callback cb, void * data); +void SetMainCallback(Callback cb, void *data); void DisableHBlank(void); -BOOL SetHBlankCallback(Callback cb, void * data); +BOOL SetHBlankCallback(Callback cb, void *data); void sub_0201789C(void); void InitGraphics(void); -void * ReadFileToHeap(int heapID, const char * filename); -void ReadFileToBuffer(const char * filename, void ** buf); +void * ReadFileToHeap(int heapID, const char *filename); +void ReadFileToBuffer(const char *filename, void **buf); void sub_02017ACC(void); void InitKeypadAndTouchpad(void); void sub_02017B70(int param0); diff --git a/src/unk_02017728.c b/src/unk_02017728.c index 27394842ff..d572550ff1 100644 --- a/src/unk_02017728.c +++ b/src/unk_02017728.c @@ -3,7 +3,6 @@ #include "core_sys.h" -#include "functypes/funcptr_02017798.h" #include "struct_defs/struct_02017E74.h" #include "unk_02017728.h"