Macro Clean up (#454)

* Add OS macros

* MTXMODE cleanup

* format

* More matrix mode macros missed
This commit is contained in:
engineer124
2021-12-07 02:13:18 +00:00
committed by GitHub
parent 93d7fe080b
commit 6ae28a789a
38 changed files with 92 additions and 91 deletions
+2 -2
View File
@@ -796,7 +796,7 @@ void Fault_ThreadEntry(void* arg) {
osSetEventMesg(12, &sFaultContext->queue, (OSMesg)2);
while (1) {
do {
osRecvMesg(&sFaultContext->queue, &msg, 1);
osRecvMesg(&sFaultContext->queue, &msg, OS_MESG_BLOCK);
if (msg == (OSMesg)1) {
sFaultContext->msgId = 1;
@@ -887,7 +887,7 @@ void Fault_Start(void) {
sFaultContext->clients = NULL;
sFaultContext->faultActive = 0;
gFaultStruct.faultHandlerEnabled = 1;
osCreateMesgQueue(&sFaultContext->queue, sFaultContext->msg, 1);
osCreateMesgQueue(&sFaultContext->queue, sFaultContext->msg, ARRAY_COUNT(sFaultContext->msg));
StackCheck_Init(&sFaultThreadInfo, sFaultStack, sFaultStack + sizeof(sFaultStack), 0, 0x100, "fault");
osCreateThread(&sFaultContext->thread, 2, Fault_ThreadEntry, NULL, sFaultStack + sizeof(sFaultStack), 0x7F);
osStartThread(&sFaultContext->thread);
+1 -1
View File
@@ -63,7 +63,7 @@ void Idle_InitCodeAndMemory(void) {
SEGMENT_ROM_END(code) - SEGMENT_ROM_START(code), 0, &queue, 0);
Idle_InitScreen();
Idle_InitMemory();
osRecvMesg(&queue, NULL, 1);
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
sDmaMgrDmaBuffSize = oldSize;
+6 -6
View File
@@ -17,10 +17,10 @@ void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* param_2, OSMesgQueue* param_
osSetIntMask(saveMask);
if (irqmgr->prenmiStage > 0) {
osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, 0);
osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK);
}
if (irqmgr->prenmiStage > 1) {
osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, 0);
osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK);
}
}
@@ -54,7 +54,7 @@ void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg) {
IrqMgrClient* iter = irqmgr->callbacks;
while (iter != NULL) {
osSendMesg(iter->queue, msg, 0);
osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK);
iter = iter->next;
}
}
@@ -64,7 +64,7 @@ void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg) {
while (iter != NULL) {
if (iter->queue->validCount < iter->queue->msgCount) {
osSendMesg(iter->queue, msg, 0);
osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK);
}
iter = iter->next;
}
@@ -130,7 +130,7 @@ void IrqMgr_ThreadEntry(IrqMgr* irqmgr) {
;
}
osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, 1);
osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, OS_MESG_BLOCK);
switch (interrupt) {
case 0x29A:
IrqMgr_HandleRetrace(irqmgr);
@@ -159,7 +159,7 @@ void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount) {
irqmgr->prenmiStage = 0;
irqmgr->lastPrenmiTime = 0;
osCreateMesgQueue(&irqmgr->irqQueue, (OSMesg*)irqmgr->irqBuffer, 8);
osCreateMesgQueue(&irqmgr->irqQueue, (OSMesg*)irqmgr->irqBuffer, ARRAY_COUNT(irqmgr->irqBuffer));
osSetEventMesg(0xE, &irqmgr->irqQueue, (OSMesg)0x29D);
osViSetEvent(&irqmgr->irqQueue, (OSMesg)0x29A, retraceCount);
+2 -2
View File
@@ -31,7 +31,7 @@ s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) {
goto END;
}
osRecvMesg(&queue, NULL, 1);
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
size -= buffSize;
rom = rom + buffSize;
ram = (u8*)ram + buffSize;
@@ -47,7 +47,7 @@ s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) {
goto END;
}
osRecvMesg(&queue, NULL, 1);
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
osInvalDCache(ram, size);
+5 -5
View File
@@ -68,10 +68,10 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo
func_8012C6FC(globalCtx->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, 0);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1);
Matrix_InsertMatrix(&globalCtx->mf_187FC, 1);
Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, 1);
Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
Matrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY);
Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
@@ -95,7 +95,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex
gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1);
Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, arg1);
+4 -4
View File
@@ -259,11 +259,11 @@ s32 View_StepQuake(View* view, Mtx* matrix) {
Matrix_FromRSPMatrix(matrix, &mf);
Matrix_SetCurrentState(&mf);
Matrix_RotateStateAroundXAxis(view->currQuakeRot.x);
Matrix_InsertYRotation_f(view->currQuakeRot.y, 1);
Matrix_InsertZRotation_f(view->currQuakeRot.z, 1);
Matrix_InsertYRotation_f(view->currQuakeRot.y, MTXMODE_APPLY);
Matrix_InsertZRotation_f(view->currQuakeRot.z, MTXMODE_APPLY);
Matrix_Scale(view->currQuakeScale.x, view->currQuakeScale.y, view->currQuakeScale.z, MTXMODE_APPLY);
Matrix_InsertZRotation_f(-view->currQuakeRot.z, 1);
Matrix_InsertYRotation_f(-view->currQuakeRot.y, 1);
Matrix_InsertZRotation_f(-view->currQuakeRot.z, MTXMODE_APPLY);
Matrix_InsertYRotation_f(-view->currQuakeRot.y, MTXMODE_APPLY);
Matrix_RotateStateAroundXAxis(-view->currQuakeRot.x);
Matrix_ToMtx(matrix);
+3 -3
View File
@@ -103,7 +103,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL);
}
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
if (globalCtx->envCtx.unk_11 == 0) {
@@ -120,7 +120,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL);
}
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
size = SEGMENT_ROM_SIZE(d2_fine_pal_static);
@@ -129,7 +129,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->skyboxPaletteStaticSegment,
SEGMENT_ROM_START(d2_fine_pal_static), size, 0, &skyboxCtx->loadQueue, NULL);
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK);
}
}
+2 -2
View File
@@ -7,11 +7,11 @@ s32 osContStartQuery(OSMesgQueue* mq) {
if (__osContLastPoll != 0) {
__osPackRequestData(0);
__osSiRawStartDma(1, &__osContPifRam);
__osSiRawStartDma(OS_WRITE, &__osContPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
ret = __osSiRawStartDma(0, &__osContPifRam);
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
__osContLastPoll = 0;
+3 -3
View File
@@ -8,11 +8,11 @@ s32 osContStartReadData(OSMesgQueue* mq) {
if (__osContLastPoll != 1) {
__osPackReadData();
__osSiRawStartDma(1, &__osContPifRam);
osRecvMesg(mq, NULL, 1);
__osSiRawStartDma(OS_WRITE, &__osContPifRam);
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
ret = __osSiRawStartDma(0, &__osContPifRam);
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
__osContLastPoll = 1;
__osSiRelAccess();
+5 -5
View File
@@ -34,16 +34,16 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
__osPackRequestData(0);
ret = __osSiRawStartDma(1, &__osContPifRam);
osRecvMesg(mq, &dummy, 1);
ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam);
osRecvMesg(mq, &dummy, OS_MESG_BLOCK);
ret = __osSiRawStartDma(0, &__osContPifRam);
osRecvMesg(mq, &dummy, 1);
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
osRecvMesg(mq, &dummy, OS_MESG_BLOCK);
__osContGetInitData(bitpattern, data);
__osContLastPoll = 0;
__osSiCreateAccessQueue();
osCreateMesgQueue(&D_8009CF38, D_8009CF50, 1);
osCreateMesgQueue(&D_8009CF38, D_8009CF50, ARRAY_COUNT(D_8009CF50));
return ret;
}
+2 -2
View File
@@ -16,9 +16,9 @@ s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
}
if (mb->hdr.pri == 1) {
result = osJamMesg(osPiGetCmdQueue(), mb, 0);
result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
} else {
result = osSendMesg(osPiGetCmdQueue(), mb, 0);
result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
}
return result;
}
+2 -2
View File
@@ -7,8 +7,8 @@ OSMesgQueue __osPiAccessQueue;
void __osPiCreateAccessQueue(void) {
__osPiAccessQueueEnabled = 1;
osCreateMesgQueue(&__osPiAccessQueue, D_8009E3F0, 1);
osSendMesg(&__osPiAccessQueue, NULL, 0);
osCreateMesgQueue(&__osPiAccessQueue, D_8009E3F0, ARRAY_COUNT(D_8009E3F0));
osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
}
void __osPiGetAccess(void) {
+1 -1
View File
@@ -14,7 +14,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
if (!__osPiDevMgr.active) {
osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt);
osCreateMesgQueue(&D_8009E3D0, D_8009E3E8, 1);
osCreateMesgQueue(&D_8009E3D0, D_8009E3E8, ARRAY_COUNT(D_8009E3E8));
if (!__osPiAccessQueueEnabled) {
__osPiCreateAccessQueue();
}
+4 -4
View File
@@ -7,8 +7,8 @@ OSMesgQueue __osSiAccessQueue;
void __osSiCreateAccessQueue() {
__osSiAccessQueueEnabled = 1;
osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, 1);
osSendMesg(&__osSiAccessQueue, NULL, 0);
osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, ARRAY_COUNT(siAccessBuf));
osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
}
void __osSiGetAccess(void) {
@@ -16,9 +16,9 @@ void __osSiGetAccess(void) {
if (!__osSiAccessQueueEnabled) {
__osSiCreateAccessQueue();
}
osRecvMesg(&__osSiAccessQueue, &dummyMesg, 1);
osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
}
void __osSiRelAccess(void) {
osSendMesg(&__osSiAccessQueue, NULL, 0);
osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
}
+1 -1
View File
@@ -17,7 +17,7 @@ void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m) {
if (e == 14) {
if (__osShutdown != 0 && D_80097F10 == 0) {
osSendMesg(mq, m, 0);
osSendMesg(mq, m, OS_MESG_NOBLOCK);
}
D_80097F10 = 1;
}
+1 -1
View File
@@ -49,7 +49,7 @@ void __osTimerInterrupt(void) {
t->next = NULL;
t->prev = NULL;
if (t->mq != NULL) {
osSendMesg(t->mq, t->msg, 0);
osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK);
}
if (t->interval != 0) {
t->value = t->interval;
@@ -89,9 +89,9 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
flags = this->dyna.actor.flags & 0x40;
rotZ = this->dyna.actor.shape.rot.z & 0x1FFF;
if ((flags != 0) && (rotZ < 0x1B58) && (rotZ >= 0x1388)) {
Matrix_RotateY(this->dyna.actor.home.rot.y, 0);
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1);
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1);
Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW);
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY);
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY);
for (i = 0; i < 4; i++) {
if ((u32)Rand_Next() >= 0x40000000) {
splashOffset.x = D_80AD3270[i].x - (Rand_ZeroOne() * 30.0f);
@@ -107,9 +107,9 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) {
}
if ((rotZ < 0x1F4) && (rotZ >= 0)) {
if (flags != 0) {
Matrix_RotateY(this->dyna.actor.home.rot.y, 0);
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, 1);
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, 1);
Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_NEW);
Matrix_InsertXRotation_s(this->dyna.actor.home.rot.x, MTXMODE_APPLY);
Matrix_InsertZRotation_s(this->dyna.actor.home.rot.z, MTXMODE_APPLY);
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
splashOffset.x = D_80AD32A0[i].x + (Rand_ZeroOne() * 10.0f);
+1 -1
View File
@@ -1051,7 +1051,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) {
sp9C = Rand_ZeroFloat(M_PI);
for (i = 0; i < 15; i++) {
Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, 0);
Matrix_InsertYRotation_f(((2.0f * (i * M_PI)) / 15.0f) + sp9C, MTXMODE_NEW);
Matrix_GetStateTranslationAndScaledZ((10 - this->unk_0146[0]) * (D_809DF5B0 * 300.0f) * 0.1f,
&sp90);
spD0.x = this->unk_0170.x + sp90.x;
+3 -3
View File
@@ -54,9 +54,9 @@ void EnBu_Draw(Actor* thisx, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW);
Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1);
Matrix_RotateY(this->actor.shape.rot.y, 1);
Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1);
Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY);
Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY);
Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY);
Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, this->displayListPtr);
+1 -1
View File
@@ -119,6 +119,6 @@ void EnCha_Draw(Actor* thisx, GlobalContext* globalCtx) {
func_800BDFC0(globalCtx, D_06000710);
Matrix_InsertTranslation(-1094.0f, 4950.0f, 9.0f, MTXMODE_APPLY);
Matrix_InsertXRotation_s(this->actor.home.rot.x, 1);
Matrix_InsertXRotation_s(this->actor.home.rot.x, MTXMODE_APPLY);
func_800BDFC0(globalCtx, D_06000958);
}

Some files were not shown because too many files have changed in this diff Show More