match and document audiosfx.c (#550)

* match func_80004668 and adjust types

* match _handleEvent

* documentation WIP

* wip

* document audiosfx.c

* fix build

* a few type renames

* update score

* remove comment

* fix type

* fix typo
This commit is contained in:
Unnunu
2025-05-05 15:47:26 +03:00
committed by GitHub
parent 7063517833
commit b88bd4366e
31 changed files with 1109 additions and 742 deletions
+11 -11
View File
@@ -7,9 +7,9 @@ All versions are supported, and the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fd
<!-- README_SCORE_SUMMARY_BEGIN -->
As of May 5, 2025, this is our current score:
&emsp;&emsp;&emsp;&emsp;Decomp progress: 84.46%
&emsp;&emsp;&emsp;&emsp;Decomp progress: 84.89%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 53.79%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 54.49%
<!-- README_SCORE_SUMMARY_END -->
---
@@ -121,26 +121,26 @@ As of May 5, 2025, this is our current score:
```
========================================================
ADVENTURE ONE (ASM -> C Decompilation)
-------- 84.46% Complete (86.01% NON_MATCHING) ---------
# Decompiled functions: 1878
# GLOBAL_ASM remaining: 73
-------- 84.89% Complete (86.44% NON_MATCHING) ---------
# Decompiled functions: 1880
# GLOBAL_ASM remaining: 71
# NON_MATCHING functions: 8
# NON_EQUIVALENT WIP functions: 26
# NON_EQUIVALENT WIP functions: 25
--------------------- Game Status ----------------------
Balloons: 39/47, Keys: 4/4, Trophies: 4/5
T.T. Amulets: 4/4, Wizpig Amulets: 4/4
--------------------------------------------------------
We are racing the wizard pig boss Wizpig. (Lap 3/3)
We are racing in Spacedust Alley. (Lap 1/3)
========================================================
ADVENTURE TWO (Cleanup & Documentation)
------------------- 53.79% Complete --------------------
# Documented functions: 1138
# Undocumented remaining: 516
------------------- 54.49% Complete --------------------
# Documented functions: 1154
# Undocumented remaining: 500
--------------------- Game Status ----------------------
Balloons: 26/47, Keys: 3/4, Trophies: 2/5
T.T. Amulets: 2/4, Wizpig Amulets: 2/4
--------------------------------------------------------
We are battling in Darkwater Beach. (2 opponents remain)
We are battling in Darkwater Beach. (1 opponent remains)
========================================================
```
<!-- README_SCORE_END -->
-23
View File
@@ -592,28 +592,6 @@ typedef struct {
u8 chan;
} ALOscEvent;
typedef struct ALSoundState {
/* 0x00 */ struct ALSoundState *next;
/* 0x04 */ struct ALSoundState *prev;
/* 0x08 */ struct ALSoundState *unk8;
/* 0x0C */ ALVoice voice;
/* 0x28 */ ALSound *sound; /* sound referenced here */
/* 0x2C */ s16 priority;
/* 0x30 */ struct ALSoundState *unk30;
/* 0x34 */ u8 pad34[0x2];
/* 0x34 */ u8 soundPriority;
/* 0x38 */ s16 vol; /* volume - combined with volume from bank */
/* 0x3A */ ALPan pan; /* pan - 0 = left, 127 = right */
/* 0x3C */ u8 fxMix; /* wet/dry mix - 0 = dry, 127 = wet */
/* 0x3C */ u8 pad3C[2];
/* 0x3E */ u8 flags;
/* 0x3F */ u8 soundState;
} ALSoundState;
typedef struct {
ALSoundState *soundState;
} ALSoundEvent;
typedef struct {
s16 type;
union {
@@ -628,7 +606,6 @@ typedef struct {
ALSeqpSeqEvent spseq;
ALSeqpBankEvent spbank;
ALOscEvent osc;
ALSoundEvent sndpevent;
} msg;
} ALEvent;
+3
View File
@@ -81,4 +81,7 @@
// A few systems in the game use an array as a cache table. This gives you the pointer to the asset
#define ASSETCACHE_PTR(x) ((x << 1) + 1)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
+16 -15
View File
@@ -9,6 +9,7 @@
#include "object_properties.h"
#include "gbi.h"
#include "PR/libaudio.h"
#include "audio.h"
typedef struct Vec4f {
union {
@@ -109,7 +110,7 @@ typedef struct SoundMask {
/* 0x11 */ u8 unk11;
/* 0x12 */ u8 unk12;
/* 0x14 */ s32 distance;
/* 0x18 */ ALSoundState *soundPtr;
/* 0x18 */ SoundHandle soundPtr;
/* 0x1C */ struct SoundMask **soundMask;
/* 0x20 */ u8 unk20;
/* 0x21 */ u8 unk21;
@@ -964,7 +965,7 @@ typedef struct Object_Animation {
/* 0x0C */ f32 x;
/* 0x10 */ f32 y;
/* 0x14 */ f32 z;
/* 0x18 */ u8 *unk18;
/* 0x18 */ SoundHandle unk18;
/* 0x1C */ struct Object *unk1C;
/* 0x20 */ s32 unk20;
/* 0x24 */ s16 unk24;
@@ -1031,7 +1032,7 @@ typedef struct Object_Weapon {
/* 0x18 */ u8 weaponID;
/* 0x19 */ s8 checkpoint;
/* 0x19 */ s16 unk1A;
/* 0x19 */ SoundMask *soundMask;
/* 0x19 */ SoundHandle soundMask;
} Object_Weapon;
typedef struct Object_Butterfly {
@@ -1225,11 +1226,11 @@ typedef struct Object_Racer {
/* 0x004 */ s32 unk4;
/* 0x008 */ f32 forwardVel;
/* 0x00C */ f32 animationSpeed;
/* 0x010 */ s32 unk10;
/* 0x014 */ s32 unk14;
/* 0x018 */ s32 unk18;
/* 0x01C */ s32 unk1C;
/* 0x020 */ s32 unk20;
/* 0x010 */ SoundHandle unk10;
/* 0x014 */ SoundHandle unk14;
/* 0x018 */ SoundHandle unk18;
/* 0x01C */ SoundHandle unk1C;
/* 0x020 */ SoundHandle unk20;
/* 0x024 */ SoundMask *soundMask;
/* 0x028 */ u16 lastSoundID;
/* 0x02A */ u16 unk2A;
@@ -1312,7 +1313,7 @@ typedef struct Object_Racer {
/* 0x174 */ s8 balloon_level;
/* 0x175 */ s8 magnetTimer;
/* 0x176 */ s16 unk176;
/* 0x178 */ void *magnetSoundMask;
/* 0x178 */ SoundHandle magnetSoundMask;
/* 0x17C */ SoundMask *shieldSoundMask;
/* 0x180 */ SoundMask *bananaSoundMask;
/* 0x184 */ s8 magnetModelID;
@@ -1427,14 +1428,14 @@ typedef struct Object_Racer {
/* 0x215 */ s8 unk215;
/* 0x216 */ u8 unk216;
/* 0x217 */ u8 unk217;
/* 0x218 */ s32 weaponSoundMask;
/* 0x21C */ SoundMask *unk21C;
/* 0x220 */ s32 unk220;
/* 0x218 */ SoundHandle weaponSoundMask;
/* 0x21C */ SoundHandle unk21C;
/* 0x220 */ SoundHandle unk220;
} Object_Racer;
typedef struct Object_Door {
/* 0x00 */ f32 homeY;
/* 0x04 */ SoundMask *soundMask;
/* 0x04 */ SoundHandle soundMask;
/* 0x08 */ s32 jingleTimer;
/* 0x0A */ s16 jingleCooldown;
/* 0x0E */ s8 doorID;
@@ -1551,7 +1552,7 @@ typedef struct Object_TT {
typedef struct Object_Bridge_WhaleRamp {
/* 0x0 */ f32 homeY;
/* 0x4 */ SoundMask *soundMask;
/* 0x4 */ SoundHandle soundMask;
} Object_Bridge_WhaleRamp;
typedef struct Object_64_80021400 {
@@ -1578,7 +1579,7 @@ typedef struct Object_Log {
typedef struct Object_Fireball_Octoweapon {
u8 pad0[0x1C];
s32 soundMask;
SoundHandle soundMask;
} Object_Fireball_Octoweapon;
typedef struct Object_AnimatedObject {
+1 -1
View File
@@ -69,7 +69,7 @@ s32 alAuxBusParam(void *filter, s32 paramID, void *param) {
}
void func_80065A80(ALSynth *arg0, PVoice *arg1, s16 arg2) {
void func_80065A80(ALSynth *arg0, struct PVoice_s *arg1, s16 arg2) {
if (arg2 != arg1->unkDC) {
alAuxBusParam(&arg0->auxBus[arg1->unkDC], AL_FILTER_UNK11, &arg1->envmixer);
alAuxBusParam(&arg0->auxBus[arg2], AL_FILTER_ADD_SOURCE, &arg1->envmixer);
+1 -1
View File
@@ -56,7 +56,7 @@ static void __CSPHandleMIDIMsg(ALCSPlayer_Custom *seqp, ALEvent *eve
static void __CSPHandleMetaMsg(ALCSPlayer *seqp, ALEvent *event);
static void __CSPRepostEvent(ALEventQueue *evtq, ALEventListItem *item);
static void __setUsptFromTempo(ALCSPlayer *seqp, f32 tempo); /* sct 1/8/96 */
void func_80065A80(ALSynth *arg0, PVoice *arg1, s16 arg2);
void func_80065A80(ALSynth *arg0, struct PVoice_s *arg1, s16 arg2);
/*
+63 -64
View File
@@ -5,7 +5,6 @@
#include "macros.h"
#include "asset_enums.h"
#include "asset_loading.h"
#include "audio_internal.h"
#include "audiomgr.h"
#include "audiosfx.h"
#include "audio_spatial.h"
@@ -67,9 +66,9 @@ ALCSeq gJingleSequence;
u8 gSkipResetChannels; // Stored and used by a single function, but redundant.
u8 gAudioVolumeSetting;
u32 gDynamicMusicChannelMask;
SoundMask *gGlobalSoundMask;
SoundMask *gSpatialSoundMask;
SoundMask *gRacerSoundMask;
SoundHandle gGlobalSoundMask;
SoundHandle gSpatialSoundMask;
SoundHandle gRacerSoundMask;
/******************************/
@@ -142,16 +141,16 @@ void audio_init(OSSched *sc) {
gJinglePlayer = sound_seqplayer_init(16, 50);
gMusicSequenceData = mempool_alloc_safe(seqLength, COLOUR_TAG_CYAN);
gJingleSequenceData = mempool_alloc_safe(seqLength, COLOUR_TAG_CYAN);
audConfig.unk04 = 150;
audConfig.unk00 = 32;
audConfig.maxEvents = 150;
audConfig.maxSounds = 32;
audConfig.maxChannels = AUDIO_CHANNELS;
audConfig.unk10 = 1;
audConfig.hp = &gALHeap;
alSndPNew(&audConfig);
audConfig.numGroups = 1;
audConfig.heap = &gALHeap;
sndp_init_player(&audConfig);
audioStartThread();
sound_volume_change(VOLUME_NORMAL);
mempool_free(addrPtr);
set_sound_channel_count(10);
sndp_set_active_sound_limit(10);
gBlockMusicChange = FALSE;
gMusicPlaying = FALSE;
gJinglePlaying = FALSE;
@@ -173,10 +172,10 @@ void sound_volume_reset(u8 skipReset) {
if (gSkipResetChannels == FALSE) {
gGlobalMusicVolume = 256;
music_volume_set(gMusicBaseVolume);
set_sound_channel_volume(0, gGlobalMusicVolume * 128 - 1);
set_sound_channel_volume(1, gGlobalMusicVolume * 128 - 1);
set_sound_channel_volume(2, gGlobalMusicVolume * 128 - 1);
set_sound_channel_volume(4, gGlobalMusicVolume * 128 - 1);
sndp_set_group_volume(0, gGlobalMusicVolume * 128 - 1);
sndp_set_group_volume(1, gGlobalMusicVolume * 128 - 1);
sndp_set_group_volume(2, gGlobalMusicVolume * 128 - 1);
sndp_set_group_volume(4, gGlobalMusicVolume * 128 - 1);
}
}
}
@@ -187,32 +186,32 @@ void sound_volume_reset(u8 skipReset) {
void sound_volume_change(s32 behaviour) {
switch (behaviour) {
case VOLUME_LOWER: // Mute most sound effects and half the volume of music.
set_sound_channel_volume(0, 0);
set_sound_channel_volume(1, 32767);
set_sound_channel_volume(2, 0);
set_sound_channel_volume(4, 0);
sndp_set_group_volume(0, 0);
sndp_set_group_volume(1, 32767);
sndp_set_group_volume(2, 0);
sndp_set_group_volume(4, 0);
alCSPSetVol(gMusicPlayer, (s16) (gMusicBaseVolume * gMusicSliderVolume >> 2));
alCSPSetVol(gJinglePlayer, 0);
break;
case VOLUME_LOWER_AMBIENT: // Mute the ambient channel, making course elements stop making noise.
set_sound_channel_volume(0, 0);
set_sound_channel_volume(1, 32767);
set_sound_channel_volume(2, 32767);
set_sound_channel_volume(4, 32767);
sndp_set_group_volume(0, 0);
sndp_set_group_volume(1, 32767);
sndp_set_group_volume(2, 32767);
sndp_set_group_volume(4, 32767);
break;
case VOLUME_UNK03:
set_sound_channel_volume(0, 0);
set_sound_channel_volume(1, 32767);
set_sound_channel_volume(2, 0);
set_sound_channel_volume(4, 0);
sndp_set_group_volume(0, 0);
sndp_set_group_volume(1, 32767);
sndp_set_group_volume(2, 0);
sndp_set_group_volume(4, 0);
break;
default: // Restore sound back to normal.
set_sound_channel_volume(0, 32767);
set_sound_channel_volume(1, 32767);
set_sound_channel_volume(2, 32767);
set_sound_channel_volume(4, 32767);
sndp_set_group_volume(0, 32767);
sndp_set_group_volume(1, 32767);
sndp_set_group_volume(2, 32767);
sndp_set_group_volume(4, 32767);
alCSPSetVol(gMusicPlayer, (s16) (gMusicBaseVolume * gMusicSliderVolume));
alCSPSetVol(gJinglePlayer, (s16) (get_sfx_volume_slider() * sfxRelativeVolume));
alCSPSetVol(gJinglePlayer, (s16) (sndp_get_global_volume() * sfxRelativeVolume));
break;
}
gAudioVolumeSetting = behaviour;
@@ -337,13 +336,13 @@ void sound_update_queue(u8 updateRate) {
gDelayedSounds[i].timer -= updateRate;
if (gDelayedSounds[i].timer <= 0) {
j = i;
sound_play(gDelayedSounds[i].soundId, (s32 *) gDelayedSounds[i].soundMask);
sound_play(gDelayedSounds[i].soundId, gDelayedSounds[i].handlePtr);
gDelayedSoundsCount -= 1;
while (j < gDelayedSoundsCount) {
gDelayedSounds[i].soundId = gDelayedSounds[i + 1].soundId;
gDelayedSounds[i].timer = gDelayedSounds[i + 1].timer;
gDelayedSounds[i].soundMask = gDelayedSounds[i + 1].soundMask;
gDelayedSounds[i].handlePtr = gDelayedSounds[i + 1].handlePtr;
j++;
}
j++;
@@ -364,10 +363,10 @@ void sound_update_queue(u8 updateRate) {
* Add a sound to a queue to play after a set time has passed.
* Delay time is in seconds. (1.0f = 1 second)
*/
void sound_play_delayed(u16 soundId, SoundMask *soundMask, f32 delayTime) {
void sound_play_delayed(u16 soundId, SoundHandle *handlePtr, f32 delayTime) {
if (gDelayedSoundsCount < 8) {
gDelayedSounds[gDelayedSoundsCount].soundId = soundId;
gDelayedSounds[gDelayedSoundsCount].soundMask = soundMask;
gDelayedSounds[gDelayedSoundsCount].handlePtr = handlePtr;
gDelayedSounds[gDelayedSoundsCount].timer = delayTime * 60.0f;
gDelayedSoundsCount++;
}
@@ -735,7 +734,7 @@ s32 music_volume_config(void) {
*/
void music_jingle_volume_set(u8 arg0) {
sfxRelativeVolume = arg0;
alCSPSetVol(gJinglePlayer, (s16) (get_sfx_volume_slider() * sfxRelativeVolume));
alCSPSetVol(gJinglePlayer, (s16) (sndp_get_global_volume() * sfxRelativeVolume));
}
/**
@@ -777,7 +776,7 @@ u32 music_jingle_playing(void) {
UNUSED void sound_channel_volume_all(u16 volume) {
u32 i;
for (i = 0; i < 64; i++) {
set_sound_channel_volume(i, volume << 8);
sndp_set_group_volume(i, volume << 8);
}
}
@@ -795,37 +794,37 @@ u16 sound_distance(u16 soundId) {
* Add the requested sound to the queue and update the mask to show that this sound is playing at that source.
* If no soundmask is provided, then instead use the global mask.
*/
void sound_play(u16 soundID, s32 *soundMask) {
void sound_play(u16 soundID, SoundHandle *handlePtr) {
f32 pitch;
s32 soundBite;
if (soundID > gSoundCount) {
if (soundMask != NULL) {
*soundMask = NULL;
if (handlePtr != NULL) {
*handlePtr = NULL;
}
stubbed_printf("amSndPlay: Illegal sound effects table index\n");
return;
}
soundBite = gSoundTable[soundID].soundBite;
if (soundBite == NULL) {
if (soundMask != NULL) {
*soundMask = NULL;
if (handlePtr != NULL) {
*handlePtr = NULL;
}
return;
}
pitch = gSoundTable[soundID].pitch / 100.0f;
if (soundMask != NULL) {
func_80004668(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, (SoundMask *) soundMask);
if (*soundMask != NULL) {
sound_event_update(*soundMask, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256);
sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32 *) &pitch));
if (handlePtr != NULL) {
sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, handlePtr);
if (*handlePtr != NULL) {
sndp_set_param(*handlePtr, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256);
sndp_set_param(*handlePtr, AL_SNDP_PITCH_EVT, *((u32 *) &pitch));
}
} else {
soundMask = (s32 *) &gGlobalSoundMask;
func_80004668(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, (SoundMask *) &gGlobalSoundMask);
if (*soundMask != NULL) {
sound_event_update(*soundMask, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256);
sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32 *) &pitch));
handlePtr = &gGlobalSoundMask;
sndp_play_with_priority(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, &gGlobalSoundMask);
if (*handlePtr != NULL) {
sndp_set_param(*handlePtr, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256);
sndp_set_param(*handlePtr, AL_SNDP_PITCH_EVT, *((u32 *) &pitch));
}
}
}
@@ -835,7 +834,7 @@ void sound_play(u16 soundID, s32 *soundMask) {
* This then makes the audio pan around in 3D space.
* If it is not given a mask, then it will use the global mask.
*/
void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **soundMask) {
void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle *soundMask) {
if (soundMask == NULL) {
soundMask = (s32 **) &gSpatialSoundMask;
}
@@ -856,28 +855,28 @@ void func_80001F14(u16 soundID, s32 *soundMask) {
return;
}
if (soundMask) {
func_80004638(gSoundBank->bankArray[0], (s16) soundID, (SoundMask *) soundMask);
sndp_play(gSoundBank->bankArray[0], (s16) soundID, soundMask);
} else {
func_80004638(gSoundBank->bankArray[0], (s16) soundID, (SoundMask *) &gRacerSoundMask);
sndp_play(gSoundBank->bankArray[0], (s16) soundID, &gRacerSoundMask);
}
}
/**
* Set the volume of the sound relative to the baseline volume of the sound ID.
*/
void sound_volume_set_relative(u16 soundID, void *soundState, u8 volume) {
void sound_volume_set_relative(u16 soundID, SoundHandle soundHandle, u8 volume) {
s32 newVolume = ((s32) (gSoundTable[soundID].volume * (volume / 127.0f))) * 256;
if (soundState) {
sound_event_update((s32) soundState, AL_SNDP_VOL_EVT, newVolume);
if (soundHandle) {
sndp_set_param(soundHandle, AL_SNDP_VOL_EVT, newVolume);
}
}
/**
* Updates the volume of the given sound mask.
*/
UNUSED void sound_volume_set(SoundMask *soundMask, u8 arg1) {
if (soundMask != NULL) {
sound_event_update((s32) soundMask, AL_SNDP_VOL_EVT, arg1 * 256);
UNUSED void sound_volume_set(SoundHandle soundHandle, u8 arg1) {
if (soundHandle != NULL) {
sndp_set_param(soundHandle, AL_SNDP_VOL_EVT, arg1 * 256);
}
}
@@ -885,10 +884,10 @@ UNUSED void sound_volume_set(SoundMask *soundMask, u8 arg1) {
* Updates the pitch of the given sound mask.
* Official name: amSndSetPitchDirect
*/
UNUSED void sound_pitch_set(SoundMask *soundMask, u32 pitch) {
UNUSED void sound_pitch_set(SoundHandle soundHandle, u32 pitch) {
u32 *pitchAddr = &pitch;
if (soundMask != NULL) {
sound_event_update((s32) soundMask, AL_SNDP_PITCH_EVT, *pitchAddr);
if (soundHandle != NULL) {
sndp_set_param(soundHandle, AL_SNDP_PITCH_EVT, *pitchAddr);
}
}
+7 -7
View File
@@ -2,9 +2,7 @@
#define _AUDIO_H_
#include "types.h"
#include "audio_internal.h"
#include "sched.h"
#include "structs.h"
#define AUDIO_CHANNELS 16
#define MUSIC_CHAN_MASK_NONE 0xFFFFFFFF
@@ -16,6 +14,8 @@ enum AudioVolumeBehaviour {
VOLUME_UNK03,
};
typedef struct ALSoundState* SoundHandle;
/* Size: 0x0A bytes */
typedef struct SoundData {
u16 soundBite; // Audio file index.
@@ -40,7 +40,7 @@ typedef struct MusicData {
typedef struct DelayedSound {
/* 0x00 */ u16 soundId;
/* 0x02 */ s16 timer;
/* 0x04 */ SoundMask *soundMask;
/* 0x04 */ SoundHandle handlePtr;
} DelayedSound;
void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); //lib/src/al/csplayer.c
@@ -74,7 +74,7 @@ void music_jingle_voicelimit_set(u8 voiceLimit);
void music_fade(s32 time);
void music_volume_reset(void);
void sound_update_queue(u8 updateRate);
void sound_play_delayed(u16 soundId, SoundMask *soundMask, f32 delayTime);
void sound_play_delayed(u16 soundId, SoundHandle *soundMask, f32 delayTime);
void sound_clear_delayed(void);
u16 music_channel_get_mask(void);
void music_dynamic_set(u16 channelMask);
@@ -106,7 +106,7 @@ void music_jingle_pan_set(ALPan pan);
void music_jingle_play(u8 seqID);
u32 music_jingle_playing(void);
u16 sound_distance(u16 soundId);
void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **soundMask);
void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, SoundHandle*soundMask);
void func_80001F14(u16 soundID, s32 *soundMask);
u16 sound_count(void);
u8 music_sequence_count(void);
@@ -118,9 +118,9 @@ void music_sequence_stop(ALCSPlayer *seqPlayer);
void sound_reverb_set(u8 setting);
void alSeqFileNew(ALSeqFile *file, u8 *base);
void func_80063A90(ALCSPlayer *seqp, u8 channel);
void sound_volume_set_relative(u16 soundID, void *soundState, u8 volume);
void sound_volume_set_relative(u16 soundID, SoundHandle soundState, u8 volume);
void music_sequence_init(ALCSPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *seq);
void sound_play(u16 soundID, s32* soundMask);
void sound_play(u16 soundID, SoundHandle* handlePtr);
f32 music_animation_fraction(void);
#endif
+5 -6
View File
@@ -1,7 +1,6 @@
#include "audio_spatial.h"
#include "types.h"
#include "macros.h"
#include "audio_internal.h"
#include "audio_vehicle.h"
#include "memory.h"
#include "audio.h"
@@ -85,7 +84,7 @@ void audioline_on(void) {
void audioline_reset(void) {
s32 i;
s32 j;
ALSoundState *sound;
SoundHandle sound;
SoundMask *heap;
f32 *ptr;
@@ -103,7 +102,7 @@ void audioline_reset(void) {
sound = gSoundMaskHeapUsed[i]->soundPtr;
gSoundMaskHeapUsed[i]->unk12 = 0;
if (sound != NULL) {
sound_stop(sound);
sndp_stop(sound);
}
}
gUsedMasks = 0;
@@ -112,7 +111,7 @@ void audioline_reset(void) {
D_80119C58[i].soundID = 0;
if (D_80119C58[i].soundPtr != 0) {
if (D_80119C58[i].unk0_02 == 0) {
sound_stop(D_80119C58[i].soundPtr);
sndp_stop(D_80119C58[i].soundPtr);
} else if (D_80119C58[i].unk0_02 == 1) {
music_jingle_stop();
}
@@ -439,7 +438,7 @@ void audioline_reverb(s32 *soundState, f32 x, f32 y, f32 z) {
}
}
if (soundState != NULL) {
sound_event_update((s32) soundState, AL_SNDP_FX_EVT, (u32) volume);
sndp_set_param((s32) soundState, AL_SNDP_FX_EVT, (u32) volume);
}
}
@@ -549,7 +548,7 @@ void debug_render_audio_effects(Gfx **dList, Vertex **verts, Triangle **tris) {
void func_8000A2E8(s32 arg0) {
if (gUsedMasks != 0) {
if (gSoundMaskHeapUsed[arg0]->soundPtr != 0) {
sound_stop(gSoundMaskHeapUsed[arg0]->soundPtr);
sndp_stop(gSoundMaskHeapUsed[arg0]->soundPtr);
}
if (gSoundMaskHeapUsed[arg0]->soundMask != NULL) {
*gSoundMaskHeapUsed[arg0]->soundMask = NULL;
+1 -17
View File
@@ -16,13 +16,6 @@ typedef struct floatXYZVals {
f32 z2;
} floatXYZVals;
/* Size: 0x0C / 12 bytes - Possibly just a Vec3f? */
typedef struct unk8011A6D8_04 {
/* 0x00 */ f32 unk0;
/* 0x04 */ f32 unk4;
/* 0x08 */ f32 unk8;
} unk8011A6D8_04;
/* Size: 0x180 / 384 bytes */
typedef struct unk80119C58 {
/* 0x000 */ u8 unk0_02;
@@ -33,7 +26,7 @@ typedef struct unk80119C58 {
/* 0x175 */ u8 unk175;
/* 0x176 */ u8 unk176;
/* 0x177 */ u8 unk177;
/* 0x178 */ ALSoundState *soundPtr;
/* 0x178 */ SoundHandle soundPtr;
/* 0x17C */ s8 unk17C;
/* 0x17D */ u8 unk17D;
/* 0x17E */ u8 unk17E;
@@ -48,15 +41,6 @@ typedef struct unk8011A6D8 {
/* 0xBC */ f32 unkBC;
} unk8011A6D8;
typedef struct unk800A414_arg3 {
f32 unk0;
f32 unk4;
f32 unk8;
f32 unkC;
f32 unk10;
f32 unk14;
} unk800A414_arg3;
void audioline_on(void);
void func_800096F8(SoundMask *);
void audioline_off(void);
+27 -28
View File
@@ -310,7 +310,7 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR
if (((gSoundRacerObj->unk10 != 0) || (gSoundRacerObj->unk14 != 0) || !(buttonsHeld & B_BUTTON) ||
(gSoundRacerObj->velocity > -0.1) || (gSoundRacerObj->vehicleID == 4)) &&
(gRacerSound->unkA8 != 0)) {
sound_stop(gRacerSound->unkA8);
sndp_stop(gRacerSound->unkA8);
gRacerSound->unkA8 = 0;
} else if ((buttonsPressed & B_BUTTON) && (gRacerSound->unkA8 == 0) && (gSoundRacerObj->playerIndex >= 0)) {
if (gSoundRacerObj->velocity < 0.0f) {
@@ -325,7 +325,7 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR
sp6C = (((var_f20 * 0.5) / 12.0) + 0.5);
temp_a0_4 = (s32) gRacerSound->unkA8;
if (temp_a0_4 != 0) {
sound_event_update(temp_a0_4, AL_SNDP_PITCH_EVT, *((u32 *) &sp6C));
sndp_set_param(temp_a0_4, AL_SNDP_PITCH_EVT, *((u32 *) &sp6C));
}
gRacerSound->unkAC = 110;
gRacerSound->unkD0 = 0;
@@ -337,9 +337,9 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR
gRacerSound->unkD0 = 0;
}
if (gRacerSound->unkD0 >= 10) {
sound_event_update((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, 0);
sndp_set_param((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, 0);
} else {
sound_event_update((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, gRacerSound->unkAC << 8);
sndp_set_param((s32) gRacerSound->unkA8, AL_SNDP_VOL_EVT, gRacerSound->unkAC << 8);
audioline_reverb((s32 *) gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position,
obj->segment.trans.z_position);
}
@@ -549,7 +549,7 @@ void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32
} else if (gSoundRacerObj->spinout_timer == 0) {
gRacerSound->brakeSound = FALSE;
if (gRacerSound->brakeSoundMask != NULL) {
sound_stop(gRacerSound->brakeSoundMask);
sndp_stop(gRacerSound->brakeSoundMask);
}
}
}
@@ -567,16 +567,16 @@ void racer_sound_free(Object *obj) {
if (gRacerSound != NULL) {
for (i = 0; i != 2; i++) {
if (gRacerSound->unk48[i] != NULL) {
sound_stop(gRacerSound->unk48[i]);
sndp_stop(gRacerSound->unk48[i]);
gRacerSound->unk48[i] = 0;
}
}
if (gRacerSound->unk50 != NULL) {
sound_stop(gRacerSound->unk50);
sndp_stop(gRacerSound->unk50);
gRacerSound->unk50 = NULL;
}
if (gRacerSound->unkA8 != NULL) {
sound_stop(gRacerSound->unkA8);
sndp_stop(gRacerSound->unkA8);
gRacerSound->unkA8 = 0;
}
for (i = 0; i < ARRAY_COUNT(D_80119C30); i++) {
@@ -732,17 +732,17 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
audioline_reverb((s32 *) gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position,
objs[loopCount1]->segment.trans.y_position,
objs[loopCount1]->segment.trans.z_position);
sound_event_update((s32) gRacerSound->unk50, AL_SNDP_VOL_EVT, temp_s3 << 8);
sound_event_update((s32) gRacerSound->unk50, AL_SNDP_PITCH_EVT, *((u32 *) &sp8C));
func_80004604((ALSoundState *) gRacerSound->unk50, 80);
sound_event_update((s32) gRacerSound->unk50, AL_SNDP_PAN_EVT, gRacerSound->unk91[0]);
sndp_set_param(gRacerSound->unk50, AL_SNDP_VOL_EVT, temp_s3 << 8);
sndp_set_param(gRacerSound->unk50, AL_SNDP_PITCH_EVT, *((u32 *) &sp8C));
sndp_set_priority(gRacerSound->unk50, 80);
sndp_set_param(gRacerSound->unk50, AL_SNDP_PAN_EVT, gRacerSound->unk91[0]);
}
} else if (gRacerSound->unk50 != NULL) {
sound_stop(gRacerSound->unk50);
sndp_stop(gRacerSound->unk50);
gRacerSound->unk50 = 0;
}
} else if (gRacerSound->unk50 != NULL) {
sound_stop(gRacerSound->unk50);
sndp_stop(gRacerSound->unk50);
gRacerSound->unk50 = 0;
}
for (loopCount2 = 0; loopCount2 < 2 && gRacerSound->unk0[loopCount2] != 0 && var_f26 != 0.0; loopCount2++) {
@@ -754,12 +754,12 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
}
if ((loopCount2 == 0) && (gRacerSound->unk44[0] & 1)) {
if (gRacerSound->unk48[0] != NULL) {
sound_stop(gRacerSound->unk48[0]);
sndp_stop(gRacerSound->unk48[0]);
gRacerSound->unk48[0] = NULL;
}
} else {
if ((gRacerSound->unk48[loopCount2] != NULL) && (temp_s3 == 0)) {
sound_stop(gRacerSound->unk48[loopCount2]);
sndp_stop(gRacerSound->unk48[loopCount2]);
gRacerSound->unk48[loopCount2] = NULL;
} else {
if (gRacerSound->unk48[loopCount2] == NULL) {
@@ -769,15 +769,14 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
audioline_reverb(
(s32 *) gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position,
objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position);
sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_VOL_EVT, temp_s3 << 8);
sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_PITCH_EVT,
*((u32 *) &sp8C));
func_80004604((ALSoundState *) gRacerSound->unk48[loopCount2], 80);
sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_VOL_EVT, temp_s3 << 8);
sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_PITCH_EVT, *((u32 *) &sp8C));
sndp_set_priority(gRacerSound->unk48[loopCount2], 80);
if (arg3 != 1) {
gRacerSound->unk91[0] = 64;
}
sound_event_update((s32) gRacerSound->unk48[loopCount2], AL_SNDP_PAN_EVT,
gRacerSound->unk91[0]);
sndp_set_param(gRacerSound->unk48[loopCount2], AL_SNDP_PAN_EVT,
gRacerSound->unk91[0]);
}
}
}
@@ -847,7 +846,7 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
for (loopCount3 = 0; loopCount3 < ARRAY_COUNT(D_80119C30); loopCount3++) {
if (D_80119C30[loopCount3] != NULL) {
if (D_80119C30[loopCount3]->unk48[0] != NULL && D_80119C30[loopCount3]->unk88 < 8) {
sound_stop(D_80119C30[loopCount3]->unk48[0]);
sndp_stop(D_80119C30[loopCount3]->unk48[0]);
D_80119C30[loopCount3]->unk48[0] = NULL;
D_80119C30[loopCount3]->unk74 = 0;
D_80119C30[loopCount3] = NULL;
@@ -884,7 +883,7 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
gRacerSound->unk74 = 2;
if (D_80119C30[loopCount3] != NULL) {
if (D_80119C30[loopCount3]->unk48[0] != NULL) {
sound_stop(D_80119C30[loopCount3]->unk48[0]);
sndp_stop(D_80119C30[loopCount3]->unk48[0]);
D_80119C30[loopCount3]->unk48[0] = NULL;
gRacerSound->unk74 = 1;
}
@@ -912,13 +911,13 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3
if (temp->unk48[0] != NULL) {
audioline_reverb((s32 *) temp->unk48[0], temp->racerPos.x, temp->racerPos.y,
temp->racerPos.z);
sound_event_update((s32) temp->unk48[0], AL_SNDP_VOL_EVT, temp->unk88 << 8);
sound_event_update((s32) temp->unk48[0], AL_SNDP_PITCH_EVT, *((u32 *) &temp->unk8C));
sndp_set_param(temp->unk48[0], AL_SNDP_VOL_EVT, temp->unk88 << 8);
sndp_set_param(temp->unk48[0], AL_SNDP_PITCH_EVT, *((u32 *) &temp->unk8C));
if (arg3 != 1) {
temp->unk91[0] = 64;
}
sound_event_update((s32) temp->unk48[0], AL_SNDP_PAN_EVT, temp->unk91[0]);
func_80004604((ALSoundState *) temp->unk48[0], 70);
sndp_set_param(temp->unk48[0], AL_SNDP_PAN_EVT, temp->unk91[0]);
sndp_set_priority(temp->unk48[0], 70);
}
}
}
+4 -4
View File
@@ -33,8 +33,8 @@ typedef struct VehicleSoundData {
/* 0x3C */ f32 bananaPitch;
/* 0x40 */ f32 unk40;
/* 0x44 */ u8 unk44[4];
/* 0x48 */ u8 *unk48[2]; //soundMask / soundState?
/* 0x50 */ u8 *unk50;
/* 0x48 */ SoundHandle unk48[2]; //soundMask / soundState?
/* 0x50 */ SoundHandle unk50;
/* 0x54 */ f32 unk54[2];
/* 0x5C */ f32 unk5C[2];
/* 0x64 */ u8 unk64;
@@ -52,7 +52,7 @@ typedef struct VehicleSoundData {
/* 0x99 */ u8 pad99[0x7];
/* 0xA0 */ u8 unkA0;
/* 0xA4 */ f32 throttlePitch; // Engine noise for the hovercraft and plane.
/* 0xA8 */ SoundMask *unkA8;
/* 0xA8 */ SoundHandle unkA8;
/* 0xAC */ u16 unkAC;
/* 0xB0 */ f32 throttlePitchVel;
/* 0xB4 */ f32 throttlePitchDecay;
@@ -65,7 +65,7 @@ typedef struct VehicleSoundData {
/* 0xD0 */ u8 unkD0;
/* 0xD4 */ f32 basePitch;
/* 0xD8 */ u8 brakeSound; //Sound is playing bool?
/* 0xDC */ SoundMask *brakeSoundMask; //soundMask / soundState?
/* 0xDC */ SoundHandle brakeSoundMask; //soundMask / soundState?
} VehicleSoundData;
/* Size: 0x4C / 76 Bytes */
-1
View File
@@ -1,6 +1,5 @@
#include "audiomgr.h"
#include "memory.h"
#include "audio_internal.h"
#include "video.h"
#include "math_util.h"
#include "asset_loading.h"
-1
View File
@@ -3,7 +3,6 @@
#include "types.h"
#include "macros.h"
#include "audio_internal.h"
#include "asset_enums.h"
#include <ultra64.h>
#include "sched.h"
+654 -207
View File
File diff suppressed because it is too large Load Diff
+86 -126
View File
@@ -3,14 +3,14 @@
#include "types.h"
#include "macros.h"
#include "audio_internal.h"
#include "asset_enums.h"
#include <ultra64.h>
#include "sched.h"
#include "structs.h"
#include "audio.h"
#define AL_SNDP_PLAY_EVT (1 << 0)
#define AL_SNDP_STOP_EVT (1 << 1)
#define AL_SNDP_RELEASE_EVT (1 << 1)
#define AL_SNDP_PAN_EVT (1 << 2)
#define AL_SNDP_VOL_EVT (1 << 3)
#define AL_SNDP_PITCH_EVT (1 << 4)
@@ -18,161 +18,121 @@
#define AL_SNDP_DECAY_EVT (1 << 6)
#define AL_SNDP_END_EVT (1 << 7)
#define AL_SNDP_FX_EVT (1 << 8)
#define AL_SNDP_UNK_9_EVT (1 << 9)
#define AL_SNDP_UNK_10_EVT (1 << 10)
#define AL_SNDP_UNK_11_EVT (1 << 11)
#define AL_SNDP_RETRIGGER_EVT (1 << 9)
#define AL_SNDP_STOP_EVT (1 << 10)
#define AL_SNDP_GROUP_VOL_EVT (1 << 11)
#define AL_SNDP_RELEASE_NEXT_EVT (1 << 12)
typedef struct ALUnkStruct {
/* 0x00 */ struct ALSoundState *next;
/* 0x04 */ struct ALSoundState *prev;
/* 0x08 */ struct ALSoundState *unk8;
} ALUnkStruct;
#define AL_SNDP_PRIORITY_DEFAULT 64
#define AL_SNDP_GROUP_VOLUME_MAX 32767
// typedef struct {
// u8 pad[0x36];
// u8 priority;
// u8 pad37[0x7];
// u8 flags;
// u8 state;
// } AlMsgUnk400Type_Unk0;
enum SoundFlags {
SOUND_FLAG_FINAL_IN_SEQUENCE = 1 << 0,
SOUND_FLAG_LOOPED = 1 << 1,
SOUND_FLAG_PLAYING = 1 << 2,
SOUND_FLAG_RETRIGGER = 1 << 4,
SOUND_FLAG_PITCH_SLIDE = 1 << 5
};
typedef struct unk80004384 {
/* 0x00 */ struct ALSoundState *next;
/* 0x04 */ struct ALSoundState *prev;
/* 0x08 */ struct ALSoundState *unk8;
/* 0x0C */ ALVoice voice;
/* 0x28 */ f32 unk28;
/* 0x2C */ f32 unk2C;
/* 0x30 */ s32 unk30;
/* 0x34 */ s16 unk34;
/* 0x36 */ u8 unk36;
/* 0x38 */ s32 unk38;
/* 0x3C */ u8 unk3C;
/* 0x3C */ u8 unk3D;
/* 0x3C */ u8 unk3E;
/* 0x3F */ u8 unk3F;
} unk80004384; // ALSoundState based?
enum SoundStates {
SOUND_STATE_NONE,
SOUND_STATE_PLAYING,
SOUND_STATE_STOPPING,
SOUND_STATE_PREEMPT,
SOUND_STATE_WAIT_VOICE,
SOUND_STATE_INIT
};
typedef struct unk800DC6BC_40 {
ALLink node;
u8 pad0C[0x38];
} unk800DC6BC_40; //ALSoundState
typedef struct ALSoundState {
/* 0x00 */ struct ALSoundState *next;
/* 0x04 */ struct ALSoundState *prev;
/* 0x08 */ ALSound *sound;
/* 0x0C */ ALVoice voice;
/* 0x28 */ f32 slideMult;
/* 0x2C */ f32 pitch;
/* 0x30 */ struct ALSoundState **userHandle;
/* 0x34 */ s16 volume;
/* 0x36 */ u8 priority;
/* 0x38 */ s32 retries;
/* 0x3C */ ALPan pan;
/* 0x3D */ u8 fxmix;
/* 0x3E */ u8 flags;
/* 0x3F */ u8 state;
} ALSoundState;
typedef struct ALLink_unk8000418C {
u8 pad0[5];
s8 unk5;
} ALLink_unk8000418C;
typedef struct ALEvent_unk8000418C {
s16 type;
ALVoiceState *unk4;
s32 unk8;
u8 pad[4]; // Not sure how big this is supposed to be.
} ALEvent_unk8000418C;
typedef struct ALSoundStateLists {
/* 0x00 */ ALSoundState *allocHead;
/* 0x04 */ ALSoundState *allocTail;
/* 0x08 */ ALSoundState *freeHead;
} ALSoundStateLists;
/* Unknown Size */
typedef struct unk800DC6BC {
typedef struct SoundPlayer {
ALPlayer node;
ALEventQueue evtq;
ALEvent nextEvent;
ALSynth *drvr;
u32 unk3C;
unk800DC6BC_40 *unk40;
s32 soundChannelsMax;
s32 soundChannels;
u32 lastSoundState;
ALSoundState *soundStatesArray;
s32 maxSystemSoundChannels;
s32 maxActiveSounds;
s32 frameTime;
ALMicroTime nextDelta;
ALMicroTime curTime;
} unk800DC6BC; //ALSndPlayer
typedef union {
ALEvent msg;
struct{
s16 type;
SoundMask *state;
u32 param;
}snd_event;
} ALEvent2;
} SoundPlayer;
typedef union {
ALEvent msg;
struct {
s16 type;
u16 type;
ALSoundState *state;
s32 param;
} common;
struct {
s16 type;
ALSoundState *state;
s16 vol;
} vol;
struct {
s16 type;
ALSoundState *state;
f32 pitch;
} pitch;
struct {
s16 type;
ALSoundState *state;
ALPan pan;
} pan;
struct {
s16 type;
ALSoundState *state;
u8 mix;
} fx;
s32 soundIndex;
ALBank *bank;
} retrigger;
} ALSndpEvent;
typedef struct audioMgrConfig_s{
u32 unk00;
u32 unk04;
u32 maxChannels;
ALHeap *hp;
u16 unk10; // Heap Size?
/* 0x00 */ s32 maxSounds; // Number of ALSoundState structures
/* 0x04 */ s32 maxEvents; // Maximum number of events that can be held in the queue
/* 0x08 */ s32 maxChannels;
/* 0x0C */ ALHeap *heap;
/* 0x10 */ u16 numGroups;
} audioMgrConfig;
typedef struct AudQueueCustom {
ALEventQueue alQ;
struct TempAud *next;
u8 unk0[0x26];
u8 unk3E;
} AudQueueCustom;
extern void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size);
extern void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount);
extern ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt);
extern void alSynAddPlayer(ALSynth *drvr, ALPlayer *client);
extern void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta);
extern void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); //lib/src/al
extern void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount); //lib/src/unknown_0C9C90.c
extern ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); //lib/src/unknown_0C9C90.c
extern void alSynAddPlayer(ALSynth *drvr, ALPlayer *client); //lib/src/unknown_0C9C90.c
extern void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta); //lib/src/unknown_0C9C90.c Non Matching
void set_sfx_volume_slider(u32 volume);
s32 get_sfx_volume_slider(void);
void set_sound_channel_count(s32 numChannels);
void alSndPNew(audioMgrConfig *c);
ALMicroTime _sndpVoiceHandler(void *node);
void func_8000410C(ALSoundState *state);
u16 func_800042CC(u16 *lastAllocListIndex, u16 *lastFreeListIndex);
void func_80004604(ALSoundState *sndp, u8 priority);
s32 func_80004638(ALBank *bnk, s16 sndIndx, SoundMask *soundMask);
void sound_stop_all(void);
void sound_event_update(s32 soundMask, s16 type, u32 volume);
u16 get_sound_channel_volume(u8 channel);
void set_sound_channel_volume(u8 channel, u16 volume);
void func_8000418C(ALVoiceState *voiceState);
void func_800048D8(u8 event);
INCONSISTENT void sound_stop();
ALSound *func_80004384(UNUSED ALBank *arg0, ALSound *arg1);
// Non Matching
void func_80004520(ALSoundState *);
s32 func_80004668(ALBank *bnk, s16 sndIndx, u8, SoundMask *soundMask);
void _handleEvent(unk800DC6BC *sndp, ALSndpEvent *event);
void sndp_set_global_volume(u32 volume);
s32 sndp_get_global_volume(void);
void sndp_set_active_sound_limit(s32 numChannels);
void sndp_init_player(audioMgrConfig *c);
ALMicroTime sndp_voice_handler(void *node);
void sndp_end(ALSoundState *state);
u16 sndp_get_state_counts(u16 *numFree, u16 *numAllocated);
void sndp_set_priority(ALSoundState *sndp, u8 priority);
ALSoundState *sndp_play(ALBank *bnk, s16 sndIndx, SoundHandle *soundMask);
void sndp_stop_all_looped(void);
void sndp_set_param(SoundHandle soundMask, s16 type, u32 volume);
u16 sndp_get_group_volume(u8 channel);
void sndp_set_group_volume(u8 channel, u16 volume);
void sndp_apply_pitch_slide(ALSoundState *voiceState);
void sndp_stop_with_flags(u8 event);
void sndp_stop(SoundHandle soundMask);
ALSoundState *sndp_allocate(UNUSED ALBank *arg0, ALSound *arg1);
void sndp_deallocate(ALSoundState *);
ALSoundState *sndp_play_with_priority(ALBank *bnk, s16 sndIndx, u8 priority, SoundHandle *soundMask);
void sndp_handle_event(SoundPlayer *sndp, ALSndpEvent *event);
#endif
+4 -4
View File
@@ -385,11 +385,11 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl
}
if (numberOfPlayers == ONE_PLAYER) {
set_sound_channel_count(8);
sndp_set_active_sound_limit(8);
} else if (numberOfPlayers == TWO_PLAYERS) {
set_sound_channel_count(12);
sndp_set_active_sound_limit(12);
} else {
set_sound_channel_count(16);
sndp_set_active_sound_limit(16);
}
settings = get_settings();
gTempAssetTable = (s32 *) load_asset_section_from_rom(ASSET_LEVEL_HEADERS_TABLE);
@@ -698,7 +698,7 @@ void clear_audio_and_track(void) {
free_ai_behaviour_table();
bgdraw_primcolour(0, 0, 0);
mempool_free(gCurrentLevelHeader);
sound_stop_all();
sndp_stop_all_looped();
music_stop();
music_jingle_stop();
music_channel_reset_all();
+14 -14
View File
@@ -224,9 +224,9 @@ u8 gHudSlide;
u8 gHideRaceTimer;
u8 gNumActivePlayers;
u8 gWrongWayNagPrefix;
SoundMask *gRaceStartSoundMask;
s32 gHUDVoiceSoundMask;
SoundMask *gHudBalloonSoundMask;
SoundHandle gRaceStartSoundMask;
SoundHandle gHUDVoiceSoundMask;
SoundHandle gHudBalloonSoundMask;
u16 D_80126D48;
s32 D_80126D4C;
s32 D_80126D50;
@@ -321,14 +321,14 @@ void hud_init(UNUSED s32 viewportCount) {
gMinimapXlu = 0;
D_80127194 = (LevelHeader_70 *) get_misc_asset(ASSET_MISC_58);
func_8007F1E8(D_80127194);
set_sound_channel_volume(0, 32767);
set_sound_channel_volume(2, 32767);
sndp_set_group_volume(0, 32767);
sndp_set_group_volume(2, 32767);
for (i = 0; i < 2; i++) {
gHudAudioData[i].volume = 0;
gHudAudioData[i].volumeRamp = 0;
gHudAudioData[i].playerIndex = PLAYER_COMPUTER;
if (gHudAudioData[i].soundMask) {
sound_stop(gHudAudioData[i].soundMask);
sndp_stop(gHudAudioData[i].soundMask);
}
}
}
@@ -694,7 +694,7 @@ void hud_render_player(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *
music_stop();
music_channel_reset_all();
music_play(SEQUENCE_RACE_START_FANFARE);
set_sound_channel_count(12);
sndp_set_active_sound_limit(12);
} else {
start_level_music(1.0f);
}
@@ -816,7 +816,7 @@ void hud_audio_init(void) {
s32 i;
for (i = 0; i < 2; i++) {
if (gHudAudioData[i].soundMask) {
sound_stop(gHudAudioData[i].soundMask);
sndp_stop(gHudAudioData[i].soundMask);
gHudAudioData[i].soundMask = NULL;
gHudAudioData[i].volume = 0;
}
@@ -844,7 +844,7 @@ void hud_audio_update(s32 updateRate) {
for (i = 0; i < 2; i++) {
if (gHudAudioData[i].volume) {
if (gHudAudioData[i].soundMask == NULL) {
sound_play(gHudAudioData[i].soundID, (s32 *) &gHudAudioData[i].soundMask);
sound_play(gHudAudioData[i].soundID, &gHudAudioData[i].soundMask);
}
sound_volume_set_relative(gHudAudioData[i].soundID, gHudAudioData[i].soundMask, gHudAudioData[i].volume);
if (gHudAudioData[i].volumeRamp > 0) {
@@ -866,7 +866,7 @@ void hud_audio_update(s32 updateRate) {
}
} else {
if (gHudAudioData[i].soundMask) {
sound_stop(gHudAudioData[i].soundMask);
sndp_stop(gHudAudioData[i].soundMask);
gHudAudioData[i].soundMask = 0;
}
}
@@ -874,11 +874,11 @@ void hud_audio_update(s32 updateRate) {
if (gHudAudioReset && gHudAudioData[0].volume == 0) {
gHudAudioReset = FALSE;
if (gNumActivePlayers == 1) {
set_sound_channel_count(8);
sndp_set_active_sound_limit(8);
} else if (gNumActivePlayers == 2) {
set_sound_channel_count(12);
sndp_set_active_sound_limit(12);
} else {
set_sound_channel_count(16);
sndp_set_active_sound_limit(16);
}
}
}
@@ -2895,7 +2895,7 @@ void hud_balloons(UNUSED Object_Racer *racer) {
balloonCount = *settings->balloonsPtr;
if (cutscene_id() == 10) {
if (get_balloon_cutscene_timer() < balloonTickTimer + 8 && gHudBalloonSoundMask == NULL) {
sound_play(SOUND_HUD_LAP_TICK, (s32 *) &gHudBalloonSoundMask);
sound_play(SOUND_HUD_LAP_TICK, &gHudBalloonSoundMask);
}
}
}
+1 -1
View File
@@ -370,7 +370,7 @@ typedef struct HudAudio {
u16 soundID;
u8 volume;
s8 volumeRamp;
SoundMask *soundMask;
SoundHandle soundMask;
s32 unk8;
s8 playerIndex;
s8 unkD;
+27 -27
View File
@@ -372,7 +372,7 @@ s32 gMenuButtons[5]; // Buttons pressed per player plus an an extra containing e
s8 *gCinematicParams;
s32 buttonsPressed[5];
s8 *gCinematicPortraits;
SoundMask *gMenuSoundMasks[MAXCONTROLLERS]; // Soundmask values
SoundHandle gMenuSoundMasks[MAXCONTROLLERS]; // Soundmask values
s16 gMenuStickX[5];
s32 gCinematicEnd;
UNUSED s8 sUnused_80126828; // Set to 0 in menu_init, and never used again.
@@ -380,9 +380,9 @@ UNUSED s32 D_8012682C;
s16 gMenuStickY[5];
s16 D_8012683A;
s32 gCinematicSkipA;
SoundMask *gTrackTTSoundMask;
SoundHandle gTrackTTSoundMask;
s32 gCinematicSkipB;
SoundMask *D_80126848;
SoundHandle D_80126848;
s32 gCinematicMusicChangeOff;
s32 *D_80126850; // Never set, but it's read? Is it part of a larger struct being set?
s32 gMenuElementScaleTimer;
@@ -423,7 +423,7 @@ f32 gTrackSelectTargetY;
char *gTrackMenuHubName;
s32 gSelectedTrackX;
s32 gSelectedTrackY;
SoundMask *gSoundOptionMask;
SoundHandle gSoundOptionMask;
s32 gSaveMenuOptionCountLower;
SaveFileData *gSaveMenuFilesDest;
s32 gSaveMenuOptionCountUpper;
@@ -3472,22 +3472,22 @@ s32 menu_title_screen_loop(s32 updateRate) {
if (gTitleRevealTimer) {
if (gTitleRevealTimer < 32) {
if (gTitleRevealTimer == 1) {
sound_play(SOUND_WHOOSH1, 0);
sound_play(SOUND_WHOOSH1, NULL);
}
gTitleRevealTimer += updateRate;
if (gTitleRevealTimer >= 32) {
gTitleRevealTimer = 32;
sp18->object.distanceToCamera = 8.0f;
sound_play(SOUND_EXPLOSION, 0);
sound_play(SOUND_EXPLOSION, NULL);
}
} else {
if (gTitleAudioCounter < 6.0f) {
gTitleAudioCounter += updateRateF;
if (gTitleAudioCounter > 0.67f && gMenuStage == TITLESCREEN_START) {
sound_play(SOUND_VOICE_TT_DIDDY_KONG_RACING, 0);
sound_play(SOUND_VOICE_TT_DIDDY_KONG_RACING, NULL);
gMenuStage = TITLESCREEN_NAME;
} else if (gTitleAudioCounter > 2.83f && gMenuStage == TITLESCREEN_NAME) {
sound_play(SOUND_VOICE_TT_PRESS_START, 0);
sound_play(SOUND_VOICE_TT_PRESS_START, NULL);
gMenuStage = TITLESCREEN_PRESS_START;
}
}
@@ -3527,7 +3527,7 @@ s32 menu_title_screen_loop(s32 updateRate) {
gMenuDelay = 1;
transition_begin(&sMenuTransitionFadeIn);
enable_new_screen_transitions();
sound_play(SOUND_SELECT2, 0);
sound_play(SOUND_SELECT2, NULL);
}
}
if (gMenuDelay > 30) {
@@ -3803,7 +3803,7 @@ void menu_audio_options_init(void) {
transition_begin(&sMenuTransitionFadeOut);
func_8007FFEC(2);
gMusicVolumeSliderValue = music_volume_config();
gSfxVolumeSliderValue = get_sfx_volume_slider();
gSfxVolumeSliderValue = sndp_get_global_volume();
if (gActiveMagicCodes & CHEAT_MUSIC_MENU) { // Check if "JUKEBOX" cheat is active
gAudioMenuStrings[6].text = gMusicTestString;
gAudioMenuStrings[3].y = 212;
@@ -3986,7 +3986,7 @@ s32 menu_audio_options_loop(s32 updateRate) {
} else if (gSfxVolumeSliderValue > 256) {
gSfxVolumeSliderValue = 256;
}
set_sfx_volume_slider(gSfxVolumeSliderValue);
sndp_set_global_volume(gSfxVolumeSliderValue);
} else if (gOptionsMenuItemIndex == 2) {
gMusicVolumeSliderValue += contXAxis;
if (gMusicVolumeSliderValue < 0) {
@@ -4026,10 +4026,10 @@ s32 menu_audio_options_loop(s32 updateRate) {
}
if (gOptionsMenuItemIndex == 1) {
if (gSoundOptionMask == NULL) {
sound_play(SOUND_VOICE_DIDDY_POSITIVE5, (s32 *) &gSoundOptionMask);
sound_play(SOUND_VOICE_DIDDY_POSITIVE5, &gSoundOptionMask);
}
} else if (gSoundOptionMask != NULL) {
sound_stop(gSoundOptionMask);
sndp_stop(gSoundOptionMask);
}
if (playSound == 3) {
sound_play(SOUND_MENU_BACK3, NULL);
@@ -4054,7 +4054,7 @@ s32 menu_audio_options_loop(s32 updateRate) {
*/
void soundoptions_free(void) {
if (gSoundOptionMask != NULL) {
sound_stop(gSoundOptionMask);
sndp_stop(gSoundOptionMask);
}
if (gOpacityDecayTimer >= 0) {
music_voicelimit_set(24);
@@ -6900,11 +6900,11 @@ void charselect_pick(void) {
}
}
if (gMenuSoundMasks[characterSelected] != 0) {
sound_stop(gMenuSoundMasks[characterSelected]);
sndp_stop(gMenuSoundMasks[characterSelected]);
}
sound_play((*gCurrCharacterSelectData)[gPlayersCharacterArray[characterSelected]].voiceID +
SOUND_VOICE_CHARACTER_SELECTED,
(s32 *) &gMenuSoundMasks[characterSelected]);
&gMenuSoundMasks[characterSelected]);
if (gNumberOfActivePlayers > 2 ||
(gNumberOfActivePlayers > 1 && !(gActiveMagicCodes & CHEAT_TWO_PLAYER_ADVENTURE)) ||
gEnteredCharSelectFrom == 1) {
@@ -6918,11 +6918,11 @@ void charselect_pick(void) {
gCharselectStatus[i] = 0;
gNumberOfReadyPlayers--;
if (gMenuSoundMasks[i] != 0) {
sound_stop(gMenuSoundMasks[i]);
sndp_stop(gMenuSoundMasks[i]);
}
sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID +
SOUND_VOICE_CHARACTER_DESELECTED),
(s32 *) &gMenuSoundMasks[i]);
&gMenuSoundMasks[i]);
}
}
}
@@ -6947,11 +6947,11 @@ void charselect_input(s8 *activePlayers) {
gCharselectStatus[i] = 0;
gNumberOfReadyPlayers -= 1;
if (gMenuSoundMasks[i] != 0) {
sound_stop(gMenuSoundMasks[i]);
sndp_stop(gMenuSoundMasks[i]);
}
sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID +
SOUND_VOICE_CHARACTER_DESELECTED),
(s32 *) &gMenuSoundMasks[i]);
&gMenuSoundMasks[i]);
}
} else {
if (gMenuButtons[i] & B_BUTTON) {
@@ -6982,11 +6982,11 @@ void charselect_input(s8 *activePlayers) {
gCharselectStatus[i] = 1;
gNumberOfReadyPlayers++;
if (gMenuSoundMasks[i] != 0) {
sound_stop(gMenuSoundMasks[i]);
sndp_stop(gMenuSoundMasks[i]);
}
sound_play(
((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + SOUND_VOICE_CHARACTER_SELECT),
(s32 *) &gMenuSoundMasks[i]);
&gMenuSoundMasks[i]);
} else {
charSelectData = (*gCurrCharacterSelectData) + gPlayersCharacterArray[i];
if (gMenuStickY[i] > 0) {
@@ -9068,7 +9068,7 @@ void trackmenu_input(s32 updateRate) {
*/
void trackmenu_timetrial_sound(UNUSED s32 updateRate) {
if (gMenuStage == TRACKMENU_CHOOSE && gTracksMenuTimeTrialHighlightIndex == 0 && gTrackTTSoundMask == NULL) {
sound_play(SOUND_VOICE_TT_SNORE, (s32 *) &gTrackTTSoundMask);
sound_play(SOUND_VOICE_TT_SNORE, &gTrackTTSoundMask);
}
}
@@ -9603,7 +9603,7 @@ void func_80092188(s32 updateRate) {
}
if (gMenuStickY[0] > 0 && gTracksMenuTimeTrialHighlightIndex > 0) {
if (D_80126848 != NULL) {
sound_stop((u8 *) D_80126848);
sndp_stop(D_80126848);
}
gTracksMenuTimeTrialHighlightIndex--;
menuChanged = TRUE;
@@ -9612,12 +9612,12 @@ void func_80092188(s32 updateRate) {
if (gTracksMenuTimeTrialHighlightIndex <= 0) {
menuChanged = TRUE;
if (gTrackTTSoundMask != NULL) {
sound_stop((u8 *) gTrackTTSoundMask);
sndp_stop(gTrackTTSoundMask);
}
if (get_random_number_from_range(0, 255) >= 128) {
sound_play(SOUND_VOICE_TT_INTRO, (s32 *) &D_80126848);
sound_play(SOUND_VOICE_TT_INTRO, &D_80126848);
} else {
sound_play(SOUND_VOICE_TT_GO_FOR_IT, (s32 *) &D_80126848);
sound_play(SOUND_VOICE_TT_GO_FOR_IT, &D_80126848);
}
gTracksMenuTimeTrialHighlightIndex++;
}

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