diff --git a/include/functions.h b/include/functions.h index fed4e51a11..0157192e71 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1868,7 +1868,7 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax); void Audio_ClearSariaBgm2(void); void func_800F5510(u16 seqId); void func_800F5550(u16 seqId); -void func_800F574C(f32 arg0, u8 arg2); +void func_800F574C(f32 scaleTempoAndFreq, u8 duration); void func_800F5718(void); void func_800F5918(void); void func_800F595C(u16); @@ -1879,7 +1879,7 @@ void func_800F5B58(void); void func_800F5BF0(u8 natureAmbienceId); void Audio_PlayFanfare(u16); void func_800F5C2C(void); -void func_800F5E18(u8 playerIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4); +void func_800F5E18(u8 seqPlayerIndex, u16 seqId, u8 fadeTimer, s8 ioPort, s8 ioData); void Audio_SetSequenceMode(u8 seqMode); void Audio_SetBgmEnemyVolume(f32 dist); void func_800F6268(f32 dist, u16); @@ -1898,7 +1898,7 @@ void func_800F6AB0(u16); // ? func_800F6BB8(?); void Audio_PreNMI(void); // ? func_800F6C34(?); -void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 port, u8 val); +void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 ioPort, u8 ioData); void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId); void Audio_Init(void); void Audio_InitSound(void); @@ -1915,8 +1915,6 @@ void Audio_StopSfxByBank(u8 bankId); void func_800F8884(u8 bankId, Vec3f* pos); void Audio_StopSfxByPosAndBank(u8 bankId, Vec3f* pos); void Audio_StopSfxByPos(Vec3f* pos); -void func_800F9280(u8 playerIdx, u8 seqId, u8 arg2, u16 fadeTimer); -void Audio_QueueSeqCmd(u32 cmd); void Audio_StopSfxByPosAndId(Vec3f* pos, u16 sfxId); void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId); void Audio_StopSfxById(u32 sfxId); @@ -1924,19 +1922,17 @@ void Audio_ProcessSfxRequests(void); void func_800F8F88(void); u8 Audio_IsSfxPlaying(u32 sfxId); void Audio_ResetSfx(void); -void func_800F9474(u8, u16); -void func_800F94FC(u32); -void Audio_ProcessSeqCmd(u32); +void Audio_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration); +void Audio_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration); +void Audio_QueueSeqCmd(u32 cmd); void Audio_ProcessSeqCmds(void); -u16 func_800FA0B4(u8 playerIdx); -s32 func_800FA11C(u32 arg0, u32 arg1); -void func_800FA174(u8); -void func_800FA18C(u8, u8); -void Audio_SetVolScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); -void func_800FA3DC(void); +u16 Audio_GetActiveSeqId(u8 seqPlayerIndex); +s32 Audio_IsSeqCmdNotQueued(u32 cmdVal, u32 cmdMask); +void Audio_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); +void Audio_UpdateActiveSequences(void); u8 func_800FAD34(void); -void func_800FADF8(void); -void func_800FAEB4(void); +void Audio_ResetActiveSequences(void); +void Audio_ResetActiveSequencesAndVolume(void); void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a); void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y); void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y); diff --git a/include/seqcmd.h b/include/seqcmd.h new file mode 100644 index 0000000000..a2649b775f --- /dev/null +++ b/include/seqcmd.h @@ -0,0 +1,506 @@ +#ifndef SEQCMD_H +#define SEQCMD_H + +// ==== Primary commands ==== + +#define SEQCMD_OP_MASK 0xF0000000 + +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_PLAYER_VOLUME, + /* 0x5 */ SEQCMD_OP_SET_PLAYER_FREQ, + /* 0x6 */ SEQCMD_OP_SET_CHANNEL_VOLUME, + /* 0x7 */ SEQCMD_OP_SET_PLAYER_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_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_VOLUME_IF_QUEUED, + /* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_WITH_SCALE_INDEX, + /* 0x9 */ SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK, + /* 0xA */ SEQCMD_SUB_OP_SETUP_SET_PLAYER_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 +} 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 duration the sequence will fade in over + * @param seqArg no effect: < 0x7F, skip ticks: = 0x7F, will not play: >= 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 was intented to load a soundFont asynchronously but the code is unfinished (based on MM). + */ +#define SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, seqArg, seqId) \ + Audio_QueueSeqCmd((SEQCMD_OP_PLAY_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 16) | \ + ((u8)(seqArg) << 8) | (u16)(seqId)) + +/** + * Stop a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to play 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) \ + Audio_QueueSeqCmd((SEQCMD_OP_STOP_SEQUENCE << 28) | 0xFF | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(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) \ + Audio_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) \ + Audio_QueueSeqCmd((SEQCMD_OP_UNQUEUE_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(fadeOutInDuration) << 16) | (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_PLAYER_VOLUME(seqPlayerIndex, duration, volume) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((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_PLAYER_FREQ(seqPlayerIndex, duration, freqScale) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \ + (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_PLAYER_FREQ` as they will overwrite one another. + */ +#define SEQCMD_SET_CHANNEL_FREQ(seqPlayerIndex, channelIndex, duration, freqScale) \ + Audio_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) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | \ + ((u8)(channelIndex) << 8) | ((u8)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_PLAYER_IO(seqPlayerIndex, ioPort, ioData) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \ + (u8)(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) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \ + ((u8)(channelIndex) << 8) | (u8)(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) \ + Audio_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) \ + Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | (u16)(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) \ + Audio_QueueSeqCmd((SEQCMD_OP_TEMPO_CMD << 28) | (SEQCMD_SUB_OP_TEMPO_SET << 12) | ((u8)(seqPlayerIndex) << 24) | \ + ((u8)(duration) << 16) | (u16)(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) \ + Audio_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) \ + Audio_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) \ + Audio_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) \ + Audio_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_PLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \ + Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_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) \ + Audio_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) \ + Audio_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) \ + Audio_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) \ + Audio_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) \ + Audio_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) \ + Audio_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_PLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \ + numSeqRequests) \ + Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_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_PLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, duration) \ + Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_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) \ + Audio_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_PLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \ + Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_PLAYER_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) \ + Audio_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) \ + Audio_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) \ + Audio_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE << 8) | (u8)(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) \ + Audio_QueueSeqCmd((SEQCMD_OP_GLOBAL_CMD << 28) | (SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES << 8) | \ + (u16)(isDisabled)) + +/** + * Restart the audio heap with the specified settings + * + * @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(sfxChannelLayout, specId) \ + Audio_QueueSeqCmd((SEQCMD_OP_RESET_AUDIO_HEAP << 28) | ((u8)(sfxChannelLayout) << 8) | (u8)(specId)) + +#endif diff --git a/include/sequence.h b/include/sequence.h index 6093b464ad..5f040d1ce9 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -1,121 +1,121 @@ #ifndef SEQUENCE_H #define SEQUENCE_H -#define NA_BGM_STOP 0x100000FF - -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x1 // Environmental nature background sounds -#define NA_BGM_FIELD_LOGIC 0x2 // Hyrule Field -#define NA_BGM_FIELD_INIT 0x3 // Hyrule Field Initial Segment From Loading Area -#define NA_BGM_FIELD_DEFAULT_1 0x4 // Hyrule Field Moving Segment 1 -#define NA_BGM_FIELD_DEFAULT_2 0x5 // Hyrule Field Moving Segment 2 -#define NA_BGM_FIELD_DEFAULT_3 0x6 // Hyrule Field Moving Segment 3 -#define NA_BGM_FIELD_DEFAULT_4 0x7 // Hyrule Field Moving Segment 4 -#define NA_BGM_FIELD_DEFAULT_5 0x8 // Hyrule Field Moving Segment 5 -#define NA_BGM_FIELD_DEFAULT_6 0x9 // Hyrule Field Moving Segment 6 -#define NA_BGM_FIELD_DEFAULT_7 0x0A // Hyrule Field Moving Segment 7 -#define NA_BGM_FIELD_DEFAULT_8 0x0B // Hyrule Field Moving Segment 8 -#define NA_BGM_FIELD_DEFAULT_9 0x0C // Hyrule Field Moving Segment 9 -#define NA_BGM_FIELD_DEFAULT_A 0x0D // Hyrule Field Moving Segment 10 -#define NA_BGM_FIELD_DEFAULT_B 0x0E // Hyrule Field Moving Segment 11 -#define NA_BGM_FIELD_ENEMY_INIT 0x0F // Hyrule Field Enemy Approaches -#define NA_BGM_FIELD_ENEMY_1 0x10 // Hyrule Field Enemy Near Segment 1 -#define NA_BGM_FIELD_ENEMY_2 0x11 // Hyrule Field Enemy Near Segment 2 -#define NA_BGM_FIELD_ENEMY_3 0x12 // Hyrule Field Enemy Near Segment 3 -#define NA_BGM_FIELD_ENEMY_4 0x13 // Hyrule Field Enemy Near Segment 4 -#define NA_BGM_FIELD_STILL_1 0x14 // Hyrule Field Standing Still Segment 1 -#define NA_BGM_FIELD_STILL_2 0x15 // Hyrule Field Standing Still Segment 2 -#define NA_BGM_FIELD_STILL_3 0x16 // Hyrule Field Standing Still Segment 3 -#define NA_BGM_FIELD_STILL_4 0x17 // Hyrule Field Standing Still Segment 4 -#define NA_BGM_DUNGEON 0x18 // Dodongo's Cavern -#define NA_BGM_KAKARIKO_ADULT 0x19 // Kakariko Village (Adult) -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle "NA_BGM_BOSS00" -#define NA_BGM_INSIDE_DEKU_TREE 0x1C // Inside the Deku Tree "NA_BGM_FAIRY_DUNGEON" -#define NA_BGM_MARKET 0x1D // Market -#define NA_BGM_TITLE 0x1E // Title Theme -#define NA_BGM_LINK_HOUSE 0x1F // House -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear -#define NA_BGM_ITEM_GET 0x22 // Obtain Item -#define NA_BGM_OPENING_GANON 0x23 // Enter Ganondorf -#define NA_BGM_HEART_GET 0x24 // Obtain Heart Container -#define NA_BGM_OCA_LIGHT 0x25 // Prelude of Light -#define NA_BGM_JABU_JABU 0x26 // Inside Jabu-Jabu's Belly "NA_BGM_BUYO_DUNGEON" -#define NA_BGM_KAKARIKO_KID 0x27 // Kakariko Village (Child) -#define NA_BGM_GREAT_FAIRY 0x28 // Great Fairy's Fountain "NA_BGM_GODESS" -#define NA_BGM_ZELDA_THEME 0x29 // Zelda's Theme "NA_BGM_HIME" -#define NA_BGM_FIRE_TEMPLE 0x2A // Fire Temple "NA_BGM_FIRE_DUNGEON" -#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Treasure Chest -#define NA_BGM_FOREST_TEMPLE 0x2C // Forest Temple "NA_BGM_FORST_DUNGEON" -#define NA_BGM_COURTYARD 0x2D // Hyrule Castle Courtyard "NA_BGM_HIRAL_GARDEN" -#define NA_BGM_GANON_TOWER 0x2E // Ganondorf's Theme -#define NA_BGM_LONLON 0x2F // Lon Lon Ranch "NA_BGM_RONRON" -#define NA_BGM_GORON_CITY 0x30 // Goron City "NA_BGM_GORON" -#define NA_BGM_FIELD_MORNING 0x31 // Hyrule Field Morning Theme -#define NA_BGM_SPIRITUAL_STONE 0x32 // Spiritual Stone Get "NA_BGM_SPIRIT_STONE" -#define NA_BGM_OCA_BOLERO 0x33 // Bolero of Fire "NA_BGM_OCA_FLAME" -#define NA_BGM_OCA_MINUET 0x34 // Minuet of Forest "NA_BGM_OCA_WIND" -#define NA_BGM_OCA_SERENADE 0x35 // Serenade of Water "NA_BGM_OCA_WATER" -#define NA_BGM_OCA_REQUIEM 0x36 // Requiem of Spirit "NA_BGM_OCA_SOUL" -#define NA_BGM_OCA_NOCTURNE 0x37 // Nocturne of Shadow "NA_BGM_OCA_DARKNESS" -#define NA_BGM_MINI_BOSS 0x38 // Mini-Boss Battle "NA_BGM_MIDDLE_BOSS" -#define NA_BGM_SMALL_ITEM_GET 0x39 // Obtain Small Item "NA_BGM_S_ITEM_GET" -#define NA_BGM_TEMPLE_OF_TIME 0x3A // Temple of Time "NA_BGM_SHRINE_OF_TIME" -#define NA_BGM_EVENT_CLEAR 0x3B // Escape from Lon Lon Ranch -#define NA_BGM_KOKIRI 0x3C // Kokiri Forest -#define NA_BGM_OCA_FAIRY_GET 0x3D // Obtain Fairy Ocarina "NA_BGM_OCA_YOUSEI" -#define NA_BGM_SARIA_THEME 0x3E // Lost Woods "NA_BGM_MAYOIMORI" -#define NA_BGM_SPIRIT_TEMPLE 0x3F // Spirit Temple "NA_BGM_SOUL_DUNGEON" -#define NA_BGM_HORSE 0x40 // Horse Race -#define NA_BGM_HORSE_GOAL 0x41 // Horse Race Goal -#define NA_BGM_INGO 0x42 // Ingo's Theme -#define NA_BGM_MEDALLION_GET 0x43 // Obtain Medallion "NA_BGM_MEDAL_GET" -#define NA_BGM_OCA_SARIA 0x44 // Ocarina Saria's Song -#define NA_BGM_OCA_EPONA 0x45 // Ocarina Epona's Song -#define NA_BGM_OCA_ZELDA 0x46 // Ocarina Zelda's Lullaby -#define NA_BGM_OCA_SUNS 0x47 // Ocarina Sun's Song "NA_BGM_OCA_SUNMOON" -#define NA_BGM_OCA_TIME 0x48 // Ocarina Song of Time -#define NA_BGM_OCA_STORM 0x49 // Ocarina Song of Storms -#define NA_BGM_NAVI_OPENING 0x4A // Fairy Flying "NA_BGM_NAVI" -#define NA_BGM_DEKU_TREE_CS 0x4B // Deku Tree "NA_BGM_DEKUNOKI" -#define NA_BGM_WINDMILL 0x4C // Windmill Hut "NA_BGM_FUSHA" -#define NA_BGM_HYRULE_CS 0x4D // Legend of Hyrule "NA_BGM_HIRAL_DEMO" -#define NA_BGM_MINI_GAME 0x4E // Shooting Gallery -#define NA_BGM_SHEIK 0x4F // Sheik's Theme "NA_BGM_SEAK" -#define NA_BGM_ZORA_DOMAIN 0x50 // Zora's Domain "NA_BGM_ZORA" -#define NA_BGM_APPEAR 0x51 // Enter Zelda -#define NA_BGM_ADULT_LINK 0x52 // Goodbye to Zelda -#define NA_BGM_MASTER_SWORD 0x53 // Master Sword -#define NA_BGM_INTRO_GANON 0x54 -#define NA_BGM_SHOP 0x55 // Shop -#define NA_BGM_CHAMBER_OF_SAGES 0x56 // Chamber of the Sages "NA_BGM_KENJA" -#define NA_BGM_FILE_SELECT 0x57 // File Select -#define NA_BGM_ICE_CAVERN 0x58 // Ice Cavern "NA_BGM_ICE_DUNGEON" -#define NA_BGM_DOOR_OF_TIME 0x59 // Open Door of Temple of Time "NA_BGM_GATE_OPEN" -#define NA_BGM_OWL 0x5A // Kaepora Gaebora's Theme -#define NA_BGM_SHADOW_TEMPLE 0x5B // Shadow Temple "NA_BGM_DARKNESS_DUNGEON" -#define NA_BGM_WATER_TEMPLE 0x5C // Water Temple "NA_BGM_AQUA_DUNGEON" -#define NA_BGM_BRIDGE_TO_GANONS 0x5D // Ganon's Castle Bridge "NA_BGM_BRIDGE" -#define NA_BGM_OCARINA_OF_TIME 0x5E // Ocarina of Time "NA_BGM_SARIA" -#define NA_BGM_GERUDO_VALLEY 0x5F // Gerudo Valley "NA_BGM_GERUDO" -#define NA_BGM_POTION_SHOP 0x60 // Potion Shop "NA_BGM_DRUGSTORE" -#define NA_BGM_KOTAKE_KOUME 0x61 // Kotake & Koume's Theme -#define NA_BGM_ESCAPE 0x62 // Escape from Ganon's Castle -#define NA_BGM_UNDERGROUND 0x63 // Ganon's Castle Under Ground -#define NA_BGM_GANONDORF_BOSS 0x64 // Ganondorf Battle -#define NA_BGM_GANON_BOSS 0x65 // Ganon Battle -#define NA_BGM_END_DEMO 0x66 // Seal of Six Sages -#define NA_BGM_STAFF_1 0x67 // End Credits I -#define NA_BGM_STAFF_2 0x68 // End Credits II -#define NA_BGM_STAFF_3 0x69 // End Credits III -#define NA_BGM_STAFF_4 0x6A // End Credits IV -#define NA_BGM_FIRE_BOSS 0x6B // King Dodongo & Volvagia Boss Battle "NA_BGM_BOSS01" -#define NA_BGM_TIMED_MINI_GAME 0x6C // Mini-Game -#define NA_BGM_CUTSCENE_EFFECTS 0x6D // A small collection of various cutscene sounds -#define NA_BGM_NO_MUSIC 0x7F // No bgm music is played -#define NA_BGM_NATURE_SFX_RAIN 0x80 // Related to rain -#define NA_BGM_DISABLED 0xFFFF +typedef enum { + /* 0x00 */ NA_BGM_GENERAL_SFX, // General Sound Effects + /* 0x01 */ NA_BGM_NATURE_AMBIENCE, // Environmental nature background sounds + /* 0x02 */ NA_BGM_FIELD_LOGIC, // Hyrule Field + /* 0x03 */ NA_BGM_FIELD_INIT, // Hyrule Field Initial Segment From Loading Area + /* 0x04 */ NA_BGM_FIELD_DEFAULT_1, // Hyrule Field Moving Segment 1 + /* 0x05 */ NA_BGM_FIELD_DEFAULT_2, // Hyrule Field Moving Segment 2 + /* 0x06 */ NA_BGM_FIELD_DEFAULT_3, // Hyrule Field Moving Segment 3 + /* 0x07 */ NA_BGM_FIELD_DEFAULT_4, // Hyrule Field Moving Segment 4 + /* 0x08 */ NA_BGM_FIELD_DEFAULT_5, // Hyrule Field Moving Segment 5 + /* 0x09 */ NA_BGM_FIELD_DEFAULT_6, // Hyrule Field Moving Segment 6 + /* 0x0A */ NA_BGM_FIELD_DEFAULT_7, // Hyrule Field Moving Segment 7 + /* 0x0B */ NA_BGM_FIELD_DEFAULT_8, // Hyrule Field Moving Segment 8 + /* 0x0C */ NA_BGM_FIELD_DEFAULT_9, // Hyrule Field Moving Segment 9 + /* 0x0D */ NA_BGM_FIELD_DEFAULT_A, // Hyrule Field Moving Segment 10 + /* 0x0E */ NA_BGM_FIELD_DEFAULT_B, // Hyrule Field Moving Segment 11 + /* 0x0F */ NA_BGM_FIELD_ENEMY_INIT, // Hyrule Field Enemy Approaches + /* 0x10 */ NA_BGM_FIELD_ENEMY_1, // Hyrule Field Enemy Near Segment 1 + /* 0x11 */ NA_BGM_FIELD_ENEMY_2, // Hyrule Field Enemy Near Segment 2 + /* 0x12 */ NA_BGM_FIELD_ENEMY_3, // Hyrule Field Enemy Near Segment 3 + /* 0x13 */ NA_BGM_FIELD_ENEMY_4, // Hyrule Field Enemy Near Segment 4 + /* 0x14 */ NA_BGM_FIELD_STILL_1, // Hyrule Field Standing Still Segment 1 + /* 0x15 */ NA_BGM_FIELD_STILL_2, // Hyrule Field Standing Still Segment 2 + /* 0x16 */ NA_BGM_FIELD_STILL_3, // Hyrule Field Standing Still Segment 3 + /* 0x17 */ NA_BGM_FIELD_STILL_4, // Hyrule Field Standing Still Segment 4 + /* 0x18 */ NA_BGM_DUNGEON, // Dodongo's Cavern + /* 0x19 */ NA_BGM_KAKARIKO_ADULT, // Kakariko Village (Adult) + /* 0x1A */ NA_BGM_ENEMY, // Battle + /* 0x1B */ NA_BGM_BOSS, // Boss Battle "NA_BGM_BOSS00" + /* 0x1C */ NA_BGM_INSIDE_DEKU_TREE, // Inside the Deku Tree "NA_BGM_FAIRY_DUNGEON" + /* 0x1D */ NA_BGM_MARKET, // Market + /* 0x1E */ NA_BGM_TITLE, // Title Theme + /* 0x1F */ NA_BGM_LINK_HOUSE, // House + /* 0x20 */ NA_BGM_GAME_OVER, // Game Over + /* 0x21 */ NA_BGM_BOSS_CLEAR, // Boss Clear + /* 0x22 */ NA_BGM_ITEM_GET, // Obtain Item + /* 0x23 */ NA_BGM_OPENING_GANON, // Enter Ganondorf + /* 0x24 */ NA_BGM_HEART_GET, // Obtain Heart Container + /* 0x25 */ NA_BGM_OCA_LIGHT, // Prelude of Light + /* 0x26 */ NA_BGM_JABU_JABU, // Inside Jabu-Jabu's Belly "NA_BGM_BUYO_DUNGEON" + /* 0x27 */ NA_BGM_KAKARIKO_KID, // Kakariko Village (Child) + /* 0x28 */ NA_BGM_GREAT_FAIRY, // Great Fairy's Fountain "NA_BGM_GODESS" + /* 0x29 */ NA_BGM_ZELDA_THEME, // Zelda's Theme "NA_BGM_HIME" + /* 0x2A */ NA_BGM_FIRE_TEMPLE, // Fire Temple "NA_BGM_FIRE_DUNGEON" + /* 0x2B */ NA_BGM_OPEN_TRE_BOX, // Open Treasure Chest + /* 0x2C */ NA_BGM_FOREST_TEMPLE, // Forest Temple "NA_BGM_FORST_DUNGEON" + /* 0x2D */ NA_BGM_COURTYARD, // Hyrule Castle Courtyard "NA_BGM_HIRAL_GARDEN" + /* 0x2E */ NA_BGM_GANON_TOWER, // Ganondorf's Theme + /* 0x2F */ NA_BGM_LONLON, // Lon Lon Ranch "NA_BGM_RONRON" + /* 0x30 */ NA_BGM_GORON_CITY, // Goron City "NA_BGM_GORON" + /* 0x31 */ NA_BGM_FIELD_MORNING, // Hyrule Field Morning Theme + /* 0x32 */ NA_BGM_SPIRITUAL_STONE, // Spiritual Stone Get "NA_BGM_SPIRIT_STONE" + /* 0x33 */ NA_BGM_OCA_BOLERO, // Bolero of Fire "NA_BGM_OCA_FLAME" + /* 0x34 */ NA_BGM_OCA_MINUET, // Minuet of Forest "NA_BGM_OCA_WIND" + /* 0x35 */ NA_BGM_OCA_SERENADE, // Serenade of Water "NA_BGM_OCA_WATER" + /* 0x36 */ NA_BGM_OCA_REQUIEM, // Requiem of Spirit "NA_BGM_OCA_SOUL" + /* 0x37 */ NA_BGM_OCA_NOCTURNE, // Nocturne of Shadow "NA_BGM_OCA_DARKNESS" + /* 0x38 */ NA_BGM_MINI_BOSS, // Mini-Boss Battle "NA_BGM_MIDDLE_BOSS" + /* 0x39 */ NA_BGM_SMALL_ITEM_GET, // Obtain Small Item "NA_BGM_S_ITEM_GET" + /* 0x3A */ NA_BGM_TEMPLE_OF_TIME, // Temple of Time "NA_BGM_SHRINE_OF_TIME" + /* 0x3B */ NA_BGM_EVENT_CLEAR, // Escape from Lon Lon Ranch + /* 0x3C */ NA_BGM_KOKIRI, // Kokiri Forest + /* 0x3D */ NA_BGM_OCA_FAIRY_GET, // Obtain Fairy Ocarina "NA_BGM_OCA_YOUSEI" + /* 0x3E */ NA_BGM_SARIA_THEME, // Lost Woods "NA_BGM_MAYOIMORI" + /* 0x3F */ NA_BGM_SPIRIT_TEMPLE, // Spirit Temple "NA_BGM_SOUL_DUNGEON" + /* 0x40 */ NA_BGM_HORSE, // Horse Race + /* 0x41 */ NA_BGM_HORSE_GOAL, // Horse Race Goal + /* 0x42 */ NA_BGM_INGO, // Ingo's Theme + /* 0x43 */ NA_BGM_MEDALLION_GET, // Obtain Medallion "NA_BGM_MEDAL_GET" + /* 0x44 */ NA_BGM_OCA_SARIA, // Ocarina Saria's Song + /* 0x45 */ NA_BGM_OCA_EPONA, // Ocarina Epona's Song + /* 0x46 */ NA_BGM_OCA_ZELDA, // Ocarina Zelda's Lullaby + /* 0x47 */ NA_BGM_OCA_SUNS, // Ocarina Sun's Song "NA_BGM_OCA_SUNMOON" + /* 0x48 */ NA_BGM_OCA_TIME, // Ocarina Song of Time + /* 0x49 */ NA_BGM_OCA_STORM, // Ocarina Song of Storms + /* 0x4A */ NA_BGM_NAVI_OPENING, // Fairy Flying "NA_BGM_NAVI" + /* 0x4B */ NA_BGM_DEKU_TREE_CS, // Deku Tree "NA_BGM_DEKUNOKI" + /* 0x4C */ NA_BGM_WINDMILL, // Windmill Hut "NA_BGM_FUSHA" + /* 0x4D */ NA_BGM_HYRULE_CS, // Legend of Hyrule "NA_BGM_HIRAL_DEMO" + /* 0x4E */ NA_BGM_MINI_GAME, // Shooting Gallery + /* 0x4F */ NA_BGM_SHEIK, // Sheik's Theme "NA_BGM_SEAK" + /* 0x50 */ NA_BGM_ZORA_DOMAIN, // Zora's Domain "NA_BGM_ZORA" + /* 0x51 */ NA_BGM_APPEAR, // Enter Zelda + /* 0x52 */ NA_BGM_ADULT_LINK, // Goodbye to Zelda + /* 0x53 */ NA_BGM_MASTER_SWORD, // Master Sword + /* 0x54 */ NA_BGM_INTRO_GANON, + /* 0x55 */ NA_BGM_SHOP, // Shop + /* 0x56 */ NA_BGM_CHAMBER_OF_SAGES, // Chamber of the Sages "NA_BGM_KENJA" + /* 0x57 */ NA_BGM_FILE_SELECT, // File Select + /* 0x58 */ NA_BGM_ICE_CAVERN, // Ice Cavern "NA_BGM_ICE_DUNGEON" + /* 0x59 */ NA_BGM_DOOR_OF_TIME, // Open Door of Temple of Time "NA_BGM_GATE_OPEN" + /* 0x5A */ NA_BGM_OWL, // Kaepora Gaebora's Theme + /* 0x5B */ NA_BGM_SHADOW_TEMPLE, // Shadow Temple "NA_BGM_DARKNESS_DUNGEON" + /* 0x5C */ NA_BGM_WATER_TEMPLE, // Water Temple "NA_BGM_AQUA_DUNGEON" + /* 0x5D */ NA_BGM_BRIDGE_TO_GANONS, // Ganon's Castle Bridge "NA_BGM_BRIDGE" + /* 0x5E */ NA_BGM_OCARINA_OF_TIME, // Ocarina of Time "NA_BGM_SARIA" + /* 0x5F */ NA_BGM_GERUDO_VALLEY, // Gerudo Valley "NA_BGM_GERUDO" + /* 0x60 */ NA_BGM_POTION_SHOP, // Potion Shop "NA_BGM_DRUGSTORE" + /* 0x61 */ NA_BGM_KOTAKE_KOUME, // Kotake & Koume's Theme + /* 0x62 */ NA_BGM_ESCAPE, // Escape from Ganon's Castle + /* 0x63 */ NA_BGM_UNDERGROUND, // Ganon's Castle Under Ground + /* 0x64 */ NA_BGM_GANONDORF_BOSS, // Ganondorf Battle + /* 0x65 */ NA_BGM_GANON_BOSS, // Ganon Battle + /* 0x66 */ NA_BGM_END_DEMO, // Seal of Six Sages + /* 0x67 */ NA_BGM_STAFF_1, // End Credits I + /* 0x68 */ NA_BGM_STAFF_2, // End Credits II + /* 0x69 */ NA_BGM_STAFF_3, // End Credits III + /* 0x6A */ NA_BGM_STAFF_4, // End Credits IV + /* 0x6B */ NA_BGM_FIRE_BOSS, // King Dodongo & Volvagia Boss Battle "NA_BGM_BOSS01" + /* 0x6C */ NA_BGM_TIMED_MINI_GAME, // Mini-Game + /* 0x6D */ NA_BGM_CUTSCENE_EFFECTS, // A small collection of various cutscene sounds + /* 0x7F */ NA_BGM_NO_MUSIC = 0x7F, // No bgm music is played + /* 0x80 */ NA_BGM_NATURE_SFX_RAIN = 0x80, // Related to rain + /* 0xFFFF */ NA_BGM_DISABLED = 0xFFFF +} SeqId; typedef enum { /* 0 */ SEQ_PLAYER_BGM_MAIN, @@ -161,6 +161,53 @@ 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 struct { + /* 0x00 */ f32 volCur; + /* 0x04 */ f32 volTarget; + /* 0x08 */ f32 volStep; + /* 0x0C */ u16 volTimer; + /* 0x10 */ f32 freqScaleCur; + /* 0x14 */ f32 freqScaleTarget; + /* 0x18 */ f32 freqScaleStep; + /* 0x1C */ u16 freqScaleTimer; +} ActiveSequenceChannelData; // size = 0x20 + +typedef struct { + /* 0x000 */ f32 volCur; + /* 0x004 */ f32 volTarget; + /* 0x008 */ f32 volStep; + /* 0x00C */ u16 volTimer; + /* 0x00E */ u8 volScales[VOL_SCALE_INDEX_MAX]; + /* 0x012 */ u8 volFadeTimer; + /* 0x013 */ u8 fadeVolUpdate; + /* 0x014 */ u32 tempoCmd; + /* 0x018 */ u16 tempoOriginal; // stores the original tempo before modifying it (to reset back to) + /* 0x01C */ f32 tempoCur; + /* 0x020 */ f32 tempoTarget; + /* 0x024 */ f32 tempoStep; + /* 0x028 */ u16 tempoTimer; + /* 0x02C */ u32 setupCmd[8]; // a queue of cmds to execute once the player is disabled + /* 0x04C */ u8 setupCmdTimer; // only execute setup commands when the timer is at 0. + /* 0x04D */ u8 setupCmdNum; // number of setup commands requested once the player is disabled + /* 0x04E */ u8 setupFadeTimer; + /* 0x050 */ ActiveSequenceChannelData channelData[16]; + /* 0x250 */ u16 freqScaleChannelFlags; + /* 0x252 */ u16 volChannelFlags; + /* 0x254 */ u16 seqId; // active seqId currently playing. Resets when sequence stops + /* 0x256 */ u16 prevSeqId; // last seqId played on a player. Does not reset when sequence stops + /* 0x258 */ u16 channelPortMask; + /* 0x25C */ u32 startSeqCmd; // This name comes from MM + /* 0x260 */ u8 isWaitingForFonts; // This name comes from MM +} ActiveSequence; // size = 0x264 + typedef enum { /* 0x0 */ NATURE_CHANNEL_STREAM_0, /* 0x1 */ NATURE_CHANNEL_CRITTER_0, @@ -175,7 +222,7 @@ typedef enum { /* 0xD */ NATURE_CHANNEL_UNK, /* 0xE */ NATURE_CHANNEL_RAIN, /* 0xF */ NATURE_CHANNEL_LIGHTNING -} NatureChannelIdx; // playerIdx = 0 (Overlaps with main bgm) +} NatureChannelIndex; // seqPlayerIndex = 0 (Overlaps with main bgm) typedef enum { /* 0x00 */ NATURE_ID_GENERAL_NIGHT, diff --git a/include/variables.h b/include/variables.h index 55ef82ef39..fd6c58c1c3 100644 --- a/include/variables.h +++ b/include/variables.h @@ -150,10 +150,10 @@ extern s8 gSfxDefaultReverb; extern u8 D_801333F0; extern u8 gAudioSfxSwapOff; extern u8 D_801333F8; -extern u8 gSeqCmdWrPos; -extern u8 gSeqCmdRdPos; -extern u8 D_80133408; -extern u8 D_8013340C; +extern u8 gSeqCmdWritePos; +extern u8 gSeqCmdReadPos; +extern u8 gStartSeqDisabled; +extern u8 gAudioDebugPrintSeqCmd; extern u8 gSoundModeList[]; extern u8 gAudioSpecId; extern u8 D_80133418; @@ -217,7 +217,7 @@ extern u8 gSfxBankMuted[]; extern u16 gAudioSfxSwapSource[10]; extern u16 gAudioSfxSwapTarget[10]; extern u8 gAudioSfxSwapMode[10]; -extern unk_D_8016E750 D_8016E750[4]; +extern ActiveSequence gActiveSeqs[4]; extern AudioContext gAudioContext; extern void(*D_801755D0)(void); diff --git a/include/z64.h b/include/z64.h index 2d8e087572..95aaab3584 100644 --- a/include/z64.h +++ b/include/z64.h @@ -27,6 +27,7 @@ #include "z64transition.h" #include "z64interface.h" #include "alignment.h" +#include "seqcmd.h" #include "sequence.h" #include "sfx.h" #include "color.h" diff --git a/include/z64audio.h b/include/z64audio.h index 9d86bdd1bb..759ec1ab79 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -975,43 +975,4 @@ typedef struct { /* 0x08 */ u32 permanentPoolSize; } AudioHeapInitSizes; // size = 0xC -typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ u16 unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ f32 unk_14; - /* 0x18 */ f32 unk_18; - /* 0x1C */ u16 unk_1C; -} unk_50_s; // size = 0x20 - -typedef struct { - /* 0x000 */ f32 volCur; - /* 0x004 */ f32 volTarget; - /* 0x008 */ f32 unk_08; - /* 0x00C */ u16 unk_0C; - /* 0x00E */ u8 volScales[0x4]; - /* 0x012 */ u8 volFadeTimer; - /* 0x013 */ u8 fadeVolUpdate; - /* 0x014 */ u32 unk_14; - /* 0x018 */ u16 unk_18; - /* 0x01C */ f32 unk_1C; - /* 0x020 */ f32 unk_20; - /* 0x024 */ f32 unk_24; - /* 0x028 */ u16 unk_28; - /* 0x02C */ u32 unk_2C[8]; - /* 0x04C */ u8 unk_4C; - /* 0x04D */ u8 unk_4D; - /* 0x04E */ u8 unk_4E; - /* 0x050 */ unk_50_s unk_50[0x10]; - /* 0x250 */ u16 unk_250; - /* 0x252 */ u16 unk_252; - /* 0x254 */ u16 unk_254; - /* 0x256 */ u16 unk_256; - /* 0x258 */ u16 unk_258; - /* 0x25C */ u32 unk_25C; - /* 0x260 */ u8 unk_260; -} unk_D_8016E750; // size = 0x264 - #endif diff --git a/src/code/audio_external_data.c b/src/code/audio_external_data.c index 3dcf0fd1de..6a4c29eda7 100644 --- a/src/code/audio_external_data.c +++ b/src/code/audio_external_data.c @@ -52,10 +52,10 @@ u8 D_801333F8 = 0; s32 D_801333FC = 0; // unused -u8 gSeqCmdWrPos = 0; -u8 gSeqCmdRdPos = 0; -u8 D_80133408 = 0; -u8 D_8013340C = 1; +u8 gSeqCmdWritePos = 0; +u8 gSeqCmdReadPos = 0; +u8 gStartSeqDisabled = false; +u8 gAudioDebugPrintSeqCmd = true; u8 gSoundModeList[] = { SOUNDMODE_STEREO, diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c index db828c39af..c34d00a6bb 100644 --- a/src/code/code_800EC960.c +++ b/src/code/code_800EC960.c @@ -1,27 +1,7 @@ #include "ultra64.h" #include "global.h" -// TODO: can these macros be shared between files? code_800F9280 seems to use -// versions without any casts... -#define Audio_DisableSeq(playerIdx, fadeOut) Audio_QueueCmdS32(0x83000000 | ((u8)playerIdx << 16), fadeOut) -#define Audio_StartSeq(playerIdx, fadeTimer, seqId) \ - Audio_QueueSeqCmd(0x00000000 | ((u8)playerIdx << 24) | ((u8)(fadeTimer) << 0x10) | (u16)seqId) -#define Audio_SeqCmd7(playerIdx, a, b) \ - Audio_QueueSeqCmd(0x70000000 | ((u8)playerIdx << 0x18) | ((u8)a << 0x10) | (u8)(b)) -#define Audio_SeqCmdC(playerIdx, a, b, c) \ - Audio_QueueSeqCmd(0xC0000000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)(c))) -#define Audio_SeqCmdA(playerIdx, a) Audio_QueueSeqCmd(0xA0000000 | ((u8)playerIdx << 24) | ((u16)(a))) -#define Audio_SeqCmd1(playerIdx, a) Audio_QueueSeqCmd(0x100000FF | ((u8)playerIdx << 24) | ((u8)(a) << 16)) -#define Audio_SeqCmdB(playerIdx, a, b, c) \ - Audio_QueueSeqCmd(0xB0000000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c)) -#define Audio_SeqCmdB40(playerIdx, a, b) Audio_QueueSeqCmd(0xB0004000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b)) -#define Audio_SeqCmd6(playerIdx, a, b, c) \ - Audio_QueueSeqCmd(0x60000000 | ((u8)playerIdx << 24) | ((u8)(a) << 16) | ((u8)b << 8) | ((u8)c)) -#define Audio_SeqCmdE0(playerIdx, a) Audio_QueueSeqCmd(0xE0000000 | ((u8)playerIdx << 24) | ((u8)a)) -#define Audio_SeqCmdE01(playerIdx, a) Audio_QueueSeqCmd(0xE0000100 | ((u8)playerIdx << 24) | ((u16)a)) -#define Audio_SeqCmd8(playerIdx, a, b, c) \ - Audio_QueueSeqCmd(0x80000000 | ((u8)playerIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c)) -#define Audio_SeqCmdF(playerIdx, a) Audio_QueueSeqCmd(0xF0000000 | ((u8)playerIdx << 24) | ((u8)a)) +#define Audio_DisableSeq(seqPlayerIndex, fadeOut) Audio_QueueCmdS32(0x83000000 | ((u8)seqPlayerIndex << 16), fadeOut) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) @@ -1768,7 +1748,7 @@ void AudioOcarina_SetInstrument(u8 ocarinaInstrumentId) { return; } - Audio_SeqCmd8(SEQ_PLAYER_SFX, 1, SFX_CHANNEL_OCARINA, ocarinaInstrumentId); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 1, ocarinaInstrumentId); sOcarinaInstrumentId = ocarinaInstrumentId; if (ocarinaInstrumentId == OCARINA_INSTRUMENT_OFF) { sOcarinaInputButtonCur = 0; @@ -3158,7 +3138,7 @@ void AudioDebug_ProcessInput_SndCont(void) { switch (sAudioSndContSel) { case 0: case 1: - Audio_StartSeq(sAudioSndContSel, 0, sAudioSndContWork[sAudioSndContSel]); + SEQCMD_PLAY_SEQUENCE(sAudioSndContSel, 0, 0, sAudioSndContWork[sAudioSndContSel]); break; case 2: case 3: @@ -3170,10 +3150,10 @@ void AudioDebug_ProcessInput_SndCont(void) { func_800F6700(sAudioSndContWork[sAudioSndContSel]); break; case 5: - Audio_SeqCmdE01(SEQ_PLAYER_BGM_MAIN, sAudioSndContWork[sAudioSndContSel]); + SEQCMD_DISABLE_PLAY_SEQUENCES(sAudioSndContWork[sAudioSndContSel]); break; case 6: - Audio_SeqCmdF(SEQ_PLAYER_BGM_MAIN, sAudioSndContWork[sAudioSndContSel]); + SEQCMD_RESET_AUDIO_HEAP(0, sAudioSndContWork[sAudioSndContSel]); sAudioSubTrackInfoSpec = sAudioSndContWork[6]; if (sAudioSubTrackInfoPlayerSel > gAudioSpecs[sAudioSubTrackInfoSpec].numSequencePlayers - 1) { sAudioSubTrackInfoPlayerSel = gAudioSpecs[sAudioSubTrackInfoSpec].numSequencePlayers - 1; @@ -3195,10 +3175,10 @@ void AudioDebug_ProcessInput_SndCont(void) { switch (sAudioSndContSel) { case 0: case 1: - Audio_SeqCmd1(sAudioSndContSel, 0); + SEQCMD_STOP_SEQUENCE(sAudioSndContSel, 0); break; case 7: - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); break; case 2: case 3: @@ -3488,11 +3468,11 @@ void AudioDebug_ProcessInput_BlkChgBgm(void) { if (CHECK_BTN_ANY(sDebugPadPress, BTN_A)) { Audio_QueueCmdS8(MK_CMD(0x46, SEQ_PLAYER_BGM_MAIN, 0x00, 0x00), sAudioBlkChgBgmWork[1]); - Audio_QueueSeqCmd(sAudioBlkChgBgmWork[0] | 0x10000); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1, 0, sAudioBlkChgBgmWork[0]); } if (CHECK_BTN_ANY(sDebugPadPress, BTN_B)) { - Audio_QueueSeqCmd(0x100100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } } @@ -3644,12 +3624,12 @@ void AudioDebug_ProcessInput(void) { case PAGE_NON: if (CHECK_BTN_ANY(sDebugPadPress, BTN_A)) { sAudioSndContWork[5] ^= 1; - Audio_SeqCmdE01(SEQ_PLAYER_BGM_MAIN, sAudioSndContWork[5]); - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) != NA_BGM_NATURE_AMBIENCE) { - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_DISABLE_PLAY_SEQUENCES(sAudioSndContWork[5]); + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_NATURE_AMBIENCE) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0); - Audio_SeqCmd1(SEQ_PLAYER_BGM_SUB, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0); } if (CHECK_BTN_ANY(sDebugPadPress, BTN_B)) { @@ -3691,7 +3671,7 @@ void AudioDebug_ProcessInput(void) { break; } - D_8013340C = sAudioScrPrtWork[10]; + gAudioDebugPrintSeqCmd = sAudioScrPrtWork[10]; } void Audio_UpdateRiverSoundVolumes(void); @@ -3716,7 +3696,7 @@ void func_800F3054(void) { Audio_ProcessSfxRequests(); Audio_ProcessSeqCmds(); func_800F8F88(); - func_800FA3DC(); + Audio_UpdateActiveSequences(); AudioDebug_SetInput(); AudioDebug_ProcessInput(); Audio_ScheduleProcessCmds(); @@ -4094,8 +4074,8 @@ void Audio_ResetSfxChannelState(void) { void Audio_PlayCutsceneEffectsSequence(u8 csEffectType) { if (gSfxBankMuted[0] != 1) { - Audio_StartSeq(SEQ_PLAYER_BGM_SUB, 0, NA_BGM_CUTSCENE_EFFECTS); - Audio_SeqCmd8(SEQ_PLAYER_BGM_SUB, 0, 0, csEffectType); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 0, 0, NA_BGM_CUTSCENE_EFFECTS); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_SUB, 0, 0, csEffectType); } } @@ -4263,17 +4243,17 @@ void Audio_StepFreqLerp(FreqLerp* lerp) { } void func_800F47BC(void) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 1, 0, 10); - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 1, 0, 10); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 10); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 10); } void func_800F47FC(void) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 3); - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 1, 0x7F, 3); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 3); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0x7F, 3); } void func_800F483C(u8 targetVol, u8 volFadeTimer) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 0, targetVol, volFadeTimer); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVol, volFadeTimer); } /** @@ -4315,7 +4295,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol) { if (sGanonsTowerVol != targetVol) { // Sets the volume - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 0, targetVol, 2); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, targetVol, 2); // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is // always set to 0 @@ -4327,7 +4307,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol) { lowPassFilterCutoff = (((targetVol - 0x40) >> 2) + 1) << 4; } // Set lowPassFilterCutoff to io port 4 from channel 15 - Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, 4, 15, lowPassFilterCutoff); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, 15, 4, lowPassFilterCutoff); // Sets the reverb for (channelIdx = 0; channelIdx < 16; channelIdx++) { @@ -4369,14 +4349,14 @@ void Audio_UpdateRiverSoundVolumes(void) { if (sRiverSoundMainBgmLower == true) { if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { // lowers the volume for 1 frame - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 0, sRiverSoundMainBgmVol, 0xA); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, sRiverSoundMainBgmVol, 10); sRiverSoundMainBgmCurrentVol = sRiverSoundMainBgmVol; sRiverSoundMainBgmRestore = true; } sRiverSoundMainBgmLower = false; } else if (sRiverSoundMainBgmRestore == true && D_80130608 == 0) { // restores the volume every frame - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 0xA); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 10); sRiverSoundMainBgmCurrentVol = 0x7F; sRiverSoundMainBgmRestore = false; } @@ -4464,7 +4444,7 @@ void func_800F4E30(Vec3f* pos, f32 arg1) { for (i = 0; i < 0x10; i++) { if (i != 9) { - Audio_SeqCmd6(SEQ_PLAYER_BGM_MAIN, 2, i, (127.0f * phi_f22)); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, i, 2, (127.0f * phi_f22)); Audio_QueueCmdS8(0x3 << 24 | SEQ_PLAYER_BGM_MAIN << 16 | ((u8)((u32)i) << 8), phi_s4); } } @@ -4494,8 +4474,8 @@ void Audio_SplitBgmChannels(s8 volSplit) { u8 channelIdx; u8 i; - if ((func_800FA0B4(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && - (func_800FA0B4(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON)) { + if ((Audio_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && + (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON)) { for (i = 0; i < ARRAY_COUNT(bgmPlayers); i++) { if (i == 0) { // Main Bgm SeqPlayer @@ -4523,7 +4503,7 @@ void Audio_SplitBgmChannels(s8 volSplit) { } } - Audio_SeqCmdA(bgmPlayers[i], channelBits); + SEQCMD_SET_CHANNEL_DISABLE_MASK(bgmPlayers[i], channelBits); } } } @@ -4570,8 +4550,8 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { Audio_SplitBgmChannels(vol); } - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, vol, 0); - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - vol, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, vol, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F - vol, 0); } void Audio_ClearSariaBgm2(void) { @@ -4587,9 +4567,9 @@ void func_800F5550(u16 seqId) { u8 sp27 = 0; u16 nv; - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) != NA_BGM_WINDMILL) { - if (func_800FA0B4(SEQ_PLAYER_BGM_SUB) == NA_BGM_LONLON) { - func_800F9474(SEQ_PLAYER_BGM_SUB, 0); + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_WINDMILL) { + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_LONLON) { + Audio_StopSequence(SEQ_PLAYER_BGM_SUB, 0); Audio_QueueCmdS32(0xF8000000, 0); } @@ -4617,7 +4597,7 @@ void func_800F56A8(void) { u16 temp_v0; u8 bvar; - temp_v0 = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); + temp_v0 = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); bvar = temp_v0 & 0xFF; if ((temp_v0 != NA_BGM_DISABLED) && (sSeqFlags[bvar] & SEQ_FLAG_4)) { if (D_8013062C != 0xC0) { @@ -4629,23 +4609,25 @@ void func_800F56A8(void) { } void func_800F5718(void) { - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) != NA_BGM_WINDMILL) { - Audio_StartSeq(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_WINDMILL); + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_WINDMILL) { + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_WINDMILL); } } -void func_800F574C(f32 arg0, u8 arg2) { - if (arg0 == 1.0f) { - Audio_SeqCmdB40(SEQ_PLAYER_BGM_MAIN, arg2, 0); +void func_800F574C(f32 scaleTempoAndFreq, u8 duration) { + if (scaleTempoAndFreq == 1.0f) { + SEQCMD_RESET_TEMPO(SEQ_PLAYER_BGM_MAIN, duration); } else { - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0x30, arg2, arg0 * 100.0f); + SEQCMD_SETUP_SCALE_TEMPO(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, duration, scaleTempoAndFreq * 100.0f); } - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0xA0, arg2, arg0 * 100.0f); + + SEQCMD_SETUP_SET_PLAYER_FREQ(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, duration, scaleTempoAndFreq * 100.0f); } void func_800F5918(void) { - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) == NA_BGM_TIMED_MINI_GAME && func_800FA11C(0, 0xF0000000)) { - Audio_SeqCmdB(SEQ_PLAYER_BGM_MAIN, 5, 0, 0xD2); + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_TIMED_MINI_GAME && + Audio_IsSeqCmdNotQueued(SEQCMD_OP_PLAY_SEQUENCE << 28, SEQCMD_OP_MASK)) { + SEQCMD_SET_TEMPO(SEQ_PLAYER_BGM_MAIN, 5, 210); } } @@ -4655,11 +4637,11 @@ void func_800F595C(u16 arg0) { if (sSeqFlags[arg0b] & SEQ_FLAG_FANFARE) { Audio_PlayFanfare(arg0); } else if (sSeqFlags[arg0b] & SEQ_FLAG_FANFARE_GANON) { - Audio_StartSeq(SEQ_PLAYER_FANFARE, 0, arg0); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, 0, arg0); } else { func_800F5E18(SEQ_PLAYER_BGM_MAIN, arg0, 0, 7, -1); - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } } @@ -4667,11 +4649,11 @@ void func_800F59E8(u16 arg0) { u8 arg0b = arg0 & 0xFF; if (sSeqFlags[arg0b] & SEQ_FLAG_FANFARE) { - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } else if (sSeqFlags[arg0b] & SEQ_FLAG_FANFARE_GANON) { - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } else { - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } } @@ -4684,7 +4666,7 @@ s32 func_800F5A58(u8 arg0) { phi_a1 = 1; } - if (arg0 == (u8)func_800FA0B4(phi_a1)) { + if (arg0 == (u8)Audio_GetActiveSeqId(phi_a1)) { return 1; } else { return 0; @@ -4696,7 +4678,7 @@ s32 func_800F5A58(u8 arg0) { * Designed for the mini-boss sequence, but also used by mini-game 2 sequence */ void func_800F5ACC(u16 seqId) { - u16 curSeqId = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); + u16 curSeqId = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); if ((curSeqId & 0xFF) != NA_BGM_GANON_TOWER && (curSeqId & 0xFF) != NA_BGM_ESCAPE && curSeqId != seqId) { Audio_SetSequenceMode(SEQ_MODE_IGNORE); @@ -4706,7 +4688,7 @@ void func_800F5ACC(u16 seqId) { osSyncPrintf("Middle Boss BGM Start not stack \n"); } - Audio_StartSeq(SEQ_PLAYER_BGM_MAIN, 0, seqId); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, seqId); } } @@ -4714,12 +4696,12 @@ void func_800F5ACC(u16 seqId) { * Restores the previous sequence to the main bgm player before func_800F5ACC was called */ void func_800F5B58(void) { - if ((func_800FA0B4(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && (sPrevMainBgmSeqId != NA_BGM_DISABLED) && - (sSeqFlags[func_800FA0B4(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { + if ((Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && (sPrevMainBgmSeqId != NA_BGM_DISABLED) && + (sSeqFlags[Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { if (sPrevMainBgmSeqId == NA_BGM_DISABLED) { - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } else { - Audio_StartSeq(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, sPrevMainBgmSeqId); } sPrevMainBgmSeqId = NA_BGM_DISABLED; @@ -4730,7 +4712,7 @@ void func_800F5B58(void) { * Plays the nature ambience sequence on the main bgm player, but stores the previous sequence to return to later */ void func_800F5BF0(u8 natureAmbienceId) { - u16 curSeqId = func_800FA0B4(SEQ_PLAYER_BGM_MAIN); + u16 curSeqId = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); if (curSeqId != NA_BGM_NATURE_AMBIENCE) { sPrevMainBgmSeqId = curSeqId; @@ -4744,7 +4726,7 @@ void func_800F5BF0(u8 natureAmbienceId) { */ void func_800F5C2C(void) { if (sPrevMainBgmSeqId != NA_BGM_DISABLED) { - Audio_StartSeq(SEQ_PLAYER_BGM_MAIN, 0, sPrevMainBgmSeqId); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, sPrevMainBgmSeqId); } sPrevMainBgmSeqId = NA_BGM_DISABLED; } @@ -4755,53 +4737,58 @@ void Audio_PlayFanfare(u16 seqId) { u8* sp1C; u8* sp18; - sp26 = func_800FA0B4(SEQ_PLAYER_FANFARE); + sp26 = Audio_GetActiveSeqId(SEQ_PLAYER_FANFARE); sp1C = func_800E5E84(sp26 & 0xFF, &sp20); sp18 = func_800E5E84(seqId & 0xFF, &sp20); if ((sp26 == NA_BGM_DISABLED) || (*sp1C == *sp18)) { D_8016B9F4 = 1; } else { D_8016B9F4 = 5; - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); } D_8016B9F6 = seqId; } void func_800F5CF8(void) { - u16 sp26; - u16 pad; - u16 sp22; + u16 seqIdFanfare; + u16 seqIdBgmMain; + u16 seqIdBgmSub; if (D_8016B9F4 != 0) { D_8016B9F4--; if (D_8016B9F4 == 0) { Audio_QueueCmdS32(0xE3000000, SEQUENCE_TABLE); Audio_QueueCmdS32(0xE3000000, FONT_TABLE); - func_800FA0B4(SEQ_PLAYER_BGM_MAIN); - sp26 = func_800FA0B4(SEQ_PLAYER_FANFARE); - sp22 = func_800FA0B4(SEQ_PLAYER_BGM_SUB); - if (sp26 == NA_BGM_DISABLED) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 1, 0, 5); - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 1, 0, 5); - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0x80, 1, 0xA); - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0x83, 1, 0xA); - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0x90, 0, 0); - if (sp22 != NA_BGM_LONLON) { - Audio_SeqCmdC(SEQ_PLAYER_FANFARE, 0x93, 0, 0); + + seqIdBgmMain = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN); + seqIdFanfare = Audio_GetActiveSeqId(SEQ_PLAYER_FANFARE); + seqIdBgmSub = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB); + + (void)seqIdBgmMain; // suppresses set but unused warning + if (seqIdFanfare == NA_BGM_DISABLED) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 5); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 5); + SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, + VOL_SCALE_INDEX_FANFARE, 10); + SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB, + VOL_SCALE_INDEX_FANFARE, 10); + SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, 0); + if (seqIdBgmSub != NA_BGM_LONLON) { + SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB, 0); } } - Audio_StartSeq(SEQ_PLAYER_FANFARE, 1, D_8016B9F6); - Audio_SeqCmdA(0, 0xFFFF); - if (sp22 != NA_BGM_LONLON) { - Audio_SeqCmdA(SEQ_PLAYER_BGM_SUB, 0xFFFF); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 1, 0, D_8016B9F6); + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_MAIN, 0xFFFF); + if (seqIdBgmSub != NA_BGM_LONLON) { + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, 0xFFFF); } } } } -void func_800F5E18(u8 playerIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4) { - Audio_SeqCmd7(playerIdx, arg3, arg4); - Audio_StartSeq(playerIdx, fadeTimer, seqId); +void func_800F5E18(u8 seqPlayerIndex, u16 seqId, u8 fadeTimer, s8 ioPort, s8 ioData) { + SEQCMD_SET_PLAYER_IO(seqPlayerIndex, ioPort, ioData); + SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeTimer, 0, seqId); } void Audio_SetSequenceMode(u8 seqMode) { @@ -4815,9 +4802,9 @@ void Audio_SetSequenceMode(u8 seqMode) { seqMode = SEQ_MODE_IGNORE; } - seqId = D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254; + seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; - if (seqId == NA_BGM_FIELD_LOGIC && func_800FA0B4(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { + if (seqId == NA_BGM_FIELD_LOGIC && Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { seqMode = SEQ_MODE_IGNORE; } @@ -4826,29 +4813,33 @@ void Audio_SetSequenceMode(u8 seqMode) { if (seqMode != (sPrevSeqMode & 0x7F)) { if (seqMode == SEQ_MODE_ENEMY) { // Start playing enemy bgm - if (D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol < 0) { - volumeFadeInTimer = -(D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol); + if (gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[VOL_SCALE_INDEX_FANFARE] - sAudioEnemyVol < 0) { + volumeFadeInTimer = + -(gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[VOL_SCALE_INDEX_FANFARE] - sAudioEnemyVol); } else { - volumeFadeInTimer = D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol; + volumeFadeInTimer = + gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[VOL_SCALE_INDEX_FANFARE] - sAudioEnemyVol; } - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, volumeFadeInTimer); - Audio_StartSeq(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sAudioEnemyVol, + volumeFadeInTimer); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10, 8, NA_BGM_ENEMY); if (seqId != NA_BGM_NATURE_AMBIENCE) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sAudioEnemyVol) & 0xFF, 0xA); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, + (0x7F - sAudioEnemyVol) & 0xFF, 0xA); Audio_SplitBgmChannels(sAudioEnemyVol); } } else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) { // Stop playing enemy bgm - Audio_SeqCmd1(SEQ_PLAYER_BGM_SUB, 10); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, 10); if (seqMode == SEQ_MODE_IGNORE) { volumeFadeOutTimer = 0; } else { volumeFadeOutTimer = 10; } - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, volumeFadeOutTimer); Audio_SplitBgmChannels(0); } @@ -4872,7 +4863,7 @@ void Audio_SetSequenceMode(u8 seqMode) { } sPrevSeqMode = seqMode; - Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 2, seqMode); + SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 2, seqMode); } } } @@ -4891,12 +4882,12 @@ void Audio_SetBgmEnemyVolume(f32 dist) { } sAudioEnemyVol = ((350.0f - adjDist) * 127.0f) / 350.0f; - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, 10); - if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sAudioEnemyVol), 10); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_BGM_SUB, sAudioEnemyVol, 10); + if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, (0x7F - sAudioEnemyVol), 10); } } - if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) { + if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) { Audio_SplitBgmChannels(sAudioEnemyVol); } } @@ -4911,7 +4902,7 @@ void func_800F6268(f32 dist, u16 arg1) { sAudioHasMalonBgm = true; sAudioMalonBgmDist = dist; if (D_8016B9F2 == 0) { - temp_a0 = (s8)(func_800FA0B4(SEQ_PLAYER_BGM_MAIN) & 0xFF); + temp_a0 = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF); if (temp_a0 == (arg1 & 0xFF)) { if ((arg1 & 0xFF) == NA_BGM_LONLON) { @@ -4923,18 +4914,18 @@ void func_800F6268(f32 dist, u16 arg1) { phi_v1 = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); } // Transition volume of channels 0, 1 and 13 on seq player 0 over 3 frames - Audio_SeqCmd6(SEQ_PLAYER_BGM_MAIN, 3, 0, 127 - phi_v1); - Audio_SeqCmd6(SEQ_PLAYER_BGM_MAIN, 3, 1, 127 - phi_v1); - Audio_SeqCmd6(SEQ_PLAYER_BGM_MAIN, 3, 13, phi_v1); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 0, 3, 127 - phi_v1); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 1, 3, 127 - phi_v1); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, 13, 3, phi_v1); if (D_8016B9D8 == 0) { D_8016B9D8++; } } } else if ((temp_a0 == NA_BGM_NATURE_AMBIENCE) && ((arg1 & 0xFF) == NA_BGM_LONLON)) { - temp_a0 = (s8)(func_800FA0B4(SEQ_PLAYER_BGM_SUB) & 0xFF); + temp_a0 = (s8)(Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF); if ((temp_a0 != (arg1 & 0xFF)) && (D_8016B9D8 < 10)) { func_800F5E18(SEQ_PLAYER_BGM_SUB, NA_BGM_LONLON, 0, 0, 0); - Audio_SeqCmdA(SEQ_PLAYER_BGM_SUB, 0xFFFC); + SEQCMD_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_BGM_SUB, 0xFFFC); D_8016B9D8 = 10; } @@ -4946,8 +4937,8 @@ void func_800F6268(f32 dist, u16 arg1) { phi_v1 = (s8)(((dist - 200.0f) * 127.0f) / 1800.0f); } // Transition volume of channels 0 and 1 on seq player 0 over 3 frames - Audio_SeqCmd6(SEQ_PLAYER_BGM_SUB, 3, 0, 127 - phi_v1); - Audio_SeqCmd6(SEQ_PLAYER_BGM_SUB, 3, 1, 127 - phi_v1); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 0, 3, 127 - phi_v1); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_SUB, 1, 3, 127 - phi_v1); } if (D_8016B9D8 < 10) { @@ -4970,34 +4961,34 @@ void func_800F64E0(u8 arg0) { } void func_800F6584(u8 arg0) { - u8 playerIdx; + u8 seqPlayerIndex; u16 sp34; D_8016B9F2 = arg0; - if ((func_800FA0B4(SEQ_PLAYER_BGM_MAIN) & 0xFF) == NA_BGM_LONLON) { - playerIdx = SEQ_PLAYER_BGM_MAIN; + if ((Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF) == NA_BGM_LONLON) { + seqPlayerIndex = SEQ_PLAYER_BGM_MAIN; sp34 = 0; - } else if ((func_800FA0B4(SEQ_PLAYER_BGM_SUB) & 0xFF) == NA_BGM_LONLON) { - playerIdx = SEQ_PLAYER_BGM_SUB; + } else if ((Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) & 0xFF) == NA_BGM_LONLON) { + seqPlayerIndex = SEQ_PLAYER_BGM_SUB; sp34 = 0xFFFC; } else { return; } if (arg0 != 0) { - Audio_SeqCmd6(playerIdx, 1, 0, 0); - Audio_SeqCmd6(playerIdx, 1, 1, 0); - if (playerIdx == SEQ_PLAYER_BGM_SUB) { - Audio_SeqCmdA(playerIdx, sp34 | 3); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0); + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, sp34 | 3); } } else { - if (playerIdx == SEQ_PLAYER_BGM_SUB) { + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { func_800F5E18(SEQ_PLAYER_BGM_SUB, NA_BGM_LONLON, 0, 0, 0); } - Audio_SeqCmd6(playerIdx, 1, 0, 0x7F); - Audio_SeqCmd6(playerIdx, 1, 1, 0x7F); - if (playerIdx == SEQ_PLAYER_BGM_SUB) { - Audio_SeqCmdA(playerIdx, sp34); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 0, 1, 0x7F); + SEQCMD_SET_CHANNEL_VOLUME(seqPlayerIndex, 1, 1, 0x7F); + if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) { + SEQCMD_SET_CHANNEL_DISABLE_MASK(seqPlayerIndex, sp34); } } } @@ -5037,7 +5028,7 @@ void func_800F6700(s8 audioSetting) { break; } - Audio_SeqCmdE0(SEQ_PLAYER_BGM_MAIN, soundModeIndex); + SEQCMD_SET_SOUND_MODE(soundModeIndex); } void Audio_SetBaseFilter(u8 filter) { @@ -5059,7 +5050,7 @@ void Audio_SetExtraFilter(u8 filter) { sAudioExtraFilter2 = filter; sAudioExtraFilter = filter; - if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 == NA_BGM_NATURE_AMBIENCE) { + if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId == NA_BGM_NATURE_AMBIENCE) { for (i = 0; i < 16; i++) { t = i; // CHAN_UPD_SCRIPT_IO (seq player 0, all channels, slot 6) @@ -5087,8 +5078,8 @@ void func_800F6964(u16 arg0) { s32 skip; u8 channelIdx; - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, (arg0 * 3) / 2); - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, (arg0 * 3) / 2); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, (arg0 * 3) / 2); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, (arg0 * 3) / 2); for (channelIdx = 0; channelIdx < 16; channelIdx++) { skip = false; switch (channelIdx) { @@ -5104,23 +5095,23 @@ void func_800F6964(u16 arg0) { } if (!skip) { - Audio_SeqCmd6(SEQ_PLAYER_SFX, arg0 >> 1, channelIdx, 0); + SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_SFX, channelIdx, arg0 >> 1, 0); } } - Audio_SeqCmd1(SEQ_PLAYER_BGM_SUB, (arg0 * 3) / 2); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, (arg0 * 3) / 2); } void func_800F6AB0(u16 arg0) { - Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, arg0); - Audio_SeqCmd1(SEQ_PLAYER_FANFARE, arg0); - Audio_SeqCmd1(SEQ_PLAYER_BGM_SUB, arg0); - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0); - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, arg0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, arg0); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_SUB, arg0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0x7F, 0); } void func_800F6B3C(void) { - func_800F9280(SEQ_PLAYER_SFX, 0, 0xFF, 5); + Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0xFF, 5); } void Audio_DisableAllSeq(void) { @@ -5179,19 +5170,20 @@ void func_800F6C34(void) { D_8016B9F2 = 0; } -void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 port, u8 val) { +void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 ioPort, u8 ioData) { u8 firstChannelIdx; u8 lastChannelIdx; u8 channelIdx; - if ((D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) && func_800FA11C(1, 0xF00000FF)) { + if ((gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId != NA_BGM_NATURE_AMBIENCE) && + Audio_IsSeqCmdNotQueued(SEQCMD_OP_PLAY_SEQUENCE << 28 | NA_BGM_NATURE_AMBIENCE, SEQCMD_OP_MASK | 0xFF)) { sAudioNatureFailed = true; return; } - // channelIdxRange = 01 on port 1 - if (((channelIdxRange << 8) + port) == ((NATURE_CHANNEL_CRITTER_0 << 8) + CHANNEL_IO_PORT_1)) { - if (func_800FA0B4(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON) { + // channelIdxRange = 01 on ioPort 1 + if (((channelIdxRange << 8) + ioPort) == ((NATURE_CHANNEL_CRITTER_0 << 8) + CHANNEL_IO_PORT_1)) { + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON) { D_8016B9D8 = 0; } } @@ -5204,38 +5196,38 @@ void Audio_SetNatureAmbienceChannelIO(u8 channelIdxRange, u8 port, u8 val) { } for (channelIdx = firstChannelIdx; channelIdx <= lastChannelIdx; channelIdx++) { - Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, port, channelIdx, val); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, channelIdx, ioPort, ioData); } } void Audio_StartNatureAmbienceSequence(u16 playerIO, u16 channelMask) { u8 channelIdx; - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) == NA_BGM_WINDMILL) { + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_WINDMILL) { Audio_PlayCutsceneEffectsSequence(SEQ_CS_EFFECTS_RAINFALL); return; } - Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 0, 1); - Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 4, playerIO >> 8); - Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 5, playerIO & 0xFF); - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1); + SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 0, 1); + SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, playerIO >> 8); + SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 5, playerIO & 0xFF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 1); channelIdx = false; - if (D_80133408 != 0) { + if (gStartSeqDisabled) { channelIdx = true; - Audio_SeqCmdE01(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_DISABLE_PLAY_SEQUENCES(false); } - Audio_StartSeq(SEQ_PLAYER_BGM_MAIN, 0, NA_BGM_NATURE_AMBIENCE); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_NATURE_AMBIENCE); if (channelIdx) { - Audio_SeqCmdE01(SEQ_PLAYER_BGM_MAIN, 1); + SEQCMD_DISABLE_PLAY_SEQUENCES(true); } for (channelIdx = 0; channelIdx < 16; channelIdx++) { if (!(channelMask & (1 << channelIdx)) && (playerIO & (1 << channelIdx))) { - Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_1, channelIdx, 1); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, channelIdx, CHANNEL_IO_PORT_1, 1); } } } @@ -5243,24 +5235,23 @@ void Audio_StartNatureAmbienceSequence(u16 playerIO, u16 channelMask) { void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId) { u8 i = 0; u8 channelIdx; - u8 port; - u8 val; + u8 ioPort; + u8 ioData; - if (!((D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_DISABLED) && - (sSeqFlags[((u8)D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254) & 0xFF] & SEQ_FLAG_NO_AMBIENCE))) { + if ((gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId == NA_BGM_DISABLED) || + !(sSeqFlags[((u8)gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId) & 0xFF] & SEQ_FLAG_NO_AMBIENCE)) { Audio_StartNatureAmbienceSequence(sNatureAmbienceDataIO[natureAmbienceId].playerIO, sNatureAmbienceDataIO[natureAmbienceId].channelMask); while ((sNatureAmbienceDataIO[natureAmbienceId].channelIO[i] != 0xFF) && (i < 100)) { - // Probably a fake match, using Audio_SeqCmd8 doesn't work. channelIdx = sNatureAmbienceDataIO[natureAmbienceId].channelIO[i++]; - port = sNatureAmbienceDataIO[natureAmbienceId].channelIO[i++]; - val = sNatureAmbienceDataIO[natureAmbienceId].channelIO[i++]; - Audio_QueueSeqCmd(0x80000000 | (SEQ_PLAYER_BGM_MAIN << 24) | (port << 0x10) | (channelIdx << 8) | val); + ioPort = sNatureAmbienceDataIO[natureAmbienceId].channelIO[i++]; + ioData = sNatureAmbienceDataIO[natureAmbienceId].channelIO[i++]; + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, channelIdx, ioPort, ioData); } - Audio_SeqCmd8(SEQ_PLAYER_BGM_MAIN, CHANNEL_IO_PORT_7, NATURE_CHANNEL_UNK, sSoundMode); + SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, NATURE_CHANNEL_UNK, CHANNEL_IO_PORT_7, sSoundMode); } } @@ -5272,13 +5263,13 @@ void Audio_InitSound(void) { func_800F6C34(); AudioOcarina_ResetStaffs(); Audio_ResetSfxChannelState(); - func_800FAEB4(); + Audio_ResetActiveSequencesAndVolume(); Audio_ResetSfx(); - func_800F9280(SEQ_PLAYER_SFX, 0, 0x70, 10); + Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0x70, 10); } void func_800F7170(void) { - func_800F9280(SEQ_PLAYER_SFX, 0, 0x70, 1); + Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0x70, 1); Audio_QueueCmdS32(0xF2000000, 1); Audio_ScheduleProcessCmds(); Audio_QueueCmdS32(0xF8000000, 0); @@ -5289,14 +5280,14 @@ void func_800F71BC(s32 arg0) { func_800F6C34(); AudioOcarina_ResetStaffs(); Audio_ResetSfxChannelState(); - func_800FADF8(); + Audio_ResetActiveSequences(); Audio_ResetSfx(); } void func_800F7208(void) { - func_800FADF8(); + Audio_ResetActiveSequences(); Audio_QueueCmdS32(0xF2000000, 1); func_800F6C34(); Audio_ResetSfxChannelState(); - func_800F9280(SEQ_PLAYER_SFX, 0, 0x70, 1); + Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0x70, 1); } diff --git a/src/code/code_800F7260.c b/src/code/code_800F7260.c index c8f24736f8..1f8e2b891e 100644 --- a/src/code/code_800F7260.c +++ b/src/code/code_800F7260.c @@ -52,15 +52,15 @@ void Audio_SetSfxBanksMute(u16 muteMask) { void Audio_QueueSeqCmdMute(u8 channelIdx) { D_801333D0 |= (1 << channelIdx); - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 2, 0x40, 0xF); - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 2, 0x40, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x40, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x40, 0xF); } void Audio_ClearBGMMute(u8 channelIdx) { D_801333D0 &= ((1 << channelIdx) ^ 0xFFFF); if (D_801333D0 == 0) { - Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 2, 0x7F, 0xF); - Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 2, 0x7F, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x7F, 0xF); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x7F, 0xF); } } diff --git a/src/code/code_800F9280.c b/src/code/code_800F9280.c index 86ca22831d..00df77801b 100644 --- a/src/code/code_800F9280.c +++ b/src/code/code_800F9280.c @@ -1,350 +1,388 @@ +/** + * @file code_800F9280.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 `Audio_QueueSeqCmd`, and a user-friendly interface for this function + * can be found in `seqcmd.h` + * + * These commands change sequences by generating internal audio commands `Audio_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 "ultra64.h" #include "global.h" #include "ultra64/abi.h" +// Direct audio command (skips the queueing system) +#define SEQCMD_SET_PLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \ + Audio_ProcessSeqCmd((SEQCMD_OP_SET_PLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | \ + ((u8)((volume)*127.0f))); + typedef struct { - u8 unk_0; - u8 unk_1; // importance? -} Struct_8016E320; + u8 seqId; + u8 priority; // higher values have higher priority +} SeqRequest; -Struct_8016E320 D_8016E320[4][5]; -u8 D_8016E348[4]; +SeqRequest sSeqRequests[4][5]; +u8 sNumSeqRequests[4]; u32 sAudioSeqCmds[0x100]; -unk_D_8016E750 D_8016E750[4]; +ActiveSequence gActiveSeqs[4]; -// TODO: clean up these macros. They are similar to ones in code_800EC960.c but without casts. -#define Audio_StartSeq(playerIdx, fadeTimer, seqId) \ - Audio_QueueSeqCmd(0x00000000 | ((playerIdx) << 24) | ((fadeTimer) << 16) | (seqId)) -#define Audio_SeqCmdA(playerIdx, a) Audio_QueueSeqCmd(0xA0000000 | ((playerIdx) << 24) | (a)) -#define Audio_SeqCmdB30(playerIdx, a, b) Audio_QueueSeqCmd(0xB0003000 | ((playerIdx) << 24) | ((a) << 16) | (b)) -#define Audio_SeqCmdB40(playerIdx, a, b) Audio_QueueSeqCmd(0xB0004000 | ((playerIdx) << 24) | ((a) << 16) | (b)) -#define Audio_SeqCmd3(playerIdx, a) Audio_QueueSeqCmd(0x30000000 | ((playerIdx) << 24) | (a)) -#define Audio_SeqCmd5(playerIdx, a, b) Audio_QueueSeqCmd(0x50000000 | ((playerIdx) << 24) | ((a) << 16) | (b)) -#define Audio_SeqCmd4(playerIdx, a, b) Audio_QueueSeqCmd(0x40000000 | ((playerIdx) << 24) | ((a) << 16) | (b)) -#define Audio_SetVolScaleNow(playerIdx, volFadeTimer, volScale) \ - Audio_ProcessSeqCmd(0x40000000 | ((u8)playerIdx << 24) | ((u8)volFadeTimer << 16) | ((u8)(volScale * 127.0f))); - -void func_800F9280(u8 playerIdx, u8 seqId, u8 arg2, u16 fadeTimer) { - u8 i; - u16 dur; +void Audio_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration) { + u8 channelIndex; + u16 duration; s32 pad; - if (D_80133408 == 0 || playerIdx == SEQ_PLAYER_SFX) { - arg2 &= 0x7F; - if (arg2 == 0x7F) { - dur = (fadeTimer >> 3) * 60 * gAudioContext.audioBufferParameters.updatesPerFrame; - Audio_QueueCmdS32(0x85000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(seqId, 8, 8), dur); + if (!gStartSeqDisabled || (seqPlayerIndex == SEQ_PLAYER_SFX)) { + seqArgs &= 0x7F; + if (seqArgs == 0x7F) { + // `fadeInDuration` is interpreted as skip ticks + duration = (fadeInDuration >> 3) * 60 * gAudioContext.audioBufferParameters.updatesPerFrame; + Audio_QueueCmdS32(0x85000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(seqId, 8, 8), duration); } else { - Audio_QueueCmdS32(0x82000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(seqId, 8, 8), - (fadeTimer * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4); + // `fadeInDuration` is interpreted as number of frames at 30 fps + Audio_QueueCmdS32(0x82000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(seqId, 8, 8), + (fadeInDuration * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4); } - D_8016E750[playerIdx].unk_254 = seqId | (arg2 << 8); - D_8016E750[playerIdx].unk_256 = seqId | (arg2 << 8); + gActiveSeqs[seqPlayerIndex].seqId = seqId | (seqArgs << 8); + gActiveSeqs[seqPlayerIndex].prevSeqId = seqId | (seqArgs << 8); - if (D_8016E750[playerIdx].volCur != 1.0f) { - Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].volCur); + if (gActiveSeqs[seqPlayerIndex].volCur != 1.0f) { + Audio_QueueCmdF32(0x41000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].volCur); } - D_8016E750[playerIdx].unk_28 = 0; - D_8016E750[playerIdx].unk_18 = 0; - D_8016E750[playerIdx].unk_14 = 0; + gActiveSeqs[seqPlayerIndex].tempoTimer = 0; + gActiveSeqs[seqPlayerIndex].tempoOriginal = 0; + gActiveSeqs[seqPlayerIndex].tempoCmd = 0; - for (i = 0; i < 0x10; i++) { - D_8016E750[playerIdx].unk_50[i].unk_00 = 1.0f; - D_8016E750[playerIdx].unk_50[i].unk_0C = 0; - D_8016E750[playerIdx].unk_50[i].unk_10 = 1.0f; - D_8016E750[playerIdx].unk_50[i].unk_1C = 0; + 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; } - D_8016E750[playerIdx].unk_250 = 0; - D_8016E750[playerIdx].unk_252 = 0; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0; + gActiveSeqs[seqPlayerIndex].volChannelFlags = 0; } } -void func_800F9474(u8 playerIdx, u16 arg1) { - Audio_QueueCmdS32(0x83000000 | ((u8)playerIdx << 16), - (arg1 * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4); - D_8016E750[playerIdx].unk_254 = NA_BGM_DISABLED; +void Audio_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration) { + Audio_QueueCmdS32(0x83000000 | ((u8)seqPlayerIndex << 16), + (fadeOutDuration * (u16)gAudioContext.audioBufferParameters.updatesPerFrame) / 4); + gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED; } -typedef enum { - SEQ_START, - CMD1, - CMD2, - CMD3, - SEQ_VOL_UPD, - CMD5, - CMD6, - CMD7, - CMD8, - CMD9, - CMDA, - CMDB, - CMDC, - CMDD, - CMDE, - CMDF -} SeqCmdType; - void Audio_ProcessSeqCmd(u32 cmd) { - s32 pad; + s32 priority; + s32 channelMaskEnable; + u16 channelMaskDisable; u16 fadeTimer; - u16 channelMask; - u32 channelMaskReversed; u16 val; u8 oldSpec; u8 spec; u8 op; u8 subOp; - u8 playerIdx; + u8 seqPlayerIndex; u8 seqId; u8 seqArgs; u8 found; u8 port; u8 duration; - u8 chanIdx; + u8 channelIndex; u8 i; - s32 new_var; - f32 freqScale; + f32 freqScaleTarget; + s32 pad; - if (D_8013340C && (cmd & 0xF0000000) != 0x70000000) { + if (gAudioDebugPrintSeqCmd && (cmd & SEQCMD_OP_MASK) != (SEQCMD_OP_SET_PLAYER_IO << 28)) { AudioDebug_ScrPrt("SEQ H", (cmd >> 16) & 0xFFFF); AudioDebug_ScrPrt(" L", cmd & 0xFFFF); } op = cmd >> 28; - playerIdx = (cmd & 0xF000000) >> 24; + seqPlayerIndex = (cmd & 0xF000000) >> 24; switch (op) { - case 0x0: - // play sequence immediately + case SEQCMD_OP_PLAY_SEQUENCE: + // Play a new sequence seqId = cmd & 0xFF; seqArgs = (cmd & 0xFF00) >> 8; + // `fadeTimer` is only shifted 13 bits instead of 16 bits. + // `fadeTimer` continues to be scaled in `Audio_StartSequence` fadeTimer = (cmd & 0xFF0000) >> 13; - if ((D_8016E750[playerIdx].unk_260 == 0) && (seqArgs < 0x80)) { - func_800F9280(playerIdx, seqId, seqArgs, fadeTimer); + if (!gActiveSeqs[seqPlayerIndex].isWaitingForFonts && (seqArgs < 0x80)) { + Audio_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); } break; - case 0x1: - // disable seq player + case SEQCMD_OP_STOP_SEQUENCE: + // Stop a sequence and disable the sequence player fadeTimer = (cmd & 0xFF0000) >> 13; - func_800F9474(playerIdx, fadeTimer); + Audio_StopSequence(seqPlayerIndex, fadeTimer); break; - case 0x2: - // queue sequence + case SEQCMD_OP_QUEUE_SEQUENCE: + // Queue a sequence into `sSeqRequests` seqId = cmd & 0xFF; seqArgs = (cmd & 0xFF00) >> 8; fadeTimer = (cmd & 0xFF0000) >> 13; - new_var = seqArgs; - for (i = 0; i < D_8016E348[playerIdx]; i++) { - if (D_8016E320[playerIdx][i].unk_0 == seqId) { + 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) { - func_800F9280(playerIdx, seqId, seqArgs, fadeTimer); + Audio_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); } return; } } - found = D_8016E348[playerIdx]; - for (i = 0; i < D_8016E348[playerIdx]; i++) { - if (D_8016E320[playerIdx][i].unk_1 <= new_var) { + // 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 = D_8016E348[playerIdx]; // "break;" + i = sNumSeqRequests[seqPlayerIndex]; // "break;" } } - if (D_8016E348[playerIdx] < 5) { - D_8016E348[playerIdx]++; + // Check if the queue is full + if (sNumSeqRequests[seqPlayerIndex] < ARRAY_COUNT(sSeqRequests[seqPlayerIndex])) { + sNumSeqRequests[seqPlayerIndex]++; } - for (i = D_8016E348[playerIdx] - 1; i != found; i--) { - D_8016E320[playerIdx][i].unk_1 = D_8016E320[playerIdx][i - 1].unk_1; - D_8016E320[playerIdx][i].unk_0 = D_8016E320[playerIdx][i - 1].unk_0; - } - D_8016E320[playerIdx][found].unk_1 = seqArgs; - D_8016E320[playerIdx][found].unk_0 = seqId; + 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) { - func_800F9280(playerIdx, seqId, seqArgs, fadeTimer); + Audio_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); } break; - case 0x3: - // unqueue/stop sequence - seqId = cmd & 0xFF; + case SEQCMD_OP_UNQUEUE_SEQUENCE: + // Unqueue sequence fadeTimer = (cmd & 0xFF0000) >> 13; - found = D_8016E348[playerIdx]; - for (i = 0; i < D_8016E348[playerIdx]; i++) { - if (D_8016E320[playerIdx][i].unk_0 == seqId) { + found = sNumSeqRequests[seqPlayerIndex]; + for (i = 0; i < sNumSeqRequests[seqPlayerIndex]; i++) { + seqId = cmd & 0xFF; + if (sSeqRequests[seqPlayerIndex][i].seqId == seqId) { found = i; - i = D_8016E348[playerIdx]; // "break;" + i = sNumSeqRequests[seqPlayerIndex]; // "break;" } } - if (found != D_8016E348[playerIdx]) { - for (i = found; i < D_8016E348[playerIdx] - 1; i++) { - D_8016E320[playerIdx][i].unk_1 = D_8016E320[playerIdx][i + 1].unk_1; - D_8016E320[playerIdx][i].unk_0 = D_8016E320[playerIdx][i + 1].unk_0; + 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; } - D_8016E348[playerIdx]--; + 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) { - func_800F9474(playerIdx, fadeTimer); - if (D_8016E348[playerIdx] != 0) { - func_800F9280(playerIdx, D_8016E320[playerIdx][0].unk_0, D_8016E320[playerIdx][0].unk_1, fadeTimer); + Audio_StopSequence(seqPlayerIndex, fadeTimer); + if (sNumSeqRequests[seqPlayerIndex] != 0) { + Audio_StartSequence(seqPlayerIndex, sSeqRequests[seqPlayerIndex][0].seqId, + sSeqRequests[seqPlayerIndex][0].priority, fadeTimer); } } break; - case 0x4: - // transition seq volume + case SEQCMD_OP_SET_PLAYER_VOLUME: + // Transition volume to a target volume for an entire player duration = (cmd & 0xFF0000) >> 15; val = cmd & 0xFF; if (duration == 0) { duration++; } - D_8016E750[playerIdx].volTarget = (f32)val / 127.0f; - if (D_8016E750[playerIdx].volCur != D_8016E750[playerIdx].volTarget) { - D_8016E750[playerIdx].unk_08 = - (D_8016E750[playerIdx].volCur - D_8016E750[playerIdx].volTarget) / (f32)duration; - D_8016E750[playerIdx].unk_0C = 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 0x5: - // transition freq scale for all channels + case SEQCMD_OP_SET_PLAYER_FREQ: + // Transition freq scale to a target freq for all channels duration = (cmd & 0xFF0000) >> 15; val = cmd & 0xFFFF; if (duration == 0) { duration++; } - freqScale = (f32)val / 1000.0f; - for (i = 0; i < 16; i++) { - D_8016E750[playerIdx].unk_50[i].unk_14 = freqScale; - D_8016E750[playerIdx].unk_50[i].unk_1C = duration; - D_8016E750[playerIdx].unk_50[i].unk_18 = - (D_8016E750[playerIdx].unk_50[i].unk_10 - freqScale) / (f32)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; } - D_8016E750[playerIdx].unk_250 = 0xFFFF; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags = 0xFFFF; break; - case 0xD: - // transition freq scale + case SEQCMD_OP_SET_CHANNEL_FREQ: + // Transition freq scale to a target for a specific channel duration = (cmd & 0xFF0000) >> 15; - chanIdx = (cmd & 0xF000) >> 12; + channelIndex = (cmd & 0xF000) >> 12; val = cmd & 0xFFF; if (duration == 0) { duration++; } - freqScale = (f32)val / 1000.0f; - D_8016E750[playerIdx].unk_50[chanIdx].unk_14 = freqScale; - D_8016E750[playerIdx].unk_50[chanIdx].unk_18 = - (D_8016E750[playerIdx].unk_50[chanIdx].unk_10 - freqScale) / (f32)duration; - D_8016E750[playerIdx].unk_50[chanIdx].unk_1C = duration; - D_8016E750[playerIdx].unk_250 |= 1 << chanIdx; + // 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 0x6: - // transition vol scale + case SEQCMD_OP_SET_CHANNEL_VOLUME: + // Transition volume to a target volume for a specific channel duration = (cmd & 0xFF0000) >> 15; - chanIdx = (cmd & 0xF00) >> 8; + channelIndex = (cmd & 0xF00) >> 8; val = cmd & 0xFF; if (duration == 0) { duration++; } - D_8016E750[playerIdx].unk_50[chanIdx].unk_04 = (f32)val / 127.0f; - if (D_8016E750[playerIdx].unk_50[chanIdx].unk_00 != D_8016E750[playerIdx].unk_50[chanIdx].unk_04) { - D_8016E750[playerIdx].unk_50[chanIdx].unk_08 = - (D_8016E750[playerIdx].unk_50[chanIdx].unk_00 - D_8016E750[playerIdx].unk_50[chanIdx].unk_04) / + // 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; - D_8016E750[playerIdx].unk_50[chanIdx].unk_0C = duration; - D_8016E750[playerIdx].unk_252 |= 1 << chanIdx; + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTimer = duration; + gActiveSeqs[seqPlayerIndex].volChannelFlags |= 1 << channelIndex; } break; - case 0x7: - // set global io port + case SEQCMD_OP_SET_PLAYER_IO: + // Set global io port port = (cmd & 0xFF0000) >> 16; val = cmd & 0xFF; - Audio_QueueCmdS8(0x46000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(port, 0, 8), val); + Audio_QueueCmdS8(0x46000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(port, 0, 8), val); break; - case 0x8: - // set io port if channel masked - chanIdx = (cmd & 0xF00) >> 8; + case SEQCMD_OP_SET_CHANNEL_IO: + // Set io port if channel masked + channelIndex = (cmd & 0xF00) >> 8; port = (cmd & 0xFF0000) >> 16; val = cmd & 0xFF; - if ((D_8016E750[playerIdx].unk_258 & (1 << chanIdx)) == 0) { - Audio_QueueCmdS8(0x06000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(chanIdx, 8, 8) | _SHIFTL(port, 0, 8), + if (!(gActiveSeqs[seqPlayerIndex].channelPortMask & (1 << channelIndex))) { + Audio_QueueCmdS8(0x06000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8) | + _SHIFTL(port, 0, 8), val); } break; - case 0x9: - // set channel mask for command 0x8 - D_8016E750[playerIdx].unk_258 = cmd & 0xFFFF; + 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 `Audio_QueueCmdS8` 0x6 + // directly. This is accomplished by setting a channel mask. + gActiveSeqs[seqPlayerIndex].channelPortMask = cmd & 0xFFFF; break; - case 0xA: - // set channel stop mask - channelMask = cmd & 0xFFFF; - if (channelMask != 0) { - // with channel mask channelMask... - Audio_QueueCmdU16(0x90000000 | _SHIFTL(playerIdx, 16, 8), channelMask); - // stop channels - Audio_QueueCmdS8(0x08000000 | _SHIFTL(playerIdx, 16, 8) | 0xFF00, 1); + case SEQCMD_OP_SET_CHANNEL_DISABLE_MASK: + // Disable or Reenable channels + + // Disable channels + channelMaskDisable = cmd & 0xFFFF; + if (channelMaskDisable != 0) { + // Apply channel mask `channelMaskDisable` + Audio_QueueCmdU16(0x90000000 | _SHIFTL(seqPlayerIndex, 16, 8), channelMaskDisable); + // Disable channels + Audio_QueueCmdS8(0x08000000 | _SHIFTL(seqPlayerIndex, 16, 8) | 0xFF00, 1); } - channelMaskReversed = channelMask ^ 0xFFFF; - if (channelMaskReversed != 0) { - // with channel mask ~channelMask... - Audio_QueueCmdU16(0x90000000 | _SHIFTL(playerIdx, 16, 8), channelMaskReversed); - // unstop channels - Audio_QueueCmdS8(0x08000000 | _SHIFTL(playerIdx, 16, 8) | 0xFF00, 0); + + // Reenable channels + channelMaskEnable = (channelMaskDisable ^ 0xFFFF); + if (channelMaskEnable != 0) { + // Apply channel mask `channelMaskEnable` + Audio_QueueCmdU16(0x90000000 | _SHIFTL(seqPlayerIndex, 16, 8), channelMaskEnable); + // Enable channels + Audio_QueueCmdS8(0x08000000 | _SHIFTL(seqPlayerIndex, 16, 8) | 0xFF00, 0); } break; - case 0xB: - // update tempo - D_8016E750[playerIdx].unk_14 = cmd; + 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 0xC: - // start sequence with setup commands + case SEQCMD_OP_SETUP_CMD: + // Queue a sub-command to execute once the sequence is finished playing subOp = (cmd & 0xF00000) >> 20; - if (subOp != 0xF) { - if (D_8016E750[playerIdx].unk_4D < 7) { - found = D_8016E750[playerIdx].unk_4D++; - if (found < 8) { - D_8016E750[playerIdx].unk_2C[found] = cmd; - D_8016E750[playerIdx].unk_4C = 2; + 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 { - D_8016E750[playerIdx].unk_4D = 0; + // `SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS` + // Discard all setup command requests on `seqPlayerIndex` + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; } break; - case 0xE: + case SEQCMD_OP_GLOBAL_CMD: + // Apply a command that applies to all sequence players subOp = (cmd & 0xF00) >> 8; val = cmd & 0xFF; switch (subOp) { - case 0: - // set sound mode + case SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE: + // Set sound mode Audio_QueueCmdS32(0xF0000000, gSoundModeList[val]); break; - case 1: - // set sequence starting disabled? - D_80133408 = val & 1; + + case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES: + // Disable the starting of new sequences (except for the sfx player) + gStartSeqDisabled = val & 1; break; } break; - case 0xF: - // change spec + case SEQCMD_OP_RESET_AUDIO_HEAP: + // Resets the audio heap based on the audio specifications and sfx channel layout spec = cmd & 0xFF; gSfxChannelLayout = (cmd & 0xFF00) >> 8; oldSpec = gAudioSpecId; @@ -356,28 +394,31 @@ void Audio_ProcessSeqCmd(u32 cmd) { } } +/** + * Add the sequence cmd to the `sAudioSeqCmds` queue + */ void Audio_QueueSeqCmd(u32 cmd) { - sAudioSeqCmds[gSeqCmdWrPos++] = cmd; + sAudioSeqCmds[gSeqCmdWritePos++] = cmd; } void Audio_ProcessSeqCmds(void) { - while (gSeqCmdWrPos != gSeqCmdRdPos) { - Audio_ProcessSeqCmd(sAudioSeqCmds[gSeqCmdRdPos++]); + while (gSeqCmdWritePos != gSeqCmdReadPos) { + Audio_ProcessSeqCmd(sAudioSeqCmds[gSeqCmdReadPos++]); } } -u16 func_800FA0B4(u8 playerIdx) { - if (!gAudioContext.seqPlayers[playerIdx].enabled) { +u16 Audio_GetActiveSeqId(u8 seqPlayerIndex) { + if (!gAudioContext.seqPlayers[seqPlayerIndex].enabled) { return NA_BGM_DISABLED; } - return D_8016E750[playerIdx].unk_254; + return gActiveSeqs[seqPlayerIndex].seqId; } -s32 func_800FA11C(u32 arg0, u32 arg1) { +s32 Audio_IsSeqCmdNotQueued(u32 cmdVal, u32 cmdMask) { u8 i; - for (i = gSeqCmdRdPos; i != gSeqCmdWrPos; i++) { - if (arg0 == (sAudioSeqCmds[i] & arg1)) { + for (i = gSeqCmdReadPos; i != gSeqCmdWritePos; i++) { + if ((sAudioSeqCmds[i] & cmdMask) == cmdVal) { return false; } } @@ -385,263 +426,342 @@ s32 func_800FA11C(u32 arg0, u32 arg1) { return true; } -void func_800FA174(u8 playerIdx) { - D_8016E348[playerIdx] = 0; +// Unused +void Audio_ResetSequenceRequests(u8 seqPlayerIndex) { + sNumSeqRequests[seqPlayerIndex] = 0; } -void func_800FA18C(u8 playerIdx, u8 arg1) { +/** + * Check if the setup command is queued. If it is, then replace the command + * with `SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME`. + * Unused + */ +void Audio_ReplaceSeqCmdSetupOpVolRestore(u8 seqPlayerIndex, u8 setupOpDisabled) { u8 i; - for (i = 0; i < D_8016E750[playerIdx].unk_4D; i++) { - u8 unkb = (D_8016E750[playerIdx].unk_2C[i] & 0xF00000) >> 20; + for (i = 0; i < gActiveSeqs[seqPlayerIndex].setupCmdNum; i++) { + u8 setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[i] & 0xF00000) >> 20; - if (unkb == arg1) { - D_8016E750[playerIdx].unk_2C[i] = 0xFF000000; + if (setupOp == setupOpDisabled) { + gActiveSeqs[seqPlayerIndex].setupCmd[i] = 0xFF000000; } } } -void Audio_SetVolScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer) { +void Audio_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer) { f32 volScale; u8 i; - D_8016E750[playerIdx].volScales[scaleIdx] = targetVol & 0x7F; + gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = targetVol & 0x7F; if (volFadeTimer != 0) { - D_8016E750[playerIdx].fadeVolUpdate = 1; - D_8016E750[playerIdx].volFadeTimer = volFadeTimer; + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true; + gActiveSeqs[seqPlayerIndex].volFadeTimer = volFadeTimer; } else { - for (i = 0, volScale = 1.0f; i < 4; i++) { - volScale *= D_8016E750[playerIdx].volScales[i] / 127.0f; + for (i = 0, volScale = 1.0f; i < VOL_SCALE_INDEX_MAX; i++) { + volScale *= gActiveSeqs[seqPlayerIndex].volScales[i] / 127.0f; } - Audio_SetVolScaleNow(playerIdx, volFadeTimer, volScale); + SEQCMD_SET_PLAYER_VOLUME_NOW(seqPlayerIndex, volFadeTimer, volScale); } } -void func_800FA3DC(void) { - u32 temp_a1; - u16 temp_lo; - u16 temp_v1; - u16 phi_a2; - u8 temp_v0_4; - u8 temp_a0; - u8 temp_s1; - u8 temp_s0_3; - u8 temp_a3_3; - s32 pad[3]; - u32 dummy; - f32 phi_f0; - u8 phi_t0; - u8 playerIdx; +/** + * Update different commands and requests for active sequences + */ +void Audio_UpdateActiveSequences(void) { + u32 tempoCmd; + u8 tempoOp; + u16 tempoPrev; + u16 tempoTarget; + u8 setupOp; + u8 targetSeqPlayerIndex; + u8 setupVal2; + u8 setupVal1; + u16 seqId; + s32 pad[2]; + u16 channelMask; + u32 retMsg; + f32 volume; + u8 tempoTimer; + u8 seqPlayerIndex; u8 j; - u8 k; + u8 channelIndex; - for (playerIdx = 0; playerIdx < 4; playerIdx++) { - if (D_8016E750[playerIdx].unk_260 != 0) { - switch (func_800E5E20(&dummy)) { - case 1: - case 2: - case 3: - case 4: - D_8016E750[playerIdx].unk_260 = 0; - Audio_ProcessSeqCmd(D_8016E750[playerIdx].unk_25C); + for (seqPlayerIndex = 0; seqPlayerIndex < 4; seqPlayerIndex++) { + + // The setup for this block of code was not fully implemented until Majora's Mask. + // The intent was to load soundfonts asynchronously before playing a + // sequence in `Audio_StartSequence` using `(seqArgs & 0x80)`. + // Checks if the requested sequence is finished loading fonts + if (gActiveSeqs[seqPlayerIndex].isWaitingForFonts) { + switch (func_800E5E20(&retMsg)) { + case SEQ_PLAYER_BGM_MAIN + 1: + case SEQ_PLAYER_FANFARE + 1: + case SEQ_PLAYER_SFX + 1: + case SEQ_PLAYER_BGM_SUB + 1: + // The fonts have been loaded successfully. + gActiveSeqs[seqPlayerIndex].isWaitingForFonts = false; + // Queue the same command that was stored previously + // The code to store this command is missing in OoT, so no command is executed + Audio_ProcessSeqCmd(gActiveSeqs[seqPlayerIndex].startSeqCmd); break; } } - if (D_8016E750[playerIdx].fadeVolUpdate) { - phi_f0 = 1.0f; - for (j = 0; j < 4; j++) { - phi_f0 *= (D_8016E750[playerIdx].volScales[j] / 127.0f); + // 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); } - Audio_SeqCmd4(playerIdx, D_8016E750[playerIdx].volFadeTimer, (u8)(phi_f0 * 127.0f)); - D_8016E750[playerIdx].fadeVolUpdate = 0; + SEQCMD_SET_PLAYER_VOLUME(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volFadeTimer, (u8)(volume * 127.0f)); + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false; } - if (D_8016E750[playerIdx].unk_0C != 0) { - D_8016E750[playerIdx].unk_0C--; + if (gActiveSeqs[seqPlayerIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].volTimer--; - if (D_8016E750[playerIdx].unk_0C != 0) { - D_8016E750[playerIdx].volCur = D_8016E750[playerIdx].volCur - D_8016E750[playerIdx].unk_08; + if (gActiveSeqs[seqPlayerIndex].volTimer != 0) { + gActiveSeqs[seqPlayerIndex].volCur -= gActiveSeqs[seqPlayerIndex].volStep; } else { - D_8016E750[playerIdx].volCur = D_8016E750[playerIdx].volTarget; + gActiveSeqs[seqPlayerIndex].volCur = gActiveSeqs[seqPlayerIndex].volTarget; } - Audio_QueueCmdF32(0x41000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].volCur); + Audio_QueueCmdF32(0x41000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].volCur); } - if (D_8016E750[playerIdx].unk_14 != 0) { - temp_a1 = D_8016E750[playerIdx].unk_14; - phi_t0 = (temp_a1 & 0xFF0000) >> 15; - phi_a2 = temp_a1 & 0xFFF; - if (phi_t0 == 0) { - phi_t0++; + // Process tempo + if (gActiveSeqs[seqPlayerIndex].tempoCmd != 0) { + tempoCmd = gActiveSeqs[seqPlayerIndex].tempoCmd; + tempoTimer = (tempoCmd & 0xFF0000) >> 15; + tempoTarget = tempoCmd & 0xFFF; + if (tempoTimer == 0) { + tempoTimer++; } - if (gAudioContext.seqPlayers[playerIdx].enabled) { - temp_lo = gAudioContext.seqPlayers[playerIdx].tempo / 0x30; - temp_v0_4 = (temp_a1 & 0xF000) >> 12; - switch (temp_v0_4) { - case 1: - phi_a2 += temp_lo; + // Process tempo commands + if (gAudioContext.seqPlayers[seqPlayerIndex].enabled) { + tempoPrev = gAudioContext.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 2: - if (phi_a2 < temp_lo) { - phi_a2 = temp_lo - phi_a2; + + case SEQCMD_SUB_OP_TEMPO_SLOW_DOWN: + // Slow down tempo by `tempoTarget` amount + if (tempoTarget < tempoPrev) { + tempoTarget = tempoPrev - tempoTarget; } break; - case 3: - phi_a2 = temp_lo * (phi_a2 / 100.0f); + + case SEQCMD_SUB_OP_TEMPO_SCALE: + // Scale tempo by a multiplicative factor + tempoTarget = tempoPrev * (tempoTarget / 100.0f); break; - case 4: - if (D_8016E750[playerIdx].unk_18) { - phi_a2 = D_8016E750[playerIdx].unk_18; - } else { - phi_a2 = temp_lo; - } + + 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 (phi_a2 > 300) { - phi_a2 = 300; + if (tempoTarget > 300) { + tempoTarget = 300; } - if (D_8016E750[playerIdx].unk_18 == 0) { - D_8016E750[playerIdx].unk_18 = temp_lo; + if (gActiveSeqs[seqPlayerIndex].tempoOriginal == 0) { + gActiveSeqs[seqPlayerIndex].tempoOriginal = tempoPrev; } - D_8016E750[playerIdx].unk_20 = phi_a2; - D_8016E750[playerIdx].unk_1C = gAudioContext.seqPlayers[playerIdx].tempo / 0x30; - D_8016E750[playerIdx].unk_24 = (D_8016E750[playerIdx].unk_1C - D_8016E750[playerIdx].unk_20) / phi_t0; - D_8016E750[playerIdx].unk_28 = phi_t0; - D_8016E750[playerIdx].unk_14 = 0; + gActiveSeqs[seqPlayerIndex].tempoTarget = tempoTarget; + gActiveSeqs[seqPlayerIndex].tempoCur = gAudioContext.seqPlayers[seqPlayerIndex].tempo / TATUMS_PER_BEAT; + gActiveSeqs[seqPlayerIndex].tempoStep = + (gActiveSeqs[seqPlayerIndex].tempoCur - gActiveSeqs[seqPlayerIndex].tempoTarget) / tempoTimer; + gActiveSeqs[seqPlayerIndex].tempoTimer = tempoTimer; + gActiveSeqs[seqPlayerIndex].tempoCmd = 0; } } - if (D_8016E750[playerIdx].unk_28 != 0) { - D_8016E750[playerIdx].unk_28--; - if (D_8016E750[playerIdx].unk_28 != 0) { - D_8016E750[playerIdx].unk_1C = D_8016E750[playerIdx].unk_1C - D_8016E750[playerIdx].unk_24; + // Step tempo to target + if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) { + gActiveSeqs[seqPlayerIndex].tempoTimer--; + if (gActiveSeqs[seqPlayerIndex].tempoTimer != 0) { + gActiveSeqs[seqPlayerIndex].tempoCur -= gActiveSeqs[seqPlayerIndex].tempoStep; } else { - D_8016E750[playerIdx].unk_1C = D_8016E750[playerIdx].unk_20; + gActiveSeqs[seqPlayerIndex].tempoCur = gActiveSeqs[seqPlayerIndex].tempoTarget; } - // set tempo - Audio_QueueCmdS32(0x47000000 | _SHIFTL(playerIdx, 16, 8), D_8016E750[playerIdx].unk_1C); + // Set tempo + Audio_QueueCmdS32(0x47000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].tempoCur); } - if (D_8016E750[playerIdx].unk_252 != 0) { - for (k = 0; k < 0x10; k++) { - if (D_8016E750[playerIdx].unk_50[k].unk_0C != 0) { - D_8016E750[playerIdx].unk_50[k].unk_0C--; - if (D_8016E750[playerIdx].unk_50[k].unk_0C != 0) { - D_8016E750[playerIdx].unk_50[k].unk_00 -= D_8016E750[playerIdx].unk_50[k].unk_08; + // 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 { - D_8016E750[playerIdx].unk_50[k].unk_00 = D_8016E750[playerIdx].unk_50[k].unk_04; - D_8016E750[playerIdx].unk_252 ^= (1 << k); + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur = + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget; + gActiveSeqs[seqPlayerIndex].volChannelFlags ^= (1 << channelIndex); } - // CHAN_UPD_VOL_SCALE (playerIdx = seq, k = chan) - Audio_QueueCmdF32(0x01000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(k, 8, 8), - D_8016E750[playerIdx].unk_50[k].unk_00); + // `CHAN_UPD_VOL_SCALE` + Audio_QueueCmdF32(0x01000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8), + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur); } } } - if (D_8016E750[playerIdx].unk_250 != 0) { - for (k = 0; k < 0x10; k++) { - if (D_8016E750[playerIdx].unk_50[k].unk_1C != 0) { - D_8016E750[playerIdx].unk_50[k].unk_1C--; - if (D_8016E750[playerIdx].unk_50[k].unk_1C != 0) { - D_8016E750[playerIdx].unk_50[k].unk_10 -= D_8016E750[playerIdx].unk_50[k].unk_18; + // 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 { - D_8016E750[playerIdx].unk_50[k].unk_10 = D_8016E750[playerIdx].unk_50[k].unk_14; - D_8016E750[playerIdx].unk_250 ^= (1 << k); + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur = + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget; + gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags ^= (1 << channelIndex); } - // CHAN_UPD_FREQ_SCALE - Audio_QueueCmdF32(0x04000000 | _SHIFTL(playerIdx, 16, 8) | _SHIFTL(k, 8, 8), - D_8016E750[playerIdx].unk_50[k].unk_10); + // `CHAN_UPD_FREQ_SCALE` + Audio_QueueCmdF32(0x04000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8), + gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur); } } } - if (D_8016E750[playerIdx].unk_4D != 0) { - if (func_800FA11C(0xF0000000, 0xF0000000) == 0) { - D_8016E750[playerIdx].unk_4D = 0; + // 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 (!Audio_IsSeqCmdNotQueued(SEQCMD_OP_RESET_AUDIO_HEAP << 28, SEQCMD_OP_MASK)) { + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; return; } - if (D_8016E750[playerIdx].unk_4C != 0) { - D_8016E750[playerIdx].unk_4C--; + // Only process setup commands once the timer reaches zero + if (gActiveSeqs[seqPlayerIndex].setupCmdTimer != 0) { + gActiveSeqs[seqPlayerIndex].setupCmdTimer--; continue; } - if (gAudioContext.seqPlayers[playerIdx].enabled) { + // Only process setup commands if `seqPlayerIndex` if no longer playing + // i.e. the `seqPlayer` is no longer enabled + if (gAudioContext.seqPlayers[seqPlayerIndex].enabled) { continue; } - for (j = 0; j < D_8016E750[playerIdx].unk_4D; j++) { - temp_a0 = (D_8016E750[playerIdx].unk_2C[j] & 0x00F00000) >> 20; - temp_s1 = (D_8016E750[playerIdx].unk_2C[j] & 0x000F0000) >> 16; - temp_s0_3 = (D_8016E750[playerIdx].unk_2C[j] & 0xFF00) >> 8; - temp_a3_3 = D_8016E750[playerIdx].unk_2C[j] & 0xFF; + for (j = 0; j < gActiveSeqs[seqPlayerIndex].setupCmdNum; j++) { + setupOp = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0x00F00000) >> 20; + targetSeqPlayerIndex = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0x000F0000) >> 16; + setupVal2 = (gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF00) >> 8; + setupVal1 = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF; - switch (temp_a0) { - case 0: - Audio_SetVolScale(temp_s1, 1, 0x7F, temp_a3_3); + switch (setupOp) { + case SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME: + // Restore `targetSeqPlayerIndex` volume back to normal levels + Audio_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal1); break; - case 7: - if (D_8016E348[playerIdx] == temp_a3_3) { - Audio_SetVolScale(temp_s1, 1, 0x7F, temp_s0_3); + + case SEQCMD_SUB_OP_SETUP_RESTORE_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]) { + Audio_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal2); } break; - case 1: - Audio_SeqCmd3(playerIdx, D_8016E750[playerIdx].unk_254); + + 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(seqPlayerIndex, 0, gActiveSeqs[seqPlayerIndex].seqId); break; - case 2: - Audio_StartSeq(temp_s1, 1, D_8016E750[temp_s1].unk_254); - D_8016E750[temp_s1].fadeVolUpdate = 1; - D_8016E750[temp_s1].volScales[1] = 0x7F; + + 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(targetSeqPlayerIndex, 1, 0, gActiveSeqs[targetSeqPlayerIndex].seqId); + gActiveSeqs[targetSeqPlayerIndex].fadeVolUpdate = true; + gActiveSeqs[targetSeqPlayerIndex].volScales[VOL_SCALE_INDEX_FANFARE] = 0x7F; break; - case 3: - Audio_SeqCmdB30(temp_s1, temp_s0_3, temp_a3_3); + + case SEQCMD_SUB_OP_SETUP_TEMPO_SCALE: + // Scale tempo by a multiplicative factor + SEQCMD_SCALE_TEMPO(targetSeqPlayerIndex, setupVal2, setupVal1); break; - case 4: - Audio_SeqCmdB40(temp_s1, temp_a3_3, 0); + + case SEQCMD_SUB_OP_SETUP_TEMPO_RESET: + // Reset tempo to previous tempo + SEQCMD_RESET_TEMPO(targetSeqPlayerIndex, setupVal1); break; - case 5: - temp_v1 = D_8016E750[playerIdx].unk_2C[j] & 0xFFFF; - Audio_StartSeq(temp_s1, D_8016E750[temp_s1].unk_4E, temp_v1); - Audio_SetVolScale(temp_s1, 1, 0x7F, 0); - D_8016E750[temp_s1].unk_4E = 0; + + 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(targetSeqPlayerIndex, gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer, 0, + seqId); + Audio_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, 0); + gActiveSeqs[targetSeqPlayerIndex].setupFadeTimer = 0; break; - case 6: - D_8016E750[playerIdx].unk_4E = temp_s0_3; + + 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 8: - Audio_SetVolScale(temp_s1, temp_s0_3, 0x7F, temp_a3_3); + + case SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_WITH_SCALE_INDEX: + // Restore the volume back to default levels + // Allows a `scaleIndex` to be specified. + Audio_SetVolumeScale(targetSeqPlayerIndex, setupVal2, 0x7F, setupVal1); break; - case 14: - if (temp_a3_3 & 1) { + + 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)) { Audio_QueueCmdS32(0xE3000000, SEQUENCE_TABLE); } - if (temp_a3_3 & 2) { + if (setupVal1 & (1 << FONT_TABLE)) { Audio_QueueCmdS32(0xE3000000, FONT_TABLE); } - if (temp_a3_3 & 4) { + if (setupVal1 & (1 << SAMPLE_TABLE)) { Audio_QueueCmdS32(0xE3000000, SAMPLE_TABLE); } break; - case 9: - temp_v1 = D_8016E750[playerIdx].unk_2C[j] & 0xFFFF; - Audio_SeqCmdA(temp_s1, temp_v1); + + 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(targetSeqPlayerIndex, channelMask); break; - case 10: - Audio_SeqCmd5(temp_s1, temp_s0_3, (temp_a3_3 * 10) & 0xFFFF); + + case SEQCMD_SUB_OP_SETUP_SET_PLAYER_FREQ: + // Scale all channels of `targetSeqPlayerIndex` + SEQCMD_SET_PLAYER_FREQ(targetSeqPlayerIndex, setupVal2, (setupVal1 * 10) & 0xFFFF); break; } } - D_8016E750[playerIdx].unk_4D = 0; + gActiveSeqs[seqPlayerIndex].setupCmdNum = 0; } } } @@ -665,39 +785,43 @@ u8 func_800FAD34(void) { return D_80133418; } -void func_800FADF8(void) { - u8 playerIdx, j; +void Audio_ResetActiveSequences(void) { + u8 seqPlayerIndex; + u8 scaleIndex; - for (playerIdx = 0; playerIdx < 4; playerIdx++) { - D_8016E348[playerIdx] = 0; - D_8016E750[playerIdx].unk_254 = NA_BGM_DISABLED; - D_8016E750[playerIdx].unk_256 = NA_BGM_DISABLED; - D_8016E750[playerIdx].unk_28 = 0; - D_8016E750[playerIdx].unk_18 = 0; - D_8016E750[playerIdx].unk_14 = 0; - D_8016E750[playerIdx].unk_258 = 0; - D_8016E750[playerIdx].unk_4D = 0; - D_8016E750[playerIdx].unk_4E = 0; - D_8016E750[playerIdx].unk_250 = 0; - D_8016E750[playerIdx].unk_252 = 0; - for (j = 0; j < 4; j++) { - D_8016E750[playerIdx].volScales[j] = 0x7F; + for (seqPlayerIndex = 0; seqPlayerIndex < 4; 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; + for (scaleIndex = 0; scaleIndex < VOL_SCALE_INDEX_MAX; scaleIndex++) { + gActiveSeqs[seqPlayerIndex].volScales[scaleIndex] = 0x7F; } - D_8016E750[playerIdx].volFadeTimer = 1; - D_8016E750[playerIdx].fadeVolUpdate = 1; + + gActiveSeqs[seqPlayerIndex].volFadeTimer = 1; + gActiveSeqs[seqPlayerIndex].fadeVolUpdate = true; } } -void func_800FAEB4(void) { - u8 playerIdx, j; +void Audio_ResetActiveSequencesAndVolume(void) { + u8 seqPlayerIndex; + u8 scaleIndex; - for (playerIdx = 0; playerIdx < 4; playerIdx++) { - D_8016E750[playerIdx].volCur = 1.0f; - D_8016E750[playerIdx].unk_0C = 0; - D_8016E750[playerIdx].fadeVolUpdate = 0; - for (j = 0; j < 4; j++) { - D_8016E750[playerIdx].volScales[j] = 0x7F; + for (seqPlayerIndex = 0; seqPlayerIndex < 4; 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; } } - func_800FADF8(); + Audio_ResetActiveSequences(); } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index e1c4f7db39..9af0c6f930 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -449,15 +449,15 @@ void Cutscene_Command_StopBGM(PlayState* play, CutsceneContext* csCtx, CsCmdMusi // Command 0x7C: Fade Background Music over duration void Cutscene_Command_FadeBGM(PlayState* play, CutsceneContext* csCtx, CsCmdMusicFade* cmd) { - u8 var1; + u8 fadeTimer; if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { - var1 = cmd->endFrame - cmd->startFrame; + fadeTimer = cmd->endFrame - cmd->startFrame; if (cmd->type == 3) { - Audio_QueueSeqCmd(var1 << 0x10 | (0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, fadeTimer); } else { - Audio_QueueSeqCmd(var1 << 0x10 | (0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xFF)); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, fadeTimer); } } } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index ec49412555..b589766d01 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -2035,7 +2035,7 @@ void Environment_PlaySceneSequence(PlayState* play) { Audio_PlayNatureAmbienceSequence(NATURE_ID_KOKIRI_REGION); } else if (((void)0, gSaveContext.forcedSeqId) != NA_BGM_GENERAL_SFX) { if (!Environment_IsForcedSequenceDisabled()) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | (s32)((void)0, gSaveContext.forcedSeqId)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, ((void)0, gSaveContext.forcedSeqId)); } gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; } else if (play->sequenceCtx.seqId == NA_BGM_NO_MUSIC) { @@ -2102,7 +2102,7 @@ void Environment_PlayTimeBasedSequence(PlayState* play) { if (gSaveContext.dayTime > CLOCK_TIME(17, 10)) { if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xF000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 240); } play->envCtx.timeSeqState++; @@ -2570,7 +2570,7 @@ void Environment_StopStormNatureAmbience(PlayState* play) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 0); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_1, 0); - if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) == NA_BGM_NATURE_AMBIENCE) { + if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_NATURE_AMBIENCE) { gSaveContext.seqId = NA_BGM_NATURE_SFX_RAIN; Environment_PlaySceneSequence(play); } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 6f21159949..ac1c779ef5 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -397,7 +397,7 @@ void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) { play->sequenceCtx.natureAmbienceId = cmd->soundSettings.natureAmbienceId; if (gSaveContext.seqId == (u8)NA_BGM_DISABLED) { - Audio_QueueSeqCmd(cmd->soundSettings.specId | 0xF0000000); + SEQCMD_RESET_AUDIO_HEAP(0, cmd->soundSettings.specId); } } diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 96d8cc302d..5c6c9ec702 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -107,8 +107,8 @@ void func_808BAF40(BgTokiSwd* this, PlayState* play) { } else { play->csCtx.segment = D_808BB7A0; } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_MASTER_SWORD); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_MASTER_SWORD); gSaveContext.cutsceneTrigger = 1; this->actor.parent = NULL; BgTokiSwd_SetupAction(this, func_808BB0AC); diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index aef29c7aee..ace123bcfd 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -319,7 +319,7 @@ void BossDodongo_IntroCutscene(BossDodongo* this, PlayState* play) { BossDodongo_Walk(this, play); if (this->unk_196 == 1) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } if (this->unk_196 == 0) { @@ -407,7 +407,7 @@ void BossDodongo_IntroCutscene(BossDodongo* this, PlayState* play) { SEGMENTED_TO_VIRTUAL(&object_kingdodongo_Blob_017410), 0xA0, 0xB4, 0x80, 0x28); } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); } if (this->unk_198 == 0) { @@ -1284,7 +1284,7 @@ void BossDodongo_SetupDeathCutscene(BossDodongo* this) { this->csState = 0; this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); this->unk_1BC = 1; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } void BossDodongo_DeathCutscene(BossDodongo* this, PlayState* play) { @@ -1598,7 +1598,7 @@ void BossDodongo_DeathCutscene(BossDodongo* this, PlayState* play) { } if (this->unk_1DA == 820) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, Math_SinS(this->actor.shape.rot.y) * -50.0f + this->actor.world.pos.x, this->actor.world.pos.y, diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index fd16437c74..477b3a2186 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -185,7 +185,7 @@ void BossFd_Init(Actor* thisx, PlayState* play) { SkelAnime_Init(play, &this->skelAnimeLeftArm, &gVolvagiaLeftArmSkel, &gVolvagiaLeftArmEmergeAnim, NULL, NULL, 0); this->introState = BFD_CS_WAIT; if (this->introState == BFD_CS_NONE) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); } this->actor.world.pos.x = this->actor.world.pos.z = 0.0f; @@ -486,7 +486,7 @@ void BossFd_Fly(BossFd* this, PlayState* play) { this->subCamAtYOffset = Math_CosS(this->work[BFD_MOVE_TIMER] * 0x8000) * this->subCamShake; } if (this->timers[3] == 160) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_FIRE_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); } if ((this->timers[3] == 130) && !GET_EVENTCHKINF(EVENTCHKINF_73)) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, @@ -743,7 +743,7 @@ void BossFd_Fly(BossFd* this, PlayState* play) { if (this->skinSegments != 0) { this->skinSegments--; if (this->skinSegments == 0) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); } } else { this->work[BFD_ACTION_STATE] = BOSSFD_BONES_FALL; diff --git a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c index 8642c77c04..43afbefc9b 100644 --- a/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c +++ b/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c @@ -884,7 +884,7 @@ void BossFd2_CollisionCheck(BossFd2* this, PlayState* play) { BossFd2_SetupDeath(this, play); this->work[FD2_DAMAGE_FLASH_TIMER] = 10; this->work[FD2_INVINC_TIMER] = 30000; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_VALVAISA_DEAD); Enemy_StartFinishingBlow(play, &this->actor); } else if (damage) { diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index 371330da66..b44e7191b2 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -575,7 +575,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { this->unk_198 = 2; this->timers[2] = 110; gSaveContext.healthAccumulator = 0x140; - Audio_QueueSeqCmd(NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } else { this->useOpenHand = true; BossGanon_SetIntroCsCamera(this, 0); @@ -807,7 +807,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { BossGanon_SetIntroCsCamera(this, 9); if (this->csTimer == 30) { - Audio_QueueSeqCmd(0x100100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->fwork[GDF_FWORK_1] = Animation_GetLastFrame(&gGanondorfStopPlayingOrganAnim); Animation_MorphToPlayOnce(&this->skelAnime, &gGanondorfStopPlayingOrganAnim, -5.0f); } @@ -1074,7 +1074,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { sCape->attachShouldersTimer = 18.0f; Audio_PlayActorSfx2(&this->actor, NA_SE_EV_GANON_MANTLE); this->unk_198 = 0; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANONDORF_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_GANONDORF_BOSS); } if (this->csTimer == 50) { @@ -2738,7 +2738,7 @@ void BossGanon_UpdateDamage(BossGanon* this, PlayState* play) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GANON_DEAD); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GANON_DD_THUNDER); func_80078914(&sZeroVec, NA_SE_EN_LAST_DAMAGE); - Audio_QueueSeqCmd(0x100100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->screenFlashTimer = 4; } else { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GANON_DAMAGE2); diff --git a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 49e1748028..6fbc2de0ef 100644 --- a/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -296,7 +296,7 @@ void func_808FD5F4(BossGanon2* this, PlayState* play) { this->unk_339 = 4; if (this->unk_398 == 10) { func_80078914(&D_80906D6C, NA_SE_EV_STONE_BOUND); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); } if (this->unk_398 == 20) { sZelda->unk_3C8 = 3; @@ -447,7 +447,7 @@ void func_808FD5F4(BossGanon2* this, PlayState* play) { this->actor.world.pos.x = -200.0f; this->actor.world.pos.y = this->actor.world.pos.y - 30.0f; this->actor.world.pos.z = -200.0f; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_OPENING_GANON); } else { break; } @@ -592,7 +592,7 @@ void func_808FD5F4(BossGanon2* this, PlayState* play) { case 18: this->unk_339 = 6; if (this->unk_398 == 30) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_GANON_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_GANON_BOSS); } Math_ApproachF(&this->unk_30C, 7.0f, 1.0f, 0.1f); Math_ApproachF(&this->subCamEye.x, (this->actor.world.pos.x + 500.0f) - 350.0f, 0.1f, 1.0f); @@ -1694,7 +1694,7 @@ void func_8090120C(BossGanon2* this, PlayState* play) { this->subCamAt.z = D_80907050[phi_a1].z + player->actor.world.pos.z; } if (this->unk_398 > 80) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->unk_39C = 75; this->unk_398 = 0; this->subCamEye.x = 112.0f; diff --git a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c index e0d4ac4014..5388fb65be 100644 --- a/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c +++ b/src/overlays/actors/ovl_Boss_Ganondrof/z_boss_ganondrof.c @@ -928,7 +928,7 @@ void BossGanondrof_SetupDeath(BossGanondrof* this, PlayState* play) { Animation_PlayOnce(&this->skelAnime, &gPhantomGanonDeathBlowAnim); this->fwork[GND_END_FRAME] = Animation_GetLastFrame(&gPhantomGanonDeathBlowAnim); this->actionFunc = BossGanondrof_Death; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_FANTOM_DEAD); this->deathState = DEATH_START; this->actor.flags &= ~ACTOR_FLAG_0; @@ -1101,7 +1101,7 @@ void BossGanondrof_Death(BossGanondrof* this, PlayState* play) { holdCamera = true; bodyDecayLevel = 10; if (this->timers[0] == 150) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); Actor_Spawn(&play->actorCtx, play, ACTOR_DOOR_WARP1, GND_BOSSROOM_CENTER_X, GND_BOSSROOM_CENTER_Y, GND_BOSSROOM_CENTER_Z, 0, 0, 0, WARP_DUNGEON_ADULT); } diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index 391a1026e9..e2c6bd4d06 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -407,7 +407,7 @@ void BossGoma_SetupDefeated(BossGoma* this, PlayState* play) { this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); this->actor.speedXZ = 0.0f; this->actor.shape.shadowScale = 0.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_GOMA_DEAD); } @@ -659,7 +659,7 @@ void BossGoma_SetupEncounterState4(BossGoma* this, PlayState* play) { this->subCamAt.y = this->actor.world.pos.y; this->subCamAt.z = this->actor.world.pos.z; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); } /** @@ -924,7 +924,7 @@ void BossGoma_Encounter(BossGoma* this, PlayState* play) { 0xA0, 0xB4, 0x80, 0x28); } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); SET_EVENTCHKINF(EVENTCHKINF_70); } @@ -1108,7 +1108,7 @@ void BossGoma_Defeated(BossGoma* this, PlayState* play) { Math_SmoothStepToF(&this->subCamAt.z, this->firstTailLimbWorldPos.z, 0.2f, 50.0f, 0.1f); if (this->timer == 80) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); } if (this->timer == 0) { diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 09e7e8ca1b..4531854e27 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -360,7 +360,7 @@ void BossMo_Init(Actor* thisx, PlayState* play2) { return; } if (GET_EVENTCHKINF(EVENTCHKINF_74)) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); this->tentMaxAngle = 5.0f; this->timers[0] = 50; } else { @@ -1101,7 +1101,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { -280.0f, this->actor.world.pos.z, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, this->actor.world.pos.x + 200.0f, -280.0f, this->actor.world.pos.z, 0, 0, 0, 0); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); Flags_SetClear(play, play->roomCtx.curRoom.num); } } @@ -1236,7 +1236,7 @@ void BossMo_IntroCs(BossMo* this, PlayState* play) { this->actor.world.rot.y = 0x721A; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_READY; sMorphaTent1->timers[0] = 30000; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x3200FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 50); Message_CloseTextbox(play); } else { break; @@ -1417,7 +1417,7 @@ void BossMo_IntroCs(BossMo* this, PlayState* play) { this->subCamAccel = 0.01f; } if (this->timers[2] == 150) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } if (this->timers[2] == 130) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 0xA0, @@ -1775,7 +1775,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) { ((sMorphaTent1->subCamId == SUB_CAM_ID_DONE) && (sMorphaTent2 != NULL) && (sMorphaTent2->subCamId == SUB_CAM_ID_DONE))) { Enemy_StartFinishingBlow(play, &this->actor); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->csState = MO_DEATH_START; sMorphaTent1->drawActor = false; sMorphaTent1->work[MO_TENT_ACTION_STATE] = MO_TENT_DEATH_START; @@ -3576,11 +3576,11 @@ void BossMo_Unknown(void) { if (BREG(32) != 0) { BREG(32)--; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); func_80078914(&zeroVec, unkSfx[BREG(33)]); } if (BREG(34) != 0) { BREG(34) = 0; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | (u16)BREG(35)); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, BREG(35)); } } diff --git a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 80ca1c97ed..76b7e5454c 100644 --- a/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -381,7 +381,7 @@ void BossSst_HeadSetupIntro(BossSst* this, PlayState* play) { } Play_CameraSetAtEye(play, sSubCamId, &sSubCamAt, &sSubCamEye); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->actionFunc = BossSst_HeadIntro; } @@ -601,7 +601,7 @@ void BossSst_HeadIntro(BossSst* this, PlayState* play) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gBongoTitleCardTex), 160, 180, 128, 40); } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); Animation_MorphToPlayOnce(&this->skelAnime, &gBongoHeadEyeCloseAnim, -5.0f); BossSst_HeadSfx(this, NA_SE_EN_SHADEST_DISAPPEAR); } @@ -1015,7 +1015,7 @@ void BossSst_HeadSetupDeath(BossSst* this, PlayState* play) { this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; sHands[LEFT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; sHands[RIGHT]->colliderJntSph.base.ocFlags1 &= ~OC1_ON; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); sSubCamId = Play_CreateSubCamera(play); Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_WAIT); Play_ChangeCameraStatus(play, sSubCamId, CAM_STAT_ACTIVE); @@ -1160,7 +1160,7 @@ void BossSst_HeadMelt(BossSst* this, PlayState* play) { void BossSst_HeadSetupFinish(BossSst* this) { this->actor.draw = BossSst_DrawEffects; this->timer = 40; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); BossSst_SetCameraTargets(1.0 / 40, 6); this->actionFunc = BossSst_HeadFinish; } diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index b21d10703c..d1085f3a18 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -519,7 +519,7 @@ void BossTw_Init(Actor* thisx, PlayState* play2) { this->actor.world.pos.x = -600.0f; this->actor.world.pos.y = 400.0f; this->actor.world.pos.z = 0.0f; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } else { BossTw_SetupCSWait(this, play); } @@ -1512,7 +1512,7 @@ void BossTw_TwinrovaMergeCS(BossTw* this, PlayState* play) { this->workf[UNK_F9] = 0.0f; this->workf[UNK_F10] = 0.0f; this->workf[UNK_F11] = 600.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xC800FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 200); this->work[CS_TIMER_2] = 0; FALLTHROUGH; case 1: @@ -1641,7 +1641,7 @@ void BossTw_TwinrovaMergeCS(BossTw* this, PlayState* play) { this->timers[0] = 50; func_8002DF54(play, &this->actor, 2); Audio_PlayActorSfx2(&this->actor, NA_SE_EN_TWINROBA_TRANSFORM); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } } @@ -1782,7 +1782,7 @@ void BossTw_TwinrovaIntroCS(BossTw* this, PlayState* play) { if (this->csSfxTimer == 180) { func_80078914(&D_8094A7D0, NA_SE_EN_TWINROBA_LAUGH); func_80078914(&D_8094A7D0, NA_SE_EN_TWINROBA_LAUGH2); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KOTAKE_KOUME); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KOTAKE_KOUME); } this->csSfxTimer++; @@ -2206,7 +2206,7 @@ void BossTw_TwinrovaIntroCS(BossTw* this, PlayState* play) { } if (this->work[CS_TIMER_1] == 90) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5A00FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 90); } if (this->work[CS_TIMER_1] == 120) { @@ -2217,7 +2217,7 @@ void BossTw_TwinrovaIntroCS(BossTw* this, PlayState* play) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(object_tw_Blob_02E170), 0xA0, 0xB4, 0x80, 0x28); SET_EVENTCHKINF(EVENTCHKINF_75); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } if (this->work[CS_TIMER_1] >= 160) { @@ -2512,7 +2512,7 @@ void BossTw_DeathCSMsgSfx(BossTw* this, PlayState* play) { if (this->work[CS_TIMER_2] == 820) { msgId1 = 0x6057; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 80); } if (this->work[CS_TIMER_2] == 860) { @@ -2688,7 +2688,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, PlayState* play) { Play_ChangeCameraStatus(play, this->subCamId, CAM_STAT_ACTIVE); this->subCamEye = mainCam->eye; this->subCamAt = mainCam->at; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); break; case 1: spD0.x = Math_SinS(this->actor.world.rot.y) * 200.0f; @@ -2763,7 +2763,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, PlayState* play) { sKoumePtr->visible = 1; sKotakePtr->visible = 1; func_80078884(NA_SE_EN_TWINROBA_TRANSFORM); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KOTAKE_KOUME); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KOTAKE_KOUME); this->csState2 = 3; this->work[CS_TIMER_2] = 0; this->subCamYaw = this->subCamYawStep = this->actor.speedXZ = this->subCamDistStep = 0.0f; @@ -2811,7 +2811,7 @@ void BossTw_TwinrovaDeathCS(BossTw* this, PlayState* play) { this->subCamId = SUB_CAM_ID_DONE; func_80064534(play, &play->csCtx); func_8002DF54(play, &this->actor, 7); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_DOOR_WARP1, 600.0f, 230.0f, 0.0f, 0, 0, 0, WARP_DUNGEON_ADULT); Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_B_HEART, -600.0f, 230.f, 0.0f, 0, 0, 0, 0); diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index c0c4a78cbb..5426855675 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -957,7 +957,7 @@ void BossVa_BodyIntro(BossVa* this, PlayState* play) { play->envCtx.lightSettingOverride = 1; func_8002DF54(play, &this->actor, 8); } else if (this->timer >= 35000) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } this->timer += this->unk_1F2; @@ -1512,7 +1512,7 @@ void BossVa_BodyPhase4(BossVa* this, PlayState* play) { void BossVa_SetupBodyDeath(BossVa* this, PlayState* play) { func_800F436C(&this->actor.projectedPos, NA_SE_EN_BALINADE_LEVEL - SFX_FLAG, 1.0f); this->actor.flags &= ~(ACTOR_FLAG_0 | ACTOR_FLAG_2); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); this->vaCamRotMod = 0xC31; sCsState = DEATH_START; this->actor.speedXZ = 0.0f; @@ -1597,7 +1597,7 @@ void BossVa_BodyDeath(BossVa* this, PlayState* play) { break; case DEATH_CORE_BURST: if (this->timer == 13) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); } this->timer--; diff --git a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c index 6f4e3a6ded..a86d617068 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -376,7 +376,7 @@ void DoorWarp1_ChooseInitialAction(DoorWarp1* this, PlayState* play) { void DoorWarp1_AwaitClearFlag(DoorWarp1* this, PlayState* play) { if (Flags_GetTempClear(play, this->actor.room)) { this->warpTimer = 200; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS_CLEAR); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS_CLEAR); DoorWarp1_SetupAction(this, func_809995D4); } } diff --git a/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c b/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c index e5b6539ff2..bd8ad7a782 100644 --- a/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c +++ b/src/overlays/actors/ovl_En_Dnt_Demo/z_en_dnt_demo.c @@ -159,7 +159,7 @@ void EnDntDemo_Judge(EnDntDemo* this, PlayState* play) { if (!GET_ITEMGETINF(ITEMGETINF_1E)) { reaction = DNT_SIGNAL_CELEBRATE; this->prize = DNT_PRIZE_STICK; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_SARIA_THEME); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_SARIA_THEME); break; } FALLTHROUGH; @@ -208,17 +208,17 @@ void EnDntDemo_Judge(EnDntDemo* this, PlayState* play) { this->action = sResultValues[resultIdx][1]; switch (this->action) { case DNT_ACTION_LOW_RUPEES: - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_COURTYARD); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_COURTYARD); break; case DNT_ACTION_ATTACK: if (this->subCamId != SUB_CAM_ID_DONE) { this->subCamId = SUB_CAM_ID_DONE; OnePointCutscene_Init(play, 2350, -99, &this->scrubs[3]->actor, CAM_ID_MAIN); } - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 8, NA_BGM_ENEMY); break; case DNT_ACTION_DANCE: - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_SHOP); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_SHOP); break; } osSyncPrintf("\n\n"); diff --git a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c index 9e97ea5a8c..0ef7cb61a8 100644 --- a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c +++ b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c @@ -358,7 +358,7 @@ void EnDntJiji_Return(EnDntJiji* this, PlayState* play) { if ((this->stage->actor.update != NULL) && (this->stage->leaderSignal == DNT_SIGNAL_NONE)) { this->stage->leaderSignal = DNT_SIGNAL_HIDE; this->stage->action = DNT_ACTION_ATTACK; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 8, NA_BGM_ENEMY); } } this->actor.speedXZ = 0.0f; diff --git a/src/overlays/actors/ovl_En_Eg/z_en_eg.c b/src/overlays/actors/ovl_En_Eg/z_en_eg.c index 0f20f07565..8e007d9e71 100644 --- a/src/overlays/actors/ovl_En_Eg/z_en_eg.c +++ b/src/overlays/actors/ovl_En_Eg/z_en_eg.c @@ -52,7 +52,7 @@ void func_809FFDC8(EnEg* this, PlayState* play) { // Void the player out Play_TriggerRespawn(play); gSaveContext.respawnFlag = -2; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); play->transitionType = TRANS_TYPE_FADE_BLACK; EnEg_PlayVoidOutSFX(); voided = true; 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 2463adb389..5f703ff8cb 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -2548,7 +2548,7 @@ void EnHorse_UpdateHorsebackArchery(EnHorse* this, PlayState* play) { if ((play->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) { if (this->hbaFlags & 4) { this->hbaFlags &= ~4; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); } } 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 ba0b382f40..933c71617e 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 @@ -182,7 +182,7 @@ s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, PlayState* play) if (this->playerFinish > 0) { this->result = INGORACE_PLAYER_WIN; this->finishTimer = 55; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); Audio_PlaySfxGeneral(NA_SE_SY_START_SHOT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } @@ -198,7 +198,7 @@ s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, PlayState* play) this->result = INGORACE_INGO_WIN; this->finishTimer = 70; ingoHorse->stateFlags |= ENHORSE_INGO_WON; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); Audio_PlaySfxGeneral(NA_SE_SY_START_SHOT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } @@ -207,12 +207,12 @@ s32 EnHorseGameCheck_UpdateIngoRace(EnHorseGameCheckBase* base, PlayState* play) } } if (((player2->rideActor != NULL) && AT_RANCH_EXIT(player2->rideActor)) || AT_RANCH_EXIT(&player2->actor)) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); this->result = INGORACE_INGO_WIN; this->finishTimer = 20; } if ((gSaveContext.timer1Value >= 180) && (this->startFlags & 2)) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); this->result = INGORACE_TIME_UP; this->finishTimer = 20; } @@ -378,7 +378,7 @@ s32 EnHorseGameCheck_UpdateMalonRace(EnHorseGameCheckBase* base, PlayState* play this->finishTimer = 30; } else if (this->fenceCheck[15] == 1) { this->lapCount = 2; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HORSE_GOAL); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_HORSE_GOAL); Audio_PlaySfxGeneral(NA_SE_SY_START_SHOT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); this->result = MALONRACE_SUCCESS; diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index e1713e2763..b71f566213 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -93,7 +93,7 @@ void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, PlayState* play) { play->envCtx.precipitation[PRECIP_SOS_MAX] = 0; if (play->csCtx.state == CS_STATE_IDLE) { Environment_StopStormNatureAmbience(play); - } else if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) == NA_BGM_NATURE_AMBIENCE) { + } else if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_NATURE_AMBIENCE) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_1, 0); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 0); } diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index 66b49d19f1..9bae7993a9 100644 --- a/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -243,7 +243,7 @@ void func_80ABF4C8(EnOkarinaTag* this, PlayState* play) { case 2: play->csCtx.segment = D_80ABF9D0; gSaveContext.cutsceneTrigger = 1; - func_800F574C(1.18921f, 0x5A); + func_800F574C(1.18921f, 90); break; case 4: play->csCtx.segment = D_80ABFB40; 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 42defa3100..49e8fe6059 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -340,7 +340,7 @@ void func_80ACA76C(EnOwl* this, PlayState* play) { func_8002DF54(play, &this->actor, 8); if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_80ACA62C(this, play); this->actor.flags &= ~ACTOR_FLAG_16; } @@ -350,7 +350,7 @@ void func_80ACA7E0(EnOwl* this, PlayState* play) { func_8002DF54(play, &this->actor, 8); if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); if ((this->unk_3EE & 0x3F) == 0) { func_80ACA62C(this, play); } else { @@ -550,7 +550,7 @@ void func_80ACB03C(EnOwl* this, PlayState* play) { func_8002DF54(play, &this->actor, 8); if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_80ACA62C(this, play); this->actor.flags &= ~ACTOR_FLAG_16; } @@ -579,7 +579,7 @@ void EnOwl_WaitZoraRiver(EnOwl* this, PlayState* play) { void func_80ACB148(EnOwl* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_80ACA5C8(this); this->actionFunc = func_80ACC30C; Flags_SetSwitch(play, 0x23); @@ -600,7 +600,7 @@ void EnOwl_WaitHyliaShortcut(EnOwl* this, PlayState* play) { void func_80ACB22C(EnOwl* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); func_80ACA5C8(this); this->actionFunc = func_80ACC30C; } @@ -608,7 +608,7 @@ void func_80ACB22C(EnOwl* this, PlayState* play) { void func_80ACB274(EnOwl* this, PlayState* play) { if (Actor_TextboxIsClosing(&this->actor, play)) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_FANFARE << 24 | 0xFF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); this->actionFunc = EnOwl_WaitDeathMountainShortcut; } } 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 ccc3bc509e..bb1e656eb4 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 @@ -505,6 +505,6 @@ void EnSyatekiMan_Draw(Actor* thisx, PlayState* play) { void EnSyatekiMan_SetBgm(void) { if (BREG(80)) { BREG(80) = false; - Audio_QueueSeqCmd(sBgmList[BREG(81)]); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, sBgmList[BREG(81)]); } } diff --git a/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/src/overlays/actors/ovl_En_Ta/z_en_ta.c index 1fc9cbb5ae..b6b9e2c054 100644 --- a/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ b/src/overlays/actors/ovl_En_Ta/z_en_ta.c @@ -708,7 +708,7 @@ void func_80B154FC(EnTa* this, PlayState* play) { this->unk_2E0 &= ~0x10; this->unk_2E0 &= ~0x100; SET_EVENTINF(EVENTINF_HORSES_08); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); this->unk_2E0 &= ~0x200; Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); return; @@ -737,7 +737,7 @@ void func_80B154FC(EnTa* this, PlayState* play) { } if (gSaveContext.timer1Value == 0 && !Play_InCsMode(play)) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); this->unk_2E0 &= ~0x200; func_80078884(NA_SE_SY_FOUND); gSaveContext.timer1State = 0; diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index d88d7742ab..e704160da4 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -241,7 +241,7 @@ void EnViewer_UpdateImpl(EnViewer* this, PlayState* play) { } } if (play->csCtx.frames == 1020) { - Audio_QueueSeqCmd(SEQ_PLAYER_FANFARE << 24 | NA_BGM_OPENING_GANON); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_FANFARE, 0, 0, NA_BGM_OPENING_GANON); } if (play->csCtx.frames == 960) { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_GROAN, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 0ca2474fc1..91c99fd4e5 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -86,7 +86,7 @@ void EnZl3_Destroy(Actor* thisx, PlayState* play) { } void func_80B53468(void) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ESCAPE); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_ESCAPE); } BossGanon2* func_80B53488(EnZl3* this, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c b/src/overlays/actors/ovl_En_fHG/z_en_fhg.c index 94f88ef272..c253f9906e 100644 --- a/src/overlays/actors/ovl_En_fHG/z_en_fhg.c +++ b/src/overlays/actors/ovl_En_fHG/z_en_fhg.c @@ -142,7 +142,7 @@ void EnfHG_Intro(EnfHG* this, PlayState* play) { } if (this->timers[0] == 51) { Audio_PlayActorSfx2(this->actor.child, NA_SE_EV_SPEAR_FENCE); - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } if (this->timers[0] == 0) { EnfHG_SetupApproach(this, play, Rand_ZeroOne() * 5.99f); @@ -158,7 +158,7 @@ void EnfHG_Intro(EnfHG* this, PlayState* play) { this->cutsceneState = INTRO_FENCE; this->timers[0] = 60; this->actor.world.pos.y = GND_BOSSROOM_CENTER_Y - 7.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); SET_EVENTCHKINF(EVENTCHKINF_72); Flags_SetSwitch(play, 0x23); FALLTHROUGH; @@ -195,7 +195,7 @@ void EnfHG_Intro(EnfHG* this, PlayState* play) { func_8002DF54(play, &this->actor, 9); } if (this->timers[0] == 1) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_OPENING_GANON); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_OPENING_GANON); } Math_ApproachF(&this->subCamEye.x, GND_BOSSROOM_CENTER_X + 40.0f, 0.05f, this->subCamVelFactor * 20.0f); Math_ApproachF(&this->subCamEye.y, GND_BOSSROOM_CENTER_Y + 37.0f, 0.05f, this->subCamVelFactor * 20.0f); @@ -284,7 +284,7 @@ void EnfHG_Intro(EnfHG* this, PlayState* play) { this->bossGndSignal = FHG_RIDE; } if (this->timers[0] == 130) { - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x5000FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 80); } if (this->timers[0] == 30) { bossGnd->work[GND_EYE_STATE] = GND_EYESTATE_BRIGHTEN; @@ -297,7 +297,7 @@ void EnfHG_Intro(EnfHG* this, PlayState* play) { func_80078914(&audioVec, NA_SE_EN_FANTOM_ST_LAUGH); } if (this->timers[0] == 20) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_BOSS); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } if (this->timers[0] == 2) { this->subCamVelFactor = 0.0f; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index ab0754b0a9..a90b22a57d 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -867,7 +867,7 @@ void Fishing_Init(Actor* thisx, PlayState* play2) { D_80B7E0AC = 0; D_80B7E0A6 = 10; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x0100FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1); if (sLinkAge == LINK_AGE_CHILD) { if ((HIGH_SCORE(HS_FISHING) & 0x7F) != 0) { @@ -3586,7 +3586,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { this->unk_198 = 1.7f; this->unk_19C = 7000.0f; D_80B7E124 = 1; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ENEMY | 0x800); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 8, NA_BGM_ENEMY); D_80B7E0A6 = 0; if (this->unk_150 == 1) { @@ -3791,7 +3791,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } else { D_80B7E086 = 0x4082; Rumble_Override(0.0f, 1, 3, 1); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x0A00FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); } this->unk_158 = this->unk_15A = 0; @@ -3859,7 +3859,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { } if (this->unk_17A[0] == 90) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_HEART_GET | 0x900); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_HEART_GET); D_80B7A67C = 40; if (this->unk_150 == 0) { @@ -3974,7 +3974,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play2) { D_80B7E148 = 520.0f; D_80B7E144 = 195.0f; - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA00FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10); D_80B7E0A6 = 20; D_80B7A6CC = 3; } @@ -5207,7 +5207,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { D_80B7A6CC = 20; Rumble_Override(0.0f, 150, 10, 10); func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x1400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } if (KREG(0) != 0) { @@ -5216,7 +5216,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { D_80B7A6CC = 20; Rumble_Override(0.0f, 150, 10, 10); func_80078884(NA_SE_SY_TRE_BOX_APPEAR); - Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0x1400FF); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 20); } if (D_80B7A6D0 != 0) { @@ -5432,7 +5432,7 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { case 22: if (D_80B7A6D0 == 30) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_ITEM_GET | 0x900); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 9, NA_BGM_ITEM_GET); } D_80B7A6D4 = 1; @@ -5741,15 +5741,15 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { if (D_80B7E0A6 == 0) { if (sLinkAge != LINK_AGE_CHILD) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KAKARIKO_ADULT); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_ADULT); } else { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KAKARIKO_KID); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_KID); } if (sLinkAge != LINK_AGE_CHILD) { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KAKARIKO_ADULT); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_ADULT); } else { - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_KAKARIKO_KID); + SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_KAKARIKO_KID); } } } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 0517ee4b29..4edafa678b 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1894,6 +1894,6 @@ void FileSelect_Init(GameState* thisx) { this->state.destroy = FileSelect_Destroy; FileSelect_InitContext(&this->state); Font_LoadOrderedFont(&this->font); - Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); + SEQCMD_RESET_AUDIO_HEAP(0, 10); func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1); } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 7fa97d93db..2a7aee5eec 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, s32 entranceIndex) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0; - Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | NA_BGM_STOP); + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0); gSaveContext.entranceIndex = entranceIndex; gSaveContext.respawnFlag = 0; gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = ENTR_LOAD_OPENING; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 0cac739acf..cfdb53cf85 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -3410,7 +3410,7 @@ void KaleidoScope_Update(PlayState* play) { gSaveContext.respawnFlag = -2; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.health = 0x30; - Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); + SEQCMD_RESET_AUDIO_HEAP(0, 10); gSaveContext.healthAccumulator = 0; gSaveContext.magicState = MAGIC_STATE_IDLE; gSaveContext.prevMagicState = MAGIC_STATE_IDLE;