diff --git a/config/dol_slices.yml b/config/dol_slices.yml index d2965c47..bcb20644 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -4,3 +4,9 @@ libultra/gfxprint/gfxprint_locate8x8.c: .text: [0x8005B210, 0x8005B238] # libforest/ReconfigBATs.c: # .text: [0x8007C070, 0x8005ae84] +# OS/OSEnableInterrupts.c: I'm too tired, but I did these and cba to fix atm stuff + # .text: [0x8007ac38, 0x8007ac4c] +# OS/OSRestoreInterrupts.c: + # .text: [0x8007ac4c, 0x8007ac70] +# OS/OSDisableInterrupts.c: + # .text: [0x8007ac24, 0x8007ac38] \ No newline at end of file diff --git a/include/JSystem/JUT/JUTAssertion.h b/include/JSystem/JUT/JUTAssertion.h index 27a0336b..9a3f600a 100644 --- a/include/JSystem/JUT/JUTAssertion.h +++ b/include/JSystem/JUT/JUTAssertion.h @@ -1,6 +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. +void JC_JUTAssertion_changeDevice(u32); #endif diff --git a/include/dolphin/os.h b/include/dolphin/os.h index 94577051..984f0d42 100644 --- a/include/dolphin/os.h +++ b/include/dolphin/os.h @@ -5,4 +5,8 @@ void OSReport(const char*, ...); +asm BOOL OSDisableInterrupts(void); +asm BOOL OSEnableInterrupts(void); +asm BOOL OSRestoreInterrupts(BOOL level); + #endif \ No newline at end of file diff --git a/include/libforest/batconfig.h b/include/libforest/batconfig.h index e99ac766..874bec0d 100644 --- a/include/libforest/batconfig.h +++ b/include/libforest/batconfig.h @@ -3,5 +3,5 @@ static asm void Config24MB(); static asm void Config48MB(); -static asm void ReconfigBATs(); +void ReconfigBATs(); #endif \ No newline at end of file diff --git a/include/libultra/gfxprint.h b/include/libultra/gfxprint.h index dd75ac66..c8811b0f 100644 --- a/include/libultra/gfxprint.h +++ b/include/libultra/gfxprint.h @@ -2,19 +2,18 @@ #define GFXPRINT_H #include "types.h" - typedef struct gfxprint_obj { s32 unk0; - struct unknown_struct * unk4; + struct unknown_struct * unk4; // This is from GBI.h, from what I've seen s16 NewX; s16 NewY; u16 PrevX; u8 PrevY; - u8 unkF; + u8 flags; u8 R; - u8 G; - u8 B; - u8 A; + u8 B; + u8 G; + u8 A; }; void gfxprint_locate(struct gfxprint_obj*, s32, s32); diff --git a/include/libultra/libultra.h b/include/libultra/libultra.h index 0b8c3ad0..960e3cfc 100644 --- a/include/libultra/libultra.h +++ b/include/libultra/libultra.h @@ -5,6 +5,6 @@ void bcmp (const void *v1, const void *v2, u32 size); void bcopy(const void *dst, void *src, size_t n); void bzero(void *ptr, size_t size); -extern s32 osAppNMIBuffer[16]; //?? It's most likely an u8 with 64 instead of s32 of 16, so the function that uses this is probably a fakematch. +extern s32 osAppNMIBuffer[15]; #endif \ No newline at end of file diff --git a/include/zurumode.h b/include/zurumode.h index 2f9b1c16..c484b7e3 100644 --- a/include/zurumode.h +++ b/include/zurumode.h @@ -22,9 +22,6 @@ extern s32 zurumode_flag; #define OS_APP_NMI_ZURUMODE_IDX 15 -#define FALSE 0 -#define TRUE 1 - #define BUTTON_NONE 0x0000 #define BUTTON_CRIGHT 0x0001 diff --git a/rel/zurumode/zurumode_cleanup.c b/rel/zurumode/zurumode_cleanup.c index 58bfd0e2..2d1f222f 100644 --- a/rel/zurumode/zurumode_cleanup.c +++ b/rel/zurumode/zurumode_cleanup.c @@ -10,9 +10,8 @@ typedef struct { extern padmgr padmgr_class; extern void zurumode_callback(void*); -extern s32 zurumode_flag; -extern void zurumode_cleanup(void) { +extern void zurumode_cleanup(void) { // Hm, this looks like PADMGR_UNSET_RETRACE_CALLBACK macro lol if ((padmgr_class.callback2 == &zurumode_callback) && (padmgr_class.callback2_param == &padmgr_class)) { padmgr_class.callback2 = NULL; padmgr_class.callback2_param = NULL; diff --git a/src/OS/OSDisableInterrupts.c b/src/OS/OSDisableInterrupts.c new file mode 100644 index 00000000..8d1044f0 --- /dev/null +++ b/src/OS/OSDisableInterrupts.c @@ -0,0 +1,12 @@ +#include "dolphin/os.h" + +asm BOOL OSDisableInterrupts(void){ + + nofralloc + + mfmsr r3 + rlwinm r4, r3, 0, 17, 15 + mtmsr r4 + rlwinm r3, r3, 17, 31, 31 + blr +} \ No newline at end of file diff --git a/src/OS/OSEnableInterrupts.c b/src/OS/OSEnableInterrupts.c new file mode 100644 index 00000000..4abb7ba7 --- /dev/null +++ b/src/OS/OSEnableInterrupts.c @@ -0,0 +1,11 @@ +#include "dolphin/os.h" + +asm BOOL OSEnableInterrupts(void){ + +nofralloc +/* 8007AC38 7C6000A6 */ mfmsr r3 +/* 8007AC3C 60648000 */ ori r4, r3, 0x8000 +/* 8007AC40 7C800124 */ mtmsr r4 +/* 8007AC44 54638FFE */ rlwinm r3, r3, 0x11, 0x1f, 0x1f +/* 8007AC48 4E800020 */ blr +} \ No newline at end of file diff --git a/src/OS/OSRestoreInterrupts.c b/src/OS/OSRestoreInterrupts.c new file mode 100644 index 00000000..de96be1c --- /dev/null +++ b/src/OS/OSRestoreInterrupts.c @@ -0,0 +1,17 @@ +#include "dolphin/os.h" + +asm BOOL OSRestoreInterrupts(register BOOL level){ + +nofralloc +/* 8007AC4C 2C030000 */ cmpwi level, 0x0 +/* 8007AC50 7C8000A6 */ mfmsr r4 +/* 8007AC54 4182000C */ beq- lbl_8007ac60 +/* 8007AC58 60858000 */ ori r5, r4, 0x8000 +/* 8007AC5C 48000008 */ b lbl_8007ac64 +lbl_8007ac60: +/* 8007AC60 5485045E */ rlwinm r5, r4, 0, 0x11, 0xf +lbl_8007ac64: +/* 8007AC64 7CA00124 */ mtmsr r5 +/* 8007AC68 54838FFE */ rlwinm r3, r4, 0x11, 0x1f, 0x1f +/* 8007AC6C 4E800020 */ blr +} \ No newline at end of file diff --git a/src/libforest/ReconfigBATs.c b/src/libforest/ReconfigBATs.c index 1b908feb..3e4606d7 100644 --- a/src/libforest/ReconfigBATs.c +++ b/src/libforest/ReconfigBATs.c @@ -1,4 +1,5 @@ #include "libforest/batconfig.h" +#include "dolphin/os.h" // Different to the OS ones. // Not fully Decompiled, need ReconfigBATs func, however there's os stuff that needs to be known. static asm void Config24MB(){ @@ -31,7 +32,7 @@ nofralloc /* 8005AE10 4C00012C */ isync /* 8005AE14 4E800020 */ blr } -static void Config48MB(){ +static asm void Config48MB(){ nofralloc /* 8005AE18 7C6000A6 */ mfmsr r3 /* 8005AE1C 54630734 */ rlwinm r3, r3, 0, 0x1c, 0x1a @@ -61,28 +62,15 @@ nofralloc /* 8005AE7C 4C00012C */ isync /* 8005AE80 4E800020 */ blr } -static void ReconfigBATs(){ -nofralloc -/* 8005AE84 9421FFF0 */ stwu r1, -0x10(r1) -/* 8005AE88 7C0802A6 */ mflr r0 -/* 8005AE8C 90010014 */ stw r0, 0x14(r1) -/* 8005AE90 93E1000C */ stw r31, 0xc(r1) -/* 8005AE94 4801FD91 */ bl func_8007ac24 -/* 8005AE98 7C7F1B78 */ mr r31, r3 -/* 8005AE9C 4802105D */ bl func_8007bef8 -/* 8005AEA0 3C000180 */ lis r0, 0x180 -/* 8005AEA4 7C030040 */ cmplw r3, r0 -/* 8005AEA8 4181000C */ bgt- lbl_8005aeb4 -/* 8005AEAC 4BFFFF01 */ bl func_8005adac -/* 8005AEB0 48000008 */ b lbl_8005aeb8 -lbl_8005aeb4: -/* 8005AEB4 4BFFFF65 */ bl func_8005ae18 -lbl_8005aeb8: -/* 8005AEB8 7FE3FB78 */ mr r3, r31 -/* 8005AEBC 4801FD91 */ bl func_8007ac4c -/* 8005AEC0 80010014 */ lwz r0, 0x14(r1) -/* 8005AEC4 83E1000C */ lwz r31, 0xc(r1) -/* 8005AEC8 7C0803A6 */ mtlr r0 -/* 8005AECC 38210010 */ addi r1, r1, 0x10 -/* 8005AED0 4E800020 */ blr +void ReconfigBATs(){ + +BOOL restore = OSDisableInterrupts(); + +if (OSGetSimulatedMemorySize() <= 0x1800000) { + Config24MB(); + else{ + Config48MB(); + } } + OSRestoreInterrupts(restore); +} \ No newline at end of file