From 982e7be1f7ed06dcd8a9026b461a5908747b8087 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Sun, 28 Nov 2021 12:50:35 +0000 Subject: [PATCH] Preliminary fixes for boot/libultra (#1032) * Preliminary fixes * Missed a NULL --- asm/entry.s | 16 +++++----- asm/osInvalDCache.s | 4 +-- asm/osInvalICache.s | 4 +-- asm/osWritebackDCache.s | 4 +-- asm/osWritebackDCacheAll.s | 4 +-- include/functions.h | 4 +-- include/ultra64/hardware.h | 2 +- include/ultra64/internal.h | 4 +-- include/ultra64/interrupt.h | 1 + include/ultra64/thread.h | 20 ++++++------- include/variables.h | 8 +---- src/libultra_boot_O1/__osGetHWIntrRoutine.c | 6 ++-- src/libultra_boot_O1/__osResetGlobalIntMask.c | 2 +- src/libultra_boot_O1/__osSetGlobalIntMask.c | 2 +- src/libultra_boot_O1/__osSetHWIntrRoutine.c | 8 ++--- src/libultra_boot_O1/initialize.c | 2 +- src/libultra_boot_O1/osDestroyThread.c | 2 +- src/libultra_boot_O1/osJamMesg.c | 2 +- src/libultra_boot_O1/osRecvMesg.c | 2 +- src/libultra_boot_O2/__osEPiRawReadIo.c | 2 +- src/libultra_boot_O2/__osEPiRawStartDma.c | 2 +- src/libultra_boot_O2/__osEPiRawWriteIo.c | 2 +- src/libultra_boot_O2/__osPiRawStartDma.c | 2 +- src/libultra_boot_O2/osCartRomInit.c | 2 +- src/libultra_boot_O2/osDriveRomInit.c | 4 +-- src/libultra_boot_O2/osViGetNextFramebuffer.c | 2 +- src/libultra_boot_O2/osViSetYScale.c | 2 +- src/libultra_boot_O2/vimgr.c | 30 +++++++------------ src/libultra_code_O1/osSetTimer.c | 2 +- src/libultra_code_O1/osStopTimer.c | 2 +- undefined_syms.txt | 7 ----- 31 files changed, 68 insertions(+), 88 deletions(-) diff --git a/asm/entry.s b/asm/entry.s index 1931e91d24..a8b7c1fdce 100644 --- a/asm/entry.s +++ b/asm/entry.s @@ -7,21 +7,23 @@ .section .text +.set BOOT_STACK_SIZE, 0x400 + glabel entrypoint # 0x80000400 - lui $t0, %hi(_bootSegmentBssStart) # $t0, 0x8001 - addiu $t0, %lo(_bootSegmentBssStart) # addiu $t0, $t0, 0x2370 - li $t1, %lo(_bootSegmentBssSize) # li $t1, 0x4A30 + lui $t0, %hi(_bootSegmentBssStart) + addiu $t0, %lo(_bootSegmentBssStart) + li $t1, %lo(_bootSegmentBssSize) .L8000040C: addi $t1, $t1, -8 sw $zero, ($t0) sw $zero, 4($t0) bnez $t1, .L8000040C addi $t0, $t0, 8 - lui $t2, %hi(bootproc) # $t2, 0x8000 - lui $sp, %hi(gMainThread) # $sp, 0x8001 - addiu $t2, %lo(bootproc) # addiu $t2, $t2, 0x0498 + lui $t2, %hi(bootproc) + lui $sp, %hi(sBootThreadStack + BOOT_STACK_SIZE) + addiu $t2, %lo(bootproc) jr $t2 - addiu $sp, %lo(gMainThread) # addiu $sp, $sp, 0x2D60 + addiu $sp, %lo(sBootThreadStack + BOOT_STACK_SIZE) nop nop nop diff --git a/asm/osInvalDCache.s b/asm/osInvalDCache.s index 06ce7df15c..5f2e55866a 100644 --- a/asm/osInvalDCache.s +++ b/asm/osInvalDCache.s @@ -49,13 +49,13 @@ glabel osInvalDCache /* 006E84 80006284 00000000 */ nop .L80006288: -/* 006E88 80006288 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000 +/* 006E88 80006288 3C088000 */ lui $t0, 0x8000 /* 006E8C 8000628C 010B4821 */ addu $t1, $t0, $t3 /* 006E90 80006290 2529FFF0 */ addiu $t1, $t1, -0x10 .L80006294: /* 006E94 80006294 BD010000 */ cache 1, ($t0) /* 006E98 80006298 0109082B */ sltu $at, $t0, $t1 /* 006E9C 8000629C 1420FFFD */ bnez $at, .L80006294 -/* 006EA0 800062A0 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10 +/* 006EA0 800062A0 25080010 */ addiu $t0, 0x10 /* 006EA4 800062A4 03E00008 */ jr $ra /* 006EA8 800062A8 00000000 */ nop diff --git a/asm/osInvalICache.s b/asm/osInvalICache.s index ad774bbd49..da0eade5b2 100644 --- a/asm/osInvalICache.s +++ b/asm/osInvalICache.s @@ -34,13 +34,13 @@ glabel osInvalICache /* 006D9C 8000619C 00000000 */ nop .L800061A0: -/* 006DA0 800061A0 3C088000 */ lui $t0, %hi(D_80000020) # $t0, 0x8000 +/* 006DA0 800061A0 3C088000 */ lui $t0, 0x8000 /* 006DA4 800061A4 010B4821 */ addu $t1, $t0, $t3 /* 006DA8 800061A8 2529FFE0 */ addiu $t1, $t1, -0x20 .L800061AC: /* 006DAC 800061AC BD000000 */ cache 0, ($t0) /* 006DB0 800061B0 0109082B */ sltu $at, $t0, $t1 /* 006DB4 800061B4 1420FFFD */ bnez $at, .L800061AC -/* 006DB8 800061B8 25080020 */ addiu $t0, %lo(D_80000020) # addiu $t0, $t0, 0x20 +/* 006DB8 800061B8 25080020 */ addiu $t0, 0x20 /* 006DBC 800061BC 03E00008 */ jr $ra /* 006DC0 800061C0 00000000 */ nop diff --git a/asm/osWritebackDCache.s b/asm/osWritebackDCache.s index f59c6e6ae6..820fd696bf 100644 --- a/asm/osWritebackDCache.s +++ b/asm/osWritebackDCache.s @@ -34,13 +34,13 @@ glabel osWritebackDCache /* 00530C 8000470C 00000000 */ nop .L80004710: -/* 005310 80004710 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000 +/* 005310 80004710 3C088000 */ lui $t0, 0x8000 /* 005314 80004714 010B4821 */ addu $t1, $t0, $t3 /* 005318 80004718 2529FFF0 */ addiu $t1, $t1, -0x10 .L8000471C: /* 00531C 8000471C BD010000 */ cache 1, ($t0) /* 005320 80004720 0109082B */ sltu $at, $t0, $t1 /* 005324 80004724 1420FFFD */ bnez $at, .L8000471C -/* 005328 80004728 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10 +/* 005328 80004728 25080010 */ addiu $t0, 0x10 /* 00532C 8000472C 03E00008 */ jr $ra /* 005330 80004730 00000000 */ nop diff --git a/asm/osWritebackDCacheAll.s b/asm/osWritebackDCacheAll.s index a3976b395a..065f400557 100644 --- a/asm/osWritebackDCacheAll.s +++ b/asm/osWritebackDCacheAll.s @@ -10,7 +10,7 @@ .balign 16 glabel osWritebackDCacheAll -/* B7D630 80106490 3C088000 */ lui $t0, %hi(D_80000010) # $t0, 0x8000 +/* B7D630 80106490 3C088000 */ lui $t0, 0x8000 /* B7D634 80106494 240A2000 */ li $t2, 8192 /* B7D638 80106498 010A4821 */ addu $t1, $t0, $t2 /* B7D63C 8010649C 2529FFF0 */ addiu $t1, $t1, -0x10 @@ -18,6 +18,6 @@ glabel osWritebackDCacheAll /* B7D640 801064A0 BD010000 */ cache 1, ($t0) /* B7D644 801064A4 0109082B */ sltu $at, $t0, $t1 /* B7D648 801064A8 1420FFFD */ bnez $at, .L801064A0 -/* B7D64C 801064AC 25080010 */ addiu $t0, %lo(D_80000010) # addiu $t0, $t0, 0x10 +/* B7D64C 801064AC 25080010 */ addiu $t0, 0x10 /* B7D650 801064B0 03E00008 */ jr $ra /* B7D654 801064B4 00000000 */ nop diff --git a/include/functions.h b/include/functions.h index 95a23c49da..82453df409 100644 --- a/include/functions.h +++ b/include/functions.h @@ -160,8 +160,8 @@ OSViContext* __osViGetCurrentContext(void); void osStartThread(OSThread* thread); void osViSetYScale(f32 scale); void osViSetXScale(f32 value); -void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); -void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); +void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* sp); +void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handlerOut)(void), void** spOut); void __osSetWatchLo(u32); EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params); diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index 48247b4734..9ffd5c92b1 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -64,7 +64,7 @@ #define PI_STATUS_BUSY 0x1 #define PI_STATUS_IOBUSY 0x2 -#define PI_STATUS_ERROR 0x3 +#define PI_STATUS_ERROR 0x4 #define PI_STATUS_RESET_CONTROLLER 0x1 #define PI_STATUS_CLEAR_INTR 0x2 diff --git a/include/ultra64/internal.h b/include/ultra64/internal.h index e6c9732995..647afb3d79 100644 --- a/include/ultra64/internal.h +++ b/include/ultra64/internal.h @@ -12,8 +12,8 @@ typedef struct { } OSMgrArgs; // size = 0x1C typedef struct { - /* 0x00 */ OSMesgQueue* queue; - /* 0x04 */ OSMesg msg; + /* 0x00 */ s32 (*handler)(void); + /* 0x04 */ void* sp; } __osHwInt; // size = 0x08 typedef struct { diff --git a/include/ultra64/interrupt.h b/include/ultra64/interrupt.h index 7c669c170f..1a7ce934fb 100644 --- a/include/ultra64/interrupt.h +++ b/include/ultra64/interrupt.h @@ -2,5 +2,6 @@ #define ULTRA64_INTERRUPT_H typedef u32 OSIntMask; +typedef u32 OSHWIntr; #endif diff --git a/include/ultra64/thread.h b/include/ultra64/thread.h index 3d826a79e8..a1b5fc57c7 100644 --- a/include/ultra64/thread.h +++ b/include/ultra64/thread.h @@ -44,16 +44,16 @@ typedef struct { } __OSThreadprofile; // size = 0x10 typedef struct OSThread { - /*0x00*/ struct OSThread* next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread** queue; - /*0x0C*/ struct OSThread* tlnext; - /*0x10*/ u16 state; - /*0x12*/ u16 flags; - /*0x14*/ OSId id; - /*0x18*/ s32 fp; - /*0x1C*/ __OSThreadprofile* thprof; - /*0x20*/ __OSThreadContext context; + /* 0x00 */ struct OSThread* next; + /* 0x04 */ OSPri priority; + /* 0x08 */ struct OSThread** queue; + /* 0x0C */ struct OSThread* tlnext; + /* 0x10 */ u16 state; + /* 0x12 */ u16 flags; + /* 0x14 */ OSId id; + /* 0x18 */ s32 fp; + /* 0x1C */ __OSThreadprofile* thprof; + /* 0x20 */ __OSThreadContext context; } OSThread; // size = 0x1B0 #endif diff --git a/include/variables.h b/include/variables.h index 889f91d682..ff95591e77 100644 --- a/include/variables.h +++ b/include/variables.h @@ -14,17 +14,11 @@ extern Gfx D_060257B8[]; extern Gfx D_0602A738[]; extern Gfx D_0602CB48[]; -//extern ? D_80000004; -//extern ? D_80000008; -//extern ? D_8000000C; -//extern ? D_80000010; -//extern ? D_80000020; - extern u32 osTvType; extern u32 osRomBase; extern u32 osResetType; extern u32 osMemSize; -extern u8 osAppNmiBuffer[]; +extern u8 osAppNmiBuffer[0x40]; extern u8 D_80009320[]; extern u8 D_800093F0[]; diff --git a/src/libultra_boot_O1/__osGetHWIntrRoutine.c b/src/libultra_boot_O1/__osGetHWIntrRoutine.c index 4ccfb032a3..4c182a29dc 100644 --- a/src/libultra_boot_O1/__osGetHWIntrRoutine.c +++ b/src/libultra_boot_O1/__osGetHWIntrRoutine.c @@ -1,7 +1,7 @@ #include "global.h" #include "ultra64/internal.h" -void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg) { - *outQueue = __osHwIntTable[idx].queue; - *outMsg = __osHwIntTable[idx].msg; +void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handlerOut)(void), void** spOut) { + *handlerOut = __osHwIntTable[interrupt].handler; + *spOut = __osHwIntTable[interrupt].sp; } diff --git a/src/libultra_boot_O1/__osResetGlobalIntMask.c b/src/libultra_boot_O1/__osResetGlobalIntMask.c index c2561d712c..0e41557976 100644 --- a/src/libultra_boot_O1/__osResetGlobalIntMask.c +++ b/src/libultra_boot_O1/__osResetGlobalIntMask.c @@ -1,7 +1,7 @@ #include "global.h" void __osResetGlobalIntMask(u32 mask) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); __OSGlobalIntMask &= ~(mask & ~0x401); __osRestoreInt(prevInt); diff --git a/src/libultra_boot_O1/__osSetGlobalIntMask.c b/src/libultra_boot_O1/__osSetGlobalIntMask.c index 6b7895d6d4..9dab2aaf1d 100644 --- a/src/libultra_boot_O1/__osSetGlobalIntMask.c +++ b/src/libultra_boot_O1/__osSetGlobalIntMask.c @@ -1,7 +1,7 @@ #include "global.h" void __osSetGlobalIntMask(u32 mask) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); __OSGlobalIntMask |= mask; __osRestoreInt(prevInt); diff --git a/src/libultra_boot_O1/__osSetHWIntrRoutine.c b/src/libultra_boot_O1/__osSetHWIntrRoutine.c index b7ba0066ae..94255df336 100644 --- a/src/libultra_boot_O1/__osSetHWIntrRoutine.c +++ b/src/libultra_boot_O1/__osSetHWIntrRoutine.c @@ -1,11 +1,11 @@ #include "global.h" #include "ultra64/internal.h" -void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg) { - register s32 prevInt = __osDisableInt(); +void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* sp) { + register u32 prevInt = __osDisableInt(); - __osHwIntTable[idx].queue = queue; - __osHwIntTable[idx].msg = msg; + __osHwIntTable[interrupt].handler = handler; + __osHwIntTable[interrupt].sp = sp; __osRestoreInt(prevInt); } diff --git a/src/libultra_boot_O1/initialize.c b/src/libultra_boot_O1/initialize.c index 0489067b0a..d20659298f 100644 --- a/src/libultra_boot_O1/initialize.c +++ b/src/libultra_boot_O1/initialize.c @@ -58,7 +58,7 @@ void __osInitialize_common(void) { osClockRate = (u64)((osClockRate * 3ll) / 4ull); if (!osResetType) { - bzero(osAppNmiBuffer, 0x40); + bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer)); } if (osTvType == OS_TV_PAL) { diff --git a/src/libultra_boot_O1/osDestroyThread.c b/src/libultra_boot_O1/osDestroyThread.c index 9d8fef2544..6f1ffff136 100644 --- a/src/libultra_boot_O1/osDestroyThread.c +++ b/src/libultra_boot_O1/osDestroyThread.c @@ -1,7 +1,7 @@ #include "global.h" void osDestroyThread(OSThread* thread) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); register OSThread* s1; register OSThread* s2; diff --git a/src/libultra_boot_O1/osJamMesg.c b/src/libultra_boot_O1/osJamMesg.c index 997c8fe65f..5668c476e2 100644 --- a/src/libultra_boot_O1/osJamMesg.c +++ b/src/libultra_boot_O1/osJamMesg.c @@ -1,7 +1,7 @@ #include "global.h" s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); while (mq->validCount >= mq->msgCount) { if (flag == OS_MESG_BLOCK) { diff --git a/src/libultra_boot_O1/osRecvMesg.c b/src/libultra_boot_O1/osRecvMesg.c index d6de78adb7..0f4c83cff8 100644 --- a/src/libultra_boot_O1/osRecvMesg.c +++ b/src/libultra_boot_O1/osRecvMesg.c @@ -1,7 +1,7 @@ #include "global.h" s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); while (mq->validCount == 0) { if (flag == OS_MESG_NOBLOCK) { diff --git a/src/libultra_boot_O2/__osEPiRawReadIo.c b/src/libultra_boot_O2/__osEPiRawReadIo.c index 6aa0bf0b68..513a246ee4 100644 --- a/src/libultra_boot_O2/__osEPiRawReadIo.c +++ b/src/libultra_boot_O2/__osEPiRawReadIo.c @@ -4,7 +4,7 @@ s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data) { s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } diff --git a/src/libultra_boot_O2/__osEPiRawStartDma.c b/src/libultra_boot_O2/__osEPiRawStartDma.c index 5ae4d9c307..c8f4de5fda 100644 --- a/src/libultra_boot_O2/__osEPiRawStartDma.c +++ b/src/libultra_boot_O2/__osEPiRawStartDma.c @@ -4,7 +4,7 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dr s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } diff --git a/src/libultra_boot_O2/__osEPiRawWriteIo.c b/src/libultra_boot_O2/__osEPiRawWriteIo.c index 7c5701e0d1..dc169ecf71 100644 --- a/src/libultra_boot_O2/__osEPiRawWriteIo.c +++ b/src/libultra_boot_O2/__osEPiRawWriteIo.c @@ -4,7 +4,7 @@ s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data) { s32 status; OSPiHandle* curHandle; - while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } diff --git a/src/libultra_boot_O2/__osPiRawStartDma.c b/src/libultra_boot_O2/__osPiRawStartDma.c index f2c0a8488e..b642b508fc 100644 --- a/src/libultra_boot_O2/__osPiRawStartDma.c +++ b/src/libultra_boot_O2/__osPiRawStartDma.c @@ -3,7 +3,7 @@ s32 __osPiRawStartDma(s32 dir, u32 cartAddr, void* dramAddr, size_t size) { register s32 status = HW_REG(PI_STATUS_REG, u32); - while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { + while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { status = HW_REG(PI_STATUS_REG, u32); } diff --git a/src/libultra_boot_O2/osCartRomInit.c b/src/libultra_boot_O2/osCartRomInit.c index f87d3bd051..ab54c19312 100644 --- a/src/libultra_boot_O2/osCartRomInit.c +++ b/src/libultra_boot_O2/osCartRomInit.c @@ -27,7 +27,7 @@ OSPiHandle* osCartRomInit(void) { __CartRomHandle.speed = 0; bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); - while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } diff --git a/src/libultra_boot_O2/osDriveRomInit.c b/src/libultra_boot_O2/osDriveRomInit.c index a9f2ea02b5..8aed46dd60 100644 --- a/src/libultra_boot_O2/osDriveRomInit.c +++ b/src/libultra_boot_O2/osDriveRomInit.c @@ -5,7 +5,7 @@ OSPiHandle __DriveRomHandle; OSPiHandle* osDriveRomInit(void) { register s32 status; register u32 a; - register s32 prevInt; + register u32 prevInt; static u32 D_8000AC70 = 1; __osPiGetAccess(); @@ -22,7 +22,7 @@ OSPiHandle* osDriveRomInit(void) { __DriveRomHandle.speed = 0; bzero(&__DriveRomHandle.transferInfo, sizeof(__OSTranxInfo)); - while (status = HW_REG(PI_STATUS_REG, u32), status & PI_STATUS_ERROR) { + while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) { ; } diff --git a/src/libultra_boot_O2/osViGetNextFramebuffer.c b/src/libultra_boot_O2/osViGetNextFramebuffer.c index aaf44ce4a9..a15a2db21c 100644 --- a/src/libultra_boot_O2/osViGetNextFramebuffer.c +++ b/src/libultra_boot_O2/osViGetNextFramebuffer.c @@ -1,7 +1,7 @@ #include "global.h" void* osViGetNextFramebuffer(void) { - s32 prevInt = __osDisableInt(); + u32 prevInt = __osDisableInt(); void* buff = __osViNext->buffer; __osRestoreInt(prevInt); diff --git a/src/libultra_boot_O2/osViSetYScale.c b/src/libultra_boot_O2/osViSetYScale.c index 29128af768..0d7a5f9684 100644 --- a/src/libultra_boot_O2/osViSetYScale.c +++ b/src/libultra_boot_O2/osViSetYScale.c @@ -1,7 +1,7 @@ #include "global.h" void osViSetYScale(f32 scale) { - register s32 prevInt = __osDisableInt(); + register u32 prevInt = __osDisableInt(); __osViNext->y.factor = scale; __osViNext->state |= 4; diff --git a/src/libultra_boot_O2/vimgr.c b/src/libultra_boot_O2/vimgr.c index b57b48d3b4..5be0ba2e30 100644 --- a/src/libultra_boot_O2/vimgr.c +++ b/src/libultra_boot_O2/vimgr.c @@ -1,21 +1,12 @@ #include "global.h" #include "ultra64/internal.h" -typedef struct { - u16 unk00; - u8 unk02; - u32 unk04; - u8 pad[0xC]; - u16 unk14; - u16 unk16; -} viMesgStruct; - OSThread viThread; u8 viThreadStack[0x1000]; OSMesgQueue viEventQueue; OSMesg viEventBuf[6]; -viMesgStruct viRetraceMsg; -viMesgStruct viCounterMsg; +OSIoMesg viRetraceMsg; +OSIoMesg viCounterMsg; OSMgrArgs __osViDevMgr = { 0 }; u32 __additional_scanline = 0; @@ -30,12 +21,12 @@ void osCreateViManager(OSPri pri) { __osTimerServicesInit(); __additional_scanline = 0; osCreateMesgQueue(&viEventQueue, viEventBuf, 5); - viRetraceMsg.unk00 = 13; - viRetraceMsg.unk02 = 0; - viRetraceMsg.unk04 = 0; - viCounterMsg.unk00 = 14; - viCounterMsg.unk02 = 0; - viCounterMsg.unk04 = 0; + viRetraceMsg.hdr.type = 13; + viRetraceMsg.hdr.pri = 0; + viRetraceMsg.hdr.retQueue = NULL; + viCounterMsg.hdr.type = 14; + viCounterMsg.hdr.pri = 0; + viCounterMsg.hdr.retQueue = NULL; osSetEventMesg(OS_EVENT_VI, &viEventQueue, &viRetraceMsg); osSetEventMesg(OS_EVENT_COUNTER, &viEventQueue, &viCounterMsg); newPri = -1; @@ -68,10 +59,9 @@ void viMgrMain(void* vargs) { OSMgrArgs* args; static u16 viRetrace; u32 addTime; - viMesgStruct* mesg; + OSIoMesg* mesg = NULL; u32 temp = 0; // always 0 - mesg = NULL; viRetrace = __osViGetCurrentContext()->retraceCount; if (viRetrace == 0) { viRetrace = 1; @@ -81,7 +71,7 @@ void viMgrMain(void* vargs) { while (true) { osRecvMesg(args->eventQueue, (OSMesg)&mesg, OS_MESG_BLOCK); - switch (mesg->unk00) { + switch (mesg->hdr.type) { case 13: __osViSwapContext(); viRetrace--; diff --git a/src/libultra_code_O1/osSetTimer.c b/src/libultra_code_O1/osSetTimer.c index a14c9b23b4..b0c4a05e91 100644 --- a/src/libultra_code_O1/osSetTimer.c +++ b/src/libultra_code_O1/osSetTimer.c @@ -5,7 +5,7 @@ s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* m OSTimer* next; u32 count; u32 value; - s32 prevInt; + u32 prevInt; timer->next = NULL; timer->prev = NULL; diff --git a/src/libultra_code_O1/osStopTimer.c b/src/libultra_code_O1/osStopTimer.c index 627d57b75d..d6d20536a1 100644 --- a/src/libultra_code_O1/osStopTimer.c +++ b/src/libultra_code_O1/osStopTimer.c @@ -1,7 +1,7 @@ #include "global.h" s32 osStopTimer(OSTimer* timer) { - register s32 prevInt; + register u32 prevInt; OSTimer* next; if (!timer->next) { diff --git a/undefined_syms.txt b/undefined_syms.txt index 95cc1844eb..b2546f2f6e 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1,11 +1,4 @@ // libultra OS symbols -D_80000000 = 0x80000000; -D_80000002 = 0x80000002; -D_80000004 = 0x80000004; -D_80000008 = 0x80000008; -D_8000000C = 0x8000000C; -D_80000010 = 0x80000010; -D_80000020 = 0x80000020; osTvType = 0x80000300; osRomBase = 0x80000308; osResetType = 0x8000030C;