diff --git a/include/functions.h b/include/functions.h index bac7712b2c..793ac829be 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2812,7 +2812,6 @@ void AudioOcarina_TerminaWallGenerateNotes(void); void AudioOcarina_PlayLongScarecrowAfterCredits(void); void Audio_Update(void); -// void func_8019E110(void); void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); @@ -2846,10 +2845,10 @@ void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale); // void Audio_PlaySfxForWaterfall(void); // void Audio_StepFreqLerp(void); void func_801A0124(Vec3f* pos, u8 arg1); -void func_801A0184(void); -void func_801A01C4(void); +void Audio_SetBgmVolumeOff(void); +void Audio_SetBgmVolumeOn(void); void func_801A0204(s8 seqId); -void func_801A0238(s32 arg0, s32 arg1); +void Audio_SetMainBgmVolume(u8 targetVolume, u8 volumeFadeTimer); // void Audio_SetGanonsTowerBgmVolumeLevel(void); // void Audio_SetGanonsTowerBgmVolume(void); // void Audio_UpdateRiverSoundVolumes(void); @@ -2879,12 +2878,9 @@ void func_801A1FB4(u8 playerIndex, Vec3f* pos, u16 seqId, f32 maxDist); void func_801A246C(u8 param_1, u8 param_2); void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne); void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne); -// void func_801A27E8(void); -// void func_801A281C(void); -void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -void func_801A2BB8(s32 seqId); -void func_801A2C20(void); -// void func_801A2C44(void); +void Audio_SetSeqTempoAndFreq(u8 seqPlayerIndex, f32 freqTempoScale, u8 duration); +void Audio_PlaySubBgm(u16 seqId); +void Audio_StopSubBgm(void); void Audio_PlaySequenceInCutscene(u16 seqId); void Audio_StopSequenceInCutscene(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); @@ -2895,7 +2891,7 @@ void Audio_RestorePrevBgm(void); void Audio_PlayFanfare(u16 seqId); // void func_801A312C(void); void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); -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 Audio_SetSequenceMode(u8 seqMode); void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); @@ -2925,23 +2921,20 @@ void func_801A41F8(UNK_TYPE arg0); void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 arg0); void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); -// void Audio_ResetRequestedSceneSeqId(void); -// void func_801A44D4(void); s32 func_801A46F8(void); void func_801A4748(Vec3f* pos, u16 sfxId); void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); void Audio_PlayAmbience(u8 ambienceId); void Audio_Init(void); -void func_801A4D00(void); -// void func_801A4D50(void); -// void func_801A4DA4(void); -// void func_801A4DF4(void); -// void func_801A4E64(void); +void Audio_InitSound(void); +void Audio_ResetForAudioHeapStep3(void); +void Audio_ResetForAudioHeapStep2(void); +void Audio_ResetForAudioHeapStep1(s32 specId); // void func_801A4EB0(void); // void func_801A4EB8(void); -// void func_801A4FD8(void); +void func_801A4FD8(void); void func_801A5080(u16 arg0); u16 func_801A5100(void); void func_801A5118(void); @@ -2955,7 +2948,7 @@ UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A54D0(void); // void func_801A5680(void); // void func_801A5808(void); -// void func_801A5A10(void); +void AudioVoice_ResetData(void); // void func_801A5A1C(void); void AudioSfx_MuteBanks(u16 muteMask); @@ -2974,20 +2967,18 @@ void AudioSfx_ProcessActiveSfx(void); u8 AudioSfx_IsPlaying(u32 sfxId); void AudioSfx_Reset(void); -void Audio_StartSequence(u8 playerIndex, u8 seqId, u8 seqArgs, u16 fadeTimer); -void Audio_StopSequence(u8 playerIndex, u16 fadeTimer); -// void func_801A7D84(void); -void Audio_QueueSeqCmd(u32 cmd); -void func_801A89D0(void); -u16 Audio_GetActiveSequence(u8 playerIndex); -s32 func_801A8ABC(u32 cmdVal, u32 cmdMask); -void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); -void func_801A8D5C(void); -// void func_801A8E90(void); -u8 func_801A9768(void); -u8 func_801A982C(void); -// void func_801A99B8(void); -// void func_801A9A74(void); +void AudioSeq_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration); +void AudioSeq_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration); +void AudioSeq_QueueSeqCmd(u32 cmd); +void AudioSeq_ProcessSeqCmds(void); +u16 AudioSeq_GetActiveSeqId(u8 seqPlayerIndex); +s32 AudioSeq_IsSeqCmdNotQueued(u32 cmdVal, u32 cmdMask); +void AudioSeq_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); +void AudioSeq_UpdateActiveSequences(void); +u8 AudioSeq_UpdateAudioHeapReset(void); +u8 AudioSeq_ResetReverb(void); +void AudioSeq_ResetActiveSequences(void); +void AudioSeq_ResetActiveSequencesAndVolume(void); void Regs_InitData(PlayState* play); diff --git a/include/seqcmd.h b/include/seqcmd.h new file mode 100644 index 0000000000..a7db69dadc --- /dev/null +++ b/include/seqcmd.h @@ -0,0 +1,521 @@ +#ifndef SEQCMD_H +#define SEQCMD_H + +// ==== Primary commands ==== + +#define SEQCMD_OP_MASK 0xF0000000 +#define SEQCMD_ASYNC_ACTIVE 0x8000000 +#define SEQCMD_SEQPLAYER_MASK 0x7000000 +#define SEQCMD_SEQID_MASK 0xFF // Only applies to certain seqcmds + +typedef enum { + /* 0x0 */ SEQCMD_OP_PLAY_SEQUENCE, + /* 0x1 */ SEQCMD_OP_STOP_SEQUENCE, + /* 0x2 */ SEQCMD_OP_QUEUE_SEQUENCE, + /* 0x3 */ SEQCMD_OP_UNQUEUE_SEQUENCE, + /* 0x4 */ SEQCMD_OP_SET_SEQPLAYER_VOLUME, + /* 0x5 */ SEQCMD_OP_SET_SEQPLAYER_FREQ, + /* 0x6 */ SEQCMD_OP_SET_CHANNEL_VOLUME, + /* 0x7 */ SEQCMD_OP_SET_SEQPLAYER_IO, + /* 0x8 */ SEQCMD_OP_SET_CHANNEL_IO, + /* 0x9 */ SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK, + /* 0xA */ SEQCMD_OP_SET_CHANNEL_DISABLE_MASK, + /* 0xB */ SEQCMD_OP_TEMPO_CMD, + /* 0xC */ SEQCMD_OP_SETUP_CMD, + /* 0xD */ SEQCMD_OP_SET_CHANNEL_FREQ, + /* 0xE */ SEQCMD_OP_GLOBAL_CMD, + /* 0xF */ SEQCMD_OP_RESET_AUDIO_HEAP +} SeqCmdOp; + +// ==== Secondary commands ==== + +// Subset of `SEQCMD_OP_TEMPO_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_TEMPO_SET, + /* 0x1 */ SEQCMD_SUB_OP_TEMPO_SPEED_UP, + /* 0x2 */ SEQCMD_SUB_OP_TEMPO_SLOW_DOWN, + /* 0x3 */ SEQCMD_SUB_OP_TEMPO_SCALE, + /* 0x4 */ SEQCMD_SUB_OP_TEMPO_RESET +} SeqCmdTempoCmdOp; + +// Subset of `SEQCMD_OP_SETUP_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME, + /* 0x1 */ SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE, + /* 0x2 */ SEQCMD_SUB_OP_SETUP_RESTART_SEQ, + /* 0x3 */ SEQCMD_SUB_OP_SETUP_TEMPO_SCALE, + /* 0x4 */ SEQCMD_SUB_OP_SETUP_TEMPO_RESET, + /* 0x5 */ SEQCMD_SUB_OP_SETUP_PLAY_SEQ, + /* 0x6 */ SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER, + /* 0x7 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED, + /* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX, + /* 0x9 */ SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK, + /* 0xA */ SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ, + /* 0xE */ SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE = 0xE, + /* 0xF */ SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS +} SeqCmdSetupCmdOp; + +// Subset of `SEQCMD_OP_GLOBAL_CMD` +typedef enum { + /* 0x0 */ SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE, + /* 0x1 */ SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES, + /* 0x2 */ SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2 +} SeqCmdSubCmdOp; + +// ==== Audio Sequence Primary Commands ==== + +/** + * Play a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to play the sequence + * @param fadeInDuration effect will depend on seqArg. See below + * @param seqArg no effect: < 0x7F, skip ticks: = 0x7F, play after loading asynchronously: >= 0x80 (see note) + * @param seqId the id of the sequence to play, see `SeqId` + * + * @note seqArg will also be stored in gActiveSeqs.seqId, any check against that seqId must also include seqArg. + * seqArg = 0x7F will interpret the duration as the number of ticks to skip. + * seqArg >= 0x80 load the soundFont asynchronously, will only start playing once loaded. + */ +#define SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_PLAY_SEQUENCE << 28) | ((seqPlayerIndex) << 24) | ((u32)(fadeInDuration) << 16) | \ + (u32)(seqId)) + +/** + * Stop a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to stop the sequence + * @param fadeOutDuration duration the sequence will fade out over + * + * @note the 0xFF in the command is not read from at all, but is common in all Stop SeqPlayer Commands + */ +#define SEQCMD_STOP_SEQUENCE(seqPlayerIndex, fadeOutDuration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_STOP_SEQUENCE << 28) | 0xFF | ((u8)(seqPlayerIndex) << 24) | \ + ((fadeOutDuration) << 16)) + +/** + * Add a sequence to a queue of sequences associated with a given seqPlayer. + * If the sequence is first in queue, play the sequence + * + * @param seqPlayerIndex the index of the seqPlayer to queue the sequence + * @param fadeInDuration if the sequence is played, duration the sequence will fade in over + * @param priority priority in the queue. The highest valued priority will be queued to play first. Also used as `seqArg`. + * @param seqId the id of the sequence to play, see `SeqId` + * + * @note for the next sequence in the queue to play, the current sequence must be unqueued with the unqueue command + * @note for a priority >= 0x7F, similar effects happen as `seqArg` in the play sequence command + */ +#define SEQCMD_QUEUE_SEQUENCE(seqPlayerIndex, fadeInDuration, priority, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_QUEUE_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(fadeInDuration) << 16) | ((u8)(priority) << 8) | (u8)(seqId)) + +/** + * Remove a sequence from a queue of sequences associated with a given seqPlayer. + * If the sequence is first in queue, stop the sequence, and play the next one in queue if any + * + * @param seqPlayerIndex the index of the seqPlayer to queue the sequence + * @param fadeInDuration if the sequence is stopped, duration the sequence will fade out over, and duration the next seq will fade in over + * @param seqId the id of the sequence to remove, see `SeqId` + * + * @note for the next sequence in the queue to play, the current sequence must be unqueued with this command + */ +#define SEQCMD_UNQUEUE_SEQUENCE(seqPlayerIndex, fadeOutInDuration, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_UNQUEUE_SEQUENCE << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u8)(fadeOutInDuration) << 16) | (u32)(seqId)) + +/** + * Set the volume of an entire sequence on a given seqPlayer. Fade to the volume over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + * @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f + */ +#define SEQCMD_SET_SEQPLAYER_VOLUME(seqPlayerIndex, duration, volume) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u32)(duration) << 16) | (volume)) + +/** + * Scale the frequency of every channel on a given seqPlayer over a specified duration. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFFF, with 1000 mapping to 1.0f + * + * @note 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave). + * Cannot be used with `SEQCMD_SET_CHANNEL_FREQ` as they will overwrite one another. + */ +#define SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_FREQ << 28) | (u32)((seqPlayerIndex) << 24) | \ + ((u32)((duration) << 16)) | (u16)(freqScale)) + +/** + * Scale the frequency of a specific channel on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFF, with 1000 mapping to 1.0f + * + * @note a frequency of 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an + * octave). Cannot be used with `SEQCMD_SET_SEQPLAYER_FREQ` as they will overwrite one another. + */ +#define SEQCMD_SET_CHANNEL_FREQ(seqPlayerIndex, channelIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \ + ((channelIndex) << 12) | (freqScale)) + +/** + * Set the volume of a specific channel on a given seqPlayer. Fade to the volume over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param duration duration to transition to the volume + * @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f + */ +#define SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, channelIndex, duration, volume) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_VOLUME << 28) | ((u32)(seqPlayerIndex) << 24) | \ + ((u32)(duration) << 16) | ((u32)(channelIndex) << 8) | (volume)) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the global + * ioPort, which can affect the entire sequence. + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData the value s8 that's written to the input-output array + * + * @note Each seqPlayer has 8 global ioPorts indexed 0-7. + * ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence. + * ioPort 2-7 can be read multiple times. + */ +#define SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_IO << 28) | ((u32)(seqPlayerIndex) << 24) | ((u32)(ioPort) << 16) | \ + (u32)(ioData)) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the channel + * ioPort, which will only affect a single channel. + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param channelIndex the index of the channel to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData the value s8 that's written to the input-output array + * + * @note Each channel has 8 channel ioPorts indexed 0-7. + * ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence. + * ioPort 2-7 can be read multiple times. + */ +#define SEQCMD_SET_CHANNEL_IO(seqPlayerIndex, channelIndex, ioPort, ioData) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO << 28) | ((u32)(seqPlayerIndex) << 24) | ((u32)(ioPort) << 16) | \ + ((u32)(channelIndex) << 8) | (u32)(ioData)) + +/** + * Disable (or reenable) specific channels from receiving input set by `SEQCMD_SET_CHANNEL_IO` + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + * + * @note using Audio_QueueCmdS8 0x06 will bypass this channelMask + */ +#define SEQCMD_SET_CHANNEL_IO_DISABLE_MASK(seqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | \ + (u16)(channelMask)) + +/** + * Disable (or reenable) specific channels + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + */ +#define SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_DISABLE_MASK << 28) | ((u32)(seqPlayerIndex) << 24) | \ + (u32)(channelMask)) + +// ==== Audio Sequence Tempo Commands ==== + +/** + * Set the absolute tempo of a sequence on a given seqPlayer, fading over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoTarget the target tempo for the sequence + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SET_TEMPO(seqPlayerIndex, duration, tempoTarget) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SET << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u8)(tempoTarget)) + +/** + * Increase the tempo of a sequence by a relative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoIncrease the change to add to the current tempo + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SPEED_UP_TEMPO(seqPlayerIndex, duration, tempoIncrease) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SPEED_UP << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoIncrease)) + +/** + * Decrease the tempo of a sequence by a relative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoDecrease the change to subtract to the current tempo + * + * @note the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SLOW_DOWN_TEMPO(seqPlayerIndex, duration, tempoDecrease) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SLOW_DOWN << 12) | \ + ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | (u16)(tempoDecrease)) + +/** + * Scale the tempo of a sequence by a multiplicative value on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoScale the scaling factor of the tempo, relative to 100 + * + * @note a tempoScale of 200 will go double-time, 50 will go half-time. + * the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SCALE_TEMPO(seqPlayerIndex, duration, tempoScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SCALE << 12) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16) | (u16)(tempoScale)) + +/** + * Reset the tempo of a sequence to the original tempo on a given seqPlayer over a specified duration + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + */ +#define SEQCMD_RESET_TEMPO(seqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_RESET << 12) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16)) + +/** + * ==== Audio Sequence Setup Commands ==== + * + * The setup commands are designed to wait to be executed. + * Up to 8 commands can be queued per `seqPlayerIndex`. + * These commands will only execute once that `seqPlayerIndex` is finished playing and is no longer enabled. + * They will often target a different player (`targetSeqPlayerIndex`) but not always. + */ + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration)) + +/** + * Setup a request to unqueue a seqPlayer once that same setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to unqueue once the same seqPlayer is disabled + * + * @bug this command was misimplemented and fails to unqueue. The command relies on `gActiveSeqs.seqId` for + * unqueueing, but seqId is reset before being used to unqueue. A simple fix is to unqueue based on + * `gActiveSeqs.prevSeqId` instead. + */ +#define SEQCMD_SETUP_UNQUEUE_SEQUENCE(setupSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24)) + +/** + * Setup a request to restart and play an active sequence currently playing on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to restart its active sequence + */ +#define SEQCMD_SETUP_RESTART_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTART_SEQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16)) + +/** + * Setup a request to scale the tempo of a sequence by a multiplicative value on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + * @param tempoScale the scaling factor of the tempo, relative to 100 + * + * @note a tempoScale of 200 will go double-time, 50 will go half-time. + * the absolute tempo is constrained to a maximum of 300 + */ +#define SEQCMD_SETUP_SCALE_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, tempoScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_SCALE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(tempoScale)) + +/** + * Setup a request to reset the tempo of a sequence to the original tempo on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the tempo + */ +#define SEQCMD_SETUP_RESET_TEMPO(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_TEMPO_RESET << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration)) + +/** + * Setup a request to play a sequence on a target seqPlayer once a setup seqPlayer is finished playing and disabled. + * This command is optionally paired with `SEQCMD_SETUP_SET_FADE_IN_TIMER` to set the fade in duration + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence + * @param seqId the id of the sequence to play, see `SeqId` + */ +#define SEQCMD_SETUP_PLAY_SEQUENCE(setupSeqPlayerIndex, targetSeqPlayerIndex, seqId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_PLAY_SEQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(seqId)) + +/** + * This command is an optional command before `SEQCMD_SETUP_PLAY_SEQUENCE` to set the fade in duration + * (see cmd above) + * + * @param targetSeqPlayerIndex the index of the seqPlayer to play the sequence + * @param fadeInDuration duration the sequence will fade in over + */ +#define SEQCMD_SETUP_SET_FADE_IN_TIMER(targetSeqPlayerIndex, fadeInDuration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER << 20) | \ + ((u8)(targetSeqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 8)) + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled. + * Specifically, it will only restore volume if the number of queued requests on the setup seqPlayer matches + * the number of sequences queued + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the volume + * @param numSeqRequests the number of sequence requests queued that must match the actual number of sequence requests + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \ + numSeqRequests) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \ + (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(numSeqRequests)) + +/** + * Setup a request to restore a volume on target seqPlayer once a setup seqPlayer is finished playing and disabled. + * Allows `scaleIndex` to be specified. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param scaleIndex the scale index of a seqPlayer + * @param duration duration to transition to the volume + */ +#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, \ + duration) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \ + (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(scaleIndex) << 8) | (u8)(duration)) + +/** + * Setup a request to disable (or reenable) specific channels on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable + */ +#define SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(setupSeqPlayerIndex, targetSeqPlayerIndex, channelMask) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u16)(channelMask)) + +/** + * Queue a request to scale the frequency of an entire sequence on a target seqPlayer + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param targetSeqPlayerIndex the index of the seqPlayer to modify + * @param duration duration to transition to the frequency + * @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFF, with 100 mapping to 1.0f + * + * @note The base value for frequency, 100, is 10 times smaller than other frequency commands. + * 200 will double the frequency (raise an octave), 50 will halve the frequency (lower an octave). + */ +#define SEQCMD_SETUP_SET_SEQPLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \ + ((u8)(duration) << 8) | (u8)(freqScale)) + +/** + * Queue a request to discard audio data by popping an entry from the persistent caches on the audio heap, + * once a setup seqPlayer is finished playing and disabled. + * + * @param setupSeqPlayerIndex the index of the seqPlayer to wait for to be disabled + * @param tableTypeFlag All tables with the flag `(tableTypeFlag & (1 << tableType))` will be discarded. Specifically: + * `(tableTypeFlag & 1)` will discard the `SEQUENCE_TABLE` + * `(tableTypeFlag & 2)` will discard the `FONT_TABLE` + * `(tableTypeFlag & 4)` will discard the `SAMPLE_TABLE` + */ +#define SEQCMD_SETUP_POP_PERSISTENT_CACHE(setupSeqPlayerIndex, tableTypeFlag) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24) | ((u8)tableTypeFlag)) + +/** + * Discard all setup command requests on a seqPlayerIndex by resetting the setup command queue + * + * @param setupSeqPlayerIndex the index of the seqPlayer to disable all setup commands + */ +#define SEQCMD_RESET_SETUP_CMDS(setupSeqPlayerIndex) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS << 20) | \ + ((u8)(setupSeqPlayerIndex) << 24)) + +/** + * ==== Audio Sequence Global Commands ==== + * + * The global commands will apply to the entire audio system and all 4 sequence players + */ + +/** + * Change the sound mode of audio + * + * @param soundMode see the `SoundMode` enum + */ +#define SEQCMD_SET_SOUND_MODE(soundMode) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE << 8) | (soundMode)) + +/** + * Disable (or reenable) new sequences from starting + * + * @param isDisabled true to disable, false to enable + * + * @note this does not disable the sfx player + */ +#define SEQCMD_DISABLE_PLAY_SEQUENCES(isDisabled) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES << 8) | \ + (u16)(isDisabled)) + +#define SEQCMD_DISABLE_PLAY_SEQUENCES_2(isDisabled) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES_2 << 8) | \ + (u16)(isDisabled)) + +/** + * Restart the audio heap with the specified settings + * + * @param fadeReverb bitmask for reverb indices indicating which reverbs to fade leading into audio heap reset + * @param sfxChannelLayout index for different mappings between the 7 banks and the 16 channels + * @param specId index for the audio specifications to set high-level audio parameters + * + * @note: For sfxChannelLayout, There are 4 possible layouts indexed by 0-3. + * However, only index 0 is properly implemented. Other indices lead to bugs and softlocks. + */ +#define SEQCMD_RESET_AUDIO_HEAP(fadeReverb, sfxChannelLayout, specId) \ + AudioSeq_QueueSeqCmd((SEQCMD_OP_RESET_AUDIO_HEAP << 28) | ((u8)(fadeReverb) << 16) | \ + ((u8)(sfxChannelLayout) << 8) | (u8)(specId)) + +#endif diff --git a/include/sequence.h b/include/sequence.h index 857609d4b2..d8a9cd95a4 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -1,8 +1,6 @@ #ifndef SEQUENCE_H #define SEQUENCE_H -#define NA_BGM_STOP 0x100000FF - #define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects #define NA_BGM_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field @@ -133,12 +131,15 @@ #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF +#define SEQ_FLAG_ASYNC 0x8000 + typedef enum { /* 0 */ SEQ_PLAYER_BGM_MAIN, /* 1 */ SEQ_PLAYER_FANFARE, /* 2 */ SEQ_PLAYER_SFX, /* 3 */ SEQ_PLAYER_BGM_SUB, /* 4 */ SEQ_PLAYER_AMBIENCE, + /* 5 */ SEQ_PLAYER_MAX, /* 0xFF */ SEQ_PLAYER_INVALID = 0xFF } SequencePlayerId; @@ -160,6 +161,14 @@ typedef enum { /* 0x7 */ CHANNEL_IO_PORT_7 } ChannelIOPort; +typedef enum { + /* 0 */ VOL_SCALE_INDEX_BGM_MAIN, + /* 1 */ VOL_SCALE_INDEX_FANFARE, + /* 2 */ VOL_SCALE_INDEX_SFX, + /* 3 */ VOL_SCALE_INDEX_BGM_SUB, + /* 4 */ VOL_SCALE_INDEX_MAX +} VolumeScaleIndex; // May be worth using SequencePlayerId instead + typedef enum { /* 0x0 */ AMBIENCE_CHANNEL_STREAM_0, /* 0x1 */ AMBIENCE_CHANNEL_CRITTER_0, @@ -174,7 +183,7 @@ typedef enum { /* 0xD */ AMBIENCE_CHANNEL_SOUND_MODE, /* 0xE */ AMBIENCE_CHANNEL_RAIN, /* 0xF */ AMBIENCE_CHANNEL_LIGHTNING -} AmbienceChannelIndex; // playerIndex = SEQ_PLAYER_AMBIENCE +} AmbienceChannelIndex; // seqPlayerIndex = SEQ_PLAYER_AMBIENCE typedef enum { /* 0x00 */ AMBIENCE_ID_00, @@ -198,7 +207,7 @@ typedef enum { /* 0x12 */ AMBIENCE_ID_12, /* 0x13 */ AMBIENCE_ID_13, /* 0xFF */ AMBIENCE_ID_DISABLED = 0xFF -} AmbienceId; // playerIndex = SEQ_PLAYER_AMBIENCE +} AmbienceId; // seqPlayerIndex = SEQ_PLAYER_AMBIENCE typedef enum { /* 0x00 */ AMBIENCE_STREAM_0, diff --git a/include/variables.h b/include/variables.h index 9ce8d04d57..745c019a89 100644 --- a/include/variables.h +++ b/include/variables.h @@ -995,14 +995,9 @@ extern u8 gSfxChannelLayout; extern Vec3f gSfxDefaultPos; extern f32 gSfxDefaultFreqAndVolScale; extern s8 gSfxDefaultReverb; -// extern UNK_TYPE1 D_801DB4C0; -// extern UNK_TYPE1 D_801DB4C4; -// extern UNK_TYPE1 D_801DB4C8; -// extern UNK_TYPE1 D_801DB4CC; extern u8 gAudioSpecId; -// extern UNK_TYPE1 D_801DB4D8; -// extern UNK_TYPE4 D_801DB4DC; -extern ReverbSettings* gReverbSettingsTable[]; +extern u8 gAudioHeapResetState; +extern ReverbSettings* gReverbSettingsTable[10]; extern AudioSpec gAudioSpecs[21]; // rodata @@ -2669,38 +2664,14 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD5E8; // extern UNK_TYPE1 D_801FD608; // extern UNK_TYPE1 D_801FD610; -// extern UNK_TYPE1 sSfxPlayerBank; -// extern UNK_TYPE1 sSfxItemBank; -// extern UNK_TYPE1 sSfxEnvironmentBank; -// extern UNK_TYPE1 sSfxEnemyBank; -// extern UNK_TYPE1 sSfxSystemBank; -// extern UNK_TYPE1 sSfxOcarinaBank; -// extern UNK_TYPE1 sSfxVoiceBank; -// extern SfxRequest sSfxRequests[0x100]; -// extern UNK_TYPE1 sSfxBankListEnd; -// extern UNK_TYPE1 sSfxBankFreeListStart; -// extern UNK_TYPE1 sSfxBankUnused; extern ActiveSfx gActiveSfx[7][3]; -// extern UNK_TYPE1 sCurSfxPlayerChannelIndex; -// extern UNK_TYPE1 gSfxBankMuted; -// extern UNK_TYPE1 sUnusedBankLerp; -// extern UNK_TYPE1 D_801FFD00; -// extern UNK_TYPE1 D_801FFD34; -// extern UNK_TYPE1 D_801FFD40; -// extern UNK_TYPE1 D_80200000; -// extern UNK_TYPE1 D_80200002; -// extern UNK_TYPE1 D_80200004; -// extern UNK_TYPE1 D_80200008; -// extern UNK_TYPE1 D_8020001E; -// extern UNK_TYPE1 D_802000C9; -// extern UNK_TYPE1 D_802000D4; +extern SeqRequest sSeqRequests[][5]; +extern u8 sNumSeqRequests[5]; +extern u32 sAudioSeqCmds[0xB0]; extern ActiveSequence gActiveSeqs[]; -// extern UNK_TYPE1 D_8020034A; -// extern UNK_TYPE1 D_80200B88; -// extern UNK_TYPE1 D_80200BBA; -// extern UNK_TYPE1 D_80200BCC; -// extern UNK_TYPE1 D_80200BCE; -// extern UNK_TYPE1 D_80200BD0; +extern u8 sResetAudioHeapTimer; +extern u16 sResetAudioHeapFadeReverbVolume; +extern u16 sResetAudioHeapFadeReverbVolumeStep; extern AudioContext gAudioCtx; // at 0x80200C70 extern AudioCustomUpdateFunction gAudioCustomUpdateFunction; extern AudioCustomSeqFunction gAudioCustomSeqFunction; diff --git a/include/z64.h b/include/z64.h index 6e8e72938f..b91333288d 100644 --- a/include/z64.h +++ b/include/z64.h @@ -20,6 +20,7 @@ #include "color.h" #include "ichain.h" #include "sequence.h" +#include "seqcmd.h" #include "sfx.h" #include "message_data_static.h" diff --git a/include/z64audio.h b/include/z64audio.h index ca54d23451..a37760566b 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -11,6 +11,12 @@ #define SEQ_NUM_CHANNELS 16 #define SEQ_IO_VAL_NONE -1 +typedef enum { + /* 0 */ AUDIO_HEAP_RESET_STATE_NONE, + /* 1 */ AUDIO_HEAP_RESET_STATE_RESETTING, + /* 2 */ AUDIO_HEAP_RESET_STATE_RESETTING_ALT // Never set to +} AudioHeapResetState; + typedef enum { /* 0x00 */ AUDIO_CUSTOM_FUNCTION_SEQ_0, /* 0x01 */ AUDIO_CUSTOM_FUNCTION_SEQ_1, @@ -1090,50 +1096,50 @@ typedef struct { } AudioHeapInitSizes; // size = 0xC typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ f32 unk_10; - /* 0x10 */ f32 unk_14; - /* 0x14 */ f32 unk_18; - /* 0x18 */ u16 unk_0C; - /* 0x1A */ u16 unk_1C; -} unk_50_s; // size = 0x1C + /* 0x00 */ f32 volCur; + /* 0x04 */ f32 volTarget; + /* 0x08 */ f32 volStep; + /* 0x0C */ f32 freqScaleCur; + /* 0x10 */ f32 freqScaleTarget; + /* 0x14 */ f32 freqScaleStep; + /* 0x18 */ u16 volTimer; + /* 0x1A */ u16 freqScaleTimer; +} ActiveSequenceChannelData; // size = 0x1C typedef struct { - /* 0x000 */ unk_50_s unk_50[0x10]; + /* 0x000 */ ActiveSequenceChannelData channelData[SEQ_NUM_CHANNELS]; /* 0x1C0 */ f32 volCur; /* 0x1C4 */ f32 volTarget; - /* 0x1C8 */ f32 unk_08; - /* 0x1CC */ u32 unk_14; - /* 0x1D0 */ f32 unk_1C; - /* 0x1D4 */ f32 unk_20; - /* 0x1D8 */ f32 unk_24; - /* 0x1DC */ u32 unk_2C[8]; - /* 0x1FC */ u32 unk_25C; - /* 0x200 */ u16 unk_0C; - /* 0x202 */ u16 unk_18; - /* 0x204 */ u16 unk_28; - /* 0x206 */ u16 unk_250; - /* 0x208 */ u16 unk_252; + /* 0x1C8 */ f32 volStep; + /* 0x1CC */ u32 tempoCmd; + /* 0x1D0 */ f32 tempoCur; + /* 0x1D4 */ f32 tempoTarget; + /* 0x1D8 */ f32 tempoStep; + /* 0x1DC */ u32 setupCmd[8]; // setup commands + /* 0x1FC */ u32 startAsyncSeqCmd; // temporarily stores the seqCmd used in SEQCMD_PLAY_SEQUENCE, to be called again once the font is reloaded in + /* 0x200 */ u16 volTimer; + /* 0x202 */ u16 tempoOriginal; + /* 0x204 */ u16 tempoTimer; + /* 0x206 */ u16 freqScaleChannelFlags; + /* 0x208 */ u16 volChannelFlags; /* 0x20A */ u16 seqId; - /* 0x20C */ u16 unk_256; - /* 0x20E */ u16 unk_258; - /* 0x210 */ u8 unk_260; - /* 0x211 */ u8 unk_261[0x1]; - /* 0x212 */ u8 volScales[0x4]; + /* 0x20C */ u16 prevSeqId; // last seqId played on a player + /* 0x20E */ u16 channelPortMask; + /* 0x210 */ u8 isWaitingForFonts; + /* 0x211 */ u8 fontId; + /* 0x212 */ u8 volScales[VOL_SCALE_INDEX_MAX]; /* 0x216 */ u8 volFadeTimer; /* 0x217 */ u8 fadeVolUpdate; - /* 0x218 */ u8 unk_4C; - /* 0x219 */ u8 unk_4D; - /* 0x21A */ u8 unk_4E; - /* 0x21B */ u8 unk_21B; + /* 0x218 */ u8 setupCmdTimer; + /* 0x219 */ u8 setupCmdNum; // number of setup commands + /* 0x21A */ u8 setupFadeTimer; + /* 0x21B */ u8 isSeqPlayerInit; } ActiveSequence; // size = 0x21C typedef struct { - /* 0x0 */ u8 unk_0; - /* 0x1 */ u8 unk_1; // importance? -} Struct_8016E320; // size = 0x02 + /* 0x0 */ u8 seqId; + /* 0x1 */ u8 priority; +} SeqRequest; // size = 0x02 typedef enum { /* 0 */ BANK_PLAYER, diff --git a/spec b/spec index 8c03e0389f..325fffa4aa 100644 --- a/spec +++ b/spec @@ -622,7 +622,6 @@ beginseg include "build/src/audio/sfx_params.o" include "build/src/audio/sfx.o" include "build/src/audio/sequence.o" - include "build/data/code/sequence.data.o" include "build/data/code/sequence.bss.o" include "build/src/audio/session_config.o" include "build/src/code/jpegutils.o" diff --git a/src/audio/code_8019AF00.c b/src/audio/code_8019AF00.c index 801e2b0768..5af712e993 100644 --- a/src/audio/code_8019AF00.c +++ b/src/audio/code_8019AF00.c @@ -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(); +} diff --git a/src/audio/sequence.c b/src/audio/sequence.c index 613f1ef1d2..7d37a0ae99 100644 --- a/src/audio/sequence.c +++ b/src/audio/sequence.c @@ -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(); +} diff --git a/src/audio/sfx.c b/src/audio/sfx.c index 76597f5f39..537a9f394a 100644 --- a/src/audio/sfx.c +++ b/src/audio/sfx.c @@ -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); } } diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index e09fdd68ca..055b66ed16 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -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") diff --git a/src/code/audio_thread_manager.c b/src/code/audio_thread_manager.c index eca7ddd835..45fbcb87e9 100644 --- a/src/code/audio_thread_manager.c +++ b/src/code/audio_thread_manager.c @@ -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); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index c3e3ecff09..2628658f6f 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -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); } } diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 01eaf2cd8f..4e24eb72e8 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -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; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 5f5440a2f8..cb4a296d4d 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -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; diff --git a/src/code/z_play.c b/src/code/z_play.c index 52146a1218..ea86b2e82e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -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); } } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 1db125af29..1fa3ed54ae 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -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); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 9bb3cdf759..d7fe815538 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -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); } } } diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index a13e18ec12..4dd27f211a 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -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); } } diff --git a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c index f2f7a9ae5d..423c70fc5a 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -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: diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index 2da9566edb..97bc517c9c 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 67c5bc0f00..3aad703de2 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index 5b753ba54e..b0c4102c27 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index d76c39d38c..373608dc43 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -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); } } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 6aaf29cda4..df3beb13b8 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 0d9f668d6b..d2aacf7483 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 2a698528fb..6d3e01952b 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -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) { diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index e650ef6d3c..5e7619cd24 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 183dc152b3..f208ece37a 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -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); } } diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 0cbe49fb9e..8b3ec59564 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -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); } } diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index 6c8ea9fe8c..fca1afc51b 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -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); } diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 35770e38c7..d35e767c0f 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -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); } } diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index 72e0f07572..38fc476107 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -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; } diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index 093fa3c302..69bcf41b36 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -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) { diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c index 89a5327a87..1fc29eafc0 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c index cff2892f45..e772e12fa0 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.c @@ -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; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index fd45820c11..52287f3177 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index a284f240ad..c356a318bf 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -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); } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 150ff9455e..5bffa0d830 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -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); } diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 3ac6d4cdb9..b0c052b5c8 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index 8554505f0d..dadfc5af40 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -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); diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 6f1c5ac543..2b57ecf51c 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -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) { diff --git a/src/overlays/actors/ovl_En_Zod/z_en_zod.c b/src/overlays/actors/ovl_En_Zod/z_en_zod.c index ecfd9387c3..0da7a17bb0 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -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); } } diff --git a/src/overlays/actors/ovl_En_Zov/z_en_zov.c b/src/overlays/actors/ovl_En_Zov/z_en_zov.c index b68827c40e..17c4a9f701 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -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: diff --git a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c index af796da2c8..8af30b3fd6 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -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) { diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index 2307fe2c42..1f42807c23 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -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; } diff --git a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c index 09fab57d6c..f06d13caf9 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -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, diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 183f6b0692..ab34ebffe7 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -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) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9957b36966..8afe297a87 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3857,7 +3857,7 @@ 0x8019E014:("Audio_Update",), 0x8019E0FC:("Audio_Noop4",), 0x8019E104:("Audio_Noop5",), - 0x8019E110:("func_8019E110",), + 0x8019E110:("Audio_PlayMainBgm",), 0x8019E14C:("AudioSfx_ComputeVolume",), 0x8019E324:("AudioSfx_ComputeReverb",), 0x8019E4B0:("AudioSfx_ComputePanSigned",), @@ -3901,10 +3901,10 @@ 0x801A0048:("Audio_PlaySfxForWaterfall",), 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), - 0x801A0184:("func_801A0184",), - 0x801A01C4:("func_801A01C4",), + 0x801A0184:("Audio_SetBgmVolumeOff",), + 0x801A01C4:("Audio_SetBgmVolumeOn",), 0x801A0204:("func_801A0204",), - 0x801A0238:("func_801A0238",), + 0x801A0238:("Audio_SetMainBgmVolume",), 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), 0x801A0450:("Audio_LowerMainBgmVolume",), @@ -3943,12 +3943,12 @@ 0x801A25E4:("Audio_PlaySceneSequence",), 0x801A2670:("Audio_StartSceneSequence",), 0x801A2778:("Audio_UpdateSceneSequenceResumePoint",), - 0x801A27E8:("func_801A27E8",), - 0x801A281C:("func_801A281C",), - 0x801A29D4:("func_801A29D4",), - 0x801A2BB8:("func_801A2BB8",), - 0x801A2C20:("func_801A2C20",), - 0x801A2C44:("func_801A2C44",), + 0x801A27E8:("Audio_PlayBgmForSongOfStorms",), + 0x801A281C:("Audio_ScaleTempoAndFreqForMainBgm",), + 0x801A29D4:("Audio_SetSeqTempoAndFreq",), + 0x801A2BB8:("Audio_PlaySubBgm",), + 0x801A2C20:("Audio_StopSubBgm",), + 0x801A2C44:("Audio_IncreaseTempoForTimedMinigame",), 0x801A2C88:("Audio_PlaySequenceInCutscene",), 0x801A2D54:("Audio_StopSequenceInCutscene",), 0x801A2DE0:("Audio_IsSequencePlaying",), @@ -3994,7 +3994,7 @@ 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), 0x801A44C4:("Audio_ResetRequestedSceneSeqId",), - 0x801A44D4:("func_801A44D4",), + 0x801A44D4:("Audio_ResetData",), 0x801A46F8:("func_801A46F8",), 0x801A4748:("func_801A4748",), 0x801A479C:("func_801A479C",), @@ -4004,11 +4004,11 @@ 0x801A4B80:("Audio_SetAmbienceRandomBend",), 0x801A4C30:("Audio_Init",), 0x801A4C54:("AudioSfx_Init",), - 0x801A4D00:("func_801A4D00",), - 0x801A4D50:("func_801A4D50",), - 0x801A4DA4:("func_801A4DA4",), - 0x801A4DF4:("func_801A4DF4",), - 0x801A4E64:("func_801A4E64",), + 0x801A4D00:("Audio_InitSound",), + 0x801A4D50:("Audio_ResetForAudioHeapStep3",), + 0x801A4DA4:("Audio_ResetForAudioHeapStep2",), + 0x801A4DF4:("Audio_ResetForAudioHeapStep1",), + 0x801A4E64:("Audio_UnusedReset",), 0x801A4EB0:("func_801A4EB0",), 0x801A4EB8:("func_801A4EB8",), 0x801A4FD8:("func_801A4FD8",), @@ -4028,7 +4028,7 @@ 0x801A54D0:("func_801A54D0",), 0x801A5680:("func_801A5680",), 0x801A5808:("func_801A5808",), - 0x801A5A10:("func_801A5A10",), + 0x801A5A10:("AudioVoice_ResetData",), 0x801A5A1C:("func_801A5A1C",), 0x801A5BD0:("AudioSfx_MuteBanks",), 0x801A5C28:("AudioSfx_LowerBgmVolume",), @@ -4052,21 +4052,21 @@ 0x801A787C:("AudioSfx_ProcessActiveSfx",), 0x801A78E4:("AudioSfx_IsPlaying",), 0x801A794C:("AudioSfx_Reset",), - 0x801A7B10:("Audio_StartSequence",), - 0x801A7D04:("Audio_StopSequence",), - 0x801A7D84:("func_801A7D84",), - 0x801A89A8:("Audio_QueueSeqCmd",), - 0x801A89D0:("func_801A89D0",), - 0x801A8A50:("Audio_GetActiveSequence",), - 0x801A8ABC:("func_801A8ABC",), - 0x801A8B14:("func_801A8B14",), - 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("Audio_SetVolumeScale",), - 0x801A8D5C:("func_801A8D5C",), - 0x801A9768:("func_801A9768",), - 0x801A982C:("func_801A982C",), - 0x801A99B8:("func_801A99B8",), - 0x801A9A74:("func_801A9A74",), + 0x801A7B10:("AudioSeq_StartSequence",), + 0x801A7D04:("AudioSeq_StopSequence",), + 0x801A7D84:("AudioSeq_ProcessSeqCmd",), + 0x801A89A8:("AudioSeq_QueueSeqCmd",), + 0x801A89D0:("AudioSeq_ProcessSeqCmds",), + 0x801A8A50:("AudioSeq_GetActiveSeqId",), + 0x801A8ABC:("AudioSeq_IsSeqCmdNotQueued",), + 0x801A8B14:("AudioSeq_ResetSequenceRequests",), + 0x801A8B2C:("AudioSeq_ReplaceSeqCmdSetupOpVolRestore",), + 0x801A8BD0:("AudioSeq_SetVolumeScale",), + 0x801A8D5C:("AudioSeq_UpdateActiveSequences",), + 0x801A9768:("AudioSeq_UpdateAudioHeapReset",), + 0x801A982C:("AudioSeq_ResetReverb",), + 0x801A99B8:("AudioSeq_ResetActiveSequences",), + 0x801A9A74:("AudioSeq_ResetActiveSequencesAndVolume",), 0x801A9B10:("JpegUtils_ProcessQuantizationTable",), 0x801A9B78:("JpegUtils_ParseHuffmanCodesLengths",), 0x801A9BFC:("JpegUtils_GetHuffmanCodes",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index bf6d8e8bb9..aecdd1cc61 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2401,14 +2401,14 @@ 0x801DB4A4:("gSfxDefaultPos","UNK_TYPE4","",0x4), 0x801DB4B0:("gSfxDefaultFreqAndVolScale","UNK_TYPE1","",0x1), 0x801DB4B8:("gSfxDefaultReverb","UNK_TYPE1","",0x1), - 0x801DB4C0:("D_801DB4C0","UNK_TYPE1","",0x1), - 0x801DB4C4:("D_801DB4C4","UNK_TYPE1","",0x1), - 0x801DB4C8:("D_801DB4C8","UNK_TYPE1","",0x1), - 0x801DB4CC:("D_801DB4CC","UNK_TYPE1","",0x1), + 0x801DB4C0:("sSeqCmdWritePos","UNK_TYPE1","",0x1), + 0x801DB4C4:("sSeqCmdReadPos","UNK_TYPE1","",0x1), + 0x801DB4C8:("sStartSeqDisabled","UNK_TYPE1","",0x1), + 0x801DB4CC:("sSoundModeList","UNK_TYPE1","",0x1), 0x801DB4D4:("gAudioSpecId","UNK_TYPE1","",0x1), - 0x801DB4D8:("D_801DB4D8","UNK_TYPE1","",0x1), - 0x801DB4DC:("D_801DB4DC","UNK_TYPE4","",0x4), - 0x801DB4E0:("D_801DB4E0","UNK_TYPE1","",0x1), + 0x801DB4D8:("gAudioHeapResetState","UNK_TYPE1","",0x1), + 0x801DB4DC:("sResetAudioHeapSeqCmd","UNK_TYPE4","",0x4), + 0x801DB4E0:("gReverbSettings","UNK_TYPE1","",0x1), 0x801DB528:("D_801DB528","UNK_TYPE1","",0x1), 0x801DB570:("D_801DB570","UNK_TYPE1","",0x1), 0x801DB5B8:("D_801DB5B8","UNK_TYPE1","",0x1), @@ -4331,9 +4331,9 @@ 0x801FFC80:("sCurSfxPlayerChannelIndex","UNK_TYPE1","",0x1), 0x801FFC84:("gSfxBankMuted","UNK_TYPE1","",0x1), 0x801FFC90:("sUnusedBankLerp","UNK_TYPE1","",0x1), - 0x801FFD00:("D_801FFD00","UNK_TYPE1","",0x1), - 0x801FFD34:("D_801FFD34","UNK_TYPE1","",0x1), - 0x801FFD40:("D_801FFD40","UNK_TYPE1","",0x1), + 0x801FFD00:("sSeqRequests","UNK_TYPE1","",0x1), + 0x801FFD34:("sNumSeqRequests","UNK_TYPE1","",0x1), + 0x801FFD40:("sAudioSeqCmds","UNK_TYPE1","",0x1), 0x80200000:("D_80200000","UNK_TYPE1","",0x1), 0x80200002:("D_80200002","UNK_TYPE1","",0x1), 0x80200004:("D_80200004","UNK_TYPE1","",0x1), @@ -4345,9 +4345,9 @@ 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), - 0x80200BCC:("D_80200BCC","UNK_TYPE1","",0x1), - 0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1), - 0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1), + 0x80200BCC:("sResetAudioHeapTimer","UNK_TYPE1","",0x1), + 0x80200BCE:("sResetAudioHeapFadeReverbVolume","UNK_TYPE1","",0x1), + 0x80200BD0:("sResetAudioHeapFadeReverbVolumeStep","UNK_TYPE1","",0x1), 0x80200C70:("gAudioCtx","AudioContext","",0x81F8), 0x80208E68:("gAudioCustomUpdateFunction","UNK_TYPE4","",0x4), 0x80208E6C:("gAudioCustomSeqFunction","UNK_TYPE4","",0x4), diff --git a/tools/namefixer.py b/tools/namefixer.py index d8c1e8bb23..853322f5ca 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -171,14 +171,19 @@ wordReplace = { "func_800BBA88": "Enemy_StartFinishingBlow", "ShrinkWindow_Step": "ShrinkWindow_Update", "ShrinkWindow_Fini": "ShrinkWindow_Destroy", - "func_801A89A8": "Audio_QueueSeqCmd", + "func_801A89A8": "AudioSeq_QueueSeqCmd", + "Audio_QueueSeqCmd": "AudioSeq_QueueSeqCmd", + "func_801A0238": "Audio_SetMainBgmVolume", + "func_801A2C20": "Audio_StopSubBgm", + "func_801A2BB8": "Audio_PlaySubBgm", "func_8019F1C0": "Audio_PlaySfxAtPos", "func_801A5BD0": "AudioSfx_MuteBanks", "func_801A72CC": "AudioSfx_StopByPos", "Audio_StopSfxByPos": "AudioSfx_StopByPos", "Audio_StopSfxById": "AudioSfx_StopById", "func_801A3098": "Audio_PlayFanfare", - "func_801A8A50": "Audio_GetActiveSequence", + "func_801A8A50": "AudioSeq_GetActiveSeqId", + "Audio_GetActiveSequence": "AudioSeq_GetActiveSeqId", "func_801A2E54": "Audio_PlayBgm_StorePrevBgm", "func_801A2ED8": "Audio_RestorePrevBgm", "func_801A2544": "Audio_PlayMorningSceneSequence", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 2ec163e244..99723cafd7 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3373,7 +3373,7 @@ asm/non_matchings/code/code_8019AF00/Audio_Noop3.s,Audio_Noop3,0x8019E00C,0x2 asm/non_matchings/code/code_8019AF00/Audio_Update.s,Audio_Update,0x8019E014,0x3A asm/non_matchings/code/code_8019AF00/Audio_Noop4.s,Audio_Noop4,0x8019E0FC,0x2 asm/non_matchings/code/code_8019AF00/Audio_Noop5.s,Audio_Noop5,0x8019E104,0x3 -asm/non_matchings/code/code_8019AF00/func_8019E110.s,func_8019E110,0x8019E110,0xF +asm/non_matchings/code/code_8019AF00/Audio_PlayMainBgm.s,Audio_PlayMainBgm,0x8019E110,0xF asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeVolume.s,AudioSfx_ComputeVolume,0x8019E14C,0x76 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputeReverb.s,AudioSfx_ComputeReverb,0x8019E324,0x63 asm/non_matchings/code/code_8019AF00/AudioSfx_ComputePanSigned.s,AudioSfx_ComputePanSigned,0x8019E4B0,0x61 @@ -3417,10 +3417,10 @@ asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiv asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForWaterfall.s,Audio_PlaySfxForWaterfall,0x801A0048,0x29 asm/non_matchings/code/code_8019AF00/Audio_StepFreqLerp.s,Audio_StepFreqLerp,0x801A00EC,0xE asm/non_matchings/code/code_8019AF00/func_801A0124.s,func_801A0124,0x801A0124,0x18 -asm/non_matchings/code/code_8019AF00/func_801A0184.s,func_801A0184,0x801A0184,0x10 -asm/non_matchings/code/code_8019AF00/func_801A01C4.s,func_801A01C4,0x801A01C4,0x10 +asm/non_matchings/code/code_8019AF00/Audio_SetBgmVolumeOff.s,Audio_SetBgmVolumeOff,0x801A0184,0x10 +asm/non_matchings/code/code_8019AF00/Audio_SetBgmVolumeOn.s,Audio_SetBgmVolumeOn,0x801A01C4,0x10 asm/non_matchings/code/code_8019AF00/func_801A0204.s,func_801A0204,0x801A0204,0xD -asm/non_matchings/code/code_8019AF00/func_801A0238.s,func_801A0238,0x801A0238,0xD +asm/non_matchings/code/code_8019AF00/Audio_SetMainBgmVolume.s,Audio_SetMainBgmVolume,0x801A0238,0xD asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolumeLevel.s,Audio_SetGanonsTowerBgmVolumeLevel,0x801A026C,0x2B asm/non_matchings/code/code_8019AF00/Audio_SetGanonsTowerBgmVolume.s,Audio_SetGanonsTowerBgmVolume,0x801A0318,0x4E asm/non_matchings/code/code_8019AF00/Audio_LowerMainBgmVolume.s,Audio_LowerMainBgmVolume,0x801A0450,0x7 @@ -3459,12 +3459,12 @@ asm/non_matchings/code/code_8019AF00/Audio_StartMorningSceneSequence.s,Audio_Sta asm/non_matchings/code/code_8019AF00/Audio_PlaySceneSequence.s,Audio_PlaySceneSequence,0x801A25E4,0x23 asm/non_matchings/code/code_8019AF00/Audio_StartSceneSequence.s,Audio_StartSceneSequence,0x801A2670,0x42 asm/non_matchings/code/code_8019AF00/Audio_UpdateSceneSequenceResumePoint.s,Audio_UpdateSceneSequenceResumePoint,0x801A2778,0x1C -asm/non_matchings/code/code_8019AF00/func_801A27E8.s,func_801A27E8,0x801A27E8,0xD -asm/non_matchings/code/code_8019AF00/func_801A281C.s,func_801A281C,0x801A281C,0x6E -asm/non_matchings/code/code_8019AF00/func_801A29D4.s,func_801A29D4,0x801A29D4,0x79 -asm/non_matchings/code/code_8019AF00/func_801A2BB8.s,func_801A2BB8,0x801A2BB8,0x1A -asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x9 -asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 +asm/non_matchings/code/code_8019AF00/Audio_PlayBgmForSongOfStorms.s,Audio_PlayBgmForSongOfStorms,0x801A27E8,0xD +asm/non_matchings/code/code_8019AF00/Audio_ScaleTempoAndFreqForMainBgm.s,Audio_ScaleTempoAndFreqForMainBgm,0x801A281C,0x6E +asm/non_matchings/code/code_8019AF00/Audio_SetSeqTempoAndFreq.s,Audio_SetSeqTempoAndFreq,0x801A29D4,0x79 +asm/non_matchings/code/code_8019AF00/Audio_PlaySubBgm.s,Audio_PlaySubBgm,0x801A2BB8,0x1A +asm/non_matchings/code/code_8019AF00/Audio_StopSubBgm.s,Audio_StopSubBgm,0x801A2C20,0x9 +asm/non_matchings/code/code_8019AF00/Audio_IncreaseTempoForTimedMinigame.s,Audio_IncreaseTempoForTimedMinigame,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceInCutscene.s,Audio_PlaySequenceInCutscene,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/Audio_StopSequenceInCutscene.s,Audio_StopSequenceInCutscene,0x801A2D54,0x23 asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D @@ -3510,7 +3510,7 @@ asm/non_matchings/code/code_8019AF00/Audio_SetSfxVolumeExceptSystemAndOcarinaBan asm/non_matchings/code/code_8019AF00/func_801A4428.s,func_801A4428,0x801A4428,0x1F asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s,Audio_PreNMI,0x801A44A4,0x8 asm/non_matchings/code/code_8019AF00/Audio_ResetRequestedSceneSeqId.s,Audio_ResetRequestedSceneSeqId,0x801A44C4,0x4 -asm/non_matchings/code/code_8019AF00/func_801A44D4.s,func_801A44D4,0x801A44D4,0x89 +asm/non_matchings/code/code_8019AF00/Audio_ResetData.s,Audio_ResetData,0x801A44D4,0x89 asm/non_matchings/code/code_8019AF00/func_801A46F8.s,func_801A46F8,0x801A46F8,0x14 asm/non_matchings/code/code_8019AF00/func_801A4748.s,func_801A4748,0x801A4748,0x15 asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x10 @@ -3520,11 +3520,11 @@ asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience.s,Audio_PlayAmbience,0x8 asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceRandomBend.s,Audio_SetAmbienceRandomBend,0x801A4B80,0x2C asm/non_matchings/code/code_8019AF00/Audio_Init.s,Audio_Init,0x801A4C30,0x9 asm/non_matchings/code/code_8019AF00/AudioSfx_Init.s,AudioSfx_Init,0x801A4C54,0x2B -asm/non_matchings/code/code_8019AF00/func_801A4D00.s,func_801A4D00,0x801A4D00,0x14 -asm/non_matchings/code/code_8019AF00/func_801A4D50.s,func_801A4D50,0x801A4D50,0x15 -asm/non_matchings/code/code_8019AF00/func_801A4DA4.s,func_801A4DA4,0x801A4DA4,0x14 -asm/non_matchings/code/code_8019AF00/func_801A4DF4.s,func_801A4DF4,0x801A4DF4,0x1C -asm/non_matchings/code/code_8019AF00/func_801A4E64.s,func_801A4E64,0x801A4E64,0x13 +asm/non_matchings/code/code_8019AF00/Audio_InitSound.s,Audio_InitSound,0x801A4D00,0x14 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep3.s,Audio_ResetForAudioHeapStep3,0x801A4D50,0x15 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep2.s,Audio_ResetForAudioHeapStep2,0x801A4DA4,0x14 +asm/non_matchings/code/code_8019AF00/Audio_ResetForAudioHeapStep1.s,Audio_ResetForAudioHeapStep1,0x801A4DF4,0x1C +asm/non_matchings/code/code_8019AF00/Audio_UnusedReset.s,Audio_UnusedReset,0x801A4E64,0x13 asm/non_matchings/code/voice_external/func_801A4EB0.s,func_801A4EB0,0x801A4EB0,0x2 asm/non_matchings/code/voice_external/func_801A4EB8.s,func_801A4EB8,0x801A4EB8,0x48 asm/non_matchings/code/voice_external/func_801A4FD8.s,func_801A4FD8,0x801A4FD8,0x2A @@ -3544,7 +3544,7 @@ asm/non_matchings/code/voice_internal/func_801A54C4.s,func_801A54C4,0x801A54C4,0 asm/non_matchings/code/voice_internal/func_801A54D0.s,func_801A54D0,0x801A54D0,0x6C asm/non_matchings/code/voice_internal/func_801A5680.s,func_801A5680,0x801A5680,0x62 asm/non_matchings/code/voice_internal/func_801A5808.s,func_801A5808,0x801A5808,0x82 -asm/non_matchings/code/voice_internal/func_801A5A10.s,func_801A5A10,0x801A5A10,0x3 +asm/non_matchings/code/voice_internal/AudioVoice_ResetData.s,AudioVoice_ResetData,0x801A5A10,0x3 asm/non_matchings/code/voice_internal/func_801A5A1C.s,func_801A5A1C,0x801A5A1C,0x69 asm/non_matchings/code/code_801A5BD0/AudioSfx_MuteBanks.s,AudioSfx_MuteBanks,0x801A5BD0,0x16 asm/non_matchings/code/code_801A5BD0/AudioSfx_LowerBgmVolume.s,AudioSfx_LowerBgmVolume,0x801A5C28,0x19 @@ -3568,21 +3568,21 @@ asm/non_matchings/code/code_801A5BD0/AudioSfx_StepBankLerp.s,AudioSfx_StepBankLe asm/non_matchings/code/code_801A5BD0/AudioSfx_ProcessActiveSfx.s,AudioSfx_ProcessActiveSfx,0x801A787C,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_IsPlaying.s,AudioSfx_IsPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/AudioSfx_Reset.s,AudioSfx_Reset,0x801A794C,0x71 -asm/non_matchings/code/sequence/Audio_StartSequence.s,Audio_StartSequence,0x801A7B10,0x7D -asm/non_matchings/code/sequence/Audio_StopSequence.s,Audio_StopSequence,0x801A7D04,0x20 -asm/non_matchings/code/sequence/func_801A7D84.s,func_801A7D84,0x801A7D84,0x309 -asm/non_matchings/code/sequence/Audio_QueueSeqCmd.s,Audio_QueueSeqCmd,0x801A89A8,0xA -asm/non_matchings/code/sequence/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 -asm/non_matchings/code/sequence/Audio_GetActiveSequence.s,Audio_GetActiveSequence,0x801A8A50,0x1B -asm/non_matchings/code/sequence/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 -asm/non_matchings/code/sequence/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 -asm/non_matchings/code/sequence/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 -asm/non_matchings/code/sequence/Audio_SetVolumeScale.s,Audio_SetVolumeScale,0x801A8BD0,0x63 -asm/non_matchings/code/sequence/func_801A8D5C.s,func_801A8D5C,0x801A8D5C,0x283 -asm/non_matchings/code/sequence/func_801A9768.s,func_801A9768,0x801A9768,0x31 -asm/non_matchings/code/sequence/func_801A982C.s,func_801A982C,0x801A982C,0x63 -asm/non_matchings/code/sequence/func_801A99B8.s,func_801A99B8,0x801A99B8,0x2F -asm/non_matchings/code/sequence/func_801A9A74.s,func_801A9A74,0x801A9A74,0x27 +asm/non_matchings/code/sequence/AudioSeq_StartSequence.s,AudioSeq_StartSequence,0x801A7B10,0x7D +asm/non_matchings/code/sequence/AudioSeq_StopSequence.s,AudioSeq_StopSequence,0x801A7D04,0x20 +asm/non_matchings/code/sequence/AudioSeq_ProcessSeqCmd.s,AudioSeq_ProcessSeqCmd,0x801A7D84,0x309 +asm/non_matchings/code/sequence/AudioSeq_QueueSeqCmd.s,AudioSeq_QueueSeqCmd,0x801A89A8,0xA +asm/non_matchings/code/sequence/AudioSeq_ProcessSeqCmds.s,AudioSeq_ProcessSeqCmds,0x801A89D0,0x20 +asm/non_matchings/code/sequence/AudioSeq_GetActiveSeqId.s,AudioSeq_GetActiveSeqId,0x801A8A50,0x1B +asm/non_matchings/code/sequence/AudioSeq_IsSeqCmdNotQueued.s,AudioSeq_IsSeqCmdNotQueued,0x801A8ABC,0x16 +asm/non_matchings/code/sequence/AudioSeq_ResetSequenceRequests.s,AudioSeq_ResetSequenceRequests,0x801A8B14,0x6 +asm/non_matchings/code/sequence/AudioSeq_ReplaceSeqCmdSetupOpVolRestore.s,AudioSeq_ReplaceSeqCmdSetupOpVolRestore,0x801A8B2C,0x29 +asm/non_matchings/code/sequence/AudioSeq_SetVolumeScale.s,AudioSeq_SetVolumeScale,0x801A8BD0,0x63 +asm/non_matchings/code/sequence/AudioSeq_UpdateActiveSequences.s,AudioSeq_UpdateActiveSequences,0x801A8D5C,0x283 +asm/non_matchings/code/sequence/AudioSeq_UpdateAudioHeapReset.s,AudioSeq_UpdateAudioHeapReset,0x801A9768,0x31 +asm/non_matchings/code/sequence/AudioSeq_ResetReverb.s,AudioSeq_ResetReverb,0x801A982C,0x63 +asm/non_matchings/code/sequence/AudioSeq_ResetActiveSequences.s,AudioSeq_ResetActiveSequences,0x801A99B8,0x2F +asm/non_matchings/code/sequence/AudioSeq_ResetActiveSequencesAndVolume.s,AudioSeq_ResetActiveSequencesAndVolume,0x801A9A74,0x27 asm/non_matchings/code/jpegutils/JpegUtils_ProcessQuantizationTable.s,JpegUtils_ProcessQuantizationTable,0x801A9B10,0x1A asm/non_matchings/code/jpegutils/JpegUtils_ParseHuffmanCodesLengths.s,JpegUtils_ParseHuffmanCodesLengths,0x801A9B78,0x21 asm/non_matchings/code/jpegutils/JpegUtils_GetHuffmanCodes.s,JpegUtils_GetHuffmanCodes,0x801A9BFC,0x1B