mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 22:44:30 +00:00
Document Sequence Modes and Related Functions (#1046)
* Document Audio_SetSequenceMode * Cleanup surrounding docs * format * Clean-up * fix capital `I` in `playeridx` * Dist -> DistSq * `SetCamModeAndSeqMode` -> `UpdateCamAndSeqModes` * Get rid of extra padding * PR Feedback
This commit is contained in:
parent
e635e34265
commit
79220ba58a
8 changed files with 268 additions and 134 deletions
|
@ -121,27 +121,134 @@ s8 sAudioCutsceneFlag = 0;
|
|||
s8 sSpecReverb = 0;
|
||||
s8 sAudioEnvReverb = 0;
|
||||
s8 sAudioCodeReverb = 0;
|
||||
u8 D_8013061C = 0;
|
||||
u8 sPrevSeqMode = 0;
|
||||
f32 sAudioEnemyDist = 0.0f;
|
||||
s8 sAudioEnemyVol = 127;
|
||||
u16 D_80130628 = NA_BGM_DISABLED;
|
||||
u8 D_8013062C = 0;
|
||||
u8 D_80130630 = NA_BGM_GENERAL_SFX;
|
||||
u32 D_80130634 = 0;
|
||||
u32 D_80130638 = 0;
|
||||
u32 sNumFramesStill = 0;
|
||||
u32 sNumFramesMoving = 0;
|
||||
u8 sAudioBaseFilter = 0;
|
||||
u8 sAudioExtraFilter = 0;
|
||||
u8 sAudioBaseFilter2 = 0;
|
||||
u8 sAudioExtraFilter2 = 0;
|
||||
Vec3f* sSariaBgmPtr = NULL;
|
||||
f32 D_80130650 = 2000.0f;
|
||||
u8 D_80130654 = 0;
|
||||
u8 D_80130658[0x70] = {
|
||||
2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 16, 0, 136,
|
||||
1, 0, 0, 32, 0, 0, 2, 4, 2, 2, 1, 16, 0, 0, 1, 2, 1, 0, 128, 0, 128, 0, 2, 2, 2, 2, 2, 2,
|
||||
136, 2, 0, 2, 17, 2, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 32, 0, 16, 2, 0, 0,
|
||||
4, 32, 64, 64, 1, 2, 2, 1, 1, 2, 0, 17, 0, 0, 128, 0, 128, 128, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0,
|
||||
u8 sSeqModeInput = 0;
|
||||
u8 sSeqFlags[0x6E] = {
|
||||
0x2, // NA_BGM_GENERAL_SFX
|
||||
0x1, // NA_BGM_NATURE_BACKGROUND
|
||||
0, // NA_BGM_FIELD_LOGIC
|
||||
0, // NA_BGM_FIELD_INIT
|
||||
0, // NA_BGM_FIELD_DEFAULT_1
|
||||
0, // NA_BGM_FIELD_DEFAULT_2
|
||||
0, // NA_BGM_FIELD_DEFAULT_3
|
||||
0, // NA_BGM_FIELD_DEFAULT_4
|
||||
0, // NA_BGM_FIELD_DEFAULT_5
|
||||
0, // NA_BGM_FIELD_DEFAULT_6
|
||||
0, // NA_BGM_FIELD_DEFAULT_7
|
||||
0, // NA_BGM_FIELD_DEFAULT_8
|
||||
0, // NA_BGM_FIELD_DEFAULT_9
|
||||
0, // NA_BGM_FIELD_DEFAULT_A
|
||||
0, // NA_BGM_FIELD_DEFAULT_B
|
||||
0, // NA_BGM_FIELD_ENEMY_INIT
|
||||
0, // NA_BGM_FIELD_ENEMY_1
|
||||
0, // NA_BGM_FIELD_ENEMY_2
|
||||
0, // NA_BGM_FIELD_ENEMY_3
|
||||
0, // NA_BGM_FIELD_ENEMY_4
|
||||
0, // NA_BGM_FIELD_STILL_1
|
||||
0, // NA_BGM_FIELD_STILL_2
|
||||
0, // NA_BGM_FIELD_STILL_3
|
||||
0, // NA_BGM_FIELD_STILL_4
|
||||
0x21, // NA_BGM_DUNGEON
|
||||
0x10, // NA_BGM_KAKARIKO_ADULT
|
||||
0, // NA_BGM_ENEMY
|
||||
0x88, // NA_BGM_BOSS
|
||||
0x1, // NA_BGM_INSIDE_DEKU_TREE
|
||||
0, // NA_BGM_MARKET
|
||||
0, // NA_BGM_TITLE
|
||||
0x20, // NA_BGM_LINK_HOUSE
|
||||
0, // NA_BGM_GAME_OVER
|
||||
0, // NA_BGM_BOSS_CLEAR
|
||||
0x2, // NA_BGM_ITEM_GET
|
||||
0x4, // NA_BGM_OPENING_GANON
|
||||
0x2, // NA_BGM_HEART_GET
|
||||
0x2, // NA_BGM_OCA_LIGHT
|
||||
0x1, // NA_BGM_JABU_JABU
|
||||
0x10, // NA_BGM_KAKARIKO_KID
|
||||
0, // NA_BGM_GREAT_FAIRY
|
||||
0, // NA_BGM_ZELDA_THEME
|
||||
0x1, // NA_BGM_FIRE_TEMPLE
|
||||
0x2, // NA_BGM_OPEN_TRE_BOX
|
||||
0x1, // NA_BGM_FOREST_TEMPLE
|
||||
0, // NA_BGM_COURTYARD
|
||||
0x80, // NA_BGM_GANON_TOWER
|
||||
0, // NA_BGM_LONLON
|
||||
0x80, // NA_BGM_GORON_CITY
|
||||
0, // NA_BGM_FIELD_MORNING
|
||||
0x2, // NA_BGM_SPIRITUAL_STONE
|
||||
0x2, // NA_BGM_OCA_BOLERO
|
||||
0x2, // NA_BGM_OCA_MINUET
|
||||
0x2, // NA_BGM_OCA_SERENADE
|
||||
0x2, // NA_BGM_OCA_REQUIEM
|
||||
0x2, // NA_BGM_OCA_NOCTURNE
|
||||
0x88, // NA_BGM_MINI_BOSS
|
||||
0x2, // NA_BGM_SMALL_ITEM_GET
|
||||
0, // NA_BGM_TEMPLE_OF_TIME
|
||||
0x2, // NA_BGM_EVENT_CLEAR
|
||||
0x11, // NA_BGM_KOKIRI
|
||||
0x2, // NA_BGM_OCA_FAIRY_GET
|
||||
0x1, // NA_BGM_SARIA_THEME
|
||||
0x1, // NA_BGM_SPIRIT_TEMPLE
|
||||
0, // NA_BGM_HORSE
|
||||
0, // NA_BGM_HORSE_GOAL
|
||||
0, // NA_BGM_INGO
|
||||
0x2, // NA_BGM_MEDALLION_GET
|
||||
0x2, // NA_BGM_OCA_SARIA
|
||||
0x2, // NA_BGM_OCA_EPONA
|
||||
0x2, // NA_BGM_OCA_ZELDA
|
||||
0x2, // NA_BGM_OCA_SUNS
|
||||
0x2, // NA_BGM_OCA_TIME
|
||||
0x2, // NA_BGM_OCA_STORM
|
||||
0, // NA_BGM_NAVI_OPENING
|
||||
0, // NA_BGM_DEKU_TREE_CS
|
||||
0, // NA_BGM_WINDMILL
|
||||
0, // NA_BGM_HYRULE_CS
|
||||
0x20, // NA_BGM_MINI_GAME
|
||||
0, // NA_BGM_SHEIK
|
||||
0x10, // NA_BGM_ZORA_DOMAIN
|
||||
0x2, // NA_BGM_APPEAR
|
||||
0, // NA_BGM_ADULT_LINK
|
||||
0, // NA_BGM_MASTER_SWORD
|
||||
0x4, // NA_BGM_INTRO_GANON
|
||||
0x20, // NA_BGM_SHOP
|
||||
0x40, // NA_BGM_CHAMBER_OF_SAGES
|
||||
0x40, // NA_BGM_FILE_SELECT
|
||||
0x1, // NA_BGM_ICE_CAVERN
|
||||
0x2, // NA_BGM_DOOR_OF_TIME
|
||||
0x2, // NA_BGM_OWL
|
||||
0x1, // NA_BGM_SHADOW_TEMPLE
|
||||
0x1, // NA_BGM_WATER_TEMPLE
|
||||
0x2, // NA_BGM_BRIDGE_TO_GANONS
|
||||
0, // NA_BGM_OCARINA_OF_TIME
|
||||
0x11, // NA_BGM_GERUDO_VALLEY
|
||||
0, // NA_BGM_POTION_SHOP
|
||||
0, // NA_BGM_KOTAKE_KOUME
|
||||
0x80, // NA_BGM_ESCAPE
|
||||
0, // NA_BGM_UNDERGROUND
|
||||
0x80, // NA_BGM_GANON_BATTLE_1
|
||||
0x80, // NA_BGM_GANON_BATTLE_2
|
||||
0, // NA_BGM_END_DEMO
|
||||
0, // NA_BGM_STAFF_1
|
||||
0, // NA_BGM_STAFF_2
|
||||
0, // NA_BGM_STAFF_3
|
||||
0, // NA_BGM_STAFF_4
|
||||
0, // NA_BGM_FIRE_BOSS
|
||||
0x8, // NA_BGM_MINI_GAME_2
|
||||
0, // NA_BGM_VARIOUS_SFX
|
||||
};
|
||||
|
||||
s8 sSpecReverbs[20] = { 0, 0, 0, 0, 0, 0, 0, 40, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
D_801306DC_s D_801306DC[20] = {
|
||||
|
@ -1480,7 +1587,7 @@ f32 D_80131C8C = 0.0f;
|
|||
|
||||
// === Audio Debugging ===
|
||||
|
||||
// These variables come between in-function statics in func_800EE824 and func_800F510C
|
||||
// These variables come between in-function statics in func_800EE824 and Audio_SplitBgmChannels
|
||||
|
||||
f32 sAudioUpdateDuration = 0.0f;
|
||||
f32 sAudioUpdateDurationMax = 0.0f;
|
||||
|
@ -2213,8 +2320,8 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
GfxPrint_Printf(printer, "SOUND GAME FRAME MAX %f", sAudioUpdateDurationMax);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 9);
|
||||
GfxPrint_Printf(printer, "SWITCH BGM MODE %d %d %d (FLAG %d)", D_8013061C, D_80130634, D_80130638,
|
||||
D_80130654);
|
||||
GfxPrint_Printf(printer, "SWITCH BGM MODE %d %d %d (FLAG %d)", sPrevSeqMode, sNumFramesStill,
|
||||
sNumFramesMoving, sSeqModeInput);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 10);
|
||||
GfxPrint_Printf(printer, "ENEMY DIST %f VOL %3d", sAudioEnemyDist, sAudioEnemyVol);
|
||||
|
@ -2639,7 +2746,7 @@ void AudioDebug_ProcessInput_BlkChgBgm(void) {
|
|||
if (CHECK_BTN_ANY(sDebugPadPress, BTN_DLEFT)) {
|
||||
sAudioBlkChgBgmWork[sAudioBlkChgBgmSel]--;
|
||||
if (sAudioBlkChgBgmSel == 1) {
|
||||
func_800F5E90(sAudioBlkChgBgmWork[1]);
|
||||
Audio_SetSequenceMode(sAudioBlkChgBgmWork[1]);
|
||||
; // might be a fake match?
|
||||
}
|
||||
}
|
||||
|
@ -2647,7 +2754,7 @@ void AudioDebug_ProcessInput_BlkChgBgm(void) {
|
|||
if (CHECK_BTN_ANY(sDebugPadPress, BTN_DRIGHT)) {
|
||||
sAudioBlkChgBgmWork[sAudioBlkChgBgmSel]++;
|
||||
if (sAudioBlkChgBgmSel == 1) {
|
||||
func_800F5E90(sAudioBlkChgBgmWork[1]);
|
||||
Audio_SetSequenceMode(sAudioBlkChgBgmWork[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3248,7 +3355,7 @@ void Audio_ResetSfxChannelState(void) {
|
|||
}
|
||||
|
||||
sSfxChannelState[SFX_PLAYER_CHANNEL_OCARINA].unk_0C = 0;
|
||||
D_8013061C = 0;
|
||||
sPrevSeqMode = 0;
|
||||
sAudioCodeReverb = 0;
|
||||
}
|
||||
|
||||
|
@ -3609,39 +3716,48 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) {
|
|||
}
|
||||
}
|
||||
|
||||
void func_800F510C(s8 volSplit) {
|
||||
u8 vol;
|
||||
u8 prio;
|
||||
/**
|
||||
* Turns on and off channels from both bgm players in a way that splits
|
||||
* equally between the two bgm channels. Split based on note priority
|
||||
*/
|
||||
void Audio_SplitBgmChannels(s8 volSplit) {
|
||||
u8 volume;
|
||||
u8 notePriority;
|
||||
u16 channelBits;
|
||||
u8 players[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB };
|
||||
u8 bgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB };
|
||||
u8 channelIdx;
|
||||
u8 i;
|
||||
u8 j;
|
||||
|
||||
if ((func_800FA0B4(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) &&
|
||||
(func_800FA0B4(SEQ_PLAYER_BGM_SUB) != NA_BGM_LONLON)) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(bgmPlayers); i++) {
|
||||
if (i == 0) {
|
||||
vol = volSplit;
|
||||
// Main Bgm SeqPlayer
|
||||
volume = volSplit;
|
||||
} else {
|
||||
vol = 0x7F - volSplit;
|
||||
// Sub Bgm SeqPlayer
|
||||
volume = 0x7F - volSplit;
|
||||
}
|
||||
|
||||
if (vol > 100) {
|
||||
prio = 11;
|
||||
} else if (vol < 20) {
|
||||
prio = 2;
|
||||
if (volume > 100) {
|
||||
notePriority = 11;
|
||||
} else if (volume < 20) {
|
||||
notePriority = 2;
|
||||
} else {
|
||||
prio = ((vol - 20) / 10) + 2;
|
||||
notePriority = ((volume - 20) / 10) + 2;
|
||||
}
|
||||
|
||||
channelBits = 0;
|
||||
for (j = 0; j < 0x10; j++) {
|
||||
if (gAudioContext.seqPlayers[players[i]].channels[j]->notePriority < prio) {
|
||||
channelBits += (1 << j);
|
||||
for (channelIdx = 0; channelIdx < 16; channelIdx++) {
|
||||
if (notePriority > gAudioContext.seqPlayers[bgmPlayers[i]].channels[channelIdx]->notePriority) {
|
||||
// If the note currently playing in the channel is a high enough priority,
|
||||
// then keep the channel on by setting a channelBit
|
||||
// If this condition fails, then the channel will be shut off
|
||||
channelBits += (1 << channelIdx);
|
||||
}
|
||||
}
|
||||
|
||||
Audio_SeqCmdA(players[i], channelBits);
|
||||
Audio_SeqCmdA(bgmPlayers[i], channelBits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3685,7 +3801,7 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) {
|
|||
}
|
||||
|
||||
if (seqId != NA_BGM_GREAT_FAIRY) {
|
||||
func_800F510C(vol);
|
||||
Audio_SplitBgmChannels(vol);
|
||||
}
|
||||
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, vol, 0);
|
||||
|
@ -3711,7 +3827,7 @@ void func_800F5550(u16 seqId) {
|
|||
Audio_QueueCmdS32(0xF8000000, 0);
|
||||
}
|
||||
|
||||
if ((D_80130658[D_80130630] & 0x20) && D_80130658[(seqId & 0xFF) & 0xFF] & 0x10) {
|
||||
if ((sSeqFlags[D_80130630] & 0x20) && sSeqFlags[(seqId & 0xFF) & 0xFF] & 0x10) {
|
||||
|
||||
if ((D_8013062C & 0x3F) != 0) {
|
||||
sp27 = 0x1E;
|
||||
|
@ -3721,9 +3837,9 @@ void func_800F5550(u16 seqId) {
|
|||
|
||||
D_8013062C = 0;
|
||||
} else {
|
||||
nv = (D_80130658[(seqId & 0xFF) & 0xFF] & 0x40) ? 1 : 0xFF;
|
||||
nv = (sSeqFlags[(seqId & 0xFF) & 0xFF] & 0x40) ? 1 : 0xFF;
|
||||
func_800F5E18(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, nv);
|
||||
if (!(D_80130658[seqId] & 0x20)) {
|
||||
if (!(sSeqFlags[seqId] & 0x20)) {
|
||||
D_8013062C = 0xC0;
|
||||
}
|
||||
}
|
||||
|
@ -3737,7 +3853,7 @@ void func_800F56A8(void) {
|
|||
|
||||
temp_v0 = func_800FA0B4(SEQ_PLAYER_BGM_MAIN);
|
||||
bvar = temp_v0 & 0xFF;
|
||||
if ((temp_v0 != NA_BGM_DISABLED) && ((D_80130658[bvar] & 0x10) != 0)) {
|
||||
if ((temp_v0 != NA_BGM_DISABLED) && (sSeqFlags[bvar] & 0x10)) {
|
||||
if (D_8013062C != 0xC0) {
|
||||
D_8013062C = gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3];
|
||||
} else {
|
||||
|
@ -3770,9 +3886,9 @@ void func_800F5918(void) {
|
|||
void func_800F595C(u16 arg0) {
|
||||
u8 arg0b = arg0 & 0xFF;
|
||||
|
||||
if (D_80130658[arg0b] & 2) {
|
||||
if (sSeqFlags[arg0b] & 2) {
|
||||
Audio_PlayFanfare(arg0);
|
||||
} else if (D_80130658[arg0b] & 4) {
|
||||
} else if (sSeqFlags[arg0b] & 4) {
|
||||
Audio_StartSeq(SEQ_PLAYER_FANFARE, 0, arg0);
|
||||
|
||||
} else {
|
||||
|
@ -3784,9 +3900,9 @@ void func_800F595C(u16 arg0) {
|
|||
void func_800F59E8(u16 arg0) {
|
||||
u8 arg0b = arg0 & 0xFF;
|
||||
|
||||
if (D_80130658[arg0b] & 2) {
|
||||
if (sSeqFlags[arg0b] & 2) {
|
||||
Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0);
|
||||
} else if (D_80130658[arg0b] & 4) {
|
||||
} else if (sSeqFlags[arg0b] & 4) {
|
||||
Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0);
|
||||
} else {
|
||||
Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0);
|
||||
|
@ -3796,9 +3912,9 @@ void func_800F59E8(u16 arg0) {
|
|||
s32 func_800F5A58(u8 arg0) {
|
||||
u8 phi_a1 = 0;
|
||||
|
||||
if (D_80130658[arg0 & 0xFF] & 2) {
|
||||
if (sSeqFlags[arg0 & 0xFF] & 2) {
|
||||
phi_a1 = 1;
|
||||
} else if (D_80130658[arg0 & 0xFF] & 4) {
|
||||
} else if (sSeqFlags[arg0 & 0xFF] & 4) {
|
||||
phi_a1 = 1;
|
||||
}
|
||||
|
||||
|
@ -3814,7 +3930,7 @@ void func_800F5ACC(u16 seqId) {
|
|||
|
||||
temp_v0 = func_800FA0B4(SEQ_PLAYER_BGM_MAIN);
|
||||
if ((temp_v0 & 0xFF) != NA_BGM_GANON_TOWER && (temp_v0 & 0xFF) != NA_BGM_ESCAPE && temp_v0 != seqId) {
|
||||
func_800F5E90(3);
|
||||
Audio_SetSequenceMode(SEQ_MODE_IGNORE);
|
||||
if (temp_v0 != NA_BGM_DISABLED) {
|
||||
D_80130628 = temp_v0;
|
||||
} else {
|
||||
|
@ -3826,7 +3942,7 @@ void func_800F5ACC(u16 seqId) {
|
|||
|
||||
void func_800F5B58(void) {
|
||||
if ((func_800FA0B4(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && (D_80130628 != NA_BGM_DISABLED) &&
|
||||
(D_80130658[func_800FA0B4(SEQ_PLAYER_BGM_MAIN) & 0xFF] & 8)) {
|
||||
(sSeqFlags[func_800FA0B4(SEQ_PLAYER_BGM_MAIN) & 0xFF] & 8)) {
|
||||
if (D_80130628 == NA_BGM_DISABLED) {
|
||||
Audio_SeqCmd1(SEQ_PLAYER_BGM_MAIN, 0);
|
||||
} else {
|
||||
|
@ -3908,77 +4024,83 @@ void func_800F5E18(u8 playerIdx, u16 seqId, u8 fadeTimer, s8 arg3, s8 arg4) {
|
|||
Audio_StartSeq(playerIdx, fadeTimer, seqId);
|
||||
}
|
||||
|
||||
void func_800F5E90(u8 arg0) {
|
||||
s32 phi_t0;
|
||||
u16 phi_t1;
|
||||
u8 phi_a3;
|
||||
void Audio_SetSequenceMode(u8 seqMode) {
|
||||
s32 volumeFadeInTimer;
|
||||
u16 seqId;
|
||||
u8 volumeFadeOutTimer;
|
||||
|
||||
D_80130654 = arg0;
|
||||
sSeqModeInput = seqMode;
|
||||
if (D_80130628 == NA_BGM_DISABLED) {
|
||||
if (sAudioCutsceneFlag) {
|
||||
arg0 = 3;
|
||||
}
|
||||
phi_t1 = D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254;
|
||||
if (phi_t1 == NA_BGM_FIELD_LOGIC && func_800FA0B4(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
|
||||
arg0 = 3;
|
||||
seqMode = SEQ_MODE_IGNORE;
|
||||
}
|
||||
|
||||
phi_a3 = phi_t1 & 0xFF;
|
||||
if ((phi_t1 == NA_BGM_DISABLED) || ((D_80130658[phi_a3] & 1) != 0) || ((D_8013061C & 0x7F) == 1)) {
|
||||
if (arg0 != (D_8013061C & 0x7F)) {
|
||||
if (arg0 == 1) {
|
||||
seqId = D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254;
|
||||
|
||||
if (seqId == NA_BGM_FIELD_LOGIC && func_800FA0B4(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
|
||||
seqMode = SEQ_MODE_IGNORE;
|
||||
}
|
||||
|
||||
if ((seqId == NA_BGM_DISABLED) || (sSeqFlags[(u8)(seqId & 0xFF)] & 1) ||
|
||||
((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY)) {
|
||||
if (seqMode != (sPrevSeqMode & 0x7F)) {
|
||||
if (seqMode == SEQ_MODE_ENEMY) {
|
||||
// Start playing enemy bgm
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol < 0) {
|
||||
phi_t0 = -(D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol);
|
||||
volumeFadeInTimer = -(D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol);
|
||||
} else {
|
||||
phi_t0 = D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol;
|
||||
volumeFadeInTimer = D_8016E750[SEQ_PLAYER_BGM_SUB].volScales[1] - sAudioEnemyVol;
|
||||
}
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, phi_t0);
|
||||
Audio_StartSeq(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800);
|
||||
if (phi_t1 != NA_BGM_NATURE_AMBIENCE) {
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sAudioEnemyVol) & 0xFF, 0xA);
|
||||
func_800F510C(sAudioEnemyVol);
|
||||
}
|
||||
} else {
|
||||
if ((D_8013061C & 0x7F) == 1) {
|
||||
Audio_SeqCmd1(SEQ_PLAYER_BGM_SUB, 10);
|
||||
if (arg0 == 3) {
|
||||
phi_a3 = 0;
|
||||
} else {
|
||||
phi_a3 = 10;
|
||||
}
|
||||
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, phi_a3);
|
||||
func_800F510C(0);
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, volumeFadeInTimer);
|
||||
Audio_StartSeq(SEQ_PLAYER_BGM_SUB, 10, NA_BGM_ENEMY | 0x800);
|
||||
|
||||
if (seqId != NA_BGM_NATURE_AMBIENCE) {
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (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);
|
||||
if (seqMode == SEQ_MODE_IGNORE) {
|
||||
volumeFadeOutTimer = 0;
|
||||
} else {
|
||||
volumeFadeOutTimer = 10;
|
||||
}
|
||||
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer);
|
||||
Audio_SplitBgmChannels(0);
|
||||
}
|
||||
|
||||
D_8013061C = arg0 + 0x80;
|
||||
sPrevSeqMode = seqMode + 0x80;
|
||||
}
|
||||
} else {
|
||||
if (arg0 == 0) {
|
||||
if (D_8013061C == 2) {
|
||||
D_80130638 = 0;
|
||||
// Hyrule Field will play slightly different bgm music depending on whether player is standing
|
||||
// still or moving. This is the logic to determine the transition between those two states
|
||||
if (seqMode == SEQ_MODE_DEFAULT) {
|
||||
if (sPrevSeqMode == SEQ_MODE_STILL) {
|
||||
sNumFramesMoving = 0;
|
||||
}
|
||||
D_80130634 = 0;
|
||||
D_80130638++;
|
||||
sNumFramesStill = 0;
|
||||
sNumFramesMoving++;
|
||||
} else {
|
||||
D_80130634++;
|
||||
sNumFramesStill++;
|
||||
}
|
||||
|
||||
if (arg0 == 2 && D_80130634 < 0x1E && D_80130638 >= 0x15) {
|
||||
arg0 = 0;
|
||||
if (seqMode == SEQ_MODE_STILL && sNumFramesStill < 30 && sNumFramesMoving > 20) {
|
||||
seqMode = SEQ_MODE_DEFAULT;
|
||||
}
|
||||
|
||||
D_8013061C = arg0;
|
||||
Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 2, arg0);
|
||||
sPrevSeqMode = seqMode;
|
||||
Audio_SeqCmd7(SEQ_PLAYER_BGM_MAIN, 2, seqMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_800F6114(f32 dist) {
|
||||
void Audio_SetBgmEnemyVolume(f32 dist) {
|
||||
f32 adjDist;
|
||||
|
||||
if (D_8013061C == 0x81) {
|
||||
if (sPrevSeqMode == (0x80 | SEQ_MODE_ENEMY)) {
|
||||
if (dist != sAudioEnemyDist) {
|
||||
if (dist < 150.0f) {
|
||||
adjDist = 0.0f;
|
||||
|
@ -3989,13 +4111,13 @@ void func_800F6114(f32 dist) {
|
|||
}
|
||||
|
||||
sAudioEnemyVol = ((350.0f - adjDist) * 127.0f) / 350.0f;
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_SUB, 3, sAudioEnemyVol, 0xA);
|
||||
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), 0xA);
|
||||
Audio_SetVolScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sAudioEnemyVol), 10);
|
||||
}
|
||||
}
|
||||
if (D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 != NA_BGM_NATURE_AMBIENCE) {
|
||||
func_800F510C(sAudioEnemyVol);
|
||||
Audio_SplitBgmChannels(sAudioEnemyVol);
|
||||
}
|
||||
}
|
||||
sAudioEnemyDist = dist;
|
||||
|
@ -4241,7 +4363,7 @@ void Audio_PreNMI(void) {
|
|||
}
|
||||
|
||||
void func_800F6C34(void) {
|
||||
D_8013061C = 0;
|
||||
sPrevSeqMode = 0;
|
||||
D_8016B7A8 = 1.0f;
|
||||
D_8016B7B0 = 1.0f;
|
||||
sAudioBaseFilter = 0;
|
||||
|
@ -4336,7 +4458,7 @@ void func_800F6FB4(u8 arg0) {
|
|||
u8 b2;
|
||||
|
||||
if ((D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254 == NA_BGM_DISABLED) ||
|
||||
((D_80130658[((u8)D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254) & 0xFF] & 0x80) == 0)) {
|
||||
!(sSeqFlags[((u8)D_8016E750[SEQ_PLAYER_BGM_MAIN].unk_254) & 0xFF] & 0x80)) {
|
||||
func_800F6E7C(D_801306DC[arg0].unk_00, D_801306DC[arg0].unk_02);
|
||||
while ((D_801306DC[arg0].unk_04[i] != 0xFF) && (i < 100)) {
|
||||
// Probably a fake match, using Audio_SeqCmd8 doesn't work.
|
||||
|
|
|
@ -391,14 +391,14 @@ void func_800FA174(u8 playerIdx) {
|
|||
D_8016E348[playerIdx] = 0;
|
||||
}
|
||||
|
||||
void func_800FA18C(u8 playeridx, u8 arg1) {
|
||||
void func_800FA18C(u8 playerIdx, u8 arg1) {
|
||||
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 < D_8016E750[playerIdx].unk_4D; i++) {
|
||||
u8 unkb = (D_8016E750[playerIdx].unk_2C[i] & 0xF00000) >> 20;
|
||||
|
||||
if (unkb == arg1) {
|
||||
D_8016E750[playeridx].unk_2C[i] = 0xFF000000;
|
||||
D_8016E750[playerIdx].unk_2C[i] = 0xFF000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ void func_8002C0C0(TargetContext* targetCtx, Actor* actor, GlobalContext* global
|
|||
targetCtx->targetedActor = NULL;
|
||||
targetCtx->unk_40 = 0.0f;
|
||||
targetCtx->unk_8C = NULL;
|
||||
targetCtx->unk_90 = NULL;
|
||||
targetCtx->bgmEnemy = NULL;
|
||||
targetCtx->unk_4B = 0;
|
||||
targetCtx->unk_4C = 0;
|
||||
func_8002BF60(targetCtx, actor, actor->category, globalCtx);
|
||||
|
@ -2836,8 +2836,8 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC
|
|||
actorCtx->targetCtx.unk_8C = NULL;
|
||||
}
|
||||
|
||||
if (actor == actorCtx->targetCtx.unk_90) {
|
||||
actorCtx->targetCtx.unk_90 = NULL;
|
||||
if (actor == actorCtx->targetCtx.bgmEnemy) {
|
||||
actorCtx->targetCtx.bgmEnemy = NULL;
|
||||
}
|
||||
|
||||
Audio_StopSfxByPos(&actor->projectedPos);
|
||||
|
@ -2873,7 +2873,7 @@ s32 func_80032880(GlobalContext* globalCtx, Actor* actor) {
|
|||
Actor* D_8015BBE8;
|
||||
Actor* D_8015BBEC;
|
||||
f32 D_8015BBF0;
|
||||
f32 D_8015BBF4;
|
||||
f32 sbgmEnemyDistSq;
|
||||
s32 D_8015BBF8;
|
||||
s16 D_8015BBFC;
|
||||
|
||||
|
@ -2890,10 +2890,13 @@ void func_800328D4(GlobalContext* globalCtx, ActorContext* actorCtx, Player* pla
|
|||
|
||||
while (actor != NULL) {
|
||||
if ((actor->update != NULL) && ((Player*)actor != player) && ((actor->flags & 1) == 1)) {
|
||||
|
||||
// This block below is for determining the closest actor to player in determining the volume
|
||||
// used while playing enemy bgm music
|
||||
if ((actorCategory == ACTORCAT_ENEMY) && ((actor->flags & 5) == 5) &&
|
||||
(actor->xyzDistToPlayerSq < 250000.0f) && (actor->xyzDistToPlayerSq < D_8015BBF4)) {
|
||||
actorCtx->targetCtx.unk_90 = actor;
|
||||
D_8015BBF4 = actor->xyzDistToPlayerSq;
|
||||
(actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sbgmEnemyDistSq)) {
|
||||
actorCtx->targetCtx.bgmEnemy = actor;
|
||||
sbgmEnemyDistSq = actor->xyzDistToPlayerSq;
|
||||
}
|
||||
|
||||
if (actor != sp84) {
|
||||
|
@ -2929,13 +2932,13 @@ Actor* func_80032AF0(GlobalContext* globalCtx, ActorContext* actorCtx, Actor** a
|
|||
u8* entry;
|
||||
|
||||
D_8015BBE8 = D_8015BBEC = NULL;
|
||||
D_8015BBF0 = D_8015BBF4 = FLT_MAX;
|
||||
D_8015BBF0 = sbgmEnemyDistSq = FLT_MAX;
|
||||
D_8015BBF8 = 0x7FFFFFFF;
|
||||
|
||||
if (!Player_InCsMode(globalCtx)) {
|
||||
entry = &D_801160A0[0];
|
||||
|
||||
actorCtx->targetCtx.unk_90 = NULL;
|
||||
actorCtx->targetCtx.bgmEnemy = NULL;
|
||||
D_8015BBFC = player->actor.shape.rot.y;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue