audio load.c decomp (#176)

This commit is contained in:
MegaMech
2022-04-17 00:11:40 -06:00
committed by GitHub
parent 13a11f0ffa
commit e4e5f91be5
54 changed files with 2038 additions and 2764 deletions
+7
View File
@@ -3,6 +3,13 @@
#include "internal.h"
#define AUDIO_LOCK_UNINITIALIZED 0
#define AUDIO_LOCK_NOT_LOADING 0x76557364
#define AUDIO_LOCK_LOADING 0x19710515
extern struct AdsrEnvelope gDefaultEnvelope[3];
// number of DMAs performed during this frame
extern s32 gCurrAudioFrameDmaCount;
#endif
+2 -2
View File
@@ -314,7 +314,7 @@ GLOBAL_ASM("asm/non_matchings/audio/effects/func_800BE5BC.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
extern ? D_803B7088;
extern ? gAudioBufferParameters;
f32 func_800BE5E0(void *arg0) {
f32 temp_f0;
@@ -352,7 +352,7 @@ loop_6:
arg0->unk1 = 0;
} else {
if (temp_a2 >= 4) {
arg0->unk4 = ((temp_a2 * D_803B7088.unkC) / D_803B7088.unk0) / 4;
arg0->unk4 = ((temp_a2 * gAudioBufferParameters.unkC) / gAudioBufferParameters.unk0) / 4;
}
phi_a2 = arg0->unk4;
if (arg0->unk4 == 0) {
+78 -75
View File
@@ -1,5 +1,8 @@
#include <ultra64.h>
#include <macros.h>
#include "heap.h"
extern struct SoundAllocPool gNotesAndBuffersPool;
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
@@ -61,7 +64,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B8DE0.s")
? func_800BF004(? *, void *); // extern
extern s32 D_803B1508;
extern ? D_803B5FC8;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
void func_800B8EA8(s32 arg0) {
s32 temp_s2;
@@ -73,7 +76,7 @@ void func_800B8EA8(s32 arg0) {
s32 phi_s2;
s32 phi_v0;
temp_v0 = D_803B70B0;
temp_v0 = gMaxSimultaneousNotes;
phi_s2 = 0;
phi_v0 = temp_v0;
if (temp_v0 > 0) {
@@ -90,7 +93,7 @@ void func_800B8EA8(s32 arg0) {
func_800BCB48(temp_s0);
func_800BD6F4(temp_s0);
func_800BF004(&D_803B5FC8, temp_s0);
phi_v0 = D_803B70B0;
phi_v0 = gMaxSimultaneousNotes;
}
temp_s2 = phi_s2 + 1;
phi_s1 += 0xC0;
@@ -127,7 +130,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B8F8C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
u32 func_800B8FFC(void *arg0, s32 arg1) {
u32 soundAlloc(void *arg0, s32 arg1) {
s32 temp_t6;
s8 *temp_a1;
u32 temp_a2;
@@ -153,7 +156,7 @@ u32 func_800B8FFC(void *arg0, s32 arg1) {
return 0;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B8FFC.s")
GLOBAL_ASM("asm/non_matchings/audio/heap/soundAlloc.s")
#endif
#ifdef MIPS_TO_C
@@ -222,16 +225,16 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B90F0.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32); // extern
s32 soundAlloc(? *, s32); // extern
? func_800B907C(? *, s32, s32); // extern
extern ? D_803AFBC8;
extern ? D_803AFBE8;
extern ? gNotesAndBuffersPool;
extern ? D_803AFC18;
void func_800B914C(void *arg0) {
D_803AFBC8.unk4 = D_803AFBC8.unk0;
func_800B907C(&D_803AFBE8, func_800B8FFC(&D_803AFBC8, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFC18, func_800B8FFC(&D_803AFBC8, arg0->unkC), arg0->unkC);
func_800B907C(&gNotesAndBuffersPool, soundAlloc(&D_803AFBC8, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFC18, soundAlloc(&D_803AFBC8, arg0->unkC), arg0->unkC);
}
#else
GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B914C.s")
@@ -239,7 +242,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B914C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32); // extern
s32 soundAlloc(? *, s32); // extern
? func_800B907C(? *, s32, s32); // extern
extern ? D_803AFC18;
extern ? D_803AFC28;
@@ -247,8 +250,8 @@ extern ? D_803AFC38;
void func_800B91C8(void *arg0) {
D_803AFC18.unk4 = D_803AFC18.unk0;
func_800B907C(&D_803AFC28, func_800B8FFC(&D_803AFC18, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFC38, func_800B8FFC(&D_803AFC18, arg0->unk4), arg0->unk4);
func_800B907C(&D_803AFC28, soundAlloc(&D_803AFC18, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFC38, soundAlloc(&D_803AFC18, arg0->unk4), arg0->unk4);
}
#else
GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B91C8.s")
@@ -256,7 +259,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B91C8.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32); // extern
s32 soundAlloc(? *, s32); // extern
? func_800B907C(? *, s32, s32); // extern
? func_800B909C(? *); // extern
extern ? D_803AFC28;
@@ -269,9 +272,9 @@ extern ? D_803AFFEC;
void func_800B9244(void *arg0) {
D_803AFC28.unk4 = D_803AFC28.unk0;
func_800B907C(&D_803AFC4C, func_800B8FFC(&D_803AFC28, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFE1C, func_800B8FFC(&D_803AFC28, arg0->unk4), arg0->unk4);
func_800B907C(&D_803AFFEC, func_800B8FFC(&D_803AFC28, arg0->unk8), arg0->unk8);
func_800B907C(&D_803AFC4C, soundAlloc(&D_803AFC28, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFE1C, soundAlloc(&D_803AFC28, arg0->unk4), arg0->unk4);
func_800B907C(&D_803AFFEC, soundAlloc(&D_803AFC28, arg0->unk8), arg0->unk8);
func_800B909C(&D_803AFC48);
func_800B909C(&D_803AFE18);
func_800B909C(&D_803AFFE8);
@@ -282,7 +285,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B9244.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32); // extern
s32 soundAlloc(? *, s32); // extern
? func_800B907C(? *, s32, s32); // extern
? func_800B90B0(? *); // extern
extern ? D_803AFC38;
@@ -295,9 +298,9 @@ extern ? D_803B0180;
void func_800B9300(void *arg0) {
D_803AFC38.unk4 = D_803AFC38.unk0;
func_800B907C(&D_803AFDE0, func_800B8FFC(&D_803AFC38, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFFB0, func_800B8FFC(&D_803AFC38, arg0->unk4), arg0->unk4);
func_800B907C(&D_803B0180, func_800B8FFC(&D_803AFC38, arg0->unk8), arg0->unk8);
func_800B907C(&D_803AFDE0, soundAlloc(&D_803AFC38, arg0->unk0), arg0->unk0);
func_800B907C(&D_803AFFB0, soundAlloc(&D_803AFC38, arg0->unk4), arg0->unk4);
func_800B907C(&D_803B0180, soundAlloc(&D_803AFC38, arg0->unk8), arg0->unk8);
func_800B90B0(&D_803AFDDC);
func_800B90B0(&D_803AFFAC);
func_800B90B0(&D_803B017C);
@@ -310,7 +313,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B9300.s")
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_800B8EA8(s16, s32, s16, s32 *); // extern
? func_800B8F8C(s16, s32); // extern
s32 func_800B8FFC(s32, s32); // extern
s32 soundAlloc(s32, s32); // extern
extern ? D_803AFC48;
extern ? D_803AFE18;
extern ? D_803AFFE8;
@@ -320,7 +323,7 @@ extern ? D_803B0400;
extern void *D_803B1508;
extern ? D_803B1510;
extern ? D_803B1A30;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
u32 func_800B93BC(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
? *sp34;
@@ -426,7 +429,7 @@ loop_1:
phi_t2_2 = phi_t2;
if (sp33 == 1) {
if (phi_t1 == 4) {
temp_a1 = D_803B70B0;
temp_a1 = gMaxSimultaneousNotes;
phi_v1 = 0;
phi_v1_2 = 0;
if (temp_a1 > 0) {
@@ -452,7 +455,7 @@ loop_18:
}
}
if (phi_t2 == 4) {
temp_a1_2 = D_803B70B0;
temp_a1_2 = gMaxSimultaneousNotes;
phi_v1_3 = 0;
phi_v1_4 = 0;
if (temp_a1_2 > 0) {
@@ -546,7 +549,7 @@ loop_54:
}
if (sp20 == 1) {
if (phi_t1_2 == 2) {
temp_a1_3 = D_803B70B0;
temp_a1_3 = gMaxSimultaneousNotes;
phi_v1_5 = 0;
phi_v1_6 = 0;
if (temp_a1_3 > 0) {
@@ -576,7 +579,7 @@ block_68:
phi_a2 = phi_a2_2;
phi_a2 = phi_a2_2;
if (phi_t2_2 == 2) {
temp_a1_4 = D_803B70B0;
temp_a1_4 = gMaxSimultaneousNotes;
phi_v1_7 = 0;
phi_v1_8 = 0;
if (temp_a1_4 > 0) {
@@ -717,7 +720,7 @@ block_99:
}
arg4 = arg4;
arg3 = phi_a3;
temp_v0_9 = func_800B8FFC(arg0 + 4, arg1 * arg2);
temp_v0_9 = soundAlloc(arg0 + 4, arg1 * arg2);
(arg0 + (*arg0 * 0xC))->unk14 = temp_v0_9;
if (temp_v0_9 == 0) {
if ((arg3 != 0) && (arg3 != 1)) {
@@ -855,7 +858,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800B9FB8.s")
? func_800BEF2C(? *); /* extern */
extern ? D_803B1510;
extern ? D_803B1A30;
extern ? D_803B7088;
extern ? gAudioBufferParameters;
s32 func_800BA00C(void) {
? *temp_s0;
@@ -894,7 +897,7 @@ s32 func_800BA00C(void) {
D_803B0504 = temp_v0 - 1;
func_800B9FB8();
} else {
temp_a2 = D_803B70B0;
temp_a2 = gMaxSimultaneousNotes;
phi_v1 = 0;
phi_a0 = 0;
phi_a2 = temp_a2;
@@ -904,10 +907,10 @@ s32 func_800BA00C(void) {
temp_v0_2 = D_803B1508 + phi_v1;
phi_a0 = temp_a0;
if (((temp_v0_2->unkB0 >> 0x1F) != 0) && (temp_v0_2->unk59 != 0)) {
temp_v0_2->unk68 = D_803B7088.unk18;
temp_v0_2->unk68 = gAudioBufferParameters.unk18;
temp_v0_3 = D_803B1508 + phi_v1;
temp_v0_3->unk58 = temp_v0_3->unk58 | 0x10;
phi_a2 = D_803B70B0;
phi_a2 = gMaxSimultaneousNotes;
}
phi_v1 += 0xC0;
} while (temp_a0 < phi_a2);
@@ -967,7 +970,7 @@ GLOBAL_ASM("asm/non_matchings/audio/heap/func_800BA00C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_800B8DE0(); // extern
s32 func_800B8FFC(? *, s32); // extern
s32 soundAlloc(? *, s32); // extern
? func_800B914C(? *, s16, s16, u16); // extern
? func_800B91C8(? *); // extern
? func_800B9244(? *); // extern
@@ -985,17 +988,17 @@ extern u16 D_803AFBC0;
extern u8 D_803AFBC3;
extern s32 D_803AFBC4;
extern s32 D_803AFBD0;
extern ? D_803AFBE8;
extern ? gNotesAndBuffersPool;
extern ? D_803B0348;
extern ? D_803B0358;
extern ? D_803B0360;
extern ? D_803B0370;
extern u8 D_803B0501;
extern s32 D_803B1508;
extern s32 D_803B6E58;
extern ? D_803B7088;
extern s32 gSampleDmaNumListItems;
extern ? gAudioBufferParameters;
extern s32 D_803B70AC;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
extern s16 D_803B70B4;
extern ? D_803B70C8;
extern ? D_803B70D0;
@@ -1034,36 +1037,36 @@ void func_800BA250(void) {
s32 phi_s1;
temp_s6 = (D_803B0501 * 0x28) + &D_800EA4D8;
D_803B6E58 = 0;
gSampleDmaNumListItems = 0;
temp_t9 = temp_s6->unk0;
D_803B7088.unk2 = temp_t9;
D_803B7088.unk4 = osAiSetFrequency(temp_t9 & 0xFFFF);
temp_a3 = D_803B7088.unk2;
D_803B7088.unk6 = ((temp_a3 / D_803B717C) + 0xF) & 0xFFF0;
temp_v1 = D_803B7088.unk6;
gAudioBufferParameters.unk2 = temp_t9;
gAudioBufferParameters.unk4 = osAiSetFrequency(temp_t9 & 0xFFFF);
temp_a3 = gAudioBufferParameters.unk2;
gAudioBufferParameters.unk6 = ((temp_a3 / D_803B717C) + 0xF) & 0xFFF0;
temp_v1 = gAudioBufferParameters.unk6;
temp_t0 = temp_v1 + 0x10;
D_803B7088.unkA = temp_v1 - 0x10;
D_803B7088.unk8 = temp_t0;
D_803B7088.unkC = (temp_t0 / 0xC0) + 1;
temp_a2 = D_803B7088.unkC;
D_803B7088.unkE = (temp_v1 / temp_a2) & 0xFFF8;
temp_t1 = D_803B7088.unkE;
gAudioBufferParameters.unkA = temp_v1 - 0x10;
gAudioBufferParameters.unk8 = temp_t0;
gAudioBufferParameters.unkC = (temp_t0 / 0xC0) + 1;
temp_a2 = gAudioBufferParameters.unkC;
gAudioBufferParameters.unkE = (temp_v1 / temp_a2) & 0xFFF8;
temp_t1 = gAudioBufferParameters.unkE;
temp_f0 = temp_a2;
D_803B7088.unk10 = temp_t1 + 8;
D_803B7088.unk12 = temp_t1 - 8;
D_803B7088.unk14 = 32000.0f / temp_a3;
D_803B7088.unk1C = D_800F2E98 / temp_f0;
D_803B7088.unk18 = 1.0f / temp_f0;
D_803B70B0 = temp_s6->unk5;
gAudioBufferParameters.unk10 = temp_t1 + 8;
gAudioBufferParameters.unk12 = temp_t1 - 8;
gAudioBufferParameters.unk14 = 32000.0f / temp_a3;
gAudioBufferParameters.unk1C = D_800F2E98 / temp_f0;
gAudioBufferParameters.unk18 = 1.0f / temp_f0;
gMaxSimultaneousNotes = temp_s6->unk5;
D_803AFBC0 = temp_s6->unkC;
D_803B70B4 = ((temp_f0 * D_800F2E9C) / D_800EA5CC) / D_803B7178;
D_803B7088.unk0 = temp_s6->unk4;
temp_a1 = D_803B7088.unk0;
D_803B7088.unk6 = temp_v1 * temp_a1;
D_803B7088.unk8 = D_803B7088.unk8 * temp_a1;
D_803B7088.unkA = D_803B7088.unkA * temp_a1;
D_803B7088.unkC = temp_a2 * temp_a1;
D_803B70AC = (D_803B70B0 * 0x14 * D_803B7088.unkC) + (temp_s6->unk6 << 5) + 0x1E0;
gAudioBufferParameters.unk0 = temp_s6->unk4;
temp_a1 = gAudioBufferParameters.unk0;
gAudioBufferParameters.unk6 = temp_v1 * temp_a1;
gAudioBufferParameters.unk8 = gAudioBufferParameters.unk8 * temp_a1;
gAudioBufferParameters.unkA = gAudioBufferParameters.unkA * temp_a1;
gAudioBufferParameters.unkC = temp_a2 * temp_a1;
D_803B70AC = (gMaxSimultaneousNotes * 0x14 * gAudioBufferParameters.unkC) + (temp_s6->unk6 << 5) + 0x1E0;
temp_s0 = temp_s6->unk10 + temp_s6->unk14 + temp_s6->unk18;
temp_s1 = temp_s6->unk1C + temp_s6->unk20 + temp_s6->unk24;
temp_t2 = temp_s0 + temp_s1;
@@ -1082,14 +1085,14 @@ void func_800BA250(void) {
D_803B0370.unk8 = temp_s6->unk24;
func_800B9300(&D_803B0370);
func_800B8DE0();
D_803B1508 = func_800B8FFC(&D_803AFBE8, D_803B70B0 * 0xC0);
D_803B1508 = soundAlloc(&gNotesAndBuffersPool, gMaxSimultaneousNotes * 0xC0);
func_800BDD34();
func_800BD368();
D_803AFBC4 = func_800B8FFC(&D_803AFBE8, D_803B7088.unkC * D_803B70B0 * 0x10);
D_803AFBC4 = soundAlloc(&gNotesAndBuffersPool, gAudioBufferParameters.unkC * gMaxSimultaneousNotes * 0x10);
phi_s0 = &D_803B70C8;
do {
temp_s0_2 = phi_s0 + 4;
temp_s0_2->unk-4 = func_800B8FFC(&D_803AFBE8, D_803B70AC * 8);
temp_s0_2->unk-4 = soundAlloc(&gNotesAndBuffersPool, D_803B70AC * 8);
phi_s0 = temp_s0_2;
} while (temp_s0_2 != &D_803B70D0);
phi_s2 = &D_803AF790;
@@ -1109,9 +1112,9 @@ void func_800BA250(void) {
phi_s2_2->unk4 = temp_v0->unk0;
phi_s2_2->unk1 = 8;
phi_s2_2->unk8 = temp_v0->unk2;
phi_s2_2->unk18 = func_800B8FFC(&D_803AFBE8, (temp_t7 & 0xFFFF) * 2);
phi_s2_2->unk18 = soundAlloc(&gNotesAndBuffersPool, (temp_t7 & 0xFFFF) * 2);
temp_v1_2 = phi_s2_2->unk4;
phi_s2_2->unk1C = func_800B8FFC(&D_803AFBE8, phi_s2_2->unk6 * 2);
phi_s2_2->unk1C = soundAlloc(&gNotesAndBuffersPool, phi_s2_2->unk6 * 2);
phi_s2_2->unkC = 0;
phi_s2_2->unk10 = 0;
phi_s2_2->unk3 = 0;
@@ -1120,26 +1123,26 @@ void func_800BA250(void) {
if (temp_v1_2 != 1) {
phi_s2_2->unk0 = 1;
phi_s2_2->unkA = 0x8000 / temp_v1_2;
phi_s2_2->unk20 = func_800B8FFC(&D_803AFBE8, 0x20);
phi_s2_2->unk24 = func_800B8FFC(&D_803AFBE8, 0x20);
phi_s2_2->unk28 = func_800B8FFC(&D_803AFBE8, 0x20);
phi_s2_2->unk2C = func_800B8FFC(&D_803AFBE8, 0x20);
phi_s2_2->unk20 = soundAlloc(&gNotesAndBuffersPool, 0x20);
phi_s2_2->unk24 = soundAlloc(&gNotesAndBuffersPool, 0x20);
phi_s2_2->unk28 = soundAlloc(&gNotesAndBuffersPool, 0x20);
phi_s2_2->unk2C = soundAlloc(&gNotesAndBuffersPool, 0x20);
phi_s1 = 0;
if (D_803B7088.unkC > 0) {
if (gAudioBufferParameters.unkC > 0) {
phi_s0_2 = phi_s2_2;
do {
temp_v0_2 = func_800B8FFC(&D_803AFBE8, 0x300);
temp_v0_2 = soundAlloc(&gNotesAndBuffersPool, 0x300);
temp_t6 = temp_v0_2 + 0x180;
phi_s0_2->unk34 = temp_v0_2;
phi_s0_2->unk38 = temp_t6;
temp_v0_3 = func_800B8FFC(&D_803AFBE8, 0x300);
temp_v0_3 = soundAlloc(&gNotesAndBuffersPool, 0x300);
temp_t8 = temp_v0_3 + 0x180;
phi_s0_2->unk98 = temp_v0_3;
phi_s0_2->unk9C = temp_t8;
temp_s1_2 = phi_s1 + 1;
phi_s0_2 += 0x14;
phi_s1 = temp_s1_2;
} while (temp_s1_2 < D_803B7088.unkC);
} while (temp_s1_2 < gAudioBufferParameters.unkC);
}
}
temp_s5 = phi_s5 + 1;
@@ -1147,7 +1150,7 @@ void func_800BA250(void) {
phi_s2_2 += 0x108;
} while (temp_s5 < D_803AFBC3);
}
func_800BB030(D_803B70B0);
func_800BB030(gMaxSimultaneousNotes);
osWritebackDCacheAll();
}
#else
+27
View File
@@ -0,0 +1,27 @@
#ifndef AUDIO_HEAP_H
#define AUDIO_HEAP_H
#include <PR/ultratypes.h>
#include "internal.h"
#define SOUND_LOAD_STATUS_NOT_LOADED 0
#define SOUND_LOAD_STATUS_IN_PROGRESS 1
#define SOUND_LOAD_STATUS_COMPLETE 2
#define SOUND_LOAD_STATUS_DISCARDABLE 3
#define SOUND_LOAD_STATUS_4 4
#define SOUND_LOAD_STATUS_5 5
#define IS_BANK_LOAD_COMPLETE(bankId) (gBankLoadStatus[bankId] >= SOUND_LOAD_STATUS_COMPLETE)
#define IS_SEQ_LOAD_COMPLETE(seqId) (gSeqLoadStatus[seqId] >= SOUND_LOAD_STATUS_COMPLETE)
struct SoundAllocPool {
u8 *start;
u8 *cur;
u32 size;
s32 numAllocatedEntries;
}; // size = 0x10
extern struct SoundAllocPool gNotesAndBuffersPool;
#endif // AUDIO_HEAP_H
+75
View File
@@ -3,11 +3,57 @@
#include <PR/ultratypes.h>
// No-op printf macro which leaves string literals in rodata in IDO. IDO
// doesn't support variadic macros, so instead we let the parameter list
// expand to a no-op comma expression. Another possibility is that it might
// have expanded to something with "if (0)". See also goddard/gd_main.h.
// On US/JP, -sopt optimizes away these except for external.c.
#ifdef __sgi
#define stubbed_printf
#else
#define stubbed_printf(...)
#endif
#define stubbed_printf_0(msg) stubbed_printf(msg)
#define stubbed_printf_1(msg, a) stubbed_printf(msg, a)
#define stubbed_printf_2(msg, a, b) stubbed_printf(msg, a, b)
#define stubbed_printf_3(msg, a, b, c) stubbed_printf(msg, a, b, c)
struct AdsrEnvelope {
s16 delay;
s16 arg;
}; // size = 0x4
struct AdpcmLoop {
u32 start;
u32 end;
u32 count;
u32 pad;
s16 state[16]; // only exists if count != 0. 8-byte aligned
};
struct AdpcmBook {
s32 order;
s32 npredictors;
s16 book[1]; // size 8 * order * npredictors. 8-byte aligned
};
struct AudioBankSample {
u8 unused;
u8 loaded;
u8 *sampleAddr;
struct AdpcmLoop *loop;
struct AdpcmBook *book;
u32 sampleSize; // never read. either 0 or 1 mod 9, depending on padding
};
struct AudioBankSound {
struct AudioBankSample *sample;
f32 tuning; // frequency scale factor
}; // size = 0x8
struct NoteSub
{
/*0x00*/ volatile u8 enabled : 1;
@@ -35,4 +81,33 @@ struct NoteSub
} sound;
};
struct AudioSessionSettings {
/*0x00*/ u32 frequency;
/*0x04*/ u8 maxSimultaneousNotes;
/*0x05*/ u8 reverbDownsampleRate; // always 1
/*0x06*/ u16 reverbWindowSize;
/*0x08*/ u16 reverbGain;
/*0x0A*/ u16 volume;
/*0x0C*/ u32 persistentSeqMem;
/*0x10*/ u32 persistentBankMem;
/*0x14*/ u32 temporarySeqMem;
/*0x18*/ u32 temporaryBankMem;
}; // size = 0x1C
struct AudioBufferParametersEU {
/*0x00*/ s16 presetUnk4; // audio frames per vsync?
/*0x02*/ u16 frequency;
/*0x04*/ u16 aiFrequency; // ?16
/*0x06*/ s16 samplesPerFrameTarget;
/*0x08*/ s16 maxAiBufferLength;
/*0x0A*/ s16 minAiBufferLength;
/*0x0C*/ s16 updatesPerFrame;
/*0x0E*/ s16 samplesPerUpdate;
/*0x10*/ s16 samplesPerUpdateMax;
/*0x12*/ s16 samplesPerUpdateMin;
/*0x14*/ f32 resampleRate; // contains 32000.0f / frequency
/*0x18*/ f32 updatesPerFrameInv; // 1.0f / updatesPerFrame
/*0x1C*/ f32 unkUpdatesPerFrameScaled; // 3.0f / (1280.0f * updatesPerFrame)
};
#endif
+343 -370
View File
@@ -1,145 +1,248 @@
#include <ultra64.h>
#include <macros.h>
#include "load.h"
#include "data.h"
#include "heap.h"
#include "internal.h"
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
struct SharedDma {
/*0x0*/ u8 *buffer; // target, points to pre-allocated buffer
/*0x4*/ uintptr_t source; // device address
/*0x8*/ u16 sizeUnused; // set to bufSize, never read
/*0xA*/ u16 bufSize; // size of buffer
/*0xC*/ u8 unused2; // set to 0, never read
/*0xD*/ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0
/*0xE*/ u8 ttl; // duration after which the DMA can be discarded
}; // size = 0x10
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? osPiStartDma(? *, ?, ?, s32, void *, u32, OSMesgQueue *); // extern
extern OSMesgQueue D_803B6720;
extern ? D_803B6740;
extern OSIoMesg D_803B6740;
void func_800BAA80(s32 arg0, void *arg1, u32 arg2) {
osInvalDCache(arg1, arg2);
osPiStartDma(&D_803B6740, 1, 0, arg0, arg1, arg2, &D_803B6720);
osRecvMesg(&D_803B6720, NULL, 1);
extern OSMesgQueue gCurrAudioFrameDmaQueue; // gCurrAudioFrameDmaQueue
extern OSMesg gCurrAudioFrameDmaMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE]; // gCurrAudioFrameDmaMesgBufs
extern OSIoMesg gCurrAudioFrameDmaIoMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE]; // gCurrAudioFrameDmaIoMesgBufs
extern struct SharedDma sSampleDmas[0x60]; // sSampleDmas
extern u32 gSampleDmaNumListItems; // gSampleDmaNumListItems
extern u32 sSampleDmaListSize1; // sSampleDmaListSize1
extern s32 D_803B6E60; // sUnused80226B40
extern u8 sSampleDmaReuseQueue1[256]; // sSampleDmaReuseQueue1
extern u8 sSampleDmaReuseQueue2[256]; // sSampleDmaReuseQueue2
extern u8 sSampleDmaReuseQueueTail1; // sSampleDmaReuseQueueTail1
extern u8 sSampleDmaReuseQueueTail2; // sSampleDmaReuseQueueTail2
extern u8 sSampleDmaReuseQueueHead1; // sSampleDmaReuseQueueHead1
extern u8 sSampleDmaReuseQueueHead2; // sSampleDmaReuseQueueHead2
extern void *soundAlloc(struct SoundAllocPool *pool, u32 size);
/**
* Performs an immediate DMA copy
*/
// audio_dma_copy_immediate
void audio_dma_copy_immediate(uintptr_t devAddr, void *vAddr, size_t nbytes) {
stubbed_printf_3("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
osInvalDCache(vAddr, nbytes);
osPiStartDma(&D_803B6740, OS_MESG_PRI_HIGH, OS_READ, devAddr, vAddr, nbytes, &D_803B6720);
osRecvMesg(&D_803B6720, NULL, OS_MESG_BLOCK);
stubbed_printf_0("Romcopyend\n");
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAA80.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? osPiStartDma(s32, ?, ?, s32, void *, u32, s32); // extern
const char audioString34[] = "CAUTION:WAVE CACHE FULL %d";
const char audioString35[] = "LOAD Rom :%x -> Ram :%x Len:%x\n";
const char audioString36[] = "BASE %x %x\n";
const char audioString37[] = "LOAD %x %x %x\n";
const char audioString38[] = "INSTTOP %x\n";
const char audioString39[] = "INSTMAP[0] %x\n";
const char audioString40[] = "already flags %d\n";
const char audioString41[] = "already flags %d\n";
const char audioString42[] = "ERR:SLOW BANK DMA BUSY\n";
const char audioString43[] = "ERR:SLOW DMA BUSY\n";
const char audioString44[] = "Check %d bank %d\n";
const char audioString45[] = "Cache Check\n";
const char audioString46[] = "NO BANK ERROR\n";
const char audioString47[] = "BANK %d LOADING START\n";
const char audioString48[] = "BANK %d LOAD MISS (NO MEMORY)!\n";
const char audioString49[] = "BANK %d ALREADY CACHED\n";
const char audioString50[] = "BANK LOAD MISS! FOR %d\n";
void func_800BAAF8(s32 arg0, void *arg1, u32 arg2, s32 arg3, s32 arg4) {
osInvalDCache(arg1, arg2);
osPiStartDma(arg4, 0, 0, arg0, arg1, arg2, arg3);
const char audioString51[] = "Seq %d Loading Start\n";
const char audioString52[] = "Heap Overflow Error\n";
const char asdf[] = "SEQ %d ALREADY CACHED\n";
const char fdsa[] = "Ok,one bank slow load Start \n";
const char af[] = "Sorry,too many %d bank is none.fast load Start \n";
/**
* Performs an asynchronus (normal priority) DMA copy
*/
//audio_dma_copy_async
void func_800BAAF8(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *queue, OSIoMesg *mesg) {
osInvalDCache(vAddr, nbytes);
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, devAddr, vAddr, nbytes, queue);
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAAF8.s")
#endif
//#else
//GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAAF8.s")
//#endif
#ifdef MIPS_TO_C
//#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? osPiStartDma(s32, ?, ?, s32, void *, u32, s32); // extern
//? osPiStartDma(s32, ?, ?, s32, void *, u32, s32); // extern
void func_800BAB58(s32 *arg0, void **arg1, s32 *arg2, s32 arg3, s32 arg4) {
s32 temp_v0;
u32 phi_s0;
temp_v0 = *arg2;
phi_s0 = temp_v0;
if (temp_v0 >= 0x1000) {
phi_s0 = 0x1000;
}
*arg2 = temp_v0 - phi_s0;
osInvalDCache(*arg1, phi_s0);
osPiStartDma(arg4, 0, 0, *arg0, *arg1, phi_s0, arg3);
*arg0 = *arg0 + phi_s0;
*arg1 = *arg1 + phi_s0;
/**
* Performs a partial asynchronous (normal priority) DMA copy. This is limited
* to 0x1000 bytes transfer at once.
*/
// audio_dma_partial_copy_async
void func_800BAB58(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) {
ssize_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining);
*remaining -= transfer;
osInvalDCache(*vAddr, transfer);
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue);
*devAddr += transfer;
*vAddr += transfer;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAB58.s")
#endif
//#else
//GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAB58.s")
//#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
extern ? D_803B6758;
extern u32 D_803B6E58;
extern u32 D_803B6E5C;
extern s32 D_803B6E60;
extern ? D_803B6E68;
extern ? D_803B6F68;
extern u8 D_803B706A;
extern u8 D_803B706B;
// decrease_sample_dma_ttls
void func_800BAC04(void) {
u32 temp_v0;
u32 temp_v0_2;
u8 temp_t4;
u8 temp_t6;
u8 temp_t6_2;
u8 temp_t8;
u8 temp_v1;
u8 temp_v1_2;
u8 temp_v1_3;
u8 temp_v1_4;
? *phi_a0;
s8 phi_v0;
void *phi_a0_2;
s8 phi_v0_2;
void func_800BAC04() {
u32 i;
phi_a0 = &D_803B6758;
phi_v0 = 0;
if (D_803B6E5C != 0) {
do {
temp_v1 = phi_a0->unkE;
temp_t6 = temp_v1 - 1;
if (temp_v1 != 0) {
phi_a0->unkE = temp_t6;
if ((temp_t6 & 0xFF) == 0) {
temp_v1_2 = D_803B706A;
temp_t8 = D_803B706A;
*(&D_803B6E68 + temp_v1_2) = phi_v0;
D_803B706A = temp_v1_2 + 1;
phi_a0->unkD = temp_t8;
}
for (i = 0; i < sSampleDmaListSize1; i++) {
struct SharedDma *temp = &sSampleDmas[i];
if (temp->ttl != 0) {
temp->ttl--;
if (temp->ttl == 0) {
temp->reuseIndex = sSampleDmaReuseQueueHead1;
sSampleDmaReuseQueue1[sSampleDmaReuseQueueHead1++] = (u8) i;
}
temp_v0 = phi_v0 + 1;
phi_a0 += 0x10;
phi_v0 = temp_v0;
} while (temp_v0 < D_803B6E5C);
}
}
phi_v0_2 = D_803B6E5C;
if (D_803B6E5C < D_803B6E58) {
phi_a0_2 = (D_803B6E5C * 0x10) + &D_803B6758;
do {
temp_v1_3 = phi_a0_2->unkE;
temp_t4 = temp_v1_3 - 1;
if (temp_v1_3 != 0) {
phi_a0_2->unkE = temp_t4;
if ((temp_t4 & 0xFF) == 0) {
temp_v1_4 = D_803B706B;
temp_t6_2 = D_803B706B;
*(&D_803B6F68 + temp_v1_4) = phi_v0_2;
D_803B706B = temp_v1_4 + 1;
phi_a0_2->unkD = temp_t6_2;
}
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
struct SharedDma *temp = &sSampleDmas[i];
if (temp->ttl != 0) {
temp->ttl--;
if (temp->ttl == 0) {
temp->reuseIndex = sSampleDmaReuseQueueHead2;
sSampleDmaReuseQueue2[sSampleDmaReuseQueueHead2++] = (u8) i;
}
temp_v0_2 = phi_v0_2 + 1;
phi_a0_2 += 0x10;
phi_v0_2 = temp_v0_2;
} while (temp_v0_2 < D_803B6E58);
}
}
D_803B6E60 = 0;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAC04.s")
#endif
#ifdef MIPS_TO_C
// dma_sample_data 3000 score diff
void *func_800BAD0C(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
s32 hasDma = FALSE;
struct SharedDma *dma;
uintptr_t dmaDevAddr;
u32 transfer;
u32 i;
u32 dmaIndex;
ssize_t bufferPos;
UNUSED u32 pad;
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) {
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
dma = &sSampleDmas[i];
bufferPos = devAddr - dma->source;
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
// We already have a DMA request for this memory range.
if (dma->ttl == 0 && sSampleDmaReuseQueueTail2 != sSampleDmaReuseQueueHead2) {
// Move the DMA out of the reuse queue, by swapping it with the
// tail, and then incrementing the tail.
if (dma->reuseIndex != sSampleDmaReuseQueueTail2) {
sSampleDmaReuseQueue2[dma->reuseIndex] =
sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2];
sSampleDmas[sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2]].reuseIndex =
dma->reuseIndex;
}
sSampleDmaReuseQueueTail2++;
}
dma->ttl = 60;
*dmaIndexRef = (u8) i;
return &dma->buffer[(devAddr - dma->source)];
}
}
if (sSampleDmaReuseQueueTail2 != sSampleDmaReuseQueueHead2 && arg2 != 0) {
// Allocate a DMA from reuse queue 2. This queue can be empty, since
// TTL 60 is pretty large.
dmaIndex = sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2];
sSampleDmaReuseQueueTail2++;
dma = sSampleDmas + dmaIndex;
hasDma = TRUE;
}
} else {
dma = sSampleDmas;
dma += *dmaIndexRef;
bufferPos = devAddr - dma->source;
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
// We already have DMA for this memory range.
if (dma->ttl == 0) {
// Move the DMA out of the reuse queue, by swapping it with the
// tail, and then incrementing the tail.
if (dma->reuseIndex != sSampleDmaReuseQueueTail1) {
if (1) {
}
sSampleDmaReuseQueue1[dma->reuseIndex] =
sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1];
sSampleDmas[sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1]].reuseIndex =
dma->reuseIndex;
}
sSampleDmaReuseQueueTail1++;
}
dma->ttl = 2;
return dma->buffer + (devAddr - dma->source);
}
}
if (!hasDma) {
// Allocate a DMA from reuse queue 1. This queue will hopefully never
// be empty, since TTL 2 is so small.
dmaIndex = sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1++];
dma = sSampleDmas + dmaIndex;
hasDma = TRUE;
}
transfer = dma->bufSize;
dmaDevAddr = devAddr & ~0xF;
dma->ttl = 2;
dma->source = dmaDevAddr;
dma->sizeUnused = transfer;
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount++], OS_MESG_PRI_NORMAL,
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
*dmaIndexRef = dmaIndex;
return (devAddr - dmaDevAddr) + dma->buffer;
}
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? osPiStartDma(void *, ?, ?, s32, s32, s32, ? *); // extern
extern ? D_803B6008;
extern ? D_803B6120;
extern ? D_803B6758;
extern u32 D_803B6E58;
extern u32 D_803B6E5C;
extern ? D_803B6E68;
extern ? D_803B6F68;
extern u8 D_803B7068;
extern u8 D_803B7069;
extern u8 D_803B706B;
extern s32 D_803B70BC;
extern ? gCurrAudioFrameDmaQueue;
extern ? gCurrAudioFrameDmaIoMesgBufs;
extern ? sSampleDmas;
extern u32 gSampleDmaNumListItems;
extern u32 sSampleDmaListSize1;
extern ? sSampleDmaReuseQueue1;
extern ? sSampleDmaReuseQueue2;
extern u8 sSampleDmaReuseQueueTail1;
extern u8 sSampleDmaReuseQueueTail2;
extern u8 sSampleDmaReuseQueueHead2;
extern s32 gCurrAudioFrameDmaCount;
s32 func_800BAD0C(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) {
void *sp40;
@@ -178,25 +281,25 @@ s32 func_800BAD0C(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) {
phi_t3 = 0;
phi_t3 = 0;
if ((arg2 != 0) || (temp_a1 = D_803B6E5C, temp_v0 = *arg3, phi_v1 = 0, ((temp_v0 < temp_a1) == 0))) {
temp_a1_2 = D_803B6E58;
temp_v1_3 = D_803B6E5C;
if ((arg2 != 0) || (temp_a1 = sSampleDmaListSize1, temp_v0 = *arg3, phi_v1 = 0, ((temp_v0 < temp_a1) == 0))) {
temp_a1_2 = gSampleDmaNumListItems;
temp_v1_3 = sSampleDmaListSize1;
phi_v1_2 = temp_v1_3;
if (temp_v1_3 < temp_a1_2) {
phi_a0 = (temp_v1_3 * 0x10) + &D_803B6758;
phi_a0 = (temp_v1_3 * 0x10) + &sSampleDmas;
loop_4:
temp_v0_4 = arg0 - phi_a0->unk4;
if ((temp_v0_4 >= 0) && ((phi_a0->unkA - arg1) >= temp_v0_4)) {
if (phi_a0->unkE == 0) {
temp_a1_3 = D_803B7069;
if (D_803B706B != temp_a1_3) {
temp_a1_3 = sSampleDmaReuseQueueTail2;
if (sSampleDmaReuseQueueHead2 != temp_a1_3) {
temp_a3 = phi_a0->unkD;
temp_v0_5 = &D_803B6F68 + temp_a1_3;
temp_v0_5 = &sSampleDmaReuseQueue2 + temp_a1_3;
if (temp_a1_3 != temp_a3) {
*(&D_803B6F68 + temp_a3) = *temp_v0_5;
(&D_803B6758 + (*temp_v0_5 * 0x10))->unkD = phi_a0->unkD;
*(&sSampleDmaReuseQueue2 + temp_a3) = *temp_v0_5;
(&sSampleDmas + (*temp_v0_5 * 0x10))->unkD = phi_a0->unkD;
}
D_803B7069 = temp_a1_3 + 1;
sSampleDmaReuseQueueTail2 = temp_a1_3 + 1;
}
}
phi_a0->unkE = 0x3C;
@@ -213,18 +316,18 @@ loop_4:
goto loop_4;
}
block_14:
temp_a1_4 = D_803B7069;
temp_a1_4 = sSampleDmaReuseQueueTail2;
phi_t0_2 = sp40;
if ((D_803B706B != temp_a1_4) && (arg2 != 0)) {
temp_t2 = *(&D_803B6F68 + temp_a1_4);
D_803B7069 = temp_a1_4 + 1;
if ((sSampleDmaReuseQueueHead2 != temp_a1_4) && (arg2 != 0)) {
temp_t2 = *(&sSampleDmaReuseQueue2 + temp_a1_4);
sSampleDmaReuseQueueTail2 = temp_a1_4 + 1;
sp30 = temp_t2;
phi_t3 = 1;
phi_t0_2 = &D_803B6758 + (temp_t2 * 0x10);
phi_t0_2 = &sSampleDmas + (temp_t2 * 0x10);
}
goto block_27;
}
temp_t0 = &D_803B6758 + (temp_v0 * 0x10);
temp_t0 = &sSampleDmas + (temp_v0 * 0x10);
phi_t0 = temp_t0;
phi_t0_2 = temp_t0;
if (temp_a1 != 0) {
@@ -234,19 +337,19 @@ loop_19:
phi_v1 = temp_v1;
if ((temp_v0_2 >= 0) && ((phi_t0->unkA - arg1) >= temp_v0_2)) {
if (phi_t0->unkE == 0) {
temp_v1_2 = D_803B7068;
temp_v1_2 = sSampleDmaReuseQueueTail1;
temp_a0 = phi_t0->unkD;
temp_v0_3 = &D_803B6E68 + temp_v1_2;
temp_v0_3 = &sSampleDmaReuseQueue1 + temp_v1_2;
if (temp_v1_2 != temp_a0) {
*(&D_803B6E68 + temp_a0) = *temp_v0_3;
(&D_803B6758 + (*temp_v0_3 * 0x10))->unkD = phi_t0->unkD;
*(&sSampleDmaReuseQueue1 + temp_a0) = *temp_v0_3;
(&sSampleDmas + (*temp_v0_3 * 0x10))->unkD = phi_t0->unkD;
}
D_803B7068 = temp_v1_2 + 1;
sSampleDmaReuseQueueTail1 = temp_v1_2 + 1;
}
phi_t0->unkE = 2;
return (phi_t0->unk0 + arg0) - phi_t0->unk4;
}
temp_t0_2 = &D_803B6758 + (phi_v1 * 0x10);
temp_t0_2 = &sSampleDmas + (phi_v1 * 0x10);
phi_t0 = temp_t0_2;
phi_t0_2 = temp_t0_2;
if (temp_v1 >= temp_a1) {
@@ -257,10 +360,10 @@ loop_19:
block_27:
phi_t2 = sp30;
if (phi_t3 == 0) {
temp_v1_5 = D_803B7068;
temp_t2_2 = *(&D_803B6E68 + temp_v1_5);
D_803B7068 = temp_v1_5 + 1;
phi_t0_2 = &D_803B6758 + (temp_t2_2 * 0x10);
temp_v1_5 = sSampleDmaReuseQueueTail1;
temp_t2_2 = *(&sSampleDmaReuseQueue1 + temp_v1_5);
sSampleDmaReuseQueueTail1 = temp_v1_5 + 1;
phi_t0_2 = &sSampleDmas + (temp_t2_2 * 0x10);
phi_t2 = temp_t2_2;
}
temp_v0_6 = phi_t0_2->unkA;
@@ -268,12 +371,12 @@ block_27:
phi_t0_2->unkE = 2;
phi_t0_2->unk4 = temp_s0;
phi_t0_2->unk8 = temp_v0_6;
temp_v1_6 = D_803B70BC;
temp_v1_6 = gCurrAudioFrameDmaCount;
temp_t9 = temp_v1_6 * 0x18;
D_803B70BC = temp_v1_6 + 1;
gCurrAudioFrameDmaCount = temp_v1_6 + 1;
sp30 = phi_t2;
sp40 = phi_t0_2;
osPiStartDma(temp_t9 + &D_803B6120, 0, 0, temp_s0, phi_t0_2->unk0, temp_v0_6, &D_803B6008);
sp40 = phi_t0_2;./
osPiStartDma(temp_t9 + &gCurrAudioFrameDmaIoMesgBufs, 0, 0, temp_s0, phi_t0_2->unk0, temp_v0_6, &gCurrAudioFrameDmaQueue);
*arg3 = phi_t2;
return (arg0 - temp_s0) + phi_t0_2->unk0;
}
@@ -281,223 +384,95 @@ block_27:
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BAD0C.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32, u32); // extern
extern ? D_803BFBE8;
extern ? D_803B6758;
extern u32 D_803B6E58;
extern u32 D_803B6E5C;
extern s8 D_803B6E68;
extern ? D_803B6F68;
extern s8 D_803B7068;
extern s8 D_803B7069;
extern s8 D_803B706A;
extern s8 D_803B706B;
extern s16 D_803B7088;
extern s32 D_803B70A8;
extern s32 D_803B70B0;
void func_800BB030(s32 arg0, u32 arg2) {
s32 temp_a1;
s32 temp_a1_2;
s32 temp_s0;
s32 temp_s0_3;
s32 temp_v0;
s32 temp_v0_3;
s8 temp_v0_4;
u32 temp_a1_3;
u32 temp_a2;
u32 temp_a2_2;
u32 temp_a2_3;
u32 temp_s0_2;
u32 temp_s0_4;
u32 temp_v0_2;
u32 temp_v0_5;
void *temp_v1;
void *temp_v1_2;
s32 phi_a1;
u32 phi_a2;
s32 phi_s0;
s8 phi_s0_2;
s8 *phi_v0;
? *phi_v1;
void *phi_v0_2;
s32 phi_a1_2;
s32 phi_s0_3;
u32 phi_a2_2;
s8 phi_s0_4;
s8 *phi_a0;
s8 phi_v0_3;
void *phi_v1_2;
s32 phi_a3;
void *phi_v0_4;
u32 phi_a2_3;
extern u32 D_803B70A8; // sDmaBufSize
extern s32 gMaxSimultaneousNotes; // gMaxSimultaneousNotes
extern struct AudioBufferParametersEU gAudioBufferParameters; // gAudioBufferParameters
//extern struct SoundAllocPool gNotesAndBuffersPool; // remove when possible. This is in heap.h
// init_sample_dma_buffers
void func_800BB030(UNUSED s32 arg0) {
s32 i;
#define j i
D_803B70A8 = 0x5A0;
phi_a1 = 0x5A0;
phi_a2 = arg2;
phi_s0 = 0;
phi_s0_3 = 0;
if ((D_803B70B0 * 3 * D_803B7088) > 0) {
loop_1:
temp_v0 = func_800B8FFC(&D_803BFBE8, phi_a1, phi_a2);
temp_a2 = D_803B6E58;
temp_v1 = &D_803B6758 + (temp_a2 * 0x10);
temp_v1->unk0 = temp_v0;
phi_a2 = temp_a2;
if (temp_v0 == 0) {
} else {
temp_a1 = D_803B70A8;
temp_s0 = phi_s0 + 1;
temp_v1->unk4 = 0;
temp_v1->unk8 = 0;
temp_v1->unkC = 0;
temp_v1->unkE = 0;
D_803B6E58 = temp_a2 + 1;
temp_v1->unkA = temp_a1;
phi_a1 = temp_a1;
phi_s0 = temp_s0;
if (temp_s0 >= (D_803B70B0 * 3 * D_803B7088)) {
} else {
goto loop_1;
}
for (i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++)
{
sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, D_803B70A8);
if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
break;
}
sSampleDmas[gSampleDmaNumListItems].bufSize = D_803B70A8;
sSampleDmas[gSampleDmaNumListItems].source = 0;
sSampleDmas[gSampleDmaNumListItems].sizeUnused = 0;
sSampleDmas[gSampleDmaNumListItems].unused2 = 0;
sSampleDmas[gSampleDmaNumListItems].ttl = 0;
gSampleDmaNumListItems++;
}
temp_a2_2 = D_803B6E58;
phi_s0_2 = 0;
phi_a2_2 = temp_a2_2;
if (temp_a2_2 != 0) {
phi_v0 = &D_803B6E68;
phi_v1 = &D_803B6758;
do {
*phi_v0 = phi_s0_2;
phi_v1->unkD = phi_s0_2;
temp_s0_2 = phi_s0_2 + 1;
phi_s0_2 = temp_s0_2;
phi_v0 += 1;
phi_v1 += 0x10;
} while (temp_s0_2 < temp_a2_2);
for (i = 0; (u32) i < gSampleDmaNumListItems; i++) {
sSampleDmaReuseQueue1[i] = (u8) i;
sSampleDmas[i].reuseIndex = (u8) i;
}
phi_a3 = temp_a2_2;
if (temp_a2_2 < 0x100) {
phi_v0_2 = temp_a2_2 + &D_803B6E68;
do {
temp_v0_2 = phi_v0_2 + 1;
temp_v0_2->unk-1 = 0;
phi_v0_2 = temp_v0_2;
} while (temp_v0_2 < &D_803B6F68);
for (j = gSampleDmaNumListItems; j < 0x100; j++) {
sSampleDmaReuseQueue1[j] = 0;
}
D_803B7068 = 0;
D_803B706A = temp_a2_2;
D_803B6E5C = temp_a2_2;
sSampleDmaReuseQueueTail1 = 0;
sSampleDmaReuseQueueHead1 = (u8) gSampleDmaNumListItems;
sSampleDmaListSize1 = gSampleDmaNumListItems;
D_803B70A8 = 0x180;
if (D_803B70B0 > 0) {
phi_a1_2 = 0x180;
loop_13:
temp_v0_3 = func_800B8FFC(&D_803BFBE8, phi_a1_2, D_803B6E58);
temp_a2_3 = D_803B6E58;
temp_s0_3 = phi_s0_3 + 1;
temp_v1_2 = &D_803B6758 + (temp_a2_3 * 0x10);
temp_v1_2->unk0 = temp_v0_3;
phi_s0_3 = temp_s0_3;
phi_a2_3 = temp_a2_3;
if (temp_v0_3 == 0) {
} else {
temp_a1_2 = D_803B70A8;
temp_v1_2->unk4 = 0;
temp_v1_2->unk8 = 0;
temp_v1_2->unkC = 0;
temp_v1_2->unkE = 0;
D_803B6E58 = temp_a2_3 + 1;
temp_v1_2->unkA = temp_a1_2;
phi_a1_2 = temp_a1_2;
if (temp_s0_3 >= D_803B70B0) {
phi_a2_3 = D_803B6E58;
} else {
goto loop_13;
}
for (i = 0; i < gMaxSimultaneousNotes; i++) {
sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, D_803B70A8);
if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
break;
}
phi_a2_2 = phi_a2_3;
phi_a3 = phi_a2_3;
sSampleDmas[gSampleDmaNumListItems].bufSize = D_803B70A8;
sSampleDmas[gSampleDmaNumListItems].source = 0;
sSampleDmas[gSampleDmaNumListItems].sizeUnused = 0;
sSampleDmas[gSampleDmaNumListItems].unused2 = 0;
sSampleDmas[gSampleDmaNumListItems].ttl = 0;
gSampleDmaNumListItems++;
}
temp_a1_3 = D_803B6E5C;
phi_s0_4 = temp_a1_3;
if (temp_a1_3 < phi_a2_2) {
temp_v0_4 = temp_a1_3 * 0;
phi_a0 = temp_v0_4 + &D_803B6F68;
phi_v0_3 = temp_v0_4;
phi_v1_2 = (temp_a1_3 * 0x10) + &D_803B6758;
do {
*phi_a0 = phi_s0_4;
temp_s0_4 = phi_s0_4 + 1;
phi_v1_2->unkD = phi_v0_3;
phi_s0_4 = temp_s0_4;
phi_a0 += 1;
phi_v0_3 += 1;
phi_v1_2 += 0x10;
} while (temp_s0_4 < phi_a2_2);
for (i = sSampleDmaListSize1; (u32) i < gSampleDmaNumListItems; i++) {
sSampleDmaReuseQueue2[i - sSampleDmaListSize1] = (u8) i;
sSampleDmas[i].reuseIndex = (u8)(i - sSampleDmaListSize1);
}
if (phi_a3 < 0x100) {
phi_v0_4 = phi_a3 + &D_803B6F68;
do {
temp_v0_5 = phi_v0_4 + 1;
temp_v0_5->unk-1 = temp_a1_3;
phi_v0_4 = temp_v0_5;
} while (temp_v0_5 < &D_803B7068);
// This probably meant to touch the range size1..size2 as well... but it
// doesn't matter, since these values are never read anyway.
for (j = gSampleDmaNumListItems; j < 0x100; j++) {
sSampleDmaReuseQueue2[j] = sSampleDmaListSize1;
}
D_803B7069 = 0;
D_803B706B = phi_a2_2 - temp_a1_3;
sSampleDmaReuseQueueTail2 = 0;
sSampleDmaReuseQueueHead2 = gSampleDmaNumListItems - sSampleDmaListSize1;
#undef j
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB030.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32, void *); // extern
? func_800BAA80(s32, s32, s32, void *); // extern
extern ? D_803BFBE8;
// Similar to patch_sound, but not really
s32 func_800BB304(struct AudioBankSample *sample) {
//struct AudioBankSample *sample = sound->sample;
UNUSED u8 *mem;
void func_800BB304(void *arg0) {
s32 sp1C;
s32 temp_a0;
s32 temp_a1;
s32 temp_a1_2;
s32 temp_a2;
s32 temp_v0;
void *temp_a3;
void *temp_a3_2;
temp_a3 = arg0;
if (arg0 == 0) {
return;
if (sample == (void *)NULL) {
return -1;
}
if (temp_a3->unk1 == 1) {
temp_a1 = temp_a3->unk10;
arg0 = temp_a3;
temp_v0 = func_800B8FFC(&D_803BFBE8, temp_a1, temp_a3);
temp_a3_2 = arg0;
temp_a1_2 = temp_v0;
if (temp_v0 == 0) {
return;
if (sample->loaded == 1) {
//temp_a1 = sound->sampleAddr // unk10;
mem = soundAlloc(&gNotesAndBuffersPool, sample->sampleSize);
//temp_a1_2 = temp_v0;
if (mem == (void *)NULL) {
return -1;
}
temp_a0 = temp_a3_2->unk4;
temp_a2 = temp_a3_2->unk10;
arg0 = temp_a3_2;
sp1C = temp_a1_2;
func_800BAA80(temp_a0, temp_a1_2, temp_a2, temp_a3_2);
arg0->unk1 = 0x81;
arg0->unk4 = temp_a1_2;
// Duplicate return node #6. Try simplifying control flow for better match
audio_dma_copy_immediate((uintptr_t)sample->sampleAddr, mem, sample->sampleSize);
sample->loaded = 0x81;
sample->sampleAddr = mem; // sound->unk4
}
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB304.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
@@ -574,9 +549,9 @@ GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB43C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, s32, s32); // extern
? func_800BAA80(s32, s32, s32, s32); // extern
extern ? D_803BFBE8;
s32 soundAlloc(? *, s32, s32); // extern
? audio_dma_copy_immediate(s32, s32, s32, s32); // extern
extern ? gNotesAndBuffersPool;
void func_800BB484(void **arg0, s32 arg1, s32 arg2) {
void *sp2C;
@@ -604,14 +579,14 @@ void func_800BB484(void **arg0, s32 arg1, s32 arg2) {
temp_a3_2 = temp_a3->unk4 + arg2;
sp28 = temp_a3_2;
sp2C = temp_a3;
temp_v0_2 = func_800B8FFC(&D_803BFBE8, temp_a3->unk10, temp_a3_2);
temp_v0_2 = soundAlloc(&gNotesAndBuffersPool, temp_a3->unk10, temp_a3_2);
if (temp_v0_2 == 0) {
temp_a3->unk4 = temp_a3_2;
temp_a3->unk1 = 1;
} else {
sp24 = temp_v0_2;
sp2C = temp_a3;
func_800BAA80(temp_a3_2, temp_v0_2, temp_a3->unk10, temp_a3_2);
audio_dma_copy_immediate(temp_a3_2, temp_v0_2, temp_a3->unk10, temp_a3_2);
temp_a3->unk1 = 0x81;
temp_a3->unk4 = temp_v0_2;
}
@@ -723,10 +698,12 @@ void func_800BB624(void **arg0, ? arg1, s32 arg2, s32 arg3) {
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB624.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B93BC(? *, ?, s32, ?, s32); // extern
? func_800BAA80(s32, s32, s32); // extern
? audio_dma_copy_immediate(s32, s32, s32); // extern
? func_800BB584(s32); // extern
extern ? D_803AFE18;
extern ? D_803B03C0;
@@ -751,7 +728,7 @@ s32 func_800BB780(s32 arg0, ? arg1) {
return 0;
}
sp2C = temp_v0_2;
func_800BAA80(sp28 + 0x10, temp_v0_2, temp_a2);
audio_dma_copy_immediate(sp28 + 0x10, temp_v0_2, temp_a2);
(D_803B7080 + (arg0 * 0xC))->unk4 = sp2C + 4;
func_800BB584(arg0);
temp_v0_3 = arg0 + &D_803B03C0;
@@ -819,7 +796,7 @@ GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB864.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B93BC(? *, ?, s32, ?, s32); // extern
? func_800BAA80(s32, s32, s32); // extern
? audio_dma_copy_immediate(s32, s32, s32); // extern
extern ? D_803AFC48;
extern ? D_803B0400;
extern s32 D_803B706C;
@@ -842,7 +819,7 @@ s32 func_800BB99C(s32 arg0, ? arg1) {
return 0;
}
sp28 = temp_v0;
func_800BAA80(sp24, temp_v0, sp2C);
audio_dma_copy_immediate(sp24, temp_v0, sp2C);
temp_v0_3 = arg0 + &D_803B0400;
if (*temp_v0_3 != 5) {
*temp_v0_3 = 2;
@@ -856,7 +833,7 @@ GLOBAL_ASM("asm/non_matchings/audio/load/func_800BB99C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B93BC(? *, ?, s32, ?, s32); // extern
? func_800BAA80(s32, s32, s32); // extern
? audio_dma_copy_immediate(s32, s32, s32); // extern
? func_800BAAF8(s32, s32, s32, OSMesgQueue *, void *); // extern
extern ? D_803AFC48;
extern ? D_803B0400;
@@ -882,13 +859,13 @@ s32 func_800BBA50(s32 arg0, ? arg1, u8 *arg2) {
return 0;
}
if (temp_s0 < 0x41) {
func_800BAA80(sp3C, temp_v0, temp_s0);
audio_dma_copy_immediate(sp3C, temp_v0, temp_s0);
temp_v0_3 = arg0 + &D_803B0400;
if (*temp_v0_3 != 5) {
*temp_v0_3 = 2;
}
} else {
func_800BAA80(sp3C, temp_v0, 0x40);
audio_dma_copy_immediate(sp3C, temp_v0, 0x40);
temp_a3 = arg2 + 0xD4;
sp34 = temp_a3;
osCreateMesgQueue(temp_a3, arg2 + 0xEC, 1);
@@ -1064,24 +1041,20 @@ block_11:
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BBDDC.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_800BBF44(); // extern
extern s32 D_800EA5DC;
void func_800BBEF0(s32 arg2) {
if (arg2 == 0) {
D_800EA5DC = 0x19710515;
extern volatile s32 D_800EA5DC;
//load_sequence_internal
void func_800BBF44(u32 player, u32 seqId, s32 loadAsync);
//load_sequence
void func_800BBEF0(u32 player, u32 seqId, s32 loadAsync) {
if (!loadAsync) {
D_800EA5DC = AUDIO_LOCK_LOADING; // gAudioLoadLock
}
func_800BBF44();
if (arg2 == 0) {
D_800EA5DC = 0x76557364;
func_800BBF44(player, seqId, loadAsync);
if (!loadAsync) {
D_800EA5DC = AUDIO_LOCK_NOT_LOADING;
}
}
#else
GLOBAL_ASM("asm/non_matchings/audio/load/func_800BBEF0.s")
#endif
//GLOBAL_ASM("asm/non_matchings/audio/load/func_800BBEF0.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
+12
View File
@@ -0,0 +1,12 @@
#ifndef AUDIO_LOAD_H
#define AUDIO_LOAD_H
#include <PR/ultratypes.h>
#include "internal.h"
#define AUDIO_FRAME_DMA_QUEUE_SIZE 0x40
#define PRELOAD_BANKS 2
#define PRELOAD_SEQUENCE 1
#endif // AUDIO_LOAD_H
+13 -13
View File
@@ -292,7 +292,7 @@ f32 func_800BE5E0(void *); // extern
? func_800BEBA4(void *, u32); // extern
? func_800BF004(s32, void *); // extern
extern s32 D_803B1508;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
void func_800BCBC4(void) {
u8 sp4B;
@@ -327,7 +327,7 @@ void func_800BCBC4(void) {
s32 phi_v0_2;
s32 phi_v1;
temp_v1 = D_803B70B0;
temp_v1 = gMaxSimultaneousNotes;
phi_v1 = temp_v1;
if (temp_v1 > 0) {
phi_s5 = 0;
@@ -347,7 +347,7 @@ void func_800BCBC4(void) {
if (temp_v0 == 0) {
func_800BEBA4(temp_a0, temp_a1);
temp_s1_2->unk0 = 1;
temp_v1_2 = D_803B70B0;
temp_v1_2 = gMaxSimultaneousNotes;
phi_v0_2 = temp_v1_2 * 3;
phi_v1 = temp_v1_2;
} else {
@@ -436,7 +436,7 @@ block_27:
phi_s3->unk1 = ((phi_s2 * 4) & 0x1C) | (phi_s3->unk1 & 0xFFE3);
}
}
temp_v1_3 = D_803B70B0;
temp_v1_3 = gMaxSimultaneousNotes;
phi_v0_2 = temp_v1_3 * 3;
phi_v1 = temp_v1_3;
}
@@ -670,7 +670,7 @@ GLOBAL_ASM("asm/non_matchings/audio/playback/func_800BD318.s")
? func_800BF004(? *, s32); // extern
extern s32 D_803B1508;
extern ? D_803B5FC8;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
void func_800BD368(void) {
s32 temp_s1;
@@ -681,7 +681,7 @@ void func_800BD368(void) {
func_800BD318(&D_803B5FC8);
phi_s0 = 0;
phi_s1 = 0;
if (D_803B70B0 > 0) {
if (gMaxSimultaneousNotes > 0) {
do {
temp_v0 = D_803B1508;
(temp_v0 + phi_s0)->unk8 = phi_s0 + temp_v0;
@@ -690,7 +690,7 @@ void func_800BD368(void) {
temp_s1 = phi_s1 + 1;
phi_s0 += 0xC0;
phi_s1 = temp_s1;
} while (temp_s1 < D_803B70B0);
} while (temp_s1 < gMaxSimultaneousNotes);
}
}
#else
@@ -1186,10 +1186,10 @@ GLOBAL_ASM("asm/non_matchings/audio/playback/func_800BDA44.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
s32 func_800B8FFC(? *, ?); // extern
extern ? D_803AFBE8;
s32 soundAlloc(? *, ?); // extern
extern ? gNotesAndBuffersPool;
extern s32 D_803B1508;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
extern ? gZeroNoteSub;
void func_800BDD34(void) {
@@ -1199,7 +1199,7 @@ void func_800BDD34(void) {
s32 phi_s1;
phi_s1 = 0;
if (D_803B70B0 > 0) {
if (gMaxSimultaneousNotes > 0) {
phi_s2 = 0;
do {
temp_s0 = phi_s2 + D_803B1508;
@@ -1219,11 +1219,11 @@ void func_800BDD34(void) {
temp_s0->unk80 = 0.0f;
temp_s0->unk84 = 0.0f;
temp_s0->unkBC = gZeroNoteSub.unkC;
temp_s0->unk1C = func_800B8FFC(&D_803AFBE8, 0xA0);
temp_s0->unk1C = soundAlloc(&gNotesAndBuffersPool, 0xA0);
temp_s1 = phi_s1 + 1;
phi_s2 += 0xC0;
phi_s1 = temp_s1;
} while (temp_s1 < D_803B70B0);
} while (temp_s1 < gMaxSimultaneousNotes);
}
}
#else
+14 -14
View File
@@ -14,10 +14,10 @@ extern OSMesgQueue *D_800EA3B4;
extern s32 D_800EA484;
extern u8 D_803B0500;
extern u8 D_803B0501;
extern OSMesgQueue D_803B6008;
extern ? D_803B7088;
extern OSMesgQueue gCurrAudioFrameDmaQueue;
extern ? gAudioBufferParameters;
extern s32 D_803B70B8;
extern s32 D_803B70BC;
extern s32 gCurrAudioFrameDmaCount;
extern s32 D_803B70C0;
extern s32 D_803B70C4;
extern ? D_803B70C8;
@@ -64,7 +64,7 @@ void *create_next_audio_frame_task(void) {
s32 phi_s1_3;
D_803B70B8 = D_803B70B8 + 1;
if ((D_803B70B8 % D_803B7088.unk0) != 0) {
if ((D_803B70B8 % gAudioBufferParameters.unk0) != 0) {
return NULL;
}
osSendMesg(D_800EA3A8, D_803B70B8, 0);
@@ -79,7 +79,7 @@ void *create_next_audio_frame_task(void) {
if (temp_v1 != 0) {
osAiSetNextBuffer(*(&D_803B7180 + (temp_hi * 4)), temp_v1 * 4);
}
temp_s1 = D_803B70BC;
temp_s1 = gCurrAudioFrameDmaCount;
phi_s0 = 0;
phi_s1 = temp_s1;
phi_s0_2 = 0;
@@ -88,31 +88,31 @@ void *create_next_audio_frame_task(void) {
if (temp_s1 > 0) {
do {
phi_s1_2 = phi_s1_3;
if (osRecvMesg(&D_803B6008, NULL, 0) == 0) {
if (osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0) == 0) {
phi_s1_2 = phi_s1_3 - 1;
}
temp_s0 = phi_s0 + 1;
phi_s0 = temp_s0;
phi_s1 = phi_s1_2;
phi_s1_3 = phi_s1_2;
} while (temp_s0 < D_803B70BC);
} while (temp_s0 < gCurrAudioFrameDmaCount);
}
if ((phi_s1 != 0) && (phi_s1 > 0)) {
do {
osRecvMesg(&D_803B6008, NULL, 1);
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 1);
temp_s0_2 = phi_s0_2 + 1;
phi_s0_2 = temp_s0_2;
} while (temp_s0_2 != phi_s1);
}
temp_s1_2 = D_803B6008.validCount;
temp_s1_2 = gCurrAudioFrameDmaQueue.validCount;
if ((temp_s1_2 != 0) && (temp_s1_2 > 0)) {
do {
osRecvMesg(&D_803B6008, NULL, 0);
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0);
temp_s0_3 = phi_s0_3 + 1;
phi_s0_3 = temp_s0_3;
} while (temp_s0_3 != temp_s1_2);
}
D_803B70BC = 0;
gCurrAudioFrameDmaCount = 0;
func_800BAC04();
if (osRecvMesg(D_800EA3B0, &sp58, 0) != -1) {
D_803B0501 = sp58;
@@ -131,12 +131,12 @@ void *create_next_audio_frame_task(void) {
D_803B70D0 = *(&D_803B70C8 + (temp_v0 * 4));
sp60 = *temp_a3;
temp_s1_3 = (temp_s0_4 * 2) + &D_803B718C;
*temp_s1_3 = (((D_803B7088.unk6 - sp74) + 0x40) & 0xFFF0) + 0x10;
temp_a0 = D_803B7088.unkA;
*temp_s1_3 = (((gAudioBufferParameters.unk6 - sp74) + 0x40) & 0xFFF0) + 0x10;
temp_a0 = gAudioBufferParameters.unkA;
if (*temp_s1_3 < temp_a0) {
*temp_s1_3 = temp_a0;
}
temp_v0_2 = D_803B7088.unk8;
temp_v0_2 = gAudioBufferParameters.unk8;
if (temp_v0_2 < *temp_s1_3) {
*temp_s1_3 = temp_v0_2;
}
+32 -32
View File
@@ -62,8 +62,8 @@ s8 gUseReverb;
s8 gNumSynthesisReverbs;
struct NoteSubEu *gNoteSubsEu;
extern struct Note *D_803B7088;
extern s32 D_803B70B0;
extern struct Note *gAudioBufferParameters;
extern s32 gMaxSimultaneousNotes;
f32 gLeftVolRampings;
//f32 gRightVolRampings[3][1024];
@@ -164,9 +164,9 @@ void synthesis_load_note_subs_eu(s32 updateIndex) {
struct NoteSubEu *dest;
s32 i;
for (i = 0; i < D_803B70B0; i++) {
src = &D_803B7088[i].noteSubEu;
dest = &gNoteSubsEu[D_803B70B0 * updateIndex + i];
for (i = 0; i < gMaxSimultaneousNotes; i++) {
src = &gAudioBufferParameters[i].noteSubEu;
dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (src->enabled) {
*dest = *src;
src->needsInit = FALSE;
@@ -183,11 +183,11 @@ void func_800B6FB4(s32 arg0, s32 arg1) {
s32 phi_v0;
temp_v0 = arg0 + 1;
if (i = 0; temp_v0 < (s32) D_803B7088.unkC; i++) {
if (i = 0; temp_v0 < (s32) gAudioBufferParameters.unkC; i++) {
phi_v0 = temp_v0;
for(i = 0; temp_v0_2 < (s32) D_803B7088.unkC; i++) {
dest = &gNoteSubsEu[D_803B70B0 * phi_v0 + (arg1 * 0x10)];
for(i = 0; temp_v0_2 < (s32) gAudioBufferParameters.unkC; i++) {
dest = &gNoteSubsEu[gMaxSimultaneousNotes * phi_v0 + (arg1 * 0x10)];
if ((*dest * 2) >= 0) {
temp_v0_2 = phi_v0 + 1;
*dest = (s8) ((u8) *dest & 0xFF7F);
@@ -205,8 +205,8 @@ GLOBAL_ASM("asm/non_matchings/audio/synthesis/func_800B6F1C.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
Tried to use struct NoteSubEu before it is defined.
extern ? D_803B7088;
extern s32 D_803B70B0;
extern ? gAudioBufferParameters;
extern s32 gMaxSimultaneousNotes;
extern ? gNoteSubsEu;
void synthesis_load_note_subs_eu(s32 arg0, s32 arg1) {
@@ -217,16 +217,16 @@ void synthesis_load_note_subs_eu(s32 arg0, s32 arg1) {
temp_v0 = arg0 + 1;
phi_v0 = temp_v0;
if (temp_v0 < D_803B7088.unkC) {
if (temp_v0 < gAudioBufferParameters.unkC) {
// Error: Tried to use struct NoteSubEu before it is defined.
// At instruction: lui $a1, %hi(gNoteSubsEu)
loop_2:
temp_a0 = *arg1 + (D_803B70B0 * phi_v0 * 0x10) + (arg1 * 0x10);
temp_a0 = *arg1 + (gMaxSimultaneousNotes * phi_v0 * 0x10) + (arg1 * 0x10);
if ((*temp_a0 * 2) >= 0) {
temp_v0_2 = phi_v0 + 1;
*temp_a0 = *temp_a0 & 0xFF7F;
phi_v0 = temp_v0_2;
if (temp_v0_2 < D_803B7088.unkC) {
if (temp_v0_2 < gAudioBufferParameters.unkC) {
goto loop_2;
}
}
@@ -239,7 +239,7 @@ GLOBAL_ASM("asm/non_matchings/audio/synthesis/synthesis_load_note_subs_eu.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
Tried to use struct NoteSubEu before it is defined.
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
extern ? gNoteSubsEu;
void func_800B7034(s32 arg0) {
@@ -252,13 +252,13 @@ void func_800B7034(s32 arg0) {
phi_a1 = 0;
phi_v0 = 0;
if (D_803B70B0 > 0) {
if (gMaxSimultaneousNotes > 0) {
// Error: Tried to use struct NoteSubEu before it is defined.
// At instruction: lui $t2, %hi(gNoteSubsEu)
do {
temp_a0 = phi_a1 + *MIPS2C_ERROR(Read from unset register $t1);
temp_a0_2 = temp_a0 + 0xB0;
temp_a2 = (((D_803B70B0 * arg0) + phi_v0) * 0x10) + *MIPS2C_ERROR(Read from unset register $t2);
temp_a2 = (((gMaxSimultaneousNotes * arg0) + phi_v0) * 0x10) + *MIPS2C_ERROR(Read from unset register $t2);
if ((temp_a0->unkB0 >> 0x1F) != 0) {
temp_a2->unk0 = temp_a0_2->unk0;
temp_a2->unk4 = temp_a0_2->unk4;
@@ -271,7 +271,7 @@ void func_800B7034(s32 arg0) {
temp_v0 = phi_v0 + 1;
phi_a1 += 0xC0;
phi_v0 = temp_v0;
} while (temp_v0 < D_803B70B0);
} while (temp_v0 < gMaxSimultaneousNotes);
}
}
#else
@@ -284,7 +284,7 @@ GLOBAL_ASM("asm/non_matchings/audio/synthesis/func_800B7034.s")
void *func_800B775C(s32, s32, void *, s32); // extern
? func_800C1138(s32); // extern
? prepare_reverb_ring_buffer(s32, s32, s32); // extern
extern ? D_803B7088;
extern ? gAudioBufferParameters;
void *func_800B70EC(void *arg0, s32 *arg1, s32 arg2, s32 arg3) {
s16 temp_s2;
@@ -317,20 +317,20 @@ void *func_800B70EC(void *arg0, s32 *arg1, s32 arg2, s32 arg3) {
void *phi_fp_2;
s16 phi_s2_3;
temp_s4 = D_803B7088.unkC;
temp_s4 = gAudioBufferParameters.unkC;
phi_s4 = temp_s4;
phi_s6 = arg3;
if (temp_s4 > 0) {
do {
temp_s0 = phi_s4 - 1;
func_800C1138(temp_s0);
func_800B7034(D_803B7088.unkC - phi_s4);
func_800B7034(gAudioBufferParameters.unkC - phi_s4);
phi_s4 = temp_s0;
} while (temp_s0 > 0);
}
arg0->unk0 = 0x7000000;
arg0->unk4 = 0;
temp_s4_2 = D_803B7088.unkC;
temp_s4_2 = gAudioBufferParameters.unkC;
temp_fp = arg0 + 8;
phi_s4_2 = temp_s4_2;
phi_s7 = arg2;
@@ -338,7 +338,7 @@ void *func_800B70EC(void *arg0, s32 *arg1, s32 arg2, s32 arg3) {
phi_fp_2 = temp_fp;
if (temp_s4_2 > 0) {
do {
temp_s2 = D_803B7088.unkC;
temp_s2 = gAudioBufferParameters.unkC;
phi_s2 = temp_s2;
phi_s1 = 0;
phi_s2_2 = temp_s2;
@@ -346,15 +346,15 @@ void *func_800B70EC(void *arg0, s32 *arg1, s32 arg2, s32 arg3) {
phi_s3 = phi_s6;
} else {
temp_lo = phi_s6 / phi_s4_2;
temp_v1 = D_803B7088.unk10;
temp_v1 = gAudioBufferParameters.unk10;
if (temp_lo >= temp_v1) {
phi_s3 = temp_v1;
} else {
temp_v1_2 = D_803B7088.unk12;
temp_v1_2 = gAudioBufferParameters.unk12;
if (temp_v1_2 >= temp_lo) {
phi_s3 = temp_v1_2;
} else {
phi_s3 = D_803B7088.unkE;
phi_s3 = gAudioBufferParameters.unkE;
}
}
}
@@ -367,7 +367,7 @@ void *func_800B70EC(void *arg0, s32 *arg1, s32 arg2, s32 arg3) {
if (phi_s0->useReverb != 0) {
prepare_reverb_ring_buffer(phi_s3, phi_s2 - phi_s4_2, phi_s1);
phi_v0 = gNumSynthesisReverbs;
phi_s2_3 = D_803B7088.unkC;
phi_s2_3 = gAudioBufferParameters.unkC;
}
temp_s1 = phi_s1 + 1;
phi_s0 += 0x108;
@@ -553,7 +553,7 @@ void *func_800B7630(void *, s16, s16); // extern
void *func_800B7C30(u8, s32, s32, s32, s32, void *, s32); // extern
extern ? D_803B03C0;
extern s32 D_803B1508;
extern s32 D_803B70B0;
extern s32 gMaxSimultaneousNotes;
extern s32 D_803B7198;
extern ? gNoteSubsEu;
extern u8 gUseReverb;
@@ -627,7 +627,7 @@ void *func_800B775C(s32 arg0, s32 arg1, void *arg2, s16 arg3) {
phi_s2_8 = 0;
phi_s2_4 = 0;
if (temp_t1 == 0) {
temp_a0 = D_803B70B0;
temp_a0 = gMaxSimultaneousNotes;
phi_s1 = 0;
if (temp_a0 > 0) {
// Error: Tried to use struct NoteSubEu before it is defined.
@@ -649,7 +649,7 @@ void *func_800B775C(s32 arg0, s32 arg1, void *arg2, s16 arg3) {
} else {
phi_s3 = 0;
if (temp_t1 > 0) {
temp_a0_2 = D_803B70B0;
temp_a0_2 = gMaxSimultaneousNotes;
do {
phi_s1_2 = 0;
phi_s2_2 = phi_s2_6;
@@ -676,7 +676,7 @@ void *func_800B775C(s32 arg0, s32 arg1, void *arg2, s16 arg3) {
phi_s2_8 = phi_s2_10;
} while (temp_s3 < temp_t1);
}
temp_a0_3 = D_803B70B0;
temp_a0_3 = gMaxSimultaneousNotes;
phi_s1_3 = 0;
phi_s2_3 = phi_s2_8;
phi_s2_4 = phi_s2_8;
@@ -727,7 +727,7 @@ void *func_800B775C(s32 arg0, s32 arg1, void *arg2, s16 arg3) {
loop_31:
temp_v1 = *phi_s0;
temp_t0 = *saved_reg_s6;
temp_lo = arg3 * D_803B70B0;
temp_lo = arg3 * gMaxSimultaneousNotes;
phi_s4_3 = phi_s4_2;
phi_s1_8 = phi_s1_5;
if (phi_s3_2 == ((temp_t0 + (temp_v1 * 0x10) + (temp_lo * 0x10))->unk1 >> 5)) {
@@ -765,7 +765,7 @@ loop_31:
do {
temp_v1_2 = *phi_s0_2;
temp_t0_2 = *saved_reg_s6;
temp_lo_2 = arg3 * D_803B70B0;
temp_lo_2 = arg3 * gMaxSimultaneousNotes;
temp_a1 = (temp_t0_2 + (temp_v1_2 * 0x10) + (temp_lo_2 * 0x10))->unk2;
phi_s4_9 = phi_s4_4;
if (((*(&D_803B03C0 + temp_a1) < 2) ^ 1) == 1) {
+339 -116
View File
@@ -7,58 +7,322 @@ extern OSMesgQueue gDmaMesgQueue;
extern OSMesg gMainReceivedMesg;
extern u8 _kart_texturesSegmentRomStart[];
extern u32 gKartPalettes[];
extern uintptr_t *gKartPalettes[];
// arrays?
extern u32 *D_802F1F80;
extern u32 *D_802DFB80;
extern u16 D_802F1F80[2][4][2048];
extern u8 D_802DFB80[2][2][18688];
extern s16 D_800DDEB0[];
extern u16 D_800DDEB0[];
/*
u16 D_800DDEB0[] = { // sizes
0x06c0, 0x06e0, 0x06e0, 0x0680, 0x07c0, 0x0700, 0x0680, 0x0910
};
*/
extern s32 gActiveScreenMode;
// Structured like a 3D pointer array
extern u32 ***gKartTextureTable0, ***gKartTextureTable1, **gKartTextureGroup18s;
extern uintptr_t **gKartTextureGroup18s;
extern uintptr_t *gKartMarioGroup8[];
extern uintptr_t *gKartMarioGroup7[];
extern uintptr_t *gKartMarioGroup6[];
extern uintptr_t *gKartMarioGroup5[];
extern uintptr_t *gKartMarioGroup4[];
extern uintptr_t *gKartMarioGroup3[];
extern uintptr_t *gKartMarioGroup2[];
extern uintptr_t *gKartMarioGroup1[];
extern uintptr_t *gKartMarioGroup0[];
extern uintptr_t *gKartLuigiGroup8[];
extern uintptr_t *gKartLuigiGroup7[];
extern uintptr_t *gKartLuigiGroup6[];
extern uintptr_t *gKartLuigiGroup5[];
extern uintptr_t *gKartLuigiGroup4[];
extern uintptr_t *gKartLuigiGroup3[];
extern uintptr_t *gKartLuigiGroup2[];
extern uintptr_t *gKartLuigiGroup1[];
extern uintptr_t *gKartLuigiGroup0[];
extern uintptr_t *gKartYoshiGroup8[];
extern uintptr_t *gKartYoshiGroup7[];
extern uintptr_t *gKartYoshiGroup6[];
extern uintptr_t *gKartYoshiGroup5[];
extern uintptr_t *gKartYoshiGroup4[];
extern uintptr_t *gKartYoshiGroup3[];
extern uintptr_t *gKartYoshiGroup2[];
extern uintptr_t *gKartYoshiGroup1[];
extern uintptr_t *gKartYoshiGroup0[];
extern uintptr_t *gKartToadGroup8[];
extern uintptr_t *gKartToadGroup7[];
extern uintptr_t *gKartToadGroup6[];
extern uintptr_t *gKartToadGroup5[];
extern uintptr_t *gKartToadGroup4[];
extern uintptr_t *gKartToadGroup3[];
extern uintptr_t *gKartToadGroup2[];
extern uintptr_t *gKartToadGroup1[];
extern uintptr_t *gKartToadGroup0[];
extern uintptr_t *gKartDKGroup8[];
extern uintptr_t *gKartDKGroup7[];
extern uintptr_t *gKartDKGroup6[];
extern uintptr_t *gKartDKGroup5[];
extern uintptr_t *gKartDKGroup4[];
extern uintptr_t *gKartDKGroup3[];
extern uintptr_t *gKartDKGroup2[];
extern uintptr_t *gKartDKGroup1[];
extern uintptr_t *gKartDKGroup0[];
extern uintptr_t *gKartWarioGroup8[];
extern uintptr_t *gKartWarioGroup7[];
extern uintptr_t *gKartWarioGroup6[];
extern uintptr_t *gKartWarioGroup5[];
extern uintptr_t *gKartWarioGroup4[];
extern uintptr_t *gKartWarioGroup3[];
extern uintptr_t *gKartWarioGroup2[];
extern uintptr_t *gKartWarioGroup1[];
extern uintptr_t *gKartWarioGroup0[];
extern uintptr_t *gKartPeachGroup8[];
extern uintptr_t *gKartPeachGroup7[];
extern uintptr_t *gKartPeachGroup6[];
extern uintptr_t *gKartPeachGroup5[];
extern uintptr_t *gKartPeachGroup4[];
extern uintptr_t *gKartPeachGroup3[];
extern uintptr_t *gKartPeachGroup2[];
extern uintptr_t *gKartPeachGroup1[];
extern uintptr_t *gKartPeachGroup0[];
extern uintptr_t *gKartBowserGroup8[];
extern uintptr_t *gKartBowserGroup7[];
extern uintptr_t *gKartBowserGroup6[];
extern uintptr_t *gKartBowserGroup5[];
extern uintptr_t *gKartBowserGroup4[];
extern uintptr_t *gKartBowserGroup3[];
extern uintptr_t *gKartBowserGroup2[];
extern uintptr_t *gKartBowserGroup1[];
extern uintptr_t *gKartBowserGroup0[];
extern uintptr_t *gKartMarioGroup17[];
extern uintptr_t *gKartMarioGroup16[];
extern uintptr_t *gKartMarioGroup15[];
extern uintptr_t *gKartMarioGroup14[];
extern uintptr_t *gKartMarioGroup13[];
extern uintptr_t *gKartMarioGroup12[];
extern uintptr_t *gKartMarioGroup11[];
extern uintptr_t *gKartMarioGroup10[];
extern uintptr_t *gKartMarioGroup9[];
extern uintptr_t *gKartLuigiGroup17[];
extern uintptr_t *gKartLuigiGroup16[];
extern uintptr_t *gKartLuigiGroup15[];
extern uintptr_t *gKartLuigiGroup14[];
extern uintptr_t *gKartLuigiGroup13[];
extern uintptr_t *gKartLuigiGroup12[];
extern uintptr_t *gKartLuigiGroup11[];
extern uintptr_t *gKartLuigiGroup10[];
extern uintptr_t *gKartLuigiGroup9[];
extern uintptr_t *gKartYoshiGroup17[];
extern uintptr_t *gKartYoshiGroup16[];
extern uintptr_t *gKartYoshiGroup15[];
extern uintptr_t *gKartYoshiGroup14[];
extern uintptr_t *gKartYoshiGroup13[];
extern uintptr_t *gKartYoshiGroup12[];
extern uintptr_t *gKartYoshiGroup11[];
extern uintptr_t *gKartYoshiGroup10[];
extern uintptr_t *gKartYoshiGroup9[];
extern uintptr_t *gKartToadGroup17[];
extern uintptr_t *gKartToadGroup16[];
extern uintptr_t *gKartToadGroup15[];
extern uintptr_t *gKartToadGroup14[];
extern uintptr_t *gKartToadGroup13[];
extern uintptr_t *gKartToadGroup12[];
extern uintptr_t *gKartToadGroup11[];
extern uintptr_t *gKartToadGroup10[];
extern uintptr_t *gKartToadGroup9[];
extern uintptr_t *gKartDKGroup17[];
extern uintptr_t *gKartDKGroup16[];
extern uintptr_t *gKartDKGroup15[];
extern uintptr_t *gKartDKGroup14[];
extern uintptr_t *gKartDKGroup13[];
extern uintptr_t *gKartDKGroup12[];
extern uintptr_t *gKartDKGroup11[];
extern uintptr_t *gKartDKGroup10[];
extern uintptr_t *gKartDKGroup9[];
extern uintptr_t *gKartWarioGroup17[];
extern uintptr_t *gKartWarioGroup16[];
extern uintptr_t *gKartWarioGroup15[];
extern uintptr_t *gKartWarioGroup14[];
extern uintptr_t *gKartWarioGroup13[];
extern uintptr_t *gKartWarioGroup12[];
extern uintptr_t *gKartWarioGroup11[];
extern uintptr_t *gKartWarioGroup10[];
extern uintptr_t *gKartWarioGroup9[];
extern uintptr_t *gKartPeachGroup17[];
extern uintptr_t *gKartPeachGroup16[];
extern uintptr_t *gKartPeachGroup15[];
extern uintptr_t *gKartPeachGroup14[];
extern uintptr_t *gKartPeachGroup13[];
extern uintptr_t *gKartPeachGroup12[];
extern uintptr_t *gKartPeachGroup11[];
extern uintptr_t *gKartPeachGroup10[];
extern uintptr_t *gKartPeachGroup9[];
extern uintptr_t *gKartBowserGroup17[];
extern uintptr_t *gKartBowserGroup16[];
extern uintptr_t *gKartBowserGroup15[];
extern uintptr_t *gKartBowserGroup14[];
extern uintptr_t *gKartBowserGroup13[];
extern uintptr_t *gKartBowserGroup12[];
extern uintptr_t *gKartBowserGroup11[];
extern uintptr_t *gKartBowserGroup10[];
extern uintptr_t *gKartBowserGroup9[];
uintptr_t **gKartMarioTable0[] = {
gKartMarioGroup8, gKartMarioGroup7, gKartMarioGroup6,
gKartMarioGroup5, gKartMarioGroup4, gKartMarioGroup3,
gKartMarioGroup2, gKartMarioGroup1, gKartMarioGroup0,
};
uintptr_t **gKartLuigiTable0[] = {
gKartLuigiGroup8, gKartLuigiGroup7, gKartLuigiGroup6,
gKartLuigiGroup5, gKartLuigiGroup4, gKartLuigiGroup3,
gKartLuigiGroup2, gKartLuigiGroup1, gKartLuigiGroup0,
};
uintptr_t **gKartYoshiTable0[] = {
gKartYoshiGroup8, gKartYoshiGroup7, gKartYoshiGroup6,
gKartYoshiGroup5, gKartYoshiGroup4, gKartYoshiGroup3,
gKartYoshiGroup2, gKartYoshiGroup1, gKartYoshiGroup0,
};
uintptr_t **gKartToadTable0[] = {
gKartToadGroup8, gKartToadGroup7, gKartToadGroup6,
gKartToadGroup5, gKartToadGroup4, gKartToadGroup3,
gKartToadGroup2, gKartToadGroup1, gKartToadGroup0,
};
uintptr_t **gKartDKTable0[] = {
gKartDKGroup8, gKartDKGroup7, gKartDKGroup6,
gKartDKGroup5, gKartDKGroup4, gKartDKGroup3,
gKartDKGroup2, gKartDKGroup1, gKartDKGroup0,
};
uintptr_t **gKartWarioTable0[] = {
gKartWarioGroup8, gKartWarioGroup7, gKartWarioGroup6,
gKartWarioGroup5, gKartWarioGroup4, gKartWarioGroup3,
gKartWarioGroup2, gKartWarioGroup1, gKartWarioGroup0,
};
uintptr_t **gKartPeachTable0[] = {
gKartPeachGroup8, gKartPeachGroup7, gKartPeachGroup6,
gKartPeachGroup5, gKartPeachGroup4, gKartPeachGroup3,
gKartPeachGroup2, gKartPeachGroup1, gKartPeachGroup0,
};
uintptr_t **gKartBowserTable0[] = {
gKartBowserGroup8, gKartBowserGroup7, gKartBowserGroup6,
gKartBowserGroup5, gKartBowserGroup4, gKartBowserGroup3,
gKartBowserGroup2, gKartBowserGroup1, gKartBowserGroup0,
};
uintptr_t **gKartMarioTable1[] = {
gKartMarioGroup17, gKartMarioGroup16, gKartMarioGroup15,
gKartMarioGroup14, gKartMarioGroup13, gKartMarioGroup12,
gKartMarioGroup11, gKartMarioGroup10, gKartMarioGroup9,
};
uintptr_t **gKartLuigiTable1[] = {
gKartLuigiGroup17, gKartLuigiGroup16, gKartLuigiGroup15, gKartLuigiGroup14,
gKartLuigiGroup13, gKartLuigiGroup12, gKartLuigiGroup11, gKartLuigiGroup10,
gKartLuigiGroup9,
};
uintptr_t **gKartYoshiTable1[] = {
gKartYoshiGroup17, gKartYoshiGroup16, gKartYoshiGroup15, gKartYoshiGroup14,
gKartYoshiGroup13, gKartYoshiGroup12, gKartYoshiGroup11, gKartYoshiGroup10,
gKartYoshiGroup9,
};
uintptr_t **gKartToadTable1[] = {
gKartToadGroup17, gKartToadGroup16, gKartToadGroup15, gKartToadGroup14,
gKartToadGroup13, gKartToadGroup12, gKartToadGroup11, gKartToadGroup10,
gKartToadGroup9,
};
uintptr_t **gKartDKTable1[] = {
gKartDKGroup17, gKartDKGroup16, gKartDKGroup15, gKartDKGroup14,
gKartDKGroup13, gKartDKGroup12, gKartDKGroup11, gKartDKGroup10,
gKartDKGroup9,
};
uintptr_t **gKartWarioTable1[] = {
gKartWarioGroup17, gKartWarioGroup16, gKartWarioGroup15, gKartWarioGroup14,
gKartWarioGroup13, gKartWarioGroup12, gKartWarioGroup11, gKartWarioGroup10,
gKartWarioGroup9,
};
uintptr_t **gKartPeachTable1[] = {
gKartPeachGroup17, gKartPeachGroup16, gKartPeachGroup15, gKartPeachGroup14,
gKartPeachGroup13, gKartPeachGroup12, gKartPeachGroup11, gKartPeachGroup10,
gKartPeachGroup9,
};
uintptr_t **gKartBowserTable1[] = {
gKartBowserGroup17, gKartBowserGroup16, gKartBowserGroup15, gKartBowserGroup14,
gKartBowserGroup13, gKartBowserGroup12, gKartBowserGroup11, gKartBowserGroup10,
gKartBowserGroup9,
};
uintptr_t ***gKartTextureTable0[] = {
gKartMarioTable0,
gKartLuigiTable0,
gKartYoshiTable0,
gKartToadTable0,
gKartDKTable0,
gKartWarioTable0,
gKartPeachTable0,
gKartBowserTable0,
};
uintptr_t ***gKartTextureTable1[] = {
gKartMarioTable1,
gKartLuigiTable1,
gKartYoshiTable1,
gKartToadTable1,
gKartDKTable1,
gKartWarioTable1,
gKartPeachTable1,
gKartBowserTable1,
};
// some larger diffs that need resolving
#ifdef MIPS_TO_C
void func_80027040(Player *player, s8 arg1, s8 arg2, s8 arg3, s32 arg4) {
s32 temp_v0 = player->unk_0BC;
void *temp_s0;
// void *temp_v1;
void func_80027040(Player *player, s8 arg1, s8 arg2, s8 arg3, s8 arg4) {
if ((temp_v0 & 0x80) == 0x80 ||
(temp_v0 & 0x40) == 0x40 ||
(temp_v0 & 0x80000) == 0x80000 ||
(temp_v0 & 0x800000) == 0x800000 ||
(temp_v0 & 0x20000) == 0x20000 ||
(player->unk_044 & 0x800) != 0
) {
//s32 tmp = player->unk_0BC;
void *buf; // = &D_802DFB80[arg4][arg3][arg1 * 0x920];
u16 id;
if (((((((player->unk_0BC & 0x80) == 0x80) || ((player->unk_0BC & 0x40) == 0x40)) || ((player->unk_0BC & 0x80000) == 0x80000)) || ((player->unk_0BC & 0x800000) == 0x800000)) || ((player->unk_0BC & 0x20000) == 0x20000)) || ((player->unk_044 & 0x800) != 0))
{
// temp_v1 = player + (arg2 * 2);
if (player->unk_244[arg2] == 0) {
temp_s0 = (arg4 * 0x9200) + (arg3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0, D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]] & 0xFFFFFF], temp_s0, D_800DDEB0[temp_v0], &gDmaMesgQueue);
if (player->unk_244[arg2] != 0) {
//buf = &D_802DFB80[arg2][arg1 * 0x920];
buf = &D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(buf, D_800DDEB0[player->characterId]);
id = player->characterId;
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable1[id][player->unk_24C[arg2]][player->unk_244[arg2]])], buf, D_800DDEB0[player->unk_0BC], &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
} else {
temp_s0 = (arg4 * 0x9200) + (arg3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0, D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartTextureTable1[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]] & 0xFFFFFF], temp_s0, D_800DDEB0[temp_v0], &gDmaMesgQueue);
buf = &D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(&D_802DFB80[arg4][arg3], D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]])], buf, D_800DDEB0[player->unk_0BC], &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
}
}
else if ((temp_v0 & 0x400) == 0x400 ||
(temp_v0 & 0x1000000) == 0x1000000 ||
(temp_v0 & 0x2000000) == 0x2000000 ||
(temp_v0 & 0x10000) == 0x10000
) {
temp_s0 = (arg4 * 0x9200) + (arg3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0, 0x780);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartTextureGroup18s[player->characterId][player->unk_0A8 >> 8] & 0xFFFFFF], temp_s0, 0x900, &gDmaMesgQueue);
} else if (((((player->unk_0BC & 0x400) == 0x400) || ((player->unk_0BC & 0x1000000) == 0x1000000)) || ((player->unk_0BC & 0x2000000) == 0x2000000)) || ((player->unk_0BC & 0x10000) == 0x10000))
{
buf = &D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(buf, 0x780);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureGroup18s[player->characterId][player->unk_0A8 >> 8])], buf, 0x900, &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
} else {
temp_s0 = (arg4 * 0x9200) + (arg3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0, D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]] & 0xFFFFFF], temp_s0, D_800DDEB0[temp_v0], &gDmaMesgQueue);
buf = &D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(buf, D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]])], buf, D_800DDEB0[player->unk_0BC], &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
}
}
@@ -68,111 +332,70 @@ GLOBAL_ASM("asm/non_matchings/code_80027040/func_80027040.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3ec45aadfc2cb619035fb802d88c52eacfab0326
void func_80027560(Player *arg0, s8 arg1, s8 arg2, s8 arg3, s8 arg4) {
void *sp30;
s32 temp_v0;
s8 temp_a3;
u16 temp_v0;
u16 temp_v0;
u16 temp_v0;
void func_80027560(Player *player, s8 arg1, s8 arg2, s8 arg3, s8 arg4) {
//s32 temp_v0;
void *temp_s0;
void *temp_s0_2;
void *temp_s0_3;
void *temp_s0_4;
void *temp_v1;
void *temp_v1_2;
temp_v0 = arg0->unkBC;
temp_a3 = arg3;
if ((temp_v0 & 0x80) == 0x80) {
block_6:
temp_v1_2 = arg0 + (arg2 * 2);
if (temp_v1_2->unk244 == 0) {
temp_s0_4 = (arg4 * 0x9200) + (temp_a3 * 0x4900) + (arg1 * 0x920) + 0x802DFB80;
sp30 = temp_v1_2;
osInvalDCache(temp_s0_4, *(&D_800DDEB0 + (arg0->unk254 * 2)));
temp_v0 = arg0->unk254;
osPiStartDma(&gDmaIoMesg, 0, 0, (*(*(*(&gKartTextureTable0 + (temp_v0 * 4)) + (temp_v1_2->unk24C * 4)) + (temp_v1_2->unk244 * 4)) & 0xFFFFFF) + &_kart_texturesSegmentRomStart, temp_s0_4, *(&D_800DDEB0 + (temp_v0 * 2)), &gDmaMesgQueue);
return;
//temp_v0 = player->unk_0BC;
if (((player->unk_0BC & 0x80) == 0x80) || ((player->unk_0BC & 0x40) == 0x40) || ((player->unk_0BC & 0x80000) == 0x80000) || ((player->unk_0BC & 0x800000) == 0x800000) || ((player->unk_0BC & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0))
{
//temp_v1_2 = player + (arg2 * 2);
if (player->unk_244[arg2] != 0) {
temp_s0 = D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(D_802DFB80[arg4][arg3], D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]])], temp_s0, D_800DDEB0[player->characterId], &gDmaMesgQueue);
} else {
temp_s0 = D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(temp_s0, D_800DDEB0[player->characterId]);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable1[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]])], temp_s0, D_800DDEB0[player->characterId], &gDmaMesgQueue);
}
temp_s0_3 = (arg4 * 0x9200) + (temp_a3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
sp30 = temp_v1_2;
osInvalDCache(temp_s0_3, *(&D_800DDEB0 + (arg0->unk254 * 2)));
temp_v0 = arg0->unk254;
osPiStartDma(&gDmaIoMesg, 0, 0, (*(*(*(&gKartTextureTable1 + (temp_v0 * 4)) + (temp_v1_2->unk24C * 4)) + (temp_v1_2->unk244 * 4)) & 0xFFFFFF) + &_kart_texturesSegmentRomStart, temp_s0_3, *(&D_800DDEB0 + (temp_v0 * 2)), &gDmaMesgQueue);
return;
} else if (((player->unk_0BC & 0x400) == 0x400) || ((player->unk_0BC & 0x01000000) == 0x01000000) || ((player->unk_0BC & 0x02000000) == 0x02000000) || ((player->unk_0BC & 0x10000) == 0x10000))
{
temp_s0 = D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(temp_s0, 0x780);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureGroup18s[player->characterId][player->unk_0A8 >> 8])], temp_s0, 0x900, &gDmaMesgQueue);
} else {
temp_s0 = D_802DFB80[arg4][arg3][arg1 * 0x920];
osInvalDCache(temp_s0, D_800DDEB0[player->characterId]);
//temp_v1 = player + (arg2 * 2);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartTextureTable0[player->characterId][player->unk_24C[arg2]][player->unk_244[arg2]])], temp_s0, D_800DDEB0[player->characterId], &gDmaMesgQueue);
}
if ((temp_v0 & 0x40) == 0x40) {
goto block_6;
}
if ((temp_v0 & 0x80000) == 0x80000) {
goto block_6;
}
if ((temp_v0 & 0x800000) == 0x800000) {
goto block_6;
}
if ((temp_v0 & 0x20000) == 0x20000) {
goto block_6;
}
if ((arg0->unk44 & 0x800) != 0) {
goto block_6;
}
if ((temp_v0 & 0x400) == 0x400) {
block_13:
temp_s0_2 = (arg4 * 0x9200) + (temp_a3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0_2, 0x780);
osPiStartDma(&gDmaIoMesg, 0, 0, (*(*(&gKartTextureGroup18s + (arg0->unk254 * 4)) + ((arg0->unkA8 >> 8) * 4)) & 0xFFFFFF) + &_kart_texturesSegmentRomStart, temp_s0_2, 0x900, &gDmaMesgQueue);
return;
}
if ((temp_v0 & 0x1000000) == 0x1000000) {
goto block_13;
}
if ((temp_v0 & 0x2000000) == 0x2000000) {
goto block_13;
}
if ((temp_v0 & 0x10000) == 0x10000) {
goto block_13;
}
temp_s0 = (arg4 * 0x9200) + (temp_a3 * 0x4900) + (arg1 * 0x920) + D_802DFB80;
osInvalDCache(temp_s0, *(&D_800DDEB0 + (arg0->unk254 * 2)));
temp_v0 = arg0->unk254;
temp_v1 = arg0 + (arg2 * 2);
osPiStartDma(&gDmaIoMesg, 0, 0, (*(*(*(&gKartTextureTable0 + (temp_v0 * 4)) + (temp_v1->unk24C * 4)) + (temp_v1->unk244 * 4)) & 0xFFFFFF) + &_kart_texturesSegmentRomStart, temp_s0, *(&D_800DDEB0 + (temp_v0 * 2)), &gDmaMesgQueue);
}
#else
GLOBAL_ASM("asm/non_matchings/code_80027040/func_80027560.s")
#endif
// regalloc
#ifdef NON_MATCHING
void func_80027A20(Player *player, s8 arg1, s8 arg2, s8 arg3) {
void *temp_s0 = (arg3 << 0xE) + (arg2 << 0xC) + (arg1 << 9) + (s32)&D_802F1F80;
// @bug: Undefined Behaviour UB
// untested fix
#ifdef AVOID_UB
void *temp_s0 = &D_802F1F80[arg3][arg2][0];
#else
void *temp_s0 = &D_802F1F80[arg3][arg2][arg1 << 8];
#endif
switch(gActiveScreenMode) {
case 0: case 1: case 2:
case 0: case 1:
case 2:
osInvalDCache(temp_s0, 0x200);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartPalettes[player->characterId] & 0x00FFFFFF], temp_s0, 0x200, &gDmaMesgQueue);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartPalettes[player->characterId])], temp_s0, 0x200, &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
break;
case 3:
osInvalDCache(temp_s0, 0x200);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[gKartPalettes[player->characterId] & 0x00FFFFFF], temp_s0, 0x200, &gDmaMesgQueue);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(gKartPalettes[player->characterId])], temp_s0, 0x200, &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
break;
default: break;
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80027040/func_80027A20.s")
#endif
void func_80027BDC(s32 arg0, s32 arg1, void *vAddr, u16 size) {
void func_80027BDC(UNUSED Player *player, s32 arg1, void *vAddr, u16 size) {
osInvalDCache(vAddr, size);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[arg1 & 0x00FFFFFF], vAddr, size, &gDmaMesgQueue);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(arg1)], vAddr, size, &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1);
}
void func_80027C74(s32 arg0, s32 arg1, void *vAddr, u16 size) {
void func_80027C74(UNUSED Player *player, s32 arg1, void *vAddr, u16 size) {
osInvalDCache(vAddr, size);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[arg1 & 0x00FFFFFF], vAddr, size, &gDmaMesgQueue);
osPiStartDma(&gDmaIoMesg, 0, 0, &_kart_texturesSegmentRomStart[SEGMENT_OFFSET(arg1)], vAddr, size, &gDmaMesgQueue);
}
+2 -2
View File
@@ -10,8 +10,8 @@ u8 D_802BFB80[77824];
u8 D_802D2B80[32768]; // Luigi raceway course path ghost
u8 D_802DAB80[20480];
u16 D_802DFB80[37376];
u16 D_802F1F80[16382];
u8 D_802DFB80[2][2][18688];
u16 D_802F1F80[2][4][2048];
u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
-565
View File
@@ -1,565 +0,0 @@
#ifndef AUDIO_INTERNAL_H
#define AUDIO_INTERNAL_H
#include <ultra64.h>
#include "types.h"
// sm64 build defines
#define IS_BIG_ENDIAN 1
// sm64 build defines
#define SEQUENCE_PLAYERS 4
#define SEQUENCE_CHANNELS 48
#define SEQUENCE_LAYERS 64
#define LAYERS_MAX 4
#define CHANNELS_MAX 16
#define NO_LAYER ((struct SequenceChannelLayer *)(-1))
#define MUTE_BEHAVIOR_STOP_SCRIPT 0x80 // stop processing sequence/channel scripts
#define MUTE_BEHAVIOR_STOP_NOTES 0x40 // prevent further notes from playing
#define MUTE_BEHAVIOR_SOFTEN 0x20 // lower volume, by default to half
#define SEQUENCE_PLAYER_STATE_0 0
#define SEQUENCE_PLAYER_STATE_FADE_OUT 1
#define SEQUENCE_PLAYER_STATE_2 2
#define SEQUENCE_PLAYER_STATE_3 3
#define SEQUENCE_PLAYER_STATE_4 4
#define NOTE_PRIORITY_DISABLED 0
#define NOTE_PRIORITY_STOPPING 1
#define NOTE_PRIORITY_MIN 2
#define NOTE_PRIORITY_DEFAULT 3
#define TATUMS_PER_BEAT 48
// abi.h contains more details about the ADPCM and S8 codecs, "skip" skips codec processing
#define CODEC_ADPCM 0
#define CODEC_S8 1
#define CODEC_SKIP 2
#define TEMPO_SCALE TATUMS_PER_BEAT
// TODO: US_FLOAT should probably be renamed to JP_DOUBLE since eu seems to use floats too
#define US_FLOAT(x) x ## f
// Convert u8 or u16 to f32.
#define FLOAT_CAST(x) (f32) (s32) (x)
// No-op printf macro which leaves string literals in rodata in IDO. IDO
// doesn't support variadic macros, so instead we let the parameter list
// expand to a no-op comma expression. Another possibility is that it might
// have expanded to something with "if (0)". See also goddard/gd_main.h.
// On US/JP, -sopt optimizes away these except for external.c.
#ifdef __sgi
#define stubbed_printf
#else
#define stubbed_printf(...)
#endif
#define eu_stubbed_printf_0(msg) stubbed_printf(msg)
#define eu_stubbed_printf_1(msg, a) stubbed_printf(msg, a)
#define eu_stubbed_printf_2(msg, a, b) stubbed_printf(msg, a, b)
#define eu_stubbed_printf_3(msg, a, b, c) stubbed_printf(msg, a, b, c)
struct NotePool;
struct AudioListItem {
// A node in a circularly linked list. Each node is either a head or an item:
// - Items can be either detached (prev = NULL), or attached to a list.
// 'value' points to something of interest.
// - List heads are always attached; if a list is empty, its head points
// to itself. 'count' contains the size of the list.
// If the list holds notes, 'pool' points back to the pool where it lives.
// Otherwise, that member is NULL.
struct AudioListItem *prev;
struct AudioListItem *next;
union {
void *value; // either Note* or SequenceChannelLayer*
s32 count;
} u;
struct NotePool *pool;
}; // size = 0x10
struct NotePool {
struct AudioListItem disabled;
struct AudioListItem decaying;
struct AudioListItem releasing;
struct AudioListItem active;
};
struct VibratoState {
/*0x00, 0x00*/ struct SequenceChannel *seqChannel;
/*0x04, 0x04*/ u32 time;
/* , 0x08*/ s16 *curve;
/* , 0x0C*/ f32 extent;
/* , 0x10*/ f32 rate;
/* , 0x14*/ u8 active;
/*0x12, 0x16*/ u16 rateChangeTimer;
/*0x14, 0x18*/ u16 extentChangeTimer;
/*0x16, 0x1A*/ u16 delay;
}; // size = 0x18, 0x1C on EU
// Pitch sliding by up to one octave in the positive direction. Negative
// direction is "supported" by setting extent to be negative. The code
// extrapolates exponentially in the wrong direction in that case, but that
// doesn't prevent seqplayer from doing it, AFAICT.
struct Portamento {
u8 mode; // bit 0x80 denotes something; the rest are an index 0-5
f32 cur;
f32 speed;
f32 extent;
}; // size = 0x10
struct AdsrEnvelope {
s16 delay;
s16 arg;
}; // size = 0x4
struct AdpcmLoop {
u32 start;
u32 end;
u32 count;
u32 pad;
s16 state[16]; // only exists if count != 0. 8-byte aligned
};
struct AdpcmBook {
s32 order;
s32 npredictors;
s16 book[1]; // size 8 * order * npredictors. 8-byte aligned
};
struct AudioBankSample {
u8 unused;
u8 loaded;
u8 *sampleAddr;
struct AdpcmLoop *loop;
struct AdpcmBook *book;
};
struct AudioBankSound {
struct AudioBankSample *sample;
f32 tuning; // frequency scale factor
}; // size = 0x8
struct Instrument {
/*0x00*/ u8 loaded;
/*0x01*/ u8 normalRangeLo;
/*0x02*/ u8 normalRangeHi;
/*0x03*/ u8 releaseRate;
/*0x04*/ struct AdsrEnvelope *envelope;
/*0x08*/ struct AudioBankSound lowNotesSound;
/*0x10*/ struct AudioBankSound normalNotesSound;
/*0x18*/ struct AudioBankSound highNotesSound;
}; // size = 0x20
struct Drum {
u8 releaseRate;
u8 pan;
u8 loaded;
struct AudioBankSound sound;
struct AdsrEnvelope *envelope;
};
struct AudioBank {
struct Drum **drums;
struct Instrument *instruments[1];
}; // dynamic size
struct CtlEntry {
u8 unused;
u8 numInstruments;
u8 numDrums;
struct Instrument **instruments;
struct Drum **drums;
}; // size = 0xC
struct M64ScriptState {
u8 *pc;
u8 *stack[4];
u8 remLoopIters[4];
u8 depth;
}; // size = 0x1C
// Also known as a Group, according to debug strings.
struct SequencePlayer {
/*0x000, 0x000, 0x000*/ u8 enabled : 1;
/*0x000, 0x000*/ u8 finished : 1; // never read
/*0x000, 0x000*/ u8 muted : 1;
/*0x000, 0x000*/ u8 seqDmaInProgress : 1;
/*0x000, 0x000*/ u8 bankDmaInProgress : 1;
/* 0x000*/ u8 recalculateVolume : 1;
/*0x002, 0x001, 0x001*/ u8 state;
/*0x003, 0x002*/ u8 noteAllocPolicy;
/*0x004, 0x003*/ u8 muteBehavior;
/*0x005, 0x004*/ u8 seqId;
/*0x006, 0x005*/ u8 defaultBank[1]; // must be an array to get a comparison
// to match; other u8's might also be part of that array
/*0x007, 0x006*/ u8 loadingBankId;
/* , 0x007, 0x007*/ s8 seqVariationEu[1];
/*0x00A, 0x008*/ u16 tempo; // beats per minute in JP, tatums per minute in US/EU
/*0x00C, 0x00A*/ u16 tempoAcc;
/*0x010, 0x00C, 0x00E*/ s16 transposition;
/*0x012, 0x00E, 0x010*/ u16 delay;
/*0x00E, 0x010, 0x012*/ u16 fadeRemainingFrames;
/* , 0x012, 0x014*/ u16 fadeTimerUnkEu;
/*0x014, 0x014*/ u8 *seqData; // buffer of some sort
/*0x018, 0x018, 0x1C*/ f32 fadeVolume; // set to 1.0f
/*0x01C, 0x01C*/ f32 fadeVelocity; // set to 0.0f
/*0x020, 0x020, 0x024*/ f32 volume; // set to 0.0f
/*0x024, 0x024*/ f32 muteVolumeScale; // set to 0.5f
/* , 0x028, 0x02C*/ f32 fadeVolumeScale;
/* , 0x02C*/ f32 appliedFadeVolume;
/*0x02C, 0x030, 0x034*/ struct SequenceChannel *channels[CHANNELS_MAX];
/*0x06C, 0x070*/ struct M64ScriptState scriptState;
/*0x088, 0x08C*/ u8 *shortNoteVelocityTable;
/*0x08C, 0x090*/ u8 *shortNoteDurationTable;
/*0x090, 0x094*/ struct NotePool notePool;
/*0x0D0, 0x0D4*/ OSMesgQueue seqDmaMesgQueue;
/*0x0E8, 0x0EC*/ OSMesg seqDmaMesg;
/*0x0EC, 0x0F0*/ OSIoMesg seqDmaIoMesg;
/*0x100, 0x108*/ OSMesgQueue bankDmaMesgQueue;
/*0x118, 0x120*/ OSMesg bankDmaMesg;
/*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg;
/*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr;
/*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr;
/*0x13C, 0x144*/ ssize_t bankDmaRemaining;
}; // size = 0x140, 0x148 on EU, 0x14C on SH
struct AdsrSettings {
u8 releaseRate;
u8 sustain;
struct AdsrEnvelope *envelope;
}; // size = 0x8
struct AdsrState {
/*0x00, 0x00*/ u8 action;
/*0x01, 0x01*/ u8 state;
/*0x08, 0x02*/ s16 envIndex;
/*0x0A, 0x04*/ s16 delay;
/* , 0x08*/ f32 sustain;
/* , 0x0C*/ f32 velocity;
/* , 0x10*/ f32 fadeOutVel;
/* , 0x14*/ f32 current;
/* , 0x18*/ f32 target;
s32 pad1C;
/*0x1C, 0x20*/ struct AdsrEnvelope *envelope;
}; // size = 0x20, 0x24 in EU
struct ReverbBitsData {
/* 0x00 */ u8 bit0 : 1;
/* 0x00 */ u8 bit1 : 1;
/* 0x00 */ u8 bit2 : 1;
/* 0x00 */ u8 usesHeadsetPanEffects : 1;
/* 0x00 */ u8 stereoHeadsetEffects : 2;
/* 0x00 */ u8 strongRight : 1;
/* 0x00 */ u8 strongLeft : 1;
};
union ReverbBits {
/* 0x00 */ struct ReverbBitsData s;
/* 0x00 */ u8 asByte;
};
struct ReverbInfo {
u8 reverbVol;
u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1
u8 pan;
union ReverbBits reverbBits;
f32 freqScale;
f32 velocity;
s32 unused;
s16 *filter;
};
struct NoteAttributes {
u8 reverbVol;
u8 pan;
f32 freqScale;
f32 velocity;
}; // size = 0x10
// Also known as a SubTrack, according to debug strings.
// Confusingly, a SubTrack is a container of Tracks.
struct SequenceChannel {
/* U/J, EU, SH */
/*0x00, 0x00*/ u8 enabled : 1;
/*0x00, 0x00*/ u8 finished : 1;
/*0x00, 0x00*/ u8 stopScript : 1;
/*0x00, 0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething
/*0x00, 0x00*/ u8 hasInstrument : 1;
/*0x00, 0x00*/ u8 stereoHeadsetEffects : 1;
/*0x00, ????*/ u8 largeNotes : 1; // notes specify duration and velocity
/*0x00, ????*/ u8 unused : 1; // never read, set to 0
/* , 0x01*/ union {
struct {
u8 freqScale : 1;
u8 volume : 1;
u8 pan : 1;
} as_bitfields;
u8 as_u8;
} changes;
/*0x01, 0x02*/ u8 noteAllocPolicy;
/*0x02, 0x03, 0x03*/ u8 muteBehavior;
/*0x03, 0x04, 0x04*/ u8 reverbVol; // until EU: Q1.7, after EU: UQ0.8
/*0x04, ????*/ u8 notePriority; // 0-3
/*0x05, 0x06*/ u8 bankId;
/* , 0x07*/ u8 reverbIndex;
/* , 0x08, 0x09*/ u8 bookOffset;
/* , 0x09*/ u8 newPan;
/* , 0x0A*/ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128)
/*0x08, 0x0C, 0x0E*/ u16 vibratoRateStart; // initially 0x800
/*0x0A, 0x0E, 0x10*/ u16 vibratoExtentStart;
/*0x0C, 0x10, 0x12*/ u16 vibratoRateTarget; // initially 0x800
/*0x0E, 0x12, 0x14*/ u16 vibratoExtentTarget;
/*0x10, 0x14, 0x16*/ u16 vibratoRateChangeDelay;
/*0x12, 0x16, 0x18*/ u16 vibratoExtentChangeDelay;
/*0x14, 0x18, 0x1A*/ u16 vibratoDelay;
/*0x16, 0x1A, 0x1C*/ u16 delay;
/*0x18, 0x1C, 0x1E*/ s16 instOrWave; // either 0 (none), instrument index + 1, or
// 0x80..0x83 for sawtooth/triangle/sine/square waves.
/*0x1A, 0x1E, 0x20*/ s16 transposition;
/*0x1C, 0x20, 0x24*/ f32 volumeScale;
/*0x20, 0x24, 0x28*/ f32 volume;
/* , 0x28*/ s32 pan;
/* , 0x2C*/ f32 appliedVolume;
/*0x2C, 0x30*/ f32 freqScale;
/*0x30, 0x34*/ u8 (*dynTable)[][2];
/*0x34, ????*/ struct Note *noteUnused; // never read
/*0x38, ????*/ struct SequenceChannelLayer *layerUnused; // never read
/*0x3C, 0x40*/ struct Instrument *instrument;
/*0x40, 0x44*/ struct SequencePlayer *seqPlayer;
/*0x44, 0x48*/ struct SequenceChannelLayer *layers[LAYERS_MAX];
/*0x54, 0x58 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib. For player 2,
// [0] contains enabled, [4] contains sound ID, [5] contains reverb adjustment
/*0x5C, 0x60*/ struct M64ScriptState scriptState;
/*0x78, 0x7C*/ struct AdsrSettings adsr;
/*0x80, 0x84*/ struct NotePool notePool;
}; // size = 0xC0, 0xC4 in EU, 0xD0 in SH
// Also known as a Track, according to debug strings.
struct SequenceChannelLayer {
/* U/J, EU, SH */
/*0x00, 0x00*/ u8 enabled : 1;
/*0x00, 0x00*/ u8 finished : 1;
/*0x00, 0x00*/ u8 stopSomething : 1; // ?
/*0x00, 0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
/* , 0x00*/ u8 unusedEu0b8 : 1;
/* , 0x00*/ u8 notePropertiesNeedInit : 1;
/* , 0x00*/ u8 ignoreDrumPan : 1;
/* , 0x01, 0x02*/ u8 instOrWave;
/*0x01, 0x02, 0x03*/ u8 status; // 0x03 in SH
/*0x02, 0x03*/ u8 noteDuration; // set to 0x80
/*0x03, 0x04*/ u8 portamentoTargetNote;
/* , 0x05*/ u8 pan; // 0..128
/* , 0x06, 0x07*/ u8 notePan;
/*0x04, 0x08*/ struct Portamento portamento;
/*0x14, 0x18*/ struct AdsrSettings adsr;
/*0x1C, 0x20*/ u16 portamentoTime;
/*0x1E, 0x22*/ s16 transposition; // #semitones added to play commands
// (m64 instruction encoding only allows referring to the limited range
// 0..0x3f; this makes 0x40..0x7f accessible as well)
/*0x20, 0x24, 0x24*/ f32 freqScale;
/*0x24, 0x28, 0x2C*/ f32 velocitySquare;
/*0x2C, 0x2C, 0x30*/ f32 noteVelocity;
/*0x34, 0x30, 0x34*/ f32 noteFreqScale;
/*0x38, 0x34*/ s16 shortNoteDefaultPlayPercentage;
/*0x3A, 0x36*/ s16 playPercentage; // it's not really a percentage...
/*0x3C, 0x38*/ s16 delay;
/*0x3E, 0x3A*/ s16 duration;
/*0x40, 0x3C*/ s16 delayUnused; // set to 'delay', never read
/*0x44, 0x40, 0x44*/ struct Note *note;
/*0x48, 0x44*/ struct Instrument *instrument;
/*0x4C, 0x48*/ struct AudioBankSound *sound;
/*0x50, 0x4C, 0x50*/ struct SequenceChannel *seqChannel;
/*0x54, 0x50*/ struct M64ScriptState scriptState;
/*0x70, 0x6C*/ struct AudioListItem listItem;
u8 pad2[4];
}; // size = 0x80
struct NoteSynthesisState {
/*0x00*/ u8 restart;
/*0x01*/ u8 sampleDmaIndex;
/*0x02*/ u8 prevHeadsetPanRight;
/*0x03*/ u8 prevHeadsetPanLeft;
/*0x04, 0x06*/ u16 samplePosFrac;
/*0x08*/ s32 samplePosInt;
/*0x0C*/ struct NoteSynthesisBuffers *synthesisBuffers;
/*0x10*/ s16 curVolLeft; // UQ0.16 (EU Q1.15)
/*0x12*/ s16 curVolRight; // UQ0.16 (EU Q1.15)
};
struct NotePlaybackState {
/* U/J, EU, SH */
/*0x04, 0x00, 0x00*/ u8 priority;
/* 0x01, 0x01*/ u8 waveId;
/* 0x02, 0x02*/ u8 sampleCountIndex;
/*0x08, 0x04, 0x06*/ s16 adsrVolScale;
/*0x18, 0x08, 0x08*/ f32 portamentoFreqScale;
/*0x1C, 0x0C, 0x0C*/ f32 vibratoFreqScale;
/*0x28, 0x10, */ struct SequenceChannelLayer *prevParentLayer;
/*0x2C, 0x14, 0x14*/ struct SequenceChannelLayer *parentLayer;
/*0x30, 0x18, 0x18*/ struct SequenceChannelLayer *wantedParentLayer;
/* , 0x1C, 0x1C*/ struct NoteAttributes attributes;
/*0x54, 0x28, 0x2C*/ struct AdsrState adsr;
/*0x74, 0x4C, */ struct Portamento portamento;
/*0x84, 0x5C, */ struct VibratoState vibratoState;
};
struct NoteSubEu {
/*0x00*/ volatile u8 enabled : 1;
/*0x00*/ u8 needsInit : 1;
/*0x00*/ u8 finished : 1;
/*0x00*/ u8 envMixerNeedsInit : 1;
/*0x00*/ u8 stereoStrongRight : 1;
/*0x00*/ u8 stereoStrongLeft : 1;
/*0x00*/ u8 stereoHeadsetEffects : 1;
/*0x00*/ u8 usesHeadsetPanEffects : 1;
/*0x01*/ u8 reverbIndex : 3;
/*0x01*/ u8 bookOffset : 3;
/*0x01*/ u8 isSyntheticWave : 1;
/*0x01*/ u8 hasTwoAdpcmParts : 1;
/*0x02*/ u8 bankId;
/*0x03*/ u8 headsetPanRight;
/*0x04*/ u8 headsetPanLeft;
/*0x05*/ u8 reverbVol; // UQ0.7 (EU Q1.7)
/*0x06*/ u16 targetVolLeft; // UQ0.12 (EU UQ0.10)
/*0x08*/ u16 targetVolRight; // UQ0.12 (EU UQ0.10)
/*0x0A*/ u16 resamplingRateFixedPoint; // stored as signed but loaded as u16
/*0x0C*/ union {
s16 *samples;
struct AudioBankSound *audioBankSound;
} sound;
};
struct Note {
/* U/J, EU, SH */
/*0xA4, 0x00, 0x00*/ struct AudioListItem listItem;
/* 0x10, 0x10*/ struct NoteSynthesisState synthesisState;
// The next members are actually part of a struct (NotePlaybackState), but
// that results in messy US/EU ifdefs. Instead we cast to a struct pointer
// when needed... This breaks alignment on non-N64 platforms, which we hack
// around by skipping the padding in that case.
// TODO: use macros or something instead.
#ifdef TARGET_N64
u8 pad0[12];
#endif
/*0x04, 0x30, 0x30*/ u8 priority;
/* 0x31, 0x31*/ u8 waveId;
/* 0x32, 0x32*/ u8 sampleCountIndex;
/*0x08, 0x34, 0x36*/ s16 adsrVolScale;
/*0x18, 0x38, */ f32 portamentoFreqScale;
/*0x1C, 0x3C, */ f32 vibratoFreqScale;
/*0x28, 0x40, */ struct SequenceChannelLayer *prevParentLayer;
/*0x2C, 0x44, 0x44*/ struct SequenceChannelLayer *parentLayer;
/*0x30, 0x48, 0x48*/ struct SequenceChannelLayer *wantedParentLayer;
/* , 0x4C, 0x4C*/ struct NoteAttributes attributes;
/*0x54, 0x58, 0x5C*/ struct AdsrState adsr;
/*0x74, 0x7C*/ struct Portamento portamento;
/*0x84, 0x8C*/ struct VibratoState vibratoState;
u8 pad3[8];
/* , 0xB0, 0xB4*/ struct NoteSubEu noteSubEu;
}; // size = 0xC0, known to be 0xC8 on SH
struct NoteSynthesisBuffers {
s16 adpcmdecState[0x10];
s16 finalResampleState[0x10];
s16 mixEnvelopeState[0x28];
s16 panResampleState[0x10];
s16 panSamplesBuffer[0x20];
s16 dummyResampleState[0x10];
};
struct ReverbSettingsEU {
u8 downsampleRate;
u8 windowSize; // To be multiplied by 64
u16 gain;
};
struct AudioSessionSettingsEU {
/* 0x00 */ u32 frequency;
/* 0x04 */ u8 unk1; // always 1
/* 0x05 */ u8 maxSimultaneousNotes;
/* 0x06 */ u8 numReverbs; // always 1
/* 0x07 */ u8 unk2; // always 0
/* 0x08 */ struct ReverbSettingsEU *reverbSettings;
/* 0x0C */ u16 volume;
/* 0x0E */ u16 unk3; // always 0
/* 0x10 */ u32 persistentSeqMem;
/* 0x14 */ u32 persistentBankMem;
/* 0x18, 0x1C */ u32 temporarySeqMem;
/* 0x1C, 0x20 */ u32 temporaryBankMem;
}; // 0x30 on shindou
struct AudioSessionSettings {
/*0x00*/ u32 frequency;
/*0x04*/ u8 maxSimultaneousNotes;
/*0x05*/ u8 reverbDownsampleRate; // always 1
/*0x06*/ u16 reverbWindowSize;
/*0x08*/ u16 reverbGain;
/*0x0A*/ u16 volume;
/*0x0C*/ u32 persistentSeqMem;
/*0x10*/ u32 persistentBankMem;
/*0x14*/ u32 temporarySeqMem;
/*0x18*/ u32 temporaryBankMem;
}; // size = 0x1C
struct AudioBufferParametersEU {
/*0x00*/ s16 presetUnk4; // audio frames per vsync?
/*0x02*/ u16 frequency;
/*0x04*/ u16 aiFrequency; // ?16
/*0x06*/ s16 samplesPerFrameTarget;
/*0x08*/ s16 maxAiBufferLength;
/*0x0A*/ s16 minAiBufferLength;
/*0x0C*/ s16 updatesPerFrame;
/*0x0E*/ s16 samplesPerUpdate;
/*0x10*/ s16 samplesPerUpdateMax;
/*0x12*/ s16 samplesPerUpdateMin;
/*0x14*/ f32 resampleRate; // contains 32000.0f / frequency
/*0x18*/ f32 updatesPerFrameInv; // 1.0f / updatesPerFrame
/*0x1C*/ f32 unkUpdatesPerFrameScaled; // 3.0f / (1280.0f * updatesPerFrame)
};
struct EuAudioCmd {
union {
#if IS_BIG_ENDIAN
struct {
u8 op;
u8 arg1;
u8 arg2;
u8 arg3;
} s;
#else
struct {
u8 arg3;
u8 arg2;
u8 arg1;
u8 op;
} s;
#endif
s32 first;
} u;
union {
s32 as_s32;
u32 as_u32;
f32 as_f32;
#if IS_BIG_ENDIAN
u8 as_u8;
s8 as_s8;
#else
struct {
u8 pad0[3];
u8 as_u8;
};
struct {
u8 pad1[3];
s8 as_s8;
};
#endif
} u2;
};
#endif // AUDIO_INTERNAL_H