From 19551728c22562986c3bccf0f6df2ec97b304d2d Mon Sep 17 00:00:00 2001 From: gijs Date: Sat, 21 Oct 2023 17:54:44 +0200 Subject: [PATCH] Split `_ob_classy_fold.c` Rename `_ob_classy_fold.c` to `nucontmgr.c` Rename `__GLOBAL_CONTROLLER_DATA` to `nuContData` Rename `__copy_global_controller_data` to `nuContDataGetAll` Split `nuContQueryRead` to it's own file Split `nuContDataGetAll` to it's own file --- include/common.h | 1 - linker_scripts/symbols/addr.txt | 4 ++-- splat.yaml | 4 +++- src/_ob_classy_fold.c | 22 ---------------------- src/_ob_proper_regret.c | 11 +++++++++++ src/main.c | 6 +++--- src/nu/nucontdatagetall.c | 9 +++++++++ src/nu/nucontmgr.c | 4 ++-- src/nu/nucontqueryread.c | 7 +++++++ 9 files changed, 37 insertions(+), 31 deletions(-) delete mode 100644 src/_ob_classy_fold.c create mode 100644 src/_ob_proper_regret.c create mode 100644 src/nu/nucontdatagetall.c create mode 100644 src/nu/nucontqueryread.c diff --git a/include/common.h b/include/common.h index 4b75e09..674f72a 100644 --- a/include/common.h +++ b/include/common.h @@ -137,7 +137,6 @@ extern OSMesgQueue MQ_800E7988; extern void (*D_800A9FE0)(s16); -extern OSContPad __GLOBAL_CONTROLLER_DATA[MAXCONTROLLERS]; extern OSContPad __GLOBAL_CONTROLLER_DATA_COPY[MAXCONTROLLERS]; extern u8 D_800AA040; diff --git a/linker_scripts/symbols/addr.txt b/linker_scripts/symbols/addr.txt index 2fb17f8..6e83779 100644 --- a/linker_scripts/symbols/addr.txt +++ b/linker_scripts/symbols/addr.txt @@ -39,6 +39,7 @@ nuContCallBack = 0x800A9FF8; nuContStatus = 0x800C4B38; // size:0x10 type:u32 nuContNum = 0x800C6D60; nuContDataLockKey = 0x800C4B30; +nuContData = 0x0800C4BF0; // size:0x18 nuBoot = 0x8007F880; nuScCreateScheduler = 0x80088C50; // rom:0x19050 @@ -85,6 +86,7 @@ nuContMgrRemove = 0x8008A334; nuSiCallBackRemove = 0x8008B1D0; nuContDataClose = 0x8008A354; nuContDataOpen = 0x8008A37C; +nuContDataGetAll = 0x8008A600; obCurrentTime = 0x800C47D0; @@ -989,11 +991,9 @@ __ROM_0_to_8000 = 0x800A83B8; // rom:0x387B8 romCopy_256 = 0x80074CF0; // rom:0x50F0 -__GLOBAL_CONTROLLER_DATA = 0x0800C4BF0; // size:0x18 __GLOBAL_CONTROLLER_DATA_COPY = 0x0800AEE78; // size:0x18 __calls_copy_controller_data = 0x8007297C; -__copy_global_controller_data = 0x8008A600; __read_controller = 0x8008A3A4; __calls_read_controller_0 = 0x8008A47C; __calls_read_controller_1 = 0x8008A508; diff --git a/splat.yaml b/splat.yaml index 589768b..ea820f3 100644 --- a/splat.yaml +++ b/splat.yaml @@ -128,7 +128,9 @@ segments: - [0x1A5B0, c, "nu/nugfxinit"] - [0x1A660, c, "nu/nucontmgr"] - [0x1A9A0, c, "nu/nucontdatalock"] - - [0x1AA00, c, "_ob_classy_fold"] + - [0x1AA00, c, "nu/nucontdatagetall"] + - [0x1AA40, c, "nu/nucontqueryread"] + - [0x1AA60, c, "_ob_proper_regret"] - [0x1AAA0, c, "_ob_dull_silver"] - [0x1AD10, asm] - [0x1AFD0, asm] diff --git a/src/_ob_classy_fold.c b/src/_ob_classy_fold.c deleted file mode 100644 index 8ab7e6b..0000000 --- a/src/_ob_classy_fold.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "common.h" - -#include "nu/nusys.h" - -void __copy_global_controller_data(OSContPad* arg0) { - nuContDataClose(); - bcopy(&__GLOBAL_CONTROLLER_DATA, arg0, 0x18); - nuContDataOpen(); -} - -void nuContQueryRead(void) { - nuSiSendMesg(NU_CONT_QUERY_MSG, NULL); -} - -void __set_fp_8008A660(void(*arg0)(s16)) { - s32 mask; - - mask = osSetIntMask(OS_IM_NONE); - D_800A9FE0 = arg0; - osSetIntMask(mask); -} - diff --git a/src/_ob_proper_regret.c b/src/_ob_proper_regret.c new file mode 100644 index 0000000..0a2d02f --- /dev/null +++ b/src/_ob_proper_regret.c @@ -0,0 +1,11 @@ +#include "common.h" + +#include "nu/nusys.h" + +void __set_fp_8008A660(void(*arg0)(s16)) { + s32 mask; + + mask = osSetIntMask(OS_IM_NONE); + D_800A9FE0 = arg0; + osSetIntMask(mask); +} diff --git a/src/main.c b/src/main.c index 07979d8..1036501 100644 --- a/src/main.c +++ b/src/main.c @@ -220,11 +220,11 @@ void func_8007284C(u16 __unused) { if ((D_800AEF9A & 1) && !(D_800AEF9A & 4)) { if (D_800AEF9A & 2) { - if (__GLOBAL_CONTROLLER_DATA[0].button == 0) { + if (nuContData[0].button == 0) { D_800AEF9A = D_800AEF9A & 0xFD; } - } else if (__GLOBAL_CONTROLLER_DATA[0].button == pattern_a || - __GLOBAL_CONTROLLER_DATA[0].button == pattern_b) { + } else if (nuContData[0].button == pattern_a || + nuContData[0].button == pattern_b) { D_800AEF9A = D_800AEF9A | 6; } } diff --git a/src/nu/nucontdatagetall.c b/src/nu/nucontdatagetall.c new file mode 100644 index 0000000..1de516f --- /dev/null +++ b/src/nu/nucontdatagetall.c @@ -0,0 +1,9 @@ +#include "common.h" + +#include "nu/nusys.h" + +void nuContDataGetAll(OSContPad* contdata) { + nuContDataClose(); + bcopy(&nuContData, contdata, 0x18); + nuContDataOpen(); +} \ No newline at end of file diff --git a/src/nu/nucontmgr.c b/src/nu/nucontmgr.c index 3354a21..1e8c8f6 100644 --- a/src/nu/nucontmgr.c +++ b/src/nu/nucontmgr.c @@ -80,7 +80,7 @@ s32 __real_read_controller(void) { s32 __calls_read_controller_0(s16* arg0) { if (nuContDataLockKey == 0) { osRecvMesg(&nuContWaitMesgQ, NULL, 0); - __read_controller(__GLOBAL_CONTROLLER_DATA, 1); + __read_controller(nuContData, 1); if (D_800A9FE0 != NULL) { D_800A9FE0(*arg0); } @@ -102,7 +102,7 @@ s32 __calls_read_controller_2(s16* arg0) { s32 var_v0; osRecvMesg(&nuContWaitMesgQ, NULL, 0); - var_v0 = __read_controller(__GLOBAL_CONTROLLER_DATA, 0); + var_v0 = __read_controller(nuContData, 0); if (var_v0 == 0) { if (D_800A9FE0 != NULL) { D_800A9FE0(*arg0); diff --git a/src/nu/nucontqueryread.c b/src/nu/nucontqueryread.c new file mode 100644 index 0000000..a93de53 --- /dev/null +++ b/src/nu/nucontqueryread.c @@ -0,0 +1,7 @@ +#include "common.h" + +#include "nu/nusys.h" + +void nuContQueryRead(void) { + nuSiSendMesg(NU_CONT_QUERY_MSG, NULL); +}