papermario/src/code_dd930_len_1c0.c

77 lines
1.9 KiB
C
Raw Normal View History

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;
} struct_80147230;
2020-05-12 06:56:46 +02:00
extern struct_80147230 D_8014F140;
extern struct_80147230 D_8015C7C0;
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-08-13 07:03:47 +02:00
void update_music_players(void) {
struct_80147230* temp = &D_8015C7C0;
2020-08-22 09:43:30 +02:00
switch (temp->state) {
case 0: // idle
break;
2020-08-22 09:43:30 +02:00
case 1: // fading in
if (temp->flags & 1) {
s32 phi_v0;
2020-08-22 09:43:30 +02:00
if (temp->fadeOutTime < 0xFA) {
phi_v0 = func_800554A4(0, temp->fadeOutTime);
} else {
2020-08-22 09:43:30 +02:00
phi_v0 = func_800554E8(0, temp->fadeOutTime);
}
if (phi_v0 != 0) {
return;
}
}
2020-08-22 09:43:30 +02:00
temp->state = 2;
break;
2020-08-22 09:43:30 +02:00
case 2: // fading out
if (temp->flags & 1) {
if (func_800555E4(0) != 0) {
return;
}
2020-08-22 09:43:30 +02:00
temp->flags &= ~1;
}
2020-08-22 09:43:30 +02:00
if (temp->fadeInTime < 0) {
temp->state = 0;
} else if (func_80055448(temp->fadeInTime) == 0) {
if (func_80055464(0, 0) == 0) {
2020-08-22 09:43:30 +02:00
temp->state = 0;
temp->flags |= 1;
}
}
break;
}
}
2020-08-22 09:43:30 +02:00
s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) {
struct_80147230* temp1 = &D_8015C7C0;
struct_80147230* temp2 = &D_8015C7C0;
2020-08-22 09:43:30 +02:00
if (!(*gGameStatusPtr)->musicEnabled) {
func_800554A4(temp1->fadeInTime, fadeOutTime);
temp1->flags &= ~1;
return 1;
}
2020-08-22 09:43:30 +02:00
if (temp1->fadeInTime == fadeInTime) {
return 2;
}
2020-08-22 09:43:30 +02:00
temp2->fadeInTime = fadeInTime;
temp2->fadeOutTime = fadeOutTime;
temp2->state = 1;
return 1;
2020-08-12 04:08:48 +02:00
}