mirror of
https://github.com/zeldaret/oot
synced 2026-07-08 22:35:00 -04:00
Preliminary fixes for boot/libultra (#1032)
* Preliminary fixes * Missed a NULL
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
|
||||
void __osResetGlobalIntMask(u32 mask) {
|
||||
register s32 prevInt = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
__OSGlobalIntMask &= ~(mask & ~0x401);
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
|
||||
void __osSetGlobalIntMask(u32 mask) {
|
||||
register s32 prevInt = __osDisableInt();
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
||||
__OSGlobalIntMask |= mask;
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
|
||||
void* osViGetNextFramebuffer(void) {
|
||||
s32 prevInt = __osDisableInt();
|
||||
u32 prevInt = __osDisableInt();
|
||||
void* buff = __osViNext->buffer;
|
||||
|
||||
__osRestoreInt(prevInt);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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--;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
|
||||
s32 osStopTimer(OSTimer* timer) {
|
||||
register s32 prevInt;
|
||||
register u32 prevInt;
|
||||
OSTimer* next;
|
||||
|
||||
if (!timer->next) {
|
||||
|
||||
Reference in New Issue
Block a user