diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2022-10-10 00:52:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-10 06:52:33 +0200 |
| commit | 3ee2190b8d8c71e8245b3d607f804acbad020cd2 (patch) | |
| tree | 6e8d30290029c2beb99f2219b766fd460a7cbad0 /src/code | |
| parent | 76803f15349d29296782663a81804cdfcf892716 (diff) | |
Document Malon's Singing (#1395)
* malon singing docs
* typo
* more cleanup
* more cleanup
* cleanup comments
* PR Suggestions
* add more comments for clarity
* grammar
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/code_800EC960.c | 153 |
1 files changed, 93 insertions, 60 deletions
diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c index 0ccb80084..7c649b6e3 100644 --- a/src/code/code_800EC960.c +++ b/src/code/code_800EC960.c @@ -1237,9 +1237,9 @@ u8 sRiverSoundMainBgmRestore; u8 sGanonsTowerVol; SfxPlayerState sSfxChannelState[0x10]; char sBinToStrBuf[0x20]; -u8 D_8016B9D8; +u8 sMalonSingingTimer; u8 sAudioSpecPeakNumNotes[0x12]; -u8 D_8016B9F2; +u8 sMalonSingingDisabled; u8 D_8016B9F3; u8 D_8016B9F4; u16 D_8016B9F6; @@ -1266,8 +1266,8 @@ u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX]; u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX]; u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX]; OcarinaNote sScarecrowsLongSongSecondNote; -u8 sAudioHasMalonBgm; -f32 sAudioMalonBgmDist; +u8 sIsMalonSinging; +f32 sMalonSingingDist; void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest); @@ -3058,9 +3058,9 @@ void AudioDebug_Draw(GfxPrint* printer) { GfxPrint_Printf(printer, "DEMO FLAG %d", sAudioCutsceneFlag); GfxPrint_SetPos(printer, 3, 12); - if (sAudioHasMalonBgm == true) { - GfxPrint_Printf(printer, "MARON BGM DIST %f", sAudioMalonBgmDist); - sAudioHasMalonBgm = false; + if (sIsMalonSinging == true) { + GfxPrint_Printf(printer, "MARON BGM DIST %f", sMalonSingingDist); + sIsMalonSinging = false; } GfxPrint_SetPos(printer, 3, 23); @@ -4919,56 +4919,69 @@ void Audio_SetBgmEnemyVolume(f32 dist) { sAudioEnemyDist = dist; } -void func_800F6268(f32 dist, u16 arg1) { +void Audio_UpdateMalonSinging(f32 dist, u16 seqId) { s8 pad; - s8 phi_v1; - s16 temp_a0; - - sAudioHasMalonBgm = true; - sAudioMalonBgmDist = dist; - if (D_8016B9F2 == 0) { - temp_a0 = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF); - if (temp_a0 == (arg1 & 0xFF)) { - if ((arg1 & 0xFF) == NA_BGM_LONLON) { - - if (dist > 2000.0f) { - phi_v1 = 127; - } else if (dist < 200.0f) { - phi_v1 = 0; - } else { - phi_v1 = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); - } - // Transition volume of channels 0, 1 and 13 on seq player 0 over 3 frames - SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 0, 3, 127 - phi_v1); - SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 1, 3, 127 - phi_v1); - SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 13, 3, phi_v1); - if (D_8016B9D8 == 0) { - D_8016B9D8++; - } - } - } else if ((temp_a0 == NA_BGM_NATURE_AMBIENCE) && ((arg1 & 0xFF) == NA_BGM_LONLON)) { - temp_a0 = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF); - if ((temp_a0 != (arg1 & 0xFF)) && (D_8016B9D8 < 10)) { - Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, NA_BGM_LONLON, 0, 0, 0); - SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, 0xFFFC); - D_8016B9D8 = 10; - } + s8 melodyVolume; + s16 curSeqId; + + sIsMalonSinging = true; + sMalonSingingDist = dist; + + if (sMalonSingingDisabled) { + return; + } + + curSeqId = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF); + + if (curSeqId == (seqId & 0xFF)) { + if ((seqId & 0xFF) == NA_BGM_LONLON) { + // Malon is singing along with the Lon Lon Sequence if (dist > 2000.0f) { - phi_v1 = 127; + melodyVolume = 127; } else if (dist < 200.0f) { - phi_v1 = 0; + melodyVolume = 0; } else { - phi_v1 = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); + melodyVolume = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); + } + + // Update volume for channels 0 & 1, which contain Malon's singing + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 0, 3, 127 - melodyVolume); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 1, 3, 127 - melodyVolume); + + // Update volume for channel 13, which contains the melody line for Lon Lon's Sequence + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 13, 3, melodyVolume); + if (sMalonSingingTimer == 0) { + sMalonSingingTimer++; } - // Transition volume of channels 0 and 1 on seq player 0 over 3 frames - SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 0, 3, 127 - phi_v1); - SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 1, 3, 127 - phi_v1); } + } else if ((curSeqId == NA_BGM_NATURE_AMBIENCE) && ((seqId & 0xFF) == NA_BGM_LONLON)) { + // Malon is singing along with ambience + curSeqId = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF); - if (D_8016B9D8 < 10) { - D_8016B9D8++; + if ((curSeqId != (seqId & 0xFF)) && (sMalonSingingTimer < 10)) { + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, NA_BGM_LONLON, 0, 0, 0); + // Disable all channels between 2-15. + // Only allow the two channels with Malon's singing to play, and suppress the full lon lon sequence. + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, 0xFFFC); + sMalonSingingTimer = 10; } + + if (dist > 2000.0f) { + melodyVolume = 127; + } else if (dist < 200.0f) { + melodyVolume = 0; + } else { + melodyVolume = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); + } + + // Update volume for channels 0 & 1, which contain Malon's singing + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 0, 3, 127 - melodyVolume); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 1, 3, 127 - melodyVolume); + } + + if (sMalonSingingTimer < 10) { + sMalonSingingTimer++; } } @@ -4985,35 +4998,55 @@ void func_800F64E0(u8 arg0) { } } -void func_800F6584(u8 arg0) { +/** + * Enable or disable Malon's singing + * + * @param malonSingingDisabled true to disable, false to enable + */ +void Audio_ToggleMalonSinging(u8 malonSingingDisabled) { u8 seqPlayerIndex; - u16 sp34; + u16 channelMaskDisable; + + sMalonSingingDisabled = malonSingingDisabled; - D_8016B9F2 = arg0; if ((Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF) == NA_BGM_LONLON) { + // Malon is singing along with the Lon Lon Sequence seqPlayerIndex = SEQ_PLAYER_BGM_MAIN; - sp34 = 0; - } else if ((Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF) == NA_BGM_LONLON) { + // Do not disable any channel. + // Allow the full lon lon sequence to play in addition to Malon's singing. + channelMaskDisable = 0; + } else if ((u8)Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_LONLON) { + // Malon is singing along with ambience seqPlayerIndex = SEQ_PLAYER_BGM_SUB; - sp34 = 0xFFFC; + // Disable all channels between 2-15. + // Only allow the two channels with Malon's singing to play, and suppress the full lon lon sequence. + channelMaskDisable = 0xFFFC; } else { return; } - if (arg0 != 0) { + if (malonSingingDisabled) { + // Turn volume off for channels 0 & 1, which contain Malon's singing SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0); SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0); + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { - SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, sp34 | 3); + // When singing along with ambience, disable all 16 channels + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMaskDisable | 3); } } else { if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + // When singing along with ambience, start the sequence Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, NA_BGM_LONLON, 0, 0, 0); } + + // Turn volume on for only channels 0 & 1, which contain Malon's singing SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0x7F); SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0x7F); + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { - SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, sp34); + // When singing along with ambience, disable channels 2-15 + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMaskDisable); } } } @@ -5184,7 +5217,7 @@ void func_800F6C34(void) { sRiverSoundMainBgmLower = false; sRiverSoundMainBgmRestore = false; sGanonsTowerVol = 0xFF; - D_8016B9D8 = 0; + sMalonSingingTimer = 0; sSpecReverb = sSpecReverbs[gAudioSpecId]; D_80130608 = 0; sPrevMainBgmSeqId = NA_BGM_DISABLED; @@ -5192,7 +5225,7 @@ void func_800F6C34(void) { sSariaBgmPtr = NULL; D_8016B9F4 = 0; D_8016B9F3 = 1; - D_8016B9F2 = 0; + sMalonSingingDisabled = false; } void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 ioPort, u8 ioData) { @@ -5209,7 +5242,7 @@ void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 ioPort, u8 ioData) // channelIdxRange = 01 on ioPort 1 if (((channelIdxRange << 8) + ioPort) == ((NATURE_CHANNEL_CRITTER_0 << 8) + CHANNEL_IO_PORT_1)) { if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON) { - D_8016B9D8 = 0; + sMalonSingingTimer = 0; } } |
