2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-11 00:04:41 +00:00
|
|
|
void func_800C3C80(AudioMgr* audioMgr) {
|
2021-07-27 23:44:58 +00:00
|
|
|
AudioTask* task;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
task = audioMgr->rspTask;
|
|
|
|
if (audioMgr->rspTask->taskQueue != NULL) {
|
|
|
|
osSendMesg(task->taskQueue, NULL, OS_MESG_BLOCK);
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-11 00:04:41 +00:00
|
|
|
void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
2021-07-27 23:44:58 +00:00
|
|
|
AudioTask* rspTask;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-11 00:04:41 +00:00
|
|
|
if (SREG(20) > 0) {
|
2021-07-27 23:44:58 +00:00
|
|
|
audioMgr->rspTask = NULL;
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
2021-07-27 23:44:58 +00:00
|
|
|
if (audioMgr->rspTask != NULL) {
|
|
|
|
audioMgr->audioTask.next = NULL;
|
|
|
|
audioMgr->audioTask.flags = 2;
|
|
|
|
audioMgr->audioTask.framebuffer = NULL;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
audioMgr->audioTask.list = audioMgr->rspTask->task;
|
|
|
|
audioMgr->audioTask.msgQ = &audioMgr->unk_AC;
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
audioMgr->audioTask.msg = NULL;
|
|
|
|
osSendMesg(&audioMgr->sched->cmdQ, &audioMgr->audioTask, OS_MESG_BLOCK);
|
2020-05-26 15:39:27 +00:00
|
|
|
Sched_SendEntryMsg(audioMgr->sched);
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
2021-02-14 00:49:40 +00:00
|
|
|
|
2020-05-11 00:04:41 +00:00
|
|
|
D_8016A550 = osGetTime();
|
|
|
|
if (SREG(20) >= 2) {
|
2021-07-27 23:44:58 +00:00
|
|
|
rspTask = NULL;
|
2020-05-11 00:04:41 +00:00
|
|
|
} else {
|
2021-07-27 23:44:58 +00:00
|
|
|
rspTask = func_800E4FE0();
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
|
|
|
D_8016A558 += osGetTime() - D_8016A550;
|
|
|
|
D_8016A550 = 0;
|
2021-07-27 23:44:58 +00:00
|
|
|
if (audioMgr->rspTask != NULL) {
|
2020-05-11 00:04:41 +00:00
|
|
|
osRecvMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK);
|
|
|
|
func_800C3C80(audioMgr);
|
|
|
|
}
|
2021-07-27 23:44:58 +00:00
|
|
|
audioMgr->rspTask = rspTask;
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2020-05-11 00:04:41 +00:00
|
|
|
void AudioMgr_HandlePRENMI(AudioMgr* audioMgr) {
|
2021-09-04 13:33:19 +00:00
|
|
|
// "Audio manager received OS_SC_PRE_NMI_MSG"
|
2020-05-11 00:04:41 +00:00
|
|
|
osSyncPrintf("オーディオマネージャが OS_SC_PRE_NMI_MSG を受け取りました\n");
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_PreNMI();
|
2020-05-11 00:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioMgr_ThreadEntry(void* arg0) {
|
2021-02-14 00:49:40 +00:00
|
|
|
AudioMgr* audioMgr = (AudioMgr*)arg0;
|
2020-05-11 00:04:41 +00:00
|
|
|
IrqMgrClient irqClient;
|
2021-02-14 00:49:40 +00:00
|
|
|
s16* msg = NULL;
|
2020-05-11 00:04:41 +00:00
|
|
|
|
2021-09-04 13:33:19 +00:00
|
|
|
osSyncPrintf("オーディオマネージャスレッド実行開始\n"); // "Start running audio manager thread"
|
2021-11-07 16:58:50 +00:00
|
|
|
Audio_Init();
|
|
|
|
AudioLoad_SetDmaHandler(DmaMgr_DmaHandler);
|
|
|
|
Audio_InitSound();
|
2020-05-11 00:04:41 +00:00
|
|
|
osSendMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK);
|
|
|
|
IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
osRecvMesg(&audioMgr->unk_74, (OSMesg*)&msg, OS_MESG_BLOCK);
|
|
|
|
switch (*msg) {
|
|
|
|
case OS_SC_RETRACE_MSG:
|
|
|
|
AudioMgr_HandleRetrace(audioMgr);
|
|
|
|
while (audioMgr->unk_74.validCount != 0) {
|
|
|
|
osRecvMesg(&audioMgr->unk_74, (OSMesg*)&msg, OS_MESG_BLOCK);
|
|
|
|
switch (*msg) {
|
|
|
|
case OS_SC_RETRACE_MSG:
|
|
|
|
break;
|
|
|
|
case OS_SC_PRE_NMI_MSG:
|
|
|
|
AudioMgr_HandlePRENMI(audioMgr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OS_SC_PRE_NMI_MSG:
|
|
|
|
AudioMgr_HandlePRENMI(audioMgr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioMgr_Unlock(AudioMgr* audioMgr) {
|
|
|
|
osRecvMesg(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK);
|
|
|
|
}
|
|
|
|
|
2020-10-03 15:22:44 +00:00
|
|
|
void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr) {
|
2020-05-11 00:04:41 +00:00
|
|
|
bzero(audioMgr, sizeof(AudioMgr));
|
|
|
|
|
|
|
|
audioMgr->sched = sched;
|
|
|
|
audioMgr->irqMgr = irqMgr;
|
2021-07-27 23:44:58 +00:00
|
|
|
audioMgr->rspTask = NULL;
|
2020-05-11 00:04:41 +00:00
|
|
|
|
|
|
|
osCreateMesgQueue(&audioMgr->unk_AC, &audioMgr->unk_C4, 1);
|
|
|
|
osCreateMesgQueue(&audioMgr->unk_74, &audioMgr->unk_8C, 8);
|
|
|
|
osCreateMesgQueue(&audioMgr->unk_C8, &audioMgr->unk_E0, 1);
|
|
|
|
|
|
|
|
osSendMesg(&audioMgr->unk_AC, NULL, OS_MESG_BLOCK);
|
|
|
|
|
|
|
|
osCreateThread(&audioMgr->unk_E8, id, AudioMgr_ThreadEntry, audioMgr, stack, pri);
|
|
|
|
osStartThread(&audioMgr->unk_E8);
|
|
|
|
}
|