From a25019b47427c7fb25e1a24554f05d4e44553986 Mon Sep 17 00:00:00 2001 From: Prakxo Date: Mon, 19 Dec 2022 09:53:02 +0100 Subject: [PATCH] match most of zurumode. --- config/rel_slices.yml | 14 ++++++++------ include/JSystem/JUT/JUTAssertion.h | 6 ++++++ include/JSystem/JUT/JUTDbPrint.h | 9 +++++++++ include/dolphin/os.h | 8 ++++++++ include/libultra/libultra.h | 6 ++++++ include/zurumode.h | 9 +++++++-- rel/zurumode/zerucheck_init.c | 2 +- rel/zurumode/zerucheck_key_check.c | 2 +- rel/zurumode/zurumode_update.c | 30 ++++++++++++++++++++++++++++++ 9 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 include/JSystem/JUT/JUTAssertion.h create mode 100644 include/JSystem/JUT/JUTDbPrint.h create mode 100644 include/dolphin/os.h create mode 100644 include/libultra/libultra.h create mode 100644 rel/zurumode/zurumode_update.c diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 03f09e9a..adf19427 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -1,8 +1,10 @@ # ac_aprilfool_control/aPC_actor_dt.c: # .text: [0x805153f0, 0x8051542C] -# zurumode/zerucheck_init.c: - # .text: [0x8040eb38, 0x8040EB50] WILL TRY TO FIX these later, one wasn't matching and the other's didn't find the symbol when converting to ELF. -# zurumode/zerucheck_key_check.c: - # .text: [0x8040EB50, 0x8040EDA8] -# zurumode/zurumode_cleanup.c: - # .text: [0x8040efc4, 0x8040f008] +zurumode/zerucheck_init.c: + .text: [0x8040eb38, 0x8040EB50] +zurumode/zerucheck_key_check.c: + .text: [0x8040EB50, 0x8040EDA8] +zurumode/zurumode_cleanup.c: + .text: [0x8040efc4, 0x8040f008] +# zurumode/zurumode_update.c: + # .text: [0x8040EDA8 , 0x8040ee74] Has C++ functions but was matched with C?? Won't really bother at the moment with this one. \ No newline at end of file diff --git a/include/JSystem/JUT/JUTAssertion.h b/include/JSystem/JUT/JUTAssertion.h new file mode 100644 index 00000000..27a0336b --- /dev/null +++ b/include/JSystem/JUT/JUTAssertion.h @@ -0,0 +1,6 @@ +#ifndef _JSYSTEM_JUT_JUTASSERTION_H +#define _JSYSTEM_JUT_JUTASSERTION_H + +void JC_JUTAssertion_changeDevice(u32); // I know these are C++ but these were used to match a c function so I'll fix these when I need them or fix zurumode update. + +#endif diff --git a/include/JSystem/JUT/JUTDbPrint.h b/include/JSystem/JUT/JUTDbPrint.h new file mode 100644 index 00000000..f718a2b7 --- /dev/null +++ b/include/JSystem/JUT/JUTDbPrint.h @@ -0,0 +1,9 @@ +#ifndef _JSYSTEM_JUT_JUTDBPRINT_H +#define _JSYSTEM_JUT_JUTDBPRINT_H + +void* JC_JUTDbPrint_getManager(void); +void JC_JUTDbPrint_setVisible(void*, int); // I know these are C++ but these were used to match a c function so I'll fix these when I need them or fix zurumode update. + + + +#endif \ No newline at end of file diff --git a/include/dolphin/os.h b/include/dolphin/os.h new file mode 100644 index 00000000..94577051 --- /dev/null +++ b/include/dolphin/os.h @@ -0,0 +1,8 @@ +#ifndef _DOLPHIN_OS +#define _DOLPHIN_OS + +#include "types.h" + +void OSReport(const char*, ...); + +#endif \ No newline at end of file diff --git a/include/libultra/libultra.h b/include/libultra/libultra.h new file mode 100644 index 00000000..f7438fa8 --- /dev/null +++ b/include/libultra/libultra.h @@ -0,0 +1,6 @@ +#ifndef LIBULTRA_H +#define LIBULTRA_H + +extern s32 osAppNMIBuffer[16]; + +#endif \ No newline at end of file diff --git a/include/zurumode.h b/include/zurumode.h index 8dd86965..2f9b1c16 100644 --- a/include/zurumode.h +++ b/include/zurumode.h @@ -3,6 +3,11 @@ #include "types.h" +#include "dolphin/os.h" +#include "libultra/libultra.h" +#include "JSystem/JUT/JUTAssertion.h" +#include "JSystem/JUT/JUTDbPrint.h" + typedef struct zuru_keycheck_s { u8 state; u8 progressing; @@ -10,8 +15,8 @@ typedef struct zuru_keycheck_s { u8 zurumode_enabled; } zuru_keycheck; -static zuru_keycheck zuruKeyCheck; - +extern zuru_keycheck zuruKeyCheck; +extern s32 zurumode_flag; #define ZURUMODE_RESET 0 #define ZURUMODE_PROGRESSING 1 diff --git a/rel/zurumode/zerucheck_init.c b/rel/zurumode/zerucheck_init.c index 49b2b332..a118b845 100644 --- a/rel/zurumode/zerucheck_init.c +++ b/rel/zurumode/zerucheck_init.c @@ -1,6 +1,6 @@ #include "zurumode.h" -static int zerucheck_init(zuru_keycheck* key_check) { +int zerucheck_init(zuru_keycheck* key_check) { key_check->zurumode_enabled = FALSE; key_check->state = ZURUMODE_STAGE_BEGIN_e; key_check->progressing = ZURUMODE_RESET; diff --git a/rel/zurumode/zerucheck_key_check.c b/rel/zurumode/zerucheck_key_check.c index 4e88e935..f21f06bc 100644 --- a/rel/zurumode/zerucheck_key_check.c +++ b/rel/zurumode/zerucheck_key_check.c @@ -21,7 +21,7 @@ * @param controller current controller state * @return int zurumodeEnabled */ -static int zerucheck_key_check(zuru_keycheck* key_check, u32 controller) { +int zerucheck_key_check(zuru_keycheck* key_check, u32 controller) { u32 controller_new; /* Buttons pressed on the current frame only */ int state = key_check->state; /* Keycheck state */ int progressing = key_check->progressing; /* Progressing through keycheck */ diff --git a/rel/zurumode/zurumode_update.c b/rel/zurumode/zurumode_update.c new file mode 100644 index 00000000..ee185341 --- /dev/null +++ b/rel/zurumode/zurumode_update.c @@ -0,0 +1,30 @@ +#include "zurumode.h" +s32 zurumode_update() { + s32 flag_now; + s32 zurumode_now; + + flag_now = zurumode_flag; + zurumode_now = osAppNMIBuffer[15]; + + if (zurumode_now & 1) { + zurumode_now = (zurumode_now >> 3) & 1; + zurumode_now = (int)(zurumode_now + 1); + } + else { + zurumode_now = 0; + } + zurumode_flag = zurumode_now; + + if (flag_now != zurumode_now) { + OSReport("zurumode_flag が %d から %d に変更されました\n", flag_now, zurumode_now); + if (zurumode_flag != 0) { + if ((osAppNMIBuffer[15] & 0x40) || (osAppNMIBuffer[15] & 1)) { + JC_JUTAssertion_changeDevice(3); + JC_JUTDbPrint_setVisible(JC_JUTDbPrint_getManager(), 1); + } + } else { + JC_JUTAssertion_changeDevice(2); + JC_JUTDbPrint_setVisible(JC_JUTDbPrint_getManager(), 0); + } + } + return zurumode_flag; \ No newline at end of file