From 33b949126bdcc02f654dcec5681c9a8374663496 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Mon, 27 Sep 2021 13:56:23 -0400 Subject: [PATCH] Split more files, and move them around. Also found and matched osDpGetStatus --- .../unknown_0D24D0/func_800D18D0.s | 7 -- lib/src/libc/ldiv.c | 7 ++ lib/src/libc/ll.c | 69 +++++++++++++++++++ lib/src/libc/xldtob.c | 8 +++ lib/src/libc/xlitob.c | 7 ++ lib/src/os/__osSetCompare.c | 8 +++ .../{unknown_0D24D0.c => os/osDpGetStatus.c} | 5 +- lib/src/os/unknown_0CF330.c | 10 +++ lib/src/{ => os}/unknown_0D6C90.c | 6 -- lib/src/unknown_0CF330.c | 17 ----- src/unknown_078050.c | 4 +- 11 files changed, 115 insertions(+), 33 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D24D0/func_800D18D0.s create mode 100644 lib/src/libc/ldiv.c create mode 100644 lib/src/libc/ll.c create mode 100644 lib/src/libc/xldtob.c create mode 100644 lib/src/libc/xlitob.c create mode 100644 lib/src/os/__osSetCompare.c rename lib/src/{unknown_0D24D0.c => os/osDpGetStatus.c} (61%) create mode 100644 lib/src/os/unknown_0CF330.c rename lib/src/{ => os}/unknown_0D6C90.c (79%) delete mode 100644 lib/src/unknown_0CF330.c diff --git a/lib/asm/non_matchings/unknown_0D24D0/func_800D18D0.s b/lib/asm/non_matchings/unknown_0D24D0/func_800D18D0.s deleted file mode 100644 index c27be119..00000000 --- a/lib/asm/non_matchings/unknown_0D24D0/func_800D18D0.s +++ /dev/null @@ -1,7 +0,0 @@ -glabel func_800D18D0 -/* 0D24D0 800D18D0 3C0EA410 */ lui $t6, 0xa410 -/* 0D24D4 800D18D4 03E00008 */ jr $ra -/* 0D24D8 800D18D8 8DC2000C */ lw $v0, 0xc($t6) - -/* 0D24DC 800D18DC 00000000 */ nop - diff --git a/lib/src/libc/ldiv.c b/lib/src/libc/ldiv.c new file mode 100644 index 00000000..e0817018 --- /dev/null +++ b/lib/src/libc/ldiv.c @@ -0,0 +1,7 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D7470 */ + +#include "macros.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/lldiv.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/ldiv.s") diff --git a/lib/src/libc/ll.c b/lib/src/libc/ll.c new file mode 100644 index 00000000..84e06840 --- /dev/null +++ b/lib/src/libc/ll.c @@ -0,0 +1,69 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800CE730 */ + +#include "types.h" +#include "macros.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_rshift.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_rem.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_div.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_lshift.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_div.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_mul.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_divremi.s") + +/* +unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) +{ + return a0 >> a1; +} +unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1) +{ + return a0 % a1; +} +unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) +{ + return a0 / a1; +} + +unsigned long long __ll_lshift(unsigned long long a0, unsigned long long a1) +{ + return a0 << a1; +} + +long long __ll_rem(unsigned long long a0, long long a1) +{ + return a0 % a1; +} + +long long __ll_div(long long a0, long long a1) +{ + return a0 / a1; +} + +unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1) +{ + return a0 * a1; +} + +void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3) +{ + *div = a2 / a3; + *rem = a2 % a3; +} +long long __ll_mod(long long a0, long long a1) +{ + long long tmp = a0 % a1; + if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0)) + { + + tmp += a1; + } + return tmp; +} + +long long __ll_rshift(long long a0, long long a1) +{ + return a0 >> a1; +} +*/ diff --git a/lib/src/libc/xldtob.c b/lib/src/libc/xldtob.c new file mode 100644 index 00000000..d049fb67 --- /dev/null +++ b/lib/src/libc/xldtob.c @@ -0,0 +1,8 @@ + +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D69A0 */ + +#include "macros.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Genld.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Ldtob.s") diff --git a/lib/src/libc/xlitob.c b/lib/src/libc/xlitob.c new file mode 100644 index 00000000..1f31ecda --- /dev/null +++ b/lib/src/libc/xlitob.c @@ -0,0 +1,7 @@ + +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6700 */ + +#include "macros.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Litob.s") diff --git a/lib/src/os/__osSetCompare.c b/lib/src/os/__osSetCompare.c new file mode 100644 index 00000000..5f4749af --- /dev/null +++ b/lib/src/os/__osSetCompare.c @@ -0,0 +1,8 @@ + +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D7460 */ + +#include "macros.h" + +//Unlikely to ever be able to be decompiled +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSetCompare.s") diff --git a/lib/src/unknown_0D24D0.c b/lib/src/os/osDpGetStatus.c similarity index 61% rename from lib/src/unknown_0D24D0.c rename to lib/src/os/osDpGetStatus.c index f1f578fa..0b0769c8 100644 --- a/lib/src/unknown_0D24D0.c +++ b/lib/src/os/osDpGetStatus.c @@ -3,5 +3,8 @@ #include "types.h" #include "macros.h" +#include "libultra_internal.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D24D0/func_800D18D0.s") +u32 osDpGetStatus(){ + return IO_READ(DPC_STATUS_REG); +} diff --git a/lib/src/os/unknown_0CF330.c b/lib/src/os/unknown_0CF330.c new file mode 100644 index 00000000..8da09a4d --- /dev/null +++ b/lib/src/os/unknown_0CF330.c @@ -0,0 +1,10 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800CED20 */ + +#include "types.h" +#include "macros.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/func_800CED20.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__osPfsGetStatus.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__osPfsGetNextPage.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/osPfsReadWriteFile.s") diff --git a/lib/src/unknown_0D6C90.c b/lib/src/os/unknown_0D6C90.c similarity index 79% rename from lib/src/unknown_0D6C90.c rename to lib/src/os/unknown_0D6C90.c index ed9511c9..7f05b926 100644 --- a/lib/src/unknown_0D6C90.c +++ b/lib/src/os/unknown_0D6C90.c @@ -36,9 +36,3 @@ void osYieldThread(void){ }*/ GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/osDestroyThread.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Litob.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Genld.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/_Ldtob.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSetCompare.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/lldiv.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/ldiv.s") diff --git a/lib/src/unknown_0CF330.c b/lib/src/unknown_0CF330.c deleted file mode 100644 index 02a3e6cd..00000000 --- a/lib/src/unknown_0CF330.c +++ /dev/null @@ -1,17 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800CE730 */ - -#include "types.h" -#include "macros.h" - -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_rshift.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_rem.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_div.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_lshift.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_div.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ll_mul.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__ull_divremi.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/func_800CED20.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__osPfsGetStatus.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/__osPfsGetNextPage.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CF330/osPfsReadWriteFile.s") diff --git a/src/unknown_078050.c b/src/unknown_078050.c index ed0941de..8e8e8d88 100644 --- a/src/unknown_078050.c +++ b/src/unknown_078050.c @@ -184,9 +184,9 @@ s32 func_80077A54(void) { void func_80077AAC(void *bufPtr, s32 arg1, s32 arg2) { osWritebackDCacheAll(); - while (func_800D18D0() & 0x100) {} + while (osDpGetStatus() & DPC_CLR_CMD_CTR) {} osDpSetNextBuffer(bufPtr, arg1); - while (func_800D18D0() & 0x100) {} + while (osDpGetStatus() & DPC_CLR_CMD_CTR) {} } //Probable red, green, blue