2020-07-18 06:11:08 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
// TODO: most likely part of the MusicPlayer struct
|
2020-05-12 06:56:46 +02:00
|
|
|
typedef struct {
|
2020-08-22 09:43:30 +02:00
|
|
|
s16 flags;
|
|
|
|
s16 state;
|
|
|
|
s32 fadeOutTime;
|
|
|
|
s32 fadeInTime;
|
2020-08-12 04:08:48 +02:00
|
|
|
s32 unkC;
|
2020-05-12 05:00:21 +02:00
|
|
|
} struct_80147230;
|
|
|
|
|
2020-05-12 06:56:46 +02:00
|
|
|
extern struct_80147230 D_8014F140;
|
|
|
|
extern struct_80147230 D_8015C7C0;
|
2020-05-12 05:00:21 +02:00
|
|
|
|
2020-05-12 06:56:46 +02:00
|
|
|
void func_80147230(void) {
|
2020-08-12 04:08:48 +02:00
|
|
|
D_8015C7C0 = D_8014F140;
|
2020-05-12 05:00:21 +02:00
|
|
|
}
|
|
|
|
|
2020-08-13 07:03:47 +02:00
|
|
|
void update_music_players(void) {
|
2020-08-12 03:01:33 +02:00
|
|
|
struct_80147230* temp = &D_8015C7C0;
|
2020-05-12 05:00:21 +02:00
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
switch (temp->state) {
|
|
|
|
case 0: // idle
|
2020-08-12 03:01:33 +02:00
|
|
|
break;
|
2020-08-22 09:43:30 +02:00
|
|
|
case 1: // fading in
|
|
|
|
if (temp->flags & 1) {
|
2020-08-12 03:01:33 +02:00
|
|
|
s32 phi_v0;
|
2020-08-22 09:43:30 +02:00
|
|
|
if (temp->fadeOutTime < 0xFA) {
|
|
|
|
phi_v0 = func_800554A4(0, temp->fadeOutTime);
|
2020-08-12 03:01:33 +02:00
|
|
|
} else {
|
2020-08-22 09:43:30 +02:00
|
|
|
phi_v0 = func_800554E8(0, temp->fadeOutTime);
|
2020-08-12 03:01:33 +02:00
|
|
|
}
|
|
|
|
if (phi_v0 != 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-08-22 09:43:30 +02:00
|
|
|
temp->state = 2;
|
2020-08-12 03:01:33 +02:00
|
|
|
break;
|
2020-08-22 09:43:30 +02:00
|
|
|
case 2: // fading out
|
|
|
|
if (temp->flags & 1) {
|
2020-08-12 03:01:33 +02:00
|
|
|
if (func_800555E4(0) != 0) {
|
|
|
|
return;
|
|
|
|
}
|
2020-08-22 09:43:30 +02:00
|
|
|
temp->flags &= ~1;
|
2020-08-12 03:01:33 +02:00
|
|
|
}
|
2020-08-22 09:43:30 +02:00
|
|
|
if (temp->fadeInTime < 0) {
|
|
|
|
temp->state = 0;
|
|
|
|
} else if (func_80055448(temp->fadeInTime) == 0) {
|
2020-08-12 03:01:33 +02:00
|
|
|
if (func_80055464(0, 0) == 0) {
|
2020-08-22 09:43:30 +02:00
|
|
|
temp->state = 0;
|
|
|
|
temp->flags |= 1;
|
2020-08-12 03:01:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-07-21 10:42:21 +02:00
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) {
|
2020-08-12 03:01:33 +02:00
|
|
|
struct_80147230* temp1 = &D_8015C7C0;
|
|
|
|
struct_80147230* temp2 = &D_8015C7C0;
|
2020-07-21 10:42:21 +02:00
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
if (!(*gGameStatusPtr)->musicEnabled) {
|
|
|
|
func_800554A4(temp1->fadeInTime, fadeOutTime);
|
|
|
|
temp1->flags &= ~1;
|
2020-08-12 03:01:33 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2020-07-21 10:42:21 +02:00
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
if (temp1->fadeInTime == fadeInTime) {
|
2020-08-12 03:01:33 +02:00
|
|
|
return 2;
|
|
|
|
}
|
2020-07-21 10:42:21 +02:00
|
|
|
|
2020-08-22 09:43:30 +02:00
|
|
|
temp2->fadeInTime = fadeInTime;
|
|
|
|
temp2->fadeOutTime = fadeOutTime;
|
|
|
|
temp2->state = 1;
|
2020-08-12 03:01:33 +02:00
|
|
|
return 1;
|
2020-08-12 04:08:48 +02:00
|
|
|
}
|