1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 17:54:15 +00:00

Document File-Select Audio Settings: Sound Modes (#1281)

* Round 1

* Cleanup

* Cleanup

* Space

* More spacing

* Apply -> Set (consistency)

* round 1 pr

* Revert some names
This commit is contained in:
engineer124 2022-06-24 19:27:54 -04:00 committed by GitHub
parent 984871eb38
commit fe7afb9b07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 24 deletions

View file

@ -1951,7 +1951,7 @@ void func_800F64E0(u8 arg0);
void func_800F6584(u8 arg0); void func_800F6584(u8 arg0);
void Audio_SetEnvReverb(s8 reverb); void Audio_SetEnvReverb(s8 reverb);
void Audio_SetCodeReverb(s8 reverb); void Audio_SetCodeReverb(s8 reverb);
void func_800F6700(s8 arg0); void func_800F6700(s8 audioSetting);
void Audio_SetBaseFilter(u8); void Audio_SetBaseFilter(u8);
void Audio_SetExtraFilter(u8); void Audio_SetExtraFilter(u8);
void Audio_SetCutsceneFlag(s8 flag); void Audio_SetCutsceneFlag(s8 flag);

View file

@ -24,6 +24,13 @@
#define AUDIO_RELOCATED_ADDRESS_START K0BASE #define AUDIO_RELOCATED_ADDRESS_START K0BASE
typedef enum {
/* 0 */ SOUNDMODE_STEREO,
/* 1 */ SOUNDMODE_HEADSET,
/* 2 */ SOUNDMODE_SURROUND,
/* 3 */ SOUNDMODE_MONO
} SoundMode;
typedef enum { typedef enum {
/* 0 */ ADSR_STATE_DISABLED, /* 0 */ ADSR_STATE_DISABLED,
/* 1 */ ADSR_STATE_INITIAL, /* 1 */ ADSR_STATE_INITIAL,

View file

@ -1168,7 +1168,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
gAudioContext.totalTaskCount = 0; gAudioContext.totalTaskCount = 0;
gAudioContext.rspTaskIndex = 0; gAudioContext.rspTaskIndex = 0;
gAudioContext.curAiBufIndex = 0; gAudioContext.curAiBufIndex = 0;
gAudioContext.soundMode = 0; gAudioContext.soundMode = SOUNDMODE_STEREO;
gAudioContext.curTask = NULL; gAudioContext.curTask = NULL;
gAudioContext.rspTask[0].task.t.data_size = 0; gAudioContext.rspTask[0].task.t.data_size = 0;
gAudioContext.rspTask[1].task.t.data_size = 0; gAudioContext.rspTask[1].task.t.data_size = 0;

View file

@ -30,7 +30,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
sub->bitField0.stereoStrongLeft = false; sub->bitField0.stereoStrongLeft = false;
sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects;
sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects;
if (stereoHeadsetEffects && gAudioContext.soundMode == 1) { if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_HEADSET)) {
smallPanIndex = pan >> 1; smallPanIndex = pan >> 1;
if (smallPanIndex > 0x3F) { if (smallPanIndex > 0x3F) {
smallPanIndex = 0x3F; smallPanIndex = 0x3F;
@ -42,7 +42,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
volLeft = gHeadsetPanVolume[pan]; volLeft = gHeadsetPanVolume[pan];
volRight = gHeadsetPanVolume[0x7F - pan]; volRight = gHeadsetPanVolume[0x7F - pan];
} else if (stereoHeadsetEffects && gAudioContext.soundMode == 0) { } else if (stereoHeadsetEffects && (gAudioContext.soundMode == SOUNDMODE_STEREO)) {
strongLeft = strongRight = 0; strongLeft = strongRight = 0;
sub->headsetPanRight = 0; sub->headsetPanRight = 0;
sub->headsetPanLeft = 0; sub->headsetPanLeft = 0;
@ -79,7 +79,7 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
break; break;
} }
} else if (gAudioContext.soundMode == 3) { } else if (gAudioContext.soundMode == SOUNDMODE_MONO) {
sub->bitField0.stereoHeadsetEffects = false; sub->bitField0.stereoHeadsetEffects = false;
sub->bitField0.usesHeadsetPanEffects = false; sub->bitField0.usesHeadsetPanEffects = false;
volLeft = 0.707f; // approx 1/sqrt(2) volLeft = 0.707f; // approx 1/sqrt(2)

View file

@ -122,7 +122,7 @@ f32 D_801305E4[4] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; // 2**({0, 2, 5, 5}/
f32 D_801305F4 = 1.0f; f32 D_801305F4 = 1.0f;
u8 sGanonsTowerLevelsVol[8] = { 127, 80, 75, 73, 70, 68, 65, 60 }; u8 sGanonsTowerLevelsVol[8] = { 127, 80, 75, 73, 70, 68, 65, 60 };
u8 sEnterGanonsTowerTimer = 0; u8 sEnterGanonsTowerTimer = 0;
s8 D_80130604 = 2; s8 sSoundMode = SOUNDMODE_SURROUND;
s8 D_80130608 = 0; s8 D_80130608 = 0;
s8 sAudioCutsceneFlag = 0; s8 sAudioCutsceneFlag = 0;
s8 sSpecReverb = 0; s8 sSpecReverb = 0;
@ -3987,7 +3987,7 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
case BANK_ENV: case BANK_ENV:
case BANK_ENEMY: case BANK_ENEMY:
case BANK_VOICE: case BANK_VOICE:
if (D_80130604 == 2) { if (sSoundMode == SOUNDMODE_SURROUND) {
sp38 = func_800F3990(*entry->posY, entry->sfxParams); sp38 = func_800F3990(*entry->posY, entry->sfxParams);
} }
FALLTHROUGH; FALLTHROUGH;
@ -3997,7 +3997,8 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
reverb = Audio_ComputeSoundReverb(bankId, entryIdx, channelIdx); reverb = Audio_ComputeSoundReverb(bankId, entryIdx, channelIdx);
panSigned = Audio_ComputeSoundPanSigned(*entry->posX, *entry->posZ, entry->token); panSigned = Audio_ComputeSoundPanSigned(*entry->posX, *entry->posZ, entry->token);
freqScale = Audio_ComputeSoundFreqScale(bankId, entryIdx) * *entry->freqScale; freqScale = Audio_ComputeSoundFreqScale(bankId, entryIdx) * *entry->freqScale;
if (D_80130604 == 2) {
if (sSoundMode == SOUNDMODE_SURROUND) {
behindScreenZ = sBehindScreenZ[(entry->sfxParams & SFX_FLAG_10) >> SFX_FLAG_10_SHIFT]; behindScreenZ = sBehindScreenZ[(entry->sfxParams & SFX_FLAG_10) >> SFX_FLAG_10_SHIFT];
if (!(entry->sfxParams & SFX_FLAG_11)) { if (!(entry->sfxParams & SFX_FLAG_11)) {
if (*entry->posZ < behindScreenZ) { if (*entry->posZ < behindScreenZ) {
@ -4023,7 +4024,7 @@ void Audio_SetSoundProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
if ((baseFilter | sAudioExtraFilter) != 0) { if ((baseFilter | sAudioExtraFilter) != 0) {
filter = (baseFilter | sAudioExtraFilter); filter = (baseFilter | sAudioExtraFilter);
} else if (D_80130604 == 2 && !(entry->sfxParams & SFX_FLAG_13)) { } else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_13)) {
filter = func_800F37B8(behindScreenZ, entry, panSigned); filter = func_800F37B8(behindScreenZ, entry, panSigned);
} }
break; break;
@ -5010,29 +5011,32 @@ void Audio_SetCodeReverb(s8 reverb) {
} }
} }
void func_800F6700(s8 arg0) { void func_800F6700(s8 audioSetting) {
s8 sp1F; s8 soundModeIndex;
switch (arg0) { switch (audioSetting) {
case 0: case 0:
sp1F = 0; soundModeIndex = SOUNDMODE_STEREO;
D_80130604 = 0; sSoundMode = SOUNDMODE_STEREO;
break; break;
case 1: case 1:
sp1F = 3; soundModeIndex = SOUNDMODE_MONO;
D_80130604 = 3; sSoundMode = SOUNDMODE_MONO;
break; break;
case 2: case 2:
sp1F = 1; soundModeIndex = SOUNDMODE_HEADSET;
D_80130604 = 1; sSoundMode = SOUNDMODE_HEADSET;
break; break;
case 3: case 3:
sp1F = 0; soundModeIndex = SOUNDMODE_STEREO;
D_80130604 = 2; sSoundMode = SOUNDMODE_SURROUND;
break; break;
} }
Audio_SeqCmdE0(SEQ_PLAYER_BGM_MAIN, sp1F); Audio_SeqCmdE0(SEQ_PLAYER_BGM_MAIN, soundModeIndex);
} }
void Audio_SetBaseFilter(u8 filter) { void Audio_SetBaseFilter(u8 filter) {
@ -5255,7 +5259,7 @@ void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId) {
Audio_QueueSeqCmd(0x80000000 | (SEQ_PLAYER_BGM_MAIN << 24) | (port << 0x10) | (channelIdx << 8) | val); Audio_QueueSeqCmd(0x80000000 | (SEQ_PLAYER_BGM_MAIN << 24) | (port << 0x10) | (channelIdx << 8) | val);
} }
Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_7, NATURE_CHANNEL_UNK, D_80130604); Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_7, NATURE_CHANNEL_UNK, sSoundMode);
} }
} }

View file

@ -16,7 +16,12 @@ u8 sSeqCmdWrPos = 0;
u8 sSeqCmdRdPos = 0; u8 sSeqCmdRdPos = 0;
u8 D_80133408 = 0; u8 D_80133408 = 0;
u8 D_8013340C = 1; u8 D_8013340C = 1;
u8 D_80133410[] = { 0, 1, 2, 3 }; u8 sSoundModeList[] = {
SOUNDMODE_STEREO,
SOUNDMODE_HEADSET,
SOUNDMODE_SURROUND,
SOUNDMODE_MONO,
};
u8 gAudioSpecId = 0; u8 gAudioSpecId = 0;
u8 D_80133418 = 0; u8 D_80133418 = 0;
@ -342,7 +347,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
switch (subOp) { switch (subOp) {
case 0: case 0:
// set sound mode // set sound mode
Audio_QueueCmdS32(0xF0000000, D_80133410[val]); Audio_QueueCmdS32(0xF0000000, sSoundModeList[val]);
break; break;
case 1: case 1:
// set sequence starting disabled? // set sequence starting disabled?