Merge branch 'master' into otr

This commit is contained in:
KiritoDv
2024-04-08 18:05:46 -06:00
committed by Sonic Dreamcaster
507 changed files with 120585 additions and 57915 deletions
+118 -61
View File
@@ -34,13 +34,13 @@ AudioCommonPoolSplit gTemporaryCommonPoolSplit;
u8 gSampleFontLoadStatus[64];
u8 gFontLoadStatus[64];
u8 gSeqLoadStatus[256];
volatile u8 gResetStatus;
volatile u8 gAudioResetStep;
u8 gAudioSpecId;
s32 gResetFadeoutFramesLeft;
u8 sAudioContextPad1000[0x1000]; // 0x1000 gap
Note* gNotes;
// 0x4
SequencePlayer gSeqPlayers[4];
SequencePlayer gSeqPlayers[SEQ_PLAYER_MAX];
SequenceChannel gSeqChannels[48];
SequenceLayer gSeqLayers[64];
SequenceChannel gSeqChannelNone;
@@ -100,43 +100,43 @@ s16* gAiBuffers[3];
s16 gAiBuffLengths[3];
u32 gAudioRandom;
u32 D_80155D88;
volatile u32 gResetTimer;
volatile u32 gAudioResetTimer;
u64 gAudioContextEnd[2];
static ReverbSettings D_800C74D0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0xD000, 0x3000 } };
static ReverbSettings D_800C74E0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x38, 0x6400, 0x1000, 0x1000 } };
static ReverbSettings D_800C74F0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0, 0 } };
static ReverbSettings D_800C7500[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5000, 0, 0 } };
static ReverbSettings D_800C7510[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x6000, 0, 0 } };
static ReverbSettings D_800C7520[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7530[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5800, 0, 0 } };
static ReverbSettings D_800C7540[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5000, 0, 0 } };
static ReverbSettings D_800C7550[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7560[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x6000, 0, 0 } };
static ReverbSettings D_800C7570[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7580[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0, 0 } };
static ReverbSettings D_800C7590[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 2, 0x28, 0x5800, 0, 0 } };
static ReverbSettings D_800C75A0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C75B0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x38, 0x5000, 0, 0 } };
static ReverbSettings D_800C75C0[3] = {
ReverbSettings D_800C74D0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0xD000, 0x3000 } };
ReverbSettings D_800C74E0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x38, 0x6400, 0x1000, 0x1000 } };
ReverbSettings D_800C74F0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0, 0 } };
ReverbSettings D_800C7500[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5000, 0, 0 } };
ReverbSettings D_800C7510[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x6000, 0, 0 } };
ReverbSettings D_800C7520[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7530[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5800, 0, 0 } };
ReverbSettings D_800C7540[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x5000, 0, 0 } };
ReverbSettings D_800C7550[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7560[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x6000, 0, 0 } };
ReverbSettings D_800C7570[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7580[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x40, 0x4000, 0, 0 } };
ReverbSettings D_800C7590[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 2, 0x28, 0x5800, 0, 0 } };
ReverbSettings D_800C75A0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C75B0[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x38, 0x5000, 0, 0 } };
ReverbSettings D_800C75C0[3] = {
{ 1, 0x30, 0x3000, 0, 0 },
{ 1, 0x38, 0x3000, 0, 0 },
{ 2, 0x48, 0x6000, 0xC000, 0x4000 },
};
static ReverbSettings D_800C75D8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C75E8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C75F8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7608[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7618[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7628[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7638[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x6800, 0, 0 } };
static ReverbSettings D_800C7648[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x18, 0x3000, 0, 0 } };
static ReverbSettings D_800C7658[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 2, 0x18, 0x3000, 0, 0 } };
static ReverbSettings D_800C7668[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x18, 0x3000, 0, 0 } };
static ReverbSettings D_800C7678[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C7688[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
static ReverbSettings D_800C76A8[] = {
ReverbSettings D_800C75D8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C75E8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C75F8[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7608[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7618[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7628[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7638[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x6800, 0, 0 } };
ReverbSettings D_800C7648[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x18, 0x3000, 0, 0 } };
ReverbSettings D_800C7658[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 2, 0x18, 0x3000, 0, 0 } };
ReverbSettings D_800C7668[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x18, 0x3000, 0, 0 } };
ReverbSettings D_800C7678[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C7688[2] = { { 1, 0x30, 0x3000, 0, 0 }, { 1, 0x30, 0x3000, 0, 0 } };
ReverbSettings D_800C76A8[] = {
// unused?
{ 1, 0x40, 0x4FFF, 0, 0 },
{ 1, 0x30, 0x4FFF, 0, 0 },
@@ -144,35 +144,92 @@ static ReverbSettings D_800C76A8[] = {
{ 1, 0x30, 0x4FFF, 0, 0 },
};
AudioSpec gAudioSpecs[] = {
{ 0x7D00, 2, 0x16, 2, D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 1, 0x16, 2, D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 3, D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x34000 },
{ 0x7D00, 2, 0x16, 2, D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x16, 2, D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
{ 0x7D00, 2, 0x20, 2, D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0 },
{ 0x7D00, 1, 0x20, 2, D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0 },
{ 0x7D00, 1, 0x20, 2, D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0, 0 },
{ 0x7D00, 1, 0x16, 2, D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0, 0x60000 },
{ 0x7D00, 2, 0x16, 2, D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0 },
{ 0x7D00, 2, 0x16, 2, D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0 },
{ 0x7D00, 2, 0x20, 2, D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0 },
{ 0x7D00, 2, 0x16, 2, D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000, 0x35000 },
/* 0 */ { 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 1 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C74E0), D_800C74E0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 2 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C74F0), D_800C74F0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 3 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7500), D_800C7500, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 4 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7510), D_800C7510, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 5 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7520), D_800C7520, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 6 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7530), D_800C7530, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 7 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7540), D_800C7540, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 8 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7550), D_800C7550, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 9 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7560), D_800C7560, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 10 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7570), D_800C7570, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 11 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7580), D_800C7580, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 12 */
{ 32000, 1, 22, ARRAY_COUNT(D_800C7590), D_800C7590, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x2B000,
0x35000 },
/* 13 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75A0), D_800C75A0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 14 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75B0), D_800C75B0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 15 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75C0), D_800C75C0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x34000 },
/* 16 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75D8), D_800C75D8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 17 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75E8), D_800C75E8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 18 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C75F8), D_800C75F8, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 19 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7608), D_800C7608, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 20 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7618), D_800C7618, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
/* 21 */
{ 32000, 2, 32, ARRAY_COUNT(D_800C7628), D_800C7628, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 22 */
{ 32000, 1, 32, ARRAY_COUNT(D_800C7638), D_800C7638, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 23 */
{ 32000, 1, 32, ARRAY_COUNT(D_800C7648), D_800C7648, 0x7FFF, 0x1200, 0xA000, 0, 0x5B00, 0x1D00, 0, 0x00000,
0x00000 },
/* 24 */
{ 32000, 1, 22, ARRAY_COUNT(D_800C7658), D_800C7658, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x00000,
0x60000 },
/* 25 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7668), D_800C7668, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 26 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C7678), D_800C7678, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 27 */
{ 32000, 2, 32, ARRAY_COUNT(D_800C7688), D_800C7688, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x00000 },
/* 28 */
{ 32000, 2, 22, ARRAY_COUNT(D_800C74D0), D_800C74D0, 0x7FFF, 0x1200, 0x1100, 0, 0x5000, 0x2400, 0, 0x1B000,
0x35000 },
};
s32 D_800C7C28 = 0x20000000; // unused?
s16 gSeqTicksPerBeat = 0x30;
+48 -49
View File
@@ -1,7 +1,7 @@
#include "sys.h"
#include "sf64audio_provisional.h"
static char devstr[] = "Audio:Envp: overflow %f\n";
static const char devstr[] = "Audio:Envp: overflow %f\n";
void func_80013400(SequenceChannel* channel, s32 updateVolume) {
s32 i;
@@ -17,7 +17,7 @@ void func_80013400(SequenceChannel* channel, s32 updateVolume) {
if (channel->changes.s.pan) {
channel->pan = channel->newPan * channel->panChannelWeight;
}
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(channel->layers); i++) {
SequenceLayer* layer = channel->layers[i];
if ((layer != NULL) && layer->enabled && (layer->note != NULL)) {
@@ -146,31 +146,31 @@ void func_80013A18(Note* note) {
}
void func_80013A84(Note* note) {
NotePlaybackState* temp_v0_3 = &note->playbackState;
VibratoState* temp_v1 = &temp_v0_3->vibratoState;
NotePlaybackState* noteState = &note->playbackState;
VibratoState* vibrato = &noteState->vibratoState;
temp_v1->active = 1;
temp_v1->time = 0;
temp_v0_3->vibratoFreqMod = 1.0f;
temp_v0_3->portamentoFreqMod = 1.0f;
vibrato->active = 1;
vibrato->time = 0;
noteState->vibratoFreqMod = 1.0f;
noteState->portamentoFreqMod = 1.0f;
temp_v1->curve = gWaveSamples[2];
vibrato->curve = gWaveSamples[2];
temp_v1->channel = temp_v0_3->parentLayer->channel;
vibrato->channel = noteState->parentLayer->channel;
if ((temp_v1->depthChangeTimer = temp_v1->channel->vibratoDepthChangeDelay) == 0) {
temp_v1->depth = (s32) temp_v1->channel->vibratoDepthTarget;
if ((vibrato->depthChangeTimer = vibrato->channel->vibratoDepthChangeDelay) == 0) {
vibrato->depth = (s32) vibrato->channel->vibratoDepthTarget;
} else {
temp_v1->depth = (s32) temp_v1->channel->vibratoDepthStart;
vibrato->depth = (s32) vibrato->channel->vibratoDepthStart;
}
if ((temp_v1->rateChangeTimer = temp_v1->channel->vibratoRateChangeDelay) == 0) {
temp_v1->rate = (s32) temp_v1->channel->vibratoRateTarget;
if ((vibrato->rateChangeTimer = vibrato->channel->vibratoRateChangeDelay) == 0) {
vibrato->rate = (s32) vibrato->channel->vibratoRateTarget;
} else {
temp_v1->rate = (s32) temp_v1->channel->vibratoRateStart;
vibrato->rate = (s32) vibrato->channel->vibratoRateStart;
}
temp_v1->delay = temp_v1->channel->vibratoDelay;
temp_v0_3->portamento = temp_v0_3->parentLayer->portamento;
vibrato->delay = vibrato->channel->vibratoDelay;
noteState->portamento = noteState->parentLayer->portamento;
}
void func_80013B6C(AdsrState* adsr, EnvelopePoint* envelope, s16* arg2) {
@@ -187,36 +187,35 @@ f32 func_80013B90(AdsrState* adsr) {
u8 state = adsr->state;
switch (state) {
case 0:
case ADSR_STATE_DISABLED:
return 0.0f;
case 1:
case ADSR_STATE_INITIAL:
if (action & 0x40) {
adsr->state = 5;
adsr->state = ADSR_STATE_HANG;
break;
}
case 2:
case ADSR_STATE_START_LOOP:
adsr->envIndex = 0;
adsr->state = 3;
case_3:
case 3:
adsr->state = ADSR_STATE_LOOP;
case_ADSR_STATE_LOOP:
case ADSR_STATE_LOOP:
adsr->delay = adsr->envelope[adsr->envIndex].delay;
switch (adsr->delay) {
case 0:
adsr->state = 0;
case ADSR_DISABLE:
adsr->state = ADSR_STATE_DISABLED;
break;
case -1:
adsr->state = 5;
case ADSR_HANG:
adsr->state = ADSR_STATE_HANG;
break;
case -2:
case ADSR_GOTO:
adsr->envIndex = adsr->envelope[adsr->envIndex].arg;
goto case_3;
case -3:
adsr->state = 1;
goto case_ADSR_STATE_LOOP;
case ADSR_RESTART:
adsr->state = ADSR_STATE_INITIAL;
break;
default:
if (adsr->delay >= 4) {
adsr->delay =
(adsr->delay * gAudioBufferParams.ticksPerUpdate / gAudioBufferParams.specUnk4) / 4;
adsr->delay = (adsr->delay * gAudioBufferParams.ticksPerUpdate / gAudioBufferParams.count) / 4;
}
if (adsr->delay == 0) {
adsr->delay = 1;
@@ -225,47 +224,47 @@ f32 func_80013B90(AdsrState* adsr) {
adsr->target = adsr->envelope[adsr->envIndex].arg / 32767.0f;
adsr->target = SQ(adsr->target);
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
adsr->state = 4;
adsr->state = ADSR_STATE_FADE;
adsr->envIndex++;
break;
}
if (adsr->state != 4) {
if (adsr->state != ADSR_STATE_FADE) {
break;
}
case 4:
adsr->delay -= 1;
case ADSR_STATE_FADE:
adsr->delay--;
adsr->current += adsr->velocity;
if (adsr->delay <= 0) {
adsr->state = 3;
adsr->state = ADSR_STATE_LOOP;
}
break;
case 6:
case 7:
case ADSR_STATE_DECAY:
case ADSR_STATE_RELEASE:
adsr->current -= adsr->fadeOutVel;
if ((adsr->sustain != 0.0f) && (state == 6)) {
if ((adsr->sustain != 0.0f) && (state == ADSR_STATE_DECAY)) {
if (adsr->current < adsr->sustain) {
adsr->current = adsr->sustain;
adsr->delay = 0x80;
adsr->state = 8;
adsr->state = ADSR_STATE_SUSTAIN;
}
} else if (adsr->current < 0.00001f) {
adsr->current = 0.0f;
adsr->state = 0;
adsr->state = ADSR_STATE_DISABLED;
}
break;
case 8:
case ADSR_STATE_SUSTAIN:
adsr->delay--;
if (adsr->delay == 0) {
adsr->state = 7;
adsr->state = ADSR_STATE_RELEASE;
}
break;
}
if (action & 0x20) {
adsr->state = 6;
adsr->state = ADSR_STATE_DECAY;
adsr->action.asByte = action & ~0x20;
}
if (action & 0x10) {
adsr->state = 7;
adsr->state = ADSR_STATE_RELEASE;
adsr->action.asByte = action & ~0x10;
}
if (adsr->current < 0.0f) {
+583 -704
View File
File diff suppressed because it is too large Load Diff
+125 -115
View File
@@ -11,62 +11,62 @@ void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id);
void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id);
SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(u32);
static char devstr00[] = "Warning:Kill Note %x \n";
static char devstr01[] = "Kill Voice %d (ID %d) %d\n";
static char devstr02[] = "Warning: Running Sequence's data disappear!\n";
static char devstr03[] = "%x %x %x\n";
static char devstr04[] = "Audio:Memory:Heap OverFlow : Not Allocate %d!\n";
static char devstr05[] = "%x %x %x\n";
static char devstr06[] = "Audio:Memory:Heap OverFlow : Not Allocate %d!\n";
static char devstr07[] = "Audio:Memory:DataHeap Not Allocate \n";
static char devstr08[] = "StayHeap Not Allocate %d\n";
static char devstr09[] = "AutoHeap Not Allocate %d\n";
static char devstr10[] = "Status ID0 : %d ID1 : %d\n";
static char devstr11[] = "id 0 is Stopping\n";
static char devstr12[] = "id 0 is Stop\n";
static char devstr13[] = "id 1 is Stopping\n";
static char devstr14[] = "id 1 is Stop\n";
static char devstr15[] = "WARNING: NO FREE AUTOSEQ AREA.\n";
static char devstr16[] = "WARNING: NO STOP AUTO AREA.\n";
static char devstr17[] = " AND TRY FORCE TO STOP SIDE \n";
static char devstr18[] = "Check ID0 (seq ID %d) Useing ...\n";
static char devstr19[] = "Check ID1 (seq ID %d) Useing ...\n";
static char devstr20[] = "No Free Seq area.\n";
static char devstr21[] = "CH %d: ID %d\n";
static char devstr22[] = "TWO SIDES ARE LOADING... ALLOC CANCELED.\n";
static char devstr23[] = "WARNING: Before Area Overlaid After.";
static char devstr24[] = "WARNING: After Area Overlaid Before.";
static char devstr25[] = "MEMORY:SzHeapAlloc ERROR: sza->side %d\n";
static char devstr26[] = "Audio:MEMORY:SzHeap Overflow error. (%d bytes)\n";
static char devstr27[] = "Auto Heap Unhit for ID %d\n";
static char devstr28[] = "Heap Reconstruct Start %x\n";
static char devstr29[] = "---------------------------------------TEMPO %d %f\n";
static char devstr30[] = "%f \n";
static char devstr31[] = "%f \n";
static char devstr32[] = "AHPBASE %x\n";
static char devstr33[] = "AHPCUR %x\n";
static char devstr34[] = "HeapTop %x\n";
static char devstr35[] = "SynoutRate %d / %d \n";
static char devstr36[] = "FXSIZE %d\n";
static char devstr37[] = "FXCOMP %d\n";
static char devstr38[] = "FXDOWN %d\n";
static char devstr39[] = "WaveCacheLen: %d\n";
static char devstr40[] = "SpecChange Finished\n";
static char devstr41[] = "Warning:Emem Over,not alloc %d\n";
static char devstr42[] = "Single AutoSize %d\n";
static char devstr43[] = "Single Ptr %x\n";
static char devstr44[] = "Request--------Single-Auto, %d\n";
static char devstr45[] = "Retry %x, %x, len %x\n";
static char devstr46[] = "DMAing list %d is killed.\n";
static char devstr47[] = "Try Kill %d \n";
static char devstr48[] = "Try Kill %x %x\n";
static char devstr49[] = "Try Kill %x %x %x\n";
static char devstr50[] = "Rom back %x %x \n";
static char devstr51[] = "Error sw NULL \n";
static char devstr52[] = "Request--------Single-Stay, %d\n";
static char devstr53[] = "Try Kill %d \n";
static char devstr54[] = "Try Kill %x %x\n";
static char devstr55[] = "Try Kill %x %x %x\n";
static const char devstr00[] = "Warning:Kill Note %x \n";
static const char devstr01[] = "Kill Voice %d (ID %d) %d\n";
static const char devstr02[] = "Warning: Running Sequence's data disappear!\n";
static const char devstr03[] = "%x %x %x\n";
static const char devstr04[] = "Audio:Memory:Heap OverFlow : Not Allocate %d!\n";
static const char devstr05[] = "%x %x %x\n";
static const char devstr06[] = "Audio:Memory:Heap OverFlow : Not Allocate %d!\n";
static const char devstr07[] = "Audio:Memory:DataHeap Not Allocate \n";
static const char devstr08[] = "StayHeap Not Allocate %d\n";
static const char devstr09[] = "AutoHeap Not Allocate %d\n";
static const char devstr10[] = "Status ID0 : %d ID1 : %d\n";
static const char devstr11[] = "id 0 is Stopping\n";
static const char devstr12[] = "id 0 is Stop\n";
static const char devstr13[] = "id 1 is Stopping\n";
static const char devstr14[] = "id 1 is Stop\n";
static const char devstr15[] = "WARNING: NO FREE AUTOSEQ AREA.\n";
static const char devstr16[] = "WARNING: NO STOP AUTO AREA.\n";
static const char devstr17[] = " AND TRY FORCE TO STOP SIDE \n";
static const char devstr18[] = "Check ID0 (seq ID %d) Useing ...\n";
static const char devstr19[] = "Check ID1 (seq ID %d) Useing ...\n";
static const char devstr20[] = "No Free Seq area.\n";
static const char devstr21[] = "CH %d: ID %d\n";
static const char devstr22[] = "TWO SIDES ARE LOADING... ALLOC CANCELED.\n";
static const char devstr23[] = "WARNING: Before Area Overlaid After.";
static const char devstr24[] = "WARNING: After Area Overlaid Before.";
static const char devstr25[] = "MEMORY:SzHeapAlloc ERROR: sza->side %d\n";
static const char devstr26[] = "Audio:MEMORY:SzHeap Overflow error. (%d bytes)\n";
static const char devstr27[] = "Auto Heap Unhit for ID %d\n";
static const char devstr28[] = "Heap Reconstruct Start %x\n";
static const char devstr29[] = "---------------------------------------TEMPO %d %f\n";
static const char devstr30[] = "%f \n";
static const char devstr31[] = "%f \n";
static const char devstr32[] = "AHPBASE %x\n";
static const char devstr33[] = "AHPCUR %x\n";
static const char devstr34[] = "HeapTop %x\n";
static const char devstr35[] = "SynoutRate %d / %d \n";
static const char devstr36[] = "FXSIZE %d\n";
static const char devstr37[] = "FXCOMP %d\n";
static const char devstr38[] = "FXDOWN %d\n";
static const char devstr39[] = "WaveCacheLen: %d\n";
static const char devstr40[] = "SpecChange Finished\n";
static const char devstr41[] = "Warning:Emem Over,not alloc %d\n";
static const char devstr42[] = "Single AutoSize %d\n";
static const char devstr43[] = "Single Ptr %x\n";
static const char devstr44[] = "Request--------Single-Auto, %d\n";
static const char devstr45[] = "Retry %x, %x, len %x\n";
static const char devstr46[] = "DMAing list %d is killed.\n";
static const char devstr47[] = "Try Kill %d \n";
static const char devstr48[] = "Try Kill %x %x\n";
static const char devstr49[] = "Try Kill %x %x %x\n";
static const char devstr50[] = "Rom back %x %x \n";
static const char devstr51[] = "Error sw NULL \n";
static const char devstr52[] = "Request--------Single-Stay, %d\n";
static const char devstr53[] = "Try Kill %d \n";
static const char devstr54[] = "Try Kill %x %x\n";
static const char devstr55[] = "Try Kill %x %x %x\n";
void AudioHeap_ResetLoadStatus(void) {
s32 i;
@@ -95,7 +95,7 @@ void AudioHeap_DiscardFont(s32 fontId) {
for (i = 0; i < gNumNotes; i++) {
note = &gNotes[i];
if (fontId == note->playbackState.fontId) {
if (note->playbackState.unk_04 == 0 && note->playbackState.priority != 0) {
if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) {
note->playbackState.parentLayer->enabled = false;
note->playbackState.parentLayer->finished = true;
}
@@ -109,7 +109,7 @@ void AudioHeap_DiscardFont(s32 fontId) {
void AudioHeap_DiscardSequence(s32 seqId) {
s32 i;
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
if (gSeqPlayers[i].enabled && gSeqPlayers[i].seqId == seqId) {
func_800144E4(&gSeqPlayers[i]);
}
@@ -137,7 +137,7 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, u32 size) {
u32 aligned = ALIGN16(size);
u8* ramAddr = pool->curRamAddr;
if (pool->startRamAddr + pool->size >= pool->curRamAddr + aligned) {
if ((pool->startRamAddr + pool->size) >= (pool->curRamAddr + aligned)) {
pool->curRamAddr += aligned;
} else {
return NULL;
@@ -230,20 +230,20 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
u8* loadStatus;
switch (tableType) {
case 0:
case SEQUENCE_TABLE:
loadedCache = &gSeqCache;
loadStatus = gSeqLoadStatus;
break;
case 1:
case FONT_TABLE:
loadedCache = &gFontCache;
loadStatus = gFontLoadStatus;
break;
case 2:
case SAMPLE_TABLE:
loadedCache = &gSampleBankCache;
loadStatus = gSampleFontLoadStatus;
break;
}
if (cache == 0) {
if (cache == CACHE_TEMPORARY) {
temporaryCache = &loadedCache->temporary;
temporaryPool = &temporaryCache->pool;
if (loadedCache->temporary.entries[0].id == -1) {
@@ -256,7 +256,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
} else {
loadStatusEntry1 = loadStatus[temporaryCache->entries[1].id];
}
if (tableType == 1) {
if (tableType == FONT_TABLE) {
if (loadStatusEntry0 == 4) {
for (i = 0; i < gNumNotes; i++) {
if ((gNotes[i].playbackState.fontId == temporaryCache->entries[0].id) &&
@@ -298,9 +298,9 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
temporaryCache->nextSide = 1;
} else {
// Check if there is a side which isn't in active use, if so, evict that one.
if (tableType == 0) {
if (tableType == SEQUENCE_TABLE) {
if (loadStatusEntry0 == 2) {
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
if (gSeqPlayers[i].enabled && (gSeqPlayers[i].seqId == temporaryCache->entries[0].id)) {
break;
}
@@ -311,7 +311,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
}
}
if (loadStatusEntry1 == 2) {
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
if (gSeqPlayers[i].enabled && (gSeqPlayers[i].seqId == temporaryCache->entries[1].id)) {
break;
}
@@ -321,7 +321,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
goto block_85;
}
}
} else if (tableType == 1) {
} else if (tableType == FONT_TABLE) {
if (loadStatusEntry0 == 2) {
for (i = 0; i < gNumNotes; i++) {
if ((gNotes[i].playbackState.fontId == temporaryCache->entries[0].id) &&
@@ -373,7 +373,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
if (temporaryCache->entries[temporaryCache->nextSide].id != -1) {
loadStatus[temporaryCache->entries[temporaryCache->nextSide].id] = 0;
if (tableType == 1) {
if (tableType == FONT_TABLE) {
AudioHeap_DiscardFont(temporaryCache->entries[temporaryCache->nextSide].id);
}
}
@@ -387,10 +387,10 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
(temporaryCache->entries[1].ramAddr < temporaryPool->curRamAddr)) {
loadStatus[temporaryCache->entries[1].id] = 0;
switch (tableType) {
case 0:
case SEQUENCE_TABLE:
AudioHeap_DiscardSequence(temporaryCache->entries[1].id);
break;
case 1:
case FONT_TABLE:
AudioHeap_DiscardFont(temporaryCache->entries[1].id);
break;
}
@@ -408,10 +408,10 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
(temporaryCache->entries[1].ramAddr < temporaryPool->curRamAddr)) {
loadStatus[temporaryCache->entries[0].id] = 0;
switch (tableType) {
case 0:
case SEQUENCE_TABLE:
AudioHeap_DiscardSequence(temporaryCache->entries[0].id);
break;
case 1:
case FONT_TABLE:
AudioHeap_DiscardFont(temporaryCache->entries[0].id);
break;
}
@@ -430,10 +430,10 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
loadedCache->persistent.entries[loadedCache->persistent.numEntries].ramAddr = persistentRamAddr;
if (persistentRamAddr == NULL) {
switch (cache) {
case 2:
return AudioHeap_AllocCached(tableType, size, 0, id);
case 0:
case 1:
case CACHE_EITHER:
return AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, id);
case CACHE_TEMPORARY:
case CACHE_PERSISTENT:
return NULL;
}
}
@@ -442,7 +442,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
return loadedCache->persistent.entries[loadedCache->persistent.numEntries++].ramAddr;
}
s32 AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) {
void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) {
void* ramAddr;
// Always search the permanent cache in addition to the regular ones.
@@ -464,15 +464,15 @@ void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) {
switch (tableType) {
case SEQUENCE_TABLE:
loadedCache = (AudioCache*) &gSeqCache;
loadedCache = &gSeqCache;
break;
case FONT_TABLE:
loadedCache = (AudioCache*) &gFontCache;
loadedCache = &gFontCache;
break;
case SAMPLE_TABLE:
loadedCache = (AudioCache*) &gSampleBankCache;
loadedCache = &gSampleBankCache;
break;
}
@@ -535,14 +535,14 @@ void AudioHeap_UpdateReverbs(void) {
s32 count;
s32 reverbIndex;
if (gAudioBufferParams.specUnk4 == 2) {
if (gAudioBufferParams.count == 2) {
count = 2;
} else {
count = 1;
}
for (reverbIndex = 0; reverbIndex < gNumSynthReverbs; reverbIndex++) {
for (i = 0; i < count; i++) {
gSynthReverbs[reverbIndex].unk_08 -= gSynthReverbs[reverbIndex].unk_08 / 3;
gSynthReverbs[reverbIndex].decayRatio -= gSynthReverbs[reverbIndex].decayRatio / 3;
}
}
}
@@ -563,18 +563,18 @@ s32 AudioHeap_ResetStep(void) {
s32 j;
s32 sp24;
if (gAudioBufferParams.specUnk4 == 2) {
if (gAudioBufferParams.count == 2) {
sp24 = 2;
} else {
sp24 = 1;
}
switch (gResetStatus) {
switch (gAudioResetStep) {
case 5:
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
func_800144E4(&gSeqPlayers[i]);
}
gResetFadeoutFramesLeft = 4 / sp24;
gResetStatus--;
gAudioResetStep--;
break;
case 4:
if (gResetFadeoutFramesLeft != 0) {
@@ -589,7 +589,7 @@ s32 AudioHeap_ResetStep(void) {
}
gResetFadeoutFramesLeft = 16 / sp24;
gResetStatus--;
gAudioResetStep--;
}
break;
case 3:
@@ -603,7 +603,7 @@ s32 AudioHeap_ResetStep(void) {
}
}
gResetFadeoutFramesLeft = 4 / sp24;
gResetStatus--;
gAudioResetStep--;
break; // needed to match
}
break;
@@ -612,13 +612,13 @@ s32 AudioHeap_ResetStep(void) {
if (gResetFadeoutFramesLeft != 0) {
gResetFadeoutFramesLeft--;
} else {
gResetStatus--;
gAudioResetStep--;
AudioHeap_DiscardSampleCaches();
}
break;
case 1:
AudioHeap_Init();
gResetStatus = 0;
gAudioResetStep = 0;
for (i = 0; i < 3; i++) {
gAiBuffLengths[i] = gAudioBufferParams.maxAiBufferLength;
for (j = 0; j < AIBUF_LEN; j++) {
@@ -627,7 +627,7 @@ s32 AudioHeap_ResetStep(void) {
}
break;
}
if (gResetStatus < 3) {
if (gAudioResetStep < 3) {
return 0;
}
return 1;
@@ -648,8 +648,7 @@ void AudioHeap_Init(void) {
gSampleDmaCount = 0;
gAudioBufferParams.samplingFrequency = spec->samplingFrequency;
gAudioBufferParams.aiSamplingFrequency = osAiSetFrequency(gAudioBufferParams.samplingFrequency);
gAudioBufferParams.samplesPerFrameTarget =
((gAudioBufferParams.samplingFrequency / gRefreshRate) + 0xF) & (u16) ~0xF;
gAudioBufferParams.samplesPerFrameTarget = ALIGN16(gAudioBufferParams.samplingFrequency / gRefreshRate);
gAudioBufferParams.minAiBufferLength = gAudioBufferParams.samplesPerFrameTarget - 0x10;
gAudioBufferParams.maxAiBufferLength = gAudioBufferParams.samplesPerFrameTarget + 0x10;
@@ -660,20 +659,20 @@ void AudioHeap_Init(void) {
gAudioBufferParams.samplesPerTickMax = gAudioBufferParams.samplesPerTick + 8;
gAudioBufferParams.samplesPerTickMin = gAudioBufferParams.samplesPerTick - 8;
gAudioBufferParams.resampleRate = 32000.0f / (s32) gAudioBufferParams.samplingFrequency;
gAudioBufferParams.ticksPerUpdateInvScaled = 0.001171875f / gAudioBufferParams.ticksPerUpdate;
gAudioBufferParams.ticksPerUpdateInvScaled = (3.0f / 2560.0f) / gAudioBufferParams.ticksPerUpdate;
gAudioBufferParams.ticksPerUpdateInv = 1.0f / gAudioBufferParams.ticksPerUpdate;
gNumNotes = spec->numNotes;
D_8014C1B0 = spec->unk_14;
gMaxTempo = (u16) ((gAudioBufferParams.ticksPerUpdate * 2880000.0f / gSeqTicksPerBeat) / gMaxTempoTvTypeFactors);
gAudioBufferParams.specUnk4 = spec->unk_04;
gAudioBufferParams.samplesPerFrameTarget *= gAudioBufferParams.specUnk4;
gAudioBufferParams.maxAiBufferLength *= gAudioBufferParams.specUnk4;
gAudioBufferParams.minAiBufferLength *= gAudioBufferParams.specUnk4;
gAudioBufferParams.ticksPerUpdate *= gAudioBufferParams.specUnk4;
if (gAudioBufferParams.specUnk4 >= 2) {
gAudioBufferParams.count = spec->numBuffers;
gAudioBufferParams.samplesPerFrameTarget *= gAudioBufferParams.count;
gAudioBufferParams.maxAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.minAiBufferLength *= gAudioBufferParams.count;
gAudioBufferParams.ticksPerUpdate *= gAudioBufferParams.count;
if (gAudioBufferParams.count >= 2) {
gAudioBufferParams.maxAiBufferLength -= 0x10;
}
gMaxAudioCmds = (gNumNotes * 0x14 * gAudioBufferParams.ticksPerUpdate) + (spec->numReverbs * 0x20) + 0x1E0;
gMaxAudioCmds = (gNumNotes * 20 * gAudioBufferParams.ticksPerUpdate) + (spec->numReverbs * 32) + 480;
persistentSize = spec->persistentSeqCacheSize + spec->persistentFontCacheSize +
spec->persistentSampleBankCacheSize + spec->persistentSampleCacheSize + 0x10;
temporarySize = spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize +
@@ -703,7 +702,7 @@ void AudioHeap_Init(void) {
for (i = 0; i != 2; i++) {
gAbiCmdBuffs[i] = AudioHeap_AllocZeroed(&gMiscPool, gMaxAudioCmds * 8);
}
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSynthReverbs); i++) {
gSynthReverbs[i].useReverb = 0;
}
gNumSynthReverbs = spec->numReverbs;
@@ -712,9 +711,9 @@ void AudioHeap_Init(void) {
reverb = &gSynthReverbs[i];
reverb->downsampleRate = settings->downsampleRate;
reverb->windowSize = settings->windowSize * 64;
reverb->unk_08 = settings->unk_2;
reverb->decayRatio = settings->decayRatio;
reverb->unk_0E = settings->unk_6;
reverb->leakRtL = settings->leakRtL;
reverb->leakLtR = settings->leakLtR;
reverb->useReverb = 8;
reverb->leftRingBuf = AudioHeap_AllocZeroed(&gMiscPool, reverb->windowSize * 2);
@@ -765,6 +764,7 @@ u8* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) {
ramAddr = AudioHeap_Alloc(&gPermanentPool.pool, size);
gPermanentPool.entry[index].ramAddr = ramAddr;
if (ramAddr == NULL) {
return NULL;
}
@@ -772,7 +772,10 @@ u8* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) {
gPermanentPool.entry[index].tableType = tableType;
gPermanentPool.entry[index].id = id;
gPermanentPool.entry[index].size = size;
// return temp;
#ifdef AVOID_UB
return ramAddr;
#endif
}
void* AudioHeap_AllocTemporarySampleCache(s32 size, s32 fontId, s32 sampleAddr, s8 medium) {
@@ -912,13 +915,15 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
s32 sampleBankId2;
s32 sampleBankId1;
numFonts = gSoundFontTable->numEntries;
numFonts = gSoundFontTable->base.numEntries;
for (fondId = 0; fondId < numFonts; fondId++) {
sampleBankId1 = gSoundFontList[fondId].sampleBankId1;
sampleBankId2 = gSoundFontList[fondId].sampleBankId2;
if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) ||
((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || (entry->sampleBankId == 0)) {
if ((AudioHeap_SearchCaches(1, 2, fondId) != NULL) && ((gFontLoadStatus[fondId] > 1) != 0)) {
if (((sampleBankId1 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId1)) ||
((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) ||
(entry->sampleBankId == SAMPLES_SFX)) {
if ((AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fondId) != NULL) &&
((gFontLoadStatus[fondId] > 1) != 0)) {
for (instId = 0; instId < gSoundFontList[fondId].numInstruments; instId++) {
instrument = Audio_GetInstrument(fondId, instId);
if (instrument != NULL) {
@@ -969,7 +974,7 @@ SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(u32 size) {
void AudioHeap_DiscardSampleCaches(void) {
s32 fontId;
s32 i;
s32 numFonts;
s32 numFonts = gSoundFontTable->base.numEntries;
s32 pad;
s32 sampleBankId2;
s32 sampleBankId1;
@@ -979,13 +984,18 @@ void AudioHeap_DiscardSampleCaches(void) {
Instrument* instrument;
SampleCacheEntry* entry;
numFonts = gSoundFontTable->numEntries;
#ifdef AVOID_UB
entry = gPersistentSampleCache.entries;
#endif
for (fontId = 0; fontId < numFonts; fontId++) {
sampleBankId1 = gSoundFontList[fontId].sampleBankId1;
sampleBankId2 = gSoundFontList[fontId].sampleBankId2;
if (((sampleBankId1 != 0xFFU) && (entry->sampleBankId == sampleBankId1)) ||
((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || (entry->sampleBankId == 0)) {
if ((AudioHeap_SearchCaches(1, 3, fontId) != NULL) && ((gFontLoadStatus[fontId] > 1) != 0)) {
if (((sampleBankId1 != SAMPLES_NONE_U) && (entry->sampleBankId == sampleBankId1)) ||
((sampleBankId2 != SAMPLES_NONE) && (entry->sampleBankId == sampleBankId2)) ||
(entry->sampleBankId == SAMPLES_SFX)) {
if ((AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) != NULL) &&
((gFontLoadStatus[fontId] > 1) != 0)) {
for (i = 0; i < gPersistentSampleCache.numEntries; i++) {
entry = &gPersistentSampleCache.entries[i];
for (instId = 0; instId < gSoundFontList[fontId].numInstruments; instId++) {
+336 -247
View File
File diff suppressed because it is too large Load Diff
+331 -332
View File
@@ -1,37 +1,37 @@
#include "sys.h"
#include "sf64audio_provisional.h"
static char devstr00[] = "Audio: setvol: volume minus %f\n";
static char devstr01[] = "Audio: setvol: volume overflow %f\n";
static char devstr02[] = "Audio: setpitch: pitch zero or minus %f\n";
static char devstr03[] = "Audio: voiceman: No bank error %d\n";
static char devstr04[] = "Audio: voiceman: progNo. overflow %d,%d\n";
static char devstr05[] = "ptr2 %x\n";
static char devstr06[] = "Audio: voiceman: progNo. undefined %d,%d\n";
static char devstr07[] = "Audio: voiceman: No bank error %d\n";
static char devstr08[] = "Audio: voiceman: Percussion Overflow %d,%d\n";
static char devstr09[] = "Audio: voiceman: Percussion table pointer (bank %d) is irregular %x.\n";
static char devstr10[] = "Audio: voiceman: Percpointer NULL %d,%d\n";
static char devstr11[] = "--4 %x\n";
static char devstr12[] = "----------------------Double-Error CH: %x %f\n";
static char devstr13[] = "----------------------Double-Error NT: %x\n";
static char devstr14[] = "CAUTION:SUB IS SEPARATED FROM GROUP\n";
static char devstr15[] = "CAUTION:PAUSE EMERGENCY\n";
static char devstr16[] = "Error:Wait Track disappear\n";
static char devstr17[] = "NoteOff Comes during wait release %x (note %x)\n";
static char devstr18[] = "Slow Release Batting\n";
static const char devstr00[] = "Audio: setvol: volume minus %f\n";
static const char devstr01[] = "Audio: setvol: volume overflow %f\n";
static const char devstr02[] = "Audio: setpitch: pitch zero or minus %f\n";
static const char devstr03[] = "Audio: voiceman: No bank error %d\n";
static const char devstr04[] = "Audio: voiceman: progNo. overflow %d,%d\n";
static const char devstr05[] = "ptr2 %x\n";
static const char devstr06[] = "Audio: voiceman: progNo. undefined %d,%d\n";
static const char devstr07[] = "Audio: voiceman: No bank error %d\n";
static const char devstr08[] = "Audio: voiceman: Percussion Overflow %d,%d\n";
static const char devstr09[] = "Audio: voiceman: Percussion table pointer (bank %d) is irregular %x.\n";
static const char devstr10[] = "Audio: voiceman: Percpointer NULL %d,%d\n";
static const char devstr11[] = "--4 %x\n";
static const char devstr12[] = "----------------------Double-Error CH: %x %f\n";
static const char devstr13[] = "----------------------Double-Error NT: %x\n";
static const char devstr14[] = "CAUTION:SUB IS SEPARATED FROM GROUP\n";
static const char devstr15[] = "CAUTION:PAUSE EMERGENCY\n";
static const char devstr16[] = "Error:Wait Track disappear\n";
static const char devstr17[] = "NoteOff Comes during wait release %x (note %x)\n";
static const char devstr18[] = "Slow Release Batting\n";
u8 sSamplesPerWavePeriod[] = { 64, 32, 16, 8 };
static char devstr19[] = "Audio:Wavemem: Bad voiceno (%d)\n";
static char devstr20[] = "Audio: C-Alloc : Dealloc voice is NULL\n";
static char devstr21[] = "Alloc Error:Dim voice-Alloc %d";
static char devstr22[] = "Error:Same List Add\n";
static char devstr23[] = "Already Cut\n";
static char devstr24[] = "Audio: C-Alloc : lowerPrio is NULL\n";
static char devstr25[] = "Intterupt UseStop %d (Kill %d)\n";
static char devstr26[] = "Intterupt RelWait %d (Kill %d)\n";
static char devstr27[] = "Drop Voice (Prio %x)\n";
static const char devstr19[] = "Audio:Wavemem: Bad voiceno (%d)\n";
static const char devstr20[] = "Audio: C-Alloc : Dealloc voice is NULL\n";
static const char devstr21[] = "Alloc Error:Dim voice-Alloc %d";
static const char devstr22[] = "Error:Same List Add\n";
static const char devstr23[] = "Already Cut\n";
static const char devstr24[] = "Audio: C-Alloc : lowerPrio is NULL\n";
static const char devstr25[] = "Intterupt UseStop %d (Kill %d)\n";
static const char devstr26[] = "Intterupt RelWait %d (Kill %d)\n";
static const char devstr27[] = "Drop Voice (Prio %x)\n";
void func_80011C58(Note* note, f32);
void func_8001268C(SequenceLayer* layer);
@@ -40,93 +40,93 @@ void func_80012C40(Note* note);
void func_80012CEC(Note* note, SequenceLayer* layer);
void func_80011890(Note* note, NoteAttributes* noteAttr) {
NoteSubEu* temp_v0;
f32 var_fa0;
f32 var_fa1;
f32 var_fv1;
NoteSubEu* noteSub;
f32 panVolumeLeft;
f32 pamVolumeRight;
f32 velocity;
s32 temp_t0;
s32 var_a0;
s32 var_a0_2;
s32 var_a1;
u8 sp27;
u8 sp26;
Stereo sp24;
s32 strongRight;
s32 strongLeft;
u8 pan;
u8 reverb;
Stereo stereo;
func_80011C58(note, noteAttr->freqMod);
temp_v0 = &note->noteSubEu;
var_fv1 = noteAttr->velocity;
sp27 = noteAttr->pan;
sp26 = noteAttr->reverb;
sp24 = noteAttr->stereo;
sp27 &= 0x7F;
if ((temp_v0->bitField0.stereoHeadsetEffects) && (gAudioSoundMode == SOUNDMODE_HEADSET)) {
var_a0 = sp27 >> 1;
if (var_a0 >= 0x40) {
var_a0 = 0x3F;
noteSub = &note->noteSubEu;
velocity = noteAttr->velocity;
pan = noteAttr->pan;
reverb = noteAttr->reverb;
stereo = noteAttr->stereo;
pan %= ARRAY_COUNTU(gHeadsetPanVolume);
if ((noteSub->bitField0.stereoHeadsetEffects) && (gAudioSoundMode == SOUNDMODE_HEADSET)) {
var_a0 = pan >> 1;
if (var_a0 >= ARRAY_COUNT(gHaasEffectDelaySizes)) {
var_a0 = ARRAY_COUNT(gHaasEffectDelaySizes) - 1;
}
temp_v0->unk_04 = gHaasEffectDelaySizes[var_a0];
temp_v0->unk_03 = gHaasEffectDelaySizes[63 - var_a0];
temp_v0->bitField0.stereoStrongRight = 0;
temp_v0->bitField0.stereoStrongLeft = 0;
temp_v0->bitField0.usesHeadsetPanEffects = 1;
noteSub->rightDelaySize = gHaasEffectDelaySizes[var_a0];
noteSub->leftDelaySize = gHaasEffectDelaySizes[ARRAY_COUNT(gHaasEffectDelaySizes) - 1 - var_a0];
noteSub->bitField0.stereoStrongRight = false;
noteSub->bitField0.stereoStrongLeft = false;
noteSub->bitField0.usesHeadsetPanEffects = true;
var_fa0 = gHeadsetPanVolume[sp27];
var_fa1 = gHeadsetPanVolume[127 - sp27];
} else if (temp_v0->bitField0.stereoHeadsetEffects && (gAudioSoundMode == SOUNDMODE_STEREO)) {
temp_v0->unk_03 = 0;
temp_v0->unk_04 = 0;
temp_v0->bitField0.usesHeadsetPanEffects = 0;
panVolumeLeft = gHeadsetPanVolume[pan];
pamVolumeRight = gHeadsetPanVolume[ARRAY_COUNT(gHeadsetPanVolume) - 1 - pan];
} else if (noteSub->bitField0.stereoHeadsetEffects && (gAudioSoundMode == SOUNDMODE_STEREO)) {
noteSub->leftDelaySize = 0;
noteSub->rightDelaySize = 0;
noteSub->bitField0.usesHeadsetPanEffects = false;
var_fa0 = gStereoPanVolume[sp27];
var_fa1 = gStereoPanVolume[127 - sp27];
var_a0_2 = 0;
var_a1 = 0;
if (sp27 < 0x20) {
var_a1 = 1;
} else if (sp27 > 0x60) {
var_a0_2 = 1;
panVolumeLeft = gStereoPanVolume[pan];
pamVolumeRight = gStereoPanVolume[ARRAY_COUNT(gStereoPanVolume) - 1 - pan];
strongRight = false;
strongLeft = false;
if (pan < 32) {
strongLeft = true;
} else if (pan > 96) {
strongRight = true;
}
temp_v0->bitField0.stereoStrongRight = var_a0_2;
temp_v0->bitField0.stereoStrongLeft = var_a1;
switch (sp24.s.bit2) {
noteSub->bitField0.stereoStrongRight = strongRight;
noteSub->bitField0.stereoStrongLeft = strongLeft;
switch (stereo.s.bit2) {
case 0:
temp_v0->bitField0.stereoStrongRight = sp24.s.strongRight;
temp_v0->bitField0.stereoStrongLeft = sp24.s.strongLeft;
noteSub->bitField0.stereoStrongRight = stereo.s.strongRight;
noteSub->bitField0.stereoStrongLeft = stereo.s.strongLeft;
break;
case 1:
break;
case 2:
temp_v0->bitField0.stereoStrongRight = sp24.s.strongRight | var_a0_2;
temp_v0->bitField0.stereoStrongLeft = sp24.s.strongLeft | var_a1;
noteSub->bitField0.stereoStrongRight = stereo.s.strongRight | strongRight;
noteSub->bitField0.stereoStrongLeft = stereo.s.strongLeft | strongLeft;
break;
case 3:
temp_v0->bitField0.stereoStrongRight = sp24.s.strongRight ^ var_a0_2;
temp_v0->bitField0.stereoStrongLeft = sp24.s.strongLeft ^ var_a1;
noteSub->bitField0.stereoStrongRight = stereo.s.strongRight ^ strongRight;
noteSub->bitField0.stereoStrongLeft = stereo.s.strongLeft ^ strongLeft;
break;
}
} else if (gAudioSoundMode == SOUNDMODE_MONO) {
var_fa0 = 0.707f;
var_fa1 = 0.707f;
panVolumeLeft = 0.707f;
pamVolumeRight = 0.707f;
} else {
var_fa0 = gDefaultPanVolume[sp27];
var_fa1 = gDefaultPanVolume[127 - sp27];
panVolumeLeft = gDefaultPanVolume[pan];
pamVolumeRight = gDefaultPanVolume[ARRAY_COUNT(gDefaultPanVolume) - 1 - pan];
}
if (var_fv1 < 0.0f) {
var_fv1 = 0.0f;
if (velocity < 0.0f) {
velocity = 0.0f;
}
if (var_fv1 > 1.0f) {
var_fv1 = 1.0f;
if (velocity > 1.0f) {
velocity = 1.0f;
}
temp_v0->unk_06 = (s32) (var_fv1 * var_fa0 * 4095.999f);
temp_v0->unk_08 = (s32) (var_fv1 * var_fa1 * 4095.999f);
temp_v0->unk_02 = noteAttr->gain;
if (temp_v0->unk_05 != sp26) {
temp_v0->unk_05 = sp26;
temp_v0->bitField0.unused = 1;
} else if (temp_v0->bitField0.needsInit) {
temp_v0->bitField0.unused = 1;
noteSub->panVolLeft = (s32) (velocity * panVolumeLeft * 4095.999f);
noteSub->panVolRight = (s32) (velocity * pamVolumeRight * 4095.999f);
noteSub->gain = noteAttr->gain;
if (noteSub->reverb != reverb) {
noteSub->reverb = reverb;
noteSub->bitField0.unused = true;
} else if (noteSub->bitField0.needsInit) {
noteSub->bitField0.unused = true;
} else {
temp_v0->bitField0.unused = 0;
noteSub->bitField0.unused = false;
}
}
@@ -149,7 +149,7 @@ void func_80011C58(Note* note, f32 arg1) {
var_fv0 = arg1 * 0.5f;
}
}
note->noteSubEu.unk_0A = (s32) (var_fv0 * 32768.0f);
note->noteSubEu.resampleRate = (s32) (var_fv0 * 32768.0f);
}
TunedSample* func_80011D10(Instrument* instrument, s32 arg1) {
@@ -165,44 +165,44 @@ TunedSample* func_80011D10(Instrument* instrument, s32 arg1) {
return sample;
}
Instrument* Audio_GetInstrument(s32 arg0, s32 arg1) {
Instrument* temp_v1;
Instrument* Audio_GetInstrument(s32 fontId, s32 instId) {
Instrument* instrument;
if ((gFontLoadStatus[arg0] < 2) != 0) {
D_80155D88 = arg0 + 0x10000000;
if ((gFontLoadStatus[fontId] < 2) != 0) {
D_80155D88 = fontId + 0x10000000;
return NULL;
}
if (arg1 >= gSoundFontList[arg0].numInstruments) {
D_80155D88 = (arg0 << 8) + arg1 + 0x03000000;
if (instId >= gSoundFontList[fontId].numInstruments) {
D_80155D88 = (fontId << 8) + instId + 0x03000000;
return NULL;
}
temp_v1 = gSoundFontList[arg0].instruments[arg1];
if (temp_v1 == NULL) {
D_80155D88 = (arg0 << 8) + arg1 + 0x01000000;
return temp_v1;
instrument = gSoundFontList[fontId].instruments[instId];
if (instrument == NULL) {
D_80155D88 = (fontId << 8) + instId + 0x01000000;
return instrument;
}
return temp_v1;
return instrument;
}
Drum* Audio_GetDrum(s32 arg0, s32 arg1) {
Drum* temp;
Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
Drum* drum;
if ((gFontLoadStatus[arg0] < 2) != 0) {
D_80155D88 = arg0 + 0x10000000;
if ((gFontLoadStatus[fontId] < 2) != 0) {
D_80155D88 = fontId + 0x10000000;
return NULL;
}
if (arg1 >= gSoundFontList[arg0].numDrums) {
D_80155D88 = (arg0 << 8) + arg1 + 0x04000000;
if (drumId >= gSoundFontList[fontId].numDrums) {
D_80155D88 = (fontId << 8) + drumId + 0x04000000;
return NULL;
}
if ((u32) gSoundFontList[arg0].drums < AUDIO_RELOCATED_ADDRESS_START) {
if ((u32) gSoundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) {
return NULL;
}
temp = gSoundFontList[arg0].drums[arg1];
if (gSoundFontList[arg0].drums[arg1] == NULL) {
D_80155D88 = (arg0 << 8) + arg1 + 0x05000000;
drum = gSoundFontList[fontId].drums[drumId];
if (gSoundFontList[fontId].drums[drumId] == NULL) {
D_80155D88 = (fontId << 8) + drumId + 0x05000000;
}
return temp;
return drum;
}
void func_80011EB8(Note* note) {
@@ -234,128 +234,128 @@ void func_80011F4C(Note* note) {
void func_80011FA8(void) {
s32 pad2;
s32 pad;
Note* temp_s1;
NotePlaybackState* var_s0;
Note* note;
NotePlaybackState* playbackState;
NoteSubEu* noteSub;
NoteAttributes* attr;
s32 i;
NoteAttributes sp70;
u8 sp6F;
u8 bookOffset;
f32 temp_fs0;
for (i = 0; i < gNumNotes; i++) {
temp_s1 = &gNotes[i];
note = &gNotes[i];
var_s0 = &temp_s1->playbackState;
if ((var_s0->parentLayer != NO_LAYER)) {
if ((u32) var_s0->parentLayer < 0x7FFFFFFF) {
playbackState = &note->playbackState;
if ((playbackState->parentLayer != NO_LAYER)) {
if ((u32) playbackState->parentLayer < 0x7FFFFFFF) {
continue;
}
if ((temp_s1 != var_s0->parentLayer->note) && (var_s0->unk_04 == 0)) {
var_s0->adsr.action.asByte |= 0x10;
var_s0->adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
var_s0->priority = 1;
var_s0->unk_04 = 2;
if ((note != playbackState->parentLayer->note) && (playbackState->unk_04 == 0)) {
playbackState->adsr.action.asByte |= 0x10;
playbackState->adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
playbackState->priority = 1;
playbackState->unk_04 = 2;
goto block_21;
} else {
if ((var_s0->parentLayer->enabled) || (var_s0->unk_04 != 0) || (var_s0->priority <= 0)) {
if (var_s0->parentLayer->channel->seqPlayer == NULL) {
func_8001415C(var_s0->parentLayer->channel);
var_s0->priority = 1;
var_s0->unk_04 = 1;
if ((playbackState->parentLayer->enabled) || (playbackState->unk_04 != 0) ||
(playbackState->priority <= 0)) {
if (playbackState->parentLayer->channel->seqPlayer == NULL) {
func_8001415C(playbackState->parentLayer->channel);
playbackState->priority = 1;
playbackState->unk_04 = 1;
continue;
}
if (!(var_s0->parentLayer->channel->seqPlayer->muted &&
(var_s0->parentLayer->channel->muteBehavior & 0x40))) {
if (!(playbackState->parentLayer->channel->seqPlayer->muted &&
(playbackState->parentLayer->channel->muteBehavior & 0x40))) {
goto block_21;
}
}
func_8001268C(var_s0->parentLayer);
func_80012C40(temp_s1);
func_80012C00(&temp_s1->listItem.pool->decaying, &temp_s1->listItem);
var_s0->priority = 1;
var_s0->unk_04 = 2;
func_8001268C(playbackState->parentLayer);
func_80012C40(note);
func_80012C00(&note->listItem.pool->decaying, &note->listItem);
playbackState->priority = 1;
playbackState->unk_04 = 2;
}
} else if ((var_s0->unk_04 == 0) && (var_s0->priority > 0)) {
} else if ((playbackState->unk_04 == 0) && (playbackState->priority > 0)) {
continue;
}
block_21:
if (var_s0->priority != 0) {
if (playbackState->priority != 0) {
if (1) {}
noteSub = &temp_s1->noteSubEu;
if ((var_s0->unk_04 > 0) || noteSub->bitField0.finished) {
if ((var_s0->adsr.state == 0) || noteSub->bitField0.finished) {
if (var_s0->wantedParentLayer != NO_LAYER) {
func_80011F4C(temp_s1);
if (var_s0->wantedParentLayer->channel != NULL) {
func_80012CEC(temp_s1, var_s0->wantedParentLayer);
func_80013A84(temp_s1);
func_80012C40(temp_s1);
func_800145BC(&temp_s1->listItem.pool->active, &temp_s1->listItem);
var_s0->wantedParentLayer = NO_LAYER;
noteSub = &note->noteSubEu;
if ((playbackState->unk_04 > 0) || noteSub->bitField0.finished) {
if ((playbackState->adsr.state == 0) || noteSub->bitField0.finished) {
if (playbackState->wantedParentLayer != NO_LAYER) {
func_80011F4C(note);
if (playbackState->wantedParentLayer->channel != NULL) {
func_80012CEC(note, playbackState->wantedParentLayer);
func_80013A84(note);
func_80012C40(note);
func_800145BC(&note->listItem.pool->active, &note->listItem);
playbackState->wantedParentLayer = NO_LAYER;
} else {
func_80011F4C(temp_s1);
func_80012C40(temp_s1);
func_800145BC(&temp_s1->listItem.pool->disabled, &temp_s1->listItem);
var_s0->wantedParentLayer = NO_LAYER;
func_80011F4C(note);
func_80012C40(note);
func_800145BC(&note->listItem.pool->disabled, &note->listItem);
playbackState->wantedParentLayer = NO_LAYER;
goto next;
}
} else {
func_80011F4C(temp_s1);
func_80012C40(temp_s1);
func_800145BC(&temp_s1->listItem.pool->disabled, &temp_s1->listItem);
func_80011F4C(note);
func_80012C40(note);
func_800145BC(&note->listItem.pool->disabled, &note->listItem);
goto next;
}
}
} else if (var_s0->adsr.state == 0) {
func_80011F4C(temp_s1);
func_80012C40(temp_s1);
func_800145BC(&temp_s1->listItem.pool->disabled, &temp_s1->listItem);
} else if (playbackState->adsr.state == 0) {
func_80011F4C(note);
func_80012C40(note);
func_800145BC(&note->listItem.pool->disabled, &note->listItem);
goto next;
}
temp_fs0 = func_80013B90(&var_s0->adsr);
func_80013A18(temp_s1);
attr = &var_s0->attributes;
if ((var_s0->unk_04 == 1) || (var_s0->unk_04 == 2)) {
temp_fs0 = func_80013B90(&playbackState->adsr);
func_80013A18(note);
attr = &playbackState->attributes;
if ((playbackState->unk_04 == 1) || (playbackState->unk_04 == 2)) {
sp70.freqMod = attr->freqMod;
sp70.velocity = attr->velocity;
sp70.pan = attr->pan;
sp70.reverb = attr->reverb;
sp70.stereo = attr->stereo;
sp70.gain = attr->gain;
sp6F = noteSub->bitField1.bookOffset;
bookOffset = noteSub->bitField1.bookOffset;
} else {
sp70.freqMod = var_s0->parentLayer->noteFreqMod;
sp70.velocity = var_s0->parentLayer->noteVelocity;
sp70.pan = var_s0->parentLayer->notePan;
sp70.stereo = var_s0->parentLayer->stereo;
sp70.reverb = var_s0->parentLayer->channel->targetReverbVol;
sp70.gain = var_s0->parentLayer->channel->reverbIndex;
sp70.freqMod = playbackState->parentLayer->noteFreqMod;
sp70.velocity = playbackState->parentLayer->noteVelocity;
sp70.pan = playbackState->parentLayer->notePan;
sp70.stereo = playbackState->parentLayer->stereo;
sp70.reverb = playbackState->parentLayer->channel->targetReverbVol;
sp70.gain = playbackState->parentLayer->channel->reverbIndex;
sp6F = var_s0->parentLayer->channel->bookOffset & 7;
if ((var_s0->parentLayer->channel->seqPlayer->muted) &&
(var_s0->parentLayer->channel->muteBehavior & 8)) {
bookOffset = playbackState->parentLayer->channel->bookOffset % 8U;
if ((playbackState->parentLayer->channel->seqPlayer->muted) &&
(playbackState->parentLayer->channel->muteBehavior & 8)) {
sp70.freqMod = 0.0f;
sp70.velocity = 0.0f;
}
}
sp70.freqMod *= (var_s0->vibratoFreqMod * var_s0->portamentoFreqMod);
sp70.freqMod *= playbackState->vibratoFreqMod * playbackState->portamentoFreqMod;
sp70.freqMod *= gAudioBufferParams.resampleRate;
sp70.velocity *= temp_fs0;
func_80011890(temp_s1, &sp70);
noteSub->bitField1.bookOffset = sp6F;
func_80011890(note, &sp70);
noteSub->bitField1.bookOffset = bookOffset;
next:;
}
}
}
void func_80012438(SequenceLayer* layer, s32 arg1) {
Note* temp_v0;
NoteAttributes* temp_v0_3;
Note* note;
NoteAttributes* noteAttr;
if (layer == NO_LAYER) {
return;
@@ -364,59 +364,58 @@ void func_80012438(SequenceLayer* layer, s32 arg1) {
if (layer->note == NULL) {
return;
}
temp_v0 = layer->note;
if (layer == temp_v0->playbackState.wantedParentLayer) {
temp_v0->playbackState.wantedParentLayer = NO_LAYER;
note = layer->note;
if (layer == note->playbackState.wantedParentLayer) {
note->playbackState.wantedParentLayer = NO_LAYER;
}
if (layer != temp_v0->playbackState.parentLayer) {
if ((temp_v0->playbackState.parentLayer == NO_LAYER) &&
(temp_v0->playbackState.wantedParentLayer == NO_LAYER) &&
(layer == temp_v0->playbackState.prevParentLayer) && (arg1 != 6)) {
temp_v0->playbackState.adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
temp_v0->playbackState.adsr.action.asByte |= 0x10;
if (layer != note->playbackState.parentLayer) {
if ((note->playbackState.parentLayer == NO_LAYER) && (note->playbackState.wantedParentLayer == NO_LAYER) &&
(layer == note->playbackState.prevParentLayer) && (arg1 != 6)) {
note->playbackState.adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
note->playbackState.adsr.action.asByte |= 0x10;
}
return;
}
temp_v0_3 = &temp_v0->playbackState.attributes;
if (temp_v0->playbackState.adsr.state != 6) {
temp_v0_3->freqMod = layer->noteFreqMod;
temp_v0_3->velocity = layer->noteVelocity;
temp_v0_3->pan = layer->notePan;
temp_v0_3->stereo = layer->stereo;
if (layer->channel != NULL) {
temp_v0_3->reverb = layer->channel->targetReverbVol;
temp_v0_3->gain = layer->channel->reverbIndex;
if (layer->channel->seqPlayer->muted && (layer->channel->muteBehavior & 8)) {
temp_v0->noteSubEu.bitField0.finished = 1;
} else {
noteAttr = &note->playbackState.attributes;
if (note->playbackState.adsr.state != 6) {
noteAttr->freqMod = layer->noteFreqMod;
noteAttr->velocity = layer->noteVelocity;
noteAttr->pan = layer->notePan;
noteAttr->stereo = layer->stereo;
if (layer->channel != NULL) {
noteAttr->reverb = layer->channel->targetReverbVol;
noteAttr->gain = layer->channel->reverbIndex;
if (layer->channel->seqPlayer->muted && (layer->channel->muteBehavior & 8)) {
note->noteSubEu.bitField0.finished = 1;
}
}
}
temp_v0->playbackState.priority = 1;
temp_v0->playbackState.prevParentLayer = temp_v0->playbackState.parentLayer;
temp_v0->playbackState.parentLayer = NO_LAYER;
note->playbackState.priority = 1;
note->playbackState.prevParentLayer = note->playbackState.parentLayer;
note->playbackState.parentLayer = NO_LAYER;
if (arg1 == 7) {
temp_v0->playbackState.adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
temp_v0->playbackState.adsr.action.asByte |= 0x10;
temp_v0->playbackState.unk_04 = 2;
if (arg1 == 7) {
note->playbackState.adsr.fadeOutVel = gAudioBufferParams.ticksPerUpdateInv;
note->playbackState.adsr.action.asByte |= 0x10;
note->playbackState.unk_04 = 2;
} else {
temp_v0->playbackState.unk_04 = 1;
temp_v0->playbackState.adsr.action.asByte |= 0x20;
if (layer->adsr.decayIndex == 0) {
temp_v0->playbackState.adsr.fadeOutVel =
layer->channel->adsr.decayIndex * gAudioBufferParams.ticksPerUpdateInvScaled;
} else {
temp_v0->playbackState.adsr.fadeOutVel =
layer->adsr.decayIndex * gAudioBufferParams.ticksPerUpdateInvScaled;
note->playbackState.unk_04 = 1;
note->playbackState.adsr.action.asByte |= 0x20;
if (layer->adsr.decayIndex == 0) {
note->playbackState.adsr.fadeOutVel =
layer->channel->adsr.decayIndex * gAudioBufferParams.ticksPerUpdateInvScaled;
} else {
note->playbackState.adsr.fadeOutVel =
layer->adsr.decayIndex * gAudioBufferParams.ticksPerUpdateInvScaled;
}
note->playbackState.adsr.sustain =
(s32) layer->channel->adsr.sustain * note->playbackState.adsr.current / 256.0f;
}
temp_v0->playbackState.adsr.sustain =
(s32) layer->channel->adsr.sustain * temp_v0->playbackState.adsr.current * 0.00390625f;
}
}
if (arg1 == 6) {
func_80012C40(temp_v0);
func_80012C00(&temp_v0->listItem.pool->decaying, &temp_v0->listItem);
if (arg1 == 6) {
func_80012C40(note);
func_80012C00(&note->listItem.pool->decaying, &note->listItem);
}
}
}
@@ -428,49 +427,49 @@ void func_8001268C(SequenceLayer* layer) {
func_80012438(layer, 7);
}
s32 func_800126AC(Note* note, SequenceLayer* layer, s32 arg2) {
f32 var_fv0;
u8 var_v1 = 0;
s32 func_800126AC(Note* note, SequenceLayer* layer, s32 waveId) {
f32 freqMod;
u8 harmonicIndex = 0;
if (arg2 < 128) {
arg2 = 128;
if (waveId < 128) {
waveId = 128;
}
var_fv0 = layer->freqMod;
freqMod = layer->freqMod;
if ((layer->portamento.mode != 0) && (layer->portamento.extent > 0.0f)) {
var_fv0 *= layer->portamento.extent + 1.0f;
freqMod *= layer->portamento.extent + 1.0f;
}
if (var_fv0 < 1.0f) {
var_fv0 = 1.0465f;
} else if (var_fv0 < 2.0f) {
var_v1 = 1;
var_fv0 = 0.52325f;
} else if (var_fv0 < 4.0f) {
var_v1 = 2;
var_fv0 = 0.26263f;
if (freqMod < 1.0f) {
freqMod = 1.0465f;
} else if (freqMod < 2.0f) {
harmonicIndex = 1;
freqMod = 0.52325f;
} else if (freqMod < 4.0f) {
harmonicIndex = 2;
freqMod = 0.26263f;
} else {
var_v1 = 3;
var_fv0 = 0.13081f;
harmonicIndex = 3;
freqMod = 0.13081f;
}
layer->freqMod *= var_fv0;
note->playbackState.waveId = arg2;
note->playbackState.harmonicIndex = var_v1;
note->noteSubEu.waveSampleAddr = &gWaveSamples[arg2 - 128][var_v1 * 64];
return var_v1;
layer->freqMod *= freqMod;
note->playbackState.waveId = waveId;
note->playbackState.harmonicIndex = harmonicIndex;
note->noteSubEu.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * 64];
return harmonicIndex;
}
void func_800127B0(Note* note, SequenceLayer* layer) {
s32 sp1C;
s32 var_a2;
s32 harmonicIndex;
s32 waveId;
var_a2 = layer->instOrWave;
if (var_a2 == 0xFF) {
var_a2 = layer->channel->instOrWave;
waveId = layer->instOrWave;
if (waveId == 0xFF) {
waveId = layer->channel->instOrWave;
}
sp1C = note->playbackState.harmonicIndex;
harmonicIndex = note->playbackState.harmonicIndex;
note->synthesisState.samplePosInt =
(note->synthesisState.samplePosInt * sSamplesPerWavePeriod[func_800126AC(note, layer, var_a2)]) /
sSamplesPerWavePeriod[sp1C];
(note->synthesisState.samplePosInt * sSamplesPerWavePeriod[func_800126AC(note, layer, waveId)]) /
sSamplesPerWavePeriod[harmonicIndex];
}
void func_80012854(AudioListItem* item) {
@@ -491,94 +490,94 @@ void func_80012864(NotePool* pool) {
}
void func_800128B4(void) {
s32 var_s1;
s32 i;
func_80012864(&gNoteFreeLists);
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
gNotes[var_s1].listItem.u.value = &gNotes[var_s1];
gNotes[var_s1].listItem.prev = NULL;
func_800145BC(&gNoteFreeLists.disabled, &gNotes[var_s1].listItem);
for (i = 0; i < gNumNotes; i++) {
gNotes[i].listItem.u.value = &gNotes[i];
gNotes[i].listItem.prev = NULL;
func_800145BC(&gNoteFreeLists.disabled, &gNotes[i].listItem);
}
}
void func_80012964(NotePool* pool) {
s32 var_s3;
AudioListItem* sp48;
AudioListItem* var_s0;
AudioListItem* sp40;
s32 poolType;
AudioListItem* poolItem;
AudioListItem* nextPoolItem;
AudioListItem* freeList;
for (var_s3 = 0; var_s3 < 4; var_s3++) {
switch (var_s3) { /* irregular */
for (poolType = 0; poolType < 4; poolType++) {
switch (poolType) {
case 0:
sp48 = &pool->disabled;
sp40 = &gNoteFreeLists.disabled;
poolItem = &pool->disabled;
freeList = &gNoteFreeLists.disabled;
break;
case 1:
sp48 = &pool->decaying;
sp40 = &gNoteFreeLists.decaying;
poolItem = &pool->decaying;
freeList = &gNoteFreeLists.decaying;
break;
case 2:
sp48 = &pool->releasing;
sp40 = &gNoteFreeLists.releasing;
poolItem = &pool->releasing;
freeList = &gNoteFreeLists.releasing;
break;
case 3:
sp48 = &pool->active;
sp40 = &gNoteFreeLists.active;
poolItem = &pool->active;
freeList = &gNoteFreeLists.active;
break;
}
while (true) {
var_s0 = sp48->next;
if ((var_s0 == sp48) || (var_s0 == NULL)) {
nextPoolItem = poolItem->next;
if ((nextPoolItem == poolItem) || (nextPoolItem == NULL)) {
break;
}
func_80012C40((Note*) var_s0);
func_800145BC(sp40, var_s0);
func_80012C40((Note*) nextPoolItem);
func_800145BC(freeList, nextPoolItem);
}
}
}
void func_80012AC4(NotePool* pool, s32 arg1) {
s32 var_s0;
s32 var_s4;
AudioListItem* temp_v0;
AudioListItem* sp48;
AudioListItem* sp44;
s32 poolType;
AudioListItem* note;
AudioListItem* freeList;
AudioListItem* poolList;
func_80012964(pool);
var_s4 = 0;
poolType = 0;
var_s0 = 0;
while (var_s0 < arg1) {
if (var_s4 == 4) {
if (poolType == 4) {
return;
}
switch (var_s4) {
switch (poolType) {
case 0:
sp48 = &gNoteFreeLists.disabled;
sp44 = &pool->disabled;
freeList = &gNoteFreeLists.disabled;
poolList = &pool->disabled;
break;
case 1:
sp48 = &gNoteFreeLists.decaying;
sp44 = &pool->decaying;
freeList = &gNoteFreeLists.decaying;
poolList = &pool->decaying;
break;
case 2:
sp48 = &gNoteFreeLists.releasing;
sp44 = &pool->releasing;
freeList = &gNoteFreeLists.releasing;
poolList = &pool->releasing;
break;
case 3:
sp48 = &gNoteFreeLists.active;
sp44 = &pool->active;
freeList = &gNoteFreeLists.active;
poolList = &pool->active;
break;
}
while (var_s0 < arg1) {
temp_v0 = func_800145FC(sp48);
if (temp_v0 == NULL) {
note = func_800145FC(freeList);
if (note == NULL) {
break;
}
func_800145BC(sp44, temp_v0);
func_800145BC(poolList, note);
var_s0++;
}
var_s4++;
poolType++;
}
}
@@ -588,7 +587,7 @@ void func_80012C00(AudioListItem* item1, AudioListItem* item2) {
item2->next = item1->next;
item1->next->prev = item2;
item1->next = item2;
item1->u.count += 1;
item1->u.count++;
item2->pool = item1->pool;
}
}
@@ -601,35 +600,35 @@ void func_80012C40(Note* note) {
}
}
Note* func_80012C6C(AudioListItem* item, s32 arg1) {
AudioListItem* var_v0;
AudioListItem* var_v1;
void* temp_a0;
Note* func_80012C6C(AudioListItem* item, s32 priority) {
AudioListItem* priorityItem;
AudioListItem* nextItem = item->next;
var_v0 = item->next;
if (var_v0 == item) {
if (nextItem == item) {
return NULL;
}
for (var_v1 = var_v0; var_v0 != item; var_v0 = var_v0->next) {
if (((Note*) var_v1->u.value)->playbackState.priority >= ((Note*) var_v0->u.value)->playbackState.priority) {
var_v1 = var_v0;
priorityItem = nextItem;
for (nextItem; nextItem != item; nextItem = nextItem->next) {
if (((Note*) nextItem->u.value)->playbackState.priority <=
((Note*) priorityItem->u.value)->playbackState.priority) {
priorityItem = nextItem;
}
// var_v0 = var_v0->next;
}
if (var_v1 == NULL) {
if (priorityItem == NULL) {
return NULL;
}
if (((Note*) var_v1->u.value)->playbackState.priority >= arg1) {
if (((Note*) priorityItem->u.value)->playbackState.priority >= priority) {
return NULL;
}
return (Note*) var_v1->u.value;
return (Note*) priorityItem->u.value;
}
void func_80012CEC(Note* note, SequenceLayer* layer) {
s32 pad[4];
s32 var_a2;
NoteSubEu* temp_v0;
NoteSubEu* noteSub;
note->playbackState.prevParentLayer = NO_LAYER;
note->playbackState.parentLayer = layer;
@@ -642,22 +641,22 @@ void func_80012CEC(Note* note, SequenceLayer* layer) {
layer->noteVelocity = 0.0f;
func_80011EB8(note);
var_a2 = layer->instOrWave;
temp_v0 = &note->noteSubEu;
noteSub = &note->noteSubEu;
if (var_a2 == 0xFF) {
var_a2 = layer->channel->instOrWave;
}
temp_v0->waveSampleAddr = (s16*) layer->tunedSample;
if (var_a2 >= 0x80) {
temp_v0->bitField1.isSyntheticWave = 1;
noteSub->waveSampleAddr = (s16*) layer->tunedSample;
if (var_a2 >= 128) {
noteSub->bitField1.isSyntheticWave = true;
} else {
temp_v0->bitField1.isSyntheticWave = 0;
noteSub->bitField1.isSyntheticWave = false;
}
if (temp_v0->bitField1.isSyntheticWave) {
if (noteSub->bitField1.isSyntheticWave) {
func_800126AC(note, layer, var_a2);
}
note->playbackState.fontId = layer->channel->fontId;
temp_v0->bitField0.stereoHeadsetEffects = layer->channel->stereoHeadsetEffects;
temp_v0->bitField1.reverbIndex = layer->channel->someOtherPriority & 3;
noteSub->bitField0.stereoHeadsetEffects = layer->channel->stereoHeadsetEffects;
noteSub->bitField1.reverbIndex = layer->channel->someOtherPriority & 3;
}
void func_80012E28(Note* note, SequenceLayer* layer) {
@@ -673,23 +672,23 @@ void func_80012E5C(Note* note, SequenceLayer* layer) {
}
Note* func_80012E88(NotePool* pool, SequenceLayer* layer) {
Note* temp_v0 = func_800145FC(&pool->disabled);
Note* note = func_800145FC(&pool->disabled);
if (temp_v0 != NULL) {
func_80012CEC(temp_v0, layer);
func_80012C00(&pool->active, &temp_v0->listItem);
if (note != NULL) {
func_80012CEC(note, layer);
func_80012C00(&pool->active, &note->listItem);
}
return temp_v0;
return note;
}
Note* func_80012ED4(NotePool* pool, SequenceLayer* layer) {
Note* sp1C = func_800145FC(&pool->decaying);
Note* note = func_800145FC(&pool->decaying);
if (sp1C != NULL) {
func_80012E5C(sp1C, layer);
func_800145BC(&pool->releasing, &sp1C->listItem);
if (note != NULL) {
func_80012E5C(note, layer);
func_800145BC(&pool->releasing, &note->listItem);
}
return sp1C;
return note;
}
Note* func_80012F24(NotePool* pool, SequenceLayer* layer) {
+166 -158
View File
@@ -1,37 +1,37 @@
#include "sys.h"
#include "sf64audio_provisional.h"
static char devstr00[] = "Audio:Track:Warning: No Free Notetrack\n";
static char devstr01[] = "SUBTRACK DIM\n";
static char devstr02[] = "Audio:Track: Warning :SUBTRACK had been stolen by other Group.\n";
static char devstr03[] = "SEQID %d,BANKID %d\n";
static char devstr04[] = "ERR:SUBTRACK %d NOT ALLOCATED\n";
static char devstr05[] = "Stop Release\n";
static char devstr06[] = "Error:Same List Add\n";
static char devstr07[] = "Wait Time out!\n";
static char devstr08[] = "Macro Level Over Error!\n";
static char devstr09[] = "Macro Level Over Error!\n";
static char devstr10[] = "WARNING: NPRG: cannot change %d\n";
static char devstr11[] = "Audio:Track:NOTE:UNDEFINED NOTE COM. %x\n";
static char devstr12[] = "Audio: Note:Velocity Error %d\n";
static char devstr13[] = "Error: Subtrack no prg.\n";
static char devstr14[] = "ERR %x\n";
static char devstr15[] = "Error: Your assignchannel is stolen.\n";
static char devstr16[] = "Audio:Track :Call Macro Level Over Error!\n";
static char devstr17[] = "Audio:Track :Loops Macro Level Over Error!\n";
static char devstr18[] = "SUB:ERR:BANK %d NOT CACHED.\n";
static char devstr19[] = "SUB:ERR:BANK %d NOT CACHED.\n";
static char devstr20[] = "Audio:Track: CTBLCALL Macro Level Over Error!\n";
static char devstr21[] = "Set Noise %d\n";
static char devstr22[] = "[%2x] \n";
static char devstr23[] = "Err :Sub %x ,address %x:Undefined SubTrack Function %x";
static char devstr24[] = "VoiceLoad Error Bank:%d,Prog:%d\n";
static char devstr25[] = "Disappear Sequence or Bank %d\n";
static char devstr26[] = "[FIN] group.\n";
static char devstr27[] = "Macro Level Over Error!\n";
static char devstr28[] = "Macro Level Over Error!\n";
static char devstr29[] = "Group:Undefine upper C0h command (%x)\n";
static char devstr30[] = "Group:Undefined Command\n";
static const char devstr00[] = "Audio:Track:Warning: No Free Notetrack\n";
static const char devstr01[] = "SUBTRACK DIM\n";
static const char devstr02[] = "Audio:Track: Warning :SUBTRACK had been stolen by other Group.\n";
static const char devstr03[] = "SEQID %d,BANKID %d\n";
static const char devstr04[] = "ERR:SUBTRACK %d NOT ALLOCATED\n";
static const char devstr05[] = "Stop Release\n";
static const char devstr06[] = "Error:Same List Add\n";
static const char devstr07[] = "Wait Time out!\n";
static const char devstr08[] = "Macro Level Over Error!\n";
static const char devstr09[] = "Macro Level Over Error!\n";
static const char devstr10[] = "WARNING: NPRG: cannot change %d\n";
static const char devstr11[] = "Audio:Track:NOTE:UNDEFINED NOTE COM. %x\n";
static const char devstr12[] = "Audio: Note:Velocity Error %d\n";
static const char devstr13[] = "Error: Subtrack no prg.\n";
static const char devstr14[] = "ERR %x\n";
static const char devstr15[] = "Error: Your assignchannel is stolen.\n";
static const char devstr16[] = "Audio:Track :Call Macro Level Over Error!\n";
static const char devstr17[] = "Audio:Track :Loops Macro Level Over Error!\n";
static const char devstr18[] = "SUB:ERR:BANK %d NOT CACHED.\n";
static const char devstr19[] = "SUB:ERR:BANK %d NOT CACHED.\n";
static const char devstr20[] = "Audio:Track: CTBLCALL Macro Level Over Error!\n";
static const char devstr21[] = "Set Noise %d\n";
static const char devstr22[] = "[%2x] \n";
static const char devstr23[] = "Err :Sub %x ,address %x:Undefined SubTrack Function %x";
static const char devstr24[] = "VoiceLoad Error Bank:%d,Prog:%d\n";
static const char devstr25[] = "Disappear Sequence or Bank %d\n";
static const char devstr26[] = "[FIN] group.\n";
static const char devstr27[] = "Macro Level Over Error!\n";
static const char devstr28[] = "Macro Level Over Error!\n";
static const char devstr29[] = "Group:Undefine upper C0h command (%x)\n";
static const char devstr30[] = "Group:Undefined Command\n";
void func_800145BC(AudioListItem* list, AudioListItem* item);
void* func_800145FC(AudioListItem* list);
@@ -44,7 +44,7 @@ void func_80013EA0(SequenceChannel* channel) {
channel->finished = 0;
channel->stopScript = 0;
channel->muted = 0;
channel->hasInstrument = 0;
channel->hasInstrument = false;
channel->stereoHeadsetEffects = 0;
channel->transposition = 0;
channel->largeNotes = 0;
@@ -142,7 +142,7 @@ void func_8001410C(SequenceChannel* channel, s32 arg1) {
void func_8001415C(SequenceChannel* channel) {
s32 var_s0;
for (var_s0 = 0; var_s0 < 4; var_s0++) {
for (var_s0 = 0; var_s0 < ARRAY_COUNT(channel->layers); var_s0++) {
func_8001410C(channel, var_s0);
}
func_80012964(&channel->notePool);
@@ -212,18 +212,18 @@ void func_80014370(SequencePlayer* seqPlayer, u16 arg1) {
}
void func_80014440(SequencePlayer* seqPlayer, u8 arg1, u8* arg2) {
SequenceChannel* temp_s2 = seqPlayer->channels[arg1];
SequenceChannel* channel = seqPlayer->channels[arg1];
s32 i;
if (IS_SEQUENCE_CHANNEL_VALID(temp_s2) != 0) {
temp_s2->scriptState.depth = 0;
temp_s2->scriptState.pc = arg2;
temp_s2->enabled = 1;
temp_s2->finished = 0;
temp_s2->delay = 0;
for (i = 0; i < 4; i++) {
if (temp_s2->layers[i] != NULL) {
func_8001410C(temp_s2, i);
if (IS_SEQUENCE_CHANNEL_VALID(channel) != 0) {
channel->scriptState.depth = 0;
channel->scriptState.pc = arg2;
channel->enabled = 1;
channel->finished = 0;
channel->delay = 0;
for (i = 0; i < ARRAY_COUNT(channel->layers); i++) {
if (channel->layers[i] != NULL) {
func_8001410C(channel, i);
}
}
}
@@ -349,25 +349,25 @@ void func_80014748(SequenceLayer* layer) {
break;
}
switch (cmd) { /* switch 5; irregular */
case 0xFF: /* switch 5 */
case 0xFF:
if (state->depth == 0) {
func_800140D0(layer);
return;
}
state->pc = state->stack[--state->depth];
break;
case 0xFC: /* switch 5 */
case 0xFC:
sp44 = func_800146D4(state);
state->stack[state->depth] = state->pc;
state->depth++;
state->pc = &seqPlayer->seqData[sp44];
break;
case 0xF8: /* switch 5 */
case 0xF8:
state->remLoopIters[state->depth] = func_800146C0(state);
state->stack[state->depth] = state->pc;
state->depth++;
break;
case 0xF7: /* switch 5 */
case 0xF7:
state->remLoopIters[state->depth - 1]--;
if (state->remLoopIters[state->depth - 1] != 0) {
state->pc = state->stack[state->depth - 1];
@@ -375,15 +375,15 @@ void func_80014748(SequenceLayer* layer) {
state->depth--;
}
break;
case 0xFB: /* switch 5 */
case 0xFB:
sp44 = func_800146D4(state);
state->pc = &seqPlayer->seqData[sp44];
break;
case 0xF4: /* switch 5 */
case 0xF4:
state->pc += (s8) func_800146C0(state);
break;
case 0xC1: /* switch 5 */
case 0xCA: /* switch 5 */
case 0xC1:
case 0xCA:
var_s2 = *state->pc++;
if (cmd == 0xC1) {
layer->velocitySquare = (f32) (var_s2 * var_s2) / 16129.0f;
@@ -391,8 +391,8 @@ void func_80014748(SequenceLayer* layer) {
layer->pan = var_s2;
}
break;
case 0xC2: /* switch 5 */
case 0xC9: /* switch 5 */
case 0xC2:
case 0xC9:
var_s2 = *state->pc++;
if (cmd == 0xC9) {
layer->gateTime = var_s2;
@@ -400,8 +400,8 @@ void func_80014748(SequenceLayer* layer) {
layer->transposition = var_s2;
}
break;
case 0xC4: /* switch 5 */
case 0xC5: /* switch 5 */
case 0xC4:
case 0xC5:
if (cmd == 0xC4) {
layer->continuousNotes = 1;
} else {
@@ -409,11 +409,11 @@ void func_80014748(SequenceLayer* layer) {
}
func_8001266C(layer);
break;
case 0xC3: /* switch 5 */
case 0xC3:
sp44 = func_80014704(state);
layer->shortNoteDefaultDelay = sp44;
break;
case 0xC6: /* switch 5 */
case 0xC6:
cmd = func_800146C0(state);
if (cmd >= 127) {
if (cmd == 127) {
@@ -433,7 +433,7 @@ void func_80014748(SequenceLayer* layer) {
}
}
break;
case 0xC7: /* switch 5 */
case 0xC7:
layer->portamento.mode = func_800146C0(state);
cmd = func_800146C0(state) + channel->transposition + layer->transposition + seqPlayer->transposition;
if (cmd > 127) {
@@ -447,27 +447,27 @@ void func_80014748(SequenceLayer* layer) {
layer->portamentoTime = sp44;
}
break;
case 0xC8: /* switch 5 */
case 0xC8:
layer->portamento.mode = 0;
break;
case 0xCB: /* switch 5 */
case 0xCB:
sp44 = func_800146D4(state);
layer->adsr.envelope = (EnvelopePoint*) &seqPlayer->seqData[sp44];
layer->adsr.decayIndex = func_800146C0(state);
break;
case 0xCC: /* switch 5 */
case 0xCC:
layer->bit1 = 1;
break;
case 0xCD: /* switch 5 */
case 0xCD:
layer->stereo.asByte = func_800146C0(state);
break;
default: /* switch 5 */
default:
switch (cmd & 0xF0) { /* switch 6; irregular */
case 0xD0: /* switch 6 */
case 0xD0:
sp44 = (u16) seqPlayer->shortNoteVelocityTable[cmd & 0xF];
layer->velocitySquare = (f32) (sp44 * sp44) / 16129.0f;
break;
case 0xE0: /* switch 6 */
case 0xE0:
layer->gateTime = seqPlayer->shortNoteGateTimeTable[cmd & 0xF];
break;
default:
@@ -518,14 +518,14 @@ void func_80014748(SequenceLayer* layer) {
cmd -= (cmd & 0xC0);
} else {
switch (cmd & 0xC0) { /* switch 4; irregular */
case 0x0: /* switch 4 */
case 0x0:
sp44 = func_80014704(state);
layer->lastDelay = sp44;
break;
case 0x40: /* switch 4 */
case 0x40:
sp44 = layer->shortNoteDefaultDelay;
break;
case 0x80: /* switch 4 */
case 0x80:
sp44 = layer->lastDelay;
break;
}
@@ -587,19 +587,19 @@ void func_80014748(SequenceLayer* layer) {
temp_fv1 = gPitchFrequencies[cmd] * tuning;
temp_fa1 = gPitchFrequencies[layer->portamentoTargetNote] * tuning;
portamento = &layer->portamento;
switch (portamento->mode & ~0x80) { /* switch 3 */
case 1: /* switch 3 */
case 3: /* switch 3 */
case 5: /* switch 3 */
switch (portamento->mode & ~0x80) {
case 1:
case 3:
case 5:
var_v0_2 = temp_fv1;
freqMod = temp_fa1;
break;
case 2: /* switch 3 */
case 4: /* switch 3 */
case 2:
case 4:
freqMod = temp_fv1;
var_v0_2 = temp_fa1;
break;
default: /* switch 3 */
default:
freqMod = temp_fv1;
var_v0_2 = temp_fv1;
break;
@@ -688,11 +688,11 @@ void func_80015330(SequenceChannel* channel, u8 arg1) {
channel->instrument = (Instrument*) 1;
} else {
if ((channel->instOrWave = func_800152C0(channel, arg1, &channel->instrument, &channel->adsr)) == 0) {
channel->hasInstrument = 0;
channel->hasInstrument = false;
return;
}
}
channel->hasInstrument = 1;
channel->hasInstrument = true;
}
void func_800153C4(SequenceChannel* channel, u8 arg1) {
@@ -715,7 +715,7 @@ void func_800153E8(SequenceChannel* channel) {
return;
}
if (channel->stopScript) {
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(channel->layers); i++) {
if (channel->layers[i] != NULL) {
func_80014748(channel->layers[i]);
}
@@ -741,7 +741,7 @@ void func_800153E8(SequenceChannel* channel) {
case 0xD5:
case 0xD6:
break;
case 0xFF: /* switch 3 */
case 0xFF:
if (state->depth == 0) {
func_8001415C(channel);
goto end_loop;
@@ -750,10 +750,10 @@ void func_800153E8(SequenceChannel* channel) {
break;
case 0xFE:
goto end_loop;
case 0xFD: /* switch 3 */
case 0xFD:
channel->delay = func_80014704(state);
goto end_loop;
case 0xEA: /* switch 3 */
case 0xEA:
channel->stopScript = 1;
goto end_loop;
case 0xFC:
@@ -764,14 +764,14 @@ void func_800153E8(SequenceChannel* channel) {
state->depth++;
state->pc = &seqPlayer->seqData[sp52];
break;
case 0xF8: /* switch 3 */
case 0xF8:
// if (0 && state->depth >= 4) {
// }
state->remLoopIters[state->depth] = func_800146C0(state);
state->stack[state->depth] = state->pc;
state->depth++;
break;
case 0xF7: /* switch 3 */
case 0xF7:
state->remLoopIters[state->depth - 1]--;
if (state->remLoopIters[state->depth - 1] != 0) {
state->pc = state->stack[state->depth - 1];
@@ -779,13 +779,13 @@ void func_800153E8(SequenceChannel* channel) {
state->depth--;
}
break;
case 0xF6: /* switch 3 */
case 0xF6:
state->depth--;
break;
case 0xF5: /* switch 3 */
case 0xF9: /* switch 3 */
case 0xFA: /* switch 3 */
case 0xFB: /* switch 3 */
case 0xF5:
case 0xF9:
case 0xFA:
case 0xFB:
sp52 = func_800146D4(state);
if (((cmd == 0xFA) && (sp4B != 0)) || ((cmd == 0xF9) && (sp4B >= 0)) ||
((cmd == 0xF5) && (sp4B < 0))) {
@@ -793,138 +793,138 @@ void func_800153E8(SequenceChannel* channel) {
}
state->pc = &seqPlayer->seqData[sp52];
break;
case 0xF2: /* switch 3 */
case 0xF3: /* switch 3 */
case 0xF4: /* switch 3 */
case 0xF2:
case 0xF3:
case 0xF4:
temps8 = func_800146C0(state);
if (((cmd == 0xF3) && (sp4B != 0)) || ((cmd == 0xF2) && (sp4B >= 0))) {
break;
}
state->pc = &state->pc[temps8];
break;
case 0xF1: /* switch 3 */
case 0xF1:
func_80012964(&channel->notePool);
func_80012AC4(&channel->notePool, func_800146C0(state));
break;
case 0xF0: /* switch 3 */
case 0xF0:
func_80012964(&channel->notePool);
break;
case 0xC2: /* switch 3 */
case 0xC2:
sp52 = func_800146D4(state);
channel->dynTable = (u8(*)[2]) & seqPlayer->seqData[sp52];
break;
case 0xC5: /* switch 3 */
case 0xC5:
if (sp4B != -1) {
seqData = channel->dynTable[sp4B];
sp52 = (seqData[0] << 8) + seqData[1];
channel->dynTable = (u8(*)[2]) & seqPlayer->seqData[sp52];
}
break;
case 0xEB: /* switch 3 */
case 0xEB:
cmd = func_800146C0(state);
sp52 = ((u16*) gSeqFontTable)[seqPlayer->seqId];
loBits = gSeqFontTable[sp52];
cmd = gSeqFontTable[sp52 + loBits - cmd];
if (AudioHeap_SearchCaches(1, 2, cmd) != 0) {
if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd) != NULL) {
channel->fontId = cmd;
}
/* fallthrough */
case 0xC1: /* switch 3 */
case 0xC1:
cmd = func_800146C0(state);
func_80015330(channel, cmd);
break;
case 0xC3: /* switch 3 */
case 0xC3:
channel->largeNotes = false;
break;
case 0xC4: /* switch 3 */
case 0xC4:
channel->largeNotes = true;
break;
case 0xDF: /* switch 3 */
case 0xDF:
cmd = func_800146C0(state);
func_800153C4(channel, cmd);
channel->changes.s.volume = 1;
break;
case 0xE0: /* switch 3 */
channel->volumeMod = (s32) func_800146C0(state) * 0.0078125f;
case 0xE0:
channel->volumeMod = (s32) func_800146C0(state) / 128.0f;
channel->changes.s.volume = 1;
break;
case 0xDE: /* switch 3 */
case 0xDE:
sp52 = func_800146D4(state);
channel->freqMod = (s32) sp52 / 32768.0f;
channel->changes.s.freqMod = 1;
break;
case 0xD3: /* switch 3 */
case 0xD3:
cmd = func_800146C0(state) + 0x80;
channel->freqMod = gBendPitchOneOctaveFrequencies[cmd];
channel->changes.s.freqMod = 1;
break;
case 0xEE: /* switch 3 */
case 0xEE:
cmd = func_800146C0(state) + 0x80;
channel->freqMod = gBendPitchTwoSemitonesFrequencies[cmd];
channel->changes.s.freqMod = 1;
break;
case 0xDD: /* switch 3 */
case 0xDD:
channel->newPan = func_800146C0(state);
channel->changes.s.pan = 1;
break;
case 0xDC: /* switch 3 */
case 0xDC:
channel->panChannelWeight = func_800146C0(state);
channel->changes.s.pan = 1;
break;
case 0xDB: /* switch 3 */
case 0xDB:
temps8 = *(state->pc++);
channel->transposition = temps8;
break;
case 0xDA: /* switch 3 */
case 0xDA:
sp52 = func_800146D4(state);
channel->adsr.envelope = (EnvelopePoint*) &seqPlayer->seqData[sp52];
break;
case 0xD9: /* switch 3 */
case 0xD9:
channel->adsr.decayIndex = func_800146C0(state);
break;
case 0xD8: /* switch 3 */
case 0xD8:
channel->vibratoDepthTarget = func_800146C0(state) * 8;
channel->vibratoDepthStart = 0;
channel->vibratoDepthChangeDelay = 0;
break;
case 0xD7: /* switch 3 */
case 0xD7:
channel->vibratoRateStart = channel->vibratoRateTarget = func_800146C0(state) * 32;
channel->vibratoRateChangeDelay = 0;
break;
case 0xE2: /* switch 3 */
case 0xE2:
channel->vibratoDepthStart = func_800146C0(state) * 8;
channel->vibratoDepthTarget = func_800146C0(state) * 8;
channel->vibratoDepthChangeDelay = func_800146C0(state) * 0x10;
break;
case 0xE1: /* switch 3 */
case 0xE1:
channel->vibratoRateStart = func_800146C0(state) * 32;
channel->vibratoRateTarget = func_800146C0(state) * 32;
channel->vibratoRateChangeDelay = func_800146C0(state) * 0x10;
break;
case 0xE3: /* switch 3 */
case 0xE3:
channel->vibratoDelay = func_800146C0(state) * 0x10;
break;
case 0xD4: /* switch 3 */
case 0xD4:
channel->targetReverbVol = func_800146C0(state);
break;
case 0xC6: /* switch 3 */
case 0xC6:
cmd = func_800146C0(state);
sp52 = ((u16*) gSeqFontTable)[seqPlayer->seqId];
loBits = gSeqFontTable[sp52];
cmd = gSeqFontTable[sp52 + loBits - cmd];
if (AudioHeap_SearchCaches(1, 2, cmd) != 0) {
if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, cmd) != NULL) {
channel->fontId = cmd;
}
break;
case 0xC7: /* switch 3 */
case 0xC7:
cmd = func_800146C0(state);
sp52 = func_800146D4(state);
seqData = &seqPlayer->seqData[sp52];
*seqData = (u8) sp4B + cmd;
break;
case 0xC8: /* switch 3 */
case 0xC9: /* switch 3 */
case 0xCC: /* switch 3 */
case 0xC8:
case 0xC9:
case 0xCC:
temps8 = func_800146C0(state);
if (cmd == 0xC8) {
sp4B -= temps8;
@@ -934,40 +934,40 @@ void func_800153E8(SequenceChannel* channel) {
sp4B &= temps8;
}
break;
case 0xCD: /* switch 3 */
case 0xCD:
func_8001415C(seqPlayer->channels[func_800146C0(state)]);
break;
case 0xCA: /* switch 3 */
case 0xCA:
channel->muteBehavior = func_800146C0(state);
break;
case 0xCB: /* switch 3 */
case 0xCB:
sp52 = func_800146D4(state);
pad = sp52 + sp4B;
// seqData =&seqPlayer->seqData[sp4B];
sp4B = seqPlayer->seqData[pad];
break;
case 0xCE: /* switch 3 */
case 0xCE:
channel->unkC4 = func_800146D4(state);
break;
case 0xCF: /* switch 3 */
case 0xCF:
sp52 = func_800146D4(state);
seqData = &seqPlayer->seqData[sp52];
seqData[0] = (channel->unkC4 >> 8) & 0xFF;
seqData[1] = channel->unkC4 & 0xFF;
break;
case 0xD0: /* switch 3 */
case 0xD0:
channel->stereoHeadsetEffects = func_800146C0(state);
break;
case 0xD1: /* switch 3 */
case 0xD1:
channel->noteAllocPolicy = func_800146C0(state);
break;
case 0xD2: /* switch 3 */
case 0xD2:
channel->adsr.sustain = func_800146C0(state);
break;
case 0xE5: /* switch 3 */
case 0xE5:
channel->someOtherPriority = func_800146C0(state);
break;
case 0xE4: /* switch 3 */
case 0xE4:
if (sp4B != -1) {
if (state->depth >= 4) {
// eu_stubbed_printf_0("Audio:Track: CTBLCALL Macro Level Over Error!\n");
@@ -982,10 +982,10 @@ void func_800153E8(SequenceChannel* channel) {
// }
}
break;
case 0xE6: /* switch 3 */
case 0xE6:
channel->bookOffset = func_800146C0(state);
break;
case 0xE7: /* switch 3 */
case 0xE7:
sp52 = func_800146D4(state);
seqData = &seqPlayer->seqData[sp52];
channel->muteBehavior = *seqData++;
@@ -998,7 +998,7 @@ void func_800153E8(SequenceChannel* channel) {
channel->someOtherPriority = *seqData++;
channel->changes.s.pan = 1;
break;
case 0xE8: /* switch 3 */
case 0xE8:
channel->muteBehavior = func_800146C0(state);
channel->noteAllocPolicy = func_800146C0(state);
channel->notePriority = func_800146C0(state);
@@ -1009,7 +1009,7 @@ void func_800153E8(SequenceChannel* channel) {
channel->someOtherPriority = func_800146C0(state);
channel->changes.s.pan = 1;
break;
case 0xEC: /* switch 3 */
case 0xEC:
channel->vibratoDepthTarget = 0;
channel->vibratoDepthStart = 0;
channel->vibratoDepthChangeDelay = 0;
@@ -1018,58 +1018,58 @@ void func_800153E8(SequenceChannel* channel) {
channel->vibratoRateChangeDelay = 0;
channel->freqMod = 1.0f;
break;
case 0xE9: /* switch 3 */
case 0xE9:
channel->notePriority = func_800146C0(state);
break;
case 0xED: /* switch 3 */
case 0xED:
// cmd =
channel->reverbIndex = func_800146C0(state);
break;
case 0xEF: /* switch 3 */
case 0xEF:
func_800146D4(state);
func_800146C0(state);
break;
}
} else {
loBits = cmd & 0xF;
switch (cmd & 0xF0) { /* switch 2 */
case 0x0: /* switch 2 */
switch (cmd & 0xF0) {
case 0x0:
if (channel->layers[loBits] != NULL) {
sp4B = channel->layers[loBits]->finished;
} else {
sp4B = -1;
}
break;
case 0x10: /* switch 2 */
case 0x10:
channel->seqScriptIO[loBits] = -1;
if (AudioLoad_SlowLoadSample(channel->fontId, sp4B, &channel->seqScriptIO[loBits]) == -1) {}
break;
case 0x70: /* switch 2 */
case 0x70:
channel->seqScriptIO[loBits] = sp4B;
break;
case 0x80: /* switch 2 */
case 0x80:
sp4B = channel->seqScriptIO[loBits];
if (loBits < 4) {
channel->seqScriptIO[loBits] = -1;
}
break;
case 0x50: /* switch 2 */
case 0x50:
sp4B -= channel->seqScriptIO[loBits];
break;
case 0x60: /* switch 2 */
case 0x60:
channel->delay = loBits;
goto end_loop;
case 0x90: /* switch 2 */
case 0x90:
sp52 = func_800146D4(state);
if (func_80013FC4(channel, loBits) == 0) {
// if(1) {}
channel->layers[loBits]->state.pc = &seqPlayer->seqData[sp52];
}
break;
case 0xA0: /* switch 2 */
case 0xA0:
func_8001410C(channel, loBits);
break;
case 0xB0: /* switch 2 */
case 0xB0:
if ((sp4B != -1) && (func_80013FC4(channel, loBits) != -1)) {
seqData = channel->dynTable[sp4B];
sp52 = (seqData[0] << 8) + seqData[1];
@@ -1080,11 +1080,11 @@ void func_800153E8(SequenceChannel* channel) {
sp52 = func_800146D4(state);
func_80014440(seqPlayer, loBits, &seqPlayer->seqData[sp52]);
break;
case 0x30: /* switch 2 */
case 0x30:
cmd = func_800146C0(state);
seqPlayer->channels[loBits]->seqScriptIO[cmd] = sp4B;
break;
case 0x40: /* switch 2 */
case 0x40:
cmd = func_800146C0(state);
sp4B = seqPlayer->channels[loBits]->seqScriptIO[cmd];
break;
@@ -1093,7 +1093,7 @@ void func_800153E8(SequenceChannel* channel) {
}
}
end_loop:;
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(channel->layers); i++) {
if (channel->layers[i] != NULL) {
func_80014748(channel->layers[i]);
}
@@ -1352,7 +1352,7 @@ void func_80015FD4(SequencePlayer* seqPlayer) {
void func_8001678C(s32 arg0) {
s32 i;
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
if (gSeqPlayers[i].enabled == 1) {
func_80015FD4(&gSeqPlayers[i]);
func_800135A8(&gSeqPlayers[i]);
@@ -1387,19 +1387,27 @@ void func_800168BC(void) {
s32 i;
s32 j;
for (i = 0; i < 48; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqChannels); i++) {
gSeqChannels[i].seqPlayer = NULL;
gSeqChannels[i].enabled = false;
for (j = 0; j < 64; j++) { // bug: this is sizeof(gSeqLayers) instead of sizeof(gSeqChannels[i].layers)
#ifdef AVOID_UB
for (j = 0; j < ARRAY_COUNT(gSeqChannels->layers); j++) {
#else
for (j = 0; j < 64;
j++) { // bug: this is ARRAY_COUNT(gSeqLayers) instead of ARRAY_COUNT(gSeqChannels[i].layers)
#endif
gSeqChannels[i].layers[j] = NULL;
}
}
func_8001463C();
for (i = 0; i < 64; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqLayers); i++) {
gSeqLayers[i].channel = NULL;
gSeqLayers[i].enabled = false;
}
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
for (j = 0; j < 16; j++) {
gSeqPlayers[i].channels[j] = &gSeqChannelNone;
}
+103 -74
View File
@@ -1,7 +1,9 @@
#include "sys.h"
#include "sf64audio_provisional.h"
s32 D_80145D40;
s32 D_80145D40; // unused
// all of these are part of the DFT-related function
f32 D_80145D48[256];
f32 D_80146148[256];
f32 D_80146548[515];
@@ -14,16 +16,16 @@ f32 D_80146D68;
f32 D_80146D6C;
f32 D_80146D70;
static char devstr0[] = "Table Remake\n";
static char devstr1[] = "-------------------Undefined Ctype \n";
static char devstr2[] = "Error? Limit OVER %d in %d\n";
static char devstr3[] = "";
static char devstr4[] = "Get %x %x\n";
static char devstr5[] = "Break %x %d %d \n";
static char devstr6[] = "Terminate-Canceled Channel %d,Phase %d\n";
static char devstr7[] = "S->W\n";
static char devstr8[] = "W->S\n";
static char devstr9[] = "S-Resample Pitch %x (old %d -> delay %d)\n";
static const char devstr0[] = "Table Remake\n";
static const char devstr1[] = "-------------------Undefined Ctype \n";
static const char devstr2[] = "Error? Limit OVER %d in %d\n";
static const char devstr3[] = "";
static const char devstr4[] = "Get %x %x\n";
static const char devstr5[] = "Break %x %d %d \n";
static const char devstr6[] = "Terminate-Canceled Channel %d,Phase %d\n";
static const char devstr7[] = "S->W\n";
static const char devstr8[] = "W->S\n";
static const char devstr9[] = "S-Resample Pitch %x (old %d -> delay %d)\n";
void func_80009A2C(s32 updateIndex, s32 noteIndex);
void func_80009AAC(s32 updateIndex);
@@ -159,6 +161,7 @@ void func_80008364(f32* buffer0, f32* buffer1, s32 length, f32* buffer2) {
}
}
// https://decomp.me/scratch/8eyVg
#ifdef NON_MATCHING
void func_80008780(f32* arg0, s32 arg1, f32* arg2) {
s32 length;
@@ -361,9 +364,10 @@ void func_80008780(f32* arg0, s32 arg1, f32* arg2) {
}
}
#else
#pragma GLOBAL_ASM("asm/us/nonmatchings/audio/audio_synthesis/func_80008780.s")
#pragma GLOBAL_ASM("asm/us/rev1/nonmatchings/audio/audio_synthesis/func_80008780.s")
#endif
// https://decomp.me/scratch/mYlns
#ifdef NON_MATCHING
void func_80009124(s16** arg0) {
s16* var_a1;
@@ -490,29 +494,26 @@ void func_80009124(s16** arg0) {
}
#else
void func_80009124(s16** arg0);
#pragma GLOBAL_ASM("asm/us/nonmatchings/audio/audio_synthesis/func_80009124.s")
#pragma GLOBAL_ASM("asm/us/rev1/nonmatchings/audio/audio_synthesis/func_80009124.s")
#endif
void func_80009504(s16* arg0, UnkStruct_800097A8* arg1) {
s32 i;
f32 temp_ft0;
f32* var_v0;
f32* var_v0_2;
s32 temp_v0;
void* var_s0;
var_s0 = arg0;
if (arg1->unk_0 != NULL) {
arg1->unk_C = arg1->unk_0;
arg1->unk_0 = 0;
}
arg1->unk18 += D_8014C1B4;
while (arg1->unk18 > 0x1000) {
func_80009124(&arg1->unk_C);
arg1->unk18 -= 0x1000;
}
func_80008364(D_80145D48, D_80146148, 8, D_80146548);
for (i = 0; i < 0x100; i++) {
for (i = 0; i < 256; i++) {
if (D_80145D48[i] > 32767.0f) {
D_80145D48[i] = 32767.0f;
}
@@ -520,6 +521,7 @@ void func_80009504(s16* arg0, UnkStruct_800097A8* arg1) {
D_80145D48[i] = -32767.0f;
}
}
for (i = 0; i < 0x100; i++, arg0++) {
*arg0 = D_80145D48[i];
}
@@ -535,6 +537,7 @@ s32 func_8000967C(s32 length, s16* ramAddr, UnkStruct_800097A8* arg2) {
for (i = 0; i < arg2->unk_4; i++) {
ramAddr[i] = temp_t7[i];
}
var_s1 = arg2->unk_4;
temp_t0 = (length - arg2->unk_4 + 0xFF) / 256;
arg2->unk_4 = (temp_t0 * 256) + arg2->unk_4 - length;
@@ -543,6 +546,7 @@ s32 func_8000967C(s32 length, s16* ramAddr, UnkStruct_800097A8* arg2) {
func_80009504(&ramAddr[var_s1], arg2);
var_s1 += 0x100;
}
for (i = 0; i < arg2->unk_4; i++) {
temp_t7[i] = ramAddr[length + i];
}
@@ -566,10 +570,13 @@ u8* func_800097A8(Sample* sample, s32 length, u32 flags, UnkStruct_800097A8* arg
arg3->unk_14->sizeUnused = 0;
}
}
if (gSampleDmaReuseQueue1RdPos != gSampleDmaReuseQueue1WrPos) {
sp1C = &gSampleDmas[gSampleDmaReuseQueue1[gSampleDmaReuseQueue1RdPos++]];
}
if (1) {}
if (1) {} //! FAKE
sp1C->ttl = 2;
sp1C->devAddr = sample->sampleAddr;
sp1C->sizeUnused = length * 2;
@@ -633,6 +640,7 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
func_8001678C(i - 1);
func_80009AAC(gAudioBufferParams.ticksPerUpdate - i);
}
aiBufPtr = (s32*) aiBufStart;
for (i = gAudioBufferParams.ticksPerUpdate; i > 0; i--) {
if (i == 1) {
@@ -644,22 +652,27 @@ Acmd* func_80009B64(Acmd* aList, s32* cmdCount, s16* aiBufStart, s32 aiBufLen) {
} else {
chunkLen = gAudioBufferParams.samplesPerTick;
}
for (j = 0; j < gNumSynthReverbs; j++) {
if (gSynthReverbs[j].useReverb) {
func_800080C0(chunkLen, gAudioBufferParams.ticksPerUpdate - i, j);
}
}
aCmdPtr = func_8000A25C((s16*) aiBufPtr, chunkLen, aCmdPtr, gAudioBufferParams.ticksPerUpdate - i);
aiBufLen -= chunkLen;
aiBufPtr += chunkLen;
}
for (j = 0; j < gNumSynthReverbs; j++) {
if (gSynthReverbs[j].framesToIgnore != 0) {
gSynthReverbs[j].framesToIgnore--;
}
gSynthReverbs[j].curFrame ^= 1;
}
*cmdCount = aCmdPtr - aList;
return aCmdPtr;
}
@@ -676,7 +689,7 @@ Acmd* func_80009D78(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s16 updateIndex)
aList = func_800098DC(aList, sp64->lengthA + 0xC90, 0, sp64->lengthB, reverbIndex);
}
aAddMixer(aList++, 0x300, 0xC90, 0x990, 0x7FFF);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].unk_08 + 0x8000, 0xC90, 0xC90);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90);
} else {
sp62 = (sp64->startPos & 7) * 2;
sp60 = ALIGN16(sp62 + sp64->lengthA);
@@ -691,13 +704,13 @@ Acmd* func_80009D78(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s16 updateIndex)
aResample(aList++, gSynthReverbs[reverbIndex].resampleFlags, gSynthReverbs[reverbIndex].unk_0A,
OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex].unk_34));
aAddMixer(aList++, 0x300, 0xC90, 0x990, 0x7FFF);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].unk_08 + 0x8000, 0xC90, 0xC90);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90);
}
if ((gSynthReverbs[reverbIndex].decayRatio != 0) || (gSynthReverbs[reverbIndex].unk_0E != 0)) {
if ((gSynthReverbs[reverbIndex].leakRtL != 0) || (gSynthReverbs[reverbIndex].leakLtR != 0)) {
aDMEMMove(aList++, 0xC90, 0x470, 0x180);
aMix(aList++, 0x18, gSynthReverbs[reverbIndex].decayRatio, 0xE10, 0xC90);
aMix(aList++, 0x18, gSynthReverbs[reverbIndex].unk_0E, 0x470, 0xE10);
aMix(aList++, 0x18, gSynthReverbs[reverbIndex].leakRtL, 0xE10, 0xC90);
aMix(aList++, 0x18, gSynthReverbs[reverbIndex].leakLtR, 0x470, 0xE10);
}
return aList;
}
@@ -713,6 +726,7 @@ Acmd* func_8000A128(Acmd* aList, s16 reverbIndex, s16 updateIndex) {
aList = func_80009984(aList, sp24->lengthA + 0xC90, 0, sp24->lengthB, reverbIndex);
}
break;
default:
aSaveBuffer(aList++, 0xC90,
OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex]
@@ -722,6 +736,7 @@ Acmd* func_8000A128(Acmd* aList, s16 reverbIndex, s16 updateIndex) {
gSynthReverbs[reverbIndex].resampleFlags = 0;
break;
}
return aList;
}
@@ -729,64 +744,70 @@ Acmd* func_8000A25C(s16* aiBuf, s32 aiBufLen, Acmd* aList, s32 updateIndex) {
u8 sp84[0x3C];
NoteSubEu* temp_v0;
s16 var_s2;
s16 var_s3;
s32 var_s1;
s16 i;
s32 j;
var_s2 = 0;
if (gNumSynthReverbs == 0) {
if (gSynthReverbs[var_s3].useReverb) {} // fake?
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
if (gNoteSubsEu[gNumNotes * updateIndex + var_s1].bitField0.enabled) {
sp84[var_s2++] = var_s1;
if (gSynthReverbs[i].useReverb) {} // fake?
for (j = 0; j < gNumNotes; j++) {
if (gNoteSubsEu[gNumNotes * updateIndex + j].bitField0.enabled) {
sp84[var_s2++] = j;
}
}
} else {
for (var_s3 = 0; var_s3 < gNumSynthReverbs; var_s3++) {
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + var_s1];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex == var_s3)) {
sp84[var_s2++] = var_s1;
for (i = 0; i < gNumSynthReverbs; i++) {
for (j = 0; j < gNumNotes; j++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + j];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex == i)) {
sp84[var_s2++] = j;
}
}
}
for (var_s1 = 0; var_s1 < gNumNotes; var_s1++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + var_s1];
for (j = 0; j < gNumNotes; j++) {
temp_v0 = &gNoteSubsEu[gNumNotes * updateIndex + j];
if (temp_v0->bitField0.enabled && (temp_v0->bitField1.reverbIndex >= gNumSynthReverbs)) {
sp84[var_s2++] = var_s1;
sp84[var_s2++] = j;
}
}
}
aClearBuffer(aList++, 0x990, 0x300);
var_s1 = 0;
for (var_s3 = 0; var_s3 < gNumSynthReverbs; var_s3++) {
D_8014C1B2 = gSynthReverbs[var_s3].useReverb;
j = 0;
for (i = 0; i < gNumSynthReverbs; i++) {
D_8014C1B2 = gSynthReverbs[i].useReverb;
if (D_8014C1B2) {
aList = func_80009D78(aList, aiBufLen, var_s3, updateIndex);
aList = func_80009D78(aList, aiBufLen, i, updateIndex);
}
while (var_s1 < var_s2) {
if (var_s3 != gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]].bitField1.reverbIndex) {
while (j < var_s2) {
if (i != gNoteSubsEu[updateIndex * gNumNotes + sp84[j]].bitField1.reverbIndex) {
break;
}
aList = func_8000A700(sp84[var_s1], &gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]],
&gNotes[sp84[var_s1]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
var_s1++;
aList = func_8000A700(sp84[j], &gNoteSubsEu[updateIndex * gNumNotes + sp84[j]],
&gNotes[sp84[j]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
j++;
}
if (gSynthReverbs[var_s3].useReverb != 0) {
aList = func_8000A128(aList, var_s3, updateIndex);
if (gSynthReverbs[i].useReverb) {
aList = func_8000A128(aList, i, updateIndex);
}
}
while (var_s1 < var_s2) {
aList = func_8000A700(sp84[var_s1], &gNoteSubsEu[updateIndex * gNumNotes + sp84[var_s1]],
&gNotes[sp84[var_s1]].synthesisState, aiBuf, aiBufLen, aList, updateIndex);
var_s1++;
while (j < var_s2) {
aList = func_8000A700(sp84[j], &gNoteSubsEu[updateIndex * gNumNotes + sp84[j]], &gNotes[sp84[j]].synthesisState,
aiBuf, aiBufLen, aList, updateIndex);
j++;
}
var_s1 = aiBufLen * 2;
aSetBuffer(aList++, 0, 0, 0x450, var_s1);
j = aiBufLen * 2;
aSetBuffer(aList++, 0, 0, 0x450, j);
aInterleave(aList++, 0, 0x990, 0xB10, 0);
aSaveBuffer(aList++, 0x450, OS_K0_TO_PHYSICAL(aiBuf), var_s1 * 2);
aSaveBuffer(aList++, 0x450, OS_K0_TO_PHYSICAL(aiBuf), j * 2);
return aList;
}
// https://decomp.me/scratch/RgX4r
#ifdef NON_MATCHING
Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synthState, s16* aiBuf, s32 aiBufLen,
Acmd* aList, s32 updateIndex) {
@@ -795,7 +816,7 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
s32 pad114;
Sample* bookSample; // sp110
AdpcmLoop* loopInfo; // sp10C
s16* currentBook; // sp108
void* currentBook; // sp108
s32 pad104;
s32 pad100;
s32 noteFinished; // spFC
@@ -872,7 +893,7 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
synthState->numParts = 0;
note->noteSubEu.bitField0.finished = 0;
}
resampleRateFixedPoint = noteSub->unk_0A;
resampleRateFixedPoint = noteSub->resampleRate;
nParts = noteSub->bitField1.hasTwoParts + 1;
sampleslenFixedPoint = (resampleRateFixedPoint * aiBufLen * 2) + synthState->samplePosFrac;
nSamplesToLoad = (sampleslenFixedPoint) >> 0x10;
@@ -911,10 +932,10 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
if ((bookSample->codec == 0) && (currentBook != bookSample->book->book)) {
switch (noteSub->bitField1.bookOffset) {
case 1:
currentBook = &D_800DD200[1];
currentBook = &gD_800DD200[1];
break;
case 2:
currentBook = &D_800DD200[2];
currentBook = &gD_800DD200[2];
break;
default:
case 3:
@@ -1111,16 +1132,16 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
aUnkCmd19(aList++, 0, aiBufLen * 2, 0x450, 0x450);
}
temp2 = noteSub->unk_02;
temp2 = noteSub->gain;
if (temp2 != 0) {
if (temp2 < 0x10) {
temp2 = 0x10;
}
aHiLoGain(aList++, temp2, (aiBufLen + 0x10) * 2, 0x450, 0);
}
if ((noteSub->unk_03 != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) {
if ((noteSub->leftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) {
delaySide = 1;
} else if ((noteSub->unk_04 != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) {
} else if ((noteSub->rightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) {
delaySide = 2;
} else {
delaySide = 0;
@@ -1138,7 +1159,7 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
return aList;
}
#else
#pragma GLOBAL_ASM("asm/us/nonmatchings/audio/audio_synthesis/func_8000A700.s")
#pragma GLOBAL_ASM("asm/us/rev1/nonmatchings/audio/audio_synthesis/func_8000A700.s")
#endif
Acmd* func_8000B3F0(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthState, s32 numSamplesToLoad) {
@@ -1179,9 +1200,10 @@ Acmd* func_8000B51C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
temp_t1 = synthState->curVolLeft;
temp_t2 = synthState->curVolRight;
temp_t7 = noteSub->unk_06;
temp_t9 = noteSub->unk_08;
temp_t7 = noteSub->panVolLeft;
temp_t9 = noteSub->panVolRight;
temp_t7 <<= 4;
temp_t9 <<= 4;
@@ -1198,15 +1220,17 @@ Acmd* func_8000B51C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
temp_a1 = synthState->reverbVol;
if (noteSub->unk_05 != temp_a1) {
temp = (((noteSub->unk_05 & 0x7F) - (temp_a1 & 0x7F)) << 8);
if (noteSub->reverb != temp_a1) {
temp = (((noteSub->reverb & 0x7F) - (temp_a1 & 0x7F)) << 8);
var_a2 = temp / (aiBufLen >> 3);
synthState->reverbVol = noteSub->unk_05;
synthState->reverbVol = noteSub->reverb;
} else {
var_a2 = 0;
}
synthState->curVolLeft = temp_t1 + (var_t0 * (aiBufLen >> 3));
synthState->curVolRight = temp_t2 + (var_a3 * (aiBufLen >> 3));
if (noteSub->bitField0.usesHeadsetPanEffects) {
aClearBuffer(aList++, 0x650, 0x180);
aEnvSetup1(aList++, (temp_a1 & 0x7F), var_a2, var_t0, var_a3);
@@ -1243,24 +1267,27 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
u8 var_v1;
u16 temp;
switch (delaySide) { /* irregular */
switch (delaySide) {
case 1:
var_t0 = 0x990;
var_a1 = noteSub->unk_03;
var_a1 = noteSub->leftDelaySize;
synthState->prevHaasEffectRightDelaySize = 0;
var_v1 = synthState->prevHaasEffectLeftDelaySize;
synthState->prevHaasEffectLeftDelaySize = var_a1;
break;
case 2:
var_t0 = 0xB10;
var_a1 = noteSub->unk_04;
var_a1 = noteSub->rightDelaySize;
synthState->prevHaasEffectLeftDelaySize = 0;
var_v1 = synthState->prevHaasEffectRightDelaySize;
synthState->prevHaasEffectRightDelaySize = var_a1;
break;
default:
return aList;
}
if (flags != 1) {
if (var_a1 != var_v1) {
temp = (((size << 0xF) / 2) - 1) / ((size + var_a1 - var_v1 - 2) / 2);
@@ -1285,6 +1312,8 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
aSaveBuffer(aList++, size + 0x650, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers->panSamplesBuffer),
ALIGN16(var_a1));
}
aAddMixer(aList++, ALIGN64(size), 0x650, var_t0, 0x7FFF);
return aList;
}
+117 -91
View File
@@ -1,99 +1,125 @@
#include "sys.h"
#include "sf64audio_external.h"
#include "sf64audio_provisional.h"
typedef struct {
/* 0x00 */ s16 numEntries;
/* 0x02 */ s16 unkMediumParam;
/* 0x04 */ u32 romAddr;
/* 0x08 */ char pad[0x8];
} AudioTableBase;
typedef struct {
/* 0x00 */ u32 romAddr;
/* 0x04 */ u32 size;
/* 0x08 */ s8 medium;
/* 0x09 */ s8 cachePolicy;
/* 0x0A */ s16 shortData1;
/* 0x0C */ s16 shortData2;
/* 0x0E */ s16 shortData3;
} AudioTableEntry; // size = 0x10
AudioTableBase gSampleBankTableInit = { 4, 0, 0 };
AudioTableEntry gSampleBankTableInitEntries[4] = {
{ 0, 0xE1E30, 2, 4, 0, 0, 0 },
{ 0xE1E30, 0xFF9D0, 2, 4, 0, 0, 0 },
{ 0x1E1800, 0x497480, 2, 4, 0, 0, 0 },
{ 0x678C80, 0xC3900, 2, 4, 0, 0, 0 },
AudioTable gSampleBankTableInit = {
{ 4, 0, 0 },
{
{ 0x000000, 0x0E1E30, MEDIUM_CART, CACHEPOLICY_4 },
{ 0x0E1E30, 0x0FF9D0, MEDIUM_CART, CACHEPOLICY_4 },
{ 0x1E1800, 0x497480, MEDIUM_CART, CACHEPOLICY_4 },
{ 0x678C80, 0x0C3900, MEDIUM_CART, CACHEPOLICY_4 },
},
};
AudioTableBase gSeqTableInit = { 66, 0, 0 };
AudioTableEntry gSeqTableInitEntries[66] = {
{ 0x00000, 0x3AF0, 2, 0, 0, 0, 0 }, { 0x03AF0, 0x56B0, 2, 0, 0, 0, 0 },
{ 0x091A0, 0x2D80, 2, 3, 0, 0, 0 }, { 0x0BF20, 0x1410, 2, 3, 0, 0, 0 },
{ 0x0D330, 0x1600, 2, 3, 0, 0, 0 }, { 0x0E930, 0xF20, 2, 3, 0, 0, 0 },
{ 0x0F850, 0x13A0, 2, 3, 0, 0, 0 }, { 0x010BF0, 0x1100, 2, 3, 0, 0, 0 },
{ 0x011CF0, 0x19E0, 2, 3, 0, 0, 0 }, { 0x0136D0, 0x13E0, 2, 3, 0, 0, 0 },
{ 0x014AB0, 0x12F0, 2, 3, 0, 0, 0 }, { SEQ_ID_SECTOR_Y, 0, 2, 3, 0, 0, 0 },
{ 0x15DA0, 0xB70, 2, 3, 0, 0, 0 }, { 0x16910, 0x2460, 2, 3, 0, 0, 0 },
{ 0x18D70, 0xD40, 2, 3, 0, 0, 0 }, { SEQ_ID_FORTUNA, 0, 2, 3, 0, 0, 0 },
{ SEQ_ID_TITANIA, 0, 2, 3, 0, 0, 0 }, { 0x19AB0, 0x7F0, 2, 3, 0, 0, 0 },
{ 0x1A2A0, 0x1440, 2, 3, 0, 0, 0 }, { 0x1B6E0, 0x1B20, 2, 3, 0, 0, 0 },
{ SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 }, { SEQ_ID_CO_BOSS_1, 0, 2, 3, 0, 0, 0 },
{ SEQ_ID_CO_BOSS_1, 0, 2, 3, 0, 0, 0 }, { SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 },
{ SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 }, { 0x1D200, 0x1B30, 2, 3, 0, 0, 0 },
{ SEQ_ID_CO_BOSS_1, 0, 2, 3, 0, 0, 0 }, { SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 },
{ 0x1ED30, 0x10B0, 2, 3, 0, 0, 0 }, { SEQ_ID_BO_BOSS, 0, 2, 3, 0, 0, 0 },
{ SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 }, { SEQ_ID_BO_BOSS, 0, 2, 3, 0, 0, 0 },
{ SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 }, { 0x1FDE0, 0x1410, 2, 3, 0, 0, 0 },
{ 0x211F0, 0xF30, 2, 3, 0, 0, 0 }, { 0x22120, 0x2B30, 2, 3, 0, 0, 0 },
{ 0x24C50, 0x7F0, 2, 3, 0, 0, 0 }, { 0x25440, 0x13B0, 2, 3, 0, 0, 0 },
{ 0x267F0, 0xC70, 2, 3, 0, 0, 0 }, { 0x27460, 0x180, 2, 3, 0, 0, 0 },
{ 0x275E0, 0x5C0, 2, 3, 0, 0, 0 }, { SEQ_ID_TITLE, 0, 2, 3, 0, 0, 0 },
{ 0x27BA0, 0x4E40, 2, 3, 0, 0, 0 }, { 0x2C9E0, 0x14E0, 2, 3, 0, 0, 0 },
{ 0x2DEC0, 0x400, 2, 3, 0, 0, 0 }, { 0x2E2C0, 0x800, 2, 3, 0, 0, 0 },
{ 0x2EAC0, 0x1AB0, 2, 3, 0, 0, 0 }, { 0x30570, 0x1AA0, 2, 3, 0, 0, 0 },
{ SEQ_ID_ME_BOSS, 0, 2, 3, 0, 0, 0 }, { 0x32010, 0x1370, 2, 3, 0, 0, 0 },
{ 0x33380, 0xB80, 2, 3, 0, 0, 0 }, { 0x33F00, 0x5C0, 2, 3, 0, 0, 0 },
{ SEQ_ID_CO_INTRO, 0, 2, 3, 0, 0, 0 }, { SEQ_ID_CO_INTRO, 0, 2, 3, 0, 0, 0 },
{ 0x344C0, 0x550, 2, 3, 0, 0, 0 }, { 0x34A10, 0x360, 2, 3, 0, 0, 0 },
{ 0x34D70, 0x620, 2, 3, 0, 0, 0 }, { SEQ_ID_VS_MENU, 0, 2, 3, 0, 0, 0 },
{ 0x35390, 0xA70, 2, 3, 0, 0, 0 }, { SEQ_ID_STAR_WOLF, 0, 2, 3, 0, 0, 0 },
{ 0x35E00, 0xAB0, 2, 3, 0, 0, 0 }, { 0x368B0, 0x13D0, 2, 3, 0, 0, 0 },
{ 0x37C80, 0x250, 2, 3, 0, 0, 0 }, { 0x37ED0, 0x6F0, 2, 3, 0, 0, 0 },
{ 0x385C0, 0xFB0, 2, 3, 0, 0, 0 }, { 0x39570, 0x1780, 2, 3, 0, 0, 0 },
AudioTable gSeqTableInit = {
{ SEQ_ID_MAX, 0, 0 },
{
{ 0x00000, 0x3AF0, MEDIUM_CART, CACHEPOLICY_0 }, { 0x03AF0, 0x56B0, MEDIUM_CART, CACHEPOLICY_0 },
{ 0x091A0, 0x2D80, MEDIUM_CART, CACHEPOLICY_3 }, { 0x0BF20, 0x1410, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x0D330, 0x1600, MEDIUM_CART, CACHEPOLICY_3 }, { 0x0E930, 0xF20, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x0F850, 0x13A0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x10BF0, 0x1100, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x11CF0, 0x19E0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x136D0, 0x13E0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x14AB0, 0x12F0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_SECTOR_Y, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x15DA0, 0xB70, MEDIUM_CART, CACHEPOLICY_3 }, { 0x16910, 0x2460, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x18D70, 0xD40, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_FORTUNA, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_TITANIA, 0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x19AB0, 0x7F0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x1A2A0, 0x1440, MEDIUM_CART, CACHEPOLICY_3 }, { 0x1B6E0, 0x1B20, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x1D200, 0x1B30, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_CO_1, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x1ED30, 0x10B0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_BO, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_BOSS_BO, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x1FDE0, 0x1410, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x211F0, 0xF30, MEDIUM_CART, CACHEPOLICY_3 }, { 0x22120, 0x2B30, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x24C50, 0x7F0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x25440, 0x13B0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x267F0, 0xC70, MEDIUM_CART, CACHEPOLICY_3 }, { 0x27460, 0x180, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x275E0, 0x5C0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_TITLE, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x27BA0, 0x4E40, MEDIUM_CART, CACHEPOLICY_3 }, { 0x2C9E0, 0x14E0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x2DEC0, 0x400, MEDIUM_CART, CACHEPOLICY_3 }, { 0x2E2C0, 0x800, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x2EAC0, 0x1AB0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x30570, 0x1AA0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_BOSS_ME, 0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x32010, 0x1370, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x33380, 0xB80, MEDIUM_CART, CACHEPOLICY_3 }, { 0x33F00, 0x5C0, MEDIUM_CART, CACHEPOLICY_3 },
{ SEQ_ID_CO_INTRO, 0, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_CO_INTRO, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x344C0, 0x550, MEDIUM_CART, CACHEPOLICY_3 }, { 0x34A10, 0x360, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x34D70, 0x620, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_VS_MENU, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x35390, 0xA70, MEDIUM_CART, CACHEPOLICY_3 }, { SEQ_ID_STAR_WOLF, 0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x35E00, 0xAB0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x368B0, 0x13D0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x37C80, 0x250, MEDIUM_CART, CACHEPOLICY_3 }, { 0x37ED0, 0x6F0, MEDIUM_CART, CACHEPOLICY_3 },
{ 0x385C0, 0xFB0, MEDIUM_CART, CACHEPOLICY_3 }, { 0x39570, 0x1780, MEDIUM_CART, CACHEPOLICY_3 },
},
};
AudioTableBase gSoundFontTableInit = { 33, 0, 0 };
AudioTableEntry gSoundFontTableInitEntries[33] = {
{ 0, 0x2F00, 2, 0, 0xFF, 0x7F00, 0 }, { 0x2F00, 0xFE0, 2, 0, 0x1FF, 0x7F00, 0 },
{ 0x3EE0, 0x640, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x4520, 0x1560, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x5A80, 0xC00, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x6680, 0xDE0, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x7460, 0x1200, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x8660, 0x1040, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x96A0, 0xE40, 2, 0, 0x2FF, 0x7F00, 0 }, { 0xA4E0, 0xC20, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0xB100, 0x1920, 2, 0, 0x2FF, 0x7F00, 0 }, { 0xCA20, 0xA20, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0xD440, 0xA00, 2, 0, 0x2FF, 0x7F00, 0 }, { 0xDE40, 0xD60, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0xEBA0, 0xC20, 2, 0, 0x2FF, 0x7F00, 0 }, { 0xF7C0, 0xF00, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x106C0, 0xF20, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x115E0, 0xE20, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x12400, 0x10A0, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x134A0, 0x2580, 2, 0, 0x2FF, 0x7F00, 0 },
{ 0x15A20, 0x9E0, 2, 0, 0x2FF, 0x7F00, 0 }, { 0x16400, 0x1220, 2, 3, 0x3FF, 0x1040, 0 },
{ 0x17620, 0x180, 2, 3, 0x3FF, 0x300, 0 }, { 0x177A0, 0x11C0, 2, 3, 0x3FF, 0x1040, 0 },
{ 0x18960, 0x940, 2, 3, 0x3FF, 0xA40, 0 }, { 0x192A0, 0x9E0, 2, 3, 0x3FF, 0xA40, 0 },
{ 0x19C80, 0x920, 2, 3, 0x3FF, 0xA40, 0 }, { 0x1A5A0, 0x9E0, 2, 3, 0x3FF, 0xA40, 0 },
{ 0x1AF80, 0x9E0, 2, 3, 0x3FF, 0xA40, 0 }, { 0x1B960, 0xA10, 2, 3, 0x3FF, 0xA40, 0 },
{ 0x1C370, 0x9E0, 2, 3, 0x3FF, 0xA40, 0 }, { 0x1CD50, 0xA00, 2, 3, 0x3FF, 0xA40, 0 },
{ 0x1D750, 0x8D0, 2, 3, 0x3FF, 0xA40, 0 },
#define SOUNDFONT_ENTRY(offset, size, medium, cachePolicy, bank1, bank2, numInst, numDrums) \
{ \
offset, size, medium, cachePolicy, (((bank1) &0xFF) << 8) | ((bank2) &0xFF), \
(((numInst) &0xFF) << 8) | ((numDrums) &0xFF) \
}
AudioTable gSoundFontTableInit = {
{ 33, 0, 0 },
{
SOUNDFONT_ENTRY(0x00000, 0x2F00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_SFX, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x02F00, 0x0FE0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_MAP, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x03EE0, 0x0640, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x04520, 0x1560, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x05A80, 0x0C00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x06680, 0x0DE0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x07460, 0x1200, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x08660, 0x1040, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x096A0, 0x0E40, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0A4E0, 0x0C20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0B100, 0x1920, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0CA20, 0x0A20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0D440, 0x0A00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0DE40, 0x0D60, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0EBA0, 0x0C20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x0F7C0, 0x0F00, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x106C0, 0x0F20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x115E0, 0x0E20, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x12400, 0x10A0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x134A0, 0x2580, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x15A20, 0x09E0, MEDIUM_CART, CACHEPOLICY_0, SAMPLES_VOICE, SAMPLES_NONE, 127, 0),
SOUNDFONT_ENTRY(0x16400, 0x1220, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 16, 64),
SOUNDFONT_ENTRY(0x17620, 0x0180, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 3, 0),
SOUNDFONT_ENTRY(0x177A0, 0x11C0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 16, 64),
SOUNDFONT_ENTRY(0x18960, 0x0940, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x192A0, 0x09E0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x19C80, 0x0920, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1A5A0, 0x09E0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1AF80, 0x09E0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1B960, 0x0A10, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1C370, 0x09E0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1CD50, 0x0A00, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
SOUNDFONT_ENTRY(0x1D750, 0x08D0, MEDIUM_CART, CACHEPOLICY_3, SAMPLES_INST, SAMPLES_NONE, 10, 64),
},
};
u8 gSeqFontTableInit[288] = {
0, 132, 0, 134, 0, 155, 0, 157, 0, 159, 0, 161, 0, 163, 0, 165, 0, 167, 0, 169, 0, 171, 0, 173,
0, 175, 0, 177, 0, 179, 0, 181, 0, 183, 0, 185, 0, 187, 0, 189, 0, 191, 0, 193, 0, 195, 0, 197,
0, 199, 0, 201, 0, 203, 0, 205, 0, 207, 0, 209, 0, 211, 0, 213, 0, 215, 0, 217, 0, 219, 0, 221,
0, 223, 0, 225, 0, 227, 0, 229, 0, 231, 0, 233, 0, 235, 0, 237, 0, 239, 0, 241, 0, 243, 0, 245,
0, 247, 0, 249, 0, 251, 0, 253, 0, 255, 1, 1, 1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13,
1, 15, 1, 17, 1, 19, 1, 21, 1, 23, 1, 25, 1, 0, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12,
11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2, 1, 24, 1, 29, 1, 25, 1, 26, 1, 28, 1, 25, 1,
25, 1, 29, 1, 24, 1, 29, 1, 28, 1, 25, 1, 30, 1, 24, 1, 25, 1, 28, 1, 28, 1, 31, 1,
31, 1, 28, 1, 28, 1, 31, 1, 31, 1, 31, 1, 28, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1,
31, 1, 32, 1, 21, 1, 21, 1, 22, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 23, 1, 25, 1,
21, 1, 21, 1, 29, 1, 25, 1, 31, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1,
21, 1, 21, 1, 27, 1, 25, 1, 21, 1, 25, 1, 25, 1, 25, 1, 21, 1, 31, 0, 0, 0, 0, 0,
#define AS_BYTES(x) (((x) >> 8) & 0xFF), ((x) &0xFF)
// clang-format off
u8 gSeqFontTableInit[283] = {
// Offset into this table for sequence sound font list
AS_BYTES(132), AS_BYTES(134), AS_BYTES(155), AS_BYTES(157), AS_BYTES(159), AS_BYTES(161), AS_BYTES(163),
AS_BYTES(165), AS_BYTES(167), AS_BYTES(169), AS_BYTES(171), AS_BYTES(173), AS_BYTES(175), AS_BYTES(177),
AS_BYTES(179), AS_BYTES(181), AS_BYTES(183), AS_BYTES(185), AS_BYTES(187), AS_BYTES(189), AS_BYTES(191),
AS_BYTES(193), AS_BYTES(195), AS_BYTES(197), AS_BYTES(199), AS_BYTES(201), AS_BYTES(203), AS_BYTES(205),
AS_BYTES(207), AS_BYTES(209), AS_BYTES(211), AS_BYTES(213), AS_BYTES(215), AS_BYTES(217), AS_BYTES(219),
AS_BYTES(221), AS_BYTES(223), AS_BYTES(225), AS_BYTES(227), AS_BYTES(229), AS_BYTES(231), AS_BYTES(233),
AS_BYTES(235), AS_BYTES(237), AS_BYTES(239), AS_BYTES(241), AS_BYTES(243), AS_BYTES(245), AS_BYTES(247),
AS_BYTES(249), AS_BYTES(251), AS_BYTES(253), AS_BYTES(255), AS_BYTES(257), AS_BYTES(259), AS_BYTES(261),
AS_BYTES(263), AS_BYTES(265), AS_BYTES(267), AS_BYTES(269), AS_BYTES(271), AS_BYTES(273), AS_BYTES(275),
AS_BYTES(277), AS_BYTES(279), AS_BYTES(281),
// sound font for SFX sequence
1, 0,
// sound fonts voice sequence
20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 2,
// sound fonts for BGM sequences. Each sequence has a single sound font.
1, 24, 1, 29, 1, 25, 1, 26, 1, 28, 1, 25, 1, 25, 1, 29, 1, 24, 1, 29, 1, 28, 1, 25, 1, 30, 1, 24, 1, 25, 1, 28,
1, 28, 1, 31, 1, 31, 1, 28, 1, 28, 1, 31, 1, 31, 1, 31, 1, 28, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32,
1, 21, 1, 21, 1, 22, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 23, 1, 25, 1, 21, 1, 21, 1, 29, 1, 25, 1, 31, 1, 21,
1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 27, 1, 25, 1, 21, 1, 25, 1, 25, 1, 25, 1, 21, 1, 31
};
// clang-format on
+74 -69
View File
@@ -8,19 +8,19 @@ void AudioThread_SetFadeInTimer(s32 seqPlayId, s32 fadeTime);
OSMesgQueue sAudioTaskStartQueue;
OSMesgQueue sThreadCmdProcQueue;
OSMesgQueue sAudioUnkQueue;
OSMesgQueue sAudioSpecQueue;
OSMesgQueue sAudioResetQueue;
AudioCmd gThreadCmdBuffer[256];
OSMesg sAudioTaskStartMsg[1];
OSMesg sThreadCmdProcMsg[4];
OSMesg sAudioUnkMsg[1];
OSMesg sAudioSpecMsg[1];
OSMesg sAudioResetMsg[1];
u8 gThreadCmdWritePos = 0;
u8 gThreadCmdReadPos = 0;
OSMesgQueue* gAudioTaskStartQueue = &sAudioTaskStartQueue;
OSMesgQueue* gThreadCmdProcQueue = &sThreadCmdProcQueue;
OSMesgQueue* gAudioUnkQueue = &sAudioUnkQueue;
OSMesgQueue* gAudioSpecQueue = &sAudioSpecQueue;
OSMesgQueue* gAudioResetQueue = &sAudioResetQueue;
static const char devstr0[] = "DAC:Lost 1 Frame.\n";
@@ -42,74 +42,81 @@ static const char devstr14[] = "Error : Queue is not empty ( %x ) \n";
SPTask* AudioThread_CreateTask(void) {
static s32 gMaxAbiCmdCnt = 128;
static SPTask* gWaitingAudioTask = NULL;
u32 sp54;
s32 sp50;
s32 sp4C;
u32 aiSamplesLeft;
s32 abiCmdCount;
s32 aiBuffIndex;
s32 pad48;
OSTask_t* task;
u16* sp40;
u16* aiBuffer;
s32 pad3C;
OSMesg sp38;
OSMesg sp34;
u32 specId;
u32 msg;
s32 pad30;
gAudioTaskCountQ++;
if ((gAudioTaskCountQ % gAudioBufferParams.specUnk4) != 0) {
if ((gAudioTaskCountQ % gAudioBufferParams.count) != 0) {
return gWaitingAudioTask;
}
osSendMesg(gAudioTaskStartQueue, OS_MESG_32(gAudioTaskCountQ), 0);
osSendMesg(gAudioTaskStartQueue, OS_MESG_32(gAudioTaskCountQ), OS_MESG_NOBLOCK);
gAudioTaskIndexQ ^= 1;
gCurAiBuffIndex++;
gCurAiBuffIndex %= 3;
sp4C = (gCurAiBuffIndex + 1) % 3;
sp54 = osAiGetLength() >> 2;
if ((gResetTimer < 16) && (gAiBuffLengths[sp4C] != 0)) {
osAiSetNextBuffer(gAiBuffers[sp4C], gAiBuffLengths[sp4C] * 4);
aiBuffIndex = (gCurAiBuffIndex + 1) % 3;
aiSamplesLeft = osAiGetLength() / 4;
if ((gAudioResetTimer < 16) && (gAiBuffLengths[aiBuffIndex] != 0)) {
osAiSetNextBuffer(gAiBuffers[aiBuffIndex], gAiBuffLengths[aiBuffIndex] * 4);
}
if (gCurAudioFrameDmaCount && gCurAudioFrameDmaCount) {}
if (gCurAudioFrameDmaCount && gCurAudioFrameDmaCount) {} //! FAKE ?
gCurAudioFrameDmaCount = 0;
AudioLoad_DecreaseSampleDmaTtls();
AudioLoad_ProcessLoads(gResetStatus);
if (osRecvMesg(gAudioUnkQueue, &sp38, 0) != -1) {
if (gResetStatus == 0) {
gResetStatus = 5;
AudioLoad_ProcessLoads(gAudioResetStep);
if (MQ_GET_MESG(gAudioSpecQueue, &specId)) {
if (gAudioResetStep == 0) {
gAudioResetStep = 5;
}
gAudioSpecId = sp38.data32;
gAudioSpecId = specId;
}
if ((gResetStatus != 0) && (AudioHeap_ResetStep() == 0)) {
if (gResetStatus == 0) {
osSendMesg(gAudioResetQueue, OS_MESG_32((s32) gAudioSpecId), 0);
if ((gAudioResetStep != 0) && (AudioHeap_ResetStep() == 0)) {
if (gAudioResetStep == 0) {
osSendMesg(gAudioResetQueue, OS_MESG_32((s32) gAudioSpecId), OS_MESG_NOBLOCK);
}
gWaitingAudioTask = NULL;
return NULL;
}
if (gResetTimer > 16) {
if (gAudioResetTimer > 16) {
return NULL;
}
if (gResetTimer != 0) {
gResetTimer++;
if (gAudioResetTimer != 0) {
gAudioResetTimer++;
}
gAudioCurTask = &gAudioRspTasks[gAudioTaskIndexQ];
gCurAbiCmdBuffer = gAbiCmdBuffs[gAudioTaskIndexQ];
sp4C = gCurAiBuffIndex;
sp40 = gAiBuffers[sp4C];
gAiBuffLengths[sp4C] = ((gAudioBufferParams.samplesPerFrameTarget - sp54 + 0x80) & ~0xF) + 0x10;
aiBuffIndex = gCurAiBuffIndex;
aiBuffer = gAiBuffers[aiBuffIndex];
gAiBuffLengths[aiBuffIndex] = ALIGN16_ALT(gAudioBufferParams.samplesPerFrameTarget - aiSamplesLeft + 0x80);
if (gAiBuffLengths[sp4C] < gAudioBufferParams.minAiBufferLength) {
gAiBuffLengths[sp4C] = gAudioBufferParams.minAiBufferLength;
if (gAiBuffLengths[aiBuffIndex] < gAudioBufferParams.minAiBufferLength) {
gAiBuffLengths[aiBuffIndex] = gAudioBufferParams.minAiBufferLength;
}
if (gAiBuffLengths[sp4C] > gAudioBufferParams.maxAiBufferLength) {
gAiBuffLengths[sp4C] = gAudioBufferParams.maxAiBufferLength;
if (gAiBuffLengths[aiBuffIndex] > gAudioBufferParams.maxAiBufferLength) {
gAiBuffLengths[aiBuffIndex] = gAudioBufferParams.maxAiBufferLength;
}
while (osRecvMesg(gThreadCmdProcQueue, &sp34, 0) != -1) {
AudioThread_ProcessCmds(sp34.data32);
while (MQ_GET_MESG(gThreadCmdProcQueue, &msg)) {
AudioThread_ProcessCmds(msg);
}
gCurAbiCmdBuffer = func_80009B64(gCurAbiCmdBuffer, &sp50, sp40, gAiBuffLengths[sp4C]);
gCurAbiCmdBuffer = func_80009B64(gCurAbiCmdBuffer, &abiCmdCount, aiBuffer, gAiBuffLengths[aiBuffIndex]);
gAudioRandom = osGetCount() * (gAudioRandom + gAudioTaskCountQ);
gAudioRandom = gAiBuffers[sp4C][gAudioTaskCountQ & 0xFF] + gAudioRandom;
gAudioRandom = gAiBuffers[aiBuffIndex][gAudioTaskCountQ & 0xFF] + gAudioRandom;
sp4C = gAudioTaskIndexQ;
aiBuffIndex = gAudioTaskIndexQ;
gAudioCurTask->msgQueue = NULL;
gAudioCurTask->msg = OS_MESG_PTR(NULL);
@@ -132,17 +139,17 @@ SPTask* AudioThread_CreateTask(void) {
task->output_buff = NULL;
task->output_buff_size = NULL;
if (1) {}
task->data_ptr = (u64*) gAbiCmdBuffs[sp4C];
task->data_size = sp50 * sizeof(Acmd);
task->data_ptr = (u64*) gAbiCmdBuffs[aiBuffIndex];
task->data_size = abiCmdCount * sizeof(Acmd);
task->yield_data_ptr = NULL;
task->yield_data_size = 0;
if (gMaxAbiCmdCnt < sp50) {
gMaxAbiCmdCnt = sp50;
if (gMaxAbiCmdCnt < abiCmdCount) {
gMaxAbiCmdCnt = abiCmdCount;
}
if (gAudioBufferParams.specUnk4 == 1) {
if (gAudioBufferParams.count == 1) {
return gAudioCurTask;
} else {
gWaitingAudioTask = gAudioCurTask;
@@ -158,7 +165,7 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
AudioLoad_SyncLoadSeqParts(cmd->arg1, 3);
break;
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER:
case 0x88:
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_ALT:
AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
AudioThread_SetFadeInTimer(cmd->arg0, cmd->data);
break;
@@ -171,13 +178,13 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
}
}
break;
case 0x84:
case AUDIOCMD_OP_GLOBAL_UNK_84:
break;
case AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE:
gAudioSoundMode = cmd->asUInt;
break;
case AUDIOCMD_OP_GLOBAL_MUTE:
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
SequencePlayer* seqplayer = &gSeqPlayers[i];
seqplayer->muted = true;
@@ -197,7 +204,7 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
}
}
}
for (i = 0; i < 4; i++) {
for (i = 0; i < ARRAY_COUNT(gSeqPlayers); i++) {
SequencePlayer* seqplayer = &gSeqPlayers[i];
seqplayer->muted = false;
@@ -244,7 +251,7 @@ void AudioThread_InitQueues(void) {
gThreadCmdReadPos = 0;
osCreateMesgQueue(gAudioTaskStartQueue, sAudioTaskStartMsg, 1);
osCreateMesgQueue(gThreadCmdProcQueue, sThreadCmdProcMsg, 4);
osCreateMesgQueue(gAudioUnkQueue, sAudioUnkMsg, 1);
osCreateMesgQueue(gAudioSpecQueue, sAudioSpecMsg, 1);
osCreateMesgQueue(gAudioResetQueue, sAudioResetMsg, 1);
}
@@ -282,7 +289,7 @@ void AudioThread_ScheduleProcessCmds(void) {
D_800C7C70 = (u8) (gThreadCmdWritePos - gThreadCmdReadPos + 0x100);
}
msg = (((gThreadCmdReadPos & 0xFF) << 8) | (gThreadCmdWritePos & 0xFF));
osSendMesg(gThreadCmdProcQueue, OS_MESG_32(msg), 0);
osSendMesg(gThreadCmdProcQueue, OS_MESG_32(msg), OS_MESG_NOBLOCK);
gThreadCmdReadPos = gThreadCmdWritePos;
}
@@ -315,7 +322,7 @@ void AudioThread_ProcessCmds(u32 msg) {
}
if ((cmd->op & 0xF0) == 0xF0) {
AudioThread_ProcessGlobalCmd(cmd);
} else if (cmd->arg0 < 4) {
} else if (cmd->arg0 < ARRAY_COUNT(gSeqPlayers)) {
player = &gSeqPlayers[cmd->arg0];
if (cmd->op & 0x80) {
AudioThread_ProcessGlobalCmd(cmd);
@@ -327,10 +334,10 @@ void AudioThread_ProcessCmds(u32 msg) {
player->recalculateVolume = true;
}
break;
case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO: /* switch 1 */
case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO:
player->tempo = cmd->asInt * 48;
break;
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION: /* switch 1 */
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION:
player->transposition = cmd->asSbyte;
break;
case 0x46: // AUDIOCMD_OP_SEQPLAYER_SET_IO?
@@ -387,46 +394,44 @@ void AudioThread_ProcessCmds(u32 msg) {
}
u32 AudioThread_GetAsyncLoadStatus(u32* outData) {
u32 sp1C;
u32 loadStatus;
if (osRecvMesg(&gExternalLoadQueue, (OSMesg*) &sp1C, 0) == -1) {
if (!MQ_GET_MESG(&gExternalLoadQueue, &loadStatus)) {
*outData = 0;
return 0;
}
*outData = sp1C & 0xFFFFFF;
return sp1C >> 0x18;
*outData = loadStatus & 0xFFFFFF;
return loadStatus >> 0x18;
}
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
return AudioLoad_GetFontsForSequence(seqId, outNumFonts);
}
s32 func_8001ED34(void) {
bool AudioThread_ResetComplete(void) {
s32 pad;
s32 sp18;
if (osRecvMesg(gAudioResetQueue, (OSMesg*) &sp18, 0) == -1) {
return 0;
if (!MQ_GET_MESG(gAudioResetQueue, &sp18)) {
return false;
}
if (sp18 != gAudioSpecId) {
return 0;
return false;
}
return 1;
return true;
}
void AudioThread_ResetAudioHeap(s32 specId) {
// clang-format off
s32 m1 = -1;OSMesg sp28;do {} while (osRecvMesg(gAudioResetQueue, &sp28, 0) != m1);
// clang-format on
MQ_CLEAR_QUEUE(gAudioResetQueue);
AudioThread_ResetCmdQueue();
osSendMesg(gAudioUnkQueue, OS_MESG_32(specId), 0);
osSendMesg(gAudioSpecQueue, OS_MESG_32(specId), OS_MESG_NOBLOCK);
}
void AudioThread_PreNMIReset(void) {
gResetTimer = 1;
AudioThread_ResetAudioHeap(0);
gResetStatus = 0;
gAudioResetTimer = 1;
AudioThread_ResetAudioHeap(AUDIOSPEC_CO);
gAudioResetStep = 0;
}
void AudioThread_Init(void) {
+1 -1
View File
@@ -280,7 +280,7 @@ u16 gHaasEffectDelaySizes[64] = {
};
// clang-format off
s16 D_800DD200[] = {
ALIGNED(8) s16 gD_800DD200[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
+7 -6
View File
@@ -1,7 +1,7 @@
#include "sys.h"
// clang-format off
s16 gSawtoothWaveSample[] = {
ALIGNED(16) s16 gSawtoothWaveSample[] = {
// Frequency of 1
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167,
8191, 9215, 10239, 11263, 12287, 13311, 14335, 15359,
@@ -43,7 +43,7 @@ s16 gSawtoothWaveSample[] = {
0, 8191, 16383, 24575, -32767, -24575, -16383, -8191,
};
s16 gTriangleWaveSample[] = {
ALIGNED(16) s16 gTriangleWaveSample[] = {
// Frequency of 1
0, 2047, 4095, 6143, 8191, 10239, 12287, 14335,
16383, 18431, 20479, 22527, 24575, 26623, 28671, 30719,
@@ -85,7 +85,7 @@ s16 gTriangleWaveSample[] = {
0, 16383, 32767, 16383, 0, -16383, -32767, -16383,
};
s16 gSineWaveSample[] = {
ALIGNED(16) s16 gSineWaveSample[] = {
// Frequency of 1
0, 3211, 6392, 9511, 12539, 15446, 18204, 20787,
23169, 25329, 27244, 28897, 30272, 31356, 32137, 32609,
@@ -127,7 +127,7 @@ s16 gSineWaveSample[] = {
0, 23169, 32767, 23169, 0, -23169, -32767, -23169,
};
s16 gSquareWaveSample[] = {
ALIGNED(16) s16 gSquareWaveSample[] = {
// Frequency of 1
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -169,7 +169,7 @@ s16 gSquareWaveSample[] = {
0, 0, 32767, 32767, 0, 0, -32767, -32767,
};
s16 gWhiteNoiseSample[] = {
ALIGNED(16) s16 gWhiteNoiseSample[] = {
// Frequency of 1
0, -25689, -25791, 27803, -27568, -21030, 22174, 6298,
27071, -18531, 28649, 2284, 3380, 6890, -12682, -21114,
@@ -212,7 +212,7 @@ s16 gWhiteNoiseSample[] = {
};
// Sine White Noise?
s16 gUnkSample[] = {
ALIGNED(16) s16 gUnkSample[] = {
// Frequency of 1
0, 16316, 20148, 20257, 27209, -32657, 29264, 27259,
-29394, -21494, -26410, 30770, 30033, 29130, 20206, 14129,
@@ -255,6 +255,7 @@ s16 gUnkSample[] = {
};
// clang-format on
ALIGNED(16)
s16* gWaveSamples[] = {
gSawtoothWaveSample, gTriangleWaveSample, gSineWaveSample, gSquareWaveSample, gWhiteNoiseSample, gUnkSample,
};