Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
ambience.c File Reference

Go to the source code of this file.

Data Structures

struct  AmbientSoundSettings
 

Enumerations

enum  AmbientSoundState { AMBIENT_SOUND_IDLE = 0 , AMBIENT_SOUND_FADE_OUT = 1 , AMBIENT_SOUND_FADE_IN = 2 }
 

Functions

void reset_ambient_sounds (void)
 
void update_ambient_sounds (void)
 
s32 play_ambient_sounds (s32 soundID, s32 fadeTime)
 

Variables

AmbientSoundSettings DefaultAmbientSoundData
 
AmbientSoundSettings AmbientSoundData
 

Data Structure Documentation

◆ AmbientSoundSettings

struct AmbientSoundSettings
Data Fields
s16 flags
s16 fadeState
s32 fadeTime
s32 soundID
s32 unkC

Enumeration Type Documentation

◆ AmbientSoundState

Enumerator
AMBIENT_SOUND_IDLE 
AMBIENT_SOUND_FADE_OUT 
AMBIENT_SOUND_FADE_IN 

Definition at line 12 of file ambience.c.

12 {
14 AMBIENT_SOUND_FADE_OUT = 1, // fade out old sounds
15 AMBIENT_SOUND_FADE_IN = 2 // fade in new sounds
AmbientSoundState
Definition ambience.c:12
@ AMBIENT_SOUND_FADE_OUT
Definition ambience.c:14
@ AMBIENT_SOUND_IDLE
Definition ambience.c:13
@ AMBIENT_SOUND_FADE_IN
Definition ambience.c:15

Function Documentation

◆ reset_ambient_sounds()

void reset_ambient_sounds ( void )

Definition at line 28 of file ambience.c.

28 {
30}
AmbientSoundSettings AmbientSoundData
Definition ambience.c:26
AmbientSoundSettings DefaultAmbientSoundData
Definition ambience.c:18

Referenced by load_engine_data().

◆ update_ambient_sounds()

void update_ambient_sounds ( void )

Definition at line 32 of file ambience.c.

32 {
33 AmbientSoundSettings* ambientSoundState = &AmbientSoundData;
34 s32 error;
35
36 switch (ambientSoundState->fadeState) {
38 break;
40 if (ambientSoundState->flags & 1) {
41 if (ambientSoundState->fadeTime < 250) {
42 error = snd_ambient_stop_quick(0);
43 } else {
44 error = snd_ambient_stop_slow(0, ambientSoundState->fadeTime);
45 }
46
47 if (error != AU_RESULT_OK) {
48 return;
49 }
50 }
51 ambientSoundState->fadeState = AMBIENT_SOUND_FADE_IN;
52 break;
54 if (ambientSoundState->flags & 1) {
56 return;
57 }
58 ambientSoundState->flags &= ~1;
59 }
60 if (ambientSoundState->soundID < 0) {
61 ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
62 } else if (snd_load_ambient(ambientSoundState->soundID) == AU_RESULT_OK) {
63 if (snd_ambient_play(0, 0) == AU_RESULT_OK) {
64 ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
65 ambientSoundState->flags |= 1;
66 }
67 }
68 break;
69 }
70}
AuResult snd_load_ambient(s32 ambSoundID)
Definition 30450.c:272
AuResult snd_ambient_stop_slow(s32 index, s32 fadeOutTime)
Definition 30450.c:295
AuResult snd_ambient_stop_quick(s32 index)
Definition 30450.c:285
AuResult snd_ambient_play(s32 index, s32 fadeInTime)
Definition 30450.c:276
AuResult snd_ambient_is_stopped(s32 index)
Definition 30450.c:325
@ AU_RESULT_OK
Definition enums.h:1756

Referenced by step_game_loop().

◆ play_ambient_sounds()

s32 play_ambient_sounds ( s32 soundID,
s32 fadeTime )

Definition at line 72 of file ambience.c.

72 {
74
77 state->flags &= ~1;
78 return 1;
79 }
80
81 if (state->soundID == soundID) {
82 return 2;
83 }
84
85 state->soundID = soundID;
86 state->fadeTime = fadeTime;
88 return 1;
89}
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Variable Documentation

◆ DefaultAmbientSoundData

AmbientSoundSettings DefaultAmbientSoundData
Initial value:
= {
.flags = 0,
.fadeState = 0,
.fadeTime = 0,
.soundID = -1,
.unkC = -1
}

Definition at line 18 of file ambience.c.

18 {
19 .flags = 0,
20 .fadeState = 0,
21 .fadeTime = 0,
22 .soundID = -1,
23 .unkC = -1
24};

Referenced by reset_ambient_sounds().

◆ AmbientSoundData

AmbientSoundSettings AmbientSoundData

Definition at line 26 of file ambience.c.

Referenced by play_ambient_sounds(), reset_ambient_sounds(), and update_ambient_sounds().