mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 04:42:18 -05:00
change OSMesg definition and fix memory corruptions
This commit is contained in:
parent
72fcd19a9e
commit
b5d5930fed
@ -6,7 +6,23 @@
|
||||
#define OS_MESG_NOBLOCK 0
|
||||
#define OS_MESG_BLOCK 1
|
||||
|
||||
typedef void* OSMesg;
|
||||
typedef union {
|
||||
u8 data8;
|
||||
u16 data16;
|
||||
u32 data32;
|
||||
void* ptr;
|
||||
} OSMesg;
|
||||
|
||||
#define OS_MESG_8(x) ((OSMesg) { .data8 = (x) })
|
||||
#define OS_MESG_16(x) ((OSMesg) { .data16 = (x) })
|
||||
#define OS_MESG_32(x) ((OSMesg) { .data32 = (x) })
|
||||
#define OS_MESG_PTR(x) ((OSMesg) { .ptr = (x) })
|
||||
|
||||
#define osSendMesg8(queue, msg, flag) osSendMesg(queue, OS_MESG_8(msg), flag)
|
||||
#define osSendMesg16(queue, msg, flag) osSendMesg(queue, OS_MESG_16(msg), flag)
|
||||
#define osSendMesg32(queue, msg, flag) osSendMesg(queue, OS_MESG_32(msg), flag)
|
||||
#define osSendMesgPtr(queue, msg, flag) osSendMesg(queue, OS_MESG_PTR(msg), flag)
|
||||
|
||||
typedef u32 OSEvent;
|
||||
|
||||
#define OS_NUM_EVENTS 15
|
||||
|
@ -30,11 +30,13 @@ endif
|
||||
|
||||
ifneq ($(ASAN),0)
|
||||
CXXFLAGS += -fsanitize=address
|
||||
CFLAGS += -fsanitize=address
|
||||
LDFLAGS += -fsanitize=address
|
||||
endif
|
||||
|
||||
ifneq ($(LTO),0)
|
||||
CXXFLAGS += -flto
|
||||
CFLAGS += -flto
|
||||
LDFLAGS += -flto
|
||||
endif
|
||||
|
||||
|
@ -689,7 +689,7 @@ typedef struct {
|
||||
};
|
||||
};
|
||||
union {
|
||||
void* data;
|
||||
u32 data;
|
||||
f32 asFloat;
|
||||
s32 asInt;
|
||||
struct {
|
||||
|
@ -312,7 +312,7 @@ void DmaMgr_ThreadEntry(void* arg0) {
|
||||
osSyncPrintf("DMAマネージャスレッド実行開始\n");
|
||||
while (true) {
|
||||
osRecvMesg(&sDmaMgrMsgQueue, &msg, OS_MESG_BLOCK);
|
||||
req = (DmaRequest*)msg;
|
||||
req = (DmaRequest*)msg.ptr;
|
||||
if (req == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -360,7 +360,7 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, uintptr_t ram, uintptr_t vrom, size_
|
||||
}
|
||||
}
|
||||
|
||||
osSendMesg(&sDmaMgrMsgQueue, req, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&sDmaMgrMsgQueue, req, OS_MESG_BLOCK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -371,7 +371,7 @@ s32 DmaMgr_SendRequest0(uintptr_t ram, uintptr_t vrom, size_t size) {
|
||||
s32 ret;
|
||||
|
||||
osCreateMesgQueue(&queue, &msg, 1);
|
||||
ret = DmaMgr_SendRequestImpl(&req, ram, vrom, size, 0, &queue, NULL);
|
||||
ret = DmaMgr_SendRequestImpl(&req, ram, vrom, size, 0, &queue, OS_MESG_PTR(NULL));
|
||||
if (ret == -1) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void ArenaImpl_LockInit(Arena* arena) {
|
||||
}
|
||||
|
||||
void ArenaImpl_Lock(Arena* arena) {
|
||||
osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&arena->lock, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void ArenaImpl_Unlock(Arena* arena) {
|
||||
|
@ -7,7 +7,7 @@ void func_800C3C80(AudioMgr* audioMgr) {
|
||||
|
||||
task = audioMgr->rspTask;
|
||||
if (audioMgr->rspTask->taskQueue != NULL) {
|
||||
osSendMesg(task->taskQueue, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(task->taskQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
audioMgr->audioTask.list = audioMgr->rspTask->task;
|
||||
audioMgr->audioTask.msgQ = &audioMgr->unk_AC;
|
||||
|
||||
audioMgr->audioTask.msg = NULL;
|
||||
osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK);
|
||||
audioMgr->audioTask.msg.ptr = NULL;
|
||||
osSendMesgPtr(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK);
|
||||
Sched_SendEntryMsg(audioMgr->sched);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon
|
||||
osCreateMesgQueue(&audioMgr->unk_74, &audioMgr->unk_8C, 8);
|
||||
osCreateMesgQueue(&audioMgr->unk_C8, &audioMgr->unk_E0, 1);
|
||||
|
||||
osSendMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK);
|
||||
|
||||
static bool hasInitialized = false;
|
||||
|
||||
@ -107,7 +107,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon
|
||||
Audio_Init();
|
||||
AudioLoad_SetDmaHandler(DmaMgr_DmaHandler);
|
||||
Audio_InitSound();
|
||||
osSendMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK);
|
||||
ModInternal_ExecuteAudioInitHooks();
|
||||
// Removed due to crash
|
||||
//IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74);
|
||||
|
@ -461,7 +461,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) {
|
||||
|
||||
void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) {
|
||||
if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) {
|
||||
osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK);
|
||||
osSendMesg32(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1079,7 +1079,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
||||
ret = AudioLoad_SearchCaches(tableType, realId);
|
||||
if (ret != NULL) {
|
||||
status = 2;
|
||||
osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK);
|
||||
osSendMesg32(retQueue, MK_ASYNC_MSG(retData, 0, 0, 0), OS_MESG_NOBLOCK);
|
||||
} else {
|
||||
sp50 = AudioLoad_GetLoadTable(tableType);
|
||||
size = sp50->entries[realId].size;
|
||||
@ -1312,19 +1312,12 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
void* temp_v0_3;
|
||||
s32 i;
|
||||
u64* heapP;
|
||||
u8* ctxP;
|
||||
s16* u2974p;
|
||||
|
||||
D_801755D0 = NULL;
|
||||
gAudioContext.resetTimer = 0;
|
||||
|
||||
{
|
||||
s32 i;
|
||||
u8* ctxP = (u8*)&gAudioContext;
|
||||
for (i = sizeof(gAudioContext); i >= 0; i--) {
|
||||
*ctxP++ = 0;
|
||||
}
|
||||
}
|
||||
memset(&gAudioContext, 0, sizeof(gAudioContext));
|
||||
|
||||
switch (osTvType) {
|
||||
case OS_TV_PAL:
|
||||
@ -1421,7 +1414,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, temp_v0_3, D_8014A6C4.permanentPoolSize);
|
||||
gAudioContextInitalized = true;
|
||||
osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
|
||||
osSendMesg32(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
void AudioLoad_InitSlowLoads(void) {
|
||||
@ -1649,7 +1642,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t
|
||||
return NULL;
|
||||
}
|
||||
|
||||
osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK);
|
||||
osSendMesgPtr(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK);
|
||||
asyncLoad->unkMediumParam = unkMediumParam;
|
||||
return asyncLoad;
|
||||
}
|
||||
@ -1765,7 +1758,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) {
|
||||
break;
|
||||
}
|
||||
|
||||
doneMsg = asyncLoad->retMsg;
|
||||
doneMsg.data32 = asyncLoad->retMsg;
|
||||
if (1) {}
|
||||
asyncLoad->status = LOAD_STATUS_WAITING;
|
||||
osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK);
|
||||
|
@ -39,7 +39,7 @@ extern u64 rspAspMainDataStart[];
|
||||
extern u64 rspAspMainDataEnd[];
|
||||
|
||||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) {
|
||||
u32 sp4C;
|
||||
OSMesg sp4C;
|
||||
|
||||
gAudioContext.totalTaskCnt++;
|
||||
|
||||
@ -50,7 +50,7 @@ void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) {
|
||||
if (gAudioContext.resetStatus != 0) {
|
||||
if (AudioHeap_ResetStep() == 0) {
|
||||
if (gAudioContext.resetStatus == 0) {
|
||||
osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
||||
osSendMesg8(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,8 +58,8 @@ void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples) {
|
||||
int j = 0;
|
||||
if (gAudioContext.resetStatus == 0) {
|
||||
// msg = 0000RREE R = read pos, E = End Pos
|
||||
while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
Audio_ProcessCmds(sp4C);
|
||||
while (osRecvMesg(gAudioContext.cmdProcQueueP, &sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
Audio_ProcessCmds(sp4C.data32);
|
||||
j++;
|
||||
}
|
||||
if ((j == 0) && (gAudioContext.cmdQueueFinished)) {
|
||||
@ -84,7 +84,7 @@ AudioTask* func_800E5000(void) {
|
||||
s16* currAiBuffer;
|
||||
OSTask_t* task;
|
||||
s32 index;
|
||||
u32 sp4C;
|
||||
OSMesg sp4C;
|
||||
s32 sp48;
|
||||
s32 i;
|
||||
|
||||
@ -102,7 +102,7 @@ AudioTask* func_800E5000(void) {
|
||||
}
|
||||
}
|
||||
|
||||
osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
|
||||
osSendMesg32(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
|
||||
gAudioContext.rspTaskIdx ^= 1;
|
||||
gAudioContext.curAIBufIdx++;
|
||||
gAudioContext.curAIBufIdx %= 3;
|
||||
@ -149,7 +149,7 @@ AudioTask* func_800E5000(void) {
|
||||
if (gAudioContext.resetStatus != 0) {
|
||||
if (AudioHeap_ResetStep() == 0) {
|
||||
if (gAudioContext.resetStatus == 0) {
|
||||
osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
||||
osSendMesg8(gAudioContext.audioResetQueueP, gAudioContext.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
sWaitingAudioTask = NULL;
|
||||
@ -186,11 +186,11 @@ AudioTask* func_800E5000(void) {
|
||||
j = 0;
|
||||
if (gAudioContext.resetStatus == 0) {
|
||||
// msg = 0000RREE R = read pos, E = End Pos
|
||||
while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
while (osRecvMesg(gAudioContext.cmdProcQueueP, &sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
Audio_ProcessCmds(sp4C);
|
||||
Audio_ProcessCmds(sp4C.data32);
|
||||
j++;
|
||||
}
|
||||
if ((j == 0) && (gAudioContext.cmdQueueFinished)) {
|
||||
@ -386,11 +386,11 @@ void Audio_InitMesgQueuesInternal(void) {
|
||||
ARRAY_COUNT(gAudioContext.audioResetMesgs));
|
||||
}
|
||||
|
||||
void Audio_QueueCmd(u32 opArgs, void** data) {
|
||||
void Audio_QueueCmd(u32 opArgs, u32 data) {
|
||||
AudioCmd* cmd = &gAudioContext.cmdBuf[gAudioContext.cmdWrPos & 0xFF];
|
||||
|
||||
cmd->opArgs = opArgs;
|
||||
cmd->data = *data;
|
||||
cmd->data = data;
|
||||
|
||||
gAudioContext.cmdWrPos++;
|
||||
|
||||
@ -400,23 +400,28 @@ void Audio_QueueCmd(u32 opArgs, void** data) {
|
||||
}
|
||||
|
||||
void Audio_QueueCmdF32(u32 opArgs, f32 data) {
|
||||
Audio_QueueCmd(opArgs, (void**)&data);
|
||||
union
|
||||
{
|
||||
f32 f;
|
||||
u32 u;
|
||||
} uData = { .f = data };
|
||||
Audio_QueueCmd(opArgs, uData.u);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdS32(u32 opArgs, s32 data) {
|
||||
Audio_QueueCmd(opArgs, (void**)&data);
|
||||
Audio_QueueCmd(opArgs, data);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdS8(u32 opArgs, s8 data) {
|
||||
u32 uData = data << 0x18;
|
||||
|
||||
Audio_QueueCmd(opArgs, (void**)&uData);
|
||||
Audio_QueueCmd(opArgs, uData);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdU16(u32 opArgs, u16 data) {
|
||||
u32 uData = data << 0x10;
|
||||
|
||||
Audio_QueueCmd(opArgs, (void**)&uData);
|
||||
Audio_QueueCmd(opArgs, uData);
|
||||
}
|
||||
|
||||
s32 Audio_ScheduleProcessCmds(void) {
|
||||
@ -428,8 +433,8 @@ s32 Audio_ScheduleProcessCmds(void) {
|
||||
}
|
||||
|
||||
ret =
|
||||
osSendMesg(gAudioContext.cmdProcQueueP,
|
||||
(void*)(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK);
|
||||
osSendMesg32(gAudioContext.cmdProcQueueP,
|
||||
(((gAudioContext.cmdRdPos & 0xFF) << 8) | (gAudioContext.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK);
|
||||
if (ret != -1) {
|
||||
gAudioContext.cmdRdPos = gAudioContext.cmdWrPos;
|
||||
ret = 0;
|
||||
@ -531,11 +536,11 @@ void func_800E5EA4(s32 arg0, u32* arg1, u32* arg2) {
|
||||
|
||||
s32 func_800E5EDC(void) {
|
||||
s32 pad;
|
||||
s32 sp18;
|
||||
OSMesg sp18;
|
||||
|
||||
if (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp18, OS_MESG_NOBLOCK) == -1) {
|
||||
if (osRecvMesg(gAudioContext.audioResetQueueP, &sp18, OS_MESG_NOBLOCK) == -1) {
|
||||
return 0;
|
||||
} else if (gAudioContext.audioResetSpecIdToLoad != sp18) {
|
||||
} else if (gAudioContext.audioResetSpecIdToLoad != sp18.data8) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
@ -545,7 +550,7 @@ s32 func_800E5EDC(void) {
|
||||
void func_800E5F34(void) {
|
||||
// macro?
|
||||
// clang-format off
|
||||
s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk);
|
||||
s32 chk = -1; OSMesg sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, &sp28, OS_MESG_NOBLOCK) != chk);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
@ -525,7 +525,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
||||
}
|
||||
SpeedMeter_Init(&D_801664D0);
|
||||
func_800AA0B4();
|
||||
osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
|
||||
|
||||
endTime = osGetTime();
|
||||
// "Other initialization processing time %d us"
|
||||
|
@ -170,7 +170,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
||||
|
||||
D_8016A528 = osGetTime() - sGraphSetTaskTime - D_8016A558;
|
||||
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, (OSMesg)666);
|
||||
osSetTimer(&timer, OS_USEC_TO_CYCLES(3000000), 0, &gfxCtx->queue, OS_MESG_32(666));
|
||||
|
||||
osRecvMesg(&gfxCtx->queue, &msg, OS_MESG_BLOCK);
|
||||
osStopTimer(&timer);
|
||||
@ -243,7 +243,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
||||
}
|
||||
|
||||
scTask->msgQ = &gfxCtx->queue;
|
||||
scTask->msg = NULL;
|
||||
scTask->msg.ptr = NULL;
|
||||
|
||||
cfb = &sGraphCfbInfos[sGraphCfbInfoIdx++];
|
||||
cfb->fb1 = gfxCtx->curFrameBuffer;
|
||||
@ -262,7 +262,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
||||
|
||||
gfxCtx->schedMsgQ = &gSchedContext.cmdQ;
|
||||
|
||||
osSendMesg(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&gSchedContext.cmdQ, scTask, OS_MESG_BLOCK);
|
||||
Sched_SendEntryMsg(&gSchedContext);
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,11 @@ void IrqMgr_AddClient(IrqMgr* this, IrqMgrClient* c, OSMesgQueue* msgQ) {
|
||||
osSetIntMask(prevInt);
|
||||
|
||||
if (this->resetStatus > STATUS_IDLE) {
|
||||
osSendMesg(c->queue, (OSMesg) & this->prenmiMsg, OS_MESG_NOBLOCK);
|
||||
osSendMesgPtr(c->queue, &this->prenmiMsg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
if (this->resetStatus >= STATUS_NMI) {
|
||||
osSendMesg(c->queue, (OSMesg) & this->nmiMsg, OS_MESG_NOBLOCK);
|
||||
osSendMesgPtr(c->queue, &this->nmiMsg, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,8 +107,8 @@ void IrqMgr_HandlePreNMI(IrqMgr* this) {
|
||||
this->resetStatus = STATUS_PRENMI;
|
||||
sIrqMgrResetTime = this->resetTime = osGetTime();
|
||||
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(450000), 0ull, &this->queue, (OSMesg)PRENMI450_MSG);
|
||||
IrqMgr_JamMesgForClient(this, (OSMesg) & this->prenmiMsg);
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(450000), 0ull, &this->queue, OS_MESG_32(PRENMI450_MSG));
|
||||
IrqMgr_JamMesgForClient(this, OS_MESG_PTR(&this->prenmiMsg));
|
||||
}
|
||||
|
||||
void IrqMgr_CheckStack() {
|
||||
@ -131,19 +131,19 @@ void IrqMgr_HandlePRENMI450(IrqMgr* this) {
|
||||
gIrqMgrResetStatus = temp;
|
||||
this->resetStatus = STATUS_NMI;
|
||||
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(30000), 0ull, &this->queue, (OSMesg)PRENMI480_MSG);
|
||||
IrqMgr_SendMesgForClient(this, (OSMesg) & this->nmiMsg);
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(30000), 0ull, &this->queue, OS_MESG_32(PRENMI480_MSG));
|
||||
IrqMgr_SendMesgForClient(this, OS_MESG_PTR(&this->nmiMsg));
|
||||
}
|
||||
|
||||
void IrqMgr_HandlePRENMI480(IrqMgr* this) {
|
||||
u32 ret;
|
||||
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(20000), 0ull, &this->queue, (OSMesg)PRENMI500_MSG);
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(20000), 0ull, &this->queue, OS_MESG_32(PRENMI500_MSG));
|
||||
ret = osAfterPreNMI();
|
||||
if (ret) {
|
||||
// "osAfterPreNMI returned %d !?"
|
||||
osSyncPrintf("osAfterPreNMIが %d を返しました!?\n", ret);
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(1000), 0ull, &this->queue, (OSMesg)PRENMI480_MSG);
|
||||
osSetTimer(&this->timer, OS_USEC_TO_CYCLES(1000), 0ull, &this->queue, OS_MESG_32(PRENMI480_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ void IrqMgr_HandleRetrace(IrqMgr* this) {
|
||||
}
|
||||
}
|
||||
sIrqMgrRetraceCount++;
|
||||
IrqMgr_SendMesgForClient(this, (OSMesg) & this->retraceMsg);
|
||||
IrqMgr_SendMesgForClient(this, OS_MESG_PTR(&this->retraceMsg));
|
||||
}
|
||||
|
||||
void IrqMgr_ThreadEntry(void* arg0) {
|
||||
@ -168,13 +168,13 @@ void IrqMgr_ThreadEntry(void* arg0) {
|
||||
IrqMgr* this = (IrqMgr*)arg0;
|
||||
u8 exit;
|
||||
|
||||
msg = 0;
|
||||
msg.data32 = 0;
|
||||
osSyncPrintf("IRQマネージャスレッド実行開始\n"); // "Start IRQ manager thread execution"
|
||||
exit = false;
|
||||
|
||||
while (!exit) {
|
||||
osRecvMesg(&this->queue, &msg, OS_MESG_BLOCK);
|
||||
switch ((u32)msg) {
|
||||
switch (msg.data32) {
|
||||
case RETRACE_MSG:
|
||||
IrqMgr_HandleRetrace(this);
|
||||
break;
|
||||
@ -225,8 +225,8 @@ void IrqMgr_Init(IrqMgr* this, void* stack, OSPri pri, u8 retraceCount) {
|
||||
this->resetTime = 0;
|
||||
|
||||
osCreateMesgQueue(&this->queue, this->msgBuf, ARRAY_COUNT(this->msgBuf));
|
||||
osSetEventMesg(OS_EVENT_PRENMI, &this->queue, (OSMesg)PRE_NMI_MSG);
|
||||
osViSetEvent(&this->queue, (OSMesg)RETRACE_MSG, retraceCount);
|
||||
osSetEventMesg(OS_EVENT_PRENMI, &this->queue, OS_MESG_32(PRE_NMI_MSG));
|
||||
osViSetEvent(&this->queue, OS_MESG_32(RETRACE_MSG), retraceCount);
|
||||
osCreateThread(&this->thread, 0x13, IrqMgr_ThreadEntry, this, stack, pri);
|
||||
osStartThread(&this->thread);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void Main(void* arg) {
|
||||
R_ENABLE_ARENA_DBG = 0;
|
||||
|
||||
osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, 1);
|
||||
osSetEventMesg(5, &sSiIntMsgQ, 0);
|
||||
osSetEventMesg(5, &sSiIntMsgQ, OS_MESG_PTR(NULL));
|
||||
|
||||
Main_LogSystemHeap();
|
||||
|
||||
@ -118,7 +118,7 @@ void Main(void* arg) {
|
||||
|
||||
while (true) {
|
||||
msg = NULL;
|
||||
osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&irqMgrMsgQ, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
if (msg == NULL) {
|
||||
break;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padMgr) {
|
||||
padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, &ctrlrQ);
|
||||
}
|
||||
|
||||
osRecvMesg(&padMgr->serialMsgQ, (OSMesg)&ctrlrQ, OS_MESG_BLOCK);
|
||||
osRecvMesg(&padMgr->serialMsgQ, (OSMesg*)&ctrlrQ, OS_MESG_BLOCK);
|
||||
|
||||
if (D_8012D280 > 2) {
|
||||
// "serialMsgQ Locked"
|
||||
@ -38,7 +38,7 @@ void PadMgr_UnlockSerialMesgQueue(PadMgr* padMgr, OSMesgQueue* ctrlrQ) {
|
||||
padMgr->serialMsgQ.validCount, padMgr, &padMgr->serialMsgQ, ctrlrQ);
|
||||
}
|
||||
|
||||
osSendMesg(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&padMgr->serialMsgQ, ctrlrQ, OS_MESG_BLOCK);
|
||||
|
||||
if (D_8012D280 > 2) {
|
||||
// "serialMsgQ Unlocked"
|
||||
@ -52,7 +52,7 @@ void PadMgr_LockPadData(PadMgr* padMgr) {
|
||||
}
|
||||
|
||||
void PadMgr_UnlockPadData(PadMgr* padMgr) {
|
||||
osSendMesg(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&padMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void PadMgr_RumbleControl(PadMgr* padMgr) {
|
||||
@ -399,7 +399,7 @@ void PadMgr_ThreadEntry(PadMgr* padMgr) {
|
||||
osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
|
||||
}
|
||||
|
||||
osRecvMesg(&padMgr->interruptMsgQ, (OSMesg)&mesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&padMgr->interruptMsgQ, (OSMesg*)&mesg, OS_MESG_BLOCK);
|
||||
//LogUtils_CheckNullPointer("msg", mesg, "../padmgr.c", 563);
|
||||
|
||||
PadMgr_HandleRetraceMsg(padMgr);
|
||||
|
@ -84,12 +84,12 @@ void Sched_HandleReset(SchedContext* sc) {
|
||||
if (sc->curRSPTask != NULL) {
|
||||
LOG_TIME("(((u64)(now - graph_rsp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))",
|
||||
OS_CYCLES_TO_USEC(now - sRSPGFXStartTime), "../sched.c", 427);
|
||||
osSendMesg(&sc->interruptQ, RSP_DONE_MSG, OS_MESG_NOBLOCK);
|
||||
osSendMesg32(&sc->interruptQ, RSP_DONE_MSG, OS_MESG_NOBLOCK);
|
||||
}
|
||||
if (sc->curRDPTask != NULL) {
|
||||
LOG_TIME("(((u64)(now - rdp_start_time)*(1000000LL/15625LL))/((62500000LL*3/4)/15625LL))",
|
||||
OS_CYCLES_TO_USEC(now - sRDPStartTime), "../sched.c", 431);
|
||||
osSendMesg(&sc->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK);
|
||||
osSendMesg32(&sc->interruptQ, RDP_DONE_MSG, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,10 +294,10 @@ void Sched_HandleEntry(SchedContext* sc) {
|
||||
OSScTask* nextRSP = NULL;
|
||||
OSScTask* nextRDP = NULL;
|
||||
s32 state;
|
||||
OSMesg msg = NULL;
|
||||
OSMesg msg = OS_MESG_PTR(NULL);
|
||||
|
||||
while (osRecvMesg(&sc->cmdQ, &msg, OS_MESG_NOBLOCK) != -1) {
|
||||
Sched_QueueTask(sc, msg);
|
||||
Sched_QueueTask(sc, msg.ptr);
|
||||
}
|
||||
|
||||
if (sc->doAudio != 0 && sc->curRSPTask != NULL) {
|
||||
@ -427,14 +427,14 @@ void Sched_SendEntryMsg(SchedContext* sc) {
|
||||
osSyncPrintf("osScKickEntryMsg\n");
|
||||
}
|
||||
|
||||
osSendMesg(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK);
|
||||
osSendMesg32(&sc->interruptQ, ENTRY_MSG, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void Sched_ThreadEntry(void* arg) {
|
||||
void* msg;
|
||||
OSMesg msg;
|
||||
SchedContext* sc = (SchedContext*)arg;
|
||||
|
||||
msg = NULL;
|
||||
msg.ptr = NULL;
|
||||
|
||||
while (true) {
|
||||
if (sLogScheduler) {
|
||||
@ -444,7 +444,7 @@ void Sched_ThreadEntry(void* arg) {
|
||||
|
||||
osRecvMesg(&sc->interruptQ, &msg, OS_MESG_BLOCK);
|
||||
|
||||
switch ((s32)msg) {
|
||||
switch (msg.data32) {
|
||||
case ENTRY_MSG:
|
||||
if (sLogScheduler) {
|
||||
osSyncPrintf("%08d:ENTRY_MSG\n", (u32)OS_CYCLES_TO_USEC(osGetTime()));
|
||||
@ -466,7 +466,7 @@ void Sched_ThreadEntry(void* arg) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (((OSScMsg*)msg)->type) {
|
||||
switch (((OSScMsg*)msg.ptr)->type) {
|
||||
case 1:
|
||||
Sched_HandleRetrace(sc);
|
||||
continue;
|
||||
@ -485,8 +485,8 @@ void Sched_Init(SchedContext* sc, void* stack, OSPri priority, UNK_TYPE arg3, UN
|
||||
sc->unk_24C = 1;
|
||||
osCreateMesgQueue(&sc->interruptQ, sc->intBuf, 8);
|
||||
osCreateMesgQueue(&sc->cmdQ, sc->cmdMsgBuf, 8);
|
||||
osSetEventMesg(OS_EVENT_SP, &sc->interruptQ, RSP_DONE_MSG);
|
||||
osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, RDP_DONE_MSG);
|
||||
osSetEventMesg(OS_EVENT_SP, &sc->interruptQ, OS_MESG_32(RSP_DONE_MSG));
|
||||
osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, OS_MESG_32(RDP_DONE_MSG));
|
||||
IrqMgr_AddClient(irqMgr, &sc->irqClient, &sc->interruptQ);
|
||||
osCreateThread(&sc->thread, 5, Sched_ThreadEntry, sc, stack, priority);
|
||||
osStartThread(&sc->thread);
|
||||
|
@ -6,7 +6,7 @@ void Sleep_Cycles(OSTime cycles) {
|
||||
OSTimer timer;
|
||||
|
||||
osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK);
|
||||
osSetTimer(&timer, cycles, 0, &mq, NULL);
|
||||
osSetTimer(&timer, cycles, 0, &mq, OS_MESG_PTR(NULL));
|
||||
osRecvMesg(&mq, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
|
@ -162,9 +162,9 @@ void HealthMeter_Init(GlobalContext* globalCtx) {
|
||||
sHeartsDDPrim[0][1] = sHeartsDDPrim[1][1] = HeartDDOutline[1];
|
||||
sHeartsDDPrim[0][2] = sHeartsDDPrim[1][2] = HeartDDOutline[2];
|
||||
|
||||
sHeartsDDPrim[2][0] = HeartInner[0];
|
||||
sHeartsDDPrim[2][1] = HeartInner[1];
|
||||
sHeartsDDPrim[2][2] = HeartInner[2];
|
||||
// sHeartsDDPrim[2][0] = HeartInner[0];
|
||||
// sHeartsDDPrim[2][1] = HeartInner[1];
|
||||
// sHeartsDDPrim[2][2] = HeartInner[2];
|
||||
|
||||
sHeartsDDEnv[0][0] = sHeartsDDEnv[1][0] = HeartDDInner[0];
|
||||
sHeartsDDEnv[0][1] = sHeartsDDEnv[1][1] = HeartDDInner[1];
|
||||
@ -306,9 +306,9 @@ void HealthMeter_Update(GlobalContext* globalCtx) {
|
||||
sBeatingHeartsDDEnv[1] = (u8)(gFactor + HeartDDInner[1]) & 0xFF;
|
||||
sBeatingHeartsDDEnv[2] = (u8)(bFactor + HeartDDInner[2]) & 0xFF;
|
||||
} else {
|
||||
sHeartsDDPrim[2][0] = HEARTS_PRIM_R;
|
||||
sHeartsDDPrim[2][1] = HEARTS_PRIM_G;
|
||||
sHeartsDDPrim[2][2] = HEARTS_PRIM_B;
|
||||
// sHeartsDDPrim[2][0] = HEARTS_PRIM_R;
|
||||
// sHeartsDDPrim[2][1] = HEARTS_PRIM_G;
|
||||
// sHeartsDDPrim[2][2] = HEARTS_PRIM_B;
|
||||
|
||||
sHeartsDDPrim[1][0] = HEARTS_DD_PRIM_R;
|
||||
sHeartsDDPrim[1][1] = HEARTS_DD_PRIM_G;
|
||||
|
@ -10,11 +10,11 @@ void MsgEvent_SendNullTask(void) {
|
||||
task.next = NULL;
|
||||
task.flags = OS_SC_RCP_MASK;
|
||||
task.msgQ = &queue;
|
||||
task.msg = NULL;
|
||||
task.msg.ptr = NULL;
|
||||
task.framebuffer = NULL;
|
||||
task.list.t.type = M_NULTASK;
|
||||
osCreateMesgQueue(task.msgQ, &msg, 1);
|
||||
osSendMesg(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK);
|
||||
osSendMesgPtr(&gSchedContext.cmdQ, &task, OS_MESG_BLOCK);
|
||||
Sched_SendEntryMsg(&gSchedContext);
|
||||
osRecvMesg(&queue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
@ -1317,7 +1317,7 @@ void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) {
|
||||
osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK);
|
||||
DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000,
|
||||
(uintptr_t)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000),
|
||||
0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1171);
|
||||
0x1000, 0, &interfaceCtx->loadQueue, OS_MESG_PTR(NULL), "../z_parameter.c", 1171);
|
||||
osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
@ -1327,7 +1327,7 @@ void Interface_LoadItemIcon2(GlobalContext* globalCtx, u16 button) {
|
||||
osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK);
|
||||
DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000,
|
||||
(uintptr_t)_icon_item_staticSegmentRomStart + (gSaveContext.equips.buttonItems[button] * 0x1000),
|
||||
0x1000, 0, &interfaceCtx->loadQueue, NULL, "../z_parameter.c", 1193);
|
||||
0x1000, 0, &interfaceCtx->loadQueue, OS_MESG_PTR(NULL), "../z_parameter.c", 1193);
|
||||
osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) {
|
||||
|
||||
osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1);
|
||||
DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, globalCtx->roomList[roomNum].vromStart, size, 0,
|
||||
&roomCtx->loadQueue, NULL, "../z_room.c", 1036);
|
||||
&roomCtx->loadQueue, OS_MESG_PTR(NULL), "../z_room.c", 1036);
|
||||
roomCtx->unk_30 ^= 1;
|
||||
|
||||
return 1;
|
||||
|
@ -4855,7 +4855,7 @@ void func_8083AE40(Player* this, s16 objectId) {
|
||||
ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091);
|
||||
|
||||
DmaMgr_SendRequest2(&this->giObjectDmaRequest, (uintptr_t)this->giObjectSegment, gObjectTable[objectId].vromStart,
|
||||
size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099);
|
||||
size, 0, &this->giObjectLoadQueue, OS_MESG_PTR(NULL), "../z_player.c", 9099);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user