Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
e0b30_len_b80.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3
4void bgm_update_volume(void);
5void bgm_set_target_volume(s16 volume);
6
11
13
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};
30
41
43
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}
62
64 s32 i;
65
66 for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++) {
68 }
69
74}
75
76void bgm_reset_volume(void) {
79}
80
81//TODO refactor out constants
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}
178
179s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
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}
221
222s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
223 gMusicSettings[playerIndex].flags &= ~MUSIC_SETTINGS_FLAG_8;
224
225 return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
226}
227
228s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 fadeStartVolume, s16 fadeEndVolume) {
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}
260
261s32 bgm_adjust_proximity(s32 playerIndex, s32 mix, s16 state) {
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}
285
286AuResult bgm_set_track_volumes(s32 playerIndex, s16 trackVolSet) {
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}
295
296AuResult bgm_clear_track_volumes(s32 playerIndex, s16 trackVolSet) {
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}
305
306AuResult bgm_set_variation(s32 playerIndex, s16 arg1) {
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}
315
317 bgm_set_song(0, -1, 0, 250, 8);
318 bgm_set_song(1, -1, 0, 250, 8);
319
320 return 1;
321}
322
324 MusicMaxVolume = 4;
325}
326
328 MusicMaxVolume = 8;
329}
330
331void bgm_set_target_volume(s16 volume) {
332 MusicTargetVolume = volume;
333}
334
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}
358
359s32 func_8014AD40(void) {
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}
374
375void bgm_pop_song(void) {
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}
383
384void bgm_push_song(s32 songID, s32 variation) {
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}
395
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}
409
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}
424
425void bgm_set_battle_song(s32 songID, s32 variation) {
426 MusicSettings* musicSetting = gMusicSettings;
427
428 musicSetting->battleSongID = songID;
429 musicSetting->battleVariation = variation;
430}
431
432void func_8014AFA0(void) {
433}
AuResult func_80055AF0(s32 songName)
Definition 30450.c:540
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:684
AuResult au_song_stop(s32 songName)
Definition 30450.c:483
void bgm_set_proximity_mix_full(s32 songName, s32 mix)
Definition 30450.c:797
AuResult func_80055B80(s32 songName)
Definition 30450.c:568
AuResult snd_ambient_resume(s32 index, s32 fadeInTime)
Definition 30450.c:315
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:704
AuResult au_song_load(s32 songID, s32 playerIndex)
Definition 30450.c:436
AuResult snd_ambient_pause(s32 index, s32 fadeOutTime)
Definition 30450.c:305
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
void func_800561A4(s32 arg0)
Definition 30450.c:849
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
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
AuResult snd_set_song_variation(s32 songName, s32 variation)
Definition 30450.c:628
s8 flags
Definition demo_api.c:15
MusicSettings gMusicSettings[2]
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)
void bgm_pop_song(void)
void bgm_quiet_max_volume(void)
void func_8014AFA0(void)
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
s32 func_8014AD40(void)
s32 SongsUsingVariationFlag[]
Lists the songs that are forced to use the variation determined by map.songVariation & 1.
void bgm_reset_max_volume(void)
s16 NextVolumeUpdateTimer
void bgm_update_volume(void)
BSS s16 MusicMaxVolume
void bgm_reset_volume(void)
void bgm_pop_battle_song(void)
s32 bgm_init_music_players(void)
void bgm_set_target_volume(s16 volume)
BSS s16 MusicCurrentVolume
void bgm_update_music_settings(void)
AuResult bgm_set_variation(s32 playerIndex, s16 arg1)
AuResult bgm_clear_track_volumes(s32 playerIndex, s16 trackVolSet)
s32 bgm_adjust_proximity(s32 playerIndex, s32 mix, s16 state)
MusicSettings BlankMusicSettings
void bgm_set_battle_song(s32 songID, s32 variation)
AuResult bgm_set_track_volumes(s32 playerIndex, s16 trackVolSet)
void bgm_reset_sequence_players(void)
BSS s16 MusicDefaultVolume
void bgm_push_song(s32 songID, s32 variation)
void bgm_push_battle_song(void)
BSS s16 MusicTargetVolume
s32 bgm_get_map_default_variation(s32 songID)
If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation &...
@ 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_ENABLE_PROXIMITY_MIX
Definition enums.h:4661
@ MUSIC_SETTINGS_FLAG_4
Definition enums.h:4662
@ 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
AuResult
Definition enums.h:1755
@ AU_RESULT_OK
Definition enums.h:1756
@ DEMO_STATE_NONE
Definition enums.h:3535
@ GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE
Definition enums.h:4336
@ MUSIC_PROXIMITY_NEAR
Definition enums.h:1784
@ MUSIC_PROXIMITY_FULL
Definition enums.h:1785
@ MUSIC_PROXIMITY_FAR
Definition enums.h:1783
#define BSS
Definition macros.h:7
#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
s32 gOverrideFlags
Definition main_loop.c:11
GameStatus * gGameStatusPtr
Definition main_loop.c:32