audio_thread.c OK and Documented (code_80192BE0.c) (#1117)

* copy docs from audio

* PR Suggestions Round 1

* more PR suggestions

* fix bss

* PR Suggestions

* oops, duplicate

* apply OoT Feedback, fix bss

* cleanup

* spacing

* bss

Co-authored-by: angie <angheloalf95@gmail.com>
This commit is contained in:
engineer124
2022-12-08 17:41:03 -03:00
committed by GitHub
co-authored by angie
parent a5425e4ffc
commit 9c37452bf7
22 changed files with 1964 additions and 445 deletions
File diff suppressed because it is too large Load Diff
+10 -31
View File
@@ -2820,39 +2820,18 @@ void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone);
void AudioLoad_ProcessScriptLoads(void);
void AudioLoad_InitScriptLoads(void);
AudioTask* func_80192BE0(void);
// void func_80192C00(void);
// void func_8019319C(void);
// void func_801936D8(void);
// void func_8019372C(void);
// void func_80193774(void);
// void func_8019380C(void);
// void func_80193858(void);
AudioTask* AudioThread_Update(void);
void AudioThread_QueueCmdF32(u32 opArgs, f32 data);
void AudioThread_QueueCmdS32(u32 opArgs, s32 data);
void AudioThread_QueueCmdS8(u32 opArgs, s8 data);
// void func_801938D0(void);
void AudioThread_QueueCmdU16(u32 opArgs, u16 data);
s32 AudioThread_ScheduleProcessCmds(void);
// void func_80193990(void);
// void func_801939A8(void);
// void func_80193AEC(void);
// void func_80193BA0(void);
// void func_80193C04(void);
// void func_80193C5C(void);
// void func_80193CB4(void);
// void func_80193D08(void);
// void func_80193DA4(void);
// void func_80193E6C(void);
// void func_80193EA8(void);
// void func_80194080(void);
// void func_80194304(void);
// void func_80194328(void);
// void func_8019435C(void);
// void func_8019439C(void);
// void func_801943D0(void);
// void func_8019440C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void func_80194528(void);
// void func_80194548(void);
// void func_80194568(void);
u32 AudioThread_GetExternalLoadQueueMsg(u32* retMsg);
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts);
s32 func_80193C5C(void);
s32 AudioThread_ResetAudioHeap(s32 specId);
void AudioThread_PreNMIInternal(void);
s32 AudioThread_GetEnabledNotesCount(void);
u32 AudioThread_NextRandom(void);
void AudioThread_InitMesgQueues(void);
@@ -2894,7 +2873,7 @@ void* AudioSeq_AudioListPopBack(AudioListItem* list);
void AudioSeq_ProcessSequences(s32 arg0);
void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer);
void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer);
void AudioSeq_InitSequencePlayerChannels(s32 playerIndex);
void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex);
void AudioSeq_InitSequencePlayers(void);
void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4);
+5 -11
View File
@@ -909,14 +909,9 @@ extern UNK_PTR D_801D5FE0;
// extern UNK_TYPE1 D_801D5FE4;
extern s32 gAudioCtxInitalized;
// extern UNK_TYPE4 D_801D5FEC;
// extern UNK_TYPE4 D_801D5FF0;
// extern UNK_TYPE4 D_801D5FF4;
// extern UNK_TYPE1 D_801D5FF8;
// extern UNK_TYPE4 D_801D5FFC;
extern UNK_PTR D_801D6000;
// extern UNK_TYPE4 D_801D6190;
// extern UNK_TYPE4 D_801D6194;
// extern UNK_TYPE1 D_801D6200;
extern u8 D_801D6200[0x400];
extern u8 gIsLargeSfxBank[7];
extern u8 D_801D6608[7];
extern u8 gChannelsPerBank[4][7];
@@ -2293,7 +2288,6 @@ extern u8 gSoundFontTable[];
extern u8 gSequenceFontTable[];
extern u8 gSequenceTable[];
extern u8 gSampleBankTable[];
extern u64 aspMainDataStart[];
// bss
// extern UNK_TYPE1 D_801ED890;
@@ -2791,10 +2785,10 @@ extern ActiveSequence gActiveSeqs[];
// extern UNK_TYPE1 D_80200BCE;
// extern UNK_TYPE1 D_80200BD0;
extern AudioContext gAudioCtx; // at 0x80200C70
extern void (*gCustomAudioUpdateFunction)(void);
extern u32 (*gCustomAudioSeqFunction)(s8 value, SequenceChannel* channel);
extern s32 (*gCustomAudioReverbFunction)(Sample*, s32, s8, s32);
extern Acmd* (*gCustomAudioSynthFunction)(Acmd*, s32, s32);
extern AudioCustomUpdateFunction gAudioCustomUpdateFunction;
extern AudioCustomSeqFunction gAudioCustomSeqFunction;
extern AudioCustomReverbFunction gAudioCustomReverbFunction;
extern AudioCustomSynthFunction gAudioCustomSynthFunction;
// post-code buffers
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
+52 -34
View File
@@ -1,7 +1,7 @@
#ifndef Z64_AUDIO_H
#define Z64_AUDIO_H
#define AUDIO_MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0))
#include "audiothread_cmd.h"
#define NO_LAYER ((SequenceLayer*)(-1))
@@ -11,16 +11,25 @@
#define SEQ_NUM_CHANNELS 16
#define SEQ_IO_VAL_NONE -1
typedef enum {
/* 0x00 */ AUDIO_CUSTOM_FUNCTION_SEQ_0,
/* 0x01 */ AUDIO_CUSTOM_FUNCTION_SEQ_1,
/* 0x02 */ AUDIO_CUSTOM_FUNCTION_SEQ_2,
/* 0x03 */ AUDIO_CUSTOM_FUNCTION_SEQ_3,
/* 0xFE */ AUDIO_CUSTOM_FUNCTION_SYNTH = 0xFE,
/* 0xFF */ AUDIO_CUSTOM_FUNCTION_REVERB
} AudioCustomFunctions;
typedef enum {
/* 0 */ SEQPLAYER_STATE_0,
/* 1 */ SEQPLAYER_STATE_1, // Fading in
/* 2 */ SEQPLAYER_STATE_2 // Fading out
/* 1 */ SEQPLAYER_STATE_FADE_IN,
/* 2 */ SEQPLAYER_STATE_FADE_OUT
} SeqPlayerState;
#define MAX_CHANNELS_PER_BANK 3
#define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing
#define MUTE_FLAGS_4 (1 << 4) // stop something in seqLayer scripts
#define MUTE_FLAGS_STOP_SAMPLES (1 << 3) // prevent further noteSubEus from playing
#define MUTE_FLAGS_STOP_LAYER (1 << 4) // stop something in seqLayer scripts
#define MUTE_FLAGS_SOFTEN (1 << 5) // lower volume, by default to half
#define MUTE_FLAGS_STOP_NOTES (1 << 6) // prevent further notes from playing
#define MUTE_FLAGS_STOP_SCRIPT (1 << 7) // stop processing sequence/channel scripts
@@ -58,6 +67,10 @@ typedef enum {
#define REVERB_INDEX_NONE -1
// To be used with AudioThread_CountAndReleaseNotes()
#define AUDIO_NOTE_RELEASE (1 << 0)
#define AUDIO_NOTE_SAMPLE_NOTES (1 << 1)
typedef enum {
/* 0 */ REVERB_DATA_TYPE_SETTINGS, // Reverb Settings (Init)
/* 1 */ REVERB_DATA_TYPE_DELAY, // Reverb Delay (numSamples)
@@ -353,11 +366,11 @@ typedef struct {
/* 0x007 */ s8 playerIndex;
/* 0x008 */ u16 tempo; // tatums per minute
/* 0x00A */ u16 tempoAcc;
/* 0x00C */ s16 unk_0C;
/* 0x00C */ s16 tempoChange;
/* 0x00E */ s16 transposition;
/* 0x010 */ u16 delay;
/* 0x012 */ u16 fadeTimer;
/* 0x014 */ u16 fadeTimerUnkEu;
/* 0x014 */ u16 storedFadeTimer;
/* 0x016 */ u16 unk_16;
/* 0x018 */ u8* seqData;
/* 0x01C */ f32 fadeVolume;
@@ -374,8 +387,8 @@ typedef struct {
/* 0x09C */ NotePool notePool;
/* 0x0DC */ s32 skipTicks;
/* 0x0E0 */ u32 scriptCounter;
/* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp
/* 0x158 */ s8 soundScriptIO[8];
/* 0x0E4 */ UNK_TYPE1 unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp
/* 0x158 */ s8 seqScriptIO[8];
} SequencePlayer; // size = 0x160
typedef struct {
@@ -387,7 +400,7 @@ typedef struct {
typedef struct {
union {
struct {
/* 0x00 */ u8 unk_0b80 : 1;
/* 0x00 */ u8 unused : 1;
/* 0x00 */ u8 hang : 1;
/* 0x00 */ u8 decay : 1;
/* 0x00 */ u8 release : 1;
@@ -402,7 +415,7 @@ typedef struct {
/* 0x0C */ f32 fadeOutVel;
/* 0x10 */ f32 current;
/* 0x14 */ f32 target;
/* 0x18 */ char unk_18[4];
/* 0x18 */ UNK_TYPE1 unk_18[4];
/* 0x1C */ EnvelopePoint* envelope;
} AdsrState; // size = 0x20
@@ -434,11 +447,11 @@ typedef struct {
typedef struct VibratoSubStruct {
/* 0x0 */ u16 vibratoRateStart;
/* 0x2 */ u16 vibratoExtentStart;
/* 0x2 */ u16 vibratoDepthStart;
/* 0x4 */ u16 vibratoRateTarget;
/* 0x6 */ u16 vibratoExtentTarget;
/* 0x6 */ u16 vibratoDepthTarget;
/* 0x8 */ u16 vibratoRateChangeDelay;
/* 0xA */ u16 vibratoExtentChangeDelay;
/* 0xA */ u16 vibratoDepthChangeDelay;
/* 0xC */ u16 vibratoDelay;
} VibratoSubStruct; // size = 0xE
@@ -447,7 +460,7 @@ typedef struct SequenceChannel {
/* 0x00 */ u8 enabled : 1;
/* 0x00 */ u8 finished : 1;
/* 0x00 */ u8 stopScript : 1;
/* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething
/* 0x00 */ u8 muted : 1; // sets SequenceLayer.muted
/* 0x00 */ u8 hasInstrument : 1;
/* 0x00 */ u8 stereoHeadsetEffects : 1;
/* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity
@@ -475,7 +488,7 @@ typedef struct SequenceChannel {
/* 0x0E */ u8 gateTimeRandomVariance;
/* 0x0F */ u8 combFilterSize;
/* 0x10 */ u8 surroundEffectIndex;
/* 0x11 */ u8 unk_11;
/* 0x11 */ u8 channelIndex;
/* 0x12 */ VibratoSubStruct vibrato;
/* 0x20 */ u16 delay;
/* 0x22 */ u16 combFilterGain;
@@ -497,7 +510,7 @@ typedef struct SequenceChannel {
/* 0x64 */ SeqScriptState scriptState;
/* 0x80 */ AdsrSettings adsr;
/* 0x88 */ NotePool notePool;
/* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports"
/* 0xC8 */ s8 seqScriptIO[8]; // bridge between sound script and audio lib, "io ports"
/* 0xD0 */ u8* sfxState; // SfxChannelState
/* 0xD4 */ s16* filter;
/* 0xD8 */ StereoData stereoData;
@@ -509,7 +522,7 @@ typedef struct SequenceChannel {
typedef struct SequenceLayer {
/* 0x00 */ u8 enabled : 1;
/* 0x00 */ u8 finished : 1;
/* 0x00 */ u8 stopSomething : 1;
/* 0x00 */ u8 muted : 1;
/* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
/* 0x00 */ u8 bit3 : 1; // "loaded"?
/* 0x00 */ u8 ignoreDrumPan : 1;
@@ -605,11 +618,11 @@ typedef struct {
/* 0x00 */ struct VibratoSubStruct* vibSubStruct; // Something else?
/* 0x04 */ u32 time;
/* 0x08 */ s16* curve;
/* 0x0C */ f32 extent;
/* 0x0C */ f32 depth;
/* 0x10 */ f32 rate;
/* 0x14 */ u8 active;
/* 0x16 */ u16 rateChangeTimer;
/* 0x18 */ u16 extentChangeTimer;
/* 0x18 */ u16 depthChangeTimer;
/* 0x1A */ u16 delay;
} VibratoState; // size = 0x1C
@@ -984,7 +997,7 @@ typedef struct {
/* 0x28B0 */ s32 sampleDmaBufSize;
/* 0x28B4 */ s32 maxAudioCmds;
/* 0x28B8 */ s32 numNotes;
/* 0x2898 */ s16 tempoInternalToExternal;
/* 0x2898 */ s16 maxTempo;
/* 0x28BE */ s8 soundMode;
/* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset
/* 0x28C4 */ s32 curAudioFrameDmaCount;
@@ -997,13 +1010,13 @@ typedef struct {
/* 0x2980 */ f32 unk_2960;
/* 0x2984*/ s32 refreshRate;
/* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI)
/* 0x2994 */ s16 aiBufNumSamples[3]; // Number of samples to transfer to the audio interface buffer
/* 0x2994 */ s16 numSamplesPerFrame[3]; // Number of samples to transfer to the audio interface buffer
/* 0x299C */ u32 audioRandom;
/* 0x29A0 */ s32 audioErrorFlags;
/* 0x29A4 */ volatile u32 resetTimer;
/* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel);
/* 0x29A8 */ u32 (*customSeqFunctions[4])(s8 value, SequenceChannel* channel);
/* 0x29B8 */ s8 unk_29B8;
/* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt
/* 0x29BC */ s32 numAbiCmdsMax; // sMaxAbiCmdCnt
/* 0x29C0 */ AudioAllocPool sessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset
/* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game
/* 0x29E0 */ AudioAllocPool initPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset
@@ -1027,7 +1040,7 @@ typedef struct {
/* 0x4398 */ u8 fontLoadStatus[0x30];
/* 0x43C8 */ u8 seqLoadStatus[0x80];
/* 0x4448 */ volatile u8 resetStatus;
/* 0x4449 */ u8 audioResetSpecIdToLoad;
/* 0x4449 */ u8 specId;
/* 0x444C */ s32 audioResetFadeOutFramesLeft;
/* 0x4450 */ f32* adsrDecayTable; // A table on the audio heap that stores decay rates used for ADSR
/* 0x4454 */ u8* audioHeap;
@@ -1039,21 +1052,21 @@ typedef struct {
/* 0x7924 */ s32 sampleStateOffset; // Start of the list of sample states for this update. Resets after each audio frame.
/* 0x7928 */ AudioListItem layerFreeList;
/* 0x7938 */ NotePool noteFreeLists;
/* 0x7978 */ u8 cmdWritePos;
/* 0x7979 */ u8 cmdReadPos;
/* 0x797A */ u8 cmdQueueFinished;
/* 0x797C */ u16 activeChannelsFlags[5]; // bit-packed for 16 channels. Only channels with bit turned on will be processed
/* 0x7978 */ u8 threadCmdWritePos;
/* 0x7979 */ u8 threadCmdReadPos;
/* 0x797A */ u8 threadCmdQueueFinished;
/* 0x797C */ u16 threadCmdChannelMask[5]; // bit-packed for 16 channels. When processing an audio thread channel command on all channels, only process channels with their bit set.
/* 0x7988 */ OSMesgQueue* audioResetQueueP;
/* 0x798C */ OSMesgQueue* taskStartQueueP;
/* 0x7990 */ OSMesgQueue* cmdProcQueueP;
/* 0x7990 */ OSMesgQueue* threadCmdProcQueueP;
/* 0x7994 */ OSMesgQueue taskStartQueue;
/* 0x79AC */ OSMesgQueue cmdProcQueue;
/* 0x79AC */ OSMesgQueue threadCmdProcQueue;
/* 0x79C4 */ OSMesgQueue audioResetQueue;
/* 0x79DC */ OSMesg taskStartMsgs[1];
/* 0x79E0 */ OSMesg audioResetMesgs[1];
/* 0x79E4 */ OSMesg cmdProcMsgs[4];
/* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread
/* 0x81F4 */ char unk_81F4[4];
/* 0x79E4 */ OSMesg threadCmdProcMsgBuf[4];
/* 0x79F4 */ AudioCmd threadCmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread
/* 0x81F4 */ UNK_TYPE1 unk_81F4[4];
} AudioContext; // size = 0x81F8
typedef struct {
@@ -1255,4 +1268,9 @@ typedef struct {
/* 0x2 */ u16 params;
} SfxParams; // size = 0x4
typedef void (*AudioCustomUpdateFunction)(void);
typedef u32 (*AudioCustomSeqFunction)(s8 value, SequenceChannel* channel);
typedef s32 (*AudioCustomReverbFunction)(Sample*, s32, s8, s32);
typedef Acmd* (*AudioCustomSynthFunction)(Acmd*, s32, s32);
#endif
+1 -2
View File
@@ -609,8 +609,7 @@ beginseg
include "build/src/code/audio/audio_heap.o"
include "build/data/code/audio_heap.bss.o"
include "build/src/code/audio/audio_load.o"
include "build/src/code/audio/code_80192BE0.o"
include "build/data/code/code_80192BE0.data.o"
include "build/src/code/audio/audio_thread.o"
include "build/src/code/audio/audio_dcache.o"
include "build/src/code/audio/aisetnextbuf.o"
include "build/src/code/audio/audio_playback.o"
+20 -20
View File
@@ -63,7 +63,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) {
}
seqPlayer->fadeTimer--;
if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_2)) {
if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT)) {
AudioSeq_SequencePlayerDisable(seqPlayer);
return;
}
@@ -112,10 +112,10 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
static f32 activeVibratoFreqScaleSum = 0.0f;
static s32 activeVibratoCount = 0;
f32 pitchChange;
f32 extent;
f32 invExtent;
f32 depth;
f32 invDepth;
f32 result;
f32 scaledExtent;
f32 scaledDepth;
VibratoSubStruct* subVib = vib->vibSubStruct;
if (vib->delay != 0) {
@@ -124,17 +124,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
}
if (subVib != NULL) {
if (vib->extentChangeTimer) {
if (vib->extentChangeTimer == 1) {
vib->extent = (s32)subVib->vibratoExtentTarget;
if (vib->depthChangeTimer) {
if (vib->depthChangeTimer == 1) {
vib->depth = (s32)subVib->vibratoDepthTarget;
} else {
vib->extent += ((s32)subVib->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer;
vib->depth += ((s32)subVib->vibratoDepthTarget - vib->depth) / (s32)vib->depthChangeTimer;
}
vib->extentChangeTimer--;
} else if (subVib->vibratoExtentTarget != (s32)vib->extent) {
if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) {
vib->extent = (s32)subVib->vibratoExtentTarget;
vib->depthChangeTimer--;
} else if (subVib->vibratoDepthTarget != (s32)vib->depth) {
if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) {
vib->depth = (s32)subVib->vibratoDepthTarget;
}
}
@@ -153,17 +153,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
}
}
if (vib->extent == 0.0f) {
if (vib->depth == 0.0f) {
return 1.0f;
}
pitchChange = AudioEffects_GetVibratoPitchChange(vib) + 32768.0f;
scaledExtent = vib->extent / 4096.0f;
extent = scaledExtent + 1.0f;
invExtent = 1.0f / extent;
scaledDepth = vib->depth / 4096.0f;
depth = scaledDepth + 1.0f;
invDepth = 1.0f / depth;
// inverse linear interpolation
result = 1.0f / ((extent - invExtent) * pitchChange / 65536.0f + invExtent);
result = 1.0f / ((depth - invDepth) * pitchChange / 65536.0f + invDepth);
activeVibratoFreqScaleSum += result;
activeVibratoCount++;
@@ -196,10 +196,10 @@ void AudioEffects_NoteVibratoInit(Note* note) {
subVib = vib->vibSubStruct;
if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) {
vib->extent = (s32)subVib->vibratoExtentTarget;
if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) {
vib->depth = (s32)subVib->vibratoDepthTarget;
} else {
vib->extent = (s32)subVib->vibratoExtentStart;
vib->depth = (s32)subVib->vibratoDepthStart;
}
if ((vib->rateChangeTimer = subVib->vibratoRateChangeDelay) == 0) {
+7 -7
View File
@@ -836,7 +836,7 @@ void AudioHeap_ClearAiBuffers(void) {
s32 curAiBufferIndex = gAudioCtx.curAiBufferIndex;
s32 i;
gAudioCtx.aiBufNumSamples[curAiBufferIndex] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin;
gAudioCtx.numSamplesPerFrame[curAiBufferIndex] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin;
for (i = 0; i < AIBUF_LEN; i++) {
gAudioCtx.aiBuffers[curAiBufferIndex][i] = 0;
@@ -905,8 +905,8 @@ s32 AudioHeap_ResetStep(void) {
case 1:
AudioHeap_Init();
gAudioCtx.resetStatus = 0;
for (i = 0; i < ARRAY_COUNT(gAudioCtx.aiBufNumSamples); i++) {
gAudioCtx.aiBufNumSamples[i] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax;
for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) {
gAudioCtx.numSamplesPerFrame[i] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax;
for (j = 0; j < AIBUF_LEN; j++) {
gAudioCtx.aiBuffers[i][j] = 0;
}
@@ -932,7 +932,7 @@ void AudioHeap_Init(void) {
s32 reverbIndex;
s32 i;
s32 pad2;
AudioSpec* spec = &gAudioSpecs[gAudioCtx.audioResetSpecIdToLoad]; // Audio Specifications
AudioSpec* spec = &gAudioSpecs[gAudioCtx.specId]; // Audio Specifications
gAudioCtx.sampleDmaCount = 0;
@@ -970,15 +970,15 @@ void AudioHeap_Init(void) {
gAudioCtx.audioBufferParameters.numSequencePlayers = 5;
}
gAudioCtx.unk_29BC = 8;
gAudioCtx.numAbiCmdsMax = 8;
gAudioCtx.unk_2 = spec->unk_14;
gAudioCtx.tempoInternalToExternal =
gAudioCtx.maxTempo =
(u32)(gAudioCtx.audioBufferParameters.updatesPerFrame * 2880000.0f / gTatumsPerBeat / gAudioCtx.unk_2960);
gAudioCtx.unk_2870 = gAudioCtx.refreshRate;
gAudioCtx.unk_2870 *= gAudioCtx.audioBufferParameters.updatesPerFrame;
gAudioCtx.unk_2870 /= gAudioCtx.audioBufferParameters.aiSamplingFreq;
gAudioCtx.unk_2870 /= gAudioCtx.tempoInternalToExternal;
gAudioCtx.unk_2870 /= gAudioCtx.maxTempo;
gAudioCtx.audioBufferParameters.specUnk4 = spec->unk_04;
gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget *= gAudioCtx.audioBufferParameters.specUnk4;
+8 -8
View File
@@ -1212,12 +1212,12 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
s32 i;
s32 j;
gCustomAudioUpdateFunction = NULL;
gCustomAudioReverbFunction = NULL;
gCustomAudioSynthFunction = NULL;
gAudioCustomUpdateFunction = NULL;
gAudioCustomReverbFunction = NULL;
gAudioCustomSynthFunction = NULL;
for (i = 0; i < ARRAY_COUNT(gAudioCtx.unk_29A8); i++) {
gAudioCtx.unk_29A8[i] = NULL;
for (i = 0; i < ARRAY_COUNT(gAudioCtx.customSeqFunctions); i++) {
gAudioCtx.customSeqFunctions[i] = NULL;
}
gAudioCtx.resetTimer = 0;
@@ -1248,8 +1248,8 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
AudioThread_InitMesgQueues();
for (i = 0; i < ARRAY_COUNT(gAudioCtx.aiBufNumSamples); i++) {
gAudioCtx.aiBufNumSamples[i] = 0xA0;
for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) {
gAudioCtx.numSamplesPerFrame[i] = 0xA0;
}
gAudioCtx.totalTaskCount = 0;
@@ -1301,7 +1301,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
gAudioCtx.numSequences = gAudioCtx.sequenceTable->numEntries;
gAudioCtx.audioResetSpecIdToLoad = 0;
gAudioCtx.specId = 0;
gAudioCtx.resetStatus = 1; // Set reset to immediately initialize the audio heap
AudioHeap_ResetStep();
+2 -2
View File
@@ -309,7 +309,7 @@ void AudioPlayback_ProcessNotes(void) {
subAttrs.combFilterGain = channel->combFilterGain;
bookOffset = channel->bookOffset & 0x7;
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) {
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) {
subAttrs.frequency = 0.0f;
subAttrs.velocity = 0.0f;
}
@@ -531,7 +531,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
attrs->combFilterGain = channel->combFilterGain;
attrs->combFilterSize = channel->combFilterSize;
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) {
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) {
note->sampleState.bitField0.finished = true;
}
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -866,8 +866,8 @@ Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd,
size = numSamplesPerUpdate * SAMPLE_SIZE;
aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, size);
if (gCustomAudioSynthFunction != NULL) {
cmd = gCustomAudioSynthFunction(cmd, 2 * size, updateIndex);
if (gAudioCustomSynthFunction != NULL) {
cmd = gAudioCustomSynthFunction(cmd, 2 * size, updateIndex);
}
aSaveBuffer(cmd++, DMEM_TEMP, aiBuf, 2 * size);
@@ -1109,8 +1109,8 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
case CODEC_REVERB:
reverbAddrSrc = (void*)0xFFFFFFFF;
if (gCustomAudioReverbFunction != NULL) {
reverbAddrSrc = gCustomAudioReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex);
if (gAudioCustomReverbFunction != NULL) {
reverbAddrSrc = gAudioCustomReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex);
}
if (reverbAddrSrc == (void*)0xFFFFFFFF) {
File diff suppressed because it is too large Load Diff
-81
View File
@@ -1,81 +0,0 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192BE0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192C00.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019319C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801936D8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019372C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193774.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019380C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193858.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS32.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_ScheduleProcessCmds.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193990.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801939A8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193AEC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193BA0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C04.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C24.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C5C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193CB4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193D08.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DA4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DF0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E44.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E6C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E9C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193EA8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194080.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801942BC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194304.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194328.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019435C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019439C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801943D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019440C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194528.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194548.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_NextRandom.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_InitMesgQueues.s")
+29 -36
View File
@@ -2640,7 +2640,7 @@ void AudioOcarina_PlayControllerInput(u8 isOcarinaSfxSuppressedWhenCancelled) {
// Add vibrato of the ocarina note based on the x control stick
sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickRel.x) >> 2;
// Sets vibrato to io port 6
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sCurOcarinaVibrato);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 6, sCurOcarinaVibrato);
} else {
// no bending or vibrato for recording state OCARINA_RECORD_SCARECROW_SPAWN
sCurOcarinaBendIndex = 0;
@@ -2652,10 +2652,9 @@ void AudioOcarina_PlayControllerInput(u8 isOcarinaSfxSuppressedWhenCancelled) {
if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && (sPrevOcarinaPitch != sCurOcarinaPitch)) {
// Sets ocarina instrument Id to io port 7, which is used
// as an index in seq 0 to get the true instrument Id
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7,
sOcarinaInstrumentId - 1);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1);
// Sets pitch to io port 5
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5, sCurOcarinaPitch);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 5, sCurOcarinaPitch);
AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sCurOcarinaBendFreq, &sDefaultOcarinaVolume,
&gSfxDefaultReverb);
} else if ((sPrevOcarinaPitch != OCARINA_PITCH_NONE) && (sCurOcarinaPitch == OCARINA_PITCH_NONE) &&
@@ -2862,7 +2861,7 @@ void AudioOcarina_PlaybackSong(void) {
// Update vibrato
sNotePlaybackVibrato = sPlaybackSong[sPlaybackNotePos].vibrato;
// Sets vibrato to io port 6
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sNotePlaybackVibrato);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 6, sNotePlaybackVibrato);
// Update bend
if (sNotePlaybackBend != sPlaybackSong[sPlaybackNotePos].bend) {
@@ -2892,10 +2891,9 @@ void AudioOcarina_PlaybackSong(void) {
sPlaybackStaffPos++;
// Sets ocarina instrument Id to io port 7, which is used
// as an index in seq 0 to get the true instrument Id
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7,
sOcarinaInstrumentId - 1);
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5,
sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 5,
sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH);
AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sRelativeNotePlaybackBend,
&sRelativeNotePlaybackVolume, &gSfxDefaultReverb);
} else {
@@ -3400,7 +3398,7 @@ u8 sRequestCustomSequence = false;
void AudioOcarina_SetCustomSequence(void) {
// Never passes true as sRequestCustomSequence is never set true
if (sRequestCustomSequence && gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].enabled &&
((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) {
((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].seqScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) {
gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].seqData = sCustomSequenceScript;
sRequestCustomSequence = false;
}
@@ -3754,8 +3752,8 @@ s8 AudioSfx_ComputeReverb(u8 bankId, u8 entryIndex, u8 channelIndex) {
}
if (IS_SEQUENCE_CHANNEL_VALID(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) {
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1];
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] <= SEQ_IO_VAL_NONE) {
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1];
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1] <= SEQ_IO_VAL_NONE) {
scriptAdd = 0;
}
}
@@ -4051,8 +4049,8 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) {
//! FAKE:
if (1) {}
// CHAN_UPD_SCRIPT_IO (slot 2, sets volume)
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (channelIndex << 8) | 2, volumeS8);
// ioPort 2, sets volume
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 2, volumeS8);
if (sSfxChannelState[channelIndex].reverb != reverb) {
sSfxChannelState[channelIndex].reverb = reverb;
@@ -4307,16 +4305,16 @@ f32 sBigBellsVolume[8] = {
*/
void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) {
u8 channelIndex;
s8 pan = 0;
s8 panChannelWeight = 0;
// Ganondorfs's Lair
if (ganonsTowerLevel == 0) {
pan = 0x7F;
// Pan comes entirely from the SequenceChannel
panChannelWeight = 0x7F;
}
for (channelIndex = 0; channelIndex < 16; channelIndex++) {
// CHAN_UPD_PAN_UNSIGNED
AudioThread_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan);
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(SEQ_PLAYER_BGM_MAIN, channelIndex, panChannelWeight);
}
// Lowest room in Ganon's Tower (Entrance Room)
@@ -4359,11 +4357,12 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels);
channelIndex++) {
if (&gAudioCtx.sequenceChannelNone != gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) {
// soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT)
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] !=
// seqScriptIO[5] was originally set to 0x40 in channels 0, 1, and 4 by OoT's Ganon's Tower BGM,
// which was removed in MM
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] !=
(u8)SEQ_IO_VAL_NONE) {
// Higher volume leads to lower reverb
reverb = (((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] -
reverb = (((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] -
targetVolume) +
0x7F);
@@ -4371,10 +4370,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
reverb = 0x7F;
}
// CHAN_UPD_REVERB
AudioThread_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) |
_SHIFTL(channelIndex, 8, 8),
(u8)reverb);
AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, (u8)reverb);
}
}
}
@@ -4445,9 +4441,7 @@ void AudioSfx_SetChannelIO(Vec3f* pos, u16 sfxId, u8 ioData) {
if (entryIndex != 0xFF) {
if ((sfxId == gSfxBanks[bankId][entryIndex].sfxId) && (&pos->x == gSfxBanks[bankId][entryIndex].posX)) {
AudioThread_QueueCmdS8(_SHIFTL(6, 24, 8) | _SHIFTL(SEQ_PLAYER_SFX, 16, 8) |
_SHIFTL(channelIndex, 8, 8) | _SHIFTL(6, 0, 8),
ioData);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 6, ioData);
}
}
channelIndex++;
@@ -4498,7 +4492,7 @@ void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) {
if (channelIndex != 9) {
Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) |
((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel)));
AudioThread_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan);
AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, channelIndex, pan);
}
}
}
@@ -4721,7 +4715,7 @@ void Audio_UpdateSceneSequenceResumePoint(void) {
if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) {
if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) {
// Get the current point to resume from
sSeqResumePoint = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3];
sSeqResumePoint = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[3];
} else {
// Initialize the point to resume from to the start of the sequence
sSeqResumePoint = 0;
@@ -5089,7 +5083,7 @@ void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) {
if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) &&
(Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) {
Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0);
AudioThread_QueueCmdS32(0xF8 << 24, 0);
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
}
if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
@@ -5164,12 +5158,11 @@ void AudioSfx_Init(u16 fadeTimer) {
Audio_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer);
for (channelIndex = 0; channelIndex < ARRAY_COUNT(sSfxChannelState); channelIndex++) {
AudioThread_QueueCmdS32(0x10 << 24 | SEQ_PLAYER_SFX << 16 | ((u8)(u32)channelIndex << 8),
&sSfxChannelState[channelIndex]);
AUDIOCMD_CHANNEL_SET_SFX_STATE(SEQ_PLAYER_SFX, channelIndex, &sSfxChannelState[channelIndex]);
}
AudioThread_QueueCmdS32(0xE4000000, AudioSfx_SetFreqAndStereoBits);
AudioThread_QueueCmdS32(0xE4000001, Audio_SetAmbienceRandomBend);
AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_0, AudioSfx_SetFreqAndStereoBits);
AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_1, Audio_SetAmbienceRandomBend);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s")
+17 -24
View File
@@ -410,9 +410,8 @@ void AudioSfx_ChooseActiveSfx(u8 bankId) {
// If a "one-frame" sfx is still in "SFX_STATE_PLAYING_ONE_FRAME", then remove the sfx
} else if (!(gSfxBanks[bankId][entryIndex].sfxId & SFX_FLAG_MASK) &&
(gSfxBanks[bankId][entryIndex].state == SFX_STATE_PLAYING_ONE_FRAME)) {
// CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0)
AudioThread_QueueCmdS8(
(0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (gSfxBanks[bankId][entryIndex].channelIndex << 8), 0);
// ioPort 0, force stop sfx in seq 0
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, gSfxBanks[bankId][entryIndex].channelIndex, 0, 0);
AudioSfx_RemoveBankEntry(bankId, entryIndex);
}
@@ -459,8 +458,8 @@ void AudioSfx_ChooseActiveSfx(u8 bankId) {
// If too far away and also playing, stop playing
if (entry->state == SFX_STATE_PLAYING) {
// CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0)
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (entry->channelIndex << 8), 0);
// ioPort 0, force stop sfx in seq 0
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
if (entry->sfxId & SFX_FLAG_MASK) {
AudioSfx_RemoveBankEntry(bankId, entryIndex);
entryIndex = k;
@@ -632,15 +631,11 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
// Calculate all the properties of sfx
AudioSfx_SetProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex);
// CHAN_UPD_SCRIPT_IO (ioPort 0, enable the sfx to play in seq 0)
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((sCurSfxPlayerChannelIndex & 0xFF) << 8),
1);
// ioPort 0, enable the sfx to play in `NA_BGM_GENERAL_SFX`
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 0, 1);
// CHAN_UPD_SCRIPT_IO (ioPort 4, write the lower bits sfx index to seq 0 so it can find the right code
// to execute)
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) |
((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 4,
entry->sfxId & 0xFF);
// ioPort 4, write the lower bits sfx index for `NA_BGM_GENERAL_SFX` to find the right code to execute
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 4, entry->sfxId & 0xFF);
// If the sfx bank has more than 255 entries (greater than a u8 can store),
// then store the Id in upper and lower bits
@@ -656,11 +651,9 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
}
if (D_801D6608[bankId]) {
// CHAN_UPD_SCRIPT_IO (ioPort 5, write the upper bits sfx index and a flag to seq 0, for banks with
// > 0xFF entries)
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) |
((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 5,
ioPort5Data);
// ioPort 5, write the upper bits sfx index and a flag for `NA_BGM_GENERAL_SFX`,
// for banks with > 0xFF entries
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 5, ioPort5Data);
}
// Update playing state
@@ -671,7 +664,7 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
// "one-frame" sfx
entry->state = SFX_STATE_PLAYING_ONE_FRAME;
}
} else if ((u8)channel->soundScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
} else if ((u8)channel->seqScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
// Signal from seq 0 that the sfx is finished playing. Remove entry
AudioSfx_RemoveBankEntry(bankId, entryIndex);
} else if (entry->state == SFX_STATE_PLAYING_REFRESH) {
@@ -702,7 +695,7 @@ void AudioSfx_StopByBank(u8 bankId) {
while (entryIndex != 0xFF) {
entry = &gSfxBanks[bankId][entryIndex];
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
}
if (entry->state != SFX_STATE_EMPTY) {
@@ -724,7 +717,7 @@ void AudioSfx_StopByPosAndBankImpl(u8 bankId, Vec3f* pos) {
entry = &gSfxBanks[bankId][entryIndex];
if (entry->posX == &pos->x) {
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
}
if (entry->state != SFX_STATE_EMPTY) {
@@ -769,7 +762,7 @@ void AudioSfx_StopByPosAndId(Vec3f* pos, u16 sfxId) {
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
if ((entry->posX == &pos->x) && (entry->sfxId == sfxId)) {
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
}
if (entry->state != SFX_STATE_EMPTY) {
@@ -800,7 +793,7 @@ void AudioSfx_StopByTokenAndId(u8 token, u16 sfxId) {
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
if ((entry->token == token) && (entry->sfxId == sfxId)) {
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
}
if (entry->state != SFX_STATE_EMPTY) {
@@ -830,7 +823,7 @@ void AudioSfx_StopById(u32 sfxId) {
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
if (entry->sfxId == sfxId) {
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
}
if (entry->state != SFX_STATE_EMPTY) {
AudioSfx_RemoveBankEntry(SFX_BANK(sfxId), entryIndex);
+1 -1
View File
@@ -39,7 +39,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
if (SREG(20) >= 2) {
rspTask = NULL;
} else {
rspTask = func_80192BE0();
rspTask = AudioThread_Update();
}
if (audioMgr->rspTask != NULL) {
@@ -4,6 +4,7 @@
* Description: Fishing Pond Elements (Owner, Fish, Props, Effects...)
*/
#include "prevent_bss_reordering.h"
#include "z_en_fishing.h"
#include "z64rumble.h"
#include "z64shrink_window.h"
+3 -3
View File
@@ -484,7 +484,7 @@
0x801877D0 : "audio_synthesis",
0x8018B0F0 : "audio_heap",
0x8018EB60 : "audio_load",
0x80192BE0 : "code_80192BE0",
0x80192BE0 : "audio_thread",
0x80194710 : "audio_dcache",
0x80194790 : "aisetnextbuf",
0x80194930 : "audio_playback",
@@ -588,7 +588,7 @@
0x801D2E80 : "audio_data",
0x801D5FB0 : "audio_synthesis",
0x801D5FE0 : "audio_load",
0x801D5FF0 : "code_80192BE0",
0x801D5FF0 : "audio_thread",
0x801D6010 : "aisetnextbuf",
0x801D6190 : "audio_effects",
0x801D61A0 : "audio_seqplayer",
@@ -672,7 +672,7 @@
0x801E0280 : "audio_synthesis",
0x801E02B0 : "audio_heap",
0x801E0300 : "audio_load",
0x801E0390 : "code_80192BE0",
0x801E0390 : "audio_thread",
0x801E04E0 : "audio_playback",
0x801E0510 : "audio_effects",
0x801E0540 : "audio_seqplayer",
+34 -34
View File
@@ -3680,44 +3680,44 @@
0x80192AE8:("AudioLoad_ScriptLoad",),
0x80192B54:("AudioLoad_ProcessScriptLoads",),
0x80192BAC:("AudioLoad_InitScriptLoads",),
0x80192BE0:("func_80192BE0",),
0x80192C00:("func_80192C00",),
0x8019319C:("func_8019319C",),
0x801936D8:("func_801936D8",),
0x8019372C:("func_8019372C",),
0x80193774:("func_80193774",),
0x8019380C:("func_8019380C",),
0x80193858:("func_80193858",),
0x80192BE0:("AudioThread_Update",),
0x80192C00:("AudioThread_UpdateImpl",),
0x8019319C:("AudioThread_ProcessGlobalCmd",),
0x801936D8:("AudioThread_SetFadeOutTimer",),
0x8019372C:("AudioThread_SetFadeInTimer",),
0x80193774:("AudioThread_InitMesgQueuesInternal",),
0x8019380C:("AudioThread_QueueCmd",),
0x80193858:("AudioThread_QueueCmdF32",),
0x8019387C:("AudioThread_QueueCmdS32",),
0x801938A0:("AudioThread_QueueCmdS8",),
0x801938D0:("func_801938D0",),
0x801938D0:("AudioThread_QueueCmdU16",),
0x80193900:("AudioThread_ScheduleProcessCmds",),
0x80193990:("func_80193990",),
0x801939A8:("func_801939A8",),
0x80193AEC:("func_80193AEC",),
0x80193BA0:("func_80193BA0",),
0x80193C04:("func_80193C04",),
0x80193C24:("func_80193C24",),
0x80193990:("AudioThread_ResetCmdQueue",),
0x801939A8:("AudioThread_ProcessCmd",),
0x80193AEC:("AudioThread_ProcessCmds",),
0x80193BA0:("AudioThread_GetExternalLoadQueueMsg",),
0x80193C04:("AudioThread_GetFontsForSequence",),
0x80193C24:("AudioThread_GetSampleBankIdsOfFont",),
0x80193C5C:("func_80193C5C",),
0x80193CB4:("func_80193CB4",),
0x80193D08:("func_80193D08",),
0x80193DA4:("func_80193DA4",),
0x80193DF0:("func_80193DF0",),
0x80193E44:("func_80193E44",),
0x80193E6C:("func_80193E6C",),
0x80193E9C:("func_80193E9C",),
0x80193EA8:("func_80193EA8",),
0x80194080:("func_80194080",),
0x801942BC:("func_801942BC",),
0x80194304:("func_80194304",),
0x80194328:("func_80194328",),
0x8019435C:("func_8019435C",),
0x8019439C:("func_8019439C",),
0x801943D0:("func_801943D0",),
0x8019440C:("func_8019440C",),
0x80194528:("func_80194528",),
0x80194548:("func_80194548",),
0x80194568:("func_80194568",),
0x80193CB4:("AudioThread_WaitForAudioResetQueueP",),
0x80193D08:("AudioThread_ResetAudioHeap",),
0x80193DA4:("AudioThread_PreNMIInternal",),
0x80193DF0:("AudioThread_GetChannelIO",),
0x80193E44:("AudioThread_GetSeqPlayerIO",),
0x80193E6C:("AudioThread_InitExternalPool",),
0x80193E9C:("AudioThread_ResetExternalPool",),
0x80193EA8:("AudioThread_ProcessSeqPlayerCmd",),
0x80194080:("AudioThread_ProcessChannelCmd",),
0x801942BC:("AudioThread_Noop1Cmd",),
0x80194304:("AudioThread_Noop1CmdZeroed",),
0x80194328:("AudioThread_Noop2Cmd",),
0x8019435C:("AudioThread_WaitForAudioTask",),
0x8019439C:("AudioThread_GetSamplePosFromStart",),
0x801943D0:("AudioThread_GetSamplePosUntilEnd",),
0x8019440C:("AudioThread_GetSamplePos",),
0x80194528:("AudioThread_GetEnabledNotesCount",),
0x80194548:("AudioThread_GetEnabledSampledNotesCount",),
0x80194568:("AudioThread_CountAndReleaseNotes",),
0x80194668:("AudioThread_NextRandom",),
0x801946E4:("AudioThread_InitMesgQueues",),
0x80194710:("Audio_InvalDCache",),
+9 -9
View File
@@ -2249,11 +2249,11 @@
0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1),
0x801D5FE8:("gAudioCtxInitalized","UNK_TYPE4","",0x4),
0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4),
0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4),
0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4),
0x801D5FF8:("D_801D5FF8","UNK_TYPE1","",0x1),
0x801D5FFC:("D_801D5FFC","UNK_TYPE4","",0x4),
0x801D6000:("D_801D6000","UNK_PTR","",0x4),
0x801D5FF0:("sWaitingAudioTask","UNK_TYPE4","",0x4),
0x801D5FF4:("sMaxWriteReadDiff","UNK_TYPE4","",0x4),
0x801D5FF8:("sCurCmdRdPos","UNK_TYPE1","",0x1),
0x801D5FFC:("sAudioRandom","UNK_TYPE4","",0x4),
0x801D6000:("sAudioOsCount","UNK_PTR","",0x4),
0x801D6010:("D_801D6010","UNK_TYPE1","",0x1),
0x801D6014:("D_801D6014","UNK_TYPE1","",0x1),
0x801D6028:("D_801D6028","UNK_TYPE1","",0x1),
@@ -4352,10 +4352,10 @@
0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1),
0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1),
0x80200C70:("gAudioCtx","AudioContext","",0x81F8),
0x80208E68:("gCustomAudioUpdateFunction","UNK_TYPE4","",0x4),
0x80208E6C:("gCustomAudioSeqFunction","UNK_TYPE4","",0x4),
0x80208E70:("gCustomAudioReverbFunction","UNK_TYPE4","",0x4),
0x80208E74:("gCustomAudioSynthFunction","UNK_TYPE4","",0x4),
0x80208E68:("gAudioCustomUpdateFunction","UNK_TYPE4","",0x4),
0x80208E6C:("gAudioCustomSeqFunction","UNK_TYPE4","",0x4),
0x80208E70:("gAudioCustomReverbFunction","UNK_TYPE4","",0x4),
0x80208E74:("gAudioCustomSynthFunction","UNK_TYPE4","",0x4),
0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1),
0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1),
0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1),

Some files were not shown because too many files have changed in this diff Show More