From 8f6fde697fbc3537026392845756930648db35f6 Mon Sep 17 00:00:00 2001 From: Gregory Heskett Date: Wed, 7 Jun 2023 13:58:59 -0400 Subject: [PATCH] Disable Stereo Headset Effects and stub out all known code references via define (#633) * Disable stereoheadseteffects and stub out all known code references via define By effect this also completely removes Headset sound options from the game config, as it serves no purpose whatsoever compared to stereo. Because it's stubbed out everywhere rather than only the necessary locations to prevent it, this should boost audio runtime slightly for everything, not just the stuff that actively used it. * Rename DISABLE_HEADSET_STEREO_EFFECTS to ENABLE_HEADSET_STEREO_EFFECTS * Reorganize and reduce audio Note struct * Add performance to define description * Rename ENABLE_HEADSET_STEREO_EFFECTS to ENABLE_STEREO_HEADSET_EFFECTS --- include/config/config_audio.h | 8 ++++ include/seq_macros.inc | 4 ++ src/audio/data.c | 4 ++ src/audio/data.h | 4 ++ src/audio/internal.h | 85 ++++++++++++++++++----------------- src/audio/playback.c | 7 ++- src/audio/seqplayer.c | 7 +++ src/audio/synthesis.c | 62 ++++++++++++++++++++----- src/game/profiling.c | 4 +- src/game/sound_init.c | 4 ++ src/menu/file_select.c | 27 ++++++++++- src/menu/file_select.h | 2 + 12 files changed, 163 insertions(+), 55 deletions(-) diff --git a/include/config/config_audio.h b/include/config/config_audio.h index 79dca44a7..268cccf5e 100644 --- a/include/config/config_audio.h +++ b/include/config/config_audio.h @@ -21,6 +21,14 @@ */ // #define DISABLE_MARIO_PITCH_SHIFTING +/** + * Enables the funky sound processing that takes place with sound effects, that can sometimes cause sounds like the waterfall in castle grounds to sound more unpleasant than necessary. + * This is not the same thing as enabling stereo audio, but it does completely represent the sole differences between the Stereo and Headset sound options. + * Because of this, the Headset sound option will also not appear in the file select menu with this disabled. + * Leaving this disabled may also be slightly beneficial for CPU performance. + */ +// #define ENABLE_STEREO_HEADSET_EFFECTS + /** * Increase audio heap size to allow for larger/more custom sequences/banks/sfx to be imported without causing issues (not supported for SH). * Note that this is REQUIRED in order to use the extended 0C audio bank. Do not disable this if you're planning on using it. diff --git a/include/seq_macros.inc b/include/seq_macros.inc index 056176b13..1d12e1ab5 100644 --- a/include/seq_macros.inc +++ b/include/seq_macros.inc @@ -282,8 +282,12 @@ .endm .macro chan_stereoheadseteffects a +#ifdef ENABLE_STEREO_HEADSET_EFFECTS .byte 0xd0 .byte \a +#else + // Feel free to hijack this command for something else if it's not being used! +#endif .endm .macro chan_setnoteallocationpolicy a diff --git a/src/audio/data.c b/src/audio/data.c index 55784d6fd..9515c25e0 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -612,8 +612,10 @@ u16 gHeadsetPanQuantization[0x10] = { 0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0, }; #elif !defined(VERSION_SH) +#ifdef ENABLE_STEREO_HEADSET_EFFECTS u16 gHeadsetPanQuantization[10] = { 0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0 }; #endif +#endif #if defined(VERSION_EU) || defined(VERSION_SH) s16 euUnknownData_80301950[64] = { @@ -622,6 +624,7 @@ s16 euUnknownData_80301950[64] = { }; #endif +#ifdef ENABLE_STEREO_HEADSET_EFFECTS // Linearly interpolated between // f(0/2 * 127) = 1 // f(1/2 * 127) = 1/sqrt(2) @@ -667,6 +670,7 @@ f32 gStereoPanVolume[128] = { 0.242161f, 0.253295f, 0.264429f, 0.275563f, 0.286697f, 0.297831f, 0.308965f, 0.320098f, 0.331232f, 0.342366f, 0.3535f }; +#endif // gDefaultVolume[k] = cos(pi/2 * k / 127) f32 gDefaultPanVolume[128] = { diff --git a/src/audio/data.h b/src/audio/data.h index 5a60baac2..e614eaa29 100644 --- a/src/audio/data.h +++ b/src/audio/data.h @@ -87,10 +87,14 @@ extern s16 euUnknownData_80301950[64]; extern struct NoteSubEu gZeroNoteSub; extern struct NoteSubEu gDefaultNoteSub; #else +#ifdef ENABLE_STEREO_HEADSET_EFFECTS extern u16 gHeadsetPanQuantization[10]; #endif +#endif +#ifdef ENABLE_STEREO_HEADSET_EFFECTS extern f32 gHeadsetPanVolume[128]; extern f32 gStereoPanVolume[128]; +#endif extern f32 gDefaultPanVolume[128]; extern f32 gVolRampingLhs136[1 << VOL_RAMPING_EXPONENT]; diff --git a/src/audio/internal.h b/src/audio/internal.h index 4f110c08b..e9c65bc93 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -420,7 +420,11 @@ struct SequenceChannel { /*0x00, 0x00*/ u8 stopScript : 1; /*0x00, 0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething /*0x00, 0x00*/ u8 hasInstrument : 1; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS /*0x00, 0x00*/ u8 stereoHeadsetEffects : 1; +#else + /*0x00, 0x00*/ u8 paddingBit : 1; +#endif /*0x00, ????*/ u8 largeNotes : 1; // notes specify duration and velocity /*0x00, ????*/ u8 unused : 1; // never read, set to 0 #if defined(VERSION_EU) || defined(VERSION_SH) @@ -667,51 +671,52 @@ struct Note { /*0x00*/ u8 restart : 1; /*0x00*/ u8 finished : 1; /*0x00*/ u8 envMixerNeedsInit : 1; - /*0x00*/ u8 stereoStrongRight : 1; - /*0x00*/ u8 stereoStrongLeft : 1; + /*0x00*/ u8 initFullVelocity : 1; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS /*0x00*/ u8 stereoHeadsetEffects : 1; - /*0x01*/ u8 usesHeadsetPanEffects : 1; - /*0x01*/ u8 initFullVelocity : 1; - /* */ u8 pad0 : 6; - /*0x02*/ u8 unk2; - /*0x03*/ u8 sampleDmaIndex; - /*0x04, 0x30*/ u8 priority; - /*0x05*/ u8 sampleCount; // 0, 8, 16, 32 or 64 - /*0x06*/ u8 instOrWave; - /*0x07*/ u8 bankId; // in NoteSubEu on EU + /*0x00*/ u8 usesHeadsetPanEffects : 1; + /*0x01*/ u8 stereoStrongRight : 1; + /*0x01*/ u8 stereoStrongLeft : 1; +#else + /* */ u8 pad0[0x01]; +#endif + /*0x02*/ u8 sampleDmaIndex; + /*0x03*/ u8 priority; + /*0x04*/ u8 sampleCount; // 0, 8, 16, 32 or 64 + /*0x05*/ u8 instOrWave; + /*0x06*/ u8 bankId; // in NoteSubEu on EU + /*0x07*/ u8 reverbVol; // Q1.7 /*0x08*/ s16 adsrVolScale; - /* */ u8 pad1[2]; - /*0x0C, 0xB3*/ u16 headsetPanRight; - /*0x0E, 0xB4*/ u16 headsetPanLeft; - /*0x10*/ u16 prevHeadsetPanRight; - /*0x12*/ u16 prevHeadsetPanLeft; - /*0x14*/ s32 samplePosInt; - /*0x18, 0x38*/ f32 portamentoFreqScale; - /*0x1C, 0x3C*/ f32 vibratoFreqScale; - /*0x20*/ u16 samplePosFrac; - /* */ u8 pad2[2]; - /*0x24*/ struct AudioBankSound *sound; - /*0x28, 0x40*/ struct SequenceChannelLayer *prevParentLayer; - /*0x2C, 0x44*/ struct SequenceChannelLayer *parentLayer; - /*0x30, 0x48*/ struct SequenceChannelLayer *wantedParentLayer; - /*0x34*/ struct NoteSynthesisBuffers *synthesisBuffers; - /*0x38*/ f32 frequency; - /*0x3C*/ u16 targetVolLeft; // Q1.15, but will always be non-negative - /*0x3E*/ u16 targetVolRight; // Q1.15, but will always be non-negative - /*0x40*/ u8 reverbVol; // Q1.7 - /*0x41*/ u8 unused1; // never read, set to 0x3f - /* */ u8 pad3[2]; - /*0x44*/ struct NoteAttributes attributes; - /*0x54, 0x58*/ struct AdsrState adsr; - /*0x74, 0x7C*/ struct Portamento portamento; - /*0x84, 0x8C*/ struct VibratoState vibratoState; + /*0x0A*/ u16 samplePosFrac; + /*0x0C*/ s32 samplePosInt; + /*0x10*/ f32 portamentoFreqScale; + /*0x14*/ f32 vibratoFreqScale; + /*0x18*/ struct AudioBankSound *sound; + /*0x1C*/ struct SequenceChannelLayer *prevParentLayer; + /*0x20*/ struct SequenceChannelLayer *parentLayer; + /*0x24*/ struct SequenceChannelLayer *wantedParentLayer; + /*0x28*/ struct NoteSynthesisBuffers *synthesisBuffers; + /*0x2C*/ f32 frequency; + /*0x30*/ u16 targetVolLeft; // Q1.15, but will always be non-negative + /*0x32*/ u16 targetVolRight; // Q1.15, but will always be non-negative + /*0x34*/ struct NoteAttributes attributes; + /*0x44*/ struct AdsrState adsr; + /*0x64*/ struct Portamento portamento; + /*0x74*/ struct VibratoState vibratoState; + /*0x8C*/ struct AudioListItem listItem; /*0x9C*/ s16 curVolLeft; // Q1.15, but will always be non-negative /*0x9E*/ s16 curVolRight; // Q1.15, but will always be non-negative /*0xA0*/ s16 reverbVolShifted; // Q1.15 - /*0xA2*/ s16 unused2; // never read, set to 0 - /*0xA4, 0x00*/ struct AudioListItem listItem; - /* */ u8 pad4[0xc]; -}; // size = 0xC0 +#ifdef ENABLE_STEREO_HEADSET_EFFECTS + /*0xA2*/ u16 headsetPanRight; + /*0xA4*/ u16 headsetPanLeft; + /*0xA6*/ u16 prevHeadsetPanRight; + /*0xA8*/ u16 prevHeadsetPanLeft; + /* */ u8 align16Padding[0x06]; +#else + /* */ u8 align16Padding[0x0E]; +#endif +}; // size = 0xB0 #endif struct NoteSynthesisBuffers { diff --git a/src/audio/playback.c b/src/audio/playback.c index 2e3b91a45..50622a4b9 100644 --- a/src/audio/playback.c +++ b/src/audio/playback.c @@ -1156,7 +1156,9 @@ s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer } note->bankId = seqLayer->seqChannel->bankId; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS note->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects; +#endif note->sound = seqLayer->sound; seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded" seqLayer->note = note; @@ -1410,9 +1412,12 @@ void note_init_all(void) { note->noteSubEu = gZeroNoteSub; #else note->enabled = FALSE; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS note->stereoStrongRight = FALSE; note->stereoStrongLeft = FALSE; note->stereoHeadsetEffects = FALSE; + note->usesHeadsetPanEffects = FALSE; +#endif #endif note->priority = NOTE_PRIORITY_DISABLED; #ifdef VERSION_SH @@ -1426,14 +1431,12 @@ void note_init_all(void) { note->vibratoState.active = FALSE; #else note->reverbVol = 0; - note->usesHeadsetPanEffects = FALSE; note->initFullVelocity = FALSE; note->sampleCount = 0; note->instOrWave = 0; note->targetVolLeft = 0; note->targetVolRight = 0; note->frequency = 0.0f; - note->unused1 = 0x3f; note->vibratoState.activeFlags = VIBMODE_NONE; #endif note->attributes.velocity = 0.0f; diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 423062ddc..1e139b2b1 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -27,7 +27,9 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) { seqChannel->stopScript = FALSE; seqChannel->stopSomething2 = FALSE; seqChannel->hasInstrument = FALSE; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS seqChannel->stereoHeadsetEffects = FALSE; +#endif seqChannel->transposition = 0; seqChannel->largeNotes = FALSE; #if defined(VERSION_EU) || defined(VERSION_SH) @@ -1867,7 +1869,12 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { #endif case 0xd0: // chan_stereoheadseteffects +#ifdef ENABLE_STEREO_HEADSET_EFFECTS seqChannel->stereoHeadsetEffects = m64_read_u8(state); +#else + // NOTE: Vanilla music does not use 0xd0, so this is safe to repurpose entirely when ENABLE_STEREO_HEADSET_EFFECTS is disabled. + m64_read_u8(state); +#endif break; case 0xd1: // chan_setnoteallocationpolicy diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index ef798d1c8..de5bf8985 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -78,11 +78,15 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struc #else u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd); u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad); -u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings, - u32 flags); +#ifdef ENABLE_STEREO_HEADSET_EFFECTS +u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings); u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings, struct VolumeChange *vol); u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32 flags, s32 leftRight); +#else +u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf); +u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, struct VolumeChange *vol); +#endif #endif #ifdef VERSION_EU @@ -841,7 +845,9 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) { s32 nSamplesToProcess; // sp10c/a0, spE0 #endif +#ifdef ENABLE_STEREO_HEADSET_EFFECTS s32 leftRight; +#endif s32 s3; s32 s5; //s4 @@ -1257,6 +1263,7 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) { aResample(cmd++, flags, resamplingRateFixedPoint, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->finalResampleState)); #endif +#ifdef ENABLE_STEREO_HEADSET_EFFECTS #ifdef VERSION_EU if (noteSubEu->headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0) { leftRight = 1; @@ -1276,7 +1283,7 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) { #ifdef VERSION_EU cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, 0, leftRight, flags); #else - cmd = process_envelope(cmd, note, bufLen, 0, leftRight, flags); + cmd = process_envelope(cmd, note, bufLen, 0, leftRight); #endif AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING); @@ -1288,6 +1295,11 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) { if (note->usesHeadsetPanEffects) { cmd = note_apply_headset_pan_effects(cmd, note, bufLen * 2, flags, leftRight); } +#endif +#else + AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB); + cmd = process_envelope(cmd, note, bufLen, 0); + AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING); #endif } #ifndef VERSION_EU @@ -1344,8 +1356,11 @@ u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) { #endif #ifndef VERSION_EU -u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings, - UNUSED u32 flags) { +#ifdef ENABLE_STEREO_HEADSET_EFFECTS +u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings) { +#else +u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf) { +#endif struct VolumeChange vol; if (note->initFullVelocity) { note->initFullVelocity = FALSE; @@ -1359,11 +1374,20 @@ u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 vol.targetRight = note->targetVolRight; note->curVolLeft = vol.targetLeft; note->curVolRight = vol.targetRight; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS return process_envelope_inner(cmd, note, nSamples, inBuf, headsetPanSettings, &vol); +#else + return process_envelope_inner(cmd, note, nSamples, inBuf, &vol); +#endif } +#ifdef ENABLE_STEREO_HEADSET_EFFECTS u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings, struct VolumeChange *vol) { +#else +u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, + struct VolumeChange *vol) { +#endif u8 mixerFlags; s32 rampLeft, rampRight; #elif defined(VERSION_EU) @@ -1394,6 +1418,7 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat // in, dry left, count without A_AUX flag. // dry right, wet left, wet right with A_AUX flag. +#ifdef ENABLE_STEREO_HEADSET_EFFECTS if (note->usesHeadsetPanEffects) { aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DEFAULT_LEN_1CH); @@ -1433,6 +1458,10 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat aSetBuffer(cmd++, A_AUX, DMEM_ADDR_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_RIGHT_CH); } } +#else + aSetBuffer(cmd++, 0, inBuf, DMEM_ADDR_LEFT_CH, nSamples * 2); + aSetBuffer(cmd++, A_AUX, DMEM_ADDR_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_RIGHT_CH); +#endif #ifdef VERSION_EU if (targetLeft == sourceLeft && targetRight == sourceRight && !note->envMixerNeedsInit) { @@ -1484,6 +1513,7 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat #endif } +#ifdef ENABLE_STEREO_HEADSET_EFFECTS #ifdef VERSION_EU if (gUseReverb && note->reverbVol != 0) { aEnvMixer(cmd++, mixerFlags | A_AUX, @@ -1519,9 +1549,16 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat /*out*/ DMEM_ADDR_RIGHT_CH); } } +#else + if (gSynthesisReverb.useReverb && note->reverbVol != 0) { + mixerFlags |= A_AUX; + } + aEnvMixer(cmd++, mixerFlags, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->mixEnvelopeState)); +#endif return cmd; } +#ifdef ENABLE_STEREO_HEADSET_EFFECTS #ifdef VERSION_EU u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) { #else @@ -1617,6 +1654,7 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32 return cmd; } +#endif #ifndef VERSION_EU // Moved to playback.c in EU @@ -1626,7 +1664,6 @@ void note_init_volume(struct Note *note) { note->targetVolRight = 0; note->reverbVol = 0; note->reverbVolShifted = 0; - note->unused2 = 0; note->curVolLeft = 1; note->curVolRight = 1; note->frequency = 0.0f; @@ -1635,7 +1672,12 @@ void note_init_volume(struct Note *note) { void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverbVol) { f32 volLeft, volRight; s32 panIndex = (s32)(pan * 127.5f) & 127; - if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_HEADSET) { + + if (gSoundMode == SOUND_MODE_MONO) { + volLeft = 0.707f; + volRight = 0.707f; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS + } else if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_HEADSET) { s8 smallPanIndex; s8 temp = (s8)(pan * 10.0f); if (temp < 9) { @@ -1665,9 +1707,7 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb } note->stereoStrongRight = strongRight; note->stereoStrongLeft = strongLeft; - } else if (gSoundMode == SOUND_MODE_MONO) { - volLeft = 0.707f; - volRight = 0.707f; +#endif } else { volLeft = gDefaultPanVolume[panIndex]; volRight = gDefaultPanVolume[127 - panIndex]; @@ -1703,6 +1743,7 @@ void note_enable(struct Note *note) { note->needsInit = TRUE; note->restart = FALSE; note->finished = FALSE; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS note->stereoStrongRight = FALSE; note->stereoStrongLeft = FALSE; note->usesHeadsetPanEffects = FALSE; @@ -1711,6 +1752,7 @@ void note_enable(struct Note *note) { note->headsetPanRight = 0; note->prevHeadsetPanRight = 0; note->prevHeadsetPanLeft = 0; +#endif } void note_disable(struct Note *note) { diff --git a/src/game/profiling.c b/src/game/profiling.c index 644dff473..75d3e6f5e 100644 --- a/src/game/profiling.c +++ b/src/game/profiling.c @@ -259,7 +259,7 @@ void profiler_print_times() { // audio time is removed from the main thread profiling, so add it back here u32 total_cpu = microseconds[PROFILER_TIME_TOTAL] + microseconds[PROFILER_TIME_AUDIO] * 2; - u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO]; + u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO] * 2; u32 max_rdp = MAX(MAX(microseconds[PROFILER_TIME_TMEM], microseconds[PROFILER_TIME_CMD]), microseconds[PROFILER_TIME_PIPE]); sprintf(text_buffer, @@ -309,7 +309,7 @@ void profiler_print_times() { microseconds[PROFILER_TIME_PIPE], total_rsp, total_rsp / 333, microseconds[PROFILER_TIME_RSP_GFX], - microseconds[PROFILER_TIME_RSP_AUDIO] + microseconds[PROFILER_TIME_RSP_AUDIO] * 2 ); Gfx* dlHead = gDisplayListHead; diff --git a/src/game/sound_init.c b/src/game/sound_init.c index d0988f59f..4d79c72b0 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -36,7 +36,11 @@ static u16 sCurrentCapMusic = MUSIC_NONE; #ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS static u8 sPlayingInfiniteStairs = FALSE; #endif +#ifdef ENABLE_STEREO_HEADSET_EFFECTS static s16 sSoundMenuModeToSoundMode[3] = { SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET }; +#else +static s16 sSoundMenuModeToSoundMode[2] = { SOUND_MODE_STEREO, SOUND_MODE_MONO }; +#endif // Only the 20th array element is used. static u32 sMenuSoundsExtra[] = { SOUND_MOVING_TERRAIN_SLIDE + (0 << 16), diff --git a/src/menu/file_select.c b/src/menu/file_select.c index 2b152aba6..ce205042c 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -119,7 +119,11 @@ unsigned char textCopyFileButton[] = { TEXT_COPY_FILE_BUTTON }; unsigned char textEraseFileButton[] = { TEXT_ERASE_FILE_BUTTON }; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS unsigned char textSoundModes[][8] = { { TEXT_STEREO }, { TEXT_MONO }, { TEXT_HEADSET } }; +#else +unsigned char textSoundModes[][8] = { { TEXT_STEREO }, { TEXT_MONO } }; +#endif #if MULTILANG unsigned char textLanguageSelect[][17] = { { TEXT_LANGUAGE_SELECT } }; @@ -788,6 +792,7 @@ void check_erase_menu_clicked_buttons(struct Object *eraseButton) { * Render buttons for the sound mode menu. */ void render_sound_mode_menu_buttons(struct Object *soundModeButton) { +#ifdef ENABLE_STEREO_HEADSET_EFFECTS // Stereo option button sMainMenuButtons[MENU_BUTTON_STEREO] = spawn_object_rel_with_rot( soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, 533, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0); @@ -800,6 +805,16 @@ void render_sound_mode_menu_buttons(struct Object *soundModeButton) { sMainMenuButtons[MENU_BUTTON_HEADSET] = spawn_object_rel_with_rot( soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, -533, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0); sMainMenuButtons[MENU_BUTTON_HEADSET]->oMenuButtonScale = MENU_BUTTON_SCALE; +#else + // Stereo option button + sMainMenuButtons[MENU_BUTTON_STEREO] = spawn_object_rel_with_rot( + soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, 355, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0); + sMainMenuButtons[MENU_BUTTON_STEREO]->oMenuButtonScale = MENU_BUTTON_SCALE; + // Mono option button + sMainMenuButtons[MENU_BUTTON_MONO] = spawn_object_rel_with_rot( + soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, -355, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0); + sMainMenuButtons[MENU_BUTTON_MONO]->oMenuButtonScale = MENU_BUTTON_SCALE; +#endif #if MULTILANG // English option button @@ -841,8 +856,12 @@ void check_sound_mode_menu_clicked_buttons(struct Object *soundModeButton) { if (check_clicked_button(buttonX, buttonY, 22.0f) == TRUE) { // If sound mode button clicked, select it and define sound mode // The check will always be true because of the group configured above (In JP & US) +#ifdef ENABLE_STEREO_HEADSET_EFFECTS if (buttonID == MENU_BUTTON_STEREO || buttonID == MENU_BUTTON_MONO || buttonID == MENU_BUTTON_HEADSET) { +#else + if (buttonID == MENU_BUTTON_STEREO || buttonID == MENU_BUTTON_MONO) { +#endif if (soundModeButton->oMenuButtonActionPhase == SOUND_MODE_PHASE_MAIN) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); #if ENABLE_RUMBLE @@ -1150,7 +1169,9 @@ void bhv_menu_button_manager_loop(void) { // exiting the Options menu, as a result they added a return button case MENU_BUTTON_STEREO: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_STEREO ]); break; case MENU_BUTTON_MONO: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_MONO ]); break; +#ifdef ENABLE_STEREO_HEADSET_EFFECTS case MENU_BUTTON_HEADSET: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_HEADSET]); break; +#endif } sClickPos[0] = -10000; @@ -1782,7 +1803,11 @@ void print_sound_mode_menu_strings(void) { gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); // Print sound mode names - for (mode = 0, textX = 90; mode < 3; textX += 70, mode++) { +#ifdef ENABLE_STEREO_HEADSET_EFFECTS + for (mode = 0, textX = 87; mode < ARRAY_COUNT(textSoundModes); textX += 74, mode++) { +#else + for (mode = 0, textX = 111; mode < ARRAY_COUNT(textSoundModes); textX += 99, mode++) { +#endif if (mode == sSoundMode) { gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, sTextBaseAlpha); } else { diff --git a/src/menu/file_select.h b/src/menu/file_select.h index 475a0906d..b6ad1e4c3 100644 --- a/src/menu/file_select.h +++ b/src/menu/file_select.h @@ -81,7 +81,9 @@ enum MenuButtonTypes { MENU_BUTTON_OPTION_MIN, MENU_BUTTON_STEREO = MENU_BUTTON_OPTION_MIN, MENU_BUTTON_MONO, +#ifdef ENABLE_STEREO_HEADSET_EFFECTS MENU_BUTTON_HEADSET, +#endif #if MULTILANG // Language Menu