Audio sequence.c OK and documented (#1201)

* import sequence docs

* cleanup

* do not need raw hex
This commit is contained in:
engineer124
2023-03-30 19:53:47 +11:00
committed by GitHub
parent 045c3537a9
commit 6685a4775e
52 changed files with 1888 additions and 404 deletions
+196 -108
View File
@@ -70,7 +70,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume);
void Audio_StartMorningSceneSequence(u16 seqId);
void Audio_StartSceneSequence(u16 seqId);
void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData);
void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData);
void func_801A4428(u8 reverbIndex);
void func_801A3038(void);
void Audio_PlayAmbience(u8 ambienceId);
@@ -2734,8 +2734,7 @@ void AudioOcarina_SetOcarinaDisableTimer(u8 unused, u8 timer) {
void AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) {
if ((sOcarinaInstrumentId != ocarinaInstrumentId) || (ocarinaInstrumentId == OCARINA_INSTRUMENT_DEFAULT)) {
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) |
((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(ocarinaInstrumentId));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 1, ocarinaInstrumentId);
sOcarinaInstrumentId = ocarinaInstrumentId;
if (ocarinaInstrumentId == OCARINA_INSTRUMENT_OFF) {
@@ -3303,7 +3302,10 @@ s32 AudioOcarina_MemoryGameNextNote(void) {
sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos].length = 0;
sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE;
sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcarinaMemoryGameAppendPos + 1].length = 0;
//! FAKE:
if (1) {}
return false;
}
#undef OCARINA_SONG_MEMORY_GAME
@@ -3407,8 +3409,7 @@ void AudioOcarina_SetCustomSequence(void) {
// Called by unused function
void AudioOcarina_PlayCustomSequence(void) {
sRequestCustomSequence = true;
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) |
(u32)(NA_BGM_DUNGEON_APPEAR));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, NA_BGM_DUNGEON_APPEAR);
}
// Unused
@@ -3586,8 +3587,7 @@ s32 AudioOcarina_CreateCustomSequence(void) {
void AudioOcarina_ResetInstrument(void) {
if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) {
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_SFX) << 24) | ((u32)(1) << 16) |
((u32)(SFX_CHANNEL_OCARINA) << 8) | (u32)(0));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 1, 0);
sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF;
AudioOcarina_ResetAndMute();
}
@@ -3629,7 +3629,7 @@ void Audio_Noop3(void) {
}
void Audio_Update(void) {
if ((func_801A9768() == 0) && (func_801A982C() == 0)) {
if ((AudioSeq_UpdateAudioHeapReset() == 0) && !AudioSeq_ResetReverb()) {
AudioOcarina_SetCustomSequence();
AudioOcarina_Update();
func_801A5118();
@@ -3646,9 +3646,9 @@ void Audio_Update(void) {
func_801A1290();
Audio_ResetRequestedSceneSeqId();
AudioSfx_ProcessRequests();
func_801A89D0();
AudioSeq_ProcessSeqCmds();
AudioSfx_ProcessActiveSfx();
func_801A8D5C();
AudioSeq_UpdateActiveSequences();
AudioSfx_ProcessSfxSettings();
AudioThread_ScheduleProcessCmds();
}
@@ -3660,7 +3660,14 @@ void Audio_Noop4(s32 arg0) {
void Audio_Noop5(s32 arg0, s32 arg1) {
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E110.s")
/**
* Queues a bgm sequence directly to the internal audio queue system.
* Skips the external audio command process
* Unused
*/
void Audio_PlayMainBgm(s8 seqId) {
AUDIOCMD_GLOBAL_INIT_SEQPLAYER(SEQ_PLAYER_BGM_MAIN, (u8)seqId, 1);
}
f32 AudioSfx_ComputeVolume(u8 bankId, u8 entryIndex) {
SfxBankEntry* bankEntry = &gSfxBanks[bankId][entryIndex];
@@ -4290,13 +4297,23 @@ f32 sBigBellsVolume[8] = {
};
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0184.s")
void Audio_SetBgmVolumeOff(void) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 10);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A01C4.s")
void Audio_SetBgmVolumeOn(void) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 3);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0x7F, 3);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0204.s")
void func_801A0204(s8 seqId) {
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_BGM_MAIN, 2, (u8)seqId);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s")
void Audio_SetMainBgmVolume(u8 targetVolume, u8 volumeFadeTimer) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVolume, volumeFadeTimer);
}
/**
* Unused remnant from OoT's EnRiverSound
@@ -4338,7 +4355,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
if (sGanonsTowerVol != targetVolume) {
// Sets the volume
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVolume, 2);
// Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is
// always set to 0
@@ -4350,8 +4367,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4;
}
Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) |
(u8)(lowPassFilterCutoff));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, 15, 4, lowPassFilterCutoff);
// Sets the reverb
for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels);
@@ -4399,14 +4415,14 @@ void Audio_UpdateRiverSoundVolumes(void) {
if (sRiverSoundMainBgmLower == true) {
if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) {
// lowers the volume for 1 frame
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, sRiverSoundMainBgmVol, 10);
sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol;
sRiverSoundMainBgmRestore = true;
}
sRiverSoundMainBgmLower = false;
} else if ((sRiverSoundMainBgmRestore == true) && !sAudioIsWindowOpen) {
// restores the volume every frame
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 10);
sRiverSoundMainBgmCurrentVol = 0x7F;
sRiverSoundMainBgmRestore = false;
}
@@ -4488,10 +4504,9 @@ void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) {
volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f;
}
for (channelIndex = 0; channelIndex < 16; channelIndex++) {
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
if (channelIndex != 9) {
Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) |
((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel)));
SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, 2, (u8)(127.0f * volumeRel));
AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, channelIndex, pan);
}
}
@@ -4527,8 +4542,8 @@ void Audio_SplitBgmChannels(s8 volumeSplit) {
u8 i;
u8 channelIndex;
if ((Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) &&
(Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) {
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) {
for (i = 0; i < ARRAY_COUNT(sBgmPlayers); i++) {
if (i == 0) {
// Main Bgm SeqPlayer
@@ -4556,7 +4571,7 @@ void Audio_SplitBgmChannels(s8 volumeSplit) {
}
}
Audio_QueueSeqCmd(0xA0000000 | ((u32)(sBgmPlayers[i]) << 24) | ((u32)(channelBits)));
SEQCMD_SET_CHANNEL_DISABLE_MASK(sBgmPlayers[i], channelBits);
}
}
}
@@ -4635,8 +4650,8 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) {
Audio_SplitBgmChannels(targetVolume);
}
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, targetVolume, 0);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F - targetVolume, 0);
}
/**
@@ -4650,12 +4665,12 @@ void Audio_ClearSariaBgm2(void) {
void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) {
Audio_StartMorningSceneSequence(seqId);
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | (u32)(dayMinusOne));
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, dayMinusOne);
}
void Audio_StartMorningSceneSequence(u16 seqId) {
if (seqId != NA_BGM_AMBIENCE) {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_AMBIENCE) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0);
Audio_StartSceneSequence(seqId);
Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 0, 1);
} else {
@@ -4669,8 +4684,7 @@ void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne) {
Audio_PlayAmbience(AMBIENCE_ID_08);
} else if ((seqId != NA_BGM_FINAL_HOURS) || (sPrevMainBgmSeqId == NA_BGM_DISABLED)) {
Audio_StartSceneSequence(seqId);
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) |
(u32)(dayMinusOne));
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, dayMinusOne);
}
sRequestedSceneSeqId = seqId;
}
@@ -4710,7 +4724,7 @@ void Audio_StartSceneSequence(u16 seqId) {
}
void Audio_UpdateSceneSequenceResumePoint(void) {
u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN);
u16 seqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) {
if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) {
@@ -4723,55 +4737,95 @@ void Audio_UpdateSceneSequenceResumePoint(void) {
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A27E8.s")
// Unused
void Audio_PlayBgmForSongOfStorms(void) {
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_SONG_OF_STORMS) {
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_SONG_OF_STORMS | SEQ_FLAG_ASYNC);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A281C.s")
/**
* Specifically for SEQ_PLAYER_BGM_MAIN
*/
void Audio_ScaleTempoAndFreqForMainBgm(f32 freqTempoScale, u8 duration) {
if (freqTempoScale == 1.0f) {
SEQCMD_RESET_TEMPO(SEQ_PLAYER_BGM_MAIN, duration);
} else {
SEQCMD_SCALE_TEMPO(SEQ_PLAYER_BGM_MAIN, duration, freqTempoScale * 100.0f);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A29D4.s")
SEQCMD_SET_SEQPLAYER_FREQ(SEQ_PLAYER_BGM_MAIN, duration, freqTempoScale * 1000.0f);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2BB8.s")
void Audio_SetSeqTempoAndFreq(u8 seqPlayerIndex, f32 freqTempoScale, u8 duration) {
if (freqTempoScale == 1.0f) {
SEQCMD_RESET_TEMPO(seqPlayerIndex, duration);
} else {
SEQCMD_SCALE_TEMPO(seqPlayerIndex, duration, freqTempoScale * 100.0f);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C20.s")
SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqTempoScale * 1000.0f);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C44.s")
void Audio_PlaySubBgm(u16 seqId) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0, seqId);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0, 5);
SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_BGM_SUB, SEQ_PLAYER_BGM_MAIN, 3, 10);
SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, SEQ_PLAYER_BGM_MAIN, 0);
}
void Audio_StopSubBgm(void) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0);
}
// Unused remnant of OoT
void Audio_IncreaseTempoForTimedMinigame(void) {
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_TIMED_MINI_GAME) &&
AudioSeq_IsSeqCmdNotQueued(SEQCMD_OP_PLAY_SEQUENCE << 28, SEQCMD_OP_MASK)) {
// Set tempo to be higher than the default tempo for th timed mini-game sequence
SEQCMD_SET_TEMPO(SEQ_PLAYER_BGM_MAIN, 5, 210);
}
}
void Audio_PlaySequenceInCutscene(u16 seqId) {
if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) {
Audio_PlayFanfare(seqId);
} else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) {
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | (u32)(seqId));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, seqId);
} else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) {
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(0) << 0x10) | (u32)(seqId));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0, seqId);
} else {
Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, SEQ_IO_VAL_NONE);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0);
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16));
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 0);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
}
}
void Audio_StopSequenceInCutscene(u16 seqId) {
if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
} else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
} else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0);
} else {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0);
}
}
s32 Audio_IsSequencePlaying(u8 seqId) {
u8 playerIndex = SEQ_PLAYER_BGM_MAIN;
u8 seqPlayerIndex = SEQ_PLAYER_BGM_MAIN;
if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE) {
playerIndex = SEQ_PLAYER_FANFARE;
seqPlayerIndex = SEQ_PLAYER_FANFARE;
} else if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) {
playerIndex = SEQ_PLAYER_FANFARE;
seqPlayerIndex = SEQ_PLAYER_FANFARE;
}
if (seqId == (Audio_GetActiveSequence(playerIndex) & 0xFF)) {
if (seqId == (AudioSeq_GetActiveSeqId(seqPlayerIndex) & 0xFF)) {
return true;
} else {
return false;
@@ -4779,7 +4833,7 @@ s32 Audio_IsSequencePlaying(u8 seqId) {
}
void Audio_PlayBgm_StorePrevBgm(u16 seqId) {
u16 curSeqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN);
u16 curSeqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
if (curSeqId == NA_BGM_DISABLED) {
curSeqId = NA_BGM_GENERAL_SFX;
@@ -4793,7 +4847,7 @@ void Audio_PlayBgm_StorePrevBgm(u16 seqId) {
sPrevMainBgmSeqId = curSeqId;
}
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | (u32)(seqId + 0x8000));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, seqId + SEQ_FLAG_ASYNC);
}
}
@@ -4801,16 +4855,15 @@ void Audio_PlayBgm_StorePrevBgm(u16 seqId) {
* To be used in conjunction with Audio_PlayBgm_StorePrevBgm
*/
void Audio_RestorePrevBgm(void) {
if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) &&
(sSeqFlags[Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) {
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) &&
(sSeqFlags[AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) {
if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) || (sPrevMainBgmSeqId == NA_BGM_GENERAL_SFX)) {
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0);
} else {
if (sPrevMainBgmSeqId == NA_BGM_AMBIENCE) {
sPrevMainBgmSeqId = sPrevAmbienceSeqId;
}
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) |
(u32)(sPrevMainBgmSeqId + 0x8000));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId + SEQ_FLAG_ASYNC);
}
sPrevMainBgmSeqId = NA_BGM_DISABLED;
}
@@ -4818,7 +4871,7 @@ void Audio_RestorePrevBgm(void) {
// Unused
void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) {
u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN);
u16 seqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
if (seqId != NA_BGM_AMBIENCE) {
sPrevMainBgmSeqId = seqId;
@@ -4830,8 +4883,7 @@ void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) {
// Unused
void Audio_ForceRestorePreviousBgm(void) {
if (sPrevMainBgmSeqId != NA_BGM_DISABLED) {
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) |
(u32)(sPrevMainBgmSeqId + 0x8000));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId + SEQ_FLAG_ASYNC);
}
sPrevMainBgmSeqId = NA_BGM_DISABLED;
@@ -4847,16 +4899,16 @@ void Audio_ForceRestorePreviousBgm(void) {
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s")
void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) {
void Audio_PlaySequenceWithSeqPlayerIO(s8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) {
u16 flaggedSeqId;
Audio_QueueSeqCmd(0x70000000 | ((u32)(playerIndex) << 24) | ((u32)(ioPort) << 0x10) | (u32)(ioData));
SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData);
if ((seqId & 0xFF) < 2) {
flaggedSeqId = seqId;
} else {
flaggedSeqId = seqId | 0x8000;
}
Audio_QueueSeqCmd(0x00000000 | ((u32)(playerIndex) << 24) | ((u32)(fadeInDuration) << 0x10) | (u32)(flaggedSeqId));
SEQCMD_PLAY_SEQUENCE((u32)seqPlayerIndex, fadeInDuration, flaggedSeqId);
}
void Audio_SetSequenceMode(u8 seqMode) {
@@ -4884,17 +4936,18 @@ void Audio_SetSequenceMode(u8 seqMode) {
volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume;
}
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, volumeFadeInTimer);
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) |
(u32)(NA_BGM_ENEMY | 0x800));
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sBgmEnemyVolume,
volumeFadeInTimer);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800);
if (seqId >= NA_BGM_TERMINA_FIELD) {
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - sBgmEnemyVolume, 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F - sBgmEnemyVolume,
10);
Audio_SplitBgmChannels(sBgmEnemyVolume);
}
} else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) {
// If only sPrevSeqMode = SEQ_MODE_ENEMY (End)
Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((10) << 16));
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10);
if (seqMode == SEQ_MODE_IGNORE) {
volumeFadeOutTimer = 0;
@@ -4902,7 +4955,7 @@ void Audio_SetSequenceMode(u8 seqMode) {
volumeFadeOutTimer = 10;
}
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, volumeFadeOutTimer);
Audio_SplitBgmChannels(0);
}
@@ -4910,10 +4963,9 @@ void Audio_SetSequenceMode(u8 seqMode) {
} else {
if (seqMode == SEQ_MODE_ENEMY) {
// If both seqMode = sPrevSeqMode = SEQ_MODE_ENEMY
if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) &&
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) &&
(seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_ENEMY)) {
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) |
(u32)(NA_BGM_ENEMY | 0x800));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800);
sPrevSeqMode = seqMode + 0x80;
}
}
@@ -4935,7 +4987,7 @@ void Audio_SetSequenceMode(u8 seqMode) {
}
sPrevSeqMode = seqMode;
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 0x10) | (u32)(seqMode));
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 2, seqMode);
}
}
}
@@ -4956,10 +5008,10 @@ void Audio_UpdateEnemyBgmVolume(f32 dist) {
}
sBgmEnemyVolume = ((350.0f - adjDist) * 127.0f) / 350.0f;
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sBgmEnemyVolume, 10);
if ((seqId >= NA_BGM_TERMINA_FIELD) && !(sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO)) {
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sBgmEnemyVolume), 10);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, (0x7F - sBgmEnemyVolume), 10);
}
}
@@ -5032,7 +5084,8 @@ void Audio_ResetRequestedSceneSeqId(void) {
sRequestedSceneSeqId = NA_BGM_DISABLED;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44D4.s")
void Audio_ResetData(void);
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_ResetData.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A46F8.s")
@@ -5046,13 +5099,15 @@ void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) {
u8 lastChannelIndex;
u8 channelIndex;
if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && func_801A8ABC(NA_BGM_AMBIENCE, 0xF00000FF)) {
if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) &&
AudioSeq_IsSeqCmdNotQueued((SEQCMD_OP_PLAY_SEQUENCE << 28) | NA_BGM_AMBIENCE,
SEQCMD_OP_MASK | SEQCMD_SEQID_MASK)) {
return;
}
// channelIndexRange = 01 on ioPort 1
if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) &&
(Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) {
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) {
D_801FD3A8 = 0;
}
@@ -5064,38 +5119,33 @@ void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) {
}
for (channelIndex = firstChannelIndex; channelIndex <= lastChannelIndex; channelIndex++) {
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) |
((u32)(channelIndex) << 8) | (u32)(ioData));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, ioPort, ioData);
}
}
void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) {
u8 channelIndex;
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_0) << 0x10) |
(u32)(1));
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_4) << 0x10) |
(u32)((u8)(initChannelMask >> 8)));
Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_5) << 0x10) |
(u32)((u8)(initChannelMask & 0xFF)));
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1);
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_0, 1);
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_4, (u8)(initChannelMask >> 8));
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_AMBIENCE, SEQ_PLAYER_IO_PORT_5, (u8)(initChannelMask & 0xFF));
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 1);
if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) &&
(Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) {
Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0);
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) {
AudioSeq_StopSequence(SEQ_PLAYER_AMBIENCE, 0);
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
}
if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 1);
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 1);
}
Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(0) << 0x10) | (u32)(NA_BGM_AMBIENCE));
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0, NA_BGM_AMBIENCE);
for (channelIndex = 0; channelIndex < 16; channelIndex++) {
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
if (!(initMuteChannelMask & (1 << channelIndex)) && (initChannelMask & (1 << channelIndex))) {
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_1) << 16) |
((u32)(channelIndex) << 8) | (u32)(1));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, CHANNEL_IO_PORT_1, 1);
}
}
}
@@ -5119,12 +5169,10 @@ void Audio_PlayAmbience(u8 ambienceId) {
channelIndex = sAmbienceData[ambienceId].channelProperties[i++];
ioPort = sAmbienceData[ambienceId].channelProperties[i++];
ioData = sAmbienceData[ambienceId].channelProperties[i++];
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) |
((u32)(channelIndex) << 8) | (u32)(ioData));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, channelIndex, ioPort, ioData);
}
Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_7) << 16) |
((u32)(AMBIENCE_CHANNEL_SOUND_MODE) << 8) | (u32)(sSoundMode));
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_AMBIENCE, AMBIENCE_CHANNEL_SOUND_MODE, CHANNEL_IO_PORT_7, sSoundMode);
}
}
@@ -5155,7 +5203,7 @@ void AudioSfx_Init(u16 fadeTimer) {
u8 channelIndex;
AudioThread_ScheduleProcessCmds();
Audio_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer);
AudioSeq_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer);
for (channelIndex = 0; channelIndex < ARRAY_COUNT(sSfxChannelState); channelIndex++) {
AUDIOCMD_CHANNEL_SET_SFX_STATE(SEQ_PLAYER_SFX, channelIndex, &sSfxChannelState[channelIndex]);
@@ -5165,12 +5213,52 @@ void AudioSfx_Init(u16 fadeTimer) {
AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_1, Audio_SetAmbienceRandomBend);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s")
void Audio_InitSound(void) {
Audio_ResetData();
AudioOcarina_ResetStaffs();
AudioSfx_ResetSfxChannelState();
AudioSeq_ResetActiveSequencesAndVolume();
AudioSfx_Reset();
AudioVoice_ResetData();
AudioSfx_Init(10);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D50.s")
void Audio_ResetForAudioHeapStep3(void) {
AudioSfx_Init(1);
AUDIOCMD_GLOBAL_UNMUTE(AUDIOCMD_ALL_SEQPLAYERS, true);
AudioThread_ScheduleProcessCmds();
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
sIsFinalHoursOrSoaring = false;
sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX;
sMuteOnlySfxAndAmbienceSeq = false;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DA4.s")
void Audio_ResetForAudioHeapStep2(void) {
Audio_ResetForAudioHeapStep3();
if (gAudioSpecId < ARRAY_COUNT(gReverbSettingsTable)) {
AUDIOCMD_GLOBAL_SET_REVERB_DATA(1, REVERB_DATA_TYPE_SETTINGS, &gReverbSettingsTable[gAudioSpecId][1]);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s")
void Audio_ResetForAudioHeapStep1(s32 specId) {
gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_RESETTING;
Audio_ResetData();
AudioOcarina_ResetStaffs();
AudioSfx_ResetSfxChannelState();
AudioSeq_ResetActiveSequences();
AudioSfx_Reset();
func_801A4FD8();
if (gAudioSpecId == 0xB) {
AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) |
(1 << BANK_OCARINA) | (1 << BANK_VOICE));
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s")
void Audio_UnusedReset(void) {
AudioSeq_ResetActiveSequences();
AUDIOCMD_GLOBAL_UNMUTE(AUDIOCMD_ALL_SEQPLAYERS, true);
Audio_ResetData();
AudioSfx_ResetSfxChannelState();
AudioSfx_Init(1);
func_801A4FD8();
}
+906 -15
View File
@@ -1,31 +1,922 @@
/**
* @file sequence.c
*
* This file implements a set of high-level audio sequence commands that allow sequences to be modified in real-time.
* These commands are intended to interface external to the audio library.
*
* These commands are generated using `AudioSeq_QueueSeqCmd`, and a user-friendly interface for this function
* can be found in `seqcmd.h`
*
* These commands change sequences by generating internal audio commands `AudioThread_QueueCmd` which allows these
* sequence requests to be passed onto the audio thread. It is worth noting all functions in this file are
* called from the graph thread.
*
* These commands are not to be confused with the sequence instructions used by the sequences themselves
* which are a midi-based scripting language.
*
* Nor are these commands to be confused with the internal audio commands used to transfer requests from
* the graph thread to the audio thread.
*/
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/Audio_StartSequence.s")
// Direct audio command (skips the queueing system)
#define SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \
AudioSeq_ProcessSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | \
((u8)(duration) << 16) | ((u8)((volume)*127.0f)));
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/Audio_StopSequence.s")
u8 sSeqCmdWritePos = 0;
u8 sSeqCmdReadPos = 0;
u8 sStartSeqDisabled = 0;
u8 sSoundModeList[] = {
SOUNDMODE_STEREO, SOUNDMODE_HEADSET, SOUNDMODE_SURROUND_EXTERNAL, SOUNDMODE_MONO, SOUNDMODE_SURROUND,
};
u8 gAudioSpecId = 0;
u8 gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE;
u32 sResetAudioHeapSeqCmd = 0;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A7D84.s")
void AudioSeq_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration) {
u8 channelIndex;
u16 skipTicks;
s32 pad;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/Audio_QueueSeqCmd.s")
if (!sStartSeqDisabled || (seqPlayerIndex == SEQ_PLAYER_SFX)) {
seqArgs &= 0x7F;
if (seqArgs == 0x7F) {
// `fadeInDuration` interpreted as seconds, 60 is refresh rate and does not account for PAL
skipTicks = (fadeInDuration >> 3) * 60 * gAudioCtx.audioBufferParameters.updatesPerFrame;
AUDIOCMD_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS(seqPlayerIndex, seqId, skipTicks);
} else {
// `fadeInDuration` interpreted as 1/30th of a second, does not account for change in refresh rate for PAL
AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId,
(fadeInDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A89D0.s")
gActiveSeqs[seqPlayerIndex].seqId = seqId | (seqArgs << 8);
gActiveSeqs[seqPlayerIndex].prevSeqId = seqId | (seqArgs << 8);
gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = true;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/Audio_GetActiveSequence.s")
if (gActiveSeqs[seqPlayerIndex].volCur != 1.0f) {
AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A8ABC.s")
gActiveSeqs[seqPlayerIndex].tempoTimer = 0;
gActiveSeqs[seqPlayerIndex].tempoOriginal = 0;
gActiveSeqs[seqPlayerIndex].tempoCmd = 0;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A8B14.s")
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur = 1.0f;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer = 0;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur = 1.0f;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A8B2C.s")
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0;
gActiveSeqs[seqPlayerIndex].volChannelFlags = 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/Audio_SetVolumeScale.s")
void AudioSeq_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration) {
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(seqPlayerIndex,
(fadeOutDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4);
gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A8D5C.s")
void AudioSeq_ProcessSeqCmd(u32 cmd) {
s32 priority;
s32 channelMaskEnable;
u16 channelMaskDisable;
u16 fadeTimer;
u16 val;
u8 oldSpecId;
u8 specId;
u8 fadeReverb;
u8 op;
u8 subOp;
u8 seqPlayerIndex;
u8 seqId;
u8 seqArgs;
u8 found;
u8 ioPort;
u8 duration;
u8 channelIndex;
u8 i;
f32 freqScaleTarget;
u32 outNumFonts;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A9768.s")
op = cmd >> 28;
seqPlayerIndex = (cmd & SEQCMD_SEQPLAYER_MASK) >> 24;
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A982C.s")
switch (op) {
case SEQCMD_OP_PLAY_SEQUENCE:
// Play a new sequence
seqId = cmd & SEQCMD_SEQID_MASK;
seqArgs = (cmd & 0xFF00) >> 8;
// `fadeTimer` is only shifted 13 bits instead of 16 bits.
// `fadeTimer` continues to be scaled in `AudioSeq_StartSequence`
fadeTimer = (cmd & 0xFF0000) >> 13;
if (!gActiveSeqs[seqPlayerIndex].isWaitingForFonts && !sStartSeqDisabled) {
if (seqArgs < 0x80) {
AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer);
} else {
// Store the cmd to be called again once the fonts are loaded
// but changes the command so that next time, the (seqArgs < 0x80) case is taken
gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd =
(cmd & ~(SEQ_FLAG_ASYNC | SEQCMD_ASYNC_ACTIVE)) + SEQCMD_ASYNC_ACTIVE;
gActiveSeqs[seqPlayerIndex].isWaitingForFonts = true;
gActiveSeqs[seqPlayerIndex].fontId = *AudioThread_GetFontsForSequence(seqId, &outNumFonts);
AudioSeq_StopSequence(seqPlayerIndex, 1);
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A99B8.s")
if (gActiveSeqs[seqPlayerIndex].prevSeqId != NA_BGM_DISABLED) {
if (*AudioThread_GetFontsForSequence(seqId, &outNumFonts) !=
*AudioThread_GetFontsForSequence(gActiveSeqs[seqPlayerIndex].prevSeqId & 0xFF,
&outNumFonts)) {
// Discard Seq Fonts
AUDIOCMD_GLOBAL_DISCARD_SEQ_FONTS((s32)seqId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sequence/func_801A9A74.s")
AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(*AudioThread_GetFontsForSequence(seqId, &outNumFonts),
(u8)((seqPlayerIndex + 1) & 0xFF));
}
}
break;
case SEQCMD_OP_STOP_SEQUENCE:
// Stop a sequence and disable the sequence player
fadeTimer = (cmd & 0xFF0000) >> 13;
AudioSeq_StopSequence(seqPlayerIndex, fadeTimer);
break;
case SEQCMD_OP_QUEUE_SEQUENCE:
// Queue a sequence into `sSeqRequests`
seqId = cmd & SEQCMD_SEQID_MASK;
seqArgs = (cmd & 0xFF00) >> 8;
fadeTimer = (cmd & 0xFF0000) >> 13;
priority = seqArgs;
// Checks if the requested sequence is first in the list of requests
// If it is already queued and first in the list, then play the sequence immediately
for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) {
if (sSeqRequests[seqPlayerIndex][i].seqId == seqId) {
if (i == 0) {
AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer);
}
return;
}
}
// Searches the sequence requests for the first request that does not have a higher priority
// than the current incoming request
found = sNumSeqRequests[seqPlayerIndex];
for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) {
if (priority >= sSeqRequests[seqPlayerIndex][i].priority) {
found = i;
i = sNumSeqRequests[seqPlayerIndex]; // "break;"
}
}
// Check if the queue is full
if (sNumSeqRequests[seqPlayerIndex] < ARRAY_COUNT(sSeqRequests[seqPlayerIndex])) {
sNumSeqRequests[seqPlayerIndex]++;
}
for (i = sNumSeqRequests[seqPlayerIndex] - 1; i != found; i--) {
// Move all requests of lower priority backwards 1 place in the queue
// If the queue is full, overwrite the entry with the lowest priority
sSeqRequests[seqPlayerIndex][i].priority = sSeqRequests[seqPlayerIndex][i - 1].priority;
sSeqRequests[seqPlayerIndex][i].seqId = sSeqRequests[seqPlayerIndex][i - 1].seqId;
}
// Fill the newly freed space in the queue with the new request
sSeqRequests[seqPlayerIndex][found].priority = seqArgs;
sSeqRequests[seqPlayerIndex][found].seqId = seqId;
// The sequence is first in queue, so start playing.
if (found == 0) {
AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer);
}
break;
case SEQCMD_OP_UNQUEUE_SEQUENCE:
// Unqueue sequence
fadeTimer = (cmd & 0xFF0000) >> 13;
found = sNumSeqRequests[seqPlayerIndex];
for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) {
seqId = cmd & SEQCMD_SEQID_MASK;
if (sSeqRequests[seqPlayerIndex][i].seqId == seqId) {
found = i;
i = sNumSeqRequests[seqPlayerIndex]; // "break;"
}
}
if (found != sNumSeqRequests[seqPlayerIndex]) {
// Move all requests of lower priority forward 1 place in the queue
for (i = found; i < sNumSeqRequests[seqPlayerIndex] - 1; i++) {
sSeqRequests[seqPlayerIndex][i].priority = sSeqRequests[seqPlayerIndex][i + 1].priority;
sSeqRequests[seqPlayerIndex][i].seqId = sSeqRequests[seqPlayerIndex][i + 1].seqId;
}
sNumSeqRequests[seqPlayerIndex]--;
}
// If the sequence was first in queue (it is currently playing),
// Then stop the sequence and play the next sequence in the queue.
if (found == 0) {
AudioSeq_StopSequence(seqPlayerIndex, fadeTimer);
if (sNumSeqRequests[seqPlayerIndex] != 0) {
AudioSeq_StartSequence(seqPlayerIndex, sSeqRequests[seqPlayerIndex][0].seqId,
sSeqRequests[seqPlayerIndex][0].priority, fadeTimer);
}
}
break;
case SEQCMD_OP_SET_SEQPLAYER_VOLUME:
// Transition volume to a target volume for an entire player
duration = (cmd & 0xFF0000) >> 15;
val = cmd & 0xFF;
if (duration == 0) {
duration++;
}
// Volume is scaled relative to 127
gActiveSeqs[seqPlayerIndex].volTarget = (f32)val / 127.0f;
if (gActiveSeqs[seqPlayerIndex].volCur != gActiveSeqs[seqPlayerIndex].volTarget) {
gActiveSeqs[seqPlayerIndex].volStep =
(gActiveSeqs[seqPlayerIndex].volCur - gActiveSeqs[seqPlayerIndex].volTarget) / (f32)duration;
gActiveSeqs[seqPlayerIndex].volTimer = duration;
}
break;
case SEQCMD_OP_SET_SEQPLAYER_FREQ:
// Transition freq scale to a target freq for all channels
duration = (cmd & 0xFF0000) >> 15;
val = cmd & 0xFFFF;
if (duration == 0) {
duration++;
}
// Frequency is scaled relative to 1000
freqScaleTarget = (f32)val / 1000.0f;
for (i = 0; i < SEQ_NUM_CHANNELS; i++) {
gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleTarget = freqScaleTarget;
gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleTimer = duration;
gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleStep =
(gActiveSeqs[seqPlayerIndex].channelData[i].freqScaleCur - freqScaleTarget) / (f32)duration;
}
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0xFFFF;
break;
case SEQCMD_OP_SET_CHANNEL_FREQ:
// Transition freq scale to a target for a specific channel
duration = (cmd & 0xFF0000) >> 15;
channelIndex = (cmd & 0xF000) >> 12;
val = cmd & 0xFFF;
if (duration == 0) {
duration++;
}
// Frequency is scaled relative to 1000
freqScaleTarget = (f32)val / 1000.0f;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget = freqScaleTarget;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleStep =
(gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur - freqScaleTarget) / (f32)duration;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer = duration;
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags |= 1 << channelIndex;
break;
case SEQCMD_OP_SET_CHANNEL_VOLUME:
// Transition volume to a target volume for a specific channel
duration = (cmd & 0xFF0000) >> 15;
channelIndex = (cmd & 0xF00) >> 8;
val = cmd & 0xFF;
if (duration == 0) {
duration++;
}
// Volume is scaled relative to 127
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget = (f32)val / 127.0f;
if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur !=
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volStep =
(gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur -
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget) /
(f32)duration;
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer = duration;
gActiveSeqs[seqPlayerIndex].volChannelFlags |= 1 << channelIndex;
}
break;
case SEQCMD_OP_SET_SEQPLAYER_IO:
// Set global io port
ioPort = (cmd & 0xFF0000) >> 16;
val = cmd & 0xFF;
AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, ioPort, val);
break;
case SEQCMD_OP_SET_CHANNEL_IO:
// Set io port if channel masked
channelIndex = (cmd & 0xF00) >> 8;
ioPort = (cmd & 0xFF0000) >> 16;
val = cmd & 0xFF;
if (!(gActiveSeqs[seqPlayerIndex].channelPortMask & (1 << channelIndex))) {
AUDIOCMD_CHANNEL_SET_IO(seqPlayerIndex, channelIndex, ioPort, val);
}
break;
case SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK:
// Disable channel io specifically for `SEQCMD_OP_SET_CHANNEL_IO`.
// This can be bypassed by setting channel io through using `AUDIOCMD_CHANNEL_SET_IO` directly.
// This is accomplished by setting a channel mask.
gActiveSeqs[seqPlayerIndex].channelPortMask = cmd & 0xFFFF;
break;
case SEQCMD_OP_SET_CHANNEL_DISABLE_MASK:
// Disable or Reenable channels
// Disable channels
channelMaskDisable = cmd & 0xFFFF;
if (channelMaskDisable != 0) {
// Apply channel mask `channelMaskDisable`
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskDisable);
// Disable channels
AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, true);
}
// Reenable channels
channelMaskEnable = channelMaskDisable ^ 0xFFFF;
if (channelMaskEnable != 0) {
// Apply channel mask `channelMaskEnable`
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskEnable);
// Enable channels
AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, false);
}
break;
case SEQCMD_OP_TEMPO_CMD:
// Update a tempo using a sub-command system.
// Stores the cmd for processing elsewhere.
gActiveSeqs[seqPlayerIndex].tempoCmd = cmd;
break;
case SEQCMD_OP_SETUP_CMD:
// Queue a sub-command to execute once the sequence is finished playing
subOp = (cmd & 0xF00000) >> 20;
if (subOp != SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS) {
// Ensure the maximum number of setup commands is not exceeded
if (gActiveSeqs[seqPlayerIndex].setupCmdNum < (ARRAY_COUNT(gActiveSeqs[seqPlayerIndex].setupCmd) - 1)) {
found = gActiveSeqs[seqPlayerIndex].setupCmdNum++;
if (found < ARRAY_COUNT(gActiveSeqs[seqPlayerIndex].setupCmd)) {
gActiveSeqs[seqPlayerIndex].setupCmd[found] = cmd;
// Adds a delay of 2 frames before executing any setup commands.
// This allows setup commands to be requested along with a new sequence on a seqPlayerIndex.
// This 2 frame delay ensures the player is enabled before its state is checked for
// the purpose of deciding if the setup commands should be run.
// Otherwise, the setup commands will be executed before the sequence starts,
// when the player is still disabled, instead of when the newly played sequence ends.
gActiveSeqs[seqPlayerIndex].setupCmdTimer = 2;
}
}
} else {
// `SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS`
// Discard all setup command requests on `seqPlayerIndex`
gActiveSeqs[seqPlayerIndex].setupCmdNum = 0;
}
break;
case SEQCMD_OP_GLOBAL_CMD:
// Apply a command that applies to all sequence players
subOp = (cmd & 0xF00) >> 8;
val = cmd & 0xFF;
switch (subOp) {
case SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE:
// Set sound mode
AUDIOCMD_GLOBAL_SET_SOUND_MODE(sSoundModeList[val]);
break;
case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES:
// Set sequence disabled in (sStartSeqDisabled & 1) bit
sStartSeqDisabled = (sStartSeqDisabled & (u8)~1) | (u8)(val & 1);
break;
case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2:
// Set sequence disabled in (sStartSeqDisabled & 2) bit
sStartSeqDisabled = (sStartSeqDisabled & (u8)~2) | (u8)((val & 1) << 1);
break;
}
break;
case SEQCMD_OP_RESET_AUDIO_HEAP:
// Resets the audio heap based on the audio specifications, audio mode, and sfx channel layout
specId = cmd & 0xFF;
fadeReverb = (cmd & 0xFF0000) >> 16;
if (fadeReverb == 0) {
gSfxChannelLayout = (cmd & 0xFF00) >> 8;
oldSpecId = gAudioSpecId;
gAudioSpecId = specId;
AudioThread_ResetAudioHeap(specId);
Audio_ResetForAudioHeapStep1(oldSpecId);
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
} else {
sResetAudioHeapSeqCmd = cmd;
sResetAudioHeapFadeReverbVolume = 0x7FFF;
sResetAudioHeapTimer = 20;
sResetAudioHeapFadeReverbVolumeStep = 0x666;
}
break;
}
}
/**
* Add the sequence cmd to the `sAudioSeqCmds` queue
*/
void AudioSeq_QueueSeqCmd(u32 cmd) {
sAudioSeqCmds[sSeqCmdWritePos++] = cmd;
}
void AudioSeq_ProcessSeqCmds(void) {
while (sSeqCmdWritePos != sSeqCmdReadPos) {
AudioSeq_ProcessSeqCmd(sAudioSeqCmds[sSeqCmdReadPos++]);
}
}
u16 AudioSeq_GetActiveSeqId(u8 seqPlayerIndex) {
if (gActiveSeqs[seqPlayerIndex].isWaitingForFonts == true) {
return gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd & SEQCMD_SEQID_MASK;
}
if (gActiveSeqs[seqPlayerIndex].seqId != NA_BGM_DISABLED) {
return gActiveSeqs[seqPlayerIndex].seqId;
}
return NA_BGM_DISABLED;
}
s32 AudioSeq_IsSeqCmdNotQueued(u32 cmdVal, u32 cmdMask) {
u8 i;
for (i = sSeqCmdReadPos; i != sSeqCmdWritePos; i++) {
if ((sAudioSeqCmds[i] & cmdMask) == cmdVal) {
return false;
}
}
return true;
}
// Unused
void AudioSeq_ResetSequenceRequests(u8 seqPlayerIndex) {
sNumSeqRequests[seqPlayerIndex] = 0;
}
/**
* Check if the setup command is queued. If it is, then replace the command
* with `SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME`.
* Unused
*/
void AudioSeq_ReplaceSeqCmdSetupOpVolRestore(u8 seqPlayerIndex, u8 setupOpDisabled) {
u8 i;
for (i = 0; i < gActiveSeqs[seqPlayerIndex].setupCmdNum; i++) {
u8 setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[i] & 0xF00000) >> 20;
if (setupOp == setupOpDisabled) {
gActiveSeqs[seqPlayerIndex].setupCmd[i] = 0xFF000000;
}
}
}
void AudioSeq_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer) {
f32 volScale;
u8 i;
gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = targetVol & 0x7F;
if (volFadeTimer != 0) {
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true;
gActiveSeqs[seqPlayerIndex].volFadeTimer = volFadeTimer;
} else {
for (i = 0, volScale = 1.0f; i < VOL_SCALE_INDEX_MAX; i++) {
volScale *= gActiveSeqs[seqPlayerIndex].volScales[i] / 127.0f;
}
SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, volFadeTimer, volScale);
}
}
/**
* Update different commands and requests for active sequences
*/
void AudioSeq_UpdateActiveSequences(void) {
u32 tempoCmd;
u16 tempoPrev;
u16 seqId;
u16 channelMask;
u16 tempoTarget;
u8 setupOp;
u8 targetSeqPlayerIndex;
u8 setupVal2;
u8 setupVal1;
u8 tempoOp;
s32 pad[2];
u32 retMsg;
f32 volume;
u8 tempoTimer;
u8 seqPlayerIndex;
u8 j;
u8 channelIndex;
for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) {
// The seqPlayer has finished initializing and is currently playing the active sequences
if (gActiveSeqs[seqPlayerIndex].isSeqPlayerInit && gAudioCtx.seqPlayers[seqPlayerIndex].enabled) {
gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = false;
}
// The seqPlayer is no longer playing the active sequences
if ((AudioSeq_GetActiveSeqId(seqPlayerIndex) != NA_BGM_DISABLED) &&
!gAudioCtx.seqPlayers[seqPlayerIndex].enabled && (!gActiveSeqs[seqPlayerIndex].isSeqPlayerInit)) {
gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED;
}
// Check if the requested sequences is waiting for fonts to load
if (gActiveSeqs[seqPlayerIndex].isWaitingForFonts) {
switch ((s32)AudioThread_GetExternalLoadQueueMsg(&retMsg)) {
case SEQ_PLAYER_BGM_MAIN + 1:
case SEQ_PLAYER_FANFARE + 1:
case SEQ_PLAYER_SFX + 1:
case SEQ_PLAYER_BGM_SUB + 1:
case SEQ_PLAYER_AMBIENCE + 1:
// The fonts have been loaded successfully.
gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false;
// Queue the same command that was stored previously, but without the 0x8000
AudioSeq_ProcessSeqCmd(gActiveSeqs[seqPlayerIndex].startAsyncSeqCmd);
break;
case 0xFF:
// There was an error in loading the fonts
gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false;
break;
}
}
// Update global volume
if (gActiveSeqs[seqPlayerIndex].fadeVolUpdate) {
volume = 1.0f;
for (j = 0; j < VOL_SCALE_INDEX_MAX; j++) {
volume *= (gActiveSeqs[seqPlayerIndex].volScales[j] / 127.0f);
}
SEQCMD_SET_SEQPLAYER_VOLUME((u8)(seqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)),
gActiveSeqs[seqPlayerIndex].volFadeTimer, (u8)(volume * 127.0f));
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false;
}
if (gActiveSeqs[seqPlayerIndex].volTimer != 0) {
gActiveSeqs[seqPlayerIndex].volTimer--;
if (gActiveSeqs[seqPlayerIndex].volTimer != 0) {
gActiveSeqs[seqPlayerIndex].volCur -= gActiveSeqs[seqPlayerIndex].volStep;
} else {
gActiveSeqs[seqPlayerIndex].volCur = gActiveSeqs[seqPlayerIndex].volTarget;
}
AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur);
}
// Process tempo
if (gActiveSeqs[seqPlayerIndex].tempoCmd != 0) {
tempoCmd = gActiveSeqs[seqPlayerIndex].tempoCmd;
tempoTimer = (tempoCmd & 0xFF0000) >> 15;
tempoTarget = tempoCmd & 0xFFF;
if (tempoTimer == 0) {
tempoTimer++;
}
// Process tempo commands
if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled) {
tempoPrev = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / TATUMS_PER_BEAT;
tempoOp = (tempoCmd & 0xF000) >> 12;
switch (tempoOp) {
case SEQCMD_SUB_OP_TEMPO_SPEED_UP:
// Speed up tempo by `tempoTarget` amount
tempoTarget += tempoPrev;
break;
case SEQCMD_SUB_OP_TEMPO_SLOW_DOWN:
// Slow down tempo by `tempoTarget` amount
if (tempoTarget < tempoPrev) {
tempoTarget = tempoPrev - tempoTarget;
}
break;
case SEQCMD_SUB_OP_TEMPO_SCALE:
// Scale tempo by a multiplicative factor
tempoTarget = tempoPrev * (tempoTarget / 100.0f);
break;
case SEQCMD_SUB_OP_TEMPO_RESET:
// Reset tempo to original tempo
tempoTarget = (gActiveSeqs[seqPlayerIndex].tempoOriginal != 0)
? gActiveSeqs[seqPlayerIndex].tempoOriginal
: tempoPrev;
break;
default: // `SEQCMD_SUB_OP_TEMPO_SET`
// `tempoTarget` is the new tempo
break;
}
if (gActiveSeqs[seqPlayerIndex].tempoOriginal == 0) {
gActiveSeqs[seqPlayerIndex].tempoOriginal = tempoPrev;
}
gActiveSeqs[seqPlayerIndex].tempoTarget = tempoTarget;
gActiveSeqs[seqPlayerIndex].tempoCur = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / 0x30;
gActiveSeqs[seqPlayerIndex].tempoStep =
(gActiveSeqs[seqPlayerIndex].tempoCur - gActiveSeqs[seqPlayerIndex].tempoTarget) / tempoTimer;
gActiveSeqs[seqPlayerIndex].tempoTimer = tempoTimer;
gActiveSeqs[seqPlayerIndex].tempoCmd = 0;
}
}
// Step tempo to target
if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) {
gActiveSeqs[seqPlayerIndex].tempoTimer--;
if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) {
gActiveSeqs[seqPlayerIndex].tempoCur -= gActiveSeqs[seqPlayerIndex].tempoStep;
} else {
gActiveSeqs[seqPlayerIndex].tempoCur = gActiveSeqs[seqPlayerIndex].tempoTarget;
}
AUDIOCMD_SEQPLAYER_SET_TEMPO(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].tempoCur);
}
// Update channel volumes
if (gActiveSeqs[seqPlayerIndex].volChannelFlags != 0) {
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer != 0) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer--;
if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer != 0) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur -=
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volStep;
} else {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur =
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget;
gActiveSeqs[seqPlayerIndex].volChannelFlags ^= (1 << channelIndex);
}
AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, channelIndex,
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur);
}
}
}
// Update frequencies
if (gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags != 0) {
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer != 0) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer--;
if (gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTimer != 0) {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur -=
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleStep;
} else {
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur =
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget;
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags ^= (1 << channelIndex);
}
AUDIOCMD_CHANNEL_SET_FREQ_SCALE(seqPlayerIndex, channelIndex,
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur);
}
}
}
// Process setup commands
if (gActiveSeqs[seqPlayerIndex].setupCmdNum != 0) {
// If there is a SeqCmd to reset the audio heap queued, then drop all setup commands
if (!AudioSeq_IsSeqCmdNotQueued(SEQCMD_OP_RESET_AUDIO_HEAP << 28, SEQCMD_OP_MASK)) {
gActiveSeqs[seqPlayerIndex].setupCmdNum = 0;
break;
}
// Only process setup commands once the timer reaches zero
if (gActiveSeqs[seqPlayerIndex].setupCmdTimer != 0) {
gActiveSeqs[seqPlayerIndex].setupCmdTimer--;
continue;
}
// Only process setup commands if `seqPlayerIndex` if no longer playing
// i.e. the `seqPlayer` is no longer enabled
if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled) {
continue;
}
for (j = 0; j < gActiveSeqs[seqPlayerIndex].setupCmdNum; j++) {
setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xF00000) >> 20;
targetSeqPlayerIndex = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xF0000) >> 16;
setupVal2 = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF00) >> 8;
setupVal1 = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF;
switch (setupOp) {
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME:
// Restore `targetSeqPlayerIndex` volume back to normal levels
AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal1);
break;
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED:
// Restore `targetSeqPlayerIndex` volume back to normal levels,
// but only if the number of sequence queue requests from `sSeqRequests`
// exactly matches the argument to the command
if (setupVal1 == sNumSeqRequests[seqPlayerIndex]) {
AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal2);
}
break;
case SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE:
// Unqueue `seqPlayerIndex` from sSeqRequests
//! @bug this command does not work as intended as unqueueing
//! the sequence relies on `gActiveSeqs[seqPlayerIndex].seqId`
//! However, `gActiveSeqs[seqPlayerIndex].seqId` is reset before the sequence on
//! `seqPlayerIndex` is requested to stop, i.e. before the sequence is disabled and setup
//! commands (including this command) can run. A simple fix would have been to unqueue based on
//! `gActiveSeqs[seqPlayerIndex].prevSeqId` instead
SEQCMD_UNQUEUE_SEQUENCE((u8)(seqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), 0,
gActiveSeqs[seqPlayerIndex].seqId);
break;
case SEQCMD_SUB_OP_SETUP_RESTART_SEQ:
// Restart the currently active sequence on `targetSeqPlayerIndex` with full volume.
// Sequence on `targetSeqPlayerIndex` must still be active to play (can be muted)
SEQCMD_PLAY_SEQUENCE((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), 1,
gActiveSeqs[targetSeqPlayerIndex].seqId);
gActiveSeqs[targetSeqPlayerIndex].fadeVolUpdate = true;
gActiveSeqs[targetSeqPlayerIndex].volScales[1] = 0x7F;
break;
case SEQCMD_SUB_OP_SETUP_TEMPO_SCALE:
// Scale tempo by a multiplicative factor
SEQCMD_SCALE_TEMPO((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal2,
setupVal1);
break;
case SEQCMD_SUB_OP_SETUP_TEMPO_RESET:
// Reset tempo to previous tempo
SEQCMD_RESET_TEMPO((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal1);
break;
case SEQCMD_SUB_OP_SETUP_PLAY_SEQ:
// Play the requested sequence
// Uses the fade timer set by `SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER`
seqId = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFFFF;
SEQCMD_PLAY_SEQUENCE((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)),
gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer, seqId);
AudioSeq_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, 0);
gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer = 0;
break;
case SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER:
// A command specifically to support `SEQCMD_SUB_OP_SETUP_PLAY_SEQ`
// Sets the fade timer for the sequence requested in `SEQCMD_SUB_OP_SETUP_PLAY_SEQ`
gActiveSeqs[seqPlayerIndex].setupFadeTimer = setupVal2;
break;
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX:
// Restore the volume back to default levels
// Allows a `scaleIndex` to be specified.
AudioSeq_SetVolumeScale(targetSeqPlayerIndex, setupVal2, 0x7F, setupVal1);
break;
case SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE:
// Discard audio data by popping one more audio caches from the audio heap
if (setupVal1 & (1 << SEQUENCE_TABLE)) {
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SEQUENCE_TABLE);
}
if (setupVal1 & (1 << FONT_TABLE)) {
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(FONT_TABLE);
}
if (setupVal1 & (1 << SAMPLE_TABLE)) {
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SAMPLE_TABLE);
}
break;
case SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK:
// Disable (or reenable) specific channels of `targetSeqPlayerIndex`
channelMask = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFFFF;
SEQCMD_SET_CHANNEL_DISABLE_MASK((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)),
channelMask);
break;
case SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ:
// Scale all channels of `targetSeqPlayerIndex`
SEQCMD_SET_SEQPLAYER_FREQ((u8)(targetSeqPlayerIndex + (SEQCMD_ASYNC_ACTIVE >> 24)), setupVal2,
setupVal1 * 10);
break;
default:
break;
}
}
gActiveSeqs[seqPlayerIndex].setupCmdNum = 0;
}
}
}
u8 AudioSeq_UpdateAudioHeapReset(void) {
if (gAudioHeapResetState != AUDIO_HEAP_RESET_STATE_NONE) {
if (gAudioHeapResetState == AUDIO_HEAP_RESET_STATE_RESETTING) {
if (func_80193C5C() == 1) {
gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE;
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
Audio_ResetForAudioHeapStep2();
}
} else if (gAudioHeapResetState == AUDIO_HEAP_RESET_STATE_RESETTING_ALT) {
while (func_80193C5C() != 1) {}
gAudioHeapResetState = AUDIO_HEAP_RESET_STATE_NONE;
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
Audio_ResetForAudioHeapStep2();
}
}
return gAudioHeapResetState;
}
u8 AudioSeq_ResetReverb(void) {
u8 isReverbFading = false;
u8 fadeReverb = ((sResetAudioHeapSeqCmd & 0xFF0000) >> 16);
u8 reverbIndex = 0;
u8 specId;
if (sResetAudioHeapSeqCmd != 0) {
if (sResetAudioHeapTimer--) {
while (fadeReverb != 0) {
if (fadeReverb & 1) {
AUDIOCMD_GLOBAL_SET_REVERB_DATA(reverbIndex, REVERB_DATA_TYPE_VOLUME,
sResetAudioHeapFadeReverbVolume);
AudioThread_ScheduleProcessCmds();
}
reverbIndex++;
fadeReverb = fadeReverb >> 1;
}
sResetAudioHeapFadeReverbVolume -= sResetAudioHeapFadeReverbVolumeStep;
isReverbFading = true;
} else {
while (fadeReverb != 0) {
if (fadeReverb & 1) {
AUDIOCMD_GLOBAL_SET_REVERB_DATA(
reverbIndex, REVERB_DATA_TYPE_SETTINGS,
(s32)(gReverbSettingsTable[(u8)(sResetAudioHeapSeqCmd & 0xFF)] + reverbIndex));
AudioThread_ScheduleProcessCmds();
}
reverbIndex++;
fadeReverb = fadeReverb >> 1;
}
sResetAudioHeapSeqCmd = 0;
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
Audio_ResetForAudioHeapStep3();
}
}
return isReverbFading;
}
void AudioSeq_ResetActiveSequences(void) {
u8 seqPlayerIndex;
u8 scaleIndex;
for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) {
sNumSeqRequests[seqPlayerIndex] = 0;
gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED;
gActiveSeqs[seqPlayerIndex].prevSeqId = NA_BGM_DISABLED;
gActiveSeqs[seqPlayerIndex].tempoTimer = 0;
gActiveSeqs[seqPlayerIndex].tempoOriginal = 0;
gActiveSeqs[seqPlayerIndex].tempoCmd = 0;
gActiveSeqs[seqPlayerIndex].channelPortMask = 0;
gActiveSeqs[seqPlayerIndex].setupCmdNum = 0;
gActiveSeqs[seqPlayerIndex].setupFadeTimer = 0;
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0;
gActiveSeqs[seqPlayerIndex].volChannelFlags = 0;
gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false;
gActiveSeqs[seqPlayerIndex].isSeqPlayerInit = false;
for (scaleIndex = 0; scaleIndex < VOL_SCALE_INDEX_MAX; scaleIndex++) {
gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F;
}
gActiveSeqs[seqPlayerIndex].volFadeTimer = 1;
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true;
}
}
void AudioSeq_ResetActiveSequencesAndVolume(void) {
u8 seqPlayerIndex;
u8 scaleIndex;
for (seqPlayerIndex = 0; seqPlayerIndex < SEQ_PLAYER_MAX; seqPlayerIndex++) {
gActiveSeqs[seqPlayerIndex].volCur = 1.0f;
gActiveSeqs[seqPlayerIndex].volTimer = 0;
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false;
for (scaleIndex = 0; scaleIndex < VOL_SCALE_INDEX_MAX; scaleIndex++) {
gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F;
}
}
AudioSeq_ResetActiveSequences();
}
+4 -4
View File
@@ -102,8 +102,8 @@ void AudioSfx_MuteBanks(u16 muteMask) {
void AudioSfx_LowerBgmVolume(u8 channelIndex) {
sSfxChannelLowVolumeFlag |= (1 << channelIndex);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x40, 0xF);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x40, 0xF);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x40, 0xF);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x40, 0xF);
}
/**
@@ -114,8 +114,8 @@ void AudioSfx_RestoreBgmVolume(u8 channelIndex) {
sSfxChannelLowVolumeFlag &= ((1 << channelIndex) ^ 0xFFFF);
if (sSfxChannelLowVolumeFlag == 0) {
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 2, 0x7F, 0xF);
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 2, 0x7F, 0xF);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x7F, 0xF);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x7F, 0xF);
}
}
+1 -1
View File
@@ -37,6 +37,6 @@ UNK_TYPE func_801A51F0(UNK_TYPE arg0) {
#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5808.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5A10.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/AudioVoice_ResetData.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/voice_internal/func_801A5A1C.s")
+1 -1
View File
@@ -80,7 +80,7 @@ void AudioMgr_ThreadEntry(void* arg) {
Audio_Init();
AudioLoad_SetDmaHandler(DmaMgr_DmaHandler);
func_801A4D00();
Audio_InitSound();
osSendMesg(&audioMgr->lockMsgQ, NULL, OS_MESG_BLOCK);
IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptMsgQ);
+4 -4
View File
@@ -396,9 +396,9 @@ void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCm
u8 fadeTimer = cmd->endFrame - cmd->startFrame;
if (cmd->type == 2) {
Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, fadeTimer);
} else {
Audio_QueueSeqCmd((fadeTimer << 0x10) | NA_BGM_STOP);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, fadeTimer);
}
}
}
@@ -471,7 +471,7 @@ void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
break;
case 7:
seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN);
seqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
break;
case 8:
@@ -492,7 +492,7 @@ void Cutscene_Command_FadeAmbienceSequence(PlayState* play, CutsceneContext* csC
if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) {
u8 fadeTimer = cmd->endFrame - cmd->startFrame;
Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x140000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, fadeTimer);
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ void GameOver_Update(PlayState* play) {
break;
case GAMEOVER_DEATH_FADE_OUT:
if (Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) {
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) {
func_80169F78(&play->state);
if (gSaveContext.respawnFlag != -7) {
gSaveContext.respawnFlag = -6;
+1 -1
View File
@@ -4324,7 +4324,7 @@ void Interface_DrawPerfectLetters(PlayState* play) {
void Interface_StartMoonCrash(PlayState* play) {
if (play->actorCtx.flags & ACTORCTX_FLAG_1) {
Audio_QueueSeqCmd(0xE0000100);
SEQCMD_DISABLE_PLAY_SEQUENCES(false);
}
gSaveContext.save.day = 4;
+2 -2
View File
@@ -572,7 +572,7 @@ void Play_UpdateTransition(PlayState* this) {
((this->nextEntrance == ENTRANCE(TERMINA_FIELD, 2)) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) ||
((this->nextEntrance == ENTRANCE(ROAD_TO_IKANA, 1)) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20))) &&
(!func_800FE590(this) || (Entrance_GetSceneId(this->nextEntrance + sceneLayer) < 0) ||
(Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS))) {
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS))) {
func_801A4058(20);
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.ambienceId = AMBIENCE_ID_DISABLED;
@@ -585,7 +585,7 @@ void Play_UpdateTransition(PlayState* this) {
}
if (func_800FE590(this) && (Entrance_GetSceneId(this->nextEntrance + sceneLayer) >= 0) &&
(Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) {
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS)) {
func_801A41C8(20);
}
}
+1 -1
View File
@@ -444,7 +444,7 @@ void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) {
play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId;
if (gSaveContext.seqId == (u8)NA_BGM_DISABLED ||
Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) {
AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) {
Audio_SetSpec(cmd->soundSettings.specId);
}
}
+3 -3
View File
@@ -979,7 +979,7 @@ void func_809DAB78(Boss02* this, PlayState* play) {
}
if (otherTwinmold->unk_0144 >= 10) {
Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_BOSS | SEQ_FLAG_ASYNC);
}
Actor_PlaySfx(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD);
@@ -1105,7 +1105,7 @@ void func_809DBFB4(Boss02* this, PlayState* play) {
this->unk_0144 = 20;
if (otherTwinmold->unk_0144 >= 10) {
Audio_QueueSeqCmd(0x100100FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
} else {
otherTwinmold->unk_0195 = 1;
}
@@ -1311,7 +1311,7 @@ void Boss02_Static_Update(Actor* thisx, PlayState* play) {
if (sMusicStartTimer != 0) {
sMusicStartTimer--;
if (sMusicStartTimer == 0) {
Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC);
}
}
}
+5 -5
View File
@@ -518,7 +518,7 @@ void Boss03_Init(Actor* thisx, PlayState* play2) {
if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_56)) {
this->actionFunc = func_809E344C;
D_809E9842 = false;
Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
} else {
Boss03_SetupIntroCutscene(this, play);
D_809E9842 = true;
@@ -1305,7 +1305,7 @@ void Boss03_IntroCutscene(Boss03* this, PlayState* play) {
this->actor.gravity = -1.5f;
this->actor.speed = 20.0f;
Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC);
Actor_PlaySfx(&this->actor, NA_SE_EN_KONB_JUMP_OLD);
this->skelAnime.playSpeed = 1.0f;
}
@@ -1415,7 +1415,7 @@ void Boss03_SetupDeathCutscene(Boss03* this, PlayState* play) {
this->actionFunc = Boss03_DeathCutscene;
Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f);
this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim);
Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
this->workTimer[WORK_TIMER_UNK0_C] = 0;
this->unk_242 = 0;
this->csState = 0;
@@ -1558,7 +1558,7 @@ void Boss03_DeathCutscene(Boss03* this, PlayState* play) {
case 1:
if (this->unk_240 == 0x96) {
Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_BOSS | SEQ_FLAG_ASYNC);
}
Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f);
Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f);
@@ -2084,7 +2084,7 @@ void Boss03_Update(Actor* thisx, PlayState* play2) {
if (D_809E9841 != 0) {
D_809E9841--;
if (D_809E9841 == 0) {
Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_BOSS | SEQ_FLAG_ASYNC);
}
}
+2 -2
View File
@@ -716,7 +716,7 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) {
break;
case 1730:
Audio_QueueSeqCmd(0x141400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 20);
break;
case 1395:
@@ -724,7 +724,7 @@ void DmStk_PlaySfxForEndingCutsceneSecondPart(DmStk* this, PlayState* play) {
break;
case 1850:
Audio_QueueSeqCmd(0x42320000);
SEQCMD_SET_SEQPLAYER_VOLUME(SEQ_PLAYER_SFX, 50, 0);
break;
case 2000:
@@ -673,7 +673,7 @@ void func_809C2730(EnAob01* this, PlayState* play) {
void func_809C2788(EnAob01* this, PlayState* play) {
this->unk_2D2 |= 0x20;
if (func_809C25E4(this, play)) {
if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) {
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) {
play->nextEntrance = ENTRANCE(DOGGY_RACETRACK, 1);
gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & (u8)~7) | 3;
play->transitionType = TRANS_TYPE_64;
+1 -1
View File
@@ -699,7 +699,7 @@ void EnBaba_KnockedOver(EnBaba* this, PlayState* play) {
}
} else {
if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40) && (DECR(this->sakonDeadTimer) == 0)) {
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7));
} else {
Actor_MoveWithGravity(&this->actor);
@@ -292,7 +292,7 @@ void EnBji01_DialogueHandler(EnBji01* this, PlayState* play) {
void func_809CD634(EnBji01* this, PlayState* play) {
AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) |
(1 << BANK_OCARINA) | (1 << BANK_VOICE));
Audio_QueueSeqCmd(0xE0000101);
SEQCMD_DISABLE_PLAY_SEQUENCES(true);
play->nextEntrance = ENTRANCE(TERMINA_FIELD, 10); /* Telescope entrance */
gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = play->nextEntrance;
func_80169EFC(&play->state); /* Load new entrance? */
@@ -346,13 +346,15 @@ void EnBji01_Init(Actor* thisx, PlayState* play) {
this->actor.params = SHIKASHI_TYPE_DEFAULT;
func_809CCE98(this, play);
break;
case ENTRANCE(ASTRAL_OBSERVATORY, 2): /* Telescope entrance */
this->actor.flags |= ACTOR_FLAG_10000;
AudioSfx_MuteBanks(0);
Audio_QueueSeqCmd(0xE0000100);
SEQCMD_DISABLE_PLAY_SEQUENCES(false);
this->actor.params = SHIKASHI_TYPE_LOOKED_THROUGH_TELESCOPE;
func_809CCE98(this, play);
break;
default:
Actor_Kill(&this->actor);
break;
@@ -851,7 +851,7 @@ void EnFishing_Init(Actor* thisx, PlayState* play2) {
D_809171FC = 0;
D_809171F6 = 10;
Audio_QueueSeqCmd(0x100100FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
if (sLinkAge == 1) {
if (gSaveContext.save.unk_EE4 & 0x7F) {
@@ -3540,7 +3540,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) {
this->unk_190 = 1.7f;
this->unk_194 = 7000.0f;
D_80917274 = 1;
Audio_QueueSeqCmd(0x881A); // Changed from 0x81A in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ENEMY | 0x800 | SEQ_FLAG_ASYNC);
D_809171F6 = 0;
if (this->unk_148 == 1) {
@@ -3751,7 +3751,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) {
} else {
// Assignment of OoT's D_80B7E086 here removed in MM
Rumble_Override(0.0f, 1, 3, 1);
Audio_QueueSeqCmd(0x100A00FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10);
}
this->unk_150 = this->unk_152 = 0;
@@ -3819,7 +3819,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) {
}
if (this->unk_172[0] == 90) {
Audio_QueueSeqCmd(0x8924); // changed from 0x924 in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GET_HEART | 0x900 | SEQ_FLAG_ASYNC);
D_8090CCFC = 40;
if (this->unk_148 == 0) {
@@ -3933,7 +3933,7 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) {
D_809101C4 = 520.0f;
D_809101C0 = 195.0f;
Audio_QueueSeqCmd(0x100A00FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10);
D_809171F6 = 20;
D_8090CD4C = 3;
}
@@ -5148,7 +5148,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) {
D_8090CD4C = 20;
Rumble_Override(0.0f, 150, 10, 10);
play_sound(NA_SE_SY_TRE_BOX_APPEAR);
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
}
if (D_8090CD50 != 0) {
@@ -5356,7 +5356,7 @@ void EnFishing_UpdateOwner(Actor* thisx, PlayState* play2) {
case 22:
if (D_8090CD50 == 30) {
Audio_QueueSeqCmd(0x8922); // changed from 0x922 to 0x8922 in MM
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GET_ITEM | 0x900 | SEQ_FLAG_ASYNC);
}
D_8090CD54 = 1;
@@ -5638,15 +5638,15 @@ void EnFishing_DrawOwner(Actor* thisx, PlayState* play) {
if (D_809171F6 == 0) {
if (sLinkAge != 1) {
Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_EVENT | SEQ_FLAG_ASYNC);
} else {
Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_MUSIC_BOX_HOUSE | SEQ_FLAG_ASYNC);
}
if (sLinkAge != 1) {
Audio_QueueSeqCmd(0x8019); // Changed from 0x19 in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CLEAR_EVENT | SEQ_FLAG_ASYNC);
} else {
Audio_QueueSeqCmd(0x8027); // Changed from 0x27 in OoT
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_MUSIC_BOX_HOUSE | SEQ_FLAG_ASYNC);
}
}
}
+3 -3
View File
@@ -538,7 +538,7 @@ void func_80962660(EnFu* this, PlayState* play) {
player->stateFlags1 |= PLAYER_STATE1_20;
this->unk_53C = 0;
Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3);
func_801A2BB8(NA_BGM_TIMED_MINI_GAME);
Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME);
if (this->unk_542 == 0) {
if (this->unk_546 == 1) {
func_80961EC8(play);
@@ -789,14 +789,14 @@ void func_80962F4C(EnFu* this, PlayState* play) {
Message_StartTextbox(play, 0x2888, &this->actor);
this->unk_552 = 0x2888;
}
func_801A2C20();
Audio_StopSubBgm();
gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0);
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP;
this->unk_548 = 0;
func_809632D0(this);
} else {
this->unk_548 = 0;
func_801A2C20();
Audio_StopSubBgm();
gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0);
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP;
Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900);
@@ -257,11 +257,11 @@ void func_80BC7068(EnGuruguru* this, PlayState* play) {
}
if ((this->unk268 != 0) && (this->textIdIndex >= 7)) {
this->skelAnime.playSpeed = 2.0f;
func_801A29D4(3, 1.18921f, 2);
Audio_SetSeqTempoAndFreq(3, 1.18921f, 2);
func_801A3B48(0);
} else {
if (this->skelAnime.playSpeed == 2.0f) {
func_801A29D4(3, 1.0f, 2);
Audio_SetSeqTempoAndFreq(3, 1.0f, 2);
}
if (this->unk268 == 0) {
func_801A3B48(1);
@@ -2934,7 +2934,7 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) {
if (((play->interfaceCtx.minigameAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) {
this->hbaFlags &= ~4;
Audio_QueueSeqCmd(0x8041);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
}
if (this->hbaStarted == 0) {
@@ -248,7 +248,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) {
}
if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(180)) {
Audio_QueueSeqCmd(0x8041);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
play_sound(NA_SE_SY_START_SHOT);
this->unk_164 |= 0x40000;
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
@@ -281,7 +281,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) {
if ((this->unk_164 & 0x4000) && (horseGameCheck != NULL) &&
(horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) &&
(horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x40000)) {
Audio_QueueSeqCmd(0x8041);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
play_sound(NA_SE_SY_START_SHOT);
this->unk_164 |= 0x40000;
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
@@ -314,7 +314,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) {
if ((this->unk_164 & 0x200000) && (horseGameCheck != NULL) &&
(horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) &&
(horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x02000000)) {
Audio_QueueSeqCmd(0x8041);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
play_sound(NA_SE_SY_START_SHOT);
this->unk_164 |= 0x02000000;
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
@@ -343,7 +343,7 @@ s32 func_808F8FAC(EnHorseGameCheck* this, PlayState* play) {
if ((this->unk_164 & 0x80) && (horseGameCheck != NULL) &&
(horseGameCheck->dyna.actor.id == ACTOR_EN_HORSE_GAME_CHECK) &&
(horseGameCheck->unk_15C == ENHORSEGAMECHECK_FF_7) && !(this->unk_164 & 0x800)) {
Audio_QueueSeqCmd(0x8041);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
play_sound(NA_SE_SY_START_SHOT);
this->unk_164 |= 0x800;
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
@@ -1653,7 +1653,7 @@ void func_80B4627C(EnInvadepoh* this, PlayState* play) {
} else {
func_80B454BC(this, play);
func_80B452EC(this, play);
Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ALIEN_INVASION | SEQ_FLAG_ASYNC);
func_80B46F88(this);
}
} else if (D_80B4E940 == 3) {
@@ -1941,7 +1941,7 @@ void func_80B46EE8(EnInvadepoh* this, PlayState* play) {
this->actionTimer--;
if (this->actionTimer <= 0) {
ActorCutscene_Stop(D_80B50404[0]);
Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ALIEN_INVASION | SEQ_FLAG_ASYNC);
func_80B46F88(this);
}
}
@@ -284,7 +284,7 @@ void func_80C1410C(EnJgameTsn* this, PlayState* play) {
Player* player = GET_PLAYER(play);
player->stateFlags1 |= PLAYER_STATE1_20;
func_801A2BB8(0x25);
Audio_PlaySubBgm(0x25);
play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3;
Interface_InitMinigame(play);
SET_WEEKEVENTREG(WEEKEVENTREG_90_20);
@@ -341,7 +341,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) {
this->unk_300 = 0x109F;
player->stateFlags1 |= PLAYER_STATE1_20;
*this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE;
func_801A2C20();
Audio_StopSubBgm();
func_80C14030(this);
} else if ((player->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) ||
(player->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
@@ -350,7 +350,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) {
this->unk_300 = 0x10A0;
player->stateFlags1 |= PLAYER_STATE1_20;
*this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE;
func_801A2C20();
Audio_StopSubBgm();
func_80C14030(this);
}
@@ -359,7 +359,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) {
this->unk_300 = 0x10A1;
player->stateFlags1 |= PLAYER_STATE1_20;
*this->unk_208[this->unk_218] &= ~OBJLUPYGAMELIFT_IGNITE_FIRE;
func_801A2C20();
Audio_StopSubBgm();
func_80C14030(this);
}
}
@@ -506,7 +506,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) {
this->subCamUp.x = -0.11f;
this->picto.actor.draw = EnKaizoku_Draw;
this->unk_598 = 0;
func_801A0238(0, 0xA);
Audio_SetMainBgmVolume(0, 0xA);
this->unk_59C++;
case 1:
@@ -575,7 +575,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) {
Message_CloseTextbox(play);
this->unk_598 = 0;
this->unk_59C++;
func_801A0238(0x7F, 0);
Audio_SetMainBgmVolume(0x7F, 0);
Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS);
EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_13);
}
@@ -800,7 +800,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, PlayState* play) {
if (currentDay == 3 && gSaveContext.save.isNight) {
EnKakasi_SetupDigAway(this);
} else {
func_801A2BB8(NA_BGM_SARIAS_SONG);
Audio_PlaySubBgm(NA_BGM_SARIAS_SONG);
EnKakasi_SetupDanceNightAway(this);
}
}
@@ -731,7 +731,7 @@ void func_80AEAFA0(EnLiftNuts* this, PlayState* play) {
}
void func_80AEB114(EnLiftNuts* this) {
func_801A2BB8(NA_BGM_TIMED_MINI_GAME);
Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME);
this->actionFunc = func_80AEB148;
}
+2 -2
View File
@@ -730,8 +730,8 @@ void EnMa4_HorsebackGameWait(EnMa4* this, PlayState* play) {
void EnMa4_SetupHorsebackGameEnd(EnMa4* this, PlayState* play) {
CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01);
this->actionFunc = EnMa4_HorsebackGameEnd;
Audio_QueueSeqCmd(NA_BGM_STOP);
Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
}
void EnMa4_HorsebackGameEnd(EnMa4* this, PlayState* play) {
+2 -2
View File
@@ -373,7 +373,7 @@ void func_80A6F9DC(EnMm3* this, PlayState* play) {
void func_80A6FBA0(EnMm3* this) {
AudioSfx_MuteBanks((1 << BANK_PLAYER) | (1 << BANK_ITEM) | (1 << BANK_ENV) | (1 << BANK_ENEMY) |
(1 << BANK_OCARINA) | (1 << BANK_VOICE));
func_801A0238(0, 5);
Audio_SetMainBgmVolume(0, 5);
SET_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_WAIT);
CLEAR_WEEKEVENTREG(WEEKEVENTREG_KICKOUT_TIME_PASSED);
this->actionFunc = func_80A6FBFC;
@@ -400,7 +400,7 @@ void func_80A6FBFC(EnMm3* this, PlayState* play) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
AudioSfx_MuteBanks(0);
func_801A0238(0x7F, 5);
Audio_SetMainBgmVolume(0x7F, 5);
Message_StartTextbox(play, 0x2791, &this->actor);
this->unk_2B4 = 0x2791;
this->unk_2AC = 7;
@@ -257,7 +257,7 @@ void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) {
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF;
Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start
func_800B7298(play, &this->actor, PLAYER_CSMODE_7);
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
this->actionFunc = EnMttag_PotentiallyRestartRace;
}
@@ -317,7 +317,7 @@ void EnMttag_RaceStart(EnMttag* this, PlayState* play) {
if (DECR(this->timer) == 60) {
Interface_StartTimer(TIMER_ID_MINIGAME_2, 0);
play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3;
Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_RACE | SEQ_FLAG_ASYNC);
play->envCtx.unk_E4 = 0xFE;
player->stateFlags1 &= ~PLAYER_STATE1_20;
} else if ((this->timer < 60) && (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO)) {
@@ -362,14 +362,14 @@ void EnMttag_Race(EnMttag* this, PlayState* play) {
if (EnMttag_IsInFinishLine(playerPos)) {
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
play_sound(NA_SE_SY_START_SHOT);
Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_GOAL | SEQ_FLAG_ASYNC);
this->timer = 55;
SET_EVENTINF(EVENTINF_11);
this->actionFunc = EnMttag_RaceFinish;
} else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) {
gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6;
play_sound(NA_SE_SY_START_SHOT);
Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_GORON_GOAL | SEQ_FLAG_ASYNC);
this->timer = 55;
SET_EVENTINF(EVENTINF_12);
this->actionFunc = EnMttag_RaceFinish;
+5 -5
View File
@@ -292,7 +292,7 @@ void func_8095ABA8(EnOwl* this) {
void func_8095ABF0(EnOwl* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
Audio_QueueSeqCmd(0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
func_8095AAD0(this, play);
this->actor.flags &= ~ACTOR_FLAG_10000;
}
@@ -301,7 +301,7 @@ void func_8095ABF0(EnOwl* this, PlayState* play) {
// Unused?
void func_8095AC50(EnOwl* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
Audio_QueueSeqCmd(0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
if ((this->unk_3DA % 64) == 0) {
func_8095AAD0(this, play);
} else {
@@ -665,7 +665,7 @@ void func_8095BA84(EnOwl* this, PlayState* play) {
case 0xBEE:
Message_CloseTextbox(play);
Audio_QueueSeqCmd(0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
EnOwl_ChangeMode(this, func_8095B9FC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94,
0.0f);
this->eyeTexIndex = 0;
@@ -681,7 +681,7 @@ void func_8095BA84(EnOwl* this, PlayState* play) {
case 0xBEF:
case 0xBF3:
Message_CloseTextbox(play);
Audio_QueueSeqCmd(0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
func_8095ACEC(this);
this->actor.flags &= ~ACTOR_FLAG_10000;
this->actor.textId = 0xBF0;
@@ -694,7 +694,7 @@ void func_8095BA84(EnOwl* this, PlayState* play) {
case 0xBF5:
Message_CloseTextbox(play);
Audio_QueueSeqCmd(0x110000FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0);
this->actor.flags &= ~ACTOR_FLAG_10000;
EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94,
0.0f);
@@ -586,7 +586,7 @@ void EnRacedog_CheckForFinish(EnRacedog* this) {
this->raceStatus == RACEDOG_RACE_STATUS_AFTER_POINT_11) {
sNumberOfDogsFinished++;
if (sNumberOfDogsFinished == 1) {
Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_HORSE_GOAL | SEQ_FLAG_ASYNC);
play_sound(NA_SE_SY_START_SHOT);
}
@@ -1173,7 +1173,7 @@ void func_80BAD230(EnSuttari* this, PlayState* play) {
this->textId = 0x2A31;
Message_StartTextbox(play, this->textId, &this->actor);
this->flags1 |= 0x4000;
Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CHASE | SEQ_FLAG_ASYNC);
this->actionFunc = func_80BAD380;
} else {
ActorCutscene_SetIntentToPlay(this->cutscenes[1]);
@@ -1234,7 +1234,7 @@ void func_80BAD380(EnSuttari* this, PlayState* play) {
SET_WEEKEVENTREG(WEEKEVENTREG_33_08);
}
this->actor.speed = 0.0f;
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
this->flags2 |= 4;
EnSuttari_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7));
} else {
@@ -1465,7 +1465,7 @@ void EnSuttari_Destroy(Actor* thisx, PlayState* play) {
EnSuttari* this = THIS;
if ((play->sceneId == SCENE_BACKTOWN) && !(this->flags2 & 4)) {
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
}
Collider_DestroyCylinder(play, &this->collider);
}
@@ -404,7 +404,7 @@ void EnSyatekiMan_Swamp_HandleNormalMessage(EnSyatekiMan* this, PlayState* play)
func_80123F2C(play, 80);
this->shootingGameState = SG_GAME_STATE_RUNNING;
this->actionFunc = EnSyatekiMan_Swamp_StartGame;
func_801A2BB8(NA_BGM_TIMED_MINI_GAME);
Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME);
break;
case 0xA32: // You have to try harder!
@@ -762,7 +762,7 @@ void EnSyatekiMan_Town_HandleNormalMessage(EnSyatekiMan* this, PlayState* play)
Interface_InitMinigame(play);
func_80123F2C(play, 0x63);
this->shootingGameState = SG_GAME_STATE_RUNNING;
func_801A2BB8(NA_BGM_TIMED_MINI_GAME);
Audio_PlaySubBgm(NA_BGM_TIMED_MINI_GAME);
this->actionFunc = EnSyatekiMan_Town_StartGame;
break;
@@ -1078,7 +1078,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) {
this->currentWave = 0;
player->stateFlags1 |= PLAYER_STATE1_20;
sHasSpawnedGuaysForThisWave = false;
func_801A2C20();
Audio_StopSubBgm();
this->actionFunc = EnSyatekiMan_Swamp_EndGame;
} else if ((this->currentWave == 4) && (this->wolfosFlags == 0) &&
(this->perGameVar2.bonusDekuScrubHitCounter == 2)) {
@@ -1087,7 +1087,7 @@ void EnSyatekiMan_Swamp_RunGame(EnSyatekiMan* this, PlayState* play) {
this->currentWave = 0;
player->stateFlags1 |= PLAYER_STATE1_20;
sHasSpawnedGuaysForThisWave = false;
func_801A2C20();
Audio_StopSubBgm();
this->shootingGameState = SG_GAME_STATE_GIVING_BONUS;
if (this->score == 2120) {
Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_2);
@@ -1355,7 +1355,7 @@ void EnSyatekiMan_Town_RunGame(EnSyatekiMan* this, PlayState* play) {
player->stateFlags1 |= PLAYER_STATE1_20;
sModFromLosingTime = 0;
this->actor.draw = EnSyatekiMan_Draw;
func_801A2C20();
Audio_StopSubBgm();
this->actionFunc = EnSyatekiMan_Town_EndGame;
if (this->score == 50) {
Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900);
@@ -773,7 +773,7 @@ s32 func_80A3FBE8(EnTest3* this, PlayState* play) {
if (play->actorCtx.flags & ACTORCTX_FLAG_5) {
this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->unk_D8D);
}
Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
D_80A41D20 = 2;
} else {
func_80A3F73C(this, play);
@@ -806,7 +806,7 @@ void func_80A92188(EnTest6* this, PlayState* play) {
(CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) {
this->unk_286 = 1;
this->unk_27A = 39;
Audio_QueueSeqCmd(0x111400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 20);
}
if (DECR(this->unk_27A) == 0) {
+1 -1
View File
@@ -472,7 +472,7 @@ void EnZod_SetupRehearse(EnZod* this, PlayState* play) {
this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene);
ActorCutscene_SetIntentToPlay(this->actor.cutscene);
gSaveContext.save.weekEventReg[79] |= 1;
Audio_QueueSeqCmd(NA_BGM_INDIGO_GO_SESSION | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_INDIGO_GO_SESSION | SEQ_FLAG_ASYNC);
}
}
+1 -1
View File
@@ -429,7 +429,7 @@ void func_80BD1DB8(EnZov* this, PlayState* play) {
SET_WEEKEVENTREG(WEEKEVENTREG_78_01);
this->actionFunc = func_80BD1D94;
play->msgCtx.msgLength = 0;
Audio_QueueSeqCmd(0x101400FF);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20);
break;
default:
@@ -60,8 +60,8 @@ void ObjDemo_Init(Actor* thisx, PlayState* play) {
}
void func_80983634(PlayState* play) {
if ((play->sceneId == SCENE_CASTLE) && (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) {
Audio_QueueSeqCmd(0x100100FF);
if ((play->sceneId == SCENE_CASTLE) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_IKANA_CASTLE)) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1);
}
}
@@ -89,7 +89,7 @@ void func_80983704(ObjDemo* this, PlayState* play) {
ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor);
}
if (play->sceneId == SCENE_CASTLE) {
Audio_QueueSeqCmd(NA_BGM_IKANA_CASTLE | 0x8000);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_IKANA_CASTLE | SEQ_FLAG_ASYNC);
}
this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene);
if (this->actor.cutscene == -1) {
@@ -232,7 +232,7 @@ void func_80BA28DC(ObjNozoki* this, PlayState* play) {
} else if (ActorCutscene_GetCurrentIndex() != this->unk_15F) {
this->unk_15F = cs;
this->dyna.actor.params &= ~OBJNOZOKI_400;
Audio_QueueSeqCmd(0x881A);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_ENEMY | 0x800 | SEQ_FLAG_ASYNC);
}
return;
}
+1 -1
View File
@@ -222,7 +222,7 @@ s32 ObjUm_InitBandits(ObjUm* this, PlayState* play) {
EnHorse* bandit2;
spawnPoints = Lib_SegmentedToVirtual(path->points);
Audio_QueueSeqCmd(0x8000 | NA_BGM_CHASE);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_CHASE | SEQ_FLAG_ASYNC);
bandit1 = (EnHorse*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, spawnPoints[0].x, spawnPoints[0].y,
spawnPoints[0].z, 0, this->dyna.actor.shape.rot.y, 0,
@@ -30,7 +30,7 @@ void MapSelect_LoadGame(MapSelectState* this, u32 entrance, s32 spawn) {
gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE;
gSaveContext.hudVisibilityTimer = 0;
Audio_QueueSeqCmd(NA_BGM_STOP);
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0);
gSaveContext.save.entrance = entrance;
if (spawn != 0) {