From 3c44b7492245e1c2813596e7c894efd34eb73d28 Mon Sep 17 00:00:00 2001 From: Unnunu Date: Tue, 31 Jan 2023 15:06:12 +0300 Subject: [PATCH] au_pull_voice and some documentation (#926) * matched dispatch_damage_event_partner * cleaning up * matched au_voice_pull * removed comment * more renames * and a couple more * rename voice group -> fx bus --- include/PR/libaudio.h | 18 +- src/audio.h | 144 ++-- src/audio/25f00_len_940.c | 33 +- src/audio/28910_len_5090.c | 16 +- src/audio/2d9a0_len_890.c | 2 +- src/audio/2e230_len_2190.c | 80 +- src/audio/31650.c | 716 ++++++++--------- src/audio/33450.c | 278 ++++++- src/audio/private.h | 68 +- src/audio/reverb.c | 6 +- ver/us/asm/bss.s | 14 +- .../nonmatchings/audio/33450/func_80058050.s | 752 ------------------ .../audio/2e230_len_2190/au_engine_init.s | 12 +- ver/us/symbol_addrs.txt | 80 +- 14 files changed, 864 insertions(+), 1355 deletions(-) delete mode 100644 ver/us/asm/nonmatchings/audio/33450/func_80058050.s diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index 38cf1e6eb3..5a2edea832 100755 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -35,10 +35,10 @@ extern "C" { #include #include - + /*********************************************************************** * misc defines - ***********************************************************************/ + ***********************************************************************/ #ifndef _EMULATOR # ifdef AUD_PROFILE @@ -65,8 +65,8 @@ extern "C" { #define AL_FRAME_INIT -1 #define AL_USEC_PER_FRAME 16000 #define AL_MAX_PRIORITY 127 -#define AL_GAIN_CHANGE_TIME 1000 - +#define AL_GAIN_CHANGE_TIME 1000 + typedef s32 ALMicroTime; typedef u8 ALPan; @@ -337,9 +337,9 @@ typedef struct { s32 curSamples; /* samples from start of game */ ALDMANew dma; ALHeap *heap; - + struct ALParam_s *paramList; - + struct ALMainBus_s *mainBus; struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ struct ALFilter_s *outputFilter; /* last filter in the filter chain */ @@ -527,7 +527,7 @@ typedef struct { typedef struct { s32 ticks; /* MIDI, Tempo and End events must start with ticks */ u8 status; - u8 byte1; + u8 byte1; u8 byte2; u32 duration; } ALMIDIEvent; @@ -800,7 +800,7 @@ f32 alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo); u32 alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo); void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); void alCSeqSetLoc(ALCSeq *seq, ALCSeqMarker *marker); -void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); +void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); /* * Sequence Player routines @@ -912,7 +912,7 @@ typedef struct { } ALSndPlayer; typedef s16 ALSndId; - + void alSndpNew(ALSndPlayer *sndp, ALSndpConfig *c); void alSndpDelete(ALSndPlayer *sndp); diff --git a/src/audio.h b/src/audio.h index 27fea92768..3ce46a03a5 100644 --- a/src/audio.h +++ b/src/audio.h @@ -44,6 +44,8 @@ typedef u8* WaveData; #define AUDIO_SAMPLES 184 #define AUDIO_COMMAND_LIST_BUFFER_SIZE 0x4000 +#define ADPCMFBYTES 9 + #define SND_MAX_VOLUME_8 0x7F // 127 #define SND_MAX_VOLUME_16 0x7FFF @@ -114,6 +116,13 @@ typedef enum SegmentControlCommands { BGM_SEGMENT_7 = 7 } SegmentControlCommands; +typedef enum FxBus { + FX_BUS_0 = 0, + FX_BUS_1 = 1, + FX_BUS_2 = 2, + FX_BUS_3 = 3, +} FxBus; + typedef union Q32 { u8 u8[4]; u16 u16[2]; @@ -306,16 +315,16 @@ typedef struct AlUnkKappa { /* 0x10 */ AuLowPass* lowpass_10; } AlUnkKappa; // size unk -typedef struct AlUnkGamma { - /* 0x00 */ u16 unk_00; +typedef struct AuFxBus { + /* 0x00 */ u16 gain; /* 0x02 */ char unk_02[0x2]; /* 0x04 */ AuFX* fxL; /* 0x08 */ AuFX* fxR; /* 0x0C */ u8 currentEffectType; /* 0x0D */ char unk_0D[0x3]; - /* 0x10 */ struct AuPVoice* pvoice_10; - /* 0x14 */ struct AuPVoice* pvoice_14; -} AlUnkGamma; // size = 0x18 + /* 0x10 */ struct AuPVoice* head; + /* 0x14 */ struct AuPVoice* tail; +} AuFxBus; // size = 0x18 // ALDMAproc in PM supposedly has an extra arg added, so that's why we have ALDMAproc2 and ALDMANew2 typedef s32 (*ALDMAproc2)(s32 addr, s32 len, void *state, u8 arg3); @@ -323,57 +332,57 @@ typedef ALDMAproc2 (*ALDMANew2)(void *state); // based on ALLoadFilter typedef struct AuLoadFilter { - /* 0x04 */ ADPCM_STATE* dc_state; - /* 0x08 */ ADPCM_STATE* dc_lstate; - /* 0x0C */ ALRawLoop dc_loop; - /* 0x18 */ struct Instrument* instrument; - /* 0x1C */ s32 dc_bookSize; - /* 0x20 */ ALDMAproc2 dc_dmaFunc; - /* 0x24 */ NUDMAState* dc_dmaState; - /* 0x28 */ s32 dc_sample; - /* 0x2C */ s32 dc_lastsam; - /* 0x30 */ s32 dc_first; - /* 0x34 */ u8* dc_memin; + /* 0x00 */ ADPCM_STATE* state; + /* 0x04 */ ADPCM_STATE* lstate; + /* 0x08 */ ALRawLoop loop; + /* 0x14 */ struct Instrument* instrument; + /* 0x18 */ s32 bookSize; + /* 0x1C */ ALDMAproc2 dmaFunc; + /* 0x20 */ NUDMAState* dmaState; + /* 0x24 */ s32 sample; + /* 0x28 */ s32 lastsam; + /* 0x2C */ s32 first; + /* 0x30 */ s32 memin; } AuLoadFilter; // size = 0x34 // based on ALResampler typedef struct AuResampler { - /* 0x38 */ RESAMPLE_STATE* rs_state; - /* 0x3C */ f32 rs_ratio; - /* 0x40 */ f32 delta; - /* 0x44 */ s32 first; + /* 0x00 */ RESAMPLE_STATE* state; + /* 0x04 */ f32 ratio; + /* 0x08 */ f32 delta; + /* 0x0C */ s32 first; } AuResampler; // size = 0x10 // envelope mixer -- based on ALEnvMixer typedef struct AuEnvMixer { - /* 0x48 */ ENVMIX_STATE* em_state; - /* 0x4C */ s16 em_pan; - /* 0x4E */ s16 em_volume; - /* 0x50 */ s16 em_cvolL; - /* 0x52 */ s16 em_cvolR; - /* 0x54 */ s16 em_dryamt; - /* 0x56 */ s16 em_wetamt; - /* 0x58 */ s16 em_lratl; - /* 0x5A */ s16 em_lratm; - /* 0x5C */ s16 em_ltgt; - /* 0x5E */ s16 em_rratl; - /* 0x60 */ s16 em_rratm; - /* 0x62 */ s16 em_rtgt; - /* 0x64 */ s32 em_delta; - /* 0x68 */ s32 em_segEnd; - /* 0x6C */ s32 em_first; - /* 0x70 */ s32 em_motion; -} AuEnvMixer; // size = 0x74 + /* 0x00 */ ENVMIX_STATE* state; + /* 0x04 */ s16 pan; + /* 0x06 */ s16 volume; + /* 0x08 */ s16 cvolL; + /* 0x0A */ s16 cvolR; + /* 0x0C */ s16 dryamt; + /* 0x0E */ s16 wetamt; + /* 0x10 */ s16 lratl; + /* 0x12 */ s16 lratm; + /* 0x14 */ s16 ltgt; + /* 0x16 */ s16 rratl; + /* 0x18 */ s16 rratm; + /* 0x1A */ s16 rtgt; + /* 0x1C */ s32 delta; + /* 0x20 */ s32 segEnd; + /* 0x24 */ s32 first; + /* 0x28 */ s32 motion; +} AuEnvMixer; // size = 0x2C // based on N_PVoice typedef struct AuPVoice { /* 0x00 */ struct AuPVoice* next; - /* 0x04 */ AuLoadFilter loadFilter; + /* 0x04 */ AuLoadFilter decoder; /* 0x38 */ AuResampler resampler; /* 0x48 */ AuEnvMixer envMixer; /* 0x74 */ s16 unk_74; /* 0x76 */ s16 unk_76; - /* 0x78 */ u8 gammaID; //? + /* 0x78 */ u8 groupID; //? /* 0x79 */ u8 index; /* 0x7A */ u8 unk_7A[2]; } AuPVoice; @@ -384,13 +393,13 @@ typedef struct AuSynDriver { /* 0x04 */ s32 unk_04; /* 0x08 */ s32 outputRate; /* 0x0C */ s32 num_pvoice; - /* 0x10 */ s32 unk_num_gamma; + /* 0x10 */ s32 num_bus; /* 0x14 */ ALDMANew2 dmaNew; // pointer to nuAuDmaNew /* 0x18 */ ALHeap* heap; /* 0x1C */ AuPVoice* pvoices; - /* 0x20 */ AlUnkGamma* al_unk_gamma; - /* 0x24 */ s32* unk_drvr_24; // struct size = 0x170 - /* 0x28 */ s32* unk_drvr_28; // struct size = 0x170 + /* 0x20 */ AuFxBus* fxBus; + /* 0x24 */ s32* savedMainOut; // struct size = 0x170 + /* 0x28 */ s32* savedAuxOut; // struct size = 0x170 } AuSynDriver; typedef struct SoundSFXEntry { @@ -785,10 +794,10 @@ typedef struct AuGlobals { /* 0x0038 */ s32 bkListLength; /* 0x003C */ u16* mseqFileList; /* 0x0040 */ AuEffectChange effectChanges[4]; - /* 0x0050 */ u8 unk_50; - /* 0x0051 */ u8 unk_51; - /* 0x0052 */ u8 unk_52; - /* 0x0053 */ u8 unk_53; + /* 0x0050 */ u8 channelDelayPending; + /* 0x0051 */ u8 channelDelayGroupIdx; + /* 0x0052 */ u8 channelDelayTime; + /* 0x0053 */ u8 channelDelaySide; /* 0x0054 */ PEREntry* dataPER; /* 0x0058 */ BGMInstrumentInfo* dataPRG; /* 0x005C */ struct BGMHeader* dataBGM[2]; @@ -1070,7 +1079,7 @@ typedef struct AlUnkGemini { typedef struct ALConfig { /* 0x00 */ s32 num_pvoice; - /* 0x04 */ s32 unk_num_gamma; + /* 0x04 */ s32 num_bus; /* 0x08 */ s32 outputRate; /* 0x0C */ u8 unk_0C; /* 0x0D */ char unk_0D[3]; @@ -1093,9 +1102,9 @@ extern u16 D_80078DB6; extern AuSynDriver* gActiveSynDriverPtr; extern AuSynDriver* gSynDriverPtr; -extern u8 D_80078E58; -extern u16 D_80078E5A; -extern u8 D_80078E5C; +extern u8 AuUseGlobalVolume; +extern u16 AuGlobalVolume; +extern u8 AuSynStereoDirty; extern AuGlobals* gSoundGlobals; extern BGMPlayer* gBGMPlayerC; @@ -1105,32 +1114,15 @@ extern AuAmbienceManager* gAuAmbienceManager; extern SoundManager* gSoundManager; extern BGMPlayer* gBGMPlayerA; -extern u16 D_800A0F50; +extern u16 AuInitialGlobalVolume; -extern s16* D_800A3FE0; -extern s16* D_800A3FE4; -extern s32 D_800A3FE8; -extern u8 D_800A3FEC; -extern s16 D_800A3FEE; -extern s32 D_800A3FF0; +extern s16* AuDelayBufferMain; +extern s16* AuDelayBufferAux; +extern s32 AuDelayCounter; +extern u8 AuDelayedVoiceGroup; +extern s16 AuDelayedChannel; +extern s32 AuDelayCount; #include "audio/private.h" -#define aLoadBufferSize(pkt,s,u,b) { \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL(s, 12, 12) | _SHIFTL(u, 0, 12); \ - _a->words.w1 = (unsigned int)(b); \ -} - -#define aSaveBufferSize(pkt,s,u,b) { \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL(s, 12, 12) | _SHIFTL(u, 0, 12); \ - _a->words.w1 = (unsigned int)(b); \ -} - -#define aInterleavePart(pkt) { \ - Acmd *_a = (Acmd *)pkt; \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ -} - #endif diff --git a/src/audio/25f00_len_940.c b/src/audio/25f00_len_940.c index 63d29bd429..52347badf1 100644 --- a/src/audio/25f00_len_940.c +++ b/src/audio/25f00_len_940.c @@ -40,7 +40,7 @@ void create_audio_system(void) { nuAuPreNMI = 0; alHeapInit(&nuAuHeap, AuHeapBase, AUDIO_HEAP_SIZE); config.num_pvoice = 24; - config.unk_num_gamma = 4; + config.num_bus = 4; outputRate = osAiSetFrequency(32000); frameSize = (AlNumFields * outputRate + 59) / 60; config.outputRate = outputRate; @@ -83,7 +83,7 @@ void create_audio_system(void) { nuAuDmaBufList[i].ptr = alHeapAlloc(config.heap, 1, 0x500); osCreateMesgQueue(&nuAuDmaMesgQ, nuAuDmaMesgBuf, 50); - nuAuPreNMIFunc = func_8004B328; + nuAuPreNMIFunc = nuAuPreNMIProc; au_driver_init(&auSynDriver, &config); au_engine_init(config.outputRate); osCreateThread(&nuAuMgrThread, NU_MAIN_THREAD_ID, nuAuMgr, NULL, &AlCmdListBuffers, NU_AU_MGR_THREAD_PRI); //why main thread? @@ -295,28 +295,27 @@ void nuAuCleanDMABuffers(void) { } while (0); } -// rename: default_nuAuPreNMIFunc -void func_8004B328(NUScMsg mesg_type, u32 frameCounter) { - s16 temp; - s32 temp2; +void nuAuPreNMIProc(NUScMsg mesg_type, u32 frameCounter) { + s16 maxVol; + s32 vol; switch (mesg_type) { - case 2: - D_800A0F50 = func_80056D50(); - func_80056D34(); + case NU_SC_PRENMI_MSG: + AuInitialGlobalVolume = au_get_global_volume(); + au_use_global_volume(); break; - case 1: - temp = D_800A0F50; - temp2 = temp - (temp / 20) * frameCounter; + case NU_SC_RETRACE_MSG: + maxVol = AuInitialGlobalVolume; + vol = maxVol - (maxVol / 20) * frameCounter; - if (temp2 < 0) { - temp2 = 0; + if (vol < 0) { + vol = 0; } - temp2 = (temp2 * temp2) >> 15; - func_80056D44(temp2); + vol = SQ(vol) >> 15; + au_set_global_volume(vol); - if (temp2 == 0) { + if (vol == 0) { nuAuTaskStop = NU_AU_TASK_STOP; } break; diff --git a/src/audio/28910_len_5090.c b/src/audio/28910_len_5090.c index ea841059a3..1ba15ac484 100644 --- a/src/audio/28910_len_5090.c +++ b/src/audio/28910_len_5090.c @@ -1736,19 +1736,19 @@ void au_BGMCmd_FF(BGMPlayer* player, BGMPlayerTrack* track) { switch (arg0) { case 1: if ((arg1 < ARRAY_COUNT(player->effectIndices)) && ((s8)player->effectIndices[arg1] >= 0)) { - player->globals->unk_51 = player->effectIndices[arg1]; + player->globals->channelDelayGroupIdx = player->effectIndices[arg1]; if (arg2 != 0) { temp_a3 = arg2 & 0xF; temp_a1 = ((arg2 >> 4) & 1) + 1; - if ((player->globals->unk_52 != temp_a3) || (player->globals->unk_53 != temp_a1)) { - player->globals->unk_52 = temp_a3; - player->globals->unk_53 = temp_a1; - player->globals->unk_50 = 1; + if ((player->globals->channelDelayTime != temp_a3) || (player->globals->channelDelaySide != temp_a1)) { + player->globals->channelDelayTime = temp_a3; + player->globals->channelDelaySide = temp_a1; + player->globals->channelDelayPending = 1; } } else { - if (player->globals->unk_53 != 0) { - player->globals->unk_53 = 0; - player->globals->unk_50 = 1; + if (player->globals->channelDelaySide != 0) { + player->globals->channelDelaySide = 0; + player->globals->channelDelayPending = 1; } } } diff --git a/src/audio/2d9a0_len_890.c b/src/audio/2d9a0_len_890.c index 80ea484028..80b435eb75 100644 --- a/src/audio/2d9a0_len_890.c +++ b/src/audio/2d9a0_len_890.c @@ -8,7 +8,7 @@ void func_800525A0(AuGlobals* globals) { AlUnkVoice* voice = &globals->voices[i]; if (voice->unk_42 != 0) { - au_pvoice_reset_filter(i); + au_syn_stop_voice(i); voice->unk_42 = 0; voice->unk_1C = NULL; voice->priority = AU_PRIORITY_FREE; diff --git a/src/audio/2e230_len_2190.c b/src/audio/2e230_len_2190.c index 77155de23a..a8a7af545e 100644 --- a/src/audio/2e230_len_2190.c +++ b/src/audio/2e230_len_2190.c @@ -78,8 +78,8 @@ void au_engine_init(s32 outputRate) { for (i = 0; i < ARRAY_COUNT(globals->voices); i++) { AlUnkVoice* voice; - func_80056EC0(i, 0); - au_pvoice_set_filter_wavetable(i, globals->defaultInstrument); + au_pvoice_set_group(i, 0); + au_syn_set_wavetable(i, globals->defaultInstrument); voice = &globals->voices[i]; voice->instrument = NULL; voice->pitchRatio = 0; @@ -136,12 +136,12 @@ void au_engine_init(s32 outputRate) { globals->instrumentGroups[5] = globals->instrumentGroup5; globals->instrumentGroups[6] = globals->instrumentGroup6; globals->instrumentGroups[7] = globals->instrumentGroup1; - globals->unk_53 = 0; - globals->unk_52 = 0; - globals->unk_51 = 0; - globals->unk_50 = 0; + globals->channelDelaySide = 0; + globals->channelDelayTime = 0; + globals->channelDelayGroupIdx = 0; + globals->channelDelayPending = 0; - func_80057ED0(0); + au_delay_channel(0); func_80055050(alHeap); } #else @@ -288,43 +288,43 @@ void func_80053654(AuGlobals* globals) { if (globals->unk_130C == 2) { globals->unk_130C = 1; - func_80057EB0(); + au_disable_channel_delay(); } - if ((globals->unk_50 != 0) && (globals->unk_130C == 0)) { - switch (globals->unk_53) { + if (globals->channelDelayPending && (globals->unk_130C == 0)) { + switch (globals->channelDelaySide) { case 1: - func_80057DC8(globals->unk_52); - func_80057E08(globals->unk_51); - globals->unk_50 = 0; + au_set_delay_time(globals->channelDelayTime); + au_delay_left_channel(globals->channelDelayGroupIdx); + globals->channelDelayPending = FALSE; break; case 2: - func_80057DC8(globals->unk_52); - func_80057E5C(globals->unk_51); - globals->unk_50 = 0; + au_set_delay_time(globals->channelDelayTime); + au_delay_right_channel(globals->channelDelayGroupIdx); + globals->channelDelayPending = FALSE; break; default: - func_80057EB0(); - globals->unk_50 = 0; + au_disable_channel_delay(); + globals->channelDelayPending = FALSE; break; } } - if (globals->effectChanges[0].changed) { - func_80056DCC(0, globals->effectChanges[0].type); - globals->effectChanges[0].changed = FALSE; + if (globals->effectChanges[FX_BUS_0].changed) { + au_bus_set_effect(FX_BUS_0, globals->effectChanges[FX_BUS_0].type); + globals->effectChanges[FX_BUS_0].changed = FALSE; } - if (globals->effectChanges[1].changed) { - func_80056DCC(1, globals->effectChanges[1].type); - globals->effectChanges[1].changed = FALSE; + if (globals->effectChanges[FX_BUS_1].changed) { + au_bus_set_effect(FX_BUS_1, globals->effectChanges[FX_BUS_1].type); + globals->effectChanges[FX_BUS_1].changed = FALSE; - } if (globals->effectChanges[2].changed) { - func_80056DCC(2, globals->effectChanges[2].type); - globals->effectChanges[2].changed = FALSE; + } if (globals->effectChanges[FX_BUS_2].changed) { + au_bus_set_effect(FX_BUS_2, globals->effectChanges[FX_BUS_2].type); + globals->effectChanges[FX_BUS_2].changed = FALSE; } - if (globals->effectChanges[3].changed) { - func_80056DCC(3, globals->effectChanges[3].type); - globals->effectChanges[3].changed = FALSE; + if (globals->effectChanges[FX_BUS_3].changed) { + au_bus_set_effect(FX_BUS_3, globals->effectChanges[FX_BUS_3].type); + globals->effectChanges[FX_BUS_3].changed = FALSE; } for (i = 0; i < ARRAY_COUNT(globals->voices); i++) { @@ -332,7 +332,7 @@ void func_80053654(AuGlobals* globals) { u8 voiceUpdateFlags = voice->unk_flags_43; if (voice->unk_42 != 0) { - au_pvoice_reset_filter(i); + au_syn_stop_voice(i); voice->unk_42 = 0; voice->unk_1C = NULL; voice->priority = AU_PRIORITY_FREE; @@ -340,17 +340,17 @@ void func_80053654(AuGlobals* globals) { if (voiceUpdateFlags & AU_VOICE_SYNC_FLAG_ALL) { func_80052BF8(voice, &voice->unk_14); - au_pvoice_set_filter(i, voice->reverbType, voice->instrument, voice->pitchRatio, voice->volume, voice->pan, voice->reverbAmt, voice->unk_08); + au_syn_start_voice_params(i, voice->reverbType, voice->instrument, voice->pitchRatio, voice->volume, voice->pan, voice->reverbAmt, voice->unk_08); voice->priority = voice->priorityCopy; } else { if (voiceUpdateFlags & AU_VOICE_SYNC_FLAG_PITCH) { - au_pvoice_set_pitch_ratio(i, voice->pitchRatio); + au_syn_set_pitch(i, voice->pitchRatio); } if (voiceUpdateFlags & AU_VOICE_SYNC_FLAG_4) { - func_8005736C(i, voice->volume, voice->unk_08, voice->pan, voice->reverbAmt); + au_syn_set_mixer_params(i, voice->volume, voice->unk_08, voice->pan, voice->reverbAmt); } else if (voiceUpdateFlags & AU_VOICE_SYNC_FLAG_10) { - func_80057548(i, voice->pan, voice->reverbAmt); + au_syn_set_pan_fxmix(i, voice->pan, voice->reverbAmt); } } voice->unk_flags_43 = 0; @@ -362,7 +362,7 @@ void func_80053888(AlUnkVoice* voice, u8 index) { voice->unk_1C = NULL; voice->unk_42 = 1; voice->unk_flags_43 = 0; - func_800576EC(index, 0, AUDIO_SAMPLES); + au_syn_set_volume_delta(index, 0, AUDIO_SAMPLES); } } @@ -371,7 +371,7 @@ void au_reset_voice(AlUnkVoice* voice, u8 index) { voice->unk_1C = NULL; voice->unk_42 = 1; voice->unk_flags_43 = 0; - func_800576EC(index, 0, AUDIO_SAMPLES); + au_syn_set_volume_delta(index, 0, AUDIO_SAMPLES); } // array offsets into AlTuneScaling @@ -427,8 +427,8 @@ void au_fade_update(Fade* fade) { } } -void func_80053A98(u8 arg0, u16 arg1, s32 arg2) { - func_80056D78(arg0, (u32)(arg1 * arg2) >> 15); +void func_80053A98(u8 busId, u16 arg1, s32 arg2) { + au_bus_set_volume(busId, (u32)(arg1 * arg2) >> 15); } void func_80053AC8(Fade* fade) { @@ -1162,7 +1162,7 @@ void func_80054DA8(u32 bMonoSound) { } else { // stereo sound if (gSoundGlobals->unk_130C != 0) { - gSoundGlobals->unk_50 = 1; + gSoundGlobals->channelDelayPending = 1; gSoundGlobals->unk_130C = 0; } } diff --git a/src/audio/31650.c b/src/audio/31650.c index bf717ef801..3102a894ea 100644 --- a/src/audio/31650.c +++ b/src/audio/31650.c @@ -6,9 +6,9 @@ static s16 _getVol(s16 arg0, s32 arg1, s16 arg2, u16 arg3); AuSynDriver* gActiveSynDriverPtr = NULL; AuSynDriver* gSynDriverPtr = NULL; -u8 D_80078E58 = FALSE; -u16 D_80078E5A = 0x7FFF; -u8 D_80078E5C = FALSE; +u8 AuUseGlobalVolume = FALSE; +u16 AuGlobalVolume = 0x7FFF; +u8 AuSynStereoDirty = FALSE; extern s16 AuEqPower[128]; @@ -24,7 +24,7 @@ void au_driver_init(AuSynDriver* driver, ALConfig* config) { } driver->num_pvoice = config->num_pvoice; - driver->unk_num_gamma = config->unk_num_gamma; + driver->num_bus = config->num_bus; driver->curSamples = 0; driver->unk_04 = 0; driver->outputRate = config->outputRate; @@ -32,72 +32,72 @@ void au_driver_init(AuSynDriver* driver, ALConfig* config) { gActiveSynDriverPtr = driver; gSynDriverPtr = driver; - D_80078E58 = FALSE; - D_80078E5A = 0x7FFF; - D_80078E5C = TRUE; + AuUseGlobalVolume = FALSE; + AuGlobalVolume = 0x7FFF; + AuSynStereoDirty = TRUE; gSynDriverPtr->pvoices = alHeapAlloc(heap, config->num_pvoice, sizeof(*gSynDriverPtr->pvoices)); // this is inlined alN_PVoiceNew for (i = 0; i < config->num_pvoice; i++) { AuPVoice* voice = &gSynDriverPtr->pvoices[i]; - voice->loadFilter.dc_state = alHeapAlloc(heap, 1, sizeof(*voice->loadFilter.dc_state)); - voice->loadFilter.dc_lstate = alHeapAlloc(heap, 1, sizeof(*voice->loadFilter.dc_lstate)); - voice->loadFilter.dc_dmaFunc = gSynDriverPtr->dmaNew(&voice->loadFilter.dc_dmaState); - voice->loadFilter.dc_lastsam = 0; - voice->loadFilter.dc_first = 1; - voice->loadFilter.dc_memin = NULL; - voice->resampler.rs_state = alHeapAlloc(heap, 1, sizeof(*voice->resampler.rs_state)); + voice->decoder.state = alHeapAlloc(heap, 1, sizeof(*voice->decoder.state)); + voice->decoder.lstate = alHeapAlloc(heap, 1, sizeof(*voice->decoder.lstate)); + voice->decoder.dmaFunc = gSynDriverPtr->dmaNew(&voice->decoder.dmaState); + voice->decoder.lastsam = 0; + voice->decoder.first = 1; + voice->decoder.memin = NULL; + voice->resampler.state = alHeapAlloc(heap, 1, sizeof(*voice->resampler.state)); voice->resampler.delta = 0; voice->resampler.first = 1; - voice->resampler.rs_ratio = 1.0f; - voice->envMixer.em_state = alHeapAlloc(heap, 1, sizeof(*voice->envMixer.em_state)); - voice->envMixer.em_first = 1; - voice->envMixer.em_motion = AL_STOPPED; - voice->envMixer.em_volume = 1; - voice->envMixer.em_ltgt = 1; - voice->envMixer.em_rtgt = 1; - voice->envMixer.em_cvolL = 1; - voice->envMixer.em_cvolR = 1; - voice->envMixer.em_dryamt = 0; - voice->envMixer.em_wetamt = 0; - voice->envMixer.em_lratm = 1; - voice->envMixer.em_lratl = 0; - voice->envMixer.em_rratm = 1; - voice->envMixer.em_rratl = 0; - voice->envMixer.em_delta = 0; - voice->envMixer.em_segEnd = 0; - voice->envMixer.em_pan = 64; + voice->resampler.ratio = 1.0f; + voice->envMixer.state = alHeapAlloc(heap, 1, sizeof(*voice->envMixer.state)); + voice->envMixer.first = 1; + voice->envMixer.motion = AL_STOPPED; + voice->envMixer.volume = 1; + voice->envMixer.ltgt = 1; + voice->envMixer.rtgt = 1; + voice->envMixer.cvolL = 1; + voice->envMixer.cvolR = 1; + voice->envMixer.dryamt = 0; + voice->envMixer.wetamt = 0; + voice->envMixer.lratm = 1; + voice->envMixer.lratl = 0; + voice->envMixer.rratm = 1; + voice->envMixer.rratl = 0; + voice->envMixer.delta = 0; + voice->envMixer.segEnd = 0; + voice->envMixer.pan = 64; voice->unk_74 = 0; voice->next = NULL; - voice->gammaID = 0; + voice->groupID = 0; voice->index = i; } - gSynDriverPtr->al_unk_gamma = alHeapAlloc(heap, config->unk_num_gamma, sizeof(*gSynDriverPtr->al_unk_gamma)); + gSynDriverPtr->fxBus = alHeapAlloc(heap, config->num_bus, sizeof(*gSynDriverPtr->fxBus)); - for (i = 0; i < config->unk_num_gamma; i++) { - AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[i]; - gamma->pvoice_10 = NULL; - gamma->pvoice_14 = NULL; - gamma->unk_00 = 0x7FFF; - gamma->currentEffectType = AU_FX_NONE; - gamma->fxL = alHeapAlloc(heap, 1, sizeof(*gamma->fxL)); - gamma->fxR = alHeapAlloc(heap, 1, sizeof(*gamma->fxR)); - func_80058E84(gamma->fxL, gamma->currentEffectType, heap); - func_80058E84(gamma->fxR, gamma->currentEffectType, heap); + for (i = 0; i < config->num_bus; i++) { + AuFxBus* fxBus = &gSynDriverPtr->fxBus[i]; + fxBus->head = NULL; + fxBus->tail = NULL; + fxBus->gain = 0x7FFF; + fxBus->currentEffectType = AU_FX_NONE; + fxBus->fxL = alHeapAlloc(heap, 1, sizeof(*fxBus->fxL)); + fxBus->fxR = alHeapAlloc(heap, 1, sizeof(*fxBus->fxR)); + func_80058E84(fxBus->fxL, fxBus->currentEffectType, heap); + func_80058E84(fxBus->fxR, fxBus->currentEffectType, heap); } - gSynDriverPtr->unk_drvr_24 = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2); - gSynDriverPtr->unk_drvr_28 = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2); - D_800A3FEC = 0; - D_800A3FEE = 0; - D_800A3FF0 = 4; + gSynDriverPtr->savedMainOut = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2); + gSynDriverPtr->savedAuxOut = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2); + AuDelayedVoiceGroup = 0; + AuDelayedChannel = 0; + AuDelayCount = 4; - D_800A3FE0 = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2); - D_800A3FE4 = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2); + AuDelayBufferMain = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2); + AuDelayBufferAux = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2); for (i = 0; i < 4 * AUDIO_SAMPLES; i++) { - D_800A3FE4[i] = D_800A3FE0[i] = 0; + AuDelayBufferAux[i] = AuDelayBufferMain[i] = 0; } gSynDriverPtr->heap = heap; @@ -112,14 +112,14 @@ void au_driver_release(void) { Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen) { Acmd* cmdListPos; AuPVoice* pvoice; - AlUnkGamma* gamma; + AuFxBus* fxBus; s16* bufPos; s16 auxOut; s16 mainOut; s32 i; - s32 var_s7 = FALSE; + s32 first = FALSE; cmdListPos = cmdList; bufPos = outBuf; @@ -127,52 +127,55 @@ Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen) { *cmdLen = 0; } else { au_update_players_main(); - if (D_80078E5C) { + if (AuSynStereoDirty) { for (i = 0; i < gSynDriverPtr->num_pvoice; i++) { pvoice = &gSynDriverPtr->pvoices[i]; - if (pvoice->envMixer.em_motion == AL_PLAYING) { - func_80057874(i, pvoice->envMixer.em_pan); + if (pvoice->envMixer.motion == AL_PLAYING) { + au_syn_set_pan(i, pvoice->envMixer.pan); } } - D_80078E5C = FALSE; + AuSynStereoDirty = FALSE; } while (outLen > 0) { au_update_clients_2(); for (i = 0; i < gSynDriverPtr->num_pvoice; i++) { pvoice = &gSynDriverPtr->pvoices[i]; - if ((pvoice->gammaID != 0xFF) && (pvoice->gammaID < gSynDriverPtr->unk_num_gamma)) { - gamma = &gSynDriverPtr->al_unk_gamma[pvoice->gammaID]; - if (gamma->pvoice_14 != NULL) { - gamma->pvoice_14->next = pvoice; + if ((pvoice->groupID != 0xFF) && (pvoice->groupID < gSynDriverPtr->num_bus)) { + fxBus = &gSynDriverPtr->fxBus[pvoice->groupID]; + if (fxBus->tail != NULL) { + fxBus->tail->next = pvoice; } else { - gamma->pvoice_10 = pvoice; + fxBus->head = pvoice; } - gamma->pvoice_14 = pvoice; + fxBus->tail = pvoice; } } - var_s7 = TRUE; - for (i = 0; i < gSynDriverPtr->unk_num_gamma; i++) { - gamma = &gSynDriverPtr->al_unk_gamma[i]; - if (gamma->pvoice_10 != NULL) { + first = TRUE; + for (i = 0; i < gSynDriverPtr->num_bus; i++) { + fxBus = &gSynDriverPtr->fxBus[i]; + if (fxBus->head != NULL) { + // clear all main and aux outputs aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 8 * AUDIO_SAMPLES); - if (gamma->pvoice_10 != NULL) { + if (fxBus->head != NULL) { AuPVoice* next; do { - cmdListPos = func_80058050(gamma->pvoice_10, cmdListPos); - next = gamma->pvoice_10->next; - gamma->pvoice_10->next = NULL; - gamma->pvoice_10 = next; + cmdListPos = au_pull_voice(fxBus->head, cmdListPos); + next = fxBus->head->next; + fxBus->head->next = NULL; + fxBus->head = next; } while (next != NULL); - gamma->pvoice_14 = 0; + fxBus->tail = NULL; } - if (gamma->currentEffectType != AU_FX_NONE) { - cmdListPos = func_80059310(gamma->fxL, cmdListPos, N_AL_AUX_L_OUT, 0); - cmdListPos = func_80059310(gamma->fxR, cmdListPos, N_AL_AUX_R_OUT, 0); + if (fxBus->currentEffectType != AU_FX_NONE) { + cmdListPos = au_pull_fx(fxBus->fxL, cmdListPos, N_AL_AUX_L_OUT, 0); + cmdListPos = au_pull_fx(fxBus->fxR, cmdListPos, N_AL_AUX_R_OUT, 0); } - if (i == D_800A3FEC) { + + // apply channel delay + if (i == AuDelayedVoiceGroup) { mainOut = -1; - switch (D_800A3FEE) { + switch (AuDelayedChannel) { case 1: mainOut = N_AL_MAIN_L_OUT; auxOut = N_AL_AUX_L_OUT; @@ -183,49 +186,53 @@ Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen) { break; } if (mainOut != -1) { - aSaveBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(D_800A3FE0 + (D_800A3FE8 % D_800A3FF0) * AUDIO_SAMPLES)); - aLoadBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(D_800A3FE0 + ((D_800A3FE8 + 1) % D_800A3FF0) * AUDIO_SAMPLES)); - aSaveBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(D_800A3FE4 + (D_800A3FE8 % D_800A3FF0) * AUDIO_SAMPLES)); - aLoadBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(D_800A3FE4 + ((D_800A3FE8 + 1) % D_800A3FF0) * AUDIO_SAMPLES)); - + n_aSaveBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(AuDelayBufferMain + (AuDelayCounter % AuDelayCount) * AUDIO_SAMPLES)); + n_aLoadBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(AuDelayBufferMain + ((AuDelayCounter + 1) % AuDelayCount) * AUDIO_SAMPLES)); + n_aSaveBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(AuDelayBufferAux + (AuDelayCounter % AuDelayCount) * AUDIO_SAMPLES)); + n_aLoadBuffer(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(AuDelayBufferAux + ((AuDelayCounter + 1) % AuDelayCount) * AUDIO_SAMPLES)); } } - if (var_s7) { + + // mix voice groups + if (first) { aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES); } else { - aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28)); + n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedAuxOut)); } - aMix(cmdListPos++, 0, gamma->unk_00, N_AL_AUX_L_OUT, 0); - aMix(cmdListPos++, 0, gamma->unk_00, N_AL_AUX_R_OUT, 2 * AUDIO_SAMPLES); - aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28)); - if (var_s7) { + aMix(cmdListPos++, 0, fxBus->gain, N_AL_AUX_L_OUT, 0); + aMix(cmdListPos++, 0, fxBus->gain, N_AL_AUX_R_OUT, 2 * AUDIO_SAMPLES); + n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedAuxOut)); + if (first) { aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES); - var_s7 = FALSE; + first = FALSE; } else { - aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_24)); + n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedMainOut)); } - aMix(cmdListPos++, 0, gamma->unk_00, N_AL_MAIN_L_OUT, 0); - aMix(cmdListPos++, 0, gamma->unk_00, N_AL_MAIN_R_OUT, 2 * AUDIO_SAMPLES); - aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_24)); + aMix(cmdListPos++, 0, fxBus->gain, N_AL_MAIN_L_OUT, 0); + aMix(cmdListPos++, 0, fxBus->gain, N_AL_MAIN_R_OUT, 2 * AUDIO_SAMPLES); + n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->savedMainOut)); } } + aDMEMMove(cmdListPos++, 0, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES); - aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, N_AL_AUX_L_OUT, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28)); + n_aLoadBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, N_AL_AUX_L_OUT, osVirtualToPhysical(gSynDriverPtr->savedAuxOut)); aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT); aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_R_OUT, N_AL_MAIN_R_OUT); - if (D_80078E58) { - u16 temp; + + if (AuUseGlobalVolume) { + u16 vol; aDMEMMove(cmdListPos++, N_AL_MAIN_L_OUT, 0, 4 * AUDIO_SAMPLES); aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES); - temp = D_80078E5A; - aMix(cmdListPos++, 0, temp, 0, N_AL_MAIN_L_OUT); - aMix(cmdListPos++, 0, temp, 2 * AUDIO_SAMPLES, N_AL_MAIN_R_OUT); + vol = AuGlobalVolume; + aMix(cmdListPos++, 0, vol, 0, N_AL_MAIN_L_OUT); + aMix(cmdListPos++, 0, vol, 2 * AUDIO_SAMPLES, N_AL_MAIN_R_OUT); } + outLen -= AUDIO_SAMPLES; - aInterleavePart(cmdListPos++); - aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, bufPos); + n_aInterleave(cmdListPos++); + n_aSaveBuffer(cmdListPos++, 4 * AUDIO_SAMPLES, 0, bufPos); bufPos += 2 * AUDIO_SAMPLES; - D_800A3FE8++; + AuDelayCounter++; gSynDriverPtr->curSamples += AUDIO_SAMPLES; } *cmdLen = (cmdListPos - cmdList); @@ -233,434 +240,433 @@ Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen) { return cmdListPos; } -void func_80056D34(void) { - D_80078E58 = TRUE; +void au_use_global_volume(void) { + AuUseGlobalVolume = TRUE; } -void func_80056D44(s16 arg0) { - D_80078E5A = arg0; +void au_set_global_volume(s16 arg0) { + AuGlobalVolume = arg0; } -s16 func_80056D50(void) { - return D_80078E5A; +s16 au_get_global_volume(void) { + return AuGlobalVolume; } void func_80056D5C(u8 bStereoSound) { AuSynUseStereo = bStereoSound; - D_80078E5C = TRUE; + AuSynStereoDirty = TRUE; } -void func_80056D78(u8 index, u16 arg1) { - AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index]; +void au_bus_set_volume(u8 index, u16 arg1) { + AuFxBus* fxBus = &gSynDriverPtr->fxBus[index]; - gamma->unk_00 = arg1 & 0x7FFF; + fxBus->gain = arg1 & 0x7FFF; } -u16 func_80056DA4(u8 index, u16 arg1) { - AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index]; +u16 au_bus_get_volume(u8 index, u16 arg1) { + AuFxBus* fxBus = &gSynDriverPtr->fxBus[index]; - return gamma->unk_00; + return fxBus->gain; } -void func_80056DCC(u8 index, u8 effectType) { - AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index]; +void au_bus_set_effect(u8 index, u8 effectType) { + AuFxBus* fxBus = &gSynDriverPtr->fxBus[index]; - gamma->currentEffectType = effectType; - func_8005904C(gamma->fxL, effectType); - func_8005904C(gamma->fxR, effectType); + fxBus->currentEffectType = effectType; + func_8005904C(fxBus->fxL, effectType); + func_8005904C(fxBus->fxR, effectType); } -void func_80056E34(u8 index, s16 delayIndex, s16 paramID, s32 value) { - AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index]; +void au_bus_set_fx_params(u8 index, s16 delayIndex, s16 paramID, s32 value) { + AuFxBus* fxBus = &gSynDriverPtr->fxBus[index]; - au_fx_param_hdl(gamma->fxL, delayIndex, paramID, value); - au_fx_param_hdl(gamma->fxR, delayIndex, paramID, value); + au_fx_param_hdl(fxBus->fxL, delayIndex, paramID, value); + au_fx_param_hdl(fxBus->fxR, delayIndex, paramID, value); } -void func_80056EC0(u8 index, s8 arg1) { +void au_pvoice_set_group(u8 index, s8 groupID) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[index]; - pvoice->gammaID = arg1; + pvoice->groupID = groupID; } -// n_alLoadParam case AL_FILTER_RESET -void au_pvoice_reset_filter(u8 voiceIdx) { +// based on n_alSynStopVoice +void au_syn_stop_voice(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - AuLoadFilter* filter = &pvoice->loadFilter; + AuLoadFilter* decoder = &pvoice->decoder; - pvoice->envMixer.em_motion = AL_STOPPED; - pvoice->envMixer.em_first = 1; - pvoice->envMixer.em_volume = 1; + pvoice->envMixer.motion = AL_STOPPED; + pvoice->envMixer.first = 1; + pvoice->envMixer.volume = 1; pvoice->resampler.delta = 0; pvoice->resampler.first = 1; - filter->dc_lastsam = 0; - filter->dc_first = 1; - filter->dc_sample = 0; - if (filter->instrument != NULL) { - filter->dc_memin = filter->instrument->base; - if (filter->instrument->type == 0) { - if (filter->instrument->loopEnd != 0){ - filter->dc_loop.count = filter->instrument->loopCount; + decoder->lastsam = 0; + decoder->first = 1; + decoder->sample = 0; + if (decoder->instrument != NULL) { + decoder->memin = (s32)decoder->instrument->base; + if (decoder->instrument->type == AL_ADPCM_WAVE) { + if (decoder->instrument->loopEnd != 0){ + decoder->loop.count = decoder->instrument->loopCount; } - } else if (filter->instrument->type == 1) { - if (filter->instrument->loopEnd != 0){ - filter->dc_loop.count = filter->instrument->loopCount; + } else if (decoder->instrument->type == AL_RAW16_WAVE) { + if (decoder->instrument->loopEnd != 0){ + decoder->loop.count = decoder->instrument->loopCount; } } } } -// n_alEnvmixerParam case AL_FILTER_START -void au_pvoice_set_playing(u8 index) { - AuPVoice* pvoice = (AuPVoice*)&gSynDriverPtr->pvoices[index]; +// based on n_alSynStartVoice, but without setting new wavetable +void au_syn_start_voice(u8 voiceIdx) { + AuPVoice* pvoice = (AuPVoice*)&gSynDriverPtr->pvoices[voiceIdx]; - pvoice->envMixer.em_motion = AL_PLAYING; + pvoice->envMixer.motion = AL_PLAYING; } -#define ADPCMFBYTES 9 - -// n_alLoadParam case AL_FILTER_SET_WAVETABLE -void au_pvoice_set_filter(u8 index, u8 reverbType, Instrument* instrument, f32 pitchRatio, s16 arg4, u8 pan, u8 reverb, s32 arg7) { - AuPVoice* pvoice = &gSynDriverPtr->pvoices[index]; - AuLoadFilter* filter = &pvoice->loadFilter; +// based on n_alSynStartVoiceParams +void au_syn_start_voice_params(u8 voiceIdx, u8 groupIdx, Instrument* instrument, f32 pitch, s16 vol, u8 pan, u8 fxMix, s32 delta) { + AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; + AuLoadFilter* decoder = &pvoice->decoder; AuEnvMixer* envMixer = &pvoice->envMixer; AuResampler* resampler = &pvoice->resampler; - pvoice->gammaID = reverbType; - filter->instrument = instrument; + pvoice->groupID = groupIdx; + decoder->instrument = instrument; - pvoice->loadFilter.dc_memin = filter->instrument->base; - pvoice->loadFilter.dc_sample = 0; + pvoice->decoder.memin = (s32)decoder->instrument->base; + pvoice->decoder.sample = 0; - switch (filter->instrument->type) { + switch (decoder->instrument->type) { case AL_ADPCM_WAVE: - filter->instrument->wavDataLength = (filter->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES; - pvoice->loadFilter.dc_bookSize = filter->instrument->dc_bookSize; - if (filter->instrument->loopEnd == 0) { - filter->dc_loop.count = 0; - filter->dc_loop.end = 0; - filter->dc_loop.start = 0; + decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES; + pvoice->decoder.bookSize = decoder->instrument->dc_bookSize; + if (decoder->instrument->loopEnd == 0) { + decoder->loop.count = 0; + decoder->loop.end = 0; + decoder->loop.start = 0; } else { - filter->dc_loop.start = filter->instrument->loopStart; - filter->dc_loop.end = filter->instrument->loopEnd; - filter->dc_loop.count = filter->instrument->loopCount; - alCopy(filter->instrument->loopPredictor, filter->dc_lstate, sizeof(ADPCM_STATE)); + decoder->loop.start = decoder->instrument->loopStart; + decoder->loop.end = decoder->instrument->loopEnd; + decoder->loop.count = decoder->instrument->loopCount; + alCopy(decoder->instrument->loopPredictor, decoder->lstate, sizeof(ADPCM_STATE)); } break; case AL_RAW16_WAVE: - if (filter->instrument->loopEnd != 0) { - filter->dc_loop.start = filter->instrument->loopStart; - filter->dc_loop.end = filter->instrument->loopEnd; - filter->dc_loop.count = filter->instrument->loopCount; + if (decoder->instrument->loopEnd != 0) { + decoder->loop.start = decoder->instrument->loopStart; + decoder->loop.end = decoder->instrument->loopEnd; + decoder->loop.count = decoder->instrument->loopCount; } else { - filter->dc_loop.count = 0; - filter->dc_loop.end = 0; - filter->dc_loop.start = 0; + decoder->loop.count = 0; + decoder->loop.end = 0; + decoder->loop.start = 0; } break; } - envMixer->em_motion = AL_PLAYING; - envMixer->em_first = 1; - envMixer->em_delta = 0; - envMixer->em_segEnd = arg7; - envMixer->em_pan = pan; - envMixer->em_volume = SQ(arg4) >> 0xF; - envMixer->em_dryamt = AuEqPower[reverb]; - envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - reverb]; - if (envMixer->em_segEnd != 0) { - envMixer->em_cvolL = 1; - envMixer->em_cvolR = 1; + envMixer->motion = AL_PLAYING; + envMixer->first = 1; + envMixer->delta = 0; + envMixer->segEnd = delta; + envMixer->pan = pan; + envMixer->volume = SQ(vol) >> 0xF; + envMixer->dryamt = AuEqPower[fxMix]; + envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix]; + if (envMixer->segEnd != 0) { + envMixer->cvolL = 1; + envMixer->cvolR = 1; } else { if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } - resampler->rs_ratio = pitchRatio; + resampler->ratio = pitch; } -void au_pvoice_set_filter_wavetable(u8 voiceIdx, Instrument* instrument) { +void au_syn_set_wavetable(u8 voiceIdx, Instrument* instrument) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - AuLoadFilter* filter = &pvoice->loadFilter; + AuLoadFilter* decoder = &pvoice->decoder; - pvoice->loadFilter.instrument = instrument; - pvoice->loadFilter.dc_memin = filter->instrument->base; - pvoice->loadFilter.dc_sample = 0; + pvoice->decoder.instrument = instrument; + pvoice->decoder.memin = (s32)decoder->instrument->base; + pvoice->decoder.sample = 0; - switch (filter->instrument->type) { + switch (decoder->instrument->type) { case AL_ADPCM_WAVE: - filter->instrument->wavDataLength = (filter->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES; - pvoice->loadFilter.dc_bookSize = filter->instrument->dc_bookSize; - if (filter->instrument->loopEnd == 0) { - pvoice->loadFilter.dc_loop.count = 0; - pvoice->loadFilter.dc_loop.end = 0; - pvoice->loadFilter.dc_loop.start = 0; + decoder->instrument->wavDataLength = (decoder->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES; + pvoice->decoder.bookSize = decoder->instrument->dc_bookSize; + if (decoder->instrument->loopEnd == 0) { + pvoice->decoder.loop.count = 0; + pvoice->decoder.loop.end = 0; + pvoice->decoder.loop.start = 0; } else { - pvoice->loadFilter.dc_loop.start = filter->instrument->loopStart; - pvoice->loadFilter.dc_loop.end = filter->instrument->loopEnd; - pvoice->loadFilter.dc_loop.count = filter->instrument->loopCount; - alCopy(filter->instrument->loopPredictor, pvoice->loadFilter.dc_lstate, sizeof(ADPCM_STATE)); + pvoice->decoder.loop.start = decoder->instrument->loopStart; + pvoice->decoder.loop.end = decoder->instrument->loopEnd; + pvoice->decoder.loop.count = decoder->instrument->loopCount; + alCopy(decoder->instrument->loopPredictor, pvoice->decoder.lstate, sizeof(ADPCM_STATE)); } break; case AL_RAW16_WAVE: - if (filter->instrument->loopEnd != 0) { - pvoice->loadFilter.dc_loop.start = filter->instrument->loopStart; - pvoice->loadFilter.dc_loop.end = filter->instrument->loopEnd; - pvoice->loadFilter.dc_loop.count = filter->instrument->loopCount; + if (decoder->instrument->loopEnd != 0) { + pvoice->decoder.loop.start = decoder->instrument->loopStart; + pvoice->decoder.loop.end = decoder->instrument->loopEnd; + pvoice->decoder.loop.count = decoder->instrument->loopCount; } else { - pvoice->loadFilter.dc_loop.count = 0; - pvoice->loadFilter.dc_loop.end = 0; - pvoice->loadFilter.dc_loop.start = 0; + pvoice->decoder.loop.count = 0; + pvoice->decoder.loop.end = 0; + pvoice->decoder.loop.start = 0; } break; } } -void au_pvoice_set_pitch_ratio(u8 voiceIdx, f32 pitchRatio) { +// based on n_alSynSetPitch +void au_syn_set_pitch(u8 voiceIdx, f32 pitch) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - pvoice->resampler.rs_ratio = pitchRatio; + pvoice->resampler.ratio = pitch; } -void func_8005736C(u8 voiceIdx, s16 volume, s32 arg2, u8 pan, u8 arg4) { +void au_syn_set_mixer_params(u8 voiceIdx, s16 volume, s32 delta, u8 pan, u8 fxMix) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; AuEnvMixer* envMixer = &pvoice->envMixer; - if (envMixer->em_delta >= envMixer->em_segEnd) { - envMixer->em_delta = envMixer->em_segEnd; + if (envMixer->delta >= envMixer->segEnd) { + envMixer->delta = envMixer->segEnd; if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } else { - envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl); - envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl); + envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl); + envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl); } - if (envMixer->em_cvolL == 0) { - envMixer->em_cvolL = 1; + if (envMixer->cvolL == 0) { + envMixer->cvolL = 1; } - if (envMixer->em_cvolR == 0) { - envMixer->em_cvolR = 1; + if (envMixer->cvolR == 0) { + envMixer->cvolR = 1; } - envMixer->em_delta = 0; - envMixer->em_segEnd = arg2; - envMixer->em_pan = pan; - envMixer->em_volume = SQ(volume) >> 0xF; - envMixer->em_dryamt = AuEqPower[arg4]; - envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - arg4]; - envMixer->em_first = 1; + envMixer->delta = 0; + envMixer->segEnd = delta; + envMixer->pan = pan; + envMixer->volume = SQ(volume) >> 0xF; + envMixer->dryamt = AuEqPower[fxMix]; + envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix]; + envMixer->first = 1; } -void func_80057548(u8 voiceIdx, u8 pan, u8 arg2) { +void au_syn_set_pan_fxmix(u8 voiceIdx, u8 pan, u8 fxMix) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; AuEnvMixer* envMixer = &pvoice->envMixer; - if (envMixer->em_delta >= envMixer->em_segEnd) { - envMixer->em_delta = envMixer->em_segEnd; + if (envMixer->delta >= envMixer->segEnd) { + envMixer->delta = envMixer->segEnd; if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } else { - envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl); - envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl); + envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl); + envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl); } - if (envMixer->em_cvolL == 0) { - envMixer->em_cvolL = 1; + if (envMixer->cvolL == 0) { + envMixer->cvolL = 1; } - if (envMixer->em_cvolR == 0) { - envMixer->em_cvolR = 1; + if (envMixer->cvolR == 0) { + envMixer->cvolR = 1; } - envMixer->em_pan = pan; - envMixer->em_dryamt = AuEqPower[arg2]; - envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - arg2]; - envMixer->em_first = 1; + envMixer->pan = pan; + envMixer->dryamt = AuEqPower[fxMix]; + envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix]; + envMixer->first = 1; } -void func_800576EC(u8 voiceIdx, s16 arg1, s32 arg2) { +void au_syn_set_volume_delta(u8 voiceIdx, s16 vol, s32 delta) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; AuEnvMixer* envMixer = &pvoice->envMixer; - if (envMixer->em_delta >= envMixer->em_segEnd) { - envMixer->em_delta = envMixer->em_segEnd; + if (envMixer->delta >= envMixer->segEnd) { + envMixer->delta = envMixer->segEnd; if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } else { - envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl); - envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl); + envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl); + envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl); } - if (envMixer->em_cvolL == 0) { - envMixer->em_cvolL = 1; + if (envMixer->cvolL == 0) { + envMixer->cvolL = 1; } - if (envMixer->em_cvolR == 0) { - envMixer->em_cvolR = 1; + if (envMixer->cvolR == 0) { + envMixer->cvolR = 1; } - envMixer->em_volume = SQ(arg1) >> 0xF; - envMixer->em_delta = 0; - envMixer->em_segEnd = arg2; - envMixer->em_first = 1; + envMixer->volume = SQ(vol) >> 0xF; + envMixer->delta = 0; + envMixer->segEnd = delta; + envMixer->first = 1; } -void func_80057874(u8 voiceIdx, u8 pan) { +void au_syn_set_pan(u8 voiceIdx, u8 pan) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; AuEnvMixer* envMixer = &pvoice->envMixer; - if (envMixer->em_delta >= envMixer->em_segEnd) { - envMixer->em_delta = envMixer->em_segEnd; + if (envMixer->delta >= envMixer->segEnd) { + envMixer->delta = envMixer->segEnd; if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } else { - envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl); - envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl); + envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl); + envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl); } - if (envMixer->em_cvolL == 0) { - envMixer->em_cvolL = 1; + if (envMixer->cvolL == 0) { + envMixer->cvolL = 1; } - if (envMixer->em_cvolR == 0) { - envMixer->em_cvolR = 1; + if (envMixer->cvolR == 0) { + envMixer->cvolR = 1; } - envMixer->em_pan = pan; - envMixer->em_first = 1; + envMixer->pan = pan; + envMixer->first = 1; } -void func_800579D8(u8 voiceIdx, u8 dryAmt) { +void au_syn_set_fxmix(u8 voiceIdx, u8 fxMix) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; AuEnvMixer* envMixer = &pvoice->envMixer; - if (envMixer->em_delta >= envMixer->em_segEnd) { - envMixer->em_delta = envMixer->em_segEnd; + if (envMixer->delta >= envMixer->segEnd) { + envMixer->delta = envMixer->segEnd; if (!AuSynUseStereo) { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF; } else { - envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF; - envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF; + envMixer->cvolL = (envMixer->volume * AuEqPower[envMixer->pan]) >> 0xF; + envMixer->cvolR = (envMixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->pan]) >> 0xF; } } else { - envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl); - envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl); + envMixer->cvolL = _getVol(envMixer->cvolL, envMixer->delta, envMixer->lratm, envMixer->lratl); + envMixer->cvolR = _getVol(envMixer->cvolR, envMixer->delta, envMixer->rratm, envMixer->rratl); } - if (envMixer->em_cvolL == 0) { - envMixer->em_cvolL = 1; + if (envMixer->cvolL == 0) { + envMixer->cvolL = 1; } - if (envMixer->em_cvolR == 0) { - envMixer->em_cvolR = 1; + if (envMixer->cvolR == 0) { + envMixer->cvolR = 1; } - envMixer->em_dryamt = AuEqPower[dryAmt]; - envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - dryAmt]; - envMixer->em_first = 1; + envMixer->dryamt = AuEqPower[fxMix]; + envMixer->wetamt = AuEqPower[AU_EQPOW_MAX_IDX - fxMix]; + envMixer->first = 1; } -s32 func_80057B64(u8 voiceIdx) { +s32 au_syn_get_playing(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->envMixer.em_motion; + return pvoice->envMixer.motion; } -s32 func_80057B8C(u8 voiceIdx) { +s32 au_syn_get_bus(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->gammaID; + return pvoice->groupID; } -f32 func_80057BB4(u8 voiceIdx) { +f32 au_syn_get_pitch(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->resampler.rs_ratio; + return pvoice->resampler.ratio; } -u8 func_80057BDC(u8 voiceIdx) { +u8 au_syn_get_pan(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->envMixer.em_pan; + return pvoice->envMixer.pan; } -s16 func_80057C04(u8 voiceIdx) { +s16 au_syn_get_dryamt(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->envMixer.em_dryamt; + return pvoice->envMixer.dryamt; } -s16 func_80057C2C(u8 voiceIdx) { +s16 au_syn_get_wetamt(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - return pvoice->envMixer.em_wetamt; + return pvoice->envMixer.wetamt; } -s32 func_80057C54(u8 voiceIdx) { +s32 au_syn_get_volume_left(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - AuEnvMixer* sub48 = &pvoice->envMixer; + AuEnvMixer* envmixer = &pvoice->envMixer; u32 retVal; - if (sub48->em_delta >= sub48->em_segEnd) { + if (envmixer->delta >= envmixer->segEnd) { if (!AuSynUseStereo) { - retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10; + retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10; } else { - retVal = (sub48->em_volume * AuEqPower[sub48->em_pan] * 2) >> 0x10; + retVal = (envmixer->volume * AuEqPower[envmixer->pan] * 2) >> 0x10; } } else { - retVal = _getVol(sub48->em_cvolL, sub48->em_delta, sub48->em_lratm, sub48->em_lratl); + retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl); } return retVal; } -s32 func_80057D0C(u8 voiceIdx) { +s32 au_syn_get_volume_right(u8 voiceIdx) { AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx]; - AuEnvMixer* sub48 = &pvoice->envMixer; + AuEnvMixer* envmixer = &pvoice->envMixer; u32 retVal; - if (sub48->em_delta >= sub48->em_segEnd) { + if (envmixer->delta >= envmixer->segEnd) { if (!AuSynUseStereo) { - retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10; + retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10; } else { - retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - sub48->em_pan] * 2) >> 0x10; + retVal = (envmixer->volume * AuEqPower[AU_EQPOW_MAX_IDX - envmixer->pan] * 2) >> 0x10; } } else { - retVal = _getVol(sub48->em_cvolL, sub48->em_delta, sub48->em_lratm, sub48->em_lratl); + retVal = _getVol(envmixer->cvolL, envmixer->delta, envmixer->lratm, envmixer->lratl); } return retVal; } -void func_80057DC8(s32 arg0) { +void au_set_delay_time(s32 arg0) { if (arg0 < 2) { - D_800A3FF0 = 0; - D_800A3FEE = 0; + AuDelayCount = 0; + AuDelayedChannel = 0; } - D_800A3FF0 = arg0; - if (arg0 >= 5) { - D_800A3FF0 = 4; + AuDelayCount = arg0; + if (arg0 > 4) { + AuDelayCount = 4; } } -void func_80057E08(u8 arg0) { - s32* phi_a1 = (s32*)D_800A3FE0; - s32* phi_v1 = (s32*)D_800A3FE4; +void au_delay_left_channel(u8 groupIdx) { + s32* phi_a1 = (s32*)AuDelayBufferMain; + s32* phi_v1 = (s32*)AuDelayBufferAux; s32 i; for (i = 0; i < 2 * AUDIO_SAMPLES; i++) { @@ -668,14 +674,14 @@ void func_80057E08(u8 arg0) { *phi_v1++ = 0; } - D_800A3FEC = arg0; - D_800A3FEE = 1; - D_800A3FE8 = 0; + AuDelayedVoiceGroup = groupIdx; + AuDelayedChannel = 1; + AuDelayCounter = 0; } -void func_80057E5C(u8 arg0) { - s32* phi_a1 = (s32*)D_800A3FE0; - s32* phi_v1 = (s32*)D_800A3FE4; +void au_delay_right_channel(u8 groupIdx) { + s32* phi_a1 = (s32*)AuDelayBufferMain; + s32* phi_v1 = (s32*)AuDelayBufferAux; s32 i; for (i = 0; i < 2 * AUDIO_SAMPLES; i++) { @@ -683,20 +689,20 @@ void func_80057E5C(u8 arg0) { *phi_v1++ = 0; } - D_800A3FEC = arg0; - D_800A3FEE = 2; - D_800A3FE8 = 0; + AuDelayedVoiceGroup = groupIdx; + AuDelayedChannel = 2; + AuDelayCounter = 0; } -void func_80057EB0(void) { - D_800A3FEC = 0; - D_800A3FEE = 0; - D_800A3FE8 = 0; +void au_disable_channel_delay(void) { + AuDelayedVoiceGroup = 0; + AuDelayedChannel = 0; + AuDelayCounter = 0; } -void func_80057ED0(s16 arg0) { - s32* phi_a1 = (s32*)D_800A3FE0; - s32* phi_v1 = (s32*)D_800A3FE4; +void au_delay_channel(s16 arg0) { + s32* phi_a1 = (s32*)AuDelayBufferMain; + s32* phi_v1 = (s32*)AuDelayBufferAux; s32 i; for (i = 0; i < 2 * AUDIO_SAMPLES; i++) { @@ -704,9 +710,9 @@ void func_80057ED0(s16 arg0) { *phi_v1++ = 0; } - D_800A3FEC = 0; - D_800A3FEE = arg0; - D_800A3FE8 = 0; + AuDelayedVoiceGroup = 0; + AuDelayedChannel = arg0; + AuDelayCounter = 0; } void alHeapInit(ALHeap* hp, u8* base, s32 len) { diff --git a/src/audio/33450.c b/src/audio/33450.c index 6b70935cbd..2418e67fb6 100644 --- a/src/audio/33450.c +++ b/src/audio/33450.c @@ -1,9 +1,12 @@ #include "common.h" #include "audio.h" +#define LFSAMPLES 4 +#define AUEQPOWER_LENGTH 128 + // values for cosine from 0 to pi/2 multiplied by 32767 // called n_eqpower in libultra -s16 AuEqPower[128] = { +s16 AuEqPower[AUEQPOWER_LENGTH] = { 32767, 32764, 32757, 32744, 32727, 32704, 32677, 32644, 32607, 32564, 32517, 32464, 32407, 32344, 32277, 32205, 32127, 32045, 31958, 31866, 31770, 31668, 31561, 31450, @@ -25,8 +28,269 @@ s16 AuEqPower[128] = { static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* arg1, s32 count, s32 size, s16 arg4, s16 arg5, s32 flags); static s16 _getRate(f64 arg0, f64 arg1, s32 arg4, u16* arg5); -// au_pull_voice -- based on n_alAdpcmPull -INCLUDE_ASM(s32, "audio/33450", func_80058050); +// decode, resample and mix +Acmd* au_pull_voice(AuPVoice* pvoice, Acmd* cmdBufPos) { + Acmd* ptr = cmdBufPos; + AuLoadFilter* decoder; + AuResampler* resampler; + AuEnvMixer* envMixer; + s16 inp; + f32 finCount; + s16 outp; + s32 startZero; + s32 outCount; + s32 incr; + + envMixer = &pvoice->envMixer; + resampler = &pvoice->resampler; + decoder = &pvoice->decoder; + + if (envMixer->motion != AL_PLAYING) { + return ptr; + } + outp = N_AL_DECODER_OUT; + if (resampler->ratio > MAX_RATIO) { + resampler->ratio = MAX_RATIO; + } + + resampler->ratio = (s32)(resampler->ratio * UNITY_PITCH); + resampler->ratio = resampler->ratio / UNITY_PITCH; + finCount = resampler->delta + resampler->ratio * (f32)184; + outCount = (s32) finCount; + resampler->delta = finCount - (f32) outCount; + if (outCount != 0) { + if (decoder->instrument->type == AL_ADPCM_WAVE) { + s32 nSam; + s32 nbytes; + s32 nframes; + s32 op; + s32 tsam; + s32 nLeft; + s32 bEnd; + s32 nOver; + s32 overFlow; + s32 decoded = FALSE; + s32 looped = FALSE; + inp = N_AL_DECODER_IN; + + aLoadADPCM(ptr++, decoder->bookSize, K0_TO_PHYS(decoder->instrument->predictor)); + + looped = (decoder->loop.end < outCount + decoder->sample) && (decoder->loop.count != 0); + + if (looped) { + nSam = decoder->loop.end - decoder->sample; + } else { + nSam = outCount; + } + if (decoder->lastsam != 0) { + nLeft = ADPCMFSIZE - decoder->lastsam; + } else { + nLeft = 0; + } + tsam = nSam - nLeft; + if (tsam < 0) { + tsam = 0; + } + nframes = (tsam + ADPCMFSIZE - 1) >> LFSAMPLES; + nbytes = nframes * ADPCMFBYTES; + if (looped) { + ptr = _decodeChunk(ptr, decoder, tsam, nbytes, outp, inp, decoder->first); + if (decoder->lastsam != 0) { + outp += (decoder->lastsam << 1); + } else { + outp += (ADPCMFSIZE << 1); + } + + decoder->lastsam = decoder->loop.start & 0xF; + decoder->memin = (s32)decoder->instrument->base + ADPCMFBYTES * ((s32)(decoder->loop.start >> LFSAMPLES) + 1); + decoder->sample = decoder->loop.start; + bEnd = outp; + while (outCount > nSam) { + outCount -= nSam; + op = (bEnd + ((nframes + 1) << (LFSAMPLES + 1)) + 16) & ~0x1f; + bEnd += nSam << 1; + if (decoder->loop.count != -1 && decoder->loop.count != 0) { + decoder->loop.count--; + } + nSam = MIN(outCount, decoder->loop.end - decoder->loop.start); + tsam = nSam - ADPCMFSIZE + decoder->lastsam; + if (tsam < 0) { + tsam = 0; + } + nframes = (tsam + ADPCMFSIZE - 1) >> LFSAMPLES; + nbytes = nframes * ADPCMFBYTES; + ptr = _decodeChunk(ptr, decoder, tsam, nbytes, op, inp, decoder->first | A_LOOP); + aDMEMMove(ptr++, op + (decoder->lastsam << 1), bEnd, nSam << 1); + } + decoder->lastsam = (outCount + decoder->lastsam) & 0xF; + decoder->sample += outCount; + decoder->memin += ADPCMFBYTES * nframes; + } else { + nSam = nframes << LFSAMPLES; + overFlow = decoder->memin + nbytes - ((s32)decoder->instrument->base + decoder->instrument->wavDataLength); + + if (overFlow <= 0) { + overFlow = 0; + } else { + envMixer->motion = AL_STOPPED; + } + nOver = (overFlow / ADPCMFBYTES) << LFSAMPLES; + if (nOver > nSam + nLeft) { + nOver = nSam + nLeft; + } + nbytes -= overFlow; + if (nOver - (nOver & 0xF) < outCount) { + decoded = TRUE; + ptr = _decodeChunk(ptr, decoder, nSam - nOver, nbytes, outp, inp, decoder->first); + if (decoder->lastsam != 0) { + outp += decoder->lastsam << 1; + } else { + outp += ADPCMFSIZE << 1; + } + decoder->lastsam = (outCount + decoder->lastsam) & 0xF; + decoder->sample += outCount; + decoder->memin += ADPCMFBYTES * nframes; + } else { + decoder->lastsam = 0; + decoder->memin += ADPCMFBYTES * nframes; + } + + if (nOver != 0) { + decoder->lastsam = 0; + if (decoded) { + startZero = (nLeft + nSam - nOver) << 1; + } else { + startZero = 0; + } + aClearBuffer(ptr++, startZero + outp, nOver << 1); + } + } + } else { + s32 nSam; + s32 nbytes; + s32 op; + s32 dramAlign; + s32 dramLoc; + s32 dmemAlign; + s32 overFlow; + if (decoder->loop.end < outCount + decoder->sample && decoder->loop.count != 0) { + nSam = decoder->loop.end - decoder->sample; + nbytes = nSam << 1; + if (nSam > 0) { + dramLoc = decoder->dmaFunc(decoder->memin, nbytes, decoder->dmaState, decoder->instrument->unk_25); + dramAlign = dramLoc & 7; + nbytes += dramAlign; + n_aLoadBuffer(ptr++, nbytes + 8 - (nbytes & 7), outp, dramLoc - dramAlign); + } else { + dramAlign = 0; + } + outp += dramAlign; + decoder->memin = (s32)decoder->instrument->base + (decoder->loop.start << 1); + decoder->sample = decoder->loop.start; + op = outp; + while (outCount > nSam){ + op += nSam << 1; + outCount -= nSam; + if (decoder->loop.count != -1 && decoder->loop.count != 0) { + decoder->loop.count--; + } + nSam = MIN(outCount, decoder->loop.end - decoder->loop.start); + nbytes = nSam << 1; + dramLoc = decoder->dmaFunc(decoder->memin, nbytes, decoder->dmaState, decoder->instrument->unk_25); + dramAlign = dramLoc & 7; + nbytes += dramAlign; + if ((op & 7) != 0) { + dmemAlign = 8 - (op & 7); + } else { + dmemAlign = 0; + } + n_aLoadBuffer(ptr++, nbytes + 8 - (nbytes & 7), op + dmemAlign, dramLoc - dramAlign); + + if (dramAlign != 0 || dmemAlign != 0) { + aDMEMMove(ptr++, op + dramAlign + dmemAlign, op, nSam * 2); + } + } + decoder->sample += outCount; + decoder->memin += outCount << 1; + } else { + nbytes = outCount << 1; + overFlow = decoder->memin + nbytes - ((s32)decoder->instrument->base + decoder->instrument->wavDataLength); + if (overFlow <= 0) { + overFlow = 0; + } else { + envMixer->motion = AL_STOPPED; + } + if (nbytes < overFlow) { + overFlow = nbytes; + } + if (overFlow < nbytes) { + if (outCount > 0) { + nbytes -= overFlow; + dramLoc = decoder->dmaFunc(decoder->memin, nbytes, decoder->dmaState, decoder->instrument->unk_25); + dramAlign = dramLoc & 7; + nbytes += dramAlign; + n_aLoadBuffer(ptr++, nbytes + 8 - (nbytes & 7), outp, dramLoc - dramAlign); + } else { + dramAlign = 0; + } + outp += dramAlign; + decoder->sample += outCount; + decoder->memin += outCount << 1; + } else { + decoder->memin += outCount << 1; + } + + if (overFlow != 0) { + startZero = (outCount << 1) - overFlow; + if (startZero < 0) { + startZero = 0; + } + aClearBuffer(ptr++, startZero + outp, overFlow); + } + } + } + } + incr = (s32)(resampler->ratio * UNITY_PITCH); + n_aResample(ptr++, osVirtualToPhysical(resampler->state), resampler->first, incr, outp, 0); + resampler->first = 0; + + if (envMixer->first != 0) { + envMixer->first = 0; + if (!AuSynUseStereo) { + envMixer->ltgt = (envMixer->volume * AuEqPower[AUEQPOWER_LENGTH / 2]) >> 15; + envMixer->rtgt = (envMixer->volume * AuEqPower[AUEQPOWER_LENGTH / 2]) >> 15; + } else { + envMixer->ltgt = (envMixer->volume * AuEqPower[envMixer->pan]) >> 15; + envMixer->rtgt = (envMixer->volume * AuEqPower[AUEQPOWER_LENGTH - envMixer->pan - 1]) >> 15; + } + envMixer->lratm = _getRate(envMixer->cvolL, envMixer->ltgt, envMixer->segEnd, &envMixer->lratl); + envMixer->rratm = _getRate(envMixer->cvolR, envMixer->rtgt, envMixer->segEnd, &envMixer->rratl); + n_aSetVolume(ptr++, A_RATE, envMixer->ltgt, envMixer->lratm, envMixer->lratl); + n_aSetVolume(ptr++, A_LEFT | A_VOL, envMixer->cvolL, envMixer->dryamt, envMixer->wetamt); + n_aSetVolume(ptr++, A_RIGHT | A_VOL, envMixer->rtgt, envMixer->rratm, envMixer->rratl); + n_aEnvMixer(ptr++, A_INIT, envMixer->cvolR, osVirtualToPhysical(envMixer->state)); + } else { + n_aEnvMixer(ptr++, A_CONTINUE, 0, osVirtualToPhysical(envMixer->state)); + } + + envMixer->delta += AUDIO_SAMPLES; + if (envMixer->segEnd < envMixer->delta) { + envMixer->delta = envMixer->segEnd; + } + if (envMixer->motion == AL_STOPPED) { + envMixer->first = 1; + envMixer->volume = 1; + resampler->delta = 0.0f; + resampler->first = 1; + decoder->lastsam = 0; + decoder->first = 1; + decoder->sample = 0; + decoder->memin = (s32) decoder->instrument->base; + decoder->loop.count = decoder->instrument->loopCount; + func_80052E30(pvoice->index); + } + return ptr; +} static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* filter, s32 tsam, s32 nbytes, s16 output, s16 input, s32 flags) { s32 endAddr; @@ -34,7 +298,7 @@ static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* filter, s32 tsam, s32 n s32 paddedSize; if (nbytes > 0) { - endAddr = filter->dc_dmaFunc((s32) filter->dc_memin, nbytes, filter->dc_dmaState, filter->instrument->unk_25); + endAddr = filter->dmaFunc((s32) filter->memin, nbytes, filter->dmaState, filter->instrument->unk_25); endAlign = endAddr & 7; nbytes += endAlign; paddedSize = nbytes + 8 - (nbytes & 7); @@ -44,12 +308,12 @@ static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* filter, s32 tsam, s32 n } if (flags & A_LOOP) { - aSetLoop(cmdBufPos++, K0_TO_PHYS(filter->dc_lstate)); + aSetLoop(cmdBufPos++, K0_TO_PHYS(filter->lstate)); } - n_aADPCMdec(cmdBufPos++, filter->dc_state, flags, tsam << 1, endAlign, output); + n_aADPCMdec(cmdBufPos++, filter->state, flags, tsam << 1, endAlign, output); - filter->dc_first = 0; + filter->first = 0; return cmdBufPos; } diff --git a/src/audio/private.h b/src/audio/private.h index b3ec118459..8da8669845 100644 --- a/src/audio/private.h +++ b/src/audio/private.h @@ -84,7 +84,7 @@ void nuAuMgr(void* arg); s32 nuAuDmaCallBack(s32 addr, s32 len, void *state, u8 arg3); //ALDMAproc nuAuDmaNew(NUDMAState** state); //void nuAuCleanDMABuffers(void); -void func_8004B328(NUScMsg mesg_type, u32 frameCounter); +//void nuAuPreNMIProc(NUScMsg mesg_type, u32 frameCounter); //void alLink(ALLink* element, ALLink* after); //void alUnlink(ALLink* element); @@ -248,52 +248,52 @@ void func_80056228(void); void au_driver_init(AuSynDriver* driver, ALConfig* config); void au_driver_release(void); //Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen); -void func_80056D34(void); -void func_80056D44(s16 arg0); -s16 func_80056D50(void); +void au_use_global_volume(void); +void au_set_global_volume(s16 arg0); +s16 au_get_global_volume(void); void func_80056D5C(u8 arg0); -void func_80056D78(u8 arg0, u16 arg1); -u16 func_80056DA4(u8 arg0, u16 arg1); -void func_80056DCC(u8 arg0, u8 effectID); -void func_80056E34(u8 arg0, s16 arg1, s16 arg2, s32 arg3); -void func_80056EC0(u8 arg0, s8 arg1); -void au_pvoice_reset_filter(u8 voiceIdx); -void au_pvoice_set_playing(u8 index); -void au_pvoice_set_filter(u8 index, u8 reverbType, Instrument* table, f32 pitchRatio, s16 arg4, u8 pan, u8 reverb, s32 arg7); -void au_pvoice_set_filter_wavetable(u8 voiceIdx, Instrument* table); -void au_pvoice_set_pitch_ratio(u8 voiceIdx, f32 pitchRatio); -void func_8005736C(u8 voiceIdx, s16 volume, s32 arg2, u8 arg3, u8 arg4); -void func_80057548(u8 voiceIdx, u8 arg1, u8 arg2); -void func_800576EC(u8 voiceIdx, s16 arg1, s32 arg2); -void func_80057874(u8 voiceIdx, u8 pan); -void func_800579D8(u8 voiceIdx, u8 dryAmt); -s32 func_80057B64(u8 voiceIdx); -s32 func_80057B8C(u8 voiceIdx); -f32 func_80057BB4(u8 voiceIdx); -u8 func_80057BDC(u8 voiceIdx); -s16 func_80057C04(u8 voiceIdx); -s16 func_80057C2C(u8 voiceIdx); -s32 func_80057C54(u8 voiceIdx); -s32 func_80057D0C(u8 voiceIdx); -void func_80057DC8(s32 arg0); -void func_80057E08(u8 arg0); -void func_80057E5C(u8 arg0); -void func_80057EB0(void); -void func_80057ED0(s16 arg0); +void au_bus_set_volume(u8 arg0, u16 arg1); +u16 au_bus_get_volume(u8 arg0, u16 arg1); +void au_bus_set_effect(u8 arg0, u8 effectID); +void au_bus_set_fx_params(u8 arg0, s16 arg1, s16 arg2, s32 arg3); +void au_pvoice_set_group(u8 arg0, s8 arg1); +void au_syn_stop_voice(u8 voiceIdx); +void au_syn_start_voice(u8 index); +void au_syn_start_voice_params(u8 index, u8 reverbType, Instrument* table, f32 pitch, s16 vol, u8 pan, u8 fxMix, s32 delta); +void au_syn_set_wavetable(u8 voiceIdx, Instrument* table); +void au_syn_set_pitch(u8 voiceIdx, f32 pitchRatio); +void au_syn_set_mixer_params(u8 voiceIdx, s16 volume, s32 arg2, u8 arg3, u8 arg4); +void au_syn_set_pan_fxmix(u8 voiceIdx, u8 arg1, u8 arg2); +void au_syn_set_volume_delta(u8 voiceIdx, s16 arg1, s32 arg2); +void au_syn_set_pan(u8 voiceIdx, u8 pan); +void au_syn_set_fxmix(u8 voiceIdx, u8 dryAmt); +s32 au_syn_get_playing(u8 voiceIdx); +s32 au_syn_get_bus(u8 voiceIdx); +f32 au_syn_get_pitch(u8 voiceIdx); +u8 au_syn_get_pan(u8 voiceIdx); +s16 au_syn_get_dryamt(u8 voiceIdx); +s16 au_syn_get_wetamt(u8 voiceIdx); +s32 au_syn_get_volume_left(u8 voiceIdx); +s32 au_syn_get_volume_right(u8 voiceIdx); +void au_set_delay_time(s32 arg0); +void au_delay_left_channel(u8 arg0); +void au_delay_right_channel(u8 arg0); +void au_disable_channel_delay(void); +void au_delay_channel(s16 arg0); //void alHeapInit(ALHeap* hp, u8* base, s32 len); //void alCopy(void* src, void* dst, s32 size); #undef alHeapAlloc void* alHeapAlloc(ALHeap* heap, s32 arg1, s32 size); // 33450.c -Acmd* func_80058050(AuPVoice* pvoice, Acmd* cmdBufPos); +Acmd* au_pull_voice(AuPVoice* pvoice, Acmd* cmdBufPos); // reverb.c void func_80058E84(AuFX* fx, u8 mode, ALHeap* heap); void func_80058F88(AlUnkKappa* kappa, ALHeap* heap); void func_80059008(AlUnkKappa* kappa, s16 arg1, s16 arg2, s16 fc); void func_8005904C(AuFX* fx, u8 effectType); -Acmd* func_80059310(AuFX* fx, Acmd* cmdBusPos, s16, s16); +Acmd* au_pull_fx(AuFX* fx, Acmd* cmdBusPos, s16, s16); s32 au_fx_param_hdl(AuFX* fx, s16 index, s16 paramID, s32 value); // sfx.c diff --git a/src/audio/reverb.c b/src/audio/reverb.c index 05a91967bb..65c8d6e471 100644 --- a/src/audio/reverb.c +++ b/src/audio/reverb.c @@ -145,7 +145,7 @@ void func_80058E84(AuFX* fx, u8 effectType, ALHeap* heap) { for (i = 0; i < AU_FX_DELAY_COUNT; i++) { delay = &fx->delays[i]; delay->resampler_2C = alHeapAlloc(heap, 1, sizeof(AuResampler)); - delay->resampler_2C->rs_state = alHeapAlloc(heap, 1, sizeof(RESAMPLE_STATE)); + delay->resampler_2C->state = alHeapAlloc(heap, 1, sizeof(RESAMPLE_STATE)); delay->lowpass_24 = alHeapAlloc(heap, 1, sizeof(AuLowPass)); delay->lowpass_24->fstate = alHeapAlloc(heap, 1, sizeof(POLEF_STATE)); } @@ -264,7 +264,7 @@ void func_8005904C(AuFX* fx, u8 effectType) { // au_pull_fx -- based on alFxPull // AuFX from gSynDriverPtr -Acmd* func_80059310(AuFX* fx, Acmd* ptr, s16 outputBuf, s16 arg3) { +Acmd* au_pull_fx(AuFX* fx, Acmd* ptr, s16 outputBuf, s16 arg3) { Acmd* cmdBufPos = ptr; s16 delayIdx; @@ -328,7 +328,7 @@ Acmd* func_80059310(AuFX* fx, Acmd* ptr, s16 outputBuf, s16 arg3) { ratio = fratio * fUnityPitch; tmp = buff2 >> 8; - n_aResample(cmdBufPos++, osVirtualToPhysical(delay->resampler_28->rs_state), + n_aResample(cmdBufPos++, osVirtualToPhysical(delay->resampler_28->state), delay->resampler_28->first, ratio, rbuff + (ramAlign<<1), tmp); delay->resampler_28->first = 0; diff --git a/ver/us/asm/bss.s b/ver/us/asm/bss.s index d6b06a0181..c961cf0978 100644 --- a/ver/us/asm/bss.s +++ b/ver/us/asm/bss.s @@ -469,7 +469,7 @@ dlabel D_800A0F44 dlabel D_800A0F48 .space 8 -dlabel D_800A0F50 +dlabel AuInitialGlobalVolume .space 4 dlabel D_800A0F54 @@ -535,22 +535,22 @@ dlabel CurrentSeqCmdHandler dlabel D_800A3FD4 .space 0x0000000c -dlabel D_800A3FE0 +dlabel AuDelayBufferMain .space 4 -dlabel D_800A3FE4 +dlabel AuDelayBufferAux .space 4 -dlabel D_800A3FE8 +dlabel AuDelayCounter .space 4 -dlabel D_800A3FEC +dlabel AuDelayedVoiceGroup .space 2 -dlabel D_800A3FEE +dlabel AuDelayedChannel .space 2 -dlabel D_800A3FF0 +dlabel AuDelayCount .space 4 dlabel D_800A3FF4 diff --git a/ver/us/asm/nonmatchings/audio/33450/func_80058050.s b/ver/us/asm/nonmatchings/audio/33450/func_80058050.s deleted file mode 100644 index e20e3fc835..0000000000 --- a/ver/us/asm/nonmatchings/audio/33450/func_80058050.s +++ /dev/null @@ -1,752 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.section .rodata - -dlabel D_80098930 -.double 1.99996 - -.section .text - -glabel func_80058050 -/* 33450 80058050 27BDFFA0 */ addiu $sp, $sp, -0x60 -/* 33454 80058054 AFB60050 */ sw $s6, 0x50($sp) -/* 33458 80058058 00A0B02D */ daddu $s6, $a1, $zero -/* 3345C 8005805C AFB1003C */ sw $s1, 0x3c($sp) -/* 33460 80058060 02C0882D */ daddu $s1, $s6, $zero -/* 33464 80058064 AFB70054 */ sw $s7, 0x54($sp) -/* 33468 80058068 AFA40060 */ sw $a0, 0x60($sp) -/* 3346C 8005806C 24970048 */ addiu $s7, $a0, 0x48 -/* 33470 80058070 24880038 */ addiu $t0, $a0, 0x38 -/* 33474 80058074 AFB20040 */ sw $s2, 0x40($sp) -/* 33478 80058078 AFBF005C */ sw $ra, 0x5c($sp) -/* 3347C 8005807C AFBE0058 */ sw $fp, 0x58($sp) -/* 33480 80058080 AFB5004C */ sw $s5, 0x4c($sp) -/* 33484 80058084 AFB40048 */ sw $s4, 0x48($sp) -/* 33488 80058088 AFB30044 */ sw $s3, 0x44($sp) -/* 3348C 8005808C AFB00038 */ sw $s0, 0x38($sp) -/* 33490 80058090 AFA80020 */ sw $t0, 0x20($sp) -/* 33494 80058094 8C830070 */ lw $v1, 0x70($a0) -/* 33498 80058098 24020001 */ addiu $v0, $zero, 1 -/* 3349C 8005809C 14620293 */ bne $v1, $v0, .L80058AEC -/* 334A0 800580A0 24920004 */ addiu $s2, $a0, 4 -/* 334A4 800580A4 8FA80060 */ lw $t0, 0x60($sp) -/* 334A8 800580A8 C500003C */ lwc1 $f0, 0x3c($t0) -/* 334AC 800580AC 3C01800A */ lui $at, %hi(D_80098930) -/* 334B0 800580B0 D4228930 */ ldc1 $f2, %lo(D_80098930)($at) -/* 334B4 800580B4 46000021 */ cvt.d.s $f0, $f0 -/* 334B8 800580B8 4620103C */ c.lt.d $f2, $f0 -/* 334BC 800580BC 00000000 */ nop -/* 334C0 800580C0 45000007 */ bc1f .L800580E0 -/* 334C4 800580C4 241E0170 */ addiu $fp, $zero, 0x170 -/* 334C8 800580C8 3C013FFF */ lui $at, 0x3fff -/* 334CC 800580CC 3421FEB0 */ ori $at, $at, 0xfeb0 -/* 334D0 800580D0 44810000 */ mtc1 $at, $f0 -/* 334D4 800580D4 00000000 */ nop -/* 334D8 800580D8 E500003C */ swc1 $f0, 0x3c($t0) -/* 334DC 800580DC 8FA80060 */ lw $t0, 0x60($sp) -.L800580E0: -/* 334E0 800580E0 3C014700 */ lui $at, 0x4700 -/* 334E4 800580E4 44811000 */ mtc1 $at, $f2 -/* 334E8 800580E8 C500003C */ lwc1 $f0, 0x3c($t0) -/* 334EC 800580EC 46020002 */ mul.s $f0, $f0, $f2 -/* 334F0 800580F0 00000000 */ nop -/* 334F4 800580F4 4600018D */ trunc.w.s $f6, $f0 -/* 334F8 800580F8 44023000 */ mfc1 $v0, $f6 -/* 334FC 800580FC 3C013800 */ lui $at, 0x3800 -/* 33500 80058100 44810000 */ mtc1 $at, $f0 -/* 33504 80058104 44822000 */ mtc1 $v0, $f4 -/* 33508 80058108 00000000 */ nop -/* 3350C 8005810C 46802120 */ cvt.s.w $f4, $f4 -/* 33510 80058110 46002102 */ mul.s $f4, $f4, $f0 -/* 33514 80058114 00000000 */ nop -/* 33518 80058118 3C014338 */ lui $at, 0x4338 -/* 3351C 8005811C 44810000 */ mtc1 $at, $f0 -/* 33520 80058120 00000000 */ nop -/* 33524 80058124 46002002 */ mul.s $f0, $f4, $f0 -/* 33528 80058128 00000000 */ nop -/* 3352C 8005812C 8FA80060 */ lw $t0, 0x60($sp) -/* 33530 80058130 C5020040 */ lwc1 $f2, 0x40($t0) -/* 33534 80058134 46001080 */ add.s $f2, $f2, $f0 -/* 33538 80058138 4600118D */ trunc.w.s $f6, $f2 -/* 3353C 8005813C 44143000 */ mfc1 $s4, $f6 -/* 33540 80058140 00000000 */ nop -/* 33544 80058144 44940000 */ mtc1 $s4, $f0 -/* 33548 80058148 00000000 */ nop -/* 3354C 8005814C 46800020 */ cvt.s.w $f0, $f0 -/* 33550 80058150 46001081 */ sub.s $f2, $f2, $f0 -/* 33554 80058154 8FA80060 */ lw $t0, 0x60($sp) -/* 33558 80058158 E504003C */ swc1 $f4, 0x3c($t0) -/* 3355C 8005815C 128001BA */ beqz $s4, .L80058848 -/* 33560 80058160 E5020040 */ swc1 $f2, 0x40($t0) -/* 33564 80058164 8E470014 */ lw $a3, 0x14($s2) -/* 33568 80058168 90E20024 */ lbu $v0, 0x24($a3) -/* 3356C 8005816C 144000F2 */ bnez $v0, .L80058538 -/* 33570 80058170 3C0300FF */ lui $v1, 0xff -/* 33574 80058174 3463FFFF */ ori $v1, $v1, 0xffff -/* 33578 80058178 AFA00024 */ sw $zero, 0x24($sp) -/* 3357C 8005817C 8D02001C */ lw $v0, 0x1c($t0) -/* 33580 80058180 3C041FFF */ lui $a0, 0x1fff -/* 33584 80058184 00431024 */ and $v0, $v0, $v1 -/* 33588 80058188 3C030B00 */ lui $v1, 0xb00 -/* 3358C 8005818C 00431025 */ or $v0, $v0, $v1 -/* 33590 80058190 AE220000 */ sw $v0, ($s1) -/* 33594 80058194 8E420014 */ lw $v0, 0x14($s2) -/* 33598 80058198 3484FFFF */ ori $a0, $a0, 0xffff -/* 3359C 8005819C 8C420018 */ lw $v0, 0x18($v0) -/* 335A0 800581A0 8FA50024 */ lw $a1, 0x24($sp) -/* 335A4 800581A4 00441024 */ and $v0, $v0, $a0 -/* 335A8 800581A8 AE220004 */ sw $v0, 4($s1) -/* 335AC 800581AC 8D040028 */ lw $a0, 0x28($t0) -/* 335B0 800581B0 8D030010 */ lw $v1, 0x10($t0) -/* 335B4 800581B4 02841021 */ addu $v0, $s4, $a0 -/* 335B8 800581B8 0062102B */ sltu $v0, $v1, $v0 -/* 335BC 800581BC 10400003 */ beqz $v0, .L800581CC -/* 335C0 800581C0 26D60008 */ addiu $s6, $s6, 8 -/* 335C4 800581C4 8D020014 */ lw $v0, 0x14($t0) -/* 335C8 800581C8 0002282B */ sltu $a1, $zero, $v0 -.L800581CC: -/* 335CC 800581CC 10A00002 */ beqz $a1, .L800581D8 -/* 335D0 800581D0 0280802D */ daddu $s0, $s4, $zero -/* 335D4 800581D4 00648023 */ subu $s0, $v1, $a0 -.L800581D8: -/* 335D8 800581D8 8E430028 */ lw $v1, 0x28($s2) -/* 335DC 800581DC 10600003 */ beqz $v1, .L800581EC -/* 335E0 800581E0 24020010 */ addiu $v0, $zero, 0x10 -/* 335E4 800581E4 0801607C */ j .L800581F0 -/* 335E8 800581E8 0043A823 */ subu $s5, $v0, $v1 -.L800581EC: -/* 335EC 800581EC 0000A82D */ daddu $s5, $zero, $zero -.L800581F0: -/* 335F0 800581F0 02153023 */ subu $a2, $s0, $s5 -/* 335F4 800581F4 04C20001 */ bltzl $a2, .L800581FC -/* 335F8 800581F8 0000302D */ daddu $a2, $zero, $zero -.L800581FC: -/* 335FC 800581FC 24C2000F */ addiu $v0, $a2, 0xf -/* 33600 80058200 00028903 */ sra $s1, $v0, 4 -/* 33604 80058204 001110C0 */ sll $v0, $s1, 3 -/* 33608 80058208 10A00072 */ beqz $a1, .L800583D4 -/* 3360C 8005820C 00513821 */ addu $a3, $v0, $s1 -/* 33610 80058210 02C0202D */ daddu $a0, $s6, $zero -/* 33614 80058214 001E1400 */ sll $v0, $fp, 0x10 -/* 33618 80058218 00021403 */ sra $v0, $v0, 0x10 -/* 3361C 8005821C AFA20010 */ sw $v0, 0x10($sp) -/* 33620 80058220 AFA00014 */ sw $zero, 0x14($sp) -/* 33624 80058224 8E42002C */ lw $v0, 0x2c($s2) -/* 33628 80058228 0240282D */ daddu $a1, $s2, $zero -/* 3362C 8005822C 0C0162C8 */ jal _decodeChunk -/* 33630 80058230 AFA20018 */ sw $v0, 0x18($sp) -/* 33634 80058234 8E430028 */ lw $v1, 0x28($s2) -/* 33638 80058238 10600005 */ beqz $v1, .L80058250 -/* 3363C 8005823C 0040B02D */ daddu $s6, $v0, $zero -/* 33640 80058240 9642002A */ lhu $v0, 0x2a($s2) -/* 33644 80058244 00021040 */ sll $v0, $v0, 1 -/* 33648 80058248 08016095 */ j .L80058254 -/* 3364C 8005824C 03C2F021 */ addu $fp, $fp, $v0 -.L80058250: -/* 33650 80058250 27DE0020 */ addiu $fp, $fp, 0x20 -.L80058254: -/* 33654 80058254 001E2C00 */ sll $a1, $fp, 0x10 -/* 33658 80058258 8E420008 */ lw $v0, 8($s2) -/* 3365C 8005825C 00059C03 */ sra $s3, $a1, 0x10 -/* 33660 80058260 3042000F */ andi $v0, $v0, 0xf -/* 33664 80058264 AE420028 */ sw $v0, 0x28($s2) -/* 33668 80058268 8E420014 */ lw $v0, 0x14($s2) -/* 3366C 8005826C 8E430008 */ lw $v1, 8($s2) -/* 33670 80058270 8C440000 */ lw $a0, ($v0) -/* 33674 80058274 0060102D */ daddu $v0, $v1, $zero -/* 33678 80058278 00031902 */ srl $v1, $v1, 4 -/* 3367C 8005827C 24630001 */ addiu $v1, $v1, 1 -/* 33680 80058280 AE420024 */ sw $v0, 0x24($s2) -/* 33684 80058284 000310C0 */ sll $v0, $v1, 3 -/* 33688 80058288 00431021 */ addu $v0, $v0, $v1 -/* 3368C 8005828C 00822021 */ addu $a0, $a0, $v0 -/* 33690 80058290 0214102A */ slt $v0, $s0, $s4 -/* 33694 80058294 10400042 */ beqz $v0, .L800583A0 -/* 33698 80058298 AE440030 */ sw $a0, 0x30($s2) -/* 3369C 8005829C 0000402D */ daddu $t0, $zero, $zero -/* 336A0 800582A0 00081400 */ sll $v0, $t0, 0x10 -/* 336A4 800582A4 00021403 */ sra $v0, $v0, 0x10 -/* 336A8 800582A8 AFA2002C */ sw $v0, 0x2c($sp) -.L800582AC: -/* 336AC 800582AC 26220001 */ addiu $v0, $s1, 1 -/* 336B0 800582B0 00021140 */ sll $v0, $v0, 5 -/* 336B4 800582B4 02621021 */ addu $v0, $s3, $v0 -/* 336B8 800582B8 00101840 */ sll $v1, $s0, 1 -/* 336BC 800582BC 02639821 */ addu $s3, $s3, $v1 -/* 336C0 800582C0 24420010 */ addiu $v0, $v0, 0x10 -/* 336C4 800582C4 2403FFE0 */ addiu $v1, $zero, -0x20 -/* 336C8 800582C8 0043A824 */ and $s5, $v0, $v1 -/* 336CC 800582CC 8E430010 */ lw $v1, 0x10($s2) -/* 336D0 800582D0 2402FFFF */ addiu $v0, $zero, -1 -/* 336D4 800582D4 10620004 */ beq $v1, $v0, .L800582E8 -/* 336D8 800582D8 0290A023 */ subu $s4, $s4, $s0 -/* 336DC 800582DC 10600002 */ beqz $v1, .L800582E8 -/* 336E0 800582E0 00621021 */ addu $v0, $v1, $v0 -/* 336E4 800582E4 AE420010 */ sw $v0, 0x10($s2) -.L800582E8: -/* 336E8 800582E8 8E43000C */ lw $v1, 0xc($s2) -/* 336EC 800582EC 8E420008 */ lw $v0, 8($s2) -/* 336F0 800582F0 00621823 */ subu $v1, $v1, $v0 -/* 336F4 800582F4 0283102B */ sltu $v0, $s4, $v1 -/* 336F8 800582F8 14400002 */ bnez $v0, .L80058304 -/* 336FC 800582FC 0280802D */ daddu $s0, $s4, $zero -/* 33700 80058300 0060802D */ daddu $s0, $v1, $zero -.L80058304: -/* 33704 80058304 8E420028 */ lw $v0, 0x28($s2) -/* 33708 80058308 2442FFF0 */ addiu $v0, $v0, -0x10 -/* 3370C 8005830C 02023021 */ addu $a2, $s0, $v0 -/* 33710 80058310 04C20001 */ bltzl $a2, .L80058318 -/* 33714 80058314 0000302D */ daddu $a2, $zero, $zero -.L80058318: -/* 33718 80058318 24C2000F */ addiu $v0, $a2, 0xf -/* 3371C 8005831C 00028903 */ sra $s1, $v0, 4 -/* 33720 80058320 02C0202D */ daddu $a0, $s6, $zero -/* 33724 80058324 0240282D */ daddu $a1, $s2, $zero -/* 33728 80058328 00151400 */ sll $v0, $s5, 0x10 -/* 3372C 8005832C 00021403 */ sra $v0, $v0, 0x10 -/* 33730 80058330 8FA8002C */ lw $t0, 0x2c($sp) -/* 33734 80058334 001138C0 */ sll $a3, $s1, 3 -/* 33738 80058338 AFA20010 */ sw $v0, 0x10($sp) -/* 3373C 8005833C AFA80014 */ sw $t0, 0x14($sp) -/* 33740 80058340 8E42002C */ lw $v0, 0x2c($s2) -/* 33744 80058344 00F13821 */ addu $a3, $a3, $s1 -/* 33748 80058348 34420002 */ ori $v0, $v0, 2 -/* 3374C 8005834C 0C0162C8 */ jal _decodeChunk -/* 33750 80058350 AFA20018 */ sw $v0, 0x18($sp) -/* 33754 80058354 0040B02D */ daddu $s6, $v0, $zero -/* 33758 80058358 02C0282D */ daddu $a1, $s6, $zero -/* 3375C 8005835C 3C0600FF */ lui $a2, 0xff -/* 33760 80058360 34C6FFFF */ ori $a2, $a2, 0xffff -/* 33764 80058364 00132400 */ sll $a0, $s3, 0x10 -/* 33768 80058368 00101840 */ sll $v1, $s0, 1 -/* 3376C 8005836C 3063FFFF */ andi $v1, $v1, 0xffff -/* 33770 80058370 00832025 */ or $a0, $a0, $v1 -/* 33774 80058374 8E420028 */ lw $v0, 0x28($s2) -/* 33778 80058378 3C030A00 */ lui $v1, 0xa00 -/* 3377C 8005837C ACA40004 */ sw $a0, 4($a1) -/* 33780 80058380 00021040 */ sll $v0, $v0, 1 -/* 33784 80058384 02A21021 */ addu $v0, $s5, $v0 -/* 33788 80058388 00461024 */ and $v0, $v0, $a2 -/* 3378C 8005838C 00431025 */ or $v0, $v0, $v1 -/* 33790 80058390 ACA20000 */ sw $v0, ($a1) -/* 33794 80058394 0214102A */ slt $v0, $s0, $s4 -/* 33798 80058398 1440FFC4 */ bnez $v0, .L800582AC -/* 3379C 8005839C 26D60008 */ addiu $s6, $s6, 8 -.L800583A0: -/* 337A0 800583A0 8E420028 */ lw $v0, 0x28($s2) -/* 337A4 800583A4 8E430024 */ lw $v1, 0x24($s2) -/* 337A8 800583A8 02821021 */ addu $v0, $s4, $v0 -/* 337AC 800583AC 3042000F */ andi $v0, $v0, 0xf -/* 337B0 800583B0 00741821 */ addu $v1, $v1, $s4 -/* 337B4 800583B4 AE420028 */ sw $v0, 0x28($s2) -/* 337B8 800583B8 001110C0 */ sll $v0, $s1, 3 -/* 337BC 800583BC AE430024 */ sw $v1, 0x24($s2) -/* 337C0 800583C0 8E430030 */ lw $v1, 0x30($s2) -/* 337C4 800583C4 00511021 */ addu $v0, $v0, $s1 -/* 337C8 800583C8 00621821 */ addu $v1, $v1, $v0 -/* 337CC 800583CC 08016212 */ j .L80058848 -/* 337D0 800583D0 AE430030 */ sw $v1, 0x30($s2) -.L800583D4: -/* 337D4 800583D4 8E440014 */ lw $a0, 0x14($s2) -/* 337D8 800583D8 8E430030 */ lw $v1, 0x30($s2) -/* 337DC 800583DC 8C820000 */ lw $v0, ($a0) -/* 337E0 800583E0 8C840004 */ lw $a0, 4($a0) -/* 337E4 800583E4 00671821 */ addu $v1, $v1, $a3 -/* 337E8 800583E8 00441021 */ addu $v0, $v0, $a0 -/* 337EC 800583EC 00622023 */ subu $a0, $v1, $v0 -/* 337F0 800583F0 1C800003 */ bgtz $a0, .L80058400 -/* 337F4 800583F4 00118100 */ sll $s0, $s1, 4 -/* 337F8 800583F8 08016101 */ j .L80058404 -/* 337FC 800583FC 0000202D */ daddu $a0, $zero, $zero -.L80058400: -/* 33800 80058400 AEE00028 */ sw $zero, 0x28($s7) -.L80058404: -/* 33804 80058404 3C0238E3 */ lui $v0, 0x38e3 -/* 33808 80058408 34428E39 */ ori $v0, $v0, 0x8e39 -/* 3380C 8005840C 00820018 */ mult $a0, $v0 -/* 33810 80058410 00041FC3 */ sra $v1, $a0, 0x1f -/* 33814 80058414 00004010 */ mfhi $t0 -/* 33818 80058418 00081043 */ sra $v0, $t0, 1 -/* 3381C 8005841C 00431023 */ subu $v0, $v0, $v1 -/* 33820 80058420 00029900 */ sll $s3, $v0, 4 -/* 33824 80058424 02151821 */ addu $v1, $s0, $s5 -/* 33828 80058428 0073102A */ slt $v0, $v1, $s3 -/* 3382C 8005842C 54400001 */ bnel $v0, $zero, .L80058434 -/* 33830 80058430 0060982D */ daddu $s3, $v1, $zero -.L80058434: -/* 33834 80058434 3262000F */ andi $v0, $s3, 0xf -/* 33838 80058438 02621023 */ subu $v0, $s3, $v0 -/* 3383C 8005843C 0054102A */ slt $v0, $v0, $s4 -/* 33840 80058440 10400020 */ beqz $v0, .L800584C4 -/* 33844 80058444 00E43823 */ subu $a3, $a3, $a0 -/* 33848 80058448 24080001 */ addiu $t0, $zero, 1 -/* 3384C 8005844C 02C0202D */ daddu $a0, $s6, $zero -/* 33850 80058450 0240282D */ daddu $a1, $s2, $zero -/* 33854 80058454 001E1400 */ sll $v0, $fp, 0x10 -/* 33858 80058458 00021403 */ sra $v0, $v0, 0x10 -/* 3385C 8005845C AFA80024 */ sw $t0, 0x24($sp) -/* 33860 80058460 AFA20010 */ sw $v0, 0x10($sp) -/* 33864 80058464 AFA00014 */ sw $zero, 0x14($sp) -/* 33868 80058468 8E42002C */ lw $v0, 0x2c($s2) -/* 3386C 8005846C 02133023 */ subu $a2, $s0, $s3 -/* 33870 80058470 0C0162C8 */ jal _decodeChunk -/* 33874 80058474 AFA20018 */ sw $v0, 0x18($sp) -/* 33878 80058478 8E430028 */ lw $v1, 0x28($s2) -/* 3387C 8005847C 10600005 */ beqz $v1, .L80058494 -/* 33880 80058480 0040B02D */ daddu $s6, $v0, $zero -/* 33884 80058484 9642002A */ lhu $v0, 0x2a($s2) -/* 33888 80058488 00021040 */ sll $v0, $v0, 1 -/* 3388C 8005848C 08016126 */ j .L80058498 -/* 33890 80058490 03C2F021 */ addu $fp, $fp, $v0 -.L80058494: -/* 33894 80058494 27DE0020 */ addiu $fp, $fp, 0x20 -.L80058498: -/* 33898 80058498 8E420028 */ lw $v0, 0x28($s2) -/* 3389C 8005849C 8E430024 */ lw $v1, 0x24($s2) -/* 338A0 800584A0 02821021 */ addu $v0, $s4, $v0 -/* 338A4 800584A4 3042000F */ andi $v0, $v0, 0xf -/* 338A8 800584A8 00741821 */ addu $v1, $v1, $s4 -/* 338AC 800584AC AE420028 */ sw $v0, 0x28($s2) -/* 338B0 800584B0 001110C0 */ sll $v0, $s1, 3 -/* 338B4 800584B4 AE430024 */ sw $v1, 0x24($s2) -/* 338B8 800584B8 8E430030 */ lw $v1, 0x30($s2) -/* 338BC 800584BC 08016135 */ j .L800584D4 -/* 338C0 800584C0 00511021 */ addu $v0, $v0, $s1 -.L800584C4: -/* 338C4 800584C4 001110C0 */ sll $v0, $s1, 3 -/* 338C8 800584C8 8E430030 */ lw $v1, 0x30($s2) -/* 338CC 800584CC 00511021 */ addu $v0, $v0, $s1 -/* 338D0 800584D0 AE400028 */ sw $zero, 0x28($s2) -.L800584D4: -/* 338D4 800584D4 00621821 */ addu $v1, $v1, $v0 -/* 338D8 800584D8 126000DB */ beqz $s3, .L80058848 -/* 338DC 800584DC AE430030 */ sw $v1, 0x30($s2) -/* 338E0 800584E0 AE400028 */ sw $zero, 0x28($s2) -/* 338E4 800584E4 8FA80024 */ lw $t0, 0x24($sp) -/* 338E8 800584E8 11000004 */ beqz $t0, .L800584FC -/* 338EC 800584EC 02B01021 */ addu $v0, $s5, $s0 -/* 338F0 800584F0 00531023 */ subu $v0, $v0, $s3 -/* 338F4 800584F4 08016140 */ j .L80058500 -/* 338F8 800584F8 00022840 */ sll $a1, $v0, 1 -.L800584FC: -/* 338FC 800584FC 0000282D */ daddu $a1, $zero, $zero -.L80058500: -/* 33900 80058500 02C0202D */ daddu $a0, $s6, $zero -/* 33904 80058504 26D60008 */ addiu $s6, $s6, 8 -/* 33908 80058508 3C0300FF */ lui $v1, 0xff -/* 3390C 8005850C 3463FFFF */ ori $v1, $v1, 0xffff -/* 33910 80058510 001E1400 */ sll $v0, $fp, 0x10 -/* 33914 80058514 00021403 */ sra $v0, $v0, 0x10 -/* 33918 80058518 00A21021 */ addu $v0, $a1, $v0 -/* 3391C 8005851C 00431024 */ and $v0, $v0, $v1 -/* 33920 80058520 3C030200 */ lui $v1, 0x200 -/* 33924 80058524 00431025 */ or $v0, $v0, $v1 -/* 33928 80058528 AC820000 */ sw $v0, ($a0) -/* 3392C 8005852C 00131040 */ sll $v0, $s3, 1 -/* 33930 80058530 08016212 */ j .L80058848 -/* 33934 80058534 AC820004 */ sw $v0, 4($a0) -.L80058538: -/* 33938 80058538 8FA80060 */ lw $t0, 0x60($sp) -/* 3393C 8005853C 8D040028 */ lw $a0, 0x28($t0) -/* 33940 80058540 8D030010 */ lw $v1, 0x10($t0) -/* 33944 80058544 02841021 */ addu $v0, $s4, $a0 -/* 33948 80058548 0062102B */ sltu $v0, $v1, $v0 -/* 3394C 8005854C 10400079 */ beqz $v0, .L80058734 -/* 33950 80058550 00148040 */ sll $s0, $s4, 1 -/* 33954 80058554 8D020014 */ lw $v0, 0x14($t0) -/* 33958 80058558 10400076 */ beqz $v0, .L80058734 -/* 3395C 8005855C 00649823 */ subu $s3, $v1, $a0 -/* 33960 80058560 1A600017 */ blez $s3, .L800585C0 -/* 33964 80058564 00138040 */ sll $s0, $s3, 1 -/* 33968 80058568 0200282D */ daddu $a1, $s0, $zero -/* 3396C 8005856C 8D040034 */ lw $a0, 0x34($t0) -/* 33970 80058570 8D060024 */ lw $a2, 0x24($t0) -/* 33974 80058574 90E70025 */ lbu $a3, 0x25($a3) -/* 33978 80058578 8D020020 */ lw $v0, 0x20($t0) -/* 3397C 8005857C 0040F809 */ jalr $v0 -/* 33980 80058580 26D60008 */ addiu $s6, $s6, 8 -/* 33984 80058584 0040382D */ daddu $a3, $v0, $zero -/* 33988 80058588 30E60007 */ andi $a2, $a3, 7 -/* 3398C 8005858C 02068021 */ addu $s0, $s0, $a2 -/* 33990 80058590 3C030400 */ lui $v1, 0x400 -/* 33994 80058594 34630170 */ ori $v1, $v1, 0x170 -/* 33998 80058598 32020007 */ andi $v0, $s0, 7 -/* 3399C 8005859C 2442FFF8 */ addiu $v0, $v0, -8 -/* 339A0 800585A0 02021023 */ subu $v0, $s0, $v0 -/* 339A4 800585A4 30420FFF */ andi $v0, $v0, 0xfff -/* 339A8 800585A8 00021300 */ sll $v0, $v0, 0xc -/* 339AC 800585AC 00431025 */ or $v0, $v0, $v1 -/* 339B0 800585B0 AE220000 */ sw $v0, ($s1) -/* 339B4 800585B4 00E61023 */ subu $v0, $a3, $a2 -/* 339B8 800585B8 08016171 */ j .L800585C4 -/* 339BC 800585BC AE220004 */ sw $v0, 4($s1) -.L800585C0: -/* 339C0 800585C0 0000302D */ daddu $a2, $zero, $zero -.L800585C4: -/* 339C4 800585C4 03C61021 */ addu $v0, $fp, $a2 -/* 339C8 800585C8 0040F02D */ daddu $fp, $v0, $zero -/* 339CC 800585CC 00021400 */ sll $v0, $v0, 0x10 -/* 339D0 800585D0 0002AC03 */ sra $s5, $v0, 0x10 -/* 339D4 800585D4 0274102A */ slt $v0, $s3, $s4 -/* 339D8 800585D8 8E430008 */ lw $v1, 8($s2) -/* 339DC 800585DC 8E440014 */ lw $a0, 0x14($s2) -/* 339E0 800585E0 0060282D */ daddu $a1, $v1, $zero -/* 339E4 800585E4 8C840000 */ lw $a0, ($a0) -/* 339E8 800585E8 00031840 */ sll $v1, $v1, 1 -/* 339EC 800585EC AE450024 */ sw $a1, 0x24($s2) -/* 339F0 800585F0 00832021 */ addu $a0, $a0, $v1 -/* 339F4 800585F4 10400047 */ beqz $v0, .L80058714 -/* 339F8 800585F8 AE440030 */ sw $a0, 0x30($s2) -/* 339FC 800585FC 26D1FFFC */ addiu $s1, $s6, -4 -/* 33A00 80058600 00131040 */ sll $v0, $s3, 1 -.L80058604: -/* 33A04 80058604 02A2A821 */ addu $s5, $s5, $v0 -/* 33A08 80058608 8E430010 */ lw $v1, 0x10($s2) -/* 33A0C 8005860C 2402FFFF */ addiu $v0, $zero, -1 -/* 33A10 80058610 10620004 */ beq $v1, $v0, .L80058624 -/* 33A14 80058614 0293A023 */ subu $s4, $s4, $s3 -/* 33A18 80058618 10600002 */ beqz $v1, .L80058624 -/* 33A1C 8005861C 00621021 */ addu $v0, $v1, $v0 -/* 33A20 80058620 AE420010 */ sw $v0, 0x10($s2) -.L80058624: -/* 33A24 80058624 8E43000C */ lw $v1, 0xc($s2) -/* 33A28 80058628 8E420008 */ lw $v0, 8($s2) -/* 33A2C 8005862C 00621823 */ subu $v1, $v1, $v0 -/* 33A30 80058630 0283102B */ sltu $v0, $s4, $v1 -/* 33A34 80058634 14400002 */ bnez $v0, .L80058640 -/* 33A38 80058638 0280982D */ daddu $s3, $s4, $zero -/* 33A3C 8005863C 0060982D */ daddu $s3, $v1, $zero -.L80058640: -/* 33A40 80058640 00138040 */ sll $s0, $s3, 1 -/* 33A44 80058644 8E440030 */ lw $a0, 0x30($s2) -/* 33A48 80058648 8E420014 */ lw $v0, 0x14($s2) -/* 33A4C 8005864C 8E460020 */ lw $a2, 0x20($s2) -/* 33A50 80058650 90470025 */ lbu $a3, 0x25($v0) -/* 33A54 80058654 8E42001C */ lw $v0, 0x1c($s2) -/* 33A58 80058658 0040F809 */ jalr $v0 -/* 33A5C 8005865C 0200282D */ daddu $a1, $s0, $zero -/* 33A60 80058660 0040382D */ daddu $a3, $v0, $zero -/* 33A64 80058664 30E60007 */ andi $a2, $a3, 7 -/* 33A68 80058668 32A30007 */ andi $v1, $s5, 7 -/* 33A6C 8005866C 10600004 */ beqz $v1, .L80058680 -/* 33A70 80058670 02068021 */ addu $s0, $s0, $a2 -/* 33A74 80058674 24020008 */ addiu $v0, $zero, 8 -/* 33A78 80058678 080161A1 */ j .L80058684 -/* 33A7C 8005867C 00432823 */ subu $a1, $v0, $v1 -.L80058680: -/* 33A80 80058680 0000282D */ daddu $a1, $zero, $zero -.L80058684: -/* 33A84 80058684 26310008 */ addiu $s1, $s1, 8 -/* 33A88 80058688 26D60008 */ addiu $s6, $s6, 8 -/* 33A8C 8005868C 32020007 */ andi $v0, $s0, 7 -/* 33A90 80058690 2442FFF8 */ addiu $v0, $v0, -8 -/* 33A94 80058694 02021023 */ subu $v0, $s0, $v0 -/* 33A98 80058698 30420FFF */ andi $v0, $v0, 0xfff -/* 33A9C 8005869C 00021300 */ sll $v0, $v0, 0xc -/* 33AA0 800586A0 02A51821 */ addu $v1, $s5, $a1 -/* 33AA4 800586A4 30630FFF */ andi $v1, $v1, 0xfff -/* 33AA8 800586A8 3C040400 */ lui $a0, 0x400 -/* 33AAC 800586AC 00641825 */ or $v1, $v1, $a0 -/* 33AB0 800586B0 00431025 */ or $v0, $v0, $v1 -/* 33AB4 800586B4 AE22FFFC */ sw $v0, -4($s1) -/* 33AB8 800586B8 00E61023 */ subu $v0, $a3, $a2 -/* 33ABC 800586BC 14C00003 */ bnez $a2, .L800586CC -/* 33AC0 800586C0 AE220000 */ sw $v0, ($s1) -/* 33AC4 800586C4 10A00011 */ beqz $a1, .L8005870C -/* 33AC8 800586C8 0274102A */ slt $v0, $s3, $s4 -.L800586CC: -/* 33ACC 800586CC 26310008 */ addiu $s1, $s1, 8 -/* 33AD0 800586D0 26D60008 */ addiu $s6, $s6, 8 -/* 33AD4 800586D4 3C0300FF */ lui $v1, 0xff -/* 33AD8 800586D8 3463FFFF */ ori $v1, $v1, 0xffff -/* 33ADC 800586DC 02A61021 */ addu $v0, $s5, $a2 -/* 33AE0 800586E0 00451021 */ addu $v0, $v0, $a1 -/* 33AE4 800586E4 00431024 */ and $v0, $v0, $v1 -/* 33AE8 800586E8 3C030A00 */ lui $v1, 0xa00 -/* 33AEC 800586EC 00431025 */ or $v0, $v0, $v1 -/* 33AF0 800586F0 00151C00 */ sll $v1, $s5, 0x10 -/* 33AF4 800586F4 AE22FFFC */ sw $v0, -4($s1) -/* 33AF8 800586F8 00131040 */ sll $v0, $s3, 1 -/* 33AFC 800586FC 3042FFFF */ andi $v0, $v0, 0xffff -/* 33B00 80058700 00621825 */ or $v1, $v1, $v0 -/* 33B04 80058704 AE230000 */ sw $v1, ($s1) -/* 33B08 80058708 0274102A */ slt $v0, $s3, $s4 -.L8005870C: -/* 33B0C 8005870C 1440FFBD */ bnez $v0, .L80058604 -/* 33B10 80058710 00131040 */ sll $v0, $s3, 1 -.L80058714: -/* 33B14 80058714 8E420024 */ lw $v0, 0x24($s2) -/* 33B18 80058718 00541021 */ addu $v0, $v0, $s4 -/* 33B1C 8005871C AE420024 */ sw $v0, 0x24($s2) -/* 33B20 80058720 8E420030 */ lw $v0, 0x30($s2) -/* 33B24 80058724 00141840 */ sll $v1, $s4, 1 -/* 33B28 80058728 00431021 */ addu $v0, $v0, $v1 -/* 33B2C 8005872C 08016212 */ j .L80058848 -/* 33B30 80058730 AE420030 */ sw $v0, 0x30($s2) -.L80058734: -/* 33B34 80058734 8E440014 */ lw $a0, 0x14($s2) -/* 33B38 80058738 8E430030 */ lw $v1, 0x30($s2) -/* 33B3C 8005873C 8C820000 */ lw $v0, ($a0) -/* 33B40 80058740 8C840004 */ lw $a0, 4($a0) -/* 33B44 80058744 00701821 */ addu $v1, $v1, $s0 -/* 33B48 80058748 00441021 */ addu $v0, $v0, $a0 -/* 33B4C 8005874C 00628823 */ subu $s1, $v1, $v0 -/* 33B50 80058750 5E200002 */ bgtzl $s1, .L8005875C -/* 33B54 80058754 AEE00028 */ sw $zero, 0x28($s7) -/* 33B58 80058758 0000882D */ daddu $s1, $zero, $zero -.L8005875C: -/* 33B5C 8005875C 0211102A */ slt $v0, $s0, $s1 -/* 33B60 80058760 54400001 */ bnel $v0, $zero, .L80058768 -/* 33B64 80058764 0200882D */ daddu $s1, $s0, $zero -.L80058768: -/* 33B68 80058768 0230102A */ slt $v0, $s1, $s0 -/* 33B6C 8005876C 10400021 */ beqz $v0, .L800587F4 -/* 33B70 80058770 00000000 */ nop -/* 33B74 80058774 1A80001A */ blez $s4, .L800587E0 -/* 33B78 80058778 02118023 */ subu $s0, $s0, $s1 -/* 33B7C 8005877C 8E440030 */ lw $a0, 0x30($s2) -/* 33B80 80058780 8E420014 */ lw $v0, 0x14($s2) -/* 33B84 80058784 8E460020 */ lw $a2, 0x20($s2) -/* 33B88 80058788 90470025 */ lbu $a3, 0x25($v0) -/* 33B8C 8005878C 8E42001C */ lw $v0, 0x1c($s2) -/* 33B90 80058790 0040F809 */ jalr $v0 -/* 33B94 80058794 0200282D */ daddu $a1, $s0, $zero -/* 33B98 80058798 0040382D */ daddu $a3, $v0, $zero -/* 33B9C 8005879C 30E60007 */ andi $a2, $a3, 7 -/* 33BA0 800587A0 02068021 */ addu $s0, $s0, $a2 -/* 33BA4 800587A4 02C0282D */ daddu $a1, $s6, $zero -/* 33BA8 800587A8 26D60008 */ addiu $s6, $s6, 8 -/* 33BAC 800587AC 32020007 */ andi $v0, $s0, 7 -/* 33BB0 800587B0 2442FFF8 */ addiu $v0, $v0, -8 -/* 33BB4 800587B4 02021023 */ subu $v0, $s0, $v0 -/* 33BB8 800587B8 30420FFF */ andi $v0, $v0, 0xfff -/* 33BBC 800587BC 00021300 */ sll $v0, $v0, 0xc -/* 33BC0 800587C0 33C30FFF */ andi $v1, $fp, 0xfff -/* 33BC4 800587C4 3C040400 */ lui $a0, 0x400 -/* 33BC8 800587C8 00641825 */ or $v1, $v1, $a0 -/* 33BCC 800587CC 00431025 */ or $v0, $v0, $v1 -/* 33BD0 800587D0 ACA20000 */ sw $v0, ($a1) -/* 33BD4 800587D4 00E61023 */ subu $v0, $a3, $a2 -/* 33BD8 800587D8 080161F9 */ j .L800587E4 -/* 33BDC 800587DC ACA20004 */ sw $v0, 4($a1) -.L800587E0: -/* 33BE0 800587E0 0000302D */ daddu $a2, $zero, $zero -.L800587E4: -/* 33BE4 800587E4 8E420024 */ lw $v0, 0x24($s2) -/* 33BE8 800587E8 03C6F021 */ addu $fp, $fp, $a2 -/* 33BEC 800587EC 00541021 */ addu $v0, $v0, $s4 -/* 33BF0 800587F0 AE420024 */ sw $v0, 0x24($s2) -.L800587F4: -/* 33BF4 800587F4 8E420030 */ lw $v0, 0x30($s2) -/* 33BF8 800587F8 00141840 */ sll $v1, $s4, 1 -/* 33BFC 800587FC 00431021 */ addu $v0, $v0, $v1 -/* 33C00 80058800 12200011 */ beqz $s1, .L80058848 -/* 33C04 80058804 AE420030 */ sw $v0, 0x30($s2) -/* 33C08 80058808 00141040 */ sll $v0, $s4, 1 -/* 33C0C 8005880C 00512823 */ subu $a1, $v0, $s1 -/* 33C10 80058810 04A20001 */ bltzl $a1, .L80058818 -/* 33C14 80058814 0000282D */ daddu $a1, $zero, $zero -.L80058818: -/* 33C18 80058818 02C0202D */ daddu $a0, $s6, $zero -/* 33C1C 8005881C 26D60008 */ addiu $s6, $s6, 8 -/* 33C20 80058820 3C0300FF */ lui $v1, 0xff -/* 33C24 80058824 3463FFFF */ ori $v1, $v1, 0xffff -/* 33C28 80058828 001E1400 */ sll $v0, $fp, 0x10 -/* 33C2C 8005882C 00021403 */ sra $v0, $v0, 0x10 -/* 33C30 80058830 00A21021 */ addu $v0, $a1, $v0 -/* 33C34 80058834 00431024 */ and $v0, $v0, $v1 -/* 33C38 80058838 3C030200 */ lui $v1, 0x200 -/* 33C3C 8005883C 00431025 */ or $v0, $v0, $v1 -/* 33C40 80058840 AC820000 */ sw $v0, ($a0) -/* 33C44 80058844 AC910004 */ sw $s1, 4($a0) -.L80058848: -/* 33C48 80058848 8FA80020 */ lw $t0, 0x20($sp) -/* 33C4C 8005884C 3C014700 */ lui $at, 0x4700 -/* 33C50 80058850 44811000 */ mtc1 $at, $f2 -/* 33C54 80058854 C5000004 */ lwc1 $f0, 4($t0) -/* 33C58 80058858 46020002 */ mul.s $f0, $f0, $f2 -/* 33C5C 8005885C 00000000 */ nop -/* 33C60 80058860 8D040000 */ lw $a0, ($t0) -/* 33C64 80058864 4600018D */ trunc.w.s $f6, $f0 -/* 33C68 80058868 44103000 */ mfc1 $s0, $f6 -/* 33C6C 8005886C 0C0187A4 */ jal osVirtualToPhysical -/* 33C70 80058870 3210FFFF */ andi $s0, $s0, 0xffff -/* 33C74 80058874 3C0300FF */ lui $v1, 0xff -/* 33C78 80058878 3463FFFF */ ori $v1, $v1, 0xffff -/* 33C7C 8005887C 02C0202D */ daddu $a0, $s6, $zero -/* 33C80 80058880 00431024 */ and $v0, $v0, $v1 -/* 33C84 80058884 3C030500 */ lui $v1, 0x500 -/* 33C88 80058888 00431025 */ or $v0, $v0, $v1 -/* 33C8C 8005888C 00108380 */ sll $s0, $s0, 0xe -/* 33C90 80058890 AC820000 */ sw $v0, ($a0) -/* 33C94 80058894 8FA80020 */ lw $t0, 0x20($sp) -/* 33C98 80058898 33C20FFF */ andi $v0, $fp, 0xfff -/* 33C9C 8005889C 8D03000C */ lw $v1, 0xc($t0) -/* 33CA0 800588A0 00021080 */ sll $v0, $v0, 2 -/* 33CA4 800588A4 00031F80 */ sll $v1, $v1, 0x1e -/* 33CA8 800588A8 00701825 */ or $v1, $v1, $s0 -/* 33CAC 800588AC 00621825 */ or $v1, $v1, $v0 -/* 33CB0 800588B0 AC830004 */ sw $v1, 4($a0) -/* 33CB4 800588B4 AD00000C */ sw $zero, 0xc($t0) -/* 33CB8 800588B8 8EE20024 */ lw $v0, 0x24($s7) -/* 33CBC 800588BC 10400069 */ beqz $v0, .L80058A64 -/* 33CC0 800588C0 26D60008 */ addiu $s6, $s6, 8 -/* 33CC4 800588C4 3C028008 */ lui $v0, %hi(AuSynUseStereo) -/* 33CC8 800588C8 24428181 */ addiu $v0, $v0, %lo(AuSynUseStereo) -/* 33CCC 800588CC 90420000 */ lbu $v0, ($v0) -/* 33CD0 800588D0 1440000C */ bnez $v0, .L80058904 -/* 33CD4 800588D4 AEE00024 */ sw $zero, 0x24($s7) -/* 33CD8 800588D8 3C048008 */ lui $a0, %hi(AuEqPower) -/* 33CDC 800588DC 24848E60 */ addiu $a0, $a0, %lo(AuEqPower) -/* 33CE0 800588E0 86E30006 */ lh $v1, 6($s7) -/* 33CE4 800588E4 84820080 */ lh $v0, 0x80($a0) -/* 33CE8 800588E8 00620018 */ mult $v1, $v0 -/* 33CEC 800588EC 00004012 */ mflo $t0 -/* 33CF0 800588F0 000813C3 */ sra $v0, $t0, 0xf -/* 33CF4 800588F4 A6E20014 */ sh $v0, 0x14($s7) -/* 33CF8 800588F8 84820080 */ lh $v0, 0x80($a0) -/* 33CFC 800588FC 08016254 */ j .L80058950 -/* 33D00 80058900 00620018 */ mult $v1, $v0 -.L80058904: -/* 33D04 80058904 86E20004 */ lh $v0, 4($s7) -/* 33D08 80058908 86E30006 */ lh $v1, 6($s7) -/* 33D0C 8005890C 00021040 */ sll $v0, $v0, 1 -/* 33D10 80058910 3C018008 */ lui $at, %hi(AuEqPower) -/* 33D14 80058914 00220821 */ addu $at, $at, $v0 -/* 33D18 80058918 84228E60 */ lh $v0, %lo(AuEqPower)($at) -/* 33D1C 8005891C 00620018 */ mult $v1, $v0 -/* 33D20 80058920 86E30004 */ lh $v1, 4($s7) -/* 33D24 80058924 00004012 */ mflo $t0 -/* 33D28 80058928 000813C3 */ sra $v0, $t0, 0xf -/* 33D2C 8005892C A6E20014 */ sh $v0, 0x14($s7) -/* 33D30 80058930 2402007F */ addiu $v0, $zero, 0x7f -/* 33D34 80058934 00431023 */ subu $v0, $v0, $v1 -/* 33D38 80058938 00021040 */ sll $v0, $v0, 1 -/* 33D3C 8005893C 86E30006 */ lh $v1, 6($s7) -/* 33D40 80058940 3C018008 */ lui $at, %hi(AuEqPower) -/* 33D44 80058944 00220821 */ addu $at, $at, $v0 -/* 33D48 80058948 84228E60 */ lh $v0, %lo(AuEqPower)($at) -/* 33D4C 8005894C 00620018 */ mult $v1, $v0 -.L80058950: -/* 33D50 80058950 00004012 */ mflo $t0 -/* 33D54 80058954 000813C3 */ sra $v0, $t0, 0xf -/* 33D58 80058958 A6E2001A */ sh $v0, 0x1a($s7) -/* 33D5C 8005895C 86E30008 */ lh $v1, 8($s7) -/* 33D60 80058960 86E40014 */ lh $a0, 0x14($s7) -/* 33D64 80058964 8EE50020 */ lw $a1, 0x20($s7) -/* 33D68 80058968 26E20010 */ addiu $v0, $s7, 0x10 -/* 33D6C 8005896C AFA20014 */ sw $v0, 0x14($sp) -/* 33D70 80058970 44836000 */ mtc1 $v1, $f12 -/* 33D74 80058974 00000000 */ nop -/* 33D78 80058978 46806321 */ cvt.d.w $f12, $f12 -/* 33D7C 8005897C 44847000 */ mtc1 $a0, $f14 -/* 33D80 80058980 00000000 */ nop -/* 33D84 80058984 468073A1 */ cvt.d.w $f14, $f14 -/* 33D88 80058988 0C01631B */ jal _getRate -/* 33D8C 8005898C AFA50010 */ sw $a1, 0x10($sp) -/* 33D90 80058990 86E3000A */ lh $v1, 0xa($s7) -/* 33D94 80058994 86E4001A */ lh $a0, 0x1a($s7) -/* 33D98 80058998 8EE50020 */ lw $a1, 0x20($s7) -/* 33D9C 8005899C A6E20012 */ sh $v0, 0x12($s7) -/* 33DA0 800589A0 26E20016 */ addiu $v0, $s7, 0x16 -/* 33DA4 800589A4 AFA20014 */ sw $v0, 0x14($sp) -/* 33DA8 800589A8 44836000 */ mtc1 $v1, $f12 -/* 33DAC 800589AC 00000000 */ nop -/* 33DB0 800589B0 46806321 */ cvt.d.w $f12, $f12 -/* 33DB4 800589B4 44847000 */ mtc1 $a0, $f14 -/* 33DB8 800589B8 00000000 */ nop -/* 33DBC 800589BC 468073A1 */ cvt.d.w $f14, $f14 -/* 33DC0 800589C0 0C01631B */ jal _getRate -/* 33DC4 800589C4 AFA50010 */ sw $a1, 0x10($sp) -/* 33DC8 800589C8 02C0202D */ daddu $a0, $s6, $zero -/* 33DCC 800589CC 26D60008 */ addiu $s6, $s6, 8 -/* 33DD0 800589D0 02C0282D */ daddu $a1, $s6, $zero -/* 33DD4 800589D4 26D60008 */ addiu $s6, $s6, 8 -/* 33DD8 800589D8 02C0302D */ daddu $a2, $s6, $zero -/* 33DDC 800589DC 26D60008 */ addiu $s6, $s6, 8 -/* 33DE0 800589E0 3C030900 */ lui $v1, 0x900 -/* 33DE4 800589E4 A6E20018 */ sh $v0, 0x18($s7) -/* 33DE8 800589E8 96E20014 */ lhu $v0, 0x14($s7) -/* 33DEC 800589EC 02C0802D */ daddu $s0, $s6, $zero -/* 33DF0 800589F0 00431025 */ or $v0, $v0, $v1 -/* 33DF4 800589F4 AC820000 */ sw $v0, ($a0) -/* 33DF8 800589F8 96E20012 */ lhu $v0, 0x12($s7) -/* 33DFC 800589FC 96E30010 */ lhu $v1, 0x10($s7) -/* 33E00 80058A00 00021400 */ sll $v0, $v0, 0x10 -/* 33E04 80058A04 00431025 */ or $v0, $v0, $v1 -/* 33E08 80058A08 AC820004 */ sw $v0, 4($a0) -/* 33E0C 80058A0C 96E20008 */ lhu $v0, 8($s7) -/* 33E10 80058A10 3C030906 */ lui $v1, 0x906 -/* 33E14 80058A14 00431025 */ or $v0, $v0, $v1 -/* 33E18 80058A18 ACA20000 */ sw $v0, ($a1) -/* 33E1C 80058A1C 96E2000C */ lhu $v0, 0xc($s7) -/* 33E20 80058A20 96E3000E */ lhu $v1, 0xe($s7) -/* 33E24 80058A24 00021400 */ sll $v0, $v0, 0x10 -/* 33E28 80058A28 00431025 */ or $v0, $v0, $v1 -/* 33E2C 80058A2C ACA20004 */ sw $v0, 4($a1) -/* 33E30 80058A30 96E2001A */ lhu $v0, 0x1a($s7) -/* 33E34 80058A34 3C030904 */ lui $v1, 0x904 -/* 33E38 80058A38 00431025 */ or $v0, $v0, $v1 -/* 33E3C 80058A3C ACC20000 */ sw $v0, ($a2) -/* 33E40 80058A40 96E20018 */ lhu $v0, 0x18($s7) -/* 33E44 80058A44 96E30016 */ lhu $v1, 0x16($s7) -/* 33E48 80058A48 00021400 */ sll $v0, $v0, 0x10 -/* 33E4C 80058A4C 00431025 */ or $v0, $v0, $v1 -/* 33E50 80058A50 ACC20004 */ sw $v0, 4($a2) -/* 33E54 80058A54 96E2000A */ lhu $v0, 0xa($s7) -/* 33E58 80058A58 3C030301 */ lui $v1, 0x301 -/* 33E5C 80058A5C 0801629B */ j .L80058A6C -/* 33E60 80058A60 00431025 */ or $v0, $v0, $v1 -.L80058A64: -/* 33E64 80058A64 02C0802D */ daddu $s0, $s6, $zero -/* 33E68 80058A68 3C020300 */ lui $v0, 0x300 -.L80058A6C: -/* 33E6C 80058A6C AE020000 */ sw $v0, ($s0) -/* 33E70 80058A70 8EE40000 */ lw $a0, ($s7) -/* 33E74 80058A74 0C0187A4 */ jal osVirtualToPhysical -/* 33E78 80058A78 26D60008 */ addiu $s6, $s6, 8 -/* 33E7C 80058A7C AE020004 */ sw $v0, 4($s0) -/* 33E80 80058A80 8EE2001C */ lw $v0, 0x1c($s7) -/* 33E84 80058A84 8EE30020 */ lw $v1, 0x20($s7) -/* 33E88 80058A88 244200B8 */ addiu $v0, $v0, 0xb8 -/* 33E8C 80058A8C AEE2001C */ sw $v0, 0x1c($s7) -/* 33E90 80058A90 0062102A */ slt $v0, $v1, $v0 -/* 33E94 80058A94 54400001 */ bnel $v0, $zero, .L80058A9C -/* 33E98 80058A98 AEE3001C */ sw $v1, 0x1c($s7) -.L80058A9C: -/* 33E9C 80058A9C 8EE20028 */ lw $v0, 0x28($s7) -/* 33EA0 80058AA0 14400013 */ bnez $v0, .L80058AF0 -/* 33EA4 80058AA4 02C0102D */ daddu $v0, $s6, $zero -/* 33EA8 80058AA8 24020001 */ addiu $v0, $zero, 1 -/* 33EAC 80058AAC AEE20024 */ sw $v0, 0x24($s7) -/* 33EB0 80058AB0 A6E20006 */ sh $v0, 6($s7) -/* 33EB4 80058AB4 8FA80020 */ lw $t0, 0x20($sp) -/* 33EB8 80058AB8 AD000008 */ sw $zero, 8($t0) -/* 33EBC 80058ABC AD02000C */ sw $v0, 0xc($t0) -/* 33EC0 80058AC0 8E430014 */ lw $v1, 0x14($s2) -/* 33EC4 80058AC4 AE400028 */ sw $zero, 0x28($s2) -/* 33EC8 80058AC8 AE42002C */ sw $v0, 0x2c($s2) -/* 33ECC 80058ACC AE400024 */ sw $zero, 0x24($s2) -/* 33ED0 80058AD0 8C620000 */ lw $v0, ($v1) -/* 33ED4 80058AD4 AE420030 */ sw $v0, 0x30($s2) -/* 33ED8 80058AD8 8C620014 */ lw $v0, 0x14($v1) -/* 33EDC 80058ADC AE420010 */ sw $v0, 0x10($s2) -/* 33EE0 80058AE0 8FA80060 */ lw $t0, 0x60($sp) -/* 33EE4 80058AE4 0C014B8C */ jal func_80052E30 -/* 33EE8 80058AE8 91040079 */ lbu $a0, 0x79($t0) -.L80058AEC: -/* 33EEC 80058AEC 02C0102D */ daddu $v0, $s6, $zero -.L80058AF0: -/* 33EF0 80058AF0 8FBF005C */ lw $ra, 0x5c($sp) -/* 33EF4 80058AF4 8FBE0058 */ lw $fp, 0x58($sp) -/* 33EF8 80058AF8 8FB70054 */ lw $s7, 0x54($sp) -/* 33EFC 80058AFC 8FB60050 */ lw $s6, 0x50($sp) -/* 33F00 80058B00 8FB5004C */ lw $s5, 0x4c($sp) -/* 33F04 80058B04 8FB40048 */ lw $s4, 0x48($sp) -/* 33F08 80058B08 8FB30044 */ lw $s3, 0x44($sp) -/* 33F0C 80058B0C 8FB20040 */ lw $s2, 0x40($sp) -/* 33F10 80058B10 8FB1003C */ lw $s1, 0x3c($sp) -/* 33F14 80058B14 8FB00038 */ lw $s0, 0x38($sp) -/* 33F18 80058B18 03E00008 */ jr $ra -/* 33F1C 80058B1C 27BD0060 */ addiu $sp, $sp, 0x60 diff --git a/ver/us/asm/shiftable/audio/2e230_len_2190/au_engine_init.s b/ver/us/asm/shiftable/audio/2e230_len_2190/au_engine_init.s index 1b53b3ccef..3a52d966cf 100644 --- a/ver/us/asm/shiftable/audio/2e230_len_2190/au_engine_init.s +++ b/ver/us/asm/shiftable/audio/2e230_len_2190/au_engine_init.s @@ -108,7 +108,7 @@ glabel au_engine_init /* 2E3F4 80052FF4 0000982D */ daddu $s3, $zero, $zero /* 2E3F8 80052FF8 8E840004 */ lw $a0, 4($s4) /* 2E3FC 80052FFC 44960000 */ mtc1 $s6, $f0 -/* 2E400 80053000 00000000 */ nop +/* 2E400 80053000 00000000 */ nop /* 2E404 80053004 46800020 */ cvt.s.w $f0, $f0 /* 2E408 80053008 AE820094 */ sw $v0, 0x94($s4) /* 2E40C 8005300C 0C014CBD */ jal au_reset_instrument @@ -118,7 +118,7 @@ glabel au_engine_init /* 2E41C 8005301C 0C014CEA */ jal au_reset_instrument_entry /* 2E420 80053020 26840014 */ addiu $a0, $s4, 0x14 /* 2E424 80053024 0C015843 */ jal bgm_clear_music_events -/* 2E428 80053028 00000000 */ nop +/* 2E428 80053028 00000000 */ nop /* 2E42C 8005302C 0280102D */ daddu $v0, $s4, $zero /* 2E430 80053030 AE8000A4 */ sw $zero, 0xa4($s4) /* 2E434 80053034 AE8000A8 */ sw $zero, 0xa8($s4) @@ -144,7 +144,7 @@ glabel au_engine_init .L8005307C: /* 2E47C 8005307C 327000FF */ andi $s0, $s3, 0xff /* 2E480 80053080 0200202D */ daddu $a0, $s0, $zero -/* 2E484 80053084 0C015BB0 */ jal func_80056EC0 +/* 2E484 80053084 0C015BB0 */ jal au_pvoice_set_group /* 2E488 80053088 0000282D */ daddu $a1, $zero, $zero /* 2E48C 8005308C 0200202D */ daddu $a0, $s0, $zero /* 2E490 80053090 8E850004 */ lw $a1, 4($s4) @@ -248,14 +248,14 @@ glabel au_engine_init .L80053214: /* 2E614 80053214 8E040000 */ lw $a0, ($s0) /* 2E618 80053218 0C012D8B */ jal au_sfx_load_groups_from_SEF -/* 2E61C 8005321C 00000000 */ nop +/* 2E61C 8005321C 00000000 */ nop /* 2E620 80053220 8E82003C */ lw $v0, 0x3c($s4) /* 2E624 80053224 24050040 */ addiu $a1, $zero, 0x40 /* 2E628 80053228 94440002 */ lhu $a0, 2($v0) /* 2E62C 8005322C 0C01511F */ jal au_fetch_SBN_file /* 2E630 80053230 27A60018 */ addiu $a2, $sp, 0x18 /* 2E634 80053234 14400004 */ bnez $v0, .L80053248 -/* 2E638 80053238 00000000 */ nop +/* 2E638 80053238 00000000 */ nop /* 2E63C 8005323C 8FA50018 */ lw $a1, 0x18($sp) /* 2E640 80053240 0C01513E */ jal au_load_PER /* 2E644 80053244 0280202D */ daddu $a0, $s4, $zero @@ -290,7 +290,7 @@ glabel au_engine_init /* 2E6B0 800532B0 A2800053 */ sb $zero, 0x53($s4) /* 2E6B4 800532B4 A2800052 */ sb $zero, 0x52($s4) /* 2E6B8 800532B8 A2800051 */ sb $zero, 0x51($s4) -/* 2E6BC 800532BC 0C015FB4 */ jal func_80057ED0 +/* 2E6BC 800532BC 0C015FB4 */ jal au_delay_channel /* 2E6C0 800532C0 A2800050 */ sb $zero, 0x50($s4) /* 2E6C4 800532C4 0C015414 */ jal func_80055050 /* 2E6C8 800532C8 02A0202D */ daddu $a0, $s5, $zero diff --git a/ver/us/symbol_addrs.txt b/ver/us/symbol_addrs.txt index 6b1445cf5d..2b8c20eac9 100644 --- a/ver/us/symbol_addrs.txt +++ b/ver/us/symbol_addrs.txt @@ -494,7 +494,7 @@ nuAuMgr = 0x8004AE08; // type:func rom:0x26208 nuAuDmaCallBack = 0x8004B074; // type:func rom:0x26474 nuAuDmaNew = 0x8004B224; // type:func rom:0x26624 nuAuCleanDMABuffers = 0x8004B268; // type:func rom:0x26668 -func_8004B328 = 0x8004B328; // type:func rom:0x26728 +nuAuPreNMIProc = 0x8004B328; // type:func rom:0x26728 alLink = 0x8004B3EC; // type:func rom:0x267EC alUnlink = 0x8004B40C; // type:func rom:0x2680C au_sfx_init = 0x8004B440; // type:func rom:0x26840 @@ -758,43 +758,43 @@ func_80056228 = 0x80056228; // type:func rom:0x31628 au_driver_init = 0x80056250; // type:func rom:0x31650 au_driver_release = 0x800565A4; // type:func rom:0x319A4 alAudioFrame = 0x800565C0; // type:func rom:0x319C0 -func_80056D34 = 0x80056D34; // type:func rom:0x32134 -func_80056D44 = 0x80056D44; // type:func rom:0x32144 -func_80056D50 = 0x80056D50; // type:func rom:0x32150 +au_use_global_volume = 0x80056D34; // type:func rom:0x32134 +au_set_global_volume = 0x80056D44; // type:func rom:0x32144 +au_get_global_volume = 0x80056D50; // type:func rom:0x32150 func_80056D5C = 0x80056D5C; // type:func rom:0x3215C -func_80056D78 = 0x80056D78; // type:func rom:0x32178 -func_80056DA4 = 0x80056DA4; // type:func rom:0x321A4 -func_80056DCC = 0x80056DCC; // type:func rom:0x321CC -func_80056E34 = 0x80056E34; // type:func rom:0x32234 -func_80056EC0 = 0x80056EC0; // type:func rom:0x322C0 +au_bus_set_volume = 0x80056D78; // type:func rom:0x32178 +au_bus_get_volume = 0x80056DA4; // type:func rom:0x321A4 +au_bus_set_effect = 0x80056DCC; // type:func rom:0x321CC +au_bus_set_fx_params = 0x80056E34; // type:func rom:0x32234 +au_pvoice_set_group = 0x80056EC0; // type:func rom:0x322C0 func_80056EE8 = 0x80056EE8; // type:func rom:0x322E8 -au_pvoice_set_playing = 0x80056F78; // type:func rom:0x32378 +au_syn_start_voice = 0x80056F78; // type:func rom:0x32378 func_80056FA4 = 0x80056FA4; // type:func rom:0x323A4 func_80057224 = 0x80057224; // type:func rom:0x32624 func_80057344 = 0x80057344; // type:func rom:0x32744 -func_8005736C = 0x8005736C; // type:func rom:0x3276C -func_80057548 = 0x80057548; // type:func rom:0x32948 -func_800576EC = 0x800576EC; // type:func rom:0x32AEC -func_80057874 = 0x80057874; // type:func rom:0x32C74 -func_800579D8 = 0x800579D8; // type:func rom:0x32DD8 -func_80057B64 = 0x80057B64; // type:func rom:0x32F64 -func_80057B8C = 0x80057B8C; // type:func rom:0x32F8C -func_80057BB4 = 0x80057BB4; // type:func rom:0x32FB4 -func_80057BDC = 0x80057BDC; // type:func rom:0x32FDC -func_80057C04 = 0x80057C04; // type:func rom:0x33004 -func_80057C2C = 0x80057C2C; // type:func rom:0x3302C -func_80057C54 = 0x80057C54; // type:func rom:0x33054 -func_80057D0C = 0x80057D0C; // type:func rom:0x3310C -func_80057DC8 = 0x80057DC8; // type:func rom:0x331C8 -func_80057E08 = 0x80057E08; // type:func rom:0x33208 -func_80057E5C = 0x80057E5C; // type:func rom:0x3325C -func_80057EB0 = 0x80057EB0; // type:func rom:0x332B0 -func_80057ED0 = 0x80057ED0; // type:func rom:0x332D0 +au_syn_set_mixer_params = 0x8005736C; // type:func rom:0x3276C +au_syn_set_pan_fxmix = 0x80057548; // type:func rom:0x32948 +au_syn_set_volume_delta = 0x800576EC; // type:func rom:0x32AEC +au_syn_set_pan = 0x80057874; // type:func rom:0x32C74 +au_syn_set_fxmix = 0x800579D8; // type:func rom:0x32DD8 +au_syn_get_playing = 0x80057B64; // type:func rom:0x32F64 +au_syn_get_bus = 0x80057B8C; // type:func rom:0x32F8C +au_syn_get_pitch = 0x80057BB4; // type:func rom:0x32FB4 +au_syn_get_pan = 0x80057BDC; // type:func rom:0x32FDC +au_syn_get_dryamt = 0x80057C04; // type:func rom:0x33004 +au_syn_get_wetamt = 0x80057C2C; // type:func rom:0x3302C +au_syn_get_volume_left = 0x80057C54; // type:func rom:0x33054 +au_syn_get_volume_right = 0x80057D0C; // type:func rom:0x3310C +au_set_delay_time = 0x80057DC8; // type:func rom:0x331C8 +au_delay_left_channel = 0x80057E08; // type:func rom:0x33208 +au_delay_right_channel = 0x80057E5C; // type:func rom:0x3325C +au_disable_channel_delay = 0x80057EB0; // type:func rom:0x332B0 +au_delay_channel = 0x80057ED0; // type:func rom:0x332D0 alHeapInit = 0x80057F20; // type:func rom:0x33320 alHeapAlloc = 0x80057F90; // type:func rom:0x33390 alCopy = 0x80057FD8; // type:func rom:0x333D8 func_80058004 = 0x80058004; // type:func rom:0x33404 -func_80058050 = 0x80058050; // type:func rom:0x33450 +au_pull_voice = 0x80058050; // type:func rom:0x33450 _decodeChunk = 0x80058B20; // type:func rom:0x33F20 _getRate = 0x80058C6C; // type:func rom:0x3406C _init_lpfilter = 0x80058DD0; // type:func rom:0x341D0 @@ -802,7 +802,7 @@ func_80058E84 = 0x80058E84; // type:func rom:0x34284 func_80058F88 = 0x80058F88; // type:func rom:0x34388 func_80059008 = 0x80059008; // type:func rom:0x34408 func_8005904C = 0x8005904C; // type:func rom:0x3444C -func_80059310 = 0x80059310; // type:func rom:0x34710 +au_pull_fx = 0x80059310; // type:func rom:0x34710 au_fx_param_hdl = 0x800598A0; // type:func rom:0x34CA0 _saveBuffer = 0x80059AB8; // type:func rom:0x34EB8 func_80059BD4 = 0x80059BD4; // type:func rom:0x34FD4 @@ -1423,9 +1423,9 @@ D_80078E14 = 0x80078E14; // type:data rom:0x54214 D_80078E30 = 0x80078E30; // type:data rom:0x54230 gActiveSynDriverPtr = 0x80078E50; // type:data rom:0x54250 gSynDriverPtr = 0x80078E54; // type:data rom:0x54254 -D_80078E58 = 0x80078E58; // type:data rom:0x54258 -D_80078E5A = 0x80078E5A; // type:data rom:0x5425A -D_80078E5C = 0x80078E5C; // type:data rom:0x5425C +AuUseGlobalVolume = 0x80078E58; // type:data rom:0x54258 +AuGlobalVolume = 0x80078E5A; // type:data rom:0x5425A +AuSynStereoDirty = 0x80078E5C; // type:data rom:0x5425C AlCosineBlend = 0x80078E60; // type:data rom:0x54260 D_80078EE0 = 0x80078EE0; // type:func rom:0x542E0 SMALLROOM_PARAMS_N = 0x8007EFE0; // type:data rom:0x5A3E0 @@ -2779,7 +2779,7 @@ phys_update_jump = 0x800E2D18; // type:func rom:0x7C1C8 D_800A0F40 = 0x800A0F40; // type:data rom:0x7C340 D_800A0F44 = 0x800A0F44; // type:data rom:0x7C344 D_800A0F48 = 0x800A0F48; // type:data rom:0x7C348 -D_800A0F50 = 0x800A0F50; // type:data rom:0x7C350 +AuInitialGlobalVolume = 0x800A0F50; // type:data rom:0x7C350 D_800A0F54 = 0x800A0F54; // type:data rom:0x7C354 nuAuMgrThread = 0x800A0F58; // type:data phys_init_integrator_for_current_state = 0x800E2F60; // type:func rom:0x7C410 @@ -2837,12 +2837,12 @@ set_action_state = 0x800E5DA4; // type:func rom:0x7F254 D_800A3FC8 = 0x800A3FC8; // type:data rom:0x7F3C8 CurrentSeqCmdHandler = 0x800A3FD0; // type:data rom:0x7F3D0 D_800A3FD4 = 0x800A3FD4; // type:data rom:0x7F3D4 -D_800A3FE0 = 0x800A3FE0; // type:data rom:0x7F3E0 -D_800A3FE4 = 0x800A3FE4; // type:data rom:0x7F3E4 -D_800A3FE8 = 0x800A3FE8; // type:data rom:0x7F3E8 -D_800A3FEC = 0x800A3FEC; // type:data rom:0x7F3EC -D_800A3FEE = 0x800A3FEE; // type:data rom:0x7F3EE -D_800A3FF0 = 0x800A3FF0; // type:data rom:0x7F3F0 +AuDelayBufferMain = 0x800A3FE0; // type:data rom:0x7F3E0 +AuDelayBufferAux = 0x800A3FE4; // type:data rom:0x7F3E4 +AuDelayCounter = 0x800A3FE8; // type:data rom:0x7F3E8 +AuDelayedVoiceGroup = 0x800A3FEC; // type:data rom:0x7F3EC +AuDelayedChannel = 0x800A3FEE; // type:data rom:0x7F3EE +AuDelayCount = 0x800A3FF0; // type:data rom:0x7F3F0 D_800A3FF4 = 0x800A3FF4; // type:data rom:0x7F3F4 gEffectGraphicsData = 0x800A4000; // type:data rom:0x7F400 update_locomotion_state = 0x800E5F68; // type:func rom:0x7F418