diff --git a/lib/asm/exception/__osException.s b/lib/asm/exception/__osException.s index 753995fb..04603d60 100644 --- a/lib/asm/exception/__osException.s +++ b/lib/asm/exception/__osException.s @@ -188,9 +188,9 @@ glabel __osException /* 0D3B20 800D2F20 2401F7FF */ li $at, -2049 /* 0D3B24 800D2F24 02018024 */ and $s0, $s0, $at /* 0D3B28 800D2F28 240A0004 */ li $t2, 4 -/* 0D3B2C 800D2F2C 3C01800E */ lui $at, %hi(D_800E48A0) # $at, 0x800e +/* 0D3B2C 800D2F2C 3C01800E */ lui $at, %hi(__osHwIntTable) # $at, 0x800e /* 0D3B30 800D2F30 002A0821 */ addu $at, $at, $t2 -/* 0D3B34 800D2F34 8C2A48A0 */ lw $t2, %lo(D_800E48A0)($at) +/* 0D3B34 800D2F34 8C2A48A0 */ lw $t2, %lo(__osHwIntTable)($at) /* 0D3B38 800D2F38 3C1D8013 */ lui $sp, %hi(D_8012AAE0) # $sp, 0x8013 /* 0D3B3C 800D2F3C 27BDAAE0 */ addiu $sp, %lo(D_8012AAE0) # addiu $sp, $sp, -0x5520 /* 0D3B40 800D2F40 24040010 */ li $a0, 16 diff --git a/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s b/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s index 12e90d2f..dd6fbaca 100644 --- a/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s +++ b/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s @@ -7,13 +7,13 @@ glabel __osSetHWIntrRoutine /* 0D5404 800D4804 AFB00018 */ sw $s0, 0x18($sp) /* 0D5408 800D4808 8FAF0028 */ lw $t7, 0x28($sp) /* 0D540C 800D480C 8FAE002C */ lw $t6, 0x2c($sp) -/* 0D5410 800D4810 3C01800E */ lui $at, %hi(D_800E48A0) # $at, 0x800e +/* 0D5410 800D4810 3C01800E */ lui $at, %hi(__osHwIntTable) # $at, 0x800e /* 0D5414 800D4814 000FC080 */ sll $t8, $t7, 2 /* 0D5418 800D4818 00408025 */ move $s0, $v0 /* 0D541C 800D481C 00380821 */ addu $at, $at, $t8 /* 0D5420 800D4820 02002025 */ move $a0, $s0 /* 0D5424 800D4824 0C034960 */ jal __osRestoreInt -/* 0D5428 800D4828 AC2E48A0 */ sw $t6, %lo(D_800E48A0)($at) +/* 0D5428 800D4828 AC2E48A0 */ sw $t6, %lo(__osHwIntTable)($at) /* 0D542C 800D482C 8FBF001C */ lw $ra, 0x1c($sp) /* 0D5430 800D4830 8FB00018 */ lw $s0, 0x18($sp) /* 0D5434 800D4834 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/lib/src/al/alCopy.c b/lib/src/al/alCopy.c index 9134fa85..8826cf0c 100644 --- a/lib/src/al/alCopy.c +++ b/lib/src/al/alCopy.c @@ -5,7 +5,7 @@ #include "macros.h" //TODO: This probably belongs somewhere else -s32 D_800E48A0[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +s32 __osHwIntTable[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; void alCopy(void *src, void *dest, s32 len) { s32 i; diff --git a/lib/src/os/__osSetHWIntrRoutine.c b/lib/src/os/__osSetHWIntrRoutine.c new file mode 100644 index 00000000..f43cc300 --- /dev/null +++ b/lib/src/os/__osSetHWIntrRoutine.c @@ -0,0 +1,13 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D47DC */ + +#include "libultra_internal.h" + +extern s32 (*__osHwIntTable[])(void); + +void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void)) { + register u32 saveMask; + saveMask = __osDisableInt(); + __osHwIntTable[interrupt] = handler; + __osRestoreInt(saveMask); +} diff --git a/lib/src/os/contramread.c b/lib/src/os/contramread.c index 2e88c70e..f9e329a1 100644 --- a/lib/src/os/contramread.c +++ b/lib/src/os/contramread.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800CDCA0 */ -#include "macros.h" #include "libultra_internal.h" #include "controller.h" #include "siint.h" diff --git a/lib/src/os/contramwrite.c b/lib/src/os/contramwrite.c index e4d9b996..4a5bdc8f 100644 --- a/lib/src/os/contramwrite.c +++ b/lib/src/os/contramwrite.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x800CD8F0 */ #include "libultra_internal.h" -#include "macros.h" #include "controller.h" #include "siint.h" diff --git a/lib/src/os/crc.c b/lib/src/os/crc.c index a0b317bd..a3f8e32e 100644 --- a/lib/src/os/crc.c +++ b/lib/src/os/crc.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x800CD770 */ #include "types.h" -#include "macros.h" u8 __osContAddressCrc(u16 addr) { u8 temp; diff --git a/lib/src/os/osAiGetLength.c b/lib/src/os/osAiGetLength.c index e6170368..7232001c 100644 --- a/lib/src/os/osAiGetLength.c +++ b/lib/src/os/osAiGetLength.c @@ -1,8 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C8E20 */ -#include "types.h" -#include "macros.h" #include "PR/rcp.h" u32 osAiGetLength(void) { diff --git a/lib/src/os/osAiSetNextBuffer.c b/lib/src/os/osAiSetNextBuffer.c index b4a15580..8d023f15 100644 --- a/lib/src/os/osAiSetNextBuffer.c +++ b/lib/src/os/osAiSetNextBuffer.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x800C8D70 */ #include "types.h" -#include "macros.h" #include #include #include "osVirtualToPhysical.h" diff --git a/lib/src/os/osCreateThread.c b/lib/src/os/osCreateThread.c index e74c1887..c4597315 100644 --- a/lib/src/os/osCreateThread.c +++ b/lib/src/os/osCreateThread.c @@ -4,8 +4,8 @@ #include "libultra_internal.h" #include "PR/R4300.h" -extern OSThread *__osActiveQueue; //__osActiveQueue; -void __osCleanupThread(void); //__osCleanupThread +extern OSThread *__osActiveQueue; +void __osCleanupThread(void); void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) { register u32 saveMask; diff --git a/lib/src/os/osDpGetStatus.c b/lib/src/os/osDpGetStatus.c index 0b0769c8..68f2344e 100644 --- a/lib/src/os/osDpGetStatus.c +++ b/lib/src/os/osDpGetStatus.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x800D18D0 */ #include "types.h" -#include "macros.h" #include "libultra_internal.h" u32 osDpGetStatus(){ diff --git a/lib/src/os/osDpSetNextBuffer.c b/lib/src/os/osDpSetNextBuffer.c index de35b0bd..ec05be1c 100644 --- a/lib/src/os/osDpSetNextBuffer.c +++ b/lib/src/os/osDpSetNextBuffer.c @@ -4,7 +4,7 @@ #include "libultra_internal.h" #include "osVirtualToPhysical.h" -int __osDpDeviceBusy(void); +s32 __osDpDeviceBusy(void); s32 osDpSetNextBuffer(void *bufPtr, u64 size) { register u32 stat; diff --git a/lib/src/os/osEepromRead.c b/lib/src/os/osEepromRead.c index 4f66e6c8..c5856877 100644 --- a/lib/src/os/osEepromRead.c +++ b/lib/src/os/osEepromRead.c @@ -1,8 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800CE280 */ -#include "types.h" -#include "macros.h" #include "libultra_internal.h" #include "PR/rcp.h" #include "controller.h" diff --git a/lib/src/os/osEpiRawStartDma.c b/lib/src/os/osEpiRawStartDma.c index 246bac2a..3698b832 100644 --- a/lib/src/os/osEpiRawStartDma.c +++ b/lib/src/os/osEpiRawStartDma.c @@ -1,8 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D2680 */ -#include "types.h" -#include "macros.h" #include "libultra_internal.h" #include "PR/rcp.h" #include "osVirtualToPhysical.h" diff --git a/lib/src/os/osGetActiveQueue.c b/lib/src/os/osGetActiveQueue.c index 27b2fff9..7dc7f369 100644 --- a/lib/src/os/osGetActiveQueue.c +++ b/lib/src/os/osGetActiveQueue.c @@ -1,8 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D2470 */ -#include "types.h" -#include "macros.h" #include "libultra_internal.h" extern OSThread *__osActiveQueue; diff --git a/lib/src/os/osGetCount.c b/lib/src/os/osGetCount.c index c6930a89..b553ef2b 100644 --- a/lib/src/os/osGetCount.c +++ b/lib/src/os/osGetCount.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C78D0 */ -#include "types.h" #include "macros.h" //I don't believe that can be decompiled diff --git a/lib/src/os/osInvalDCache.c b/lib/src/os/osInvalDCache.c index 08cbb7ef..3fea6d4c 100644 --- a/lib/src/os/osInvalDCache.c +++ b/lib/src/os/osInvalDCache.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D17F0 */ -#include "types.h" #include "macros.h" //Most likely hand written and unable to be be decomped diff --git a/lib/src/os/osSetEventMesg.c b/lib/src/os/osSetEventMesg.c index 47339dbf..f5fdea3d 100644 --- a/lib/src/os/osSetEventMesg.c +++ b/lib/src/os/osSetEventMesg.c @@ -8,7 +8,7 @@ typedef struct __OSEventState { OSMesg message; } __OSEventState; -__OSEventState __osEventStateTab[15]; // __osEventStateTab[OS_NUM_EVENTS]; +__OSEventState __osEventStateTab[15]; //OS_NUM_EVENTS = 15 void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) { register u32 saveMask = __osDisableInt(); __OSEventState *es; diff --git a/lib/src/os/osSetIntMask.c b/lib/src/os/osSetIntMask.c index cbe2348f..286825ce 100644 --- a/lib/src/os/osSetIntMask.c +++ b/lib/src/os/osSetIntMask.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C9A30 */ -#include "types.h" #include "macros.h" //I don't believe it's possible to decomp this one diff --git a/lib/src/os/osSetTimer.c b/lib/src/os/osSetTimer.c index 41c97d8a..ff3db096 100644 --- a/lib/src/os/osSetTimer.c +++ b/lib/src/os/osSetTimer.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D4DE0 */ -#include "macros.h" #include "libultra_internal.h" extern OSTimer *__osTimerList; diff --git a/lib/src/os/osTimer.c b/lib/src/os/osTimer.c index 9a9f2bea..77d6e70d 100644 --- a/lib/src/os/osTimer.c +++ b/lib/src/os/osTimer.c @@ -18,8 +18,7 @@ OSTime __osInsertTimer(OSTimer *t); #ifdef NON_MATCHING //Seems to be a mistmatch based on where __osCurrentTime is defined. //Scratch proving that: https://decomp.me/scratch/OB3iP -void __osTimerServicesInit(void) -{ +void __osTimerServicesInit(void) { __osCurrentTime = 0; __osBaseCounter = 0; __osViIntrCount = 0; diff --git a/lib/src/os/osViMgr.c b/lib/src/os/osViMgr.c index 49a1a551..0789aec4 100644 --- a/lib/src/os/osViMgr.c +++ b/lib/src/os/osViMgr.c @@ -8,20 +8,20 @@ extern OSTime __osCurrentTime; extern u32 __osBaseCounter; -extern u32 __osViIntrCount; //__osViIntrCount +extern u32 __osViIntrCount; OSDevMgr __osViDevMgr = {0}; #define OS_VIM_STACKSIZE 4096 -u8 viThreadStack[2960]; // viThreadStack[OS_VIM_STACKSIZE]; +u8 viThreadStack[2960]; // Should be OS_VIM_STACKSIZE? s32 gThread30Stack; extern OSThread viThread; extern OSMesgQueue viEventQueue; -extern OSMesg viEventBuf[5]; //viEventBuf; -extern OSIoMesg viRetraceMsg; //viRetraceMsg -extern OSIoMesg viCounterMsg; //viCounterMsg +extern OSMesg viEventBuf[5]; +extern OSIoMesg viRetraceMsg; +extern OSIoMesg viCounterMsg; void viMgrMain(void *arg); diff --git a/lib/src/os/osWritebackDCacheAll.c b/lib/src/os/osWritebackDCacheAll.c index 1c238a06..3aa719a3 100644 --- a/lib/src/os/osWritebackDCacheAll.c +++ b/lib/src/os/osWritebackDCacheAll.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D18A0 */ -#include "types.h" #include "macros.h" //Likely hand written and impossible to decomp diff --git a/lib/src/os/unknown_0C7F40.c b/lib/src/os/unknown_0C7340.c similarity index 90% rename from lib/src/os/unknown_0C7F40.c rename to lib/src/os/unknown_0C7340.c index cb91a737..e8c8ccde 100644 --- a/lib/src/os/unknown_0C7F40.c +++ b/lib/src/os/unknown_0C7340.c @@ -2,7 +2,6 @@ /* RAM_POS: 0x800C7340 */ #include "types.h" -#include "macros.h" //Called only in osInitialize s32 func_800C7340(void) { diff --git a/lib/src/os/unknown_0D5390.c b/lib/src/os/unknown_0D5390.c deleted file mode 100644 index edc82764..00000000 --- a/lib/src/os/unknown_0D5390.c +++ /dev/null @@ -1,6 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800D47DC */ - -#include "macros.h" - -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s")