Audio Sequences Decompiled & Documented (z_obj_sound OK, more code_8019AF00.c) (#1407)

* import audio docs

* cleanup

* SEQ_SCREEN_WEIGHTED_DIST

* PR

* PR
This commit is contained in:
engineer124
2023-10-14 07:39:10 +11:00
committed by GitHub
parent 576cf6964c
commit 93713a1da0
15 changed files with 583 additions and 112 deletions
+455 -26
View File
@@ -77,10 +77,10 @@ void Audio_PlayAmbience(u8 ambienceId);
void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume);
void Audio_UpdateRiverSoundVolumes(void);
void func_801A1290(void);
void func_801A1904(void);
void func_801A1E0C(void);
void func_801A2090(void);
void Audio_UpdateObjSoundProperties(void);
void Audio_UpdateObjSoundFanfare(void);
void Audio_UpdateSubBgmAtPos(void);
void Audio_UpdateSequenceAtPos(void);
void Audio_UpdateSceneSequenceResumePoint(void);
void func_801A312C(void);
void func_801A3AC0(void);
@@ -116,7 +116,14 @@ u8 sRiverSoundBgmTimer;
u8 sFanfareState;
u16 sFanfareSeqId;
u8 sMuteOnlySfxAndAmbienceSeq;
u8 sAllPlayersMutedExceptOcaAndSys;
u8 sAllPlayersMutedExceptSystemAndOcarina;
typedef enum {
/* 0 */ AUDIO_PAUSE_STATE_CLOSED,
/* 1 */ AUDIO_PAUSE_STATE_CLOSING,
/* 2 */ AUDIO_PAUSE_STATE_OPEN
} AudioPauseState;
u8 sAudioPauseState;
u8 sSpatialSeqIsActive[4];
u8 sSequenceFilter[8 * 4];
@@ -237,6 +244,10 @@ Vec3f* sRiverSoundBgmPos = NULL;
f32 sRiverSoundXZDistToPlayer = 2000.0f;
u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX;
// Weights distance strongest by depth (z), weaker by left/right screen (x), and weakest by top/bottom screen (y)
#define SEQ_SCREEN_WEIGHTED_DIST(projectedPos) \
(sqrtf(SQ((projectedPos)->z) + ((SQ((projectedPos)->x) / 4.0f) + (SQ((projectedPos)->y) / 6.0f))))
// Allows enemy bgm
#define SEQ_FLAG_ENEMY (1 << 0)
@@ -3639,11 +3650,11 @@ void Audio_Update(void) {
Audio_UpdateSceneSequenceResumePoint();
func_801A312C();
Audio_UpdateSfxVolumeTransition();
func_801A1E0C();
func_801A1904();
func_801A2090();
Audio_UpdateSubBgmAtPos();
Audio_UpdateObjSoundFanfare();
Audio_UpdateSequenceAtPos();
func_801A3AC0();
func_801A1290();
Audio_UpdateObjSoundProperties();
Audio_ResetRequestedSceneSeqId();
AudioSfx_ProcessRequests();
AudioSeq_ProcessSeqCmds();
@@ -4870,37 +4881,455 @@ void Audio_SplitBgmChannels(s8 volumeSplit) {
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s")
void Audio_SetSequenceProperties(u8 seqPlayerIndex, Vec3f* projectedPos, s16 flags, f32 minDist, f32 maxDist,
f32 maxVolume, f32 minVolume) {
f32 dist;
f32 volume;
s8 surroundEffectIndex;
s8 pan;
s32 pad;
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1290.s")
// calculating surround sound effect from screen depth
if (projectedPos->z > 0.0f) {
if (projectedPos->z > 100.0f) {
surroundEffectIndex = 0;
} else {
surroundEffectIndex = ((100.0f - projectedPos->z) / 100.0f) * 64.0f;
}
} else {
if (projectedPos->z < -100.0f) {
surroundEffectIndex = 0x7F;
} else {
surroundEffectIndex = (s8)((-projectedPos->z / 100.0f) * 64.0f) + 0x3F;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1348.s")
// calculating pan from left-right screen position
if (projectedPos->x > 0.0f) {
if (projectedPos->x > 200.0f) {
pan = 0x6C;
} else {
pan = (s8)((projectedPos->x / 200.0f) * 45.0f) + 0x3F;
}
} else {
if (projectedPos->x < -200.0f) {
pan = 0x14;
} else {
pan = (s8)(((projectedPos->x + 200.0f) / 200.0f) * 44.0f) + 0x14;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A13BC.s")
// Calculate weighted volume
dist = SEQ_SCREEN_WEIGHTED_DIST(projectedPos);
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A153C.s")
if (dist > maxDist) {
volume = minVolume;
} else if (dist < minDist) {
volume = 1.0f;
} else {
volume = (((maxDist - dist) / (maxDist - minDist)) * (1.0f - minVolume)) + minVolume;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A17F4.s")
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, 0xFFFF);
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1904.s")
if (flags & 1) {
AUDIOCMD_CHANNEL_SET_SURROUND_EFFECT_INDEX(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, surroundEffectIndex);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1A10.s")
if (flags & 2) {
AUDIOCMD_CHANNEL_SET_PAN(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, pan);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1A8C.s")
if (flags & 4) {
AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0x7F);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1D44.s")
// applies filter, stores result in sSequenceFilter
if (flags & 8) {
// Uses new filter gBandPassFilterData
AUDIOCMD_CHANNEL_SET_FILTER(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0x54,
((u32)&sSequenceFilter[0] & ~0xF) + 0x10);
} else {
// Identity Filter
AUDIOCMD_CHANNEL_SET_FILTER(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0, ((u32)&sSequenceFilter[0] & ~0xF) + 0x10);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1DB8.s")
if (flags & 0x10) {
AUDIOCMD_CHANNEL_SET_GAIN(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0x7F);
} else {
AUDIOCMD_CHANNEL_SET_GAIN(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1E0C.s")
if (flags & 0x20) {
AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, maxVolume * volume);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1F00.s")
if (flags & 0x40) {
AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 0x40);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1F88.s")
if (flags & 0x80) {
AUDIOCMD_CHANNEL_SET_REVERB_INDEX(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 1);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A1FB4.s")
if (flags & 0x100) {
AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, 55);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2090.s")
// ======== BEGIN Z_OBJ_SOUND FUNCTIONS ========
/**
* Used for Main Bgm and Fanfares
*/
void Audio_UpdateObjSoundProperties(void) {
if (sObjSoundPlayerIndex != SEQ_PLAYER_INVALID) {
if ((AudioSeq_GetActiveSeqId(sObjSoundPlayerIndex) != NA_BGM_FINAL_HOURS) &&
AudioSeq_IsSeqCmdNotQueued((sObjSoundPlayerIndex << 24) + NA_BGM_FINAL_HOURS,
SEQCMD_OP_MASK | SEQCMD_ASYNC_ACTIVE | SEQCMD_SEQPLAYER_MASK |
SEQCMD_SEQID_MASK) &&
!sIsFinalHoursOrSoaring) {
Audio_SetSequenceProperties(sObjSoundPlayerIndex, &sObjSoundPos, sObjSoundFlags, sObjSoundMinDist,
sObjSoundMaxDist, sObjSoundMaxVol, sObjSoundMinVol);
}
sObjSoundPlayerIndex = SEQ_PLAYER_INVALID;
}
}
/**
* Used for Main Bgm and Fanfares
*/
void Audio_SetObjSoundProperties(u8 seqPlayerIndex, Vec3f* pos, s16 flags, f32 minDist, f32 maxDist, f32 maxVolume,
f32 minVolume) {
sObjSoundPlayerIndex = seqPlayerIndex;
sObjSoundPos.x = pos->x;
sObjSoundPos.y = pos->y;
sObjSoundPos.z = pos->z;
sObjSoundFlags = flags;
sObjSoundMinDist = minDist;
sObjSoundMaxDist = maxDist;
sObjSoundMaxVol = maxVolume;
sObjSoundMinVol = minVolume;
}
void Audio_StartObjSoundFanfare(u8 seqPlayerIndex, Vec3f* pos, s8 seqId, u16 seqIdOffset) {
s32 pad[3];
u32 mask;
if ((AudioSeq_GetActiveSeqId(seqPlayerIndex) == NA_BGM_FINAL_HOURS) ||
!AudioSeq_IsSeqCmdNotQueued((seqPlayerIndex << 0x18) + NA_BGM_FINAL_HOURS,
SEQCMD_OP_MASK | SEQCMD_ASYNC_ACTIVE | SEQCMD_SEQPLAYER_MASK | SEQCMD_SEQID_MASK) ||
sIsFinalHoursOrSoaring) {
sIsFinalHoursOrSoaring = true;
} else if (pos != NULL) {
if ((seqId != (s8)(AudioSeq_GetActiveSeqId(seqPlayerIndex) & 0xFFFF)) &&
!gAudioCtx.seqPlayers[seqPlayerIndex].enabled && (sObjSoundMainBgmSeqId == NA_BGM_GENERAL_SFX)) {
mask = 0xFFFF;
SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, ((((AudioThread_NextRandom() % 30) & 0xFF) + 1)),
((seqId & mask) + seqIdOffset));
sObjSoundMainBgmSeqId = seqId;
}
Audio_SetObjSoundProperties(seqPlayerIndex, pos, 0x7F, 320.0f, 1280.0f, 1.0f, 0.0f);
} else {
SEQCMD_STOP_SEQUENCE(seqPlayerIndex, 5);
}
}
void Audio_PlayObjSoundBgm(Vec3f* pos, s8 seqId) {
s32 pad[2];
u16 sp36;
s32 sp2C;
u16 seqId0 = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
u32 temp_a0;
if ((seqId0 == NA_BGM_FINAL_HOURS) ||
!AudioSeq_IsSeqCmdNotQueued(NA_BGM_FINAL_HOURS,
SEQCMD_OP_MASK | SEQCMD_ASYNC_ACTIVE | SEQCMD_SEQPLAYER_MASK | SEQCMD_SEQID_MASK) ||
sIsFinalHoursOrSoaring) {
sIsFinalHoursOrSoaring = true;
return;
}
if (seqId0 == NA_BGM_SONG_OF_SOARING) {
sIsFinalHoursOrSoaring = true;
}
if (pos != NULL) {
if (seqId == NA_BGM_ASTRAL_OBSERVATORY) {
if ((seqId != (u8)(seqId0 & 0xFF)) && !sAllPlayersMutedExceptSystemAndOcarina) {
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, (u16)seqId);
sObjSoundMainBgmSeqId = seqId;
} else if ((seqId == (u8)(seqId0 & 0xFF)) && (sObjSoundMainBgmSeqId == NA_BGM_GENERAL_SFX)) {
sObjSoundMainBgmSeqId = seqId;
}
Audio_SetObjSoundProperties(SEQ_PLAYER_BGM_MAIN, pos, 0x20, 100.0f, 1500.0f, 0.9f, 0.0f);
} else {
if (sObjSoundMainBgmSeqId == NA_BGM_GENERAL_SFX) {
temp_a0 = ((((AudioThread_NextRandom() % 30) & 0xFF) + 1) << 0x10) | ((u16)seqId + 0x7F00);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, temp_a0);
sObjSoundMainBgmSeqId = seqId;
}
if (seqId == NA_BGM_MILK_BAR_DUPLICATE) {
Audio_SetObjSoundProperties(SEQ_PLAYER_BGM_MAIN, pos, 0x1E3, 0.0f, 600.0f, 0.9f, 0.55f);
} else if (seqId == NA_BGM_MILK_BAR) {
Audio_SetObjSoundProperties(SEQ_PLAYER_BGM_MAIN, pos, 0x1FF, 0.0f, 600.0f, 0.9f, 0.55f);
} else {
Audio_SetObjSoundProperties(SEQ_PLAYER_BGM_MAIN, pos, 0x3F, 0.0f, 600.0f, 0.9f, 0.55f);
}
}
} else {
if (sObjSoundMainBgmSeqId == NA_BGM_ASTRAL_OBSERVATORY) {
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(SEQ_PLAYER_BGM_MAIN, 0xFFFF);
AUDIOCMD_CHANNEL_SET_VOL_SCALE(SEQ_PLAYER_BGM_MAIN, AUDIOCMD_ALL_CHANNELS, 1.0f);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 10, NA_BGM_CAVERN);
} else {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 5);
}
sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX;
}
}
void Audio_PlayObjSoundFanfare(Vec3f* pos, s8 seqId) {
s32 requestFanfare = false;
s32 pad;
if (sObjSoundFanfareSeqId == NA_BGM_GENERAL_SFX) {
// No spatial fanfare is currently playing
requestFanfare = true;
} else if (SEQ_SCREEN_WEIGHTED_DIST(pos) < SEQ_SCREEN_WEIGHTED_DIST(&sObjSoundFanfarePos)) {
// The spatial fanfare requested is closer than the spatial fanfare currently playing
requestFanfare = true;
}
if (requestFanfare) {
sObjSoundFanfarePos.x = pos->x;
sObjSoundFanfarePos.y = pos->y;
sObjSoundFanfarePos.z = pos->z;
sObjSoundFanfareSeqId = seqId;
sObjSoundFanfareRequested = true;
}
}
void Audio_UpdateObjSoundFanfare(void) {
if (sObjSoundFanfareRequested && (sAudioPauseState == AUDIO_PAUSE_STATE_CLOSED)) {
if (sObjSoundFanfareSeqId != NA_BGM_GENERAL_SFX) {
Audio_StartObjSoundFanfare(SEQ_PLAYER_FANFARE, &sObjSoundFanfarePos, sObjSoundFanfareSeqId, 0);
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) {
func_801A3038();
}
if ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) &&
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_AMBIENCE) == NA_BGM_DISABLED)) {
Audio_PlayAmbience(AMBIENCE_ID_09);
}
sAudioCutsceneFlag = true;
} else {
Audio_StartObjSoundFanfare(SEQ_PLAYER_FANFARE, NULL, sObjSoundFanfareSeqId, 0);
if (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) {
SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_AMBIENCE, 0);
}
sObjSoundFanfareRequested = false;
sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX;
sAudioCutsceneFlag = false;
}
sObjSoundFanfareSeqId = NA_BGM_GENERAL_SFX;
}
}
// ======== END Z_OBJ_SOUND FUNCTIONS ========
void Audio_StopSequenceAtPos(u8 seqPlayerIndex, u8 volumeFadeTimer) {
SEQCMD_STOP_SEQUENCE((u32)seqPlayerIndex, 20);
if ((seqPlayerIndex == SEQ_PLAYER_BGM_SUB) && (AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED)) {
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, 0x7F, volumeFadeTimer);
Audio_SplitBgmChannels(0);
}
}
void Audio_StartSubBgmAtPos(u8 seqPlayerIndex, Vec3f* projectedPos, u8 seqId, u8 flags, f32 minDist, f32 maxDist,
f32 arg6) {
f32 dist = SEQ_SCREEN_WEIGHTED_DIST(projectedPos);
u8 targetVolume;
u16 seqId0 = AudioSeq_GetActiveSeqId(seqPlayerIndex);
f32 relVolume;
s32 pad;
if (dist > maxDist) {
if ((u8)seqId0 == seqId) {
Audio_StopSequenceAtPos(seqPlayerIndex, 10);
sSpatialSeqIsActive[seqPlayerIndex] = false;
}
return;
}
if ((!gAudioCtx.seqPlayers[seqPlayerIndex].enabled && !sAllPlayersMutedExceptSystemAndOcarina) ||
(seqId0 == (NA_BGM_ENEMY | 0x800))) {
if (seqPlayerIndex == SEQ_PLAYER_BGM_SUB) {
AudioSeq_SetVolumeScale(seqPlayerIndex, VOL_SCALE_INDEX_BGM_SUB, 0x7F, 1);
}
SEQCMD_PLAY_SEQUENCE((u32)seqPlayerIndex, 1, seqId);
sSpatialSeqIsActive[seqPlayerIndex] = true;
}
Audio_SetSequenceProperties(seqPlayerIndex, projectedPos, flags, minDist, maxDist, 1.0, 0.05f);
if ((seqPlayerIndex == SEQ_PLAYER_BGM_SUB) && (gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].enabled == true)) {
if (dist > maxDist) {
relVolume = 1.0f;
} else if (dist < minDist) {
relVolume = 0.0f;
} else {
relVolume = 1.0f - ((maxDist - dist) / (maxDist - minDist));
}
targetVolume = (u8)(relVolume * 127.0f);
AudioSeq_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_SUB, targetVolume, 10);
Audio_SplitBgmChannels(0x7F - targetVolume);
}
}
/**
* sSpatialSeqNoFilterPos takes priority over sSpatialSeqFilterPos
* Used only by guru guru for song of storms
*/
void Audio_PlaySubBgmAtPos(Vec3f* pos, u8 seqId, f32 maxDist) {
if (gAudioSpecId != 0xC) {
sSpatialSeqNoFilterPos.x = pos->x;
sSpatialSeqNoFilterPos.y = pos->y;
sSpatialSeqNoFilterPos.z = pos->z;
sSpatialSeqSeqId = seqId;
sSpatialSeqMaxDist = maxDist;
sSpatialSeqFlags |= 2; // Only update volume
sSpatialSubBgmFadeTimer = 4;
}
}
// Used only by guru guru for song of storms in stock pot from hallway or neighboring room
void Audio_PlaySubBgmAtPosWithFilter(Vec3f* pos, u8 seqId, f32 maxDist) {
sSpatialSeqFilterPos.x = pos->x;
sSpatialSeqFilterPos.y = pos->y;
sSpatialSeqFilterPos.z = pos->z;
sSpatialSeqSeqId = seqId;
//! @bug Did not set sSpatialSeqMaxDist = maxDist; This will use the previously set value of sSpatialSeqMaxDist
sSpatialSeqFlags |= 1; // Update with volume and filter
sSpatialSubBgmFadeTimer = 4;
}
// Another bgm by pos, less customization
void Audio_UpdateSubBgmAtPos(void) {
if (sSpatialSubBgmFadeTimer != 0) {
if (sSpatialSeqFlags & 2) {
// Affects only volume
Audio_StartSubBgmAtPos(SEQ_PLAYER_BGM_SUB, &sSpatialSeqNoFilterPos, sSpatialSeqSeqId, 0x20, 100.0f,
sSpatialSeqMaxDist, 1.0f);
} else {
// Set volume with band-pass filter
Audio_StartSubBgmAtPos(SEQ_PLAYER_BGM_SUB, &sSpatialSeqFilterPos, sSpatialSeqSeqId, 0x28, 100.0f,
sSpatialSeqMaxDist, 1.0f);
}
sSpatialSubBgmFadeTimer--;
if (sSpatialSubBgmFadeTimer == 0) {
Audio_StopSequenceAtPos(SEQ_PLAYER_BGM_SUB, 10);
}
sSpatialSeqFlags = 0;
}
}
/**
* Play sequence at the default center of the screen. Does not check for final hours or soaring bgms playing
* Used only by minifrog for the frog song
*/
void Audio_PlaySequenceAtDefaultPos(u8 seqPlayerIndex, u16 seqId) {
if (!sAudioCutsceneFlag && (gAudioSpecId != 0xC)) {
sSpatialSeqFilterPos.x = gSfxDefaultPos.x;
sSpatialSeqFilterPos.y = gSfxDefaultPos.y;
sSpatialSeqFilterPos.z = gSfxDefaultPos.z;
sSpatialSeqMaxDist = 10000.0f;
sSpatialSeqFadeTimer = 128;
sSpatialSeqSeqId = seqId;
sSpatialSeqPlayerIndex = seqPlayerIndex;
}
}
// Used only by minifrog
void Audio_StopSequenceAtDefaultPos(void) {
if (gAudioSpecId != 0xC) {
sSpatialSeqFadeTimer = 1;
sSpatialSeqSeqId = NA_BGM_GENERAL_SFX;
}
}
/**
* Play the requested sequence at a position. Valid for sequences on players 0 - 3
*/
void Audio_PlaySequenceAtPos(u8 seqPlayerIndex, Vec3f* pos, u16 seqId, f32 maxDist) {
if ((!sAudioCutsceneFlag) && ((AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) & 0xFF) != NA_BGM_SONG_OF_SOARING) &&
(gAudioSpecId != 0xC) && (pos != NULL) &&
((sSpatialSeqPlayerIndex != SEQ_PLAYER_BGM_MAIN) ||
(AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_FINAL_HOURS))) {
sSpatialSeqFilterPos.x = pos->x;
sSpatialSeqFilterPos.y = pos->y;
sSpatialSeqFilterPos.z = pos->z;
sSpatialSeqMaxDist = maxDist;
sSpatialSeqFadeTimer = 2;
sSpatialSeqSeqId = seqId & 0xFF;
sSpatialSeqPlayerIndex = seqPlayerIndex;
}
}
void Audio_UpdateSequenceAtPos(void) {
u16 mainBgmSeqId = AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
u8 volumeFadeTimer;
if ((sSpatialSeqFadeTimer != 0) && (sAudioPauseState == AUDIO_PAUSE_STATE_CLOSED)) {
if ((sSpatialSeqSeqId == NA_BGM_GENERAL_SFX) || (mainBgmSeqId == NA_BGM_SONG_OF_SOARING)) {
volumeFadeTimer = 10;
if (mainBgmSeqId == NA_BGM_SONG_OF_SOARING) {
sSpatialSeqFadeTimer = 0;
volumeFadeTimer = 1;
} else if (sSpatialSeqFadeTimer < 128) {
sSpatialSeqFadeTimer--;
}
if (sSpatialSeqFadeTimer == 0) {
Audio_StopSequenceAtPos(sSpatialSeqPlayerIndex, volumeFadeTimer);
sSpatialSeqIsActive[sSpatialSeqPlayerIndex] = false;
}
} else {
if ((sSpatialSeqPlayerIndex == SEQ_PLAYER_BGM_MAIN) && (mainBgmSeqId == NA_BGM_FINAL_HOURS)) {
Audio_StopSequenceAtPos(sSpatialSeqPlayerIndex, 10);
sSpatialSeqIsActive[sSpatialSeqPlayerIndex] = false;
return;
}
Audio_StartSubBgmAtPos(sSpatialSeqPlayerIndex, &sSpatialSeqFilterPos, sSpatialSeqSeqId, 0x20, 200.0f,
sSpatialSeqMaxDist, 1.0f);
if (!sSpatialSeqIsActive[sSpatialSeqPlayerIndex]) {
sSpatialSeqFadeTimer = 0;
}
}
if (sSpatialSeqFadeTimer < 128) {
sSpatialSeqSeqId = NA_BGM_GENERAL_SFX;
}
}
}
/**
* Unused remnant of OoT's EnRiverSound
@@ -5408,7 +5837,7 @@ void Audio_StartSfxPlayer(void) {
void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume) {
u8 channelIndex;
if (!sAllPlayersMutedExceptOcaAndSys) {
if (!sAllPlayersMutedExceptSystemAndOcarina) {
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
switch (channelIndex) {
case SFX_CHANNEL_SYSTEM0:
+2 -2
View File
@@ -2767,11 +2767,11 @@ void Actor_UpdateFlaggedAudio(Actor* actor) {
if (sfxId != NA_SE_NONE) {}
if (actor->audioFlags & ACTOR_AUDIO_FLAG_SEQ_MUSIC_BOX_HOUSE) {
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f);
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &actor->projectedPos, NA_BGM_MUSIC_BOX_HOUSE, 1500.0f);
}
if (actor->audioFlags & ACTOR_AUDIO_FLAG_SEQ_KAMARO_DANCE) {
func_801A1FB4(SEQ_PLAYER_BGM_MAIN, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f);
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_MAIN, &actor->projectedPos, NA_BGM_KAMARO_DANCE, 900.0f);
}
}
@@ -350,12 +350,12 @@ void EnGuruguru_Update(Actor* thisx, PlayState* play) {
if (this->actor.params == 2) {
if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) {
func_801A1DB8(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f);
Audio_PlaySubBgmAtPosWithFilter(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f);
}
return;
}
if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) {
func_801A1D44(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f);
Audio_PlaySubBgmAtPos(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f);
}
if (this->unusedTimer != 0) {
this->unusedTimer--;
@@ -150,7 +150,7 @@ void EnMinifrog_Destroy(Actor* thisx, PlayState* play) {
Collider_DestroyCylinder(play, &this->collider);
if (this->flags & 0x100) {
func_801A1F88();
Audio_StopSequenceAtDefaultPos();
}
}
@@ -438,7 +438,7 @@ void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) {
this->actionFunc = EnMinifrog_NextFrogMissing;
this->timer = 60;
this->actor.home.rot.y = Actor_WorldYawTowardActor(&this->actor, &this->frog->actor);
func_801A1F88();
Audio_StopSequenceAtDefaultPos();
this->flags &= ~0x100;
this->flags &=
~(0x2 << FROG_YELLOW | 0x2 << FROG_CYAN | 0x2 << FROG_PINK | 0x2 << FROG_BLUE | 0x2 << FROG_WHITE);
@@ -460,7 +460,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, PlayState* play) {
CutsceneManager_Start(this->actor.csId, &this->actor);
this->actionFunc = EnMinifrog_SetupNextFrogChoir;
this->timer = 5;
func_801A1F00(3, NA_BGM_FROG_SONG);
Audio_PlaySequenceAtDefaultPos(SEQ_PLAYER_BGM_SUB, NA_BGM_FROG_SONG);
this->flags |= 0x100;
play->setPlayerTalkAnim(play, &gPlayerAnim_pn_gakkiplay, ANIMMODE_LOOP);
} else {
+10 -10
View File
@@ -417,7 +417,7 @@ void func_80BFC058(EnRz* this, PlayState* play) {
void func_80BFC078(EnRz* this, PlayState* play) {
s32 pad;
Vec3f sp28;
Vec3f seqPos;
EnRz_UpdateSkelAnime(this, play);
@@ -443,10 +443,10 @@ void func_80BFC078(EnRz* this, PlayState* play) {
}
if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) {
sp28.x = this->actor.projectedPos.x;
sp28.y = this->actor.projectedPos.y;
sp28.z = this->actor.projectedPos.z;
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_ROSA_SISTERS, 900.0f);
seqPos.x = this->actor.projectedPos.x;
seqPos.y = this->actor.projectedPos.y;
seqPos.z = this->actor.projectedPos.z;
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_ROSA_SISTERS, 900.0f);
}
}
@@ -504,7 +504,7 @@ void func_80BFC36C(EnRz* this, PlayState* play) {
void func_80BFC3F8(EnRz* this, PlayState* play) {
s32 pad;
Vec3f bgmPos;
Vec3f seqPos;
EnRz_UpdateSkelAnime(this, play);
@@ -544,10 +544,10 @@ void func_80BFC3F8(EnRz* this, PlayState* play) {
}
if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) {
bgmPos.x = this->actor.projectedPos.x;
bgmPos.y = this->actor.projectedPos.y;
bgmPos.z = this->actor.projectedPos.z;
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &bgmPos, NA_BGM_ROSA_SISTERS, 900.0f);
seqPos.x = this->actor.projectedPos.x;
seqPos.y = this->actor.projectedPos.y;
seqPos.z = this->actor.projectedPos.z;
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_ROSA_SISTERS, 900.0f);
}
}
}
+5 -5
View File
@@ -558,7 +558,7 @@ void func_80BA06BC(EnZob* this, PlayState* play) {
void func_80BA0728(EnZob* this, PlayState* play) {
s32 pad;
Vec3f sp28;
Vec3f seqPos;
func_80B9F86C(this);
@@ -585,10 +585,10 @@ void func_80BA0728(EnZob* this, PlayState* play) {
func_800B874C(&this->actor, play, 200.0f, 150.0f);
}
sp28.x = this->actor.projectedPos.x;
sp28.y = this->actor.projectedPos.y;
sp28.z = this->actor.projectedPos.z;
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_BASS_PLAY, 1000.0f);
seqPos.x = this->actor.projectedPos.x;
seqPos.y = this->actor.projectedPos.y;
seqPos.z = this->actor.projectedPos.z;
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_BASS_PLAY, 1000.0f);
}
void func_80BA08E8(EnZob* this, PlayState* play) {
+1 -1
View File
@@ -387,7 +387,7 @@ void EnZod_PlayDrumsSequence(EnZod* this, PlayState* play) {
seqPos.y = this->actor.projectedPos.y;
seqPos.z = this->actor.projectedPos.z;
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_DRUMS_PLAY, 700.0f);
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_DRUMS_PLAY, 700.0f);
}
void func_80BAFA44(EnZod* this, PlayState* play) {
+5 -5
View File
@@ -542,7 +542,7 @@ void func_80BBBD5C(EnZos* this, PlayState* play) {
void func_80BBBDE0(EnZos* this, PlayState* play) {
Actor* thisx = &this->actor;
Vec3f sp28;
Vec3f seqPos;
if (this->unk_2B6 & 1) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200);
@@ -578,10 +578,10 @@ void func_80BBBDE0(EnZos* this, PlayState* play) {
CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_10);
}
sp28.x = this->actor.projectedPos.x;
sp28.y = this->actor.projectedPos.y;
sp28.z = this->actor.projectedPos.z;
func_801A1FB4(SEQ_PLAYER_BGM_SUB, &sp28, NA_BGM_PIANO_PLAY, 1000.0f);
seqPos.x = this->actor.projectedPos.x;
seqPos.y = this->actor.projectedPos.y;
seqPos.z = this->actor.projectedPos.z;
Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &seqPos, NA_BGM_PIANO_PLAY, 1000.0f);
}
void func_80BBBFBC(EnZos* this, PlayState* play) {
@@ -1,7 +1,7 @@
/*
* File: z_obj_sound.c
* Overlay: ovl_Obj_Sound
* Description: Plays certain sounds (e.g., swamp waterfall noise)
* Description: An invisible point-source to play sounds, including sfx and sequences.
*/
#include "z_obj_sound.h"
@@ -13,8 +13,8 @@
void ObjSound_Init(Actor* thisx, PlayState* play);
void ObjSound_Destroy(Actor* thisx, PlayState* play);
void ObjSound_Update(Actor* thisx, PlayState* play);
void ObjSound_Draw(Actor* thisx, PlayState* play);
#if 0
ActorInit Obj_Sound_InitVars = {
ACTOR_OBJ_SOUND,
ACTORCAT_ITEMACTION,
@@ -27,12 +27,50 @@ ActorInit Obj_Sound_InitVars = {
(ActorFunc)NULL,
};
#endif
void ObjSound_Init(Actor* thisx, PlayState* play) {
ObjSound* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Sound/ObjSound_Init.s")
this->unk_144 = false;
this->soundType = OBJ_SOUND_GET_TYPE(&this->actor);
this->sfxType = OBJ_SOUND_GET_SFX_TYPE(&this->actor);
this->actor.params &= OBJ_SOUND_ID_MASK;
if (this->soundType == OBJ_SOUND_TYPE_FANFARE) {
this->actor.draw = ObjSound_Draw;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Sound/ObjSound_Destroy.s")
void ObjSound_Destroy(Actor* thisx, PlayState* play) {
ObjSound* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Sound/ObjSound_Update.s")
if (this->soundType == OBJ_SOUND_TYPE_BGM) {
Audio_PlayObjSoundBgm(NULL, NA_BGM_GENERAL_SFX);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Sound/func_8099AA84.s")
void ObjSound_Update(Actor* thisx, PlayState* play) {
ObjSound* this = THIS;
if (this->soundType == OBJ_SOUND_TYPE_SFX) {
if (this->sfxType != 0) {
Actor_PlaySfx_Flagged(&this->actor, gAudioEnvironmentalSfx[this->actor.params]);
} else {
Actor_PlaySfx_FlaggedCentered3(&this->actor, gAudioEnvironmentalSfx[this->actor.params]);
}
} else if (this->unk_144) {
if (this->soundType == OBJ_SOUND_TYPE_BGM) {
Audio_PlayObjSoundBgm(&this->actor.projectedPos, this->actor.params);
} else if (this->soundType == OBJ_SOUND_TYPE_FIXED_SFX) {
Audio_PlaySfx_AtFixedPos(&this->actor.projectedPos, gAudioEnvironmentalSfx[this->actor.params]);
}
} else {
this->unk_144 = true;
}
}
void ObjSound_Draw(Actor* thisx, PlayState* play) {
ObjSound* this = THIS;
if (CHECK_EVENTINF(EVENTINF_41) || CHECK_EVENTINF(EVENTINF_35)) {
Audio_PlayObjSoundFanfare(&this->actor.projectedPos, this->actor.params);
}
}
@@ -5,9 +5,22 @@
struct ObjSound;
#define OBJ_SOUND_GET_TYPE(thisx) (((thisx)->params >> 8) & 0xFF)
#define OBJ_SOUND_GET_SFX_TYPE(thisx) (((thisx)->params >> 7) & 1)
#define OBJ_SOUND_ID_MASK 0x7F
typedef enum {
/* 0 */ OBJ_SOUND_TYPE_SFX,
/* 1 */ OBJ_SOUND_TYPE_BGM,
/* 2 */ OBJ_SOUND_TYPE_FIXED_SFX,
/* 3 */ OBJ_SOUND_TYPE_FANFARE
} ObjSoundType;
typedef struct ObjSound {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x4];
/* 0x144 */ u8 unk_144;
/* 0x145 */ u8 sfxType;
/* 0x146 */ s16 soundType;
} ObjSound; // size = 0x148
#endif // Z_OBJ_SOUND_H