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

Go to the source code of this file.

Functions

void bgm_update_volume (void)
 
void bgm_set_target_volume (s16 volume)
 
s32 bgm_get_map_default_variation (s32 songID)
 If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation & 1 value.
 
void bgm_reset_sequence_players (void)
 
void bgm_reset_volume (void)
 
void bgm_update_music_settings (void)
 
s32 _bgm_set_song (s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
 
s32 bgm_set_song (s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
 
s32 func_8014A964 (s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 fadeStartVolume, s16 fadeEndVolume)
 
s32 bgm_adjust_proximity (s32 playerIndex, s32 mix, s16 state)
 
AuResult bgm_set_track_volumes (s32 playerIndex, s16 trackVolSet)
 
AuResult bgm_clear_track_volumes (s32 playerIndex, s16 trackVolSet)
 
AuResult bgm_set_variation (s32 playerIndex, s16 arg1)
 
s32 bgm_init_music_players (void)
 
void bgm_quiet_max_volume (void)
 
void bgm_reset_max_volume (void)
 
s32 func_8014AD40 (void)
 
void bgm_pop_song (void)
 
void bgm_push_song (s32 songID, s32 variation)
 
void bgm_pop_battle_song (void)
 
void bgm_push_battle_song (void)
 
void bgm_set_battle_song (s32 songID, s32 variation)
 
void func_8014AFA0 (void)
 

Variables

BSS s16 MusicDefaultVolume
 
BSS s16 MusicTargetVolume
 
BSS s16 MusicMaxVolume
 
BSS s16 MusicCurrentVolume
 
MusicSettings gMusicSettings [2]
 
MusicSettings BlankMusicSettings
 
s32 SongsUsingVariationFlag []
 Lists the songs that are forced to use the variation determined by map.songVariation & 1.
 
s16 NextVolumeUpdateTimer = 0
 

Function Documentation

◆ bgm_update_volume()

void bgm_update_volume ( void )

Definition at line 335 of file e0b30_len_b80.c.

335 {
336 s16 toVolume;
337
338 if (NextVolumeUpdateTimer != 0) {
340 return;
341 }
342
343 toVolume = MusicTargetVolume;
344 if (toVolume > MusicMaxVolume) {
345 toVolume = MusicMaxVolume;
346 }
347
348 if (MusicCurrentVolume != toVolume) {
349 if (MusicCurrentVolume >= toVolume) {
351 } else {
353 }
356 }
357}
void func_800561A4(s32 arg0)
Definition 30450.c:849
s16 NextVolumeUpdateTimer
BSS s16 MusicMaxVolume
BSS s16 MusicCurrentVolume
BSS s16 MusicTargetVolume

Referenced by bgm_update_music_settings().

◆ bgm_set_target_volume()

void bgm_set_target_volume ( s16 volume)

Definition at line 331 of file e0b30_len_b80.c.

331 {
332 MusicTargetVolume = volume;
333}

Referenced by _bgm_set_song(), and bgm_update_music_settings().

◆ bgm_get_map_default_variation()

s32 bgm_get_map_default_variation ( s32 songID)

If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation & 1 value.

Otherwise, returns -1.

See also
SongsUsingVariationFlag
Returns
-1: no override; 0: override to variation 0; 1 override to variation 1

Definition at line 49 of file e0b30_len_b80.c.

49 {
50 u32 i;
51
52 for (i = 0; i < ARRAY_COUNT(SongsUsingVariationFlag); i++) {
53 if (SongsUsingVariationFlag[i] == songID) {
55
56 return map->songVariation & 1;
57 }
58 }
59
60 return -1;
61}
s32 SongsUsingVariationFlag[]
Lists the songs that are forced to use the variation determined by map.songVariation & 1.
#define ARRAY_COUNT(arr)
Definition macros.h:40
s8 songVariation
0 or 1.
Definition map.h:58
AreaConfig gAreas[29]
Zero-terminated.
Definition world.c:868
MapConfig * maps
Definition map.h:64
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Referenced by _bgm_set_song(), and func_8014A964().

◆ bgm_reset_sequence_players()

void bgm_reset_sequence_players ( void )

Definition at line 63 of file e0b30_len_b80.c.

63 {
64 s32 i;
65
66 for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++) {
68 }
69
74}
MusicSettings gMusicSettings[2]
MusicSettings BlankMusicSettings

Referenced by load_engine_data().

◆ bgm_reset_volume()

void bgm_reset_volume ( void )

Definition at line 76 of file e0b30_len_b80.c.

76 {
79}

Referenced by state_step_startup().

◆ bgm_update_music_settings()

void bgm_update_music_settings ( void )

Definition at line 82 of file e0b30_len_b80.c.

82 {
84 s32 i = 0;
85 s16 state2 = 2;
86 s16 flag4 = MUSIC_SETTINGS_FLAG_4;
87 s32 flags;
88
89 for (i; i < ARRAY_COUNT(gMusicSettings); i++, music++) {
90 switch (music->state) {
91 case 0:
92 break;
93 case 1:
94 if (music->flags & MUSIC_SETTINGS_FLAG_1) {
95 if (music->fadeOutTime < 250) {
96 if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
97 if (au_song_stop(music->songName) == AU_RESULT_OK) {
98 music->state = state2;
99 }
100 } else {
101 if (func_80055AF0(music->songName) == AU_RESULT_OK) {
102 music->state = state2;
103 }
104 }
105 } else if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
106 if (snd_set_song_variation_fade_time(music->songName, music->fadeOutTime, 0) == 0) {
107 music->state = state2;
108 }
109 } else {
110 if (func_80055BB8(music->songName, 250) == AU_RESULT_OK) {
111 music->state = state2;
112 }
113 }
114 } else {
115 if (music->flags & MUSIC_SETTINGS_FLAG_4) {
117 }
118 music->flags &= ~flag4;
119 music->state = 5;
120 }
121 break;
122 case 2:
123 flags = music->flags;
124 music->flags &= ~flag4;
127 music->flags &= ~MUSIC_SETTINGS_FLAG_1;
128 music->state = 3;
129 }
130 } else {
131 music->state = 5;
132 }
133 break;
134 case 3:
135 music->state = 4;
136 break;
137 case 4:
138 music->state = 5;
139 break;
140 case 5:
141 if (!(music->flags & MUSIC_SETTINGS_FLAG_8)) {
142 if (music->songID < 0) {
143 music->state = 0;
144 } else {
145 music->songName = au_song_load(music->songID, i);
146 if (music->songName > 0xFFFFU) {
147 if ((music->flags & MUSIC_SETTINGS_FLAG_20)) {
149 music->fadeInTime, music->fadeStartVolume, music->fadeEndVolume);
150 music->flags &= ~MUSIC_SETTINGS_FLAG_20;
151 } else {
153 }
154 if (au_song_start_variation(music->songName, music->variation) == 0) {
156 music->state = 0;
157 }
158 }
159 }
160 } else {
161 if (music->flags & MUSIC_SETTINGS_FLAG_10) {
162 music->state = 0;
164 } else if (func_80055B28(music->savedSongName) == 0) {
165 music->songID = music->savedSongID;
166 music->variation = music->savedVariation;
167 music->songName = music->savedSongName;
168 music->state = 0;
170 music->flags &= ~MUSIC_SETTINGS_FLAG_8;
171 }
172 }
173 break;
174 }
175 }
177}
AuResult func_80055AF0(s32 songName)
Definition 30450.c:540
AuResult au_song_stop(s32 songName)
Definition 30450.c:483
AuResult au_song_load(s32 songID, s32 playerIndex)
Definition 30450.c:436
AuResult au_song_is_playing(s32 songName)
Definition 30450.c:491
AuResult func_80055BB8(s32 songName, s32 fadeTime)
Definition 30450.c:579
AuResult snd_set_song_variation_fade(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume)
Definition 30450.c:495
AuResult func_80055B28(s32 songName)
Definition 30450.c:551
AuResult snd_set_song_variation_fade_time(s32 songName, s32 fadeTime, s32 variation)
Definition 30450.c:529
AuResult au_song_start_variation(s32 songName, s32 variation)
Definition 30450.c:466
s8 flags
Definition demo_api.c:15
void bgm_update_volume(void)
void bgm_set_target_volume(s16 volume)
BSS s16 MusicDefaultVolume
@ MUSIC_SETTINGS_FLAG_20
Definition enums.h:4665
@ MUSIC_SETTINGS_FLAG_10
Definition enums.h:4664
@ MUSIC_SETTINGS_FLAG_1
Definition enums.h:4660
@ MUSIC_SETTINGS_FLAG_8
Definition enums.h:4663
@ MUSIC_SETTINGS_FLAG_4
Definition enums.h:4662
@ AU_RESULT_OK
Definition enums.h:1756

