summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorzelda2774 <69368340+zelda2774@users.noreply.github.com>2021-08-12 21:37:37 +0200
committerGitHub <noreply@github.com>2021-08-12 15:37:37 -0400
commita0d2cceeca7e655010b0ec0589c09803104e8192 (patch)
tree4174eb8bf1d9c12b7010f1d2de1eb9cb3831b920 /src/code
parent1b1487a50466340c8b75ec21a31d4ce71055f034 (diff)
Match some audio functions (#896)
* cleanups * Improve Audio_SequencePlayerProcessSequence * cleanup * labeling * progress on func_800E5000 * func_800F6268 * func_800ECDF8 * Improve func_800F2464 * reorder variables * labelling * non-equivalent func_800EEA50 * minor doc * func_800E6590 * minor doc * Reformat abi.h * Very slight improvements * func_800DC384 * func_800E1618 * formatting Co-authored-by: zelda2774 <zelda2774@invalid>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/audio_heap.c8
-rw-r--r--src/code/audio_load.c46
-rw-r--r--src/code/audio_seqplayer.c14
-rw-r--r--src/code/audio_synthesis.c50
-rw-r--r--src/code/code_800E4FE0.c252
-rw-r--r--src/code/code_800EC960.c1109
-rw-r--r--src/code/code_800F7260.c29
-rw-r--r--src/code/code_800F9280.c1
8 files changed, 1062 insertions, 447 deletions
diff --git a/src/code/audio_heap.c b/src/code/audio_heap.c
index 2c83fd511..70bb62805 100644
--- a/src/code/audio_heap.c
+++ b/src/code/audio_heap.c
@@ -45,8 +45,8 @@ void Audio_ResetLoadStatus(void) {
}
for (i = 0; i < 0x80; i++) {
- if (gAudioContext.seqLoadstatus[i] != 5) {
- gAudioContext.seqLoadstatus[i] = 0;
+ if (gAudioContext.seqLoadStatus[i] != 5) {
+ gAudioContext.seqLoadStatus[i] = 0;
}
}
}
@@ -207,7 +207,7 @@ void func_800DE4B0(s32 poolIdx) {
switch (poolIdx) {
case 0:
loadedPool = &gAudioContext.seqLoadedPool;
- table = gAudioContext.seqLoadstatus;
+ table = gAudioContext.seqLoadStatus;
break;
case 1:
loadedPool = &gAudioContext.bankLoadedPool;
@@ -304,7 +304,7 @@ void* Audio_AllocBankOrSeq(s32 poolIdx, s32 size, s32 arg2, s32 id) {
switch (poolIdx) {
case 0:
loadedPool = &gAudioContext.seqLoadedPool;
- table = gAudioContext.seqLoadstatus;
+ table = gAudioContext.seqLoadStatus;
break;
case 1:
loadedPool = &gAudioContext.bankLoadedPool;
diff --git a/src/code/audio_load.c b/src/code/audio_load.c
index 3d6da12c9..a5e2b83a7 100644
--- a/src/code/audio_load.c
+++ b/src/code/audio_load.c
@@ -74,19 +74,19 @@ void func_800E11F0(void) {
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_800E12DC.s")
-#ifdef NON_MATCHING
void func_800E1618(s32 arg0) {
SampleDmaReq* temp_s0;
s32 i;
s32 t2;
+ s32 j;
gAudioContext.unk_288C = gAudioContext.unk_2874;
gAudioContext.sampleDmaReqs =
Audio_Alloc(&gAudioContext.notesAndBuffersPool,
- (gAudioContext.maxSimultaneousNotes * 0x40) * gAudioContext.audioBufferParameters.presetUnk4);
- t2 = gAudioContext.maxSimultaneousNotes * 3 * gAudioContext.audioBufferParameters.presetUnk4;
+ 4 * gAudioContext.maxSimultaneousNotes * sizeof(SampleDmaReq) * gAudioContext.audioBufferParameters.presetUnk4);
+ t2 = 3 * gAudioContext.maxSimultaneousNotes * gAudioContext.audioBufferParameters.presetUnk4;
for (i = 0; i < t2; i++) {
- SampleDmaReq* temp_s0 = &gAudioContext.sampleDmaReqs[gAudioContext.sampleDmaReqCnt];
+ temp_s0 = &gAudioContext.sampleDmaReqs[gAudioContext.sampleDmaReqCnt];
temp_s0->ramAddr = func_800DE2B0(&gAudioContext.notesAndBuffersPool, gAudioContext.unk_288C);
if (temp_s0->ramAddr == NULL) {
break;
@@ -115,8 +115,8 @@ void func_800E1618(s32 arg0) {
gAudioContext.unk_2624 = gAudioContext.sampleDmaReqCnt;
gAudioContext.unk_288C = gAudioContext.unk_2878;
- for (i = 0; i < gAudioContext.maxSimultaneousNotes; i++) {
- SampleDmaReq* temp_s0 = &gAudioContext.sampleDmaReqs[gAudioContext.sampleDmaReqCnt];
+ for (j = 0; j < gAudioContext.maxSimultaneousNotes; j++) {
+ temp_s0 = &gAudioContext.sampleDmaReqs[gAudioContext.sampleDmaReqCnt];
temp_s0->ramAddr = func_800DE2B0(&gAudioContext.notesAndBuffersPool, gAudioContext.unk_288C);
if (temp_s0->ramAddr == NULL) {
break;
@@ -132,9 +132,8 @@ void func_800E1618(s32 arg0) {
}
for (i = gAudioContext.unk_2624; i < gAudioContext.sampleDmaReqCnt; i++) {
- SampleDmaReq* temp_s0 = &gAudioContext.sampleDmaReqs[i + gAudioContext.unk_2624];
- gAudioContext.unk_272C[i - gAudioContext.unk_2624] = gAudioContext.unk_2624;
- temp_s0->unk_0D = i - gAudioContext.unk_2624;
+ gAudioContext.unk_272C[i - gAudioContext.unk_2624] = i;
+ gAudioContext.sampleDmaReqs[i].unk_0D = i - gAudioContext.unk_2624;
}
for (i = gAudioContext.sampleDmaReqCnt; i < 0x100; i++) {
@@ -144,9 +143,6 @@ void func_800E1618(s32 arg0) {
gAudioContext.unk_282D = 0;
gAudioContext.unk_282F = gAudioContext.sampleDmaReqCnt - gAudioContext.unk_2624;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_800E1618.s")
-#endif
s32 Audio_IsBankLoadComplete(s32 bankId) {
if (bankId == 0xFF) {
@@ -162,10 +158,10 @@ s32 Audio_IsBankLoadComplete(s32 bankId) {
s32 Audio_IsSeqLoadComplete(s32 seqId) {
if (seqId == 0xFF) {
- return 1;
- } else if (gAudioContext.seqLoadstatus[seqId] >= 2) {
- return 1;
- } else if (gAudioContext.seqLoadstatus[Audio_GetTableIndex(SEQUENCE_TABLE, seqId)] >= 2) {
+ return true;
+ } else if (gAudioContext.seqLoadStatus[seqId] >= 2) {
+ return true;
+ } else if (gAudioContext.seqLoadStatus[Audio_GetTableIndex(SEQUENCE_TABLE, seqId)] >= 2) {
return true;
} else {
return false;
@@ -191,8 +187,8 @@ void Audio_SetBankLoadStatus(s32 bankId, s32 status) {
}
void Audio_SetSeqLoadStatus(s32 seqId, s32 status) {
- if ((seqId != 0xFF) && (gAudioContext.seqLoadstatus[seqId] != 5)) {
- gAudioContext.seqLoadstatus[seqId] = status;
+ if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != 5)) {
+ gAudioContext.seqLoadStatus[seqId] = status;
}
}
@@ -208,7 +204,7 @@ void func_800E1A78(s32 arg0, s32 arg1) {
}
}
-void Aduio_SetAudtabLoadstatus(s32 tabId, s32 status) {
+void Audio_SetAudtabLoadStatus(s32 tabId, s32 status) {
if ((tabId != 0xFF) && (gAudioContext.audioTableLoadStatus[tabId] != 5)) {
gAudioContext.audioTableLoadStatus[tabId] = status;
}
@@ -451,7 +447,7 @@ u8* func_800E22C4(s32 seqId) {
s32 pad;
s32 sp20;
- if (gAudioContext.seqLoadstatus[Audio_GetTableIndex(0, seqId)] == 1) {
+ if (gAudioContext.seqLoadStatus[Audio_GetTableIndex(0, seqId)] == 1) {
return NULL;
}
@@ -472,7 +468,7 @@ u32 func_800E2338(u32 arg0, u32* arg1, s32 arg2) {
audioTable = Audio_GetLoadTable(2);
if (temp_v0 = func_800E27A4(2, temp_s0), temp_v0 != NULL) {
if (gAudioContext.audioTableLoadStatus[temp_s0] != 1) {
- Aduio_SetAudtabLoadstatus(temp_s0, 2);
+ Audio_SetAudtabLoadStatus(temp_s0, 2);
}
*arg1 = 0;
return temp_v0;
@@ -829,7 +825,7 @@ void* Audio_AsyncLoadInner(s32 tableType, s32 arg1, s32 arg2, s32 arg3, OSMesgQu
sp34 = Audio_GetTableIndex(tableType, arg1);
switch (tableType) {
case SEQUENCE_TABLE:
- if (gAudioContext.seqLoadstatus[sp34] == 1) {
+ if (gAudioContext.seqLoadStatus[sp34] == 1) {
return NULL;
}
break;
@@ -991,9 +987,9 @@ void Audio_ContextInit(void* heap, u32 heapSize) {
gAudioContext.rspTask[0].task.t.data_size = 0;
gAudioContext.rspTask[1].task.t.data_size = 0;
osCreateMesgQueue(&gAudioContext.unk_25E8, &gAudioContext.unk_2600, 1);
- osCreateMesgQueue(&gAudioContext.unk_1ED0, &gAudioContext.unk_1EE8, 0x40);
- osCreateMesgQueue(&gAudioContext.unk_1E20, &gAudioContext.unk_1E38, 0x10);
- osCreateMesgQueue(&gAudioContext.unk_1E78, &gAudioContext.unk_1E90, 0x10);
+ osCreateMesgQueue(&gAudioContext.unk_1ED0, gAudioContext.unk_1EE8, 0x40);
+ osCreateMesgQueue(&gAudioContext.unk_1E20, gAudioContext.unk_1E38, 0x10);
+ osCreateMesgQueue(&gAudioContext.unk_1E78, gAudioContext.unk_1E90, 0x10);
gAudioContext.sampleIoReqIdx = 0;
gAudioContext.sampleDmaReqCnt = 0;
gAudioContext.cartHandle = osCartRomInit();
diff --git a/src/code/audio_seqplayer.c b/src/code/audio_seqplayer.c
index 7f86f0bc1..2c48d9b1a 100644
--- a/src/code/audio_seqplayer.c
+++ b/src/code/audio_seqplayer.c
@@ -121,7 +121,7 @@ void Audio_SequenceChannelInit(SequenceChannel* seqChannel) {
seqChannel->largeNotes = false;
seqChannel->bookOffset = 0;
seqChannel->reverbBits.asByte = 0;
- seqChannel->changes.asByte = 0xff;
+ seqChannel->changes.asByte = 0xFF;
seqChannel->scriptState.depth = 0;
seqChannel->newPan = 0x40;
seqChannel->panChannelWeight = 0x80;
@@ -135,7 +135,7 @@ void Audio_SequenceChannelInit(SequenceChannel* seqChannel) {
seqChannel->someOtherPriority = 1;
seqChannel->delay = 0;
seqChannel->adsr.envelope = gDefaultEnvelope;
- seqChannel->adsr.releaseRate = 0xf0;
+ seqChannel->adsr.releaseRate = 0xF0;
seqChannel->adsr.sustain = 0;
seqChannel->vibratoRateTarget = 0x800;
seqChannel->vibratoRateStart = 0x800;
@@ -200,7 +200,7 @@ s32 Audio_SeqChannelSetLayer(SequenceChannel* seqChannel, s32 layerIdx) {
layer->freqScale = 1.0f;
layer->unk_34 = 1.0f;
layer->velocitySquare2 = 0.0f;
- layer->instOrWave = 0xff;
+ layer->instOrWave = 0xFF;
return 0;
}
@@ -287,7 +287,7 @@ void Audio_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer) {
}
void Audio_SequencePlayerDisable(SequencePlayer* seqPlayer) {
- Audio_SequencePlayerDisableChannels(seqPlayer, 0xffff);
+ Audio_SequencePlayerDisableChannels(seqPlayer, 0xFFFF);
Audio_NotePoolClear(&seqPlayer->notePool);
if (!seqPlayer->enabled) {
return;
@@ -363,7 +363,7 @@ s16 Audio_M64ReadS16(M64ScriptState* state) {
u16 Audio_M64ReadCompressedU16(M64ScriptState* state) {
u16 ret = *(state->pc++);
if (ret & 0x80) {
- ret = (ret << 8) & 0x7f00;
+ ret = (ret << 8) & 0x7F00;
ret = *(state->pc++) | ret;
}
return ret;
@@ -1640,9 +1640,9 @@ void Audio_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
case 0xCE:
command = Audio_M64ReadU8(seqScript);
if (command == 0) {
- seqScript->value = gAudioContext.audioRandom / 4;
+ seqScript->value = (gAudioContext.audioRandom >> 2) & 0xFF;
} else {
- seqScript->value = (gAudioContext.audioRandom / 4) % command;
+ seqScript->value = (gAudioContext.audioRandom >> 2) % command;
}
break;
case 0xCD: {
diff --git a/src/code/audio_synthesis.c b/src/code/audio_synthesis.c
index 3a183f480..8e07ef0d8 100644
--- a/src/code/audio_synthesis.c
+++ b/src/code/audio_synthesis.c
@@ -12,6 +12,8 @@ Acmd* func_800DDB64(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthSt
Acmd* func_800DD6CC(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 aiBufLen, u16, s32, s32);
Acmd* func_800DD62C(Acmd* cmd, NoteSynthesisState* synthState, s32 count, u16 pitch, u16 inpDmem, s32 resampleFlags);
extern s16 D_8012FBAA[];
+
+// 4 nops, part of ucode_disas?
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/pad_800DACB0.s")
void AudioSynth_InitNextRingBuf(s32 chunkSize, s32 bufIdx, s32 reverbIdx) {
@@ -512,29 +514,26 @@ Acmd* func_800DC2DC(Acmd* cmd, SynthesisReverb* reverb, s16 bufIdx) {
return cmd;
}
-#ifdef NON_MATCHING
Acmd* func_800DC384(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updateIdx) {
- NoteSubEu* phi_v0;
- u8 sp9C[88];
+ u8 sp9C[0x5C];
s16 phi_s2;
s16 phi_s4;
- s32 t;
- s32 useReverb;
SynthesisReverb* temp_t8;
- u8 t2;
+ s32 useReverb;
+ s32 t;
s32 i;
+ NoteSubEu* phi_v0;
+ NoteSubEu* phi_v0_2;
s32 unk14;
t = gAudioContext.maxSimultaneousNotes * updateIdx;
phi_s2 = 0;
if (gAudioContext.numSynthesisReverbs == 0) {
for (i = 0; i < gAudioContext.maxSimultaneousNotes; i++) {
- phi_v0 = &gAudioContext.noteSubsEu[t + i];
- if (phi_v0->bitField0.s.enabled) {
+ if (gAudioContext.noteSubsEu[t + i].bitField0.s.enabled) {
sp9C[phi_s2++] = i;
}
}
- i = 0;
} else {
for (phi_s4 = 0; phi_s4 < gAudioContext.numSynthesisReverbs; phi_s4++) {
for (i = 0; i < gAudioContext.maxSimultaneousNotes; i++) {
@@ -551,10 +550,10 @@ Acmd* func_800DC384(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updateIdx) {
sp9C[phi_s2++] = i;
}
}
- i = 0;
}
aClearBuffer(cmd++, 0x940, 0x340);
+ i = 0;
for (phi_s4 = 0; phi_s4 < gAudioContext.numSynthesisReverbs; phi_s4++) {
temp_t8 = &gAudioContext.synthesisReverbs[phi_s4];
useReverb = temp_t8->useReverb;
@@ -582,10 +581,10 @@ Acmd* func_800DC384(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updateIdx) {
}
while (i < phi_s2) {
- phi_v0 = &gAudioContext.noteSubsEu[sp9C[i] + t];
- if (phi_v0->bitField1.s.reverbIndex == phi_s4) {
- cmd = func_800DC910(sp9C[i], phi_v0, &gAudioContext.notes[sp9C[i]].synthesisState, aiBuf, aiBufLen, cmd,
- updateIdx);
+ phi_v0_2 = &gAudioContext.noteSubsEu[sp9C[i] + t];
+ if (phi_v0_2->bitField1.s.reverbIndex == phi_s4) {
+ cmd = func_800DC910(sp9C[i], phi_v0_2, &gAudioContext.notes[sp9C[i]].synthesisState, aiBuf, aiBufLen,
+ cmd, updateIdx);
} else {
break;
}
@@ -619,9 +618,6 @@ Acmd* func_800DC384(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updateIdx) {
return cmd;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_800DC384.s")
-#endif
#ifdef NON_EQUIVALENT
Acmd* func_800DC910(s32 noteIdx, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s16* aiBuf, s32 aiBufLen,
@@ -1151,18 +1147,18 @@ Acmd* func_800DDB64(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthSt
switch (arg5) {
case 1:
+ phi_t0 = 0x940;
phi_v1 = noteSubEu->headsetPanRight;
phi_v0 = synthState->prevHeadsetPanRight;
synthState->prevHeadsetPanLeft = 0;
- synthState->prevHeadsetPanRight = noteSubEu->headsetPanRight;
- phi_t0 = 0x940;
+ synthState->prevHeadsetPanRight = phi_v1;
break;
case 2:
+ phi_t0 = 0xAE0;
phi_v1 = noteSubEu->headsetPanLeft;
phi_v0 = synthState->prevHeadsetPanLeft;
- synthState->prevHeadsetPanLeft = noteSubEu->headsetPanLeft;
+ synthState->prevHeadsetPanLeft = phi_v1;
synthState->prevHeadsetPanRight = 0;
- phi_t0 = 0xAE0;
break;
default:
return cmd;
@@ -1170,26 +1166,26 @@ Acmd* func_800DDB64(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthSt
if (arg4 != 1) {
if (phi_v0 != phi_v1) {
- aSetBuffer(cmd++, 0, 0x5C0, 0x3C0, (arg3 + phi_v1) - phi_v0);
- aResampleZOH(cmd++, (u16)((((arg3 << 0xF) / 2) - 1) / ((((arg3 + phi_v1) - phi_v0) - 2) / 2)), 0);
+ aSetBuffer(cmd++, 0, 0x5C0, 0x3C0, arg3 + phi_v1 - phi_v0);
+ aResampleZOH(cmd++, (u16)((((arg3 << 0xF) / 2) - 1) / ((arg3 + phi_v1 - phi_v0 - 2) / 2)), 0);
} else {
aDMEMMove(cmd++, 0x5C0, 0x3C0, arg3);
}
if (phi_v0 != 0) {
aLoadBuffer(cmd++, &synthState->synthesisBuffers->panResampleState[0x8], 0x5C0, ALIGN16(phi_v0));
- aDMEMMove(cmd++, 0x3C0, phi_v0 + 0x5C0, (arg3 + phi_v1) - phi_v0);
+ aDMEMMove(cmd++, 0x3C0, 0x5C0 + phi_v0, arg3 + phi_v1 - phi_v0);
} else {
- aDMEMMove(cmd++, 0x3C0, 0x5C0, (arg3 + phi_v1));
+ aDMEMMove(cmd++, 0x3C0, 0x5C0, arg3 + phi_v1);
}
} else {
aDMEMMove(cmd++, 0x5C0, 0x3C0, arg3);
aClearBuffer(cmd++, 0x5C0, phi_v1);
- aDMEMMove(cmd++, 0x3C0, phi_v1 + 0x5C0, arg3);
+ aDMEMMove(cmd++, 0x3C0, 0x5C0 + phi_v1, arg3);
}
if (phi_v1 != 0) {
- aSaveBuffer(cmd++, arg3 + 0x5C0, &synthState->synthesisBuffers->panResampleState[0x8], ALIGN16(phi_v1));
+ aSaveBuffer(cmd++, 0x5C0 + arg3, &synthState->synthesisBuffers->panResampleState[0x8], ALIGN16(phi_v1));
}
aAddMixer(cmd++, ((arg3 + 0x3F) & ~0x3F), 0x5C0, phi_t0, 0x7FFF);
return cmd;
diff --git a/src/code/code_800E4FE0.c b/src/code/code_800E4FE0.c
index cd5382e6c..494c6e5b5 100644
--- a/src/code/code_800E4FE0.c
+++ b/src/code/code_800E4FE0.c
@@ -1,5 +1,8 @@
#include "global.h"
+#define SAMPLES_TO_OVERPRODUCE 0x10
+#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x80
+
typedef enum {
CHAN_UPD_UNK_0, // 0
CHAN_UPD_VOL_SCALE, // 1
@@ -32,90 +35,50 @@ AudioTask* func_800E4FE0(void) {
return func_800E5000();
}
-u32 D_801304E0 = 0x80;
-AudioTask* D_801304E4 = NULL;
+extern u64 rspAspMainDataStart[];
+extern u64 rspAspMainDataEnd[];
-extern u8 D_80155C70[];
-#ifdef NON_EQUIVALENT
-// haven't verified Equivalency yet.
+#ifdef NON_MATCHING
AudioTask* func_800E5000(void) {
- u32 sp6C;
+ static s32 sMaxAbiCmdCnt = 0x80;
+ static AudioTask* sWaitingAudioTask = NULL;
+ u32 samplesRemainingInAi;
s32 abiCmdCnt;
+ s32 pad;
+ s32 j;
s32 sp5C;
- s16* sp58;
+ s16* currAiBuffer; // sp58
+ OSTask_t* task;
+ s32 index;
u32 sp4C;
s32 sp48;
- void* sp3C;
- void* sp34;
- OSTask_t* temp_v1_10;
- OSMesgQueue* temp_s1;
- s16 temp_a0_2;
- s16 temp_v0_2;
- s16 temp_v1;
- s16 temp_v1_2;
- s16 temp_v1_9;
- s32 temp_a0;
- s32 temp_a3;
- s32 temp_a3_2;
- s32 temp_hi;
- s32 temp_s0;
- s32 temp_s0_2;
- s32 temp_s0_3;
- s32 temp_s0_4;
- s32 temp_s0_5;
- s32 temp_t4;
- s32 temp_t6;
- s32 temp_t7;
- s32 temp_v1_6;
- s32 temp_v1_7;
- s32 temp_v1_8;
- u32 temp_t3;
- u32 temp_t4_2;
- void* temp_t0;
- void* temp_v1_3;
- void* temp_v1_4;
- void* temp_v1_5;
- s16 phi_v1;
- s32 phi_a0;
- void* phi_v1_2;
- s32 phi_s0;
- s32 phi_v1_3;
- void* phi_v1_4;
- s32 phi_s0_2;
- s32 phi_v1_5;
- s32 phi_s0_3;
- s32 phi_s0_4;
- void* phi_v1_6;
- s32 phi_s0_5;
s32 i;
gAudioContext.totalTaskCnt++;
if (gAudioContext.totalTaskCnt % (gAudioContext.audioBufferParameters.presetUnk4) != 0) {
- if (D_801755D0 != 0) {
+ if (D_801755D0 != NULL) {
D_801755D0();
}
- if (gAudioContext.audioBufferParameters.presetUnk4 ==
- ((gAudioContext.totalTaskCnt % (gAudioContext.audioBufferParameters.presetUnk4)) + 1)) {
- return D_801304E4;
+ if ((gAudioContext.totalTaskCnt % gAudioContext.audioBufferParameters.presetUnk4) + 1 ==
+ gAudioContext.audioBufferParameters.presetUnk4) {
+ return sWaitingAudioTask;
} else {
return NULL;
}
}
- osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, 0);
- temp_t4 = gAudioContext.curAIBufIdx + 1;
- temp_t6 = (gAudioContext.curAIBufIdx + 1) % 3;
+ osSendMesg(gAudioContext.taskStartQueueP, gAudioContext.totalTaskCnt, OS_MESG_NOBLOCK);
gAudioContext.rspTaskIdx ^= 1;
gAudioContext.curAIBufIdx++;
gAudioContext.curAIBufIdx %= 3;
- temp_hi = (gAudioContext.curAIBufIdx - 2 + 3) % 3;
- sp6C = osAiGetLength() / 4;
+ index = (gAudioContext.curAIBufIdx - 2 + 3) % 3;
+ samplesRemainingInAi = osAiGetLength() / 4;
+
if (gAudioContext.resetTimer < 16) {
- if (gAudioContext.aiBufLengths[temp_hi] != 0) {
- sp34 = &gAudioContext + (temp_hi * 4);
- sp3C = &gAudioContext + (temp_hi * 2);
- osAiSetNextBuffer(gAudioContext.aiBuffers[temp_hi], gAudioContext.aiBufLengths[temp_hi] * 4);
+ if (gAudioContext.aiBufLengths[index] != 0) {
+ // &gAudioContext + index*{2,4} should be saved across here
+ osAiSetNextBuffer(gAudioContext.aiBuffers[index], gAudioContext.aiBufLengths[index] * 4);
}
}
@@ -125,105 +88,124 @@ AudioTask* func_800E5000(void) {
sp5C = gAudioContext.sampleIoReqIdx;
for (i = 0; i < gAudioContext.sampleIoReqIdx; i++) {
- if (osRecvMesg(&gAudioContext.unk_1ED0, NULL, 0) == 0) {
+ if (osRecvMesg(&gAudioContext.unk_1ED0, NULL, OS_MESG_NOBLOCK) == 0) {
sp5C--;
}
}
if (sp5C != 0) {
for (i = 0; i < sp5C; i++) {
- osRecvMesg(&gAudioContext.unk_1ED0, NULL, 1);
+ osRecvMesg(&gAudioContext.unk_1ED0, NULL, OS_MESG_BLOCK);
}
}
sp48 = gAudioContext.unk_1ED0.validCount;
- if (gAudioContext.unk_1ED0.validCount != 0) {
+ if (sp48 != 0) {
for (i = 0; i < sp48; i++) {
- osRecvMesg(&gAudioContext.unk_1ED0, NULL, 0);
+ osRecvMesg(&gAudioContext.unk_1ED0, NULL, OS_MESG_NOBLOCK);
}
}
+
gAudioContext.sampleIoReqIdx = 0;
func_800E11F0();
Audio_ProcessLoads(gAudioContext.resetStatus);
func_800E4F58();
- if ((gAudioContext.resetStatus != 0) && (Audio_ResetStep() == 0)) {
- if (gAudioContext.resetStatus == 0) {
- osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetPresetIdToLoad, 0);
- }
- D_801304E4 = NULL;
- return NULL;
+ if (gAudioContext.resetStatus != 0) {
+ if (Audio_ResetStep() == 0) {
+ if (gAudioContext.resetStatus == 0) {
+ osSendMesg(gAudioContext.audioResetQueueP, gAudioContext.audioResetPresetIdToLoad, OS_MESG_NOBLOCK);
+ }
+
+ sWaitingAudioTask = NULL;
+ return NULL;
+ }
}
if (gAudioContext.resetTimer > 16) {
return NULL;
- } else if (gAudioContext.resetTimer != 0) {
+ }
+ if (gAudioContext.resetTimer != 0) {
gAudioContext.resetTimer++;
}
gAudioContext.currTask = &gAudioContext.rspTask[gAudioContext.rspTaskIdx];
gAudioContext.curAbiCmdBuf = gAudioContext.abiCmdBufs[gAudioContext.rspTaskIdx];
- gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx] =
- (s16)((((gAudioContext.audioBufferParameters.samplesPerFrameTarget - sp6C) + 0x80) & 0xFFF0) + 0x10);
- if (gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx] < gAudioContext.audioBufferParameters.minAiBufferLength) {
- gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx] = gAudioContext.audioBufferParameters.minAiBufferLength;
+
+ index = gAudioContext.curAIBufIdx;
+ currAiBuffer = gAudioContext.aiBuffers[index];
+
+ gAudioContext.aiBufLengths[index] =
+ (s16)((((gAudioContext.audioBufferParameters.samplesPerFrameTarget - samplesRemainingInAi) +
+ EXTRA_BUFFERED_AI_SAMPLES_TARGET) &
+ ~0xF) +
+ SAMPLES_TO_OVERPRODUCE);
+ if (gAudioContext.aiBufLengths[index] < gAudioContext.audioBufferParameters.minAiBufferLength) {
+ gAudioContext.aiBufLengths[index] = gAudioContext.audioBufferParameters.minAiBufferLength;
}
- if (gAudioContext.audioBufferParameters.maxAiBufferLength < gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx]) {
- gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx] = gAudioContext.audioBufferParameters.maxAiBufferLength;
+ if (gAudioContext.aiBufLengths[index] > gAudioContext.audioBufferParameters.maxAiBufferLength) {
+ gAudioContext.aiBufLengths[index] = gAudioContext.audioBufferParameters.maxAiBufferLength;
}
+ j = 0;
if (gAudioContext.resetStatus == 0) {
- i = 0;
// msg = 0000RREE R = read pos, E = End Pos
- while (osRecvMesg(gAudioContext.cmdProcQueueP, &sp4C, 0) != -1) {
+ while (osRecvMesg(gAudioContext.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
+ if (1) {}
+ if (1) {}
+ if (1) {}
Audio_ProcessCmds(sp4C);
- i++;
+ j++;
}
- if ((i == 0) && (gAudioContext.cmdQueueFinished)) {
+ if ((j == 0) && (gAudioContext.cmdQueueFinished)) {
Audio_ScheduleProcessCmds();
}
}
gAudioContext.curAbiCmdBuf =
- AudioSynth_Update(gAudioContext.curAbiCmdBuf, &abiCmdCnt, gAudioContext.aiBuffers[gAudioContext.curAIBufIdx],
- gAudioContext.aiBufLengths[gAudioContext.curAIBufIdx]);
- gAudioContext.audioRandom = osGetCount() * (gAudioContext.audioRandom + gAudioContext.totalTaskCnt);
- gAudioContext.audioRandom = gAudioContext.aiBuffers[gAudioContext.curAIBufIdx][gAudioContext.totalTaskCnt & 0xFF] +
- gAudioContext.audioRandom;
- ;
- gWaveSamples[8] = (s16*)((((u8*)func_800E4FE0)) + (gAudioContext.audioRandom & 0xFFF0));
+ AudioSynth_Update(gAudioContext.curAbiCmdBuf, &abiCmdCnt, currAiBuffer, gAudioContext.aiBufLengths[index]);
+ gAudioContext.audioRandom = (gAudioContext.audioRandom + gAudioContext.totalTaskCnt) * osGetCount();
+ gAudioContext.audioRandom =
+ gAudioContext.aiBuffers[index][gAudioContext.totalTaskCnt & 0xFF] + gAudioContext.audioRandom;
+ gWaveSamples[8] = (s16*)(((u8*)func_800E4FE0) + (gAudioContext.audioRandom & 0xFFF0));
+
+ index = gAudioContext.rspTaskIdx;
gAudioContext.currTask->taskQueue = NULL;
gAudioContext.currTask->unk_44 = NULL;
- temp_v1_10 = &gAudioContext.currTask->task.t;
- temp_v1_10->type = 2U;
- temp_v1_10->flags = 0U;
- temp_v1_10->ucode_boot = D_801120C0;
- temp_v1_10->ucode_boot_size = 0x1000;
- temp_v1_10->ucode_data_size = (((s32)(D_80155F50 - D_80155C70) >> 3) * 8) - 1;
- temp_v1_10->ucode = D_801120C0;
- temp_v1_10->ucode_data = D_80155C70;
- temp_v1_10->ucode_size = 0x1000;
- temp_v1_10->dram_stack = NULL;
- temp_v1_10->dram_stack_size = 0;
- temp_v1_10->output_buff = NULL;
- temp_v1_10->output_buff_size = NULL;
- temp_v1_10->data_ptr = gAudioContext.abiCmdBufs[gAudioContext.rspTaskIdx];
- temp_v1_10->yield_data_ptr = NULL;
- temp_v1_10->yield_data_size = 0;
- temp_v1_10->data_size = abiCmdCnt * sizeof(ACmd);
-
- if (D_801304E0 < abiCmdCnt) {
- D_801304E0 = abiCmdCnt;
+
+ task = &gAudioContext.currTask->task.t;
+ task->type = M_AUDTASK;
+ task->flags = 0;
+ task->ucode_boot = D_801120C0;
+ task->ucode_boot_size = 0x1000;
+ task->ucode_data_size = ((rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64)) - 1;
+ task->ucode = D_801120C0;
+ task->ucode_data = rspAspMainDataStart;
+ task->ucode_size = 0x1000;
+ task->dram_stack = NULL;
+ task->dram_stack_size = 0;
+ task->output_buff = NULL;
+ task->output_buff_size = NULL;
+ task->data_ptr = (u64*)gAudioContext.abiCmdBufs[index];
+ task->data_size = abiCmdCnt * sizeof(Acmd);
+ task->yield_data_ptr = NULL;
+ task->yield_data_size = 0;
+
+ if (sMaxAbiCmdCnt < abiCmdCnt) {
+ sMaxAbiCmdCnt = abiCmdCnt;
}
if (gAudioContext.audioBufferParameters.presetUnk4 == 1) {
return gAudioContext.currTask;
+ } else {
+ sWaitingAudioTask = gAudioContext.currTask;
+ return NULL;
}
- D_801304E4 = gAudioContext.currTask;
- return NULL;
}
#else
+s32 sMaxAbiCmdCnt = 0x80;
+AudioTask* sWaitingAudioTask = NULL;
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E4FE0/func_800E5000.s")
#endif
@@ -271,7 +253,7 @@ void func_800E5584(AudioCmd* cmd) {
if (cmd->asUInt == 1) {
for (i = 0; i < gAudioContext.maxSimultaneousNotes; i++) {
Note* note = &gAudioContext.notes[i];
- NoteSubEu* subEu = &note->noteSubEu.bitField0;
+ NoteSubEu* subEu = &note->noteSubEu;
if (subEu->bitField0.s.enabled && note->playbackState.unk_04 == 0) {
if (note->playbackState.parentLayer->seqChannel->muteBehavior & 8) {
subEu->bitField0.s.finished = 1;
@@ -310,7 +292,7 @@ void func_800E5584(AudioCmd* cmd) {
gAudioContext.audioResetPresetIdToLoad = cmd->asUInt;
return;
case 0xFB:
- D_801755D0 = cmd->asUInt;
+ D_801755D0 = (void (*)(void))cmd->asUInt;
return;
case 0xE0:
case 0xE1:
@@ -503,7 +485,7 @@ void Audio_ProcessCmds(u32 msg) {
u32 func_800E5E20(u32* arg0) {
u32 sp1C;
- if (osRecvMesg(&gAudioContext.unk_1E20, &sp1C, 0) == -1) {
+ if (osRecvMesg(&gAudioContext.unk_1E20, (OSMesg*)&sp1C, OS_MESG_NOBLOCK) == -1) {
*arg0 = 0;
return 0;
}
@@ -524,7 +506,7 @@ s32 func_800E5EDC(void) {
s32 pad;
s32 sp18;
- if (osRecvMesg(gAudioContext.audioResetQueueP, &sp18, OS_MESG_NOBLOCK) == -1) {
+ if (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp18, OS_MESG_NOBLOCK) == -1) {
return 0;
} else if (gAudioContext.audioResetPresetIdToLoad != sp18) {
return -1;
@@ -536,7 +518,7 @@ s32 func_800E5EDC(void) {
void func_800E5F34(void) {
// macro?
// clang-format off
- s32 chk = -1; s32 sp28; do { } while (osRecvMesg(gAudioContext.audioResetQueueP, &sp28, 0) != chk);
+ s32 chk = -1; s32 sp28; do {} while (osRecvMesg(gAudioContext.audioResetQueueP, (OSMesg*)&sp28, OS_MESG_NOBLOCK) != chk);
// clang-format on
}
@@ -745,47 +727,45 @@ void Audio_WaitForAudioTask(void) {
osRecvMesg(gAudioContext.taskStartQueueP, NULL, OS_MESG_BLOCK);
}
-#ifdef NON_MATCHING
s32 func_800E6590(s32 arg0, s32 arg1, s32 arg2) {
- u32 temp_v1_2;
- AudioBankSound* temp_a0;
- Note* temp_a0_2;
- SequenceChannelLayer* temp_v0;
- SequenceChannel* temp_v1;
SequencePlayer* seqPlayer;
+ SequenceChannelLayer* layer;
+ Note* note;
+ AudioBankSound* sound;
+ s32 loopEnd;
+ s32 samplePos;
seqPlayer = &gAudioContext.seqPlayers[arg0];
if (seqPlayer->enabled && seqPlayer->channels[arg1]->enabled) {
- temp_v0 = seqPlayer->channels[arg1]->layers[arg2];
- if (temp_v0 == NULL) {
+ layer = seqPlayer->channels[arg1]->layers[arg2];
+ if (layer == NULL) {
return 0;
}
- if (temp_v0->enabled) {
- temp_a0_2 = temp_v0->note;
- if (temp_a0_2 == NULL) {
+ if (layer->enabled) {
+ if (layer->note == NULL) {
return 0;
}
- if (!temp_v0->bit3) {
+ if (!layer->bit3) {
return 0;
}
- if (temp_v0 == temp_a0_2->playbackState.parentLayer) {
- temp_a0 = temp_a0_2->noteSubEu.sound.audioBankSound;
- if (temp_a0 == 0) {
+ note = layer->note;
+ if (layer == note->playbackState.parentLayer) {
+ sound = note->noteSubEu.sound.audioBankSound;
+ if (sound == NULL) {
return 0;
}
- return temp_a0->sample->loop->end - temp_a0_2->synthesisState.samplePosInt;
+ loopEnd = sound->sample->loop->end;
+ samplePos = note->synthesisState.samplePosInt;
+ return loopEnd - samplePos;
}
return 0;
}
}
return 0;
}
-#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E4FE0/func_800E6590.s")
-#endif
s32 func_800E6680(void) {
return func_800E66C0(0);
diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c
index c52c87e7d..79fb1479b 100644
--- a/src/code/code_800EC960.c
+++ b/src/code/code_800EC960.c
@@ -18,6 +18,12 @@ typedef struct {
s32 unk_0C;
} unk_s2;
+typedef struct {
+ u16 unk_00;
+ u16 unk_02;
+ u8 unk_04[100];
+} D_801306DC_s; // size = 0x68
+
void Audio_SetVolScale(u8, u8, u8, u8);
void func_800F5550(u16);
void func_800F5E18(u8 arg0, u16 arg1, u8 arg2, s8 arg3, s8 arg4);
@@ -26,80 +32,146 @@ void func_800F56A8(void);
void func_800F6FB4(u8);
s32 func_800F491C(u8 arg0);
+extern f32 D_8012F6B4[]; // from audio_synthesis
+
// stick float vals
-extern f32 D_8012F6B4[];
-extern u32 sOcarinaAllowedBtnMask; // 80130EFC
-extern s32 sOcarinaABtnMap; // 80130F00
-extern s32 sOcarinaCUPBtnMap; // 80130F04
-extern s32 sOcarinaCDownBtnMap; // 80130F08
-extern u8 D_80131F64;
-extern u8 D_80133408;
-extern s8 D_8013060C;
+extern u32 D_801305B0;
+extern u32 D_801305B4;
+extern s8 D_801305B8;
+extern s8 D_801305BC;
+extern s8 D_801305C0;
+extern f32 D_801305C4[2];
+extern u8 D_801305CC;
+extern u8 sPrevChargeLevel; // 801305E0
+extern f32 D_801305E4[4];
+extern f32 D_801305F4;
+extern u8 D_801305F8[8];
+extern u8 D_80130600;
extern s8 D_80130604;
+extern s8 D_80130608;
+extern s8 D_8013060C;
+extern s8 D_80130610;
extern s8 D_80130614;
-extern f32 D_80130620;
-extern s8 D_80130624;
-extern u8 D_80131878;
-extern u32 D_80130F3C;
-extern u8 sCurOcarinaBtnVal; // 80130F14
-extern u8 sPrevOcarinaNoteVal; // 80130F18
-extern u8 sCurOcarinaBtnIdx; // note index?
-extern u8 sLearnSongLastBtn;
-extern u8 sOcarinaInpEnabled; // D_80130F0C
-extern u8 sPlaybackState;
-extern u16 sStaffPlaybackPos;
-extern s8 D_80130F10; // ocarina active?
-extern u8 sNoteValueIndexMap[];
extern s8 D_80130618;
extern u8 D_8013061C;
+extern f32 D_80130620;
+extern s8 D_80130624;
+extern u16 D_80130628;
+extern u8 D_8013062C;
+extern u8 D_80130630;
+extern u32 D_80130634;
+extern u32 D_80130638;
extern u8 D_8013063C;
extern u8 D_80130640;
extern u8 D_80130644;
extern u8 D_80130648;
-extern s8 D_801306C8[];
-extern u8 D_80133414;
-extern s8 D_80130610;
-extern u8 D_80130600;
-extern u8 D_801305F8[];
-extern s8 D_80130608;
-extern u8 D_801305FF;
extern Vec3f* D_8013064C;
-extern u8 D_801305CC;
-extern u8 D_8013062C;
-extern u8 D_80130630;
-extern u8 D_80130658[];
-extern u8 D_80133418;
-extern u16 D_80130628;
-extern s8 D_80130F2C; // pitch?
extern f32 D_80130650;
-extern s8 D_801305B8;
-extern s8 D_801305BC;
-extern s8 D_801305C0;
-extern f32 D_801305E4[];
-extern u8 sPrevChargeLevel;
-extern f32 D_801305F4;
-extern u32 D_801305B0;
-extern u32 D_801305B4;
+extern u8 D_80130654;
+extern u8 D_80130658[]; // <= 112
+extern s8 D_801306C8[20];
+extern D_801306DC_s D_801306DC[20];
+extern u32 sOcarinaAllowedBtnMask; // 80130EFC
+extern s32 sOcarinaABtnMap; // 80130F00
+extern s32 sOcarinaCUPBtnMap; // 80130F04
+extern s32 sOcarinaCDownBtnMap; // 80130F08
+extern u8 sOcarinaInpEnabled; // 80130F0C
+extern s8 D_80130F10; // ocarina active?
+extern u8 sCurOcarinaBtnVal; // 80130F14
+extern u8 sPrevOcarinaNoteVal; // 80130F18
+extern u8 sCurOcarinaBtnIdx; // 80130F1C, note index?
+extern u8 sLearnSongLastBtn; // 80130F20
+extern f32 D_80130F24;
+extern u32 D_80130F28;
+extern s8 D_80130F2C; // pitch?
+extern s8 D_80130F30;
+extern s8 D_80130F34;
+extern u8 sPlaybackState; // 80130F38
+extern u32 D_80130F3C;
+extern u32 sNotePlaybackTimer;
+extern u16 sPlaybackNotePos;
+extern u16 sStaffPlaybackPos;
+extern u16 D_80130F4C;
+extern u8 sDisplayedNoteValue; // Note to display on screen?
+extern u8 sNotePlaybackVolume;
+extern u8 sNotePlaybackVibrato;
+extern s8 sNotePlaybackTone;
+extern f32 sNormalizedNotePlaybackTone;
+extern f32 sNormalizedNotePlaybackVolume;
+extern s32 D_80130F68;
+extern u8 sOcarinaNoteValues[5];
+extern u8 sOcaMinigameApndPos;
+extern u8 sOcaMinigameEndPos;
+extern u8 sOcaMinigameNoteCnts[]; // <= 4
+extern OcarinaSong sOcarinaSongs[14]; // 80130F80
+extern OcarinaSong* sPlaybackSong;
+// extern u8 D_80131844[];
+// extern u8* gFrogsSongPtr = D_80131844;
+extern u8 D_80131858;
+extern u8 sRecordSongPos;
+extern u32 D_80131860;
+extern u8 D_80131864;
+extern u8 D_80131868;
+extern u8 D_8013186C;
+extern s8 D_80131870;
+extern u8 D_80131874;
+extern u8 D_80131878;
+extern u8 D_8013187C;
+extern u8 D_80131880;
+extern OcarinaSong sPierresSong;
+// extern OcarinaNote* gScarecrowCustomSongPtr = &sPierresSong;
+// extern OcarinaNote* gScarecrowSpawnSongPtr = &sOcarinaSongs[12];
+extern OcarinaSong* D_80131BEC; // = &sOcarinaSongs[13];
+extern u8 sNoteValueIndexMap[16]; // = {0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 5, 3, 3, 4, 4, 4}
+// extern OcarinaSongInfo gOcarinaSongNotes[14];
+// D_80131C80 .. 88 are in-function static in func_800EE824
extern f32 D_80131C8C;
+
+extern u8 D_801333F0;
+
+// Debug variables (separate file?):
+extern f32 D_80131C90; // func_800EEA50, in-function static?
+extern f32 D_80131C94; // func_800EEA50, in-function static?
extern u8 D_80131C98;
extern u8 D_80131C9C;
extern u8 D_80131CA0;
+extern u8 D_80131CA4;
extern u8 D_80131CA8;
-extern u16 D_80131E08[];
-extern u8 D_8013340C;
-extern u8 D_80131EEE;
+extern char D_80131CAC[][23];
+extern u16 D_80131E08[11];
+extern u16 D_80131E20[11];
+extern char D_80131E38[7][11]; // func_800EEA50
+extern char D_80131E88[][10]; // func_800EEA50
extern s8 D_80131EBC;
extern s8 D_80131EC0;
extern s8 D_80131EC4;
extern s8 D_80131EC8[];
-extern u16 D_80131E20[];
-extern u8 D_80131CA4;
-extern u8 sOcaMinigameEndPos;
-extern u8 sOcaMinigameApndPos;
-extern u8 sOcaMinigameNoteCnts[];
-extern u16 D_80130F3E;
-extern u8 sOcarinaNoteValues[5];
-extern u8 D_8013170C;
+extern u8 D_80131ED0;
+extern u8 sAudioScreenPrintInd;
+extern u8 sAudioScreenPrintOverflow;
+extern s8 D_80131EDC;
+extern s8 D_80131EE0;
+extern u8 D_80131EE4[11];
+extern u8 D_80131EF0[11];
+extern u8 D_80131EFC;
+extern u8 D_80131F00;
+extern u8 D_80131F04;
+extern u8 D_80131F08;
+extern char D_80131F0C[][5]; // func_800EEA50
+extern u8 D_80131F18;
+extern u8 D_80131F1C;
+extern u16 D_80131F20[];
+extern u8 D_80131F28;
+extern u8 D_80131F2C;
+extern u8 D_80131F30[];
+extern char D_80131F44[][2]; // func_800EEA50
+extern u8 D_80131F4C[];
+extern u8 D_80131F50;
+extern char D_80131F54[][5]; // func_800EEA50
+extern u8 D_80131F64;
+extern u8 D_80131F68;
+// D_80131F6C is in-function static in func_800F510C
+
/** bit field of songs that can be played
* 0x0800 storms
* 0x0400 song of time
@@ -114,44 +186,18 @@ extern u8 D_8013170C;
* 0x0002 bolero
* 0x0001 minuet
*/
-extern u8 D_8013187C;
-extern u16 D_80130F4C;
-extern u8 D_80131880;
-extern u8 D_80131858;
-extern f32 D_80130F24;
-extern s8 D_80130F34;
-extern u32 D_80130F28;
-extern u8 D_80131F4C[];
-extern u8 D_80131F50;
-extern OcarinaSong sOcarinaSongs[]; // 80130F80
-extern u32 sNotePlaybackTimer;
-extern u16 sPlaybackNotePos;
-extern u32 D_80131860;
-extern u8 D_8013186;
-extern u8 D_80131868;
-extern u8 D_8013186C;
-extern s8 D_80131870;
-extern u8 D_80131874;
-extern u8 sRecordSongPos;
-extern u8 D_80131864;
-extern s8 D_80130F30;
-extern OcarinaSong* sPlaybackSong;
-extern OcarinaSong sPierresSong;
-extern u8 sDisplayedNoteValue; // Note to display on screen?
-extern s32 D_80130F68;
-extern OcarinaNote* D_80131BE4;
-extern OcarinaSong* D_80131BEC;
typedef struct {
u8 unk_00;
char unk_01[0x37];
} unk_dstruct;
-extern u8 D_80131EFC;
+extern u8 D_801333F4;
+extern u8 D_80133408;
+extern u8 D_8013340C;
+extern u8 D_80133414;
+extern u8 D_80133418;
extern unk_dstruct D_801337CE[];
-extern u8 D_80131F28;
-extern u8 D_80131F2C;
-extern u8 D_80131F30[];
/**
* BSS
@@ -169,10 +215,10 @@ s8 D_8016B7DC;
f32 D_8016B7E0;
u16 D_8016B7E4;
typedef struct {
- char unk_00[6];
- s16 unk_06;
-} unk_D_8016B7E8;
-unk_D_8016B7E8 D_8016B7E8[0x19];
+ s8 str[5];
+ u16 num;
+} unk_sAudioScreenPrintBuf;
+unk_sAudioScreenPrintBuf sAudioScreenPrintBuf[25];
u8 D_8016B8B0;
u8 D_8016B8B1;
u8 D_8016B8B2;
@@ -223,6 +269,10 @@ u32 sDebugPadPress;
s32 sAudioUpdateTaskStart;
s32 sAudioUpdateTaskEnd;
+extern u16 D_8016E2E0[];
+extern u16 D_8016E2F8[];
+extern u8 D_8016E310[];
+
void func_800EC960(u8 custom) {
if (!custom) {
osSyncPrintf("AUDIO : Ocarina Control Assign Normal\n");
@@ -377,7 +427,6 @@ void func_800ECDBC(void) {
}
}
-#ifdef NON_MATCHING
void func_800ECDF8(void) {
u16 sh;
u16 pad;
@@ -396,16 +445,17 @@ void func_800ECDF8(void) {
return;
}
- if (sPrevOcarinaNoteVal == sCurOcarinaBtnVal || sCurOcarinaBtnVal == 0xFF) {
- inputChanged = 1;
- }
+ // clang-format off
+ if (sPrevOcarinaNoteVal == sCurOcarinaBtnVal || sCurOcarinaBtnVal == 0xFF) { inputChanged = 1; }
+ // clang-format on
for (i = gOcarinaSongNotestartIdx; i < sOcarinaSongCnt; i++) {
sh = 1 << i;
if (sOcarinaAvailSongs & sh) {
D_8016BA50[i] = D_8016BA70[i] + 0x12;
if (inputChanged) {
- if ((D_8016BA50[i] >= D_8016BA70[i] - 0x12) && (D_8016BA50[i] >= D_8016BA70[i]) &&
+ // (pointless if check, this is always true)
+ if ((D_8016BA50[i] >= D_8016BA70[i] - 0x12) && (D_8016BA50[i] >= D_8016BA70[i] + 0x12) &&
(sOcarinaSongs[i].notes[sLearnSongPos[i]].unk_02 == 0) &&
(sLearnSongLastBtn == sLearnSongExpectedNote[i])) {
D_80131878 = i + 1;
@@ -431,11 +481,11 @@ void func_800ECDF8(void) {
if (sCurOcarinaBtnVal != sLearnSongExpectedNote[i]) {
sOcarinaAvailSongs ^= sh;
}
- for (; prevNote->noteIdx == note->noteIdx || (note->noteIdx == 0xFF && note->unk_02 != 0);
- sLearnSongPos[i]++) {
+ while (prevNote->noteIdx == note->noteIdx || (note->noteIdx == 0xFF && note->unk_02 != 0)) {
D_8016BA70[i] += note->unk_02;
- note = &sOcarinaSongs[i].notes[sLearnSongPos[i] + 1];
prevNote = &sOcarinaSongs[i].notes[sLearnSongPos[i]];
+ note = &sOcarinaSongs[i].notes[sLearnSongPos[i] + 1];
+ sLearnSongPos[i]++;
}
} else if (D_8016BA50[i] < 0xA) {
sp57 = -1;
@@ -462,10 +512,6 @@ void func_800ECDF8(void) {
}
}
}
-#else
-void func_800ECDF8(void);
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_800EC960/func_800ECDF8.s")
-#endif
void func_800ED200(void) {
u32 temp_v0;
@@ -474,7 +520,7 @@ void func_800ED200(void) {
u8 k;
if (CHECK_BTN_ANY(sCurOcarinaBtnPress, BTN_L) && CHECK_BTN_ANY(sCurOcarinaBtnPress, sOcarinaAllowedBtnMask)) {
- func_800ECC04(D_80130F3E);
+ func_800ECC04((u16)D_80130F3C);
return;
}
@@ -533,7 +579,7 @@ void func_800ED458(s32 arg0) {
}
if ((D_8016BA10 == 0) ||
- ((sCurOcarinaBtnPress & sOcarinaAllowedBtnMask) != (0, D_8016BA10 & sOcarinaAllowedBtnMask))) {
+ ((D_8016BA10 & sOcarinaAllowedBtnMask) != (sCurOcarinaBtnPress & sOcarinaAllowedBtnMask))) {
D_8016BA10 = 0;
if (1) {}
sCurOcarinaBtnVal = 0xFF;
@@ -660,12 +706,6 @@ void func_800ED93C(s8 songIdx, s8 arg1) {
}
}
-extern u8 sNotePlaybackVolume;
-extern f32 sNormalizedNotePlaybackVolume;
-extern u8 sNotePlaybackVibrato;
-extern s8 sNotePlaybackTone;
-extern f32 sNormalizedNotePlaybackTone;
-
void Audio_OcaPlayback(void) {
s32 noteTimerStep;
s32 nextNoteTimerStep;
@@ -1145,16 +1185,664 @@ u8* func_800EE9D0(s32 arg0, u8 arg1) {
return D_8016B9B8;
}
-extern char D_80131CAC[][0x17];
-extern char D_80131F54[][5];
-extern char D_80131E38[7][0xB];
-extern char D_80131E88[][0xA];
-extern u8 D_80131F68;
-
// Debug Print
+#ifdef NON_EQUIVALENT
+void func_800EEA50(GfxPrint* printer) {
+ char digitStr[2] = "1"; // sp98
+ s32 s0;
+ s32 k;
+ u8 i;
+ u8 j;
+ u8 songInd;
+ u8 totalNumLayers;
+ u8 instOrWave;
+ u8 inst;
+ u8 phi_s2_3;
+ s8 ind;
+ u8 idx; // v1
+ u8 bank; // fp
+ u8 numEnabledNotes; // sp78
+
+#define SETCOL_COMMON(v, r, g, b) \
+ GfxPrint_SetColor(printer, ((v & 4) >> 2) * (r), ((v & 2) >> 1) * (g), (v & 1) * (b), 255)
+#define SETCOL(r, g, b) SETCOL_COMMON(D_80131CA8, r, g, b)
+#define SETCOL2(r, g, b) SETCOL_COMMON(D_80131EE4[2], r, g, b)
+
+ D_80131C98 = 1;
+ GfxPrint_SetPos(printer, 3, 2);
+ SETCOL(255, 255, 255);
+ GfxPrint_Printf(printer, "Audio Debug Mode");
+
+ GfxPrint_SetPos(printer, 3, 3);
+ GfxPrint_Printf(printer, "- %s -", D_80131CAC[D_80131CA0]);
+
+ numEnabledNotes = 0; // s0
+ for (i = 0; i < gAudioSessionPresets[D_80133414].maxSimultaneousNotes; i++) { // s6
+ if (gAudioContext.notes[i].noteSubEu.bitField0.s.enabled == 1) {
+ numEnabledNotes++;
+ }
+ }
+
+ if (D_80131F68 < numEnabledNotes) {
+ D_80131F68 = numEnabledNotes;
+ }
+ if (D_8016B9E0[D_80133414] < numEnabledNotes) {
+ D_8016B9E0[D_80133414] = numEnabledNotes;
+ }
+
+ if (D_80131EE4[0] != 0) {
+ GfxPrint_SetPos(printer, D_80131EDC, D_80131EE0);
+ SETCOL2(0xC8, 0xC8, 0xC8);
+ GfxPrint_Printf(printer, "Audio ScrPrt");
+
+ ind = sAudioScreenPrintInd; // fp
+ for (k = 0; k < D_80131EE4[1] + 1; k++) { // s2 (s32 loop)
+ if (ind == 0) {
+ if (sAudioScreenPrintOverflow == 1) {
+ ind = 25 - 1;
+ } else {
+ k = D_80131EE4[1] + 1; // "break;"
+ }
+ } else {
+ ind--;
+ }
+ if (k != D_80131EE4[1] + 1) {
+ if ((ind % 5) != 0) {
+ SETCOL2(0xB4, 0xB4, 0xB4);
+ } else {
+ SETCOL2(0x78, 0x78, 0x78);
+ }
+ GfxPrint_SetPos(printer, D_80131EDC + 2, D_80131EE0 + D_80131EE4[1] + 1 - k);
+ GfxPrint_Printf(printer, "%s", sAudioScreenPrintBuf[ind].str);
+
+ GfxPrint_SetPos(printer, D_80131EDC + 7, D_80131EE0 + D_80131EE4[1] + 1 - k);
+ GfxPrint_Printf(printer, "%04X", sAudioScreenPrintBuf[ind].num);
+ }
+ }
+ }
+
+ switch (D_80131CA0) {
+ case 0:
+ GfxPrint_SetPos(printer, 3, 4);
+ SETCOL(255, 6, 6);
+ GfxPrint_Printf(printer, "BGM CANCEL:%s", D_80131F54[D_80131E08[5]]);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "SE MUTE:%s", D_80131F54[D_80131C9C]);
+
+ GfxPrint_SetPos(printer, 18, 4);
+ SETCOL(255, 255, 255);
+ GfxPrint_Printf(printer, "PUSH CONT-4 A-BTN");
+
+ bank = (u8)D_80131E08[2];
+ i = gSoundBanks[bank][0].next; // s6, s3
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "SE HANDLE:%s", D_80131E38[bank]);
+
+ while (i != 0xFF) {
+ GfxPrint_SetPos(printer, 3, j + 7);
+ GfxPrint_Printf(printer, "%02x %04x %02x %08x", i, gSoundBanks[bank][i].unk_28,
+ gSoundBanks[bank][i].unk_2A, gSoundBanks[bank][i].unk_20);
+ i = gSoundBanks[bank][i].next;
+ j++;
+ }
+ break;
+
+ case 1:
+ GfxPrint_SetPos(printer, 2, D_80131CA4 + 4);
+ SETCOL(127, 255, 127);
+ GfxPrint_Printf(printer, "*");
+
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "Seq 0 : %2x", D_80131E08[0]);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "Seq 1 : %2x", D_80131E08[1]);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "SE HD : %2x %s", D_80131E08[2], D_80131E38[D_80131E08[2]]);
+
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "SE No. :%3x", D_80131E08[3]);
+
+ GfxPrint_SetPos(printer, 3, 8);
+ GfxPrint_Printf(printer, "S-Out : %2x %s", D_80131E08[4], D_80131E88[D_80131E08[4]]);
+
+ GfxPrint_SetPos(printer, 3, 9);
+ GfxPrint_Printf(printer, "BGM Ent: %2x", D_80131E08[5]);
+
+ GfxPrint_SetPos(printer, 3, 10);
+ GfxPrint_Printf(printer, "Spec : %2x", D_80131E08[6]);
+
+ GfxPrint_SetPos(printer, 3, 11);
+ GfxPrint_Printf(printer, "Na Snd : %2x", D_80131E08[7]);
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "Cam Wt : %s", D_80131F54[D_80131E08[8]]);
+
+ GfxPrint_SetPos(printer, 3, 13);
+ GfxPrint_Printf(printer, "Lnk Wt : %s", D_80131F54[D_80131E08[9]]);
+
+ GfxPrint_SetPos(printer, 3, 14);
+ GfxPrint_Printf(printer, "SE Ent : %2x", D_80131E08[10]);
+ break;
+
+ case 7:
+ ind = 0; // fp
+ for (k = 0; k < 7; k++) { // s2 (s32 loop)
+ if (k == D_80131EC4) {
+ SETCOL(255, 127, 127);
+ } else {
+ SETCOL(255, 255, 255);
+ }
+ GfxPrint_SetPos(printer, D_80131EBC + 2, D_80131EC0 + ind + 4);
+ GfxPrint_Printf(printer, "%s <%d>", D_80131E38[k], D_80131EC8[k]);
+
+ for (s0 = 0; s0 < D_80130578[D_801333CC][k]; s0++) {
+ GfxPrint_SetPos(printer, D_80131EBC + 2, D_80131EC0 + ind + 5);
+ if (D_80131EC8[k] == 1) {
+ idx = D_8016E1B8[k][s0].unk_4;
+ if ((idx != 0xFF) && ((gSoundBanks[k][idx].unk_2A == 4) || (gSoundBanks[k][idx].unk_2A == 5))) {
+ SoundBankEntry* entry = &gSoundBanks[k][idx];
+ GfxPrint_Printf(printer, "%2X %5d %5d %5d %02X %04X %04X", idx, (s32)*entry->posX,
+ (s32)*entry->posY, (s32)*entry->posZ, entry->unk_24, entry->unk_26,
+ entry->unk_28);
+ } else {
+ GfxPrint_Printf(printer, "FF ----- ----- ----- -- ---- ----", idx);
+ }
+ } else if (D_80131EC8[k] == 2) {
+ idx = D_8016E1B8[k][s0].unk_4;
+ if ((idx != 0xFF) && ((gSoundBanks[k][idx].unk_2A == 4) || (gSoundBanks[k][idx].unk_2A == 5))) {
+ SoundBankEntry* entry = &gSoundBanks[k][idx];
+ SequenceChannel* chan = gAudioContext.seqPlayers[2].channels[entry->unk_2E];
+ GfxPrint_Printf(printer, "%2X %5d %5d %5d %3d %3d %04X", idx, (s32)*entry->posX,
+ (s32)*entry->posY, (s32)*entry->posZ, (s32)(chan->volume * 127.1f),
+ chan->newPan, entry->unk_28);
+ } else {
+ GfxPrint_Printf(printer, "FF ----- ----- ----- --- --- ----", idx);
+ }
+ } else if (D_80131EC8[k] == 3) {
+ idx = D_8016E1B8[k][s0].unk_4;
+ if ((idx != 0xFF) && ((gSoundBanks[k][idx].unk_2A == 4) || (gSoundBanks[k][idx].unk_2A == 5))) {
+ SoundBankEntry* entry = &gSoundBanks[k][idx];
+ SequenceChannel* chan = gAudioContext.seqPlayers[2].channels[entry->unk_2E];
+ GfxPrint_Printf(printer, "%2X %5d %5d %5d %3d %3d %04X", idx, (s32)*entry->posX,
+ (s32)*entry->posY, (s32)*entry->posZ, (s32)(chan->freqScale * 100.0f),
+ chan->reverb, entry->unk_28);
+ } else {
+ GfxPrint_Printf(printer, "FF ----- ----- ----- --- --- ----", idx);
+ }
+ } else if (D_80131EC8[k] == 4) {
+ idx = D_8016E1B8[k][s0].unk_4;
+ if ((idx != 0xFF) && ((gSoundBanks[k][idx].unk_2A == 4) || (gSoundBanks[k][idx].unk_2A == 5))) {
+ SoundBankEntry* entry = &gSoundBanks[k][idx];
+ GfxPrint_Printf(printer, "%2X %04X", idx, entry->unk_28);
+ } else {
+ GfxPrint_Printf(printer, "FF ----", idx);
+ }
+ }
+
+ if (D_80131EC8[k] != 0) {
+ ind++;
+ }
+ }
+ ind++;
+ }
+ break;
+
+ case 13:
+ GfxPrint_SetPos(printer, 2, D_80131ED0 + 4);
+ SETCOL(255, 255, 255);
+ GfxPrint_Printf(printer, "*");
+
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "Swicth : %d", D_80131EE4[0]);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "Lines : %d", D_80131EE4[1] + 1);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "Color : %d", D_80131EE4[2]);
+
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[0], D_80131EE4[3]);
+
+ GfxPrint_SetPos(printer, 3, 8);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[1], D_80131EE4[4]);
+
+ GfxPrint_SetPos(printer, 3, 9);
+ GfxPrint_Printf(printer, "ENVRONM : %d", D_80131EE4[5]);
+
+ GfxPrint_SetPos(printer, 3, 10);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[3], D_80131EE4[6]);
+
+ GfxPrint_SetPos(printer, 3, 11);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[4], D_80131EE4[7]);
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[5], D_80131EE4[8]);
+
+ GfxPrint_SetPos(printer, 3, 13);
+ GfxPrint_Printf(printer, "%s : %d", D_80131E38[6], D_80131EE4[9]);
+
+ GfxPrint_SetPos(printer, 3, 14);
+ GfxPrint_Printf(printer, "SEQ ENT : %d", D_80131EE4[10]);
+ break;
+
+ case 8:
+ GfxPrint_SetPos(printer, 3, 4);
+ SETCOL(255, 255, 255);
+ if (D_801333F4 != 0) {
+ GfxPrint_Printf(printer, "SWAP OFF");
+ }
+
+ if (D_80131F00 == 0) {
+ SETCOL(255, 255, 255);
+ } else {
+ SETCOL(127, 127, 127);
+ }
+ GfxPrint_SetPos(printer, 2, D_80131F04 + 6);
+ GfxPrint_Printf(printer, "*");
+
+ phi_s2_3 = D_80131F08;
+ if (D_80131F08 >= 4) {
+ phi_s2_3++;
+ }
+ if (D_80131F00 == 1) {
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, phi_s2_3 + 3, 5);
+ GfxPrint_Printf(printer, "V");
+ }
+
+ for (i = 0; i < 10; i++) { // s3, s6
+ if (i == D_80131F04) {
+ if (D_80131F00 == 0) {
+ SETCOL(192, 192, 192);
+ } else {
+ SETCOL(255, 255, 255);
+ }
+ } else if (D_80131F00 == 0) {
+ SETCOL(144, 144, 144);
+ } else {
+ SETCOL(96, 96, 96);
+ }
+ GfxPrint_SetPos(printer, 3, i + 6);
+ GfxPrint_Printf(printer, "%04x %04x %s", D_8016E2E0[i], D_8016E2F8[i], D_80131F0C[D_8016E310[i]]);
+ }
+ break;
+
+ case 5:
+ GfxPrint_SetPos(printer, 3, 4);
+ SETCOL(255, 255, 255);
+ GfxPrint_Printf(printer, "Group Track:%d", D_80131F28);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "Sub Track :%d", D_80131F2C);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "TRK NO. ");
+
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "ENTRY ");
+
+ GfxPrint_SetPos(printer, 3, 8);
+ GfxPrint_Printf(printer, "MUTE ");
+
+ GfxPrint_SetPos(printer, 3, 9);
+ GfxPrint_Printf(printer, "OPENNOTE");
+
+ totalNumLayers = 0; // s4
+ for (i = 0; i < 16; i++) { // s3, s6
+ u8 numLayers = 0; // s2
+ if (i == D_80131F2C) {
+ SETCOL(255, 255, 255);
+ } else {
+ SETCOL(200, 200, 200);
+ }
+ GfxPrint_SetPos(printer, i + 15, 6);
+ GfxPrint_Printf(printer, "%1X", i);
+
+ GfxPrint_SetPos(printer, i + 15, 7);
+ if (gAudioContext.seqPlayers[D_80131F28].channels[i]->enabled) {
+ GfxPrint_Printf(printer, "O");
+ } else {
+ GfxPrint_Printf(printer, "X");
+ }
+
+ GfxPrint_SetPos(printer, i + 15, 8);
+ if (gAudioContext.seqPlayers[D_80131F28].channels[i]->stopSomething2) {
+ GfxPrint_Printf(printer, "O");
+ } else {
+ GfxPrint_Printf(printer, "X");
+ }
+
+ GfxPrint_SetPos(printer, i + 15, 9);
+ for (j = 0; j < 4; j++) { // s0
+ if (gAudioContext.seqPlayers[D_80131F28].channels[i]->layers[j] != NULL) {
+ numLayers++;
+ }
+ }
+
+ GfxPrint_Printf(printer, "%1X", numLayers);
+ totalNumLayers += numLayers;
+ }
+
+ SETCOL(255, 255, 255);
+ if (D_80131F30[D_80131F28] < totalNumLayers) {
+ D_80131F30[D_80131F28] = totalNumLayers;
+ }
+ GfxPrint_SetPos(printer, i + 16, 9);
+ GfxPrint_Printf(printer, "%2d,%2d", totalNumLayers, D_80131F30[D_80131F28]);
+
+ GfxPrint_SetPos(printer, 3, 11);
+ GfxPrint_Printf(printer, "VOL ");
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "E VOL ");
+
+ GfxPrint_SetPos(printer, 3, 13);
+ GfxPrint_Printf(printer, "BANK ID ");
+
+ GfxPrint_SetPos(printer, 3, 14);
+ GfxPrint_Printf(printer, "PROG ");
+
+ GfxPrint_SetPos(printer, 3, 15);
+ GfxPrint_Printf(printer, "PAN ");
+
+ GfxPrint_SetPos(printer, 3, 16);
+ GfxPrint_Printf(printer, "PANPOW ");
+
+ GfxPrint_SetPos(printer, 3, 17);
+ GfxPrint_Printf(printer, "FXMIX ");
+
+ GfxPrint_SetPos(printer, 3, 18);
+ GfxPrint_Printf(printer, "PRIO ");
+
+ GfxPrint_SetPos(printer, 3, 19);
+ GfxPrint_Printf(printer, "VIB PIT ");
+
+ GfxPrint_SetPos(printer, 3, 20);
+ GfxPrint_Printf(printer, "VIB DEP ");
+
+ GfxPrint_SetPos(printer, 3, 21);
+ GfxPrint_Printf(printer, "TUNE ");
+
+ GfxPrint_SetPos(printer, 3, 22);
+ GfxPrint_Printf(printer, "TUNE ");
+
+ for (i = 0; i < 8; i++) { // s3, s6
+ GfxPrint_SetPos(printer, (i + 5) * 3, 22);
+ GfxPrint_Printf(printer, "%02X ",
+ gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->soundScriptIO[i]);
+ }
+
+ if (gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->enabled) {
+ GfxPrint_SetPos(printer, 15, 11);
+ GfxPrint_Printf(printer, "%d",
+ (u32)(gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->volume * 127.1) &
+ 0xFF);
+
+ GfxPrint_SetPos(printer, 15, 12);
+ GfxPrint_Printf(printer, "%d",
+ (u32)(gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->volumeScale * 127.1) &
+ 0xFF);
+
+ GfxPrint_SetPos(printer, 15, 13);
+ GfxPrint_Printf(printer, "%X", gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->bankId);
+
+ instOrWave = (u8)gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->instOrWave;
+ if (instOrWave == 0) {
+ inst = 0x7F;
+ } else {
+ inst = instOrWave;
+ if (instOrWave < 0x80) {
+ inst--;
+ }
+ }
+
+ GfxPrint_SetPos(printer, 15, 14);
+ GfxPrint_Printf(printer, "%d", inst);
+
+ GfxPrint_SetPos(printer, 15, 15);
+ GfxPrint_Printf(printer, "%d", gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->newPan);
+
+ GfxPrint_SetPos(printer, 15, 16);
+ GfxPrint_Printf(printer, "%d",
+ gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->panChannelWeight);
+
+ GfxPrint_SetPos(printer, 15, 17);
+ GfxPrint_Printf(printer, "%d", gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->reverb);
+
+ GfxPrint_SetPos(printer, 15, 18);
+ GfxPrint_Printf(printer, "%d", gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->notePriority);
+
+ GfxPrint_SetPos(printer, 15, 19);
+ GfxPrint_Printf(printer, "%d",
+ (gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->vibratoRateTarget / 32) &
+ 0xFF);
+
+ GfxPrint_SetPos(printer, 15, 20);
+ GfxPrint_Printf(printer, "%d",
+ (gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->vibratoExtentTarget / 8) &
+ 0xFF);
+
+ GfxPrint_SetPos(printer, 15, 21);
+ GfxPrint_Printf(printer, "%d",
+ (u32)(gAudioContext.seqPlayers[D_80131F28].channels[D_80131F2C]->freqScale * 100.0f) &
+ 0xFFFF);
+ }
+ break;
+
+ case 3:
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "TOTAL %d", D_8014A6C4.heap);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "DRIVER %05X / %05X",
+ gAudioContext.notesAndBuffersPool.cur - gAudioContext.notesAndBuffersPool.start,
+ gAudioContext.notesAndBuffersPool.size);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(
+ printer, "AT-SEQ %02X-%02X (%05X-%05X / %05X)", (u8)gAudioContext.seqLoadedPool.temporary.entries[0].id,
+ (u8)gAudioContext.seqLoadedPool.temporary.entries[1].id,
+ gAudioContext.seqLoadedPool.temporary.entries[0].size,
+ gAudioContext.seqLoadedPool.temporary.entries[1].size, gAudioContext.seqLoadedPool.temporary.pool.size);
+
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "AT-BNK %02X-%02X (%05X-%05X / %05X)",
+ (u8)gAudioContext.bankLoadedPool.temporary.entries[0].id,
+ (u8)gAudioContext.bankLoadedPool.temporary.entries[1].id,
+ gAudioContext.bankLoadedPool.temporary.entries[0].size,
+ gAudioContext.bankLoadedPool.temporary.entries[1].size,
+ gAudioContext.bankLoadedPool.temporary.pool.size);
+
+ GfxPrint_SetPos(printer, 3, 8);
+ GfxPrint_Printf(
+ printer, "ST-SEQ %02Xseqs (%05X / %06X)", gAudioContext.seqLoadedPool.persistent.numEntries,
+ gAudioContext.seqLoadedPool.persistent.pool.cur - gAudioContext.seqLoadedPool.persistent.pool.start,
+ gAudioContext.seqLoadedPool.persistent.pool.size);
+
+ for (k = 0; k < gAudioContext.seqLoadedPool.persistent.numEntries; k++) { // s2 (s32 loop)
+ GfxPrint_SetPos(printer, (k + 1) * 3, 9);
+ GfxPrint_Printf(printer, "%02x", gAudioContext.seqLoadedPool.persistent.entries[k].id);
+ }
+
+ GfxPrint_SetPos(printer, 3, 10);
+ GfxPrint_Printf(
+ printer, "ST-BNK %02Xbanks (%05X / %06X)", gAudioContext.bankLoadedPool.persistent.numEntries,
+ gAudioContext.bankLoadedPool.persistent.pool.cur - gAudioContext.bankLoadedPool.persistent.pool.start,
+ gAudioContext.bankLoadedPool.persistent.pool.size);
+
+ for (k = 0; k < gAudioContext.bankLoadedPool.persistent.numEntries; k++) { // s2 (s32 loop)
+ GfxPrint_SetPos(printer, (k + 1) * 3, 11);
+ GfxPrint_Printf(printer, "%02x", gAudioContext.bankLoadedPool.persistent.entries[k].id);
+ }
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "E-MEM %05X / %05X", gAudioContext.unk_2D50.cur - gAudioContext.unk_2D50.start,
+ gAudioContext.unk_2D50.size);
+ break;
+
+ case 9:
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "BGM No. %02X", D_80131F4C[0]);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "SCENE SET %02X %s", D_80131F4C[1], D_80131F44[D_80131F4C[1]]);
+
+ SETCOL(0x64, 255, 0x64);
+ GfxPrint_SetPos(printer, 2, D_80131F50 + 4);
+ GfxPrint_Printf(printer, "*");
+
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "NEXT SCENE %02X %s", (u8)gAudioContext.seqPlayers[0].unk_158[2],
+ D_80131F44[(u8)gAudioContext.seqPlayers[0].unk_158[2]]);
+
+ GfxPrint_SetPos(printer, 3, 8);
+ GfxPrint_Printf(printer, "NOW SCENE %02X %s", (u8)gAudioContext.seqPlayers[0].unk_158[4],
+ D_80131F44[(u8)gAudioContext.seqPlayers[0].unk_158[4]]);
+
+ GfxPrint_SetPos(printer, 3, 9);
+ GfxPrint_Printf(printer, "NOW BLOCK %02X", (gAudioContext.seqPlayers[0].unk_158[5] + 1) & 0xFF);
+
+ GfxPrint_SetPos(printer, 3, 11);
+ GfxPrint_Printf(printer, "PORT");
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "%02X %02X %02X %02X", (u8)gAudioContext.seqPlayers[0].unk_158[0],
+ (u8)gAudioContext.seqPlayers[0].unk_158[1], (u8)gAudioContext.seqPlayers[0].unk_158[2],
+ (u8)gAudioContext.seqPlayers[0].unk_158[3]);
+
+ GfxPrint_SetPos(printer, 3, 13);
+ GfxPrint_Printf(printer, "%02X %02X %02X %02X", (u8)gAudioContext.seqPlayers[0].unk_158[4],
+ (u8)gAudioContext.seqPlayers[0].unk_158[5], (u8)gAudioContext.seqPlayers[0].unk_158[6],
+ (u8)gAudioContext.seqPlayers[0].unk_158[7]);
+ break;
+
+ case 11:
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "SEQ INFO : %2d %02x %d", sDisplayedStaff.noteIdx, sDisplayedStaff.state,
+ sDisplayedStaff.pos);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "PLAY INFO : %2d %02x %d", D_8016B9F8.noteIdx, D_8016B9F8.state, D_8016B9F8.pos);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "8note REC POINTER : %08x", gScarecrowSpawnSongPtr);
+
+ songInd = 0; // s2
+ for (j = 0; j < 4; j++) { // s0, a0
+ for (i = 0; i < 8; i++) { // s3, s6
+ GfxPrint_SetPos(printer, (i + 1) * 3, j + 7);
+ GfxPrint_Printf(printer, "%02x", gScarecrowSpawnSongPtr[songInd++]);
+ }
+ }
+
+ GfxPrint_SetPos(printer, 3, 24);
+ GfxPrint_Printf(printer, "OCA:%02x SEQ:%04x PLAY:%02x REC:%02x", D_80130F10, D_80130F3C, sPlaybackState,
+ D_80131858);
+ break;
+
+ case 12:
+ GfxPrint_SetPos(printer, 2, D_80131F18 + 4);
+ SETCOL(127, 255, 127);
+ GfxPrint_Printf(printer, "*");
+
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 4);
+ GfxPrint_Printf(printer, "SE HD : %02x %s", D_80131F20[0], D_80131E38[D_80131F20[0]]);
+
+ GfxPrint_SetPos(printer, 3, 5);
+ GfxPrint_Printf(printer, "SE No. : %02x", D_80131F20[1]);
+
+ GfxPrint_SetPos(printer, 20, 6);
+ GfxPrint_Printf(printer, " : %04x", D_8013331C[D_80131F20[0]][D_80131F20[1]].unk_2);
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "SE SW %s", func_800EE9D0(D_8013331C[D_80131F20[0]][D_80131F20[1]].unk_2, 16));
+
+ SETCOL(127, 255, 127);
+ digitStr[0] = (char)('0' + ((D_8013331C[D_80131F20[0]][D_80131F20[1]].unk_2 >> (15 - D_80131F1C)) & 1));
+ GfxPrint_SetPos(printer, D_80131F1C + 12, 6);
+ GfxPrint_Printf(printer, "%s", &digitStr);
+
+ SETCOL(255, 255, 255);
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "SE PR : %02x", D_8013331C[D_80131F20[0]][D_80131F20[1]].unk_0);
+ break;
+
+ case 14:
+ GfxPrint_SetPos(printer, 3, 4);
+ SETCOL(255, 255, 255);
+ GfxPrint_Printf(printer, "env_fx %d code_fx %d SPEC %d", D_80130614, D_80130618, D_80133414);
+
+ if (sAudioUpdateTaskEnd == sAudioUpdateTaskStart) {
+ D_80131C90 = (f32)((sAudioUpdateEndTime - sAudioUpdateStartTime) * 64ULL / 3) / 50000000.0f;
+ if (D_80131C94 < D_80131C90) {
+ D_80131C94 = D_80131C90;
+ }
+ }
+
+ GfxPrint_SetPos(printer, 3, 6);
+ GfxPrint_Printf(printer, "SOUND GAME FRAME NOW %f", D_80131C90);
+
+ GfxPrint_SetPos(printer, 3, 7);
+ GfxPrint_Printf(printer, "SOUND GAME FRAME MAX %f", D_80131C94);
+
+ GfxPrint_SetPos(printer, 3, 9);
+ GfxPrint_Printf(printer, "SWITCH BGM MODE %d %d %d (FLAG %d)", D_8013061C, D_80130634, D_80130638,
+ D_80130654);
+
+ GfxPrint_SetPos(printer, 3, 10);
+ GfxPrint_Printf(printer, "ENEMY DIST %f VOL %3d", D_80130620, D_80130624);
+
+ GfxPrint_SetPos(printer, 3, 11);
+ GfxPrint_Printf(printer, "GANON DIST VOL %3d", D_8016B8B4);
+
+ GfxPrint_SetPos(printer, 3, 12);
+ GfxPrint_Printf(printer, "DEMO FLAG %d", D_8013060C);
+
+ GfxPrint_SetPos(printer, 3, 12);
+ if (D_8016BAA8 == 1) {
+ GfxPrint_Printf(printer, "MARON BGM DIST %f", D_8016BAAC);
+ D_8016BAA8 = 0;
+ }
+
+ GfxPrint_SetPos(printer, 3, 23);
+ if (D_80131F64 != 0) {
+ GfxPrint_Printf(printer, "NATURE FAILED %01x", D_80131F64);
+ }
+
+ GfxPrint_SetPos(printer, 3, 24);
+ if (D_8013064C != 0) {
+ GfxPrint_Printf(printer, "SARIA BGM PTR %08x", D_8013064C);
+ }
+
+ GfxPrint_SetPos(printer, 3, 25);
+ GfxPrint_Printf(printer, "POLI %d(%d)", D_80131F68, numEnabledNotes);
+
+ for (i = 0; i < 11; i++) { // s3, s6
+ GfxPrint_SetPos(printer, (i + 1) * 3, 26);
+ GfxPrint_Printf(printer, "%d", D_8016B9E0[i]);
+ }
+ break;
+ }
+#undef SETCOL_COMMON
+#undef SETCOL
+#undef SETCOL2
+}
+#else
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800EC960/func_800EEA50.s")
+#endif
-extern u16 D_80131E14;
void func_800F1BDC(void) {
u16 phi_t1 = 1;
@@ -1176,12 +1864,12 @@ void func_800F1BDC(void) {
if (D_80131CA4 > 0) {
D_80131CA4--;
} else {
- D_80131CA4 = 0xA;
+ D_80131CA4 = 10;
}
}
if (CHECK_BTN_ANY(sDebugPadPress, BTN_DDOWN)) {
- if (D_80131CA4 < 0xA) {
+ if (D_80131CA4 < 10) {
D_80131CA4++;
} else {
D_80131CA4 = 0;
@@ -1241,7 +1929,7 @@ void func_800F1BDC(void) {
break;
case 6:
Audio_SeqCmdF(0, D_80131E08[D_80131CA4]);
- D_80131EFC = D_80131E14;
+ D_80131EFC = D_80131E08[6];
if (gAudioSessionPresets[D_80131EFC].numSequencePlayers - 1 < D_80131F28) {
D_80131F28 = gAudioSessionPresets[D_80131EFC].numSequencePlayers - 1;
}
@@ -1327,15 +2015,6 @@ void func_800F2150(void) {
}
}
-extern u8 D_80131ED0;
-extern u8 D_80131ED4;
-extern u8 D_80131ED8;
-extern s8 D_80131EDC;
-extern s8 D_80131EE0;
-extern u8 D_80131EE4[];
-extern u8 D_80131EF0[];
-extern u8 D_801333F0;
-
void func_800F227C(void) {
if (D_80131EE4[0] != 0) {
@@ -1358,8 +2037,8 @@ void func_800F227C(void) {
}
if (CHECK_BTN_ANY(sDebugPadPress, BTN_B)) {
- D_80131ED4 = 0;
- D_80131ED8 = 0;
+ sAudioScreenPrintInd = 0;
+ sAudioScreenPrintOverflow = 0;
}
}
@@ -1372,7 +2051,7 @@ void func_800F227C(void) {
}
if (CHECK_BTN_ANY(sDebugPadPress, BTN_DDOWN)) {
- if (D_80131ED0 < 0xA) {
+ if (D_80131ED0 < 10) {
D_80131ED0++;
} else {
D_80131ED0 = 0;
@@ -1396,20 +2075,14 @@ void func_800F227C(void) {
}
D_801333F0 = D_80131EE4[3] + (D_80131EE4[4] * 2) + (D_80131EE4[5] * 4) + (D_80131EE4[6] * 8) +
- (D_80131EE4[7] * 0x10) + (D_80131EE4[8] * 32);
+ (D_80131EE4[7] * 0x10) + (D_80131EE4[8] * 0x20);
}
-extern u8 D_80131F00;
-extern u8 D_80131F04;
-extern u8 D_80131F08;
-extern u16 D_8016E2E0[];
-extern u16 D_8016E2F8[];
-extern u8 D_801333F4;
-extern u8 D_8016E310[];
#ifdef NON_MATCHING
+// regalloc near phi_v1
void func_800F2464(void) {
- s16 phi_t1;
- u16 new_var;
+ s16 delta;
+ u16 val;
u8 phi_v1;
if (D_80131F00 == 0) {
@@ -1429,7 +2102,6 @@ void func_800F2464(void) {
}
phi_v1 = 9;
- phi_t1 = phi_t1;
if ((sDebugPadPress & 0x8000) != 0) {
D_80131F00 = 1;
}
@@ -1446,9 +2118,7 @@ void func_800F2464(void) {
phi_v1 = 9;
}
D_8016E2E0[D_80131F04] = D_8016E2E0[phi_v1];
- if (!D_80131F08) {
- ;
- }
+ if (D_80131F08) {}
D_8016E2F8[D_80131F04] = D_8016E2F8[phi_v1];
}
} else {
@@ -1469,23 +2139,23 @@ void func_800F2464(void) {
if (((sDebugPadPress & 0x800) != 0) || ((sDebugPadPress & 0x400) != 0)) {
if ((sDebugPadPress & 0x800) != 0) {
- phi_t1 = (D_8016BAB0 & 8) != 0 ? 8 : 1;
+ delta = (D_8016BAB0 & 8) != 0 ? 8 : 1;
}
if ((sDebugPadPress & 0x400) != 0) {
- phi_t1 = (D_8016BAB0 & 8) != 0 ? -8 : -1;
+ delta = (D_8016BAB0 & 8) != 0 ? -8 : -1;
}
if (D_80131F08 < 4) {
- new_var = (u16)(((D_8016E2E0[D_80131F04] >> (((-D_80131F08) * 4) + 0xC)) + phi_t1) & 0xF);
- D_8016E2E0[D_80131F04] =
- (u16)((D_8016E2E0[D_80131F04] & ((0xF << (((-D_80131F08) * 4) + 0xC)) ^ 0xFFFF)) +
- (new_var << (((-D_80131F08) * 4) + 0xC)));
+ val = D_8016E2E0[D_80131F04] >> (((-D_80131F08) * 4) + 0xC);
+ val = (val + delta) & 0xF;
+ D_8016E2E0[D_80131F04] = (D_8016E2E0[D_80131F04] & ((0xF << (((-D_80131F08) * 4) + 0xC)) ^ 0xFFFF)) +
+ (val << (((-D_80131F08) * 4) + 0xC));
} else {
- new_var = (u16)(((D_8016E2F8[D_80131F04] >> (((-D_80131F08) * 4) + 0x1C)) + phi_t1) & 0xF);
- D_8016E2F8[D_80131F04] =
- (u16)((D_8016E2F8[D_80131F04] & ((0xF << (((-D_80131F08) * 4) + 0x1C)) ^ 0xFFFF)) +
- (new_var << (((-D_80131F08) * 4) + 0x1C)));
+ val = D_8016E2F8[D_80131F04] >> (((-D_80131F08) * 4) + 0x1C);
+ val = (val + delta) & 0xF;
+ D_8016E2F8[D_80131F04] = (D_8016E2F8[D_80131F04] & ((0xF << (((-D_80131F08) * 4) + 0x1C)) ^ 0xFFFF)) +
+ (val << (((-D_80131F08) * 4) + 0x1C));
}
}
@@ -1586,12 +2256,6 @@ void func_800F28B4(void) {
void func_800F29FC(void) {
}
-extern u8 D_80131F18;
-extern u16 D_80131F20[];
-
-extern u16 D_80131E24;
-extern u8 D_80131F1C;
-
void func_800F2A04(void) {
s32 phi_a2;
u16 sfx;
@@ -1623,7 +2287,7 @@ void func_800F2A04(void) {
if (D_80131F20[D_80131F18] > 0) {
D_80131F20[D_80131F18]--;
} else {
- D_80131F20[D_80131F18] = D_80131E24 - 1;
+ D_80131F20[D_80131F18] = D_80131E20[2] - 1;
}
} else {
D_80131F20[D_80131F18] -= phi_a2;
@@ -1639,7 +2303,7 @@ void func_800F2A04(void) {
if (CHECK_BTN_ANY(sDebugPadPress, BTN_DRIGHT)) {
if (D_80131F18 < 2) {
if (D_80131F18 == 0) {
- if (D_80131F20[D_80131F18] < (D_80131E24 - 1)) {
+ if (D_80131F20[D_80131F18] < (D_80131E20[2] - 1)) {
D_80131F20[D_80131F18]++;
} else {
D_80131F20[D_80131F18] = 0;
@@ -1675,26 +2339,26 @@ void func_800F2A04(void) {
}
}
-void func_800F2D6C(s8* arg0, u16 arg1) {
+void func_800F2D6C(const s8* str, u16 num) {
u8 i = 0;
- D_8016B7E8[D_80131ED4].unk_06 = arg1;
+ sAudioScreenPrintBuf[sAudioScreenPrintInd].num = num;
- while (arg0[i] != 0) {
- D_8016B7E8[D_80131ED4].unk_00[i] = arg0[i];
+ while (str[i] != 0) {
+ sAudioScreenPrintBuf[sAudioScreenPrintInd].str[i] = str[i];
i++;
}
while (i < 5) {
- D_8016B7E8[D_80131ED4].unk_00[i] = 0;
+ sAudioScreenPrintBuf[sAudioScreenPrintInd].str[i] = 0;
i++;
}
- if (D_80131ED4 < 0x18) {
- D_80131ED4++;
+ if (sAudioScreenPrintInd < 25 - 1) {
+ sAudioScreenPrintInd++;
} else {
- D_80131ED4 = 0;
- D_80131ED8 = 1;
+ sAudioScreenPrintInd = 0;
+ sAudioScreenPrintOverflow = 1;
}
}
@@ -1731,7 +2395,8 @@ void func_800F2E28(void) {
if (CHECK_BTN_ANY(sDebugPadPress, BTN_Z)) {
// change text color
- D_80131CA8 = (u32)(++D_80131CA8) % 8;
+ D_80131CA8++;
+ D_80131CA8 &= 7;
}
switch (D_80131CA0) {
@@ -1785,7 +2450,7 @@ void func_800F2E28(void) {
break;
}
- D_8013340C = D_80131EEE;
+ D_8013340C = D_80131EE4[10];
}
}
@@ -1886,7 +2551,7 @@ s8 func_800F32F0(u8 arg0, u8 arg1, u8 arg2) {
if (temp_a3->unk_1C < 2500.0f) {
phi_v0 = *temp_a3->posZ > 0.0f ? (temp_a3->unk_1C / 2500.0f) * 70.0f : (temp_a3->unk_1C / 2500.0f) * 91.0f;
} else {
- phi_v0 = 0x46;
+ phi_v0 = 70;
}
}
@@ -2018,12 +2683,12 @@ u8 func_800F37B8(f32 arg0, SoundBankEntry* arg1, s8 arg2) {
f32 phi_f12;
if (*arg1->posZ < arg0) {
- phi_v0 = arg2 < 0x41 ? arg2 : 0x7F - arg2;
+ phi_v0 = arg2 < 65 ? arg2 : 0x7F - arg2;
- if (phi_v0 < 0x1E) {
+ if (phi_v0 < 30) {
phi_v1 = 0;
} else {
- phi_v1 = (((phi_v0 & 0xFFFF) * 0xA) - 0x12C) / 0x22;
+ phi_v1 = (((phi_v0 & 0xFFFF) * 10) - 300) / 34;
if (phi_v1 != 0) {
phi_v1 = 0x10 - phi_v1;
}
@@ -2067,7 +2732,7 @@ s8 func_800F3990(f32 arg0, u16 arg1) {
if (arg0 >= 0.0f) {
if (arg0 > 625.0f) {
- ret = 0x7F;
+ ret = 127;
} else {
ret = (arg0 / 625.0f) * 126.0f;
}
@@ -2075,12 +2740,11 @@ s8 func_800F3990(f32 arg0, u16 arg1) {
return ret | 1;
}
-extern f32 D_801305C4[];
void func_800F3A08(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
f32 sp44;
s8 phi_a1;
- s8 sp42;
- f32 sp3C;
+ s8 reverb;
+ f32 freqScale;
s8 sp3B;
u8 sp3A;
u8 sp39;
@@ -2089,13 +2753,13 @@ void func_800F3A08(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
u8 sp33;
SoundBankEntry* temp_a3;
- sp42 = 0;
+ reverb = 0;
sp3B = 0x40;
sp3A = 0;
sp39 = 0;
sp38 = 0;
sp33 = 0;
- sp3C = 1.0f;
+ freqScale = 1.0f;
sp44 = 1.0f;
temp_a3 = &gSoundBanks[bankIdx][entryIdx];
switch (bankIdx) {
@@ -2110,11 +2774,11 @@ void func_800F3A08(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
case BANK_OCARINA:
temp_a3->unk_1C = sqrtf(temp_a3->unk_1C);
sp44 = func_800F3188(bankIdx, entryIdx) * *temp_a3->unk_14;
- sp42 = func_800F32F0(bankIdx, entryIdx, channelIdx);
+ reverb = func_800F32F0(bankIdx, entryIdx, channelIdx);
sp3B = func_800F3468(*temp_a3->posX, *temp_a3->posZ, temp_a3->unk_C);
- sp3C = func_800F35EC(bankIdx, entryIdx) * *temp_a3->unk_10;
+ freqScale = func_800F35EC(bankIdx, entryIdx) * *temp_a3->unk_10;
if (D_80130604 == 2) {
- sp34 = D_801305C4[(temp_a3->unk_26 & 0x400) >> 0xA];
+ sp34 = D_801305C4[(temp_a3->unk_26 & 0x400) >> 10];
if (!(temp_a3->unk_26 & 0x800)) {
if (*temp_a3->posZ < sp34) {
sp3A = 0x10;
@@ -2132,7 +2796,7 @@ void func_800F3A08(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
}
}
if (D_8013063C != 0) {
- if ((bankIdx == 1) || (bankIdx == 0) || (bankIdx == 6)) {
+ if ((bankIdx == BANK_ITEM) || (bankIdx == BANK_PLAYER) || (bankIdx == BANK_VOICE)) {
sp33 = D_8013063C;
}
}
@@ -2157,13 +2821,13 @@ void func_800F3A08(u8 bankIdx, u8 entryIdx, u8 channelIdx) {
}
Audio_QueueCmdS8(0x6020000 | (channelIdx << 8) | 2, phi_a1);
- if (sp42 != D_8016B8B8[channelIdx].unk_08) {
- Audio_QueueCmdS8(0x5020000 | (channelIdx << 8), sp42);
- D_8016B8B8[channelIdx].unk_08 = sp42;
+ if (reverb != D_8016B8B8[channelIdx].unk_08) {
+ Audio_QueueCmdS8(0x5020000 | (channelIdx << 8), reverb);
+ D_8016B8B8[channelIdx].unk_08 = reverb;
}
- if (sp3C != D_8016B8B8[channelIdx].unk_04) {
- Audio_QueueCmdF32(0x4020000 | (channelIdx << 8), sp3C);
- D_8016B8B8[channelIdx].unk_04 = sp3C;
+ if (freqScale != D_8016B8B8[channelIdx].unk_04) {
+ Audio_QueueCmdF32(0x4020000 | (channelIdx << 8), freqScale);
+ D_8016B8B8[channelIdx].unk_04 = freqScale;
}
if (sp3A != D_8016B8B8[channelIdx].unk_0A) {
Audio_QueueCmdS8(0xE020000 | (channelIdx << 8), sp3A | 0x10);
@@ -2457,7 +3121,7 @@ void func_800F4A70(void) {
if (D_80130600 != 0) {
D_80130600--;
if (D_80130600 == 0) {
- func_800F491C(D_801305FF);
+ func_800F491C(D_801305F8[7]);
}
}
}
@@ -2576,12 +3240,12 @@ void func_800F510C(s8 arg0) {
phi_v1 = 0x7F - arg0;
}
- if (phi_v1 >= 0x65) {
- phi_a2 = 0xB;
- } else if (phi_v1 < 0x14) {
+ if (phi_v1 > 100) {
+ phi_a2 = 11;
+ } else if (phi_v1 < 20) {
phi_a2 = 2;
} else {
- phi_a2 = ((phi_v1 - 0x14) / 0xA) + 2;
+ phi_a2 = ((phi_v1 - 20) / 10) + 2;
}
phi_a1 = 0;
@@ -2808,7 +3472,7 @@ void func_800F5C2C(void) {
void func_800F5C64(u16 arg0) {
u16 sp26;
- s32 sp20;
+ u32 sp20;
u8* sp1C;
u8* sp18;
@@ -2861,9 +3525,6 @@ void func_800F5E18(u8 seqIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4) {
Audio_StartSeq(seqIdx, fadeTimer, seqId);
}
-extern u8 D_80130654;
-extern u32 D_80130634;
-extern u32 D_80130638;
void func_800F5E90(u8 arg0) {
s32 phi_t0;
u16 phi_t1;
@@ -2957,38 +3618,38 @@ void func_800F6114(f32 arg0) {
D_80130620 = arg0;
}
-#ifdef NON_MATCHING
void func_800F6268(f32 arg0, u16 arg1) {
- s8 temp_a0;
+ s8 pad;
s8 phi_v1;
+ s16 temp_a0;
D_8016BAA8 = 1;
D_8016BAAC = arg0;
if (D_8016B9F2 == 0) {
- temp_a0 = func_800FA0B4(0);
+ temp_a0 = (s8)(func_800FA0B4(0) & 0xFF);
if (temp_a0 == (arg1 & 0xFF)) {
if ((arg1 & 0xFF) == 0x2F) {
if (arg0 > 2000.0f) {
- phi_v1 = 0x7F;
+ phi_v1 = 127;
} else if (arg0 < 200.0f) {
phi_v1 = 0;
} else {
- phi_v1 = ((arg0 - 200.0f) * 127.0f) / 1800.0f;
+ phi_v1 = (s8)(((arg0 - 200.0f) * 127.0f) / 1800.0f);
}
- Audio_SeqCmd6(0, 3, 0, 0x7F - phi_v1);
- Audio_SeqCmd6(0, 3, 1, 0x7F - phi_v1);
+ Audio_SeqCmd6(0, 3, 0, 127 - phi_v1);
+ Audio_SeqCmd6(0, 3, 1, 127 - phi_v1);
Audio_SeqCmd6(0, 3, 13, phi_v1);
if (D_8016B9D8[0] == 0) {
D_8016B9D8[0]++;
}
}
} else if ((temp_a0 == 1) && ((arg1 & 0xFF) == 0x2F)) {
- temp_a0 = func_800FA0B4(3);
- if ((temp_a0 != (arg1 & 0xFF)) && (D_8016B9D8[0] < 0xA)) {
+ temp_a0 = (s8)(func_800FA0B4(3) & 0xFF);
+ if ((temp_a0 != (arg1 & 0xFF)) && (D_8016B9D8[0] < 10)) {
func_800F5E18(3, 0x2F, 0, 0, 0);
Audio_SeqCmdA(3, 0xFFFC);
- D_8016B9D8[0] = 0xA;
+ D_8016B9D8[0] = 10;
}
if (arg0 > 2000.0f) {
@@ -2996,21 +3657,17 @@ void func_800F6268(f32 arg0, u16 arg1) {
} else if (arg0 < 200.0f) {
phi_v1 = 0;
} else {
- phi_v1 = ((arg0 - 200.0f) * 127.0f) / 1800.0f;
+ phi_v1 = (s8)(((arg0 - 200.0f) * 127.0f) / 1800.0f);
}
Audio_SeqCmd6(3, 3, 0, 127 - phi_v1);
Audio_SeqCmd6(3, 3, 1, 127 - phi_v1);
}
- if (D_8016B9D8[0] < 0xA) {
+ if (D_8016B9D8[0] < 10) {
D_8016B9D8[0]++;
}
}
}
-#else
-void func_800F6268(f32 arg0, u16 arg1);
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_800EC960/func_800F6268.s")
-#endif
void func_800F64E0(u8 arg0) {
D_80130608 = arg0;
@@ -3142,7 +3799,7 @@ void func_800F6964(u16 arg0) {
switch (i) {
case 0xB:
case 0xC:
- if (D_80133414 == 0xA) {
+ if (D_80133414 == 10) {
phi_v1 = 1;
}
break;
@@ -3227,14 +3884,6 @@ void func_800F6C34(void) {
D_8016B9F2 = 0;
}
-typedef struct {
- u16 unk_00;
- u16 unk_02;
- u8 unk_04[0x64];
-} D_801306DC_s;
-
-extern D_801306DC_s D_801306DC[];
-
void func_800F6D58(u8 arg0, u8 arg1, u8 arg2) {
u8 t;
u8 temp_a0;
@@ -3302,8 +3951,8 @@ void func_800F6FB4(u8 arg0) {
if ((D_8016E750[0].unk_254 == 0xFFFF) || ((D_80130658[((u8)D_8016E750[0].unk_254) & 0xFFFF] & 0x80) == 0)) {
func_800F6E7C(D_801306DC[arg0].unk_00, D_801306DC[arg0].unk_02);
- while ((D_801306DC[arg0].unk_04[i] != 0xFF) && (i < 0x64)) {
- // Probably a fake match, using Audio_SeqCmd8 deosn't work.
+ while ((D_801306DC[arg0].unk_04[i] != 0xFF) && (i < 100)) {
+ // Probably a fake match, using Audio_SeqCmd8 doesn't work.
b0 = D_801306DC[arg0].unk_04[i++];
b1 = D_801306DC[arg0].unk_04[i++];
b2 = D_801306DC[arg0].unk_04[i++];
diff --git a/src/code/code_800F7260.c b/src/code/code_800F7260.c
index aed3f4cb8..db3180fb1 100644
--- a/src/code/code_800F7260.c
+++ b/src/code/code_800F7260.c
@@ -18,27 +18,20 @@ typedef struct {
/* 0x0C */ u16 unk_C;
} Struct_800F8EA0; // size = 0x10
-u8 D_80133340[4] = {
- 0x53,
- 0x45,
- 0x00,
- 0x00,
-};
+// rodata for func_800F7680 (this file)
+char D_80133340[] = "SE";
+// rodata for func_800F7CEC (this file)
char D_80133344[] = VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n";
+// file padding
s32 D_8013338C = 0;
-UNK_TYPE D_80133390[] = {
- 0x53455120,
- 0x48000000,
-};
-
-UNK_TYPE D_80133398[] = {
- 0x20202020,
- 0x4C000000,
-};
+// rodata for Audio_ProcessSeqCmd (code_800F9280.c)
+char D_80133390[] = "SEQ H";
+char D_80133398[] = " L";
+// data
u8 D_801333A0 = 0;
u8 D_801333A4 = 0;
@@ -114,6 +107,8 @@ void Audio_ClearBGMMute(u8 arg0) {
}
}
+// a3 = freq scale factor for ocarina
+// a5 = reverb add
void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* a1, u8 a2, f32* a3, f32* a4, s8* a5) {
u8 i;
Struct_800F738C* phi_v0;
@@ -559,7 +554,7 @@ void func_800F87A0(u8 bankId) {
}
bankIndex = gSoundBanks[bankId][0].next;
}
- sp48.unk_28 = bankId << 0xC;
+ sp48.unk_28 = bankId << 12;
func_800F74E0(0, &sp48);
}
@@ -588,7 +583,7 @@ void func_800F89A0(u8 bankId, Vec3f* pos) {
SoundBankEntry sp18;
func_800F8884(bankId, pos);
- sp18.unk_28 = bankId << 0xC;
+ sp18.unk_28 = bankId << 12;
sp18.posX = &pos->x;
func_800F74E0(1, &sp18);
}
diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.c
index 6b273f981..3f93b87bc 100644
--- a/src/code/code_800F9280.c
+++ b/src/code/code_800F9280.c
@@ -48,7 +48,6 @@ void func_800F9280(u8 seqIdx, u8 seqId, u8 arg2, u16 fadeTimer) {
}
}
#else
-void func_800F9280(u8 seqIdx, u8 seqId, u8 arg2, u16 fadeTimer);
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F9280/func_800F9280.s")
#endif