More audio stuff (#488)

* Match create_next_audio_frame_task

Required some variable renaming and other changes

* Match synthesis_execute

I'm not entirly sure about the way we have stuff ifdef'd in
 PR/abi.h. I feel like we're doing something slightly wrong there


* Match synthesis_do_one_audio_update

There's something super fucked with the way our ifdef's work in
 abi.h. It is going to demand a lot more attention sometime in the
 future.

* Rename a couple functions

Also had to hack up the ABI file a bit. I'm convinced that we
 don't need nor want to have the EU/Shindou/US split thing the
 SM64 code does. There's probably just the 1 ABI version being
 used and we need to figure out what it looks like

Signed-off-by: Taggerung <tyler.taggerung@email.com>
This commit is contained in:
Tyler McGavran
2023-11-07 22:38:25 -05:00
committed by GitHub
parent f75460cb8b
commit cbe41239d7
18 changed files with 217 additions and 1178 deletions
+4 -3
View File
@@ -49,8 +49,9 @@ s32 gMaxAudioCmds;
s32 gMaxSimultaneousNotes;
s16 gTempoInternalToExternal;
s8 gAudioLibSoundMode;
s32 gAudioUpdatesPerFrame;
s32 gCurrAudioFrameDmaCount; // file split around here?
// If we take SM64 as gospel, these should be in data.c, but that doesn't match
volatile s32 gAudioFrameCount;
s32 gCurrAudioFrameDmaCount;
/**
@@ -811,7 +812,7 @@ void audio_init() {
gAiBufferLengths[i] = 0xa0;
}
gAudioTaskIndex = gAudioUpdatesPerFrame = 0;
gAudioTaskIndex = gAudioFrameCount = 0;
gCurrAiBufferIndex = 0;
gAudioLibSoundMode = 0;
gAudioTask = NULL;
+1 -1
View File
@@ -81,7 +81,7 @@ extern s32 gMaxAudioCmds;
extern s32 gMaxSimultaneousNotes;
extern s16 gTempoInternalToExternal;
extern s8 gAudioLibSoundMode;
extern s32 gAudioUpdatesPerFrame;
extern volatile s32 gAudioFrameCount;
extern s32 gCurrAudioFrameDmaCount;
#endif // AUDIO_LOAD_H
+79 -97
View File
@@ -1,9 +1,13 @@
#include <ultra64.h>
#include <macros.h>
#include <PR/ucode.h>
#include "audio/synthesis.h"
#include "audio/seqplayer.h"
#include "audio/port_eu.h"
#include "audio/load.h"
#include "audio/heap.h"
#include "audio/data.h"
OSMesgQueue D_801937C0;
OSMesgQueue D_801937D8;
@@ -42,75 +46,48 @@ s32 D_800EA4A4 = 0;
char port_eu_unused_string7[] = "Undefined Port Command %d\n";
#ifdef MIPS_TO_C
//generated by m2c commit 08138748803d75e73e4a94bb0c619a273754ee9c on Sep-14-2023
u64 *func_800B70EC(u64 *, s32 *, s16 *, s16); /* extern */
extern ? aspMainDataEnd;
extern u64 aspMainDataStart;
extern u64 aspMainTextStart;
struct SPTask *create_next_audio_frame_task(void) {
u32 sp74;
s32 sp70;
s16 *sp60;
void *sp58;
void *sp54;
s16 **sp40;
s16 **temp_a3;
s16 *temp_s1_2;
s16 temp_v1;
s32 temp_hi;
s32 temp_hi_2;
s32 temp_s1;
s32 temp_t3;
u32 samplesRemainingInAI;
s32 writtenCmds;
s32 index;
OSTask_t *task;
s32 var_s0;
s32 var_s0_2;
s32 var_s0_3;
s32 var_s1;
s16 *currAiBuffer;
s32 oldDmaCount;
OSMesg sp58;
OSMesg sp54;
s32 writtenCmdsCopy;
gAudioUpdatesPerFrame += 1;
if (((s32) gAudioUpdatesPerFrame % (s16) gAudioBufferParameters.presetUnk4) != 0) {
gAudioFrameCount++;
if ((gAudioFrameCount % gAudioBufferParameters.presetUnk4) != 0) {
return NULL;
}
osSendMesg(D_800EA3A8, (void *) gAudioUpdatesPerFrame, 0);
temp_t3 = gCurrAiBufferIndex + 1;
temp_hi = temp_t3 % 3;
temp_hi_2 = (s32) (temp_hi + 1) % 3;
gCurrAiBufferIndex = temp_t3;
osSendMesg(D_800EA3A8, (OSMesg) gAudioFrameCount, 0);
gAudioTaskIndex ^= 1;
gCurrAiBufferIndex = temp_hi;
sp74 = osAiGetLength() >> 2;
temp_v1 = gAiBufferLengths[temp_hi_2];
if (temp_v1 != 0) {
osAiSetNextBuffer(gAiBuffers[temp_hi_2], temp_v1 * 4);
gCurrAiBufferIndex++;
gCurrAiBufferIndex %= NUMAIBUFFERS;
index = (gCurrAiBufferIndex + 1) % NUMAIBUFFERS;
samplesRemainingInAI = osAiGetLength() / 4;
if (gAiBufferLengths[index] != 0) {
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
}
var_s1 = gCurrAudioFrameDmaCount;
var_s0 = 0;
if (var_s1 > 0) {
do {
if (osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0) == 0) {
var_s1 -= 1;
}
var_s0 += 1;
} while (var_s0 < gCurrAudioFrameDmaCount);
}
if (var_s1 != 0) {
var_s0_2 = 0;
if (var_s1 > 0) {
do {
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 1);
var_s0_2 += 1;
} while (var_s0_2 != var_s1);
oldDmaCount = gCurrAudioFrameDmaCount;
for (var_s0 = 0; var_s0 < gCurrAudioFrameDmaCount; var_s0++) {
if (osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0) == 0) {
oldDmaCount -= 1;
}
}
temp_s1 = gCurrAudioFrameDmaQueue.validCount;
if (temp_s1 != 0) {
var_s0_3 = 0;
if (temp_s1 > 0) {
do {
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0);
var_s0_3 += 1;
} while (var_s0_3 != temp_s1);
if (oldDmaCount != 0) {
for (var_s0 = 0; var_s0 < oldDmaCount; var_s0++) {
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 1);
}
}
oldDmaCount = gCurrAudioFrameDmaQueue.validCount;
if (oldDmaCount != 0) {
for (var_s0 = 0; var_s0 < oldDmaCount; var_s0++) {
osRecvMesg(&gCurrAudioFrameDmaQueue, NULL, 0);
}
}
gCurrAudioFrameDmaCount = 0;
@@ -119,57 +96,62 @@ struct SPTask *create_next_audio_frame_task(void) {
gAudioResetPresetIdToLoad = (u8) sp58;
gAudioResetStatus = 5;
}
if ((gAudioResetStatus != 0) && (audio_shut_down_and_reset_step() == 0)) {
if (gAudioResetStatus == 0) {
osSendMesg(D_800EA3B4, (void *) gAudioResetPresetIdToLoad, 0);
if (gAudioResetStatus != 0) {
if (audio_shut_down_and_reset_step() == 0) {
if (gAudioResetStatus == 0) {
osSendMesg(D_800EA3B4, (OSMesg) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
}
return NULL;
}
return NULL;
}
gAudioTask = &gAudioTasks[gAudioTaskIndex];
temp_a3 = &gAiBuffers[gCurrAiBufferIndex];
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
sp60 = *temp_a3;
temp_s1_2 = &gAiBufferLengths[gCurrAiBufferIndex];
*temp_s1_2 = (((gAudioBufferParameters.samplesPerFrameTarget - sp74) + 0x40) & 0xFFF0) + 0x10;
if (*temp_s1_2 < gAudioBufferParameters.minAiBufferLength) {
*temp_s1_2 = gAudioBufferParameters.minAiBufferLength;
index = gCurrAiBufferIndex;
currAiBuffer = gAiBuffers[index];
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI + EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xF) + SAMPLES_TO_OVERPRODUCE;
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
}
if (gAudioBufferParameters.maxAiBufferLength < *temp_s1_2) {
*temp_s1_2 = gAudioBufferParameters.maxAiBufferLength;
if (gAudioBufferParameters.maxAiBufferLength < gAiBufferLengths[index]) {
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
}
sp40 = temp_a3;
if (osRecvMesg(D_800EA3AC, &sp54, 0) != -1) {
func_800CBCB0((u32) sp54);
}
gAudioCmd = func_800B70EC(gAudioCmd, &sp70, sp60, *temp_s1_2);
gAudioRandom = osGetCount() * (gAudioRandom + gAudioUpdatesPerFrame);
gAudioRandom += (*sp40)[gAudioUpdatesPerFrame & 0xFF];
gAudioCmd = synthesis_execute((Acmd *) gAudioCmd, &writtenCmds, currAiBuffer, gAiBufferLengths[index]);
gAudioRandom = osGetCount() * (gAudioRandom + gAudioFrameCount);
gAudioRandom = gAudioRandom + gAiBuffers[index][gAudioFrameCount & 0xFF];
index = gAudioTaskIndex;
gAudioTask->msgqueue = NULL;
// wtf?
writtenCmdsCopy += 0;
gAudioTask->msg = NULL;
gAudioTask->task.t.type = 2;
gAudioTask->task.t.flags = 0;
gAudioTask->task.t.ucode_boot = rspbootTextStart;
gAudioTask->task.t.ucode_boot_size = rspbootTextEnd - rspbootTextStart;
gAudioTask->task.t.ucode = &aspMainTextStart;
gAudioTask->task.t.ucode_data = &aspMainDataStart;
gAudioTask->task.t.ucode_size = 0x00001000;
gAudioTask->task.t.ucode_data_size = ((s32) (&aspMainDataEnd - &aspMainDataStart) >> 3) * 8;
gAudioTask->task.t.dram_stack = NULL;
gAudioTask->task.t.dram_stack_size = 0;
gAudioTask->task.t.output_buff = NULL;
gAudioTask->task.t.output_buff_size = NULL;
gAudioTask->task.t.data_ptr = gAudioCmdBuffers[gAudioTaskIndex];
gAudioTask->task.t.yield_data_ptr = NULL;
gAudioTask->task.t.yield_data_size = 0;
gAudioTask->task.t.data_size = sp70 * 8;
if (D_800EA484 < sp70) {
D_800EA484 = sp70;
task = &gAudioTask->task.t;
task->type = M_AUDTASK;
task->flags = 0;
task->ucode_boot = rspF3DBootStart;
task->ucode_boot_size = (u8*) rspF3DBootEnd - (u8*) rspF3DBootStart;
task->ucode = rspAspMainStart;
task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x00001000;
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
task->dram_stack = NULL;
task->dram_stack_size = 0;
task->output_buff = NULL;
task->output_buff_size = NULL;
task->data_ptr = gAudioCmdBuffers[index];
task->data_size = writtenCmds * sizeof(u64);
task->yield_data_ptr = NULL;
task->yield_data_size = 0;
writtenCmdsCopy = writtenCmds;
if (D_800EA484 < writtenCmds) {
D_800EA484 = writtenCmdsCopy;
}
return gAudioTask;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/port_eu/create_next_audio_frame_task.s")
#endif
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
s32 i;
+3
View File
@@ -3,6 +3,9 @@
#include "audio/internal.h"
#define SAMPLES_TO_OVERPRODUCE 0x10
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x40
void eu_process_audio_cmd(struct EuAudioCmd*);
void seq_player_fade_to_zero_volume(s32 arg0, s32 fadeOutTime);
void func_800CBA64(s32 playerIndex, s32 fadeInTime);
+1
View File
@@ -37,6 +37,7 @@ void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume);
void seq_channel_layer_process_script(struct SequenceChannelLayer *layer);
void sequence_player_process_sequence(struct SequencePlayer*);
void sequence_channel_process_script(struct SequenceChannel*);
void process_sequences(s32);
void init_sequence_player(u32 player);
void init_sequence_players(void);
+100 -230
View File
@@ -2,7 +2,7 @@
#include <macros.h>
#include "audio/synthesis.h"
#include "audio/heap.h"
//#include "audio/data.h"
#include "audio/data.h"
#include "audio/load.h"
//#include "audio/seqplayer.h"
#include "audio/internal.h"
@@ -28,8 +28,6 @@ struct VolumeChange {
u16 targetRight;
};
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex);
u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, u64 *cmd);
u64 *process_envelope(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
struct SynthesisReverb gSynthesisReverbs[4];
@@ -153,94 +151,49 @@ void synthesis_load_note_subs_eu(s32 updateIndex) {
}
}
#ifdef MIPS_TO_C
//generated by m2c commit eefca95b040d7ee0c617bc58f9ac6cd1cf7bce87 on Aug-14-2023
Acmd *func_800B775C(s16 *, s32, Acmd *, s32); /* extern */
? process_sequences(s16); /* extern */
Acmd *synthesis_execute(Acmd *acmd, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
s32 i, j;
u32 *aiBufPtr;
Acmd *cmd = acmd;
s32 chunkLen;
void *func_800B70EC(Acmd *acmd, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
Acmd *temp_v0;
Acmd *var_fp;
s16 *var_s7;
s16 temp_s0;
s16 temp_s2;
s16 var_s4;
s16 var_s4_2;
s32 temp_lo;
s32 var_s1;
s32 var_s3;
s32 var_s6;
struct SynthesisReverb *var_s0;
struct SynthesisReverb *var_s0_2;
u8 temp_t4;
u8 temp_v0_2;
var_s4 = gAudioBufferParameters.updatesPerFrame;
var_s6 = bufLen;
if (var_s4 > 0) {
do {
temp_s0 = var_s4 - 1;
process_sequences(temp_s0);
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - var_s4);
var_s4 = temp_s0;
} while (temp_s0 > 0);
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
process_sequences(i - 1);
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i);
}
var_s7 = aiBuf;
acmd->words.w0 = 0x07000000;
acmd->words.w1 = 0;
var_s4_2 = gAudioBufferParameters.updatesPerFrame;
var_fp = acmd + 8;
if (var_s4_2 > 0) {
do {
temp_s2 = gAudioBufferParameters.updatesPerFrame;
var_s1 = 0;
if (var_s4_2 == 1) {
var_s3 = var_s6;
aSegment(cmd++, 0, 0);
aiBufPtr = aiBuf;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
if (i == 1) {
chunkLen = bufLen;
} else {
if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax) {
chunkLen = gAudioBufferParameters.samplesPerUpdateMax;
} else if (bufLen / i <= gAudioBufferParameters.samplesPerUpdateMin) {
chunkLen = gAudioBufferParameters.samplesPerUpdateMin;
} else {
temp_lo = var_s6 / var_s4_2;
if (temp_lo >= gAudioBufferParameters.samplesPerUpdateMax) {
var_s3 = (s32) gAudioBufferParameters.samplesPerUpdateMax;
} else if (gAudioBufferParameters.samplesPerUpdateMin >= temp_lo) {
var_s3 = (s32) gAudioBufferParameters.samplesPerUpdateMin;
} else {
var_s3 = (s32) gAudioBufferParameters.samplesPerUpdate;
}
chunkLen = gAudioBufferParameters.samplesPerUpdate;
}
if (gNumSynthesisReverbs > 0) {
var_s0 = gSynthesisReverbs;
do {
if (var_s0->useReverb != 0) {
prepare_reverb_ring_buffer(var_s3, temp_s2 - var_s4_2, var_s1);
}
var_s1 += 1;
var_s0 += 0x108;
} while (var_s1 < gNumSynthesisReverbs);
}
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].useReverb != 0) {
prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j);
}
temp_v0 = func_800B775C(var_s7, var_s3, var_fp, temp_s2 - var_s4_2);
var_s4_2 -= 1;
var_fp = temp_v0;
var_s6 -= var_s3;
var_s7 += var_s3 * 4;
} while (var_s4_2 > 0);
}
cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
bufLen -= chunkLen;
aiBufPtr += chunkLen;
}
var_s0_2 = gSynthesisReverbs;
if (gNumSynthesisReverbs > 0) {
do {
temp_v0_2 = var_s0_2->framesLeftToIgnore;
if (temp_v0_2 != 0) {
var_s0_2->framesLeftToIgnore = temp_v0_2 - 1;
}
temp_t4 = var_s0_2->curFrame;
var_s0_2 += 0x108;
var_s0_2->unk-105 = (s8) (temp_t4 ^ 1);
} while ((u32) var_s0_2 < (u32) &gSynthesisReverbs[gNumSynthesisReverbs]);
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].framesLeftToIgnore != 0) {
gSynthesisReverbs[j].framesLeftToIgnore--;
}
gSynthesisReverbs[j].curFrame ^= 1;
}
*writtenCmds = (s32) (var_fp - acmd) >> 3;
return var_fp;
*writtenCmds = cmd - acmd;
return cmd;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/synthesis/func_800B70EC.s")
#endif
Acmd *synthesis_resample_and_mix_reverb(Acmd *acmd, s32 bufLen, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
@@ -277,7 +230,7 @@ Acmd *synthesis_resample_and_mix_reverb(Acmd *acmd, s32 bufLen, s16 reverbIndex,
return acmd;
}
Acmd *synthesis_load_reverb_samples(Acmd *acmd, s16 reverbIndex, s16 updateIndex) {
Acmd *synthesis_save_reverb_samples(Acmd *acmd, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
@@ -298,165 +251,82 @@ Acmd *synthesis_load_reverb_samples(Acmd *acmd, s16 reverbIndex, s16 updateIndex
return acmd;
}
#ifdef MIPS_TO_C
//generated by m2c commit eefca95b040d7ee0c617bc58f9ac6cd1cf7bce87 on Aug-14-2023
Acmd *func_800B7C30(u8, struct NoteSubEu *, struct NoteSynthesisState *, s16 *, s32, Acmd *, s32); /* extern */
extern u8 gUseReverb;
Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 updateIndex) {
struct NoteSubEu *noteSubEu;
u8 noteIndices[56];
s32 temp;
s32 i;
s16 j;
s16 notePos = 0;
Acmd *func_800B775C(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 updateIndex) {
? sp84;
struct SynthesisReverb *sp64;
Acmd *temp_s4;
Acmd *temp_s4_2;
Acmd *var_s4;
s16 var_s2;
s16 var_s3;
s32 temp_lo;
s32 temp_lo_2;
s32 temp_t3_2;
s32 var_v1;
s32 var_v1_2;
s8 *temp_t4;
s8 *temp_t5;
s8 *temp_t8;
s8 var_s1;
s8 var_s1_2;
struct NoteSubEu *temp_v0;
struct NoteSubEu *temp_v0_2;
struct NoteSubEu *var_v0;
struct SynthesisReverb *temp_t9;
u8 *var_s0;
u8 *var_s0_2;
u8 temp_a1;
u8 temp_t3;
u8 temp_v1;
u8 temp_v1_2;
var_s2 = 0;
if (gNumSynthesisReverbs == 0) {
var_s1 = 0;
if (gMaxSimultaneousNotes > 0) {
var_v0 = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex];
do {
temp_t4 = &sp84 + var_s2;
if (((u32) *var_v0 >> 0x1F) != 0) {
var_s2 += 1;
*temp_t4 = var_s1;
}
var_s1 += 1;
var_v0 += 0x10;
} while (var_s1 < gMaxSimultaneousNotes);
var_s1 = 0;
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i].enabled) {
noteIndices[notePos++] = i;
}
}
var_s3 = 0;
} else {
var_s3 = 0;
if (gNumSynthesisReverbs > 0) {
do {
var_s1_2 = 0;
if (gMaxSimultaneousNotes > 0) {
var_v1 = gMaxSimultaneousNotes * updateIndex;
do {
temp_v0 = &gNoteSubsEu[var_v1];
if (((u32) temp_v0->unk0 >> 0x1F) != 0) {
temp_t5 = &sp84 + var_s2;
if (var_s3 == ((u8) temp_v0->unk1 >> 5)) {
var_s2 += 1;
*temp_t5 = var_s1_2;
}
}
var_s1_2 += 1;
var_v1 += 1;
} while (var_s1_2 < gMaxSimultaneousNotes);
for (j = 0; j < gNumSynthesisReverbs; j++) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && j == noteSubEu->reverbIndex) {
noteIndices[notePos++] = i;
}
var_s3 += 1;
} while (var_s3 < gNumSynthesisReverbs);
var_s3 = 0;
}
}
var_s1 = 0;
if (gMaxSimultaneousNotes > 0) {
var_v1_2 = gMaxSimultaneousNotes * updateIndex;
do {
temp_v0_2 = &gNoteSubsEu[var_v1_2];
if (((u32) temp_v0_2->unk0 >> 0x1F) != 0) {
temp_t8 = &sp84 + var_s2;
if ((s32) ((u8) temp_v0_2->unk1 >> 5) >= gNumSynthesisReverbs) {
var_s2 += 1;
*temp_t8 = var_s1;
}
}
var_s1 += 1;
var_v1_2 += 1;
} while (var_s1 < gMaxSimultaneousNotes);
var_s1 = 0;
for (i = 0; i < gMaxSimultaneousNotes; i++) {
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && noteSubEu->reverbIndex >= gNumSynthesisReverbs) {
noteIndices[notePos++] = i;
}
}
}
acmd->words.w1 = 0x00000300;
acmd->words.w0 = 0x02000540;
var_s4 = acmd + 8;
if (gNumSynthesisReverbs > 0) {
do {
temp_t9 = &gSynthesisReverbs[var_s3];
sp64 = temp_t9;
temp_t3 = temp_t9->useReverb;
gUseReverb = temp_t3;
if ((s8) temp_t3 != 0) {
var_s4 = synthesis_resample_and_mix_reverb(var_s4, bufLen, var_s3, (s16) updateIndex);
}
if (var_s1 < var_s2) {
var_s0 = var_s1 + &sp84;
loop_31:
temp_v1 = *var_s0;
temp_lo = updateIndex * gMaxSimultaneousNotes;
if (var_s3 == ((u8) (&gNoteSubsEu[temp_v1])[temp_lo].unk1 >> 5)) {
var_s1 += 1;
var_s4 = func_800B7C30(temp_v1, &gNoteSubsEu[temp_v1 + temp_lo], &gNotes[temp_v1].synthesisState, aiBuf, bufLen, var_s4, updateIndex);
var_s0 += 1;
if (var_s1 < var_s2) {
goto loop_31;
}
}
}
if (sp64->useReverb != 0) {
var_s4 = synthesis_load_reverb_samples(var_s4, var_s3, (s16) updateIndex);
}
var_s3 += 1;
} while (var_s3 < gNumSynthesisReverbs);
}
if (var_s1 < var_s2) {
var_s0_2 = var_s1 + &sp84;
do {
temp_v1_2 = *var_s0_2;
temp_lo_2 = updateIndex * gMaxSimultaneousNotes;
temp_a1 = (&gNoteSubsEu[temp_v1_2])[temp_lo_2].bankId;
if ((((s32) gBankLoadStatus[temp_a1] < 2) ^ 1) == 1) {
var_s4 = func_800B7C30(temp_v1_2, &gNoteSubsEu[temp_v1_2 + temp_lo_2], &gNotes[temp_v1_2].synthesisState, aiBuf, bufLen, var_s4, updateIndex);
aClearBuffer(acmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
i = 0;
for (j = 0; j < gNumSynthesisReverbs; j++) {
gUseReverb = gSynthesisReverbs[j].useReverb;
if (gUseReverb != 0) {
acmd = synthesis_resample_and_mix_reverb(acmd, bufLen, j, updateIndex);
}
for (; i < notePos; i++) {
temp = updateIndex * gMaxSimultaneousNotes;
if (j == gNoteSubsEu[temp + noteIndices[i]].reverbIndex) {
acmd = synthesis_process_note(noteIndices[i],
&gNoteSubsEu[temp + noteIndices[i]],
&gNotes[noteIndices[i]].synthesisState,
aiBuf, bufLen, acmd, updateIndex);
continue;
} else {
gAudioErrorFlags = temp_a1 + (var_s1 << 8) + 0x10000000;
break;
}
var_s1 += 1;
var_s0_2 += 1;
} while (var_s1 < var_s2);
}
if (gSynthesisReverbs[j].useReverb != 0) {
acmd = synthesis_save_reverb_samples(acmd, j, updateIndex);
}
}
var_s4->words.w0 = 0x08000000;
temp_s4_2 = var_s4 + 8;
temp_t3_2 = bufLen * 2;
var_s4->words.w1 = temp_t3_2 & 0xFFFF;
temp_s4 = temp_s4_2 + 8;
temp_s4_2->words.w0 = 0x0D000000;
temp_s4_2->words.w1 = 0x054006C0;
temp_s4->words.w0 = ((((s32) (temp_t3_2 * 2) >> 4) & 0xFF) << 0x10) | 0x15000000;
temp_s4->words.w1 = (u32) (aiBuf + 0x80000000);
return temp_s4 + 8;
for (; i < notePos; i++) {
temp = updateIndex * gMaxSimultaneousNotes;
if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId) == TRUE) {
acmd = synthesis_process_note(noteIndices[i],
&gNoteSubsEu[temp + noteIndices[i]],
&gNotes[noteIndices[i]].synthesisState,
aiBuf, bufLen, acmd, updateIndex);
} else {
gAudioErrorFlags = (gNoteSubsEu[temp + noteIndices[i]].bankId + (i << 8)) + 0x10000000;
}
}
temp = bufLen * 2;
aSetBuffer(acmd++, 0, 0, DMEM_ADDR_TEMP, temp);
aInterleave(acmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH);
aSaveBuffer(acmd++, DMEM_ADDR_TEMP, VIRTUAL_TO_PHYSICAL2(aiBuf), temp * 2);
return acmd;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/synthesis/func_800B775C.s")
#endif
#ifdef MIPS_TO_C
//generated by m2c commit 08138748803d75e73e4a94bb0c619a273754ee9c on Sep-15-2023
// synthesis_process_notes
Acmd *func_800B7C30(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 updateIndex) {
//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Nov-01-2023
Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 updateIndex) {
void *sp130;
void *sp12C;
s32 *sp128;
@@ -796,7 +666,7 @@ block_60:
return var_s2;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/synthesis/func_800B7C30.s")
GLOBAL_ASM("asm/non_matchings/audio/synthesis/synthesis_process_note.s")
#endif
Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) {
+4 -2
View File
@@ -95,13 +95,15 @@ struct SynthesisReverb {
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex);
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen);
Acmd *synthesis_load_reverb_ring_buffer(Acmd*, u16, u16, s32, s32);
Acmd *synthesis_save_reverb_ring_buffer(Acmd*, u16, u16, s32, s32);
void func_800B6FB4(s32 updateIndexStart, s32 noteIndex);
void synthesis_load_note_subs_eu(s32 updateIndex);
Acmd *synthesis_execute(Acmd*, s32*, s16*, s32);
Acmd *synthesis_resample_and_mix_reverb(Acmd*, s32, s16, s16);
Acmd *synthesis_load_reverb_samples(Acmd*, s16, s16);
Acmd *synthesis_save_reverb_samples(Acmd*, s16, s16);
Acmd *synthesis_do_one_audio_update(s16*, s32, Acmd*, s32);
Acmd *synthesis_process_note(s32, struct NoteSubEu*, struct NoteSynthesisState*, s16*, s32, Acmd*, s32);
Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad);
Acmd *final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags);
Acmd *func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
+3 -2
View File
@@ -1,6 +1,7 @@
#define STRANGE_MAIN_HEADER_H
#include <ultra64.h>
#include <PR/os.h>
#include <PR/ucode.h>
#include <macros.h>
#include <functions.h>
#include <types.h>
@@ -273,8 +274,8 @@ void create_gfx_task_structure(void) {
gGfxSPTask->msg = (OSMesg) 2;
gGfxSPTask->task.t.type = M_GFXTASK;
gGfxSPTask->task.t.flags = OS_TASK_DP_WAIT;
gGfxSPTask->task.t.ucode_boot = rspbootTextStart;
gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspbootTextEnd - (u8 *) rspbootTextStart);
gGfxSPTask->task.t.ucode_boot = rspF3DBootStart;
gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart);
// The split-screen multiplayer racing state uses F3DLX which has a simple subpixel calculation.
// Singleplayer race mode and all other game states use F3DEX.
// http://n64devkit.square7.ch/n64man/ucode/gspF3DEX.htm
-6
View File
@@ -231,12 +231,6 @@ extern f32 gCourseTimer;
// end of definition of main.c variables
extern u64 rspbootTextStart[], rspbootTextEnd[];
extern u64 gspF3DEXTextStart[], gspF3DEXTextEnd[];
extern u64 gspF3DLXTextStart[], gspF3DLXTextEnd[];
extern u64 gspF3DEXDataStart[];
extern u64 gspF3DLXDataStart[];
extern u64 gGfxSPTaskOutputBuffer[];
extern u32 gGfxSPTaskOutputBufferSize;