Referenced by step_game_loop().

◆ _bgm_set_song()

s32 _bgm_set_song ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeOutTime,
s16 volume )

Definition at line 179 of file e0b30_len_b80.c.

179 {
180 MusicSettings* musicSetting;
181 s32 mapSongVariation;
182
184 return 1;
185 }
186
187 musicSetting = &gMusicSettings[playerIndex];
188
190 au_song_stop(musicSetting->songName);
191 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_1;
192
193 return 1;
194 }
195
196 mapSongVariation = bgm_get_map_default_variation(songID);
197 if (mapSongVariation >= 0) {
198 variation = mapSongVariation;
199 }
200
201 if (musicSetting->songID == songID && musicSetting->variation == variation) {
202 bgm_set_target_volume(volume);
203
204 if (musicSetting->flags & MUSIC_SETTINGS_FLAG_4) {
205 func_80055B80(musicSetting->songName);
206 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_4;
207 }
208
209 return 2;
210 }
211
212 MusicDefaultVolume = volume;
213 musicSetting->songID = songID;
214 musicSetting->variation = variation;
215 musicSetting->fadeOutTime = fadeOutTime;
216 musicSetting->state = 1;
217 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX;
218
219 return 1;
220}
AuResult func_80055B80(s32 songName)
Definition 30450.c:568
s32 bgm_get_map_default_variation(s32 songID)
If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation &...
@ DEMO_STATE_NONE
Definition enums.h:3535

Referenced by bgm_pop_battle_song(), bgm_pop_song(), and bgm_set_song().

◆ bgm_set_song()

s32 bgm_set_song ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeOutTime,
s16 volume )

Definition at line 222 of file e0b30_len_b80.c.

222 {
223 gMusicSettings[playerIndex].flags &= ~MUSIC_SETTINGS_FLAG_8;
224
225 return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
226}
s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by bgm_init_music_players(), bgm_push_battle_song(), bgm_push_song(), btl_state_update_celebration(), btl_state_update_defeat(), btl_state_update_end_training_battle(), btl_state_update_run_away(), btl_state_update_victory(), state_init_exit_file_select(), state_init_title_screen(), and state_step_title_screen().

◆ func_8014A964()

s32 func_8014A964 ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeInTime,
s16 fadeStartVolume,
s16 fadeEndVolume )

Definition at line 228 of file e0b30_len_b80.c.

228 {
229 MusicSettings* musicSetting;
230 s32 mapSongVariation;
231
233 return 1;
234 }
235
236 musicSetting = &gMusicSettings[playerIndex];
237
239 au_song_stop(musicSetting->songName);
240 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_1;
241 return 1;
242 }
243
244 mapSongVariation = bgm_get_map_default_variation(songID);
245 if (mapSongVariation >= 0) {
246 variation = mapSongVariation;
247 }
248
249 musicSetting->fadeInTime = fadeInTime;
250 musicSetting->fadeStartVolume = fadeStartVolume;
251 musicSetting->fadeEndVolume = fadeEndVolume;
252 musicSetting->songID = songID;
253 musicSetting->variation = variation;
254 musicSetting->flags |= MUSIC_SETTINGS_FLAG_20;
255 musicSetting->state = 1;
256 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX;
257
258 return 1;
259}

◆ bgm_adjust_proximity()

s32 bgm_adjust_proximity ( s32 playerIndex,
s32 mix,
s16 state )

Definition at line 261 of file e0b30_len_b80.c.

261 {
262 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
263
264 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
265 return FALSE;
266 }
267
268 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX)) {
269 return FALSE;
270 }
271
272 switch (state) {
274 bgm_set_proximity_mix_far(musicSetting->songName, mix);
275 break;
277 bgm_set_proximity_mix_near(musicSetting->songName, mix);
278 break;
280 bgm_set_proximity_mix_full(musicSetting->songName, mix);
281 break;
282 }
283 return TRUE;
284}
void bgm_set_proximity_mix_full(s32 songName, s32 mix)
Definition 30450.c:797
void bgm_set_proximity_mix_near(s32 songName, s32 mix)
Definition 30450.c:793
void bgm_set_proximity_mix_far(s32 songName, s32 mix)
Definition 30450.c:789
@ MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX
Definition enums.h:4661
@ MUSIC_PROXIMITY_NEAR
Definition enums.h:1784
@ MUSIC_PROXIMITY_FULL
Definition enums.h:1785
@ MUSIC_PROXIMITY_FAR
Definition enums.h:1783

◆ bgm_set_track_volumes()

AuResult bgm_set_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 286 of file e0b30_len_b80.c.

286 {
287 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
288
289 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
290 return AU_RESULT_OK;
291 }
292
293 return snd_song_set_track_volumes(musicSetting->songName, trackVolSet);
294}
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:684

◆ bgm_clear_track_volumes()

AuResult bgm_clear_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 296 of file e0b30_len_b80.c.

296 {
297 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
298
299 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
300 return AU_RESULT_OK;
301 }
302
303 return snd_song_clear_track_volumes(musicSetting->songName, trackVolSet);
304}
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:704

◆ bgm_set_variation()

AuResult bgm_set_variation ( s32 playerIndex,
s16 arg1 )

Definition at line 306 of file e0b30_len_b80.c.

306 {
307 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
308
309 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
310 return AU_RESULT_OK;
311 }
312
313 return snd_set_song_variation(musicSetting->songName, arg1);
314}
AuResult snd_set_song_variation(s32 songName, s32 variation)
Definition 30450.c:628

◆ bgm_init_music_players()

s32 bgm_init_music_players ( void )

Definition at line 316 of file e0b30_len_b80.c.

316 {
317 bgm_set_song(0, -1, 0, 250, 8);
318 bgm_set_song(1, -1, 0, 250, 8);
319
320 return 1;
321}
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by state_step_startup().

◆ bgm_quiet_max_volume()

void bgm_quiet_max_volume ( void )

Definition at line 323 of file e0b30_len_b80.c.

323 {
324 MusicMaxVolume = 4;
325}

Referenced by state_step_pause().

◆ bgm_reset_max_volume()

void bgm_reset_max_volume ( void )

Definition at line 327 of file e0b30_len_b80.c.

327 {
328 MusicMaxVolume = 8;
329}

Referenced by state_step_unpause().

◆ func_8014AD40()

s32 func_8014AD40 ( void )

Definition at line 359 of file e0b30_len_b80.c.

359 {
360 MusicSettings* settings = gMusicSettings;
361 s32 i;
362
363 for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++, settings++) {
364 if (!(settings->flags & MUSIC_SETTINGS_FLAG_1)) {
365 continue;
366 }
367
368 if (au_song_is_playing(settings->songName)) {
369 return TRUE;
370 }
371 }
372 return FALSE;
373}

◆ bgm_pop_song()

void bgm_pop_song ( void )

Definition at line 375 of file e0b30_len_b80.c.

375 {
376 MusicSettings* musicSetting = gMusicSettings;
377
379 musicSetting->flags |= MUSIC_SETTINGS_FLAG_8;
380 _bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
381 }
382}

◆ bgm_push_song()

void bgm_push_song ( s32 songID,
s32 variation )

Definition at line 384 of file e0b30_len_b80.c.

384 {
385 MusicSettings* musicSetting = gMusicSettings;
386
388 musicSetting->savedSongID = musicSetting->songID;
389 musicSetting->savedVariation = musicSetting->variation;
390 musicSetting->savedSongName = musicSetting->songName;
391 musicSetting->flags |= MUSIC_SETTINGS_FLAG_4;
392 bgm_set_song(0, songID, variation, 500, 8);
393 }
394}

◆ bgm_pop_battle_song()

void bgm_pop_battle_song ( void )

Definition at line 396 of file e0b30_len_b80.c.

396 {
397 MusicSettings* musicSetting = gMusicSettings;
398
401 gOverrideFlags &= ~GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE;
402 } else {
403 musicSetting->flags |= MUSIC_SETTINGS_FLAG_8;
404 _bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
405 snd_ambient_resume(0, 250);
406 }
407 }
408}
AuResult snd_ambient_resume(s32 index, s32 fadeInTime)
Definition 30450.c:315
@ GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE
Definition enums.h:4336
s32 gOverrideFlags
Definition main_loop.c:11

Referenced by update_encounters_post_battle().

◆ bgm_push_battle_song()

void bgm_push_battle_song ( void )

Definition at line 410 of file e0b30_len_b80.c.

410 {
411 MusicSettings* musicSetting = gMusicSettings;
412
415 snd_ambient_pause(0, 250);
416 musicSetting->savedSongID = musicSetting->songID;
417 musicSetting->savedVariation = musicSetting->variation;
418 musicSetting->savedSongName = musicSetting->songName;
419 musicSetting->flags |= MUSIC_SETTINGS_FLAG_4;
420 bgm_set_song(0, musicSetting->battleSongID, musicSetting->battleVariation, 500, 8);
421 }
422 }
423}
AuResult snd_ambient_pause(s32 index, s32 fadeOutTime)
Definition 30450.c:305

Referenced by update_encounters_pre_battle().

◆ bgm_set_battle_song()

void bgm_set_battle_song ( s32 songID,
s32 variation )

Definition at line 425 of file e0b30_len_b80.c.

425 {
426 MusicSettings* musicSetting = gMusicSettings;
427
428 musicSetting->battleSongID = songID;
429 musicSetting->battleVariation = variation;
430}

Referenced by update_encounters_pre_battle().

◆ func_8014AFA0()

void func_8014AFA0 ( void )

Definition at line 432 of file e0b30_len_b80.c.

432 {
433}

Variable Documentation

◆ MusicDefaultVolume

BSS s16 MusicDefaultVolume

Definition at line 7 of file e0b30_len_b80.c.

Referenced by _bgm_set_song(), and bgm_update_music_settings().

◆ MusicTargetVolume

BSS s16 MusicTargetVolume

◆ MusicMaxVolume

◆ MusicCurrentVolume

BSS s16 MusicCurrentVolume

Definition at line 10 of file e0b30_len_b80.c.

Referenced by bgm_reset_sequence_players(), and bgm_update_volume().

◆ gMusicSettings

◆ BlankMusicSettings

MusicSettings BlankMusicSettings
Initial value:
= {
.flags = 0,
.state = 0,
.fadeOutTime = -1,
.fadeInTime = 0,
.fadeStartVolume = 0,
.fadeEndVolume = 0,
.songID = -1,
.variation = -1,
.songName = -1,
.battleSongID = 0,
.battleVariation = 0,
.savedSongID = 0,
.savedVariation = 0,
.savedSongName = 0
}

Definition at line 14 of file e0b30_len_b80.c.

14 {
15 .flags = 0,
16 .state = 0,
17 .fadeOutTime = -1,
18 .fadeInTime = 0,
19 .fadeStartVolume = 0,
20 .fadeEndVolume = 0,
21 .songID = -1,
22 .variation = -1,
23 .songName = -1,
24 .battleSongID = 0,
25 .battleVariation = 0,
26 .savedSongID = 0,
27 .savedVariation = 0,
28 .savedSongName = 0
29};

Referenced by bgm_reset_sequence_players().

◆ SongsUsingVariationFlag

s32 SongsUsingVariationFlag[]
Initial value:
= {
}
@ SONG_NEW_PARTNER
Definition enums.h:412
@ SONG_TUBBA_BLUBBA_BATTLE
Definition enums.h:293
@ SONG_YOSHI_KIDS_FOUND
Definition enums.h:360
@ SONG_SPECIAL_BATTLE
Definition enums.h:285
@ SONG_JR_TROOPA_BATTLE
Definition enums.h:286
@ SONG_ITEM_UPGRADE
Definition enums.h:348

Lists the songs that are forced to use the variation determined by map.songVariation & 1.

See also
bgm_get_map_default_variation

Definition at line 33 of file e0b30_len_b80.c.

Referenced by bgm_get_map_default_variation().

◆ NextVolumeUpdateTimer

s16 NextVolumeUpdateTimer = 0

Definition at line 42 of file e0b30_len_b80.c.

Referenced by bgm_update_volume().