Actor Docs (#270)

* Docs

* actor timer_04C -> work_04C

* Actor & Boss unk_04A -> work_04A

* actor & boss unk_048 -> work_048

* actor & boss unk_046 -> work_046

* boss unk_044 -> work_044

* actor event docs

* ActorEvent docs

* name all Event Actor IDs

* EVID names in EventActorInfo comments

* refactor EVC_PASSED_ALL_RINGS by @inspectredc

* clarification comment

* some option docs

* audio enums and macros

* some audio renamings
This commit is contained in:
Alejandro Asenjo Nitti
2024-08-24 19:36:53 -03:00
committed by GitHub
parent 669fff8759
commit e82019fa2b
95 changed files with 2126 additions and 1960 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, u32 size) {
u32 aligned = ALIGN16(size);
u8* ramAddr = pool->curRamAddr;
if (pool->startRamAddr + pool->size >= pool->curRamAddr + aligned) {
if ((pool->startRamAddr + pool->size) >= (pool->curRamAddr + aligned)) {
pool->curRamAddr += aligned;
} else {
return NULL;
+29 -17
View File
@@ -214,6 +214,7 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) {
gSampleDmaReuseQueue2WrPos = gSampleDmaCount - gSampleDmaListSize1;
}
// Updates the audiotable entries with their absolute ROM addresses
void AudioLoad_InitTable(AudioTable* table, u8* romAddr, u16 unkMediumParam) {
s32 i;
@@ -259,7 +260,7 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 flags) {
s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) {
u8* sampleAddr;
if ((sample->isRelocated == 1) && (sample->medium != 0)) {
if ((sample->isRelocated == true) && (sample->medium != MEDIUM_RAM)) {
sampleAddr = AudioHeap_AllocPersistentSampleCache(sample->size, fontId, sample->sampleAddr, sample->medium);
if (sampleAddr == NULL) {
return -1;
@@ -486,6 +487,7 @@ void* AudioLoad_SyncLoadFont(s32 fontId) {
if (didAllocate == 1) {
AudioLoad_RelocateFontAndPreloadSamples(fontId, fontData, &relocInfo, AUDIOLOAD_SYNC);
}
return fontData;
}
@@ -649,13 +651,14 @@ void AudioLoad_RelocateFont(s32 fontId, u32 fontBaseAddr, void* relocData) {
}
}
}
for (i = 1; i <= numInstruments; i++) {
if (fontDataPtrs[i] != 0) {
fontDataPtrs[i] += fontBaseAddr;
instrument = fontDataPtrs[i];
if (instrument->isRelocated == 0) {
if (!instrument->isRelocated) {
if (instrument->normalRangeLo != 0) {
AudioLoad_RelocateSample(&instrument->lowPitchTunedSample, fontBaseAddr, relocData);
}
@@ -669,6 +672,7 @@ void AudioLoad_RelocateFont(s32 fontId, u32 fontBaseAddr, void* relocData) {
}
}
}
gSoundFontList[fontId].drums = fontDataPtrs[0];
gSoundFontList[fontId].instruments = (u32) &fontDataPtrs[1];
}
@@ -723,7 +727,7 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void
return 0;
}
if (size & 0xF) {
if (size % 16) {
size = ALIGN16(size);
}
@@ -763,19 +767,19 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
switch (tableType) {
case SEQUENCE_TABLE:
if (gSeqLoadStatus[id] == 1) {
if (gSeqLoadStatus[id] == LOAD_STATUS_IN_PROGRESS) {
return NULL;
}
break;
case FONT_TABLE:
if (gFontLoadStatus[id] == 1) {
if (gFontLoadStatus[id] == LOAD_STATUS_IN_PROGRESS) {
return NULL;
}
break;
case SAMPLE_TABLE:
if (gSampleFontLoadStatus[id] == 1) {
if (gSampleFontLoadStatus[id] == LOAD_STATUS_IN_PROGRESS) {
return NULL;
}
break;
@@ -783,7 +787,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
ramAddr = AudioLoad_SearchCaches(tableType, id);
if (ramAddr != NULL) {
loadStatus = 2;
loadStatus = LOAD_STATUS_COMPLETE;
osSendMesg(retQueue, (OSMesg) (retData << 0x18), OS_MESG_NOBLOCK);
} else {
table = AudioLoad_GetLoadTable(tableType);
@@ -792,7 +796,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
medium = table->entries[id].medium;
cachePolicy = table->entries[id].cachePolicy;
romAddr = table->entries[id].romAddr;
loadStatus = 2;
loadStatus = LOAD_STATUS_COMPLETE;
switch (cachePolicy) {
case CACHEPOLICY_0:
@@ -800,7 +804,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
if (ramAddr == NULL) {
return ramAddr;
}
loadStatus = 5;
loadStatus = LOAD_STATUS_PERMANENTLY_LOADED;
break;
case CACHEPOLICY_1:
@@ -827,7 +831,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
}
AudioLoad_StartAsyncLoad(romAddr, ramAddr, size, medium, nChunks, retQueue,
(retData << 0x18) | (tableType << 0x10) | (id << 8) | loadStatus);
loadStatus = 1;
loadStatus = LOAD_STATUS_IN_PROGRESS;
}
switch (tableType) {
@@ -892,21 +896,22 @@ void AudioLoad_Init(void) {
*clearContext++ = 0;
}
// 1000 is a conversion from seconds to milliseconds
switch (osTvType) {
case OS_TV_PAL:
gMaxTempoTvTypeFactors = 20.03042f;
gRefreshRate = 50;
gMaxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_PAL / REFRESH_RATE_PAL;
gRefreshRate = REFRESH_RATE_PAL;
break;
case OS_TV_MPAL:
gMaxTempoTvTypeFactors = 16.546f;
gRefreshRate = 60;
gMaxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_MPAL / REFRESH_RATE_MPAL;
gRefreshRate = REFRESH_RATE_MPAL;
break;
default:
case OS_TV_NTSC:
gMaxTempoTvTypeFactors = 16.713f;
gRefreshRate = 60;
default:
gMaxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_NTSC / REFRESH_RATE_NTSC;
gRefreshRate = REFRESH_RATE_NTSC;
break;
}
@@ -940,6 +945,7 @@ void AudioLoad_Init(void) {
gAiBuffers[i][j] = 0;
}
}
gAudioSpecId = AUDIOSPEC_0;
gAudioResetStep = 1;
AudioHeap_ResetStep();
@@ -977,6 +983,7 @@ void AudioLoad_Init(void) {
static const char devstr38[] = "Entry--- %d %d\n";
static const char devstr39[] = "---Block LPS here\n";
static const char devstr40[] = "===Block LPS end\n";
s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
Sample* sample;
AudioSlowLoad* slowLoad;
@@ -995,10 +1002,13 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
if (slowLoad->state == SLOW_LOAD_DONE) {
slowLoad->state = SLOW_LOAD_WAITING;
}
slowLoad->sample = *sample;
slowLoad->status = status;
slowLoad->curRamAddr =
AudioHeap_AllocTemporarySampleCache(sample->size, fontId, sample->sampleAddr, sample->medium);
if (slowLoad->curRamAddr == NULL) {
if ((sample->medium == MEDIUM_UNK) || (sample->codec == 2)) {
*status = SLOW_LOAD_STATUS_0;
@@ -1008,6 +1018,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
return -1;
}
}
slowLoad->state = SLOW_LOAD_START;
slowLoad->bytesRemaining = ALIGN16(sample->size);
slowLoad->ramAddr = slowLoad->curRamAddr;
@@ -1016,6 +1027,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
slowLoad->seqOrFontId = fontId;
slowLoad->instId = instId;
gSlowLoads.unk_00 ^= 1;
return 0;
}
+3
View File
@@ -1399,11 +1399,14 @@ void func_800168BC(void) {
gSeqChannels[i].layers[j] = NULL;
}
}
func_8001463C();
for (i = 0; i < ARRAY_COUNT(gSeqLayers); i++) {
gSeqLayers[i].channel = NULL;
gSeqLayers[i].enabled = false;
}
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
for (j = 0; j < 16; j++) {
gSeqPlayers[i].channels[j] = &gSeqChannelNone;
+59 -34
View File
@@ -513,7 +513,7 @@ void func_80009504(s16* arg0, UnkStruct_800097A8* arg1) {
func_80008364(D_80145D48, D_80146148, 8, D_80146548);
for (i = 0; i < 0x100; i++) {
for (i = 0; i < 256; i++) {
if (D_80145D48[i] > 32767.0f) {
D_80145D48[i] = 32767.0f;
}
@@ -537,6 +537,7 @@ s32 func_8000967C(s32 length, s16* ramAddr, UnkStruct_800097A8* arg2) {
for (i = 0; i < arg2->unk_4; i++) {
ramAddr[i] = temp_t7[i];
}
var_s1 = arg2->unk_4;
temp_t0 = (length - arg2->unk_4 + 0xFF) / 256;
arg2->unk_4 = (temp_t0 * 256) + arg2->unk_4 - length;
@@ -545,6 +546,7 @@ s32 func_8000967C(s32 length, s16* ramAddr, UnkStruct_800097A8* arg2) {
func_80009504(&ramAddr[var_s1], arg2);
var_s1 += 0x100;
}
for (i = 0; i < arg2->unk_4; i++) {
temp_t7[i] = ramAddr[length + i];
}
@@ -568,10 +570,13 @@ u8* func_800097A8(Sample* sample, s32 length, u32 flags, UnkStruct_800097A8* arg
arg3->unk_14->sizeUnused = 0;
}
}
if (gSampleDmaReuseQueue1RdPos != gSampleDmaReuseQueue1WrPos) {
sp1C = &gSampleDmas[gSampleDmaReuseQueue1[gSampleDmaReuseQueue1RdPos++]];
}
if (1) {}
if (1) {} //! FAKE
sp1C->ttl = 2;
sp1C->devAddr = sample->sampleAddr;
sp1C->sizeUnused = length * 2;
@@ -635,6 +640,7 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
func_8001678C(i - 1);
func_80009AAC(gAudioBufferParams.ticksPerUpdate - i);
}
aiBufPtr = (s32*) aiBufStart;
for (i = gAudioBufferParams.ticksPerUpdate; i > 0; i--) {
if (i == 1) {
@@ -646,22 +652,27 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
} else {
chunkLen = gAudioBufferParams.samplesPerTick;
}
for (j = 0; j < gNumSynthReverbs; j++) {
if (gSynthReverbs[j].useReverb) {
func_800080C0(chunkLen, gAudioBufferParams.ticksPerUpdate - i, j);
}
}
aCmdPtr = func_8000A25C((s16*) aiBufPtr, chunkLen, aCmdPtr, gAudioBufferParams.ticksPerUpdate - i);
aiBufLen -= chunkLen;
aiBufPtr += chunkLen;
}
for (j = 0; j < gNumSynthReverbs; j++) {
if (gSynthReverbs[j].framesToIgnore != 0) {
gSynthReverbs[j].framesToIgnore--;
}
gSynthReverbs[j].curFrame ^= 1;
}
*cmdCount = aCmdPtr - aList;
return aCmdPtr;
}
@@ -715,6 +726,7 @@ Acmd* func_8000A128(Acmd* aList, s16 reverbIndex, s16 updateIndex) {
aList = func_80009984(aList, sp24->lengthA + 0xC90, 0, sp24->lengthB, reverbIndex);
}
break;
default:
aSaveBuffer(aList++, 0xC90,
OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex]
@@ -724,6 +736,7 @@ Acmd* func_8000A128(Acmd* aList, s16 reverbIndex, s16 updateIndex) {
gSynthReverbs[reverbIndex].resampleFlags = 0;
break;
}
return aList;
}
@@ -731,61 +744,66 @@ Acmd* func_8000A25C(s16* aiBuf, s32 aiBufLen, Acmd* aList, s32 updateIndex) {
u8 sp84[0x3C];
NoteSubEu* temp_v0;
s16 var_s2;
s16 var_s3;
s32 var_s1;
s16 i;
s32 j;
var_s2 = 0;
if (gNumSynthReverbs == 0) {
if (gSynthReverbs[var_s3].useReverb) {} // fake?
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
if (gNoteSubsEu[gNumNotes * updateIndex + var_s1].bitField0.enabled) {
sp84[var_s2++] = var_s1;
if (gSynthReverbs[i].useReverb) {} // fake?
for (j = 0; j < gNumNotes; j++) {
if (gNoteSubsEu[gNumNotes * updateIndex + j].bitField0.enabled) {
sp84[var_s2++] = j;
}
}
} else {
for (var_s3 = 0; var_s3 < gNumSynthReverbs; var_s3++) {
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + var_s1];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex == var_s3)) {
sp84[var_s2++] = var_s1;
for (i = 0; i < gNumSynthReverbs; i++) {
for (j = 0; j < gNumNotes; j++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + j];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex == i)) {
sp84[var_s2++] = j;
}
}
}
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + var_s1];
for (j = 0; j < gNumNotes; j++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + j];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex >= gNumSynthReverbs)) {
sp84[var_s2++] = var_s1;
sp84[var_s2++] = j;
}
}
}
aClearBuffer(aList++, 0x990, 0x300);
var_s1 = 0;
for (var_s3 = 0; var_s3 < gNumSynthReverbs; var_s3++) {
D_8014C1B2 = gSynthReverbs[var_s3].useReverb;
j = 0;
for (i = 0; i < gNumSynthReverbs; i++) {
D_8014C1B2 = gSynthReverbs[i].useReverb;
if (D_8014C1B2) {
aList = func_80009D78(aList, aiBufLen, var_s3, updateIndex);
aList = func_80009D78(aList, aiBufLen, i, updateIndex);
}
while (var_s1 < var_s2) {
if (var_s3 != gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]].bitField1.reverbIndex) {
while (j < var_s2) {
if (i != gNoteSubsEu[updateIndex * gNumNotes + sp84[j]].bitField1.reverbIndex) {
break;
}
aList = func_8000A700(sp84[var_s1], &gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]],
&gNotes[sp84[var_s1]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
var_s1++;
aList = func_8000A700(sp84[j], &gNoteSubsEu[updateIndex * gNumNotes + sp84[j]],
&gNotes[sp84[j]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
j++;
}
if (gSynthReverbs[var_s3].useReverb) {
aList = func_8000A128(aList, var_s3, updateIndex);
if (gSynthReverbs[i].useReverb) {
aList = func_8000A128(aList, i, updateIndex);
}
}
while (var_s1 < var_s2) {
aList = func_8000A700(sp84[var_s1], &gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]],
&gNotes[sp84[var_s1]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
var_s1++;
while (j < var_s2) {
aList = func_8000A700(sp84[j], &gNoteSubsEu[updateIndex * gNumNotes + sp84[j]], &gNotes[sp84[j]].synthesisState,
aiBuf, aiBufLen, aList, updateIndex);
j++;
}
var_s1 = aiBufLen * 2;
aSetBuffer(aList++, 0, 0, 0x450, var_s1);
j = aiBufLen * 2;
aSetBuffer(aList++, 0, 0, 0x450, j);
aInterleave(aList++, 0, 0x990, 0xB10, 0);
aSaveBuffer(aList++, 0x450, OS_K0_TO_PHYSICAL(aiBuf), var_s1 * 2);
aSaveBuffer(aList++, 0x450, OS_K0_TO_PHYSICAL(aiBuf), j * 2);
return aList;
}
@@ -1209,8 +1227,10 @@ Acmd* func_8000B51C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
} else {
var_a2 = 0;
}
synthState->curVolLeft = temp_t1 + (var_t0 * (aiBufLen >> 3));
synthState->curVolRight = temp_t2 + (var_a3 * (aiBufLen >> 3));
if (noteSub->bitField0.usesHeadsetPanEffects) {
aClearBuffer(aList++, 0x650, 0x180);
aEnvSetup1(aList++, (temp_a1 & 0x7F), var_a2, var_t0, var_a3);
@@ -1255,6 +1275,7 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
var_v1 = synthState->prevHaasEffectLeftDelaySize;
synthState->prevHaasEffectLeftDelaySize = var_a1;
break;
case 2:
var_t0 = 0xB10;
var_a1 = noteSub->rightDelaySize;
@@ -1262,9 +1283,11 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
var_v1 = synthState->prevHaasEffectRightDelaySize;
synthState->prevHaasEffectRightDelaySize = var_a1;
break;
default:
return aList;
}
if (flags != 1) {
if (var_a1 != var_v1) {
temp = (((size << 0xF) / 2) - 1) / ((size + var_a1 - var_v1 - 2) / 2);
@@ -1289,6 +1312,8 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
aSaveBuffer(aList++, size + 0x650, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers->panSamplesBuffer),
ALIGN16(var_a1));
}
aAddMixer(aList++, ALIGN64(size), 0x650, var_t0, 0x7FFF);
return aList;
}
+10 -1
View File
@@ -57,26 +57,33 @@ SPTask* AudioThread_CreateTask(void) {
if ((gAudioTaskCountQ % gAudioBufferParams.count) != 0) {
return gWaitingAudioTask;
}
osSendMesg(gAudioTaskStartQueue, (OSMesg) gAudioTaskCountQ, OS_MESG_NOBLOCK);
gAudioTaskIndexQ ^= 1;
gCurAiBuffIndex++;
gCurAiBuffIndex %= 3;
aiBuffIndex = (gCurAiBuffIndex + 1) % 3;
aiSamplesLeft = osAiGetLength() / 4;
if ((gAudioResetTimer < 16) && (gAiBuffLengths[aiBuffIndex] != 0)) {
osAiSetNextBuffer(gAiBuffers[aiBuffIndex], gAiBuffLengths[aiBuffIndex] * 4);
}
if (gCurAudioFrameDmaCount && gCurAudioFrameDmaCount) {}
if (gCurAudioFrameDmaCount && gCurAudioFrameDmaCount) {} //! FAKE ?
gCurAudioFrameDmaCount = 0;
AudioLoad_DecreaseSampleDmaTtls();
AudioLoad_ProcessLoads(gAudioResetStep);
if (MQ_GET_MESG(gAudioSpecQueue, &specId)) {
if (gAudioResetStep == 0) {
gAudioResetStep = 5;
}
gAudioSpecId = specId;
}
if ((gAudioResetStep != 0) && (AudioHeap_ResetStep() == 0)) {
if (gAudioResetStep == 0) {
osSendMesg(gAudioResetQueue, (OSMesg) (s32) gAudioSpecId, OS_MESG_NOBLOCK);
@@ -84,12 +91,14 @@ SPTask* AudioThread_CreateTask(void) {
gWaitingAudioTask = NULL;
return NULL;
}
if (gAudioResetTimer > 16) {
return NULL;
}
if (gAudioResetTimer != 0) {
gAudioResetTimer++;
}
gAudioCurTask = &gAudioRspTasks[gAudioTaskIndexQ];
gCurAbiCmdBuffer = gAbiCmdBuffs[gAudioTaskIndexQ];
aiBuffIndex = gCurAiBuffIndex;