papermario/src/code_dd930_len_1c0.c

78 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-09-18 22:07:15 +02:00
s16 fadeFlags;
s16 fadeState;
2020-08-22 09:43:30 +02:00
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-09-24 05:16:13 +02:00
void func_80147264(void) {
struct_80147230* temp = &D_8015C7C0;
2020-09-18 22:07:15 +02:00
switch (temp->fadeState) {
2020-08-22 09:43:30 +02:00
case 0: // idle
break;
2020-09-18 22:07:15 +02:00
case 1: // fading out
if (temp->fadeFlags & 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);
}
2020-09-18 22:07:15 +02:00
if (phi_v0 != 0) {
return;
}
}
2020-09-18 22:07:15 +02:00
temp->fadeState = 2;
break;
2020-09-18 22:07:15 +02:00
case 2: // fading in
if (temp->fadeFlags & 1) {
if (func_800555E4(0) != 0) {
return;
}
2020-09-18 22:07:15 +02:00
temp->fadeFlags &= ~1;
}
2020-08-22 09:43:30 +02:00
if (temp->fadeInTime < 0) {
2020-09-18 22:07:15 +02:00
temp->fadeState = 0;
2020-08-22 09:43:30 +02:00
} else if (func_80055448(temp->fadeInTime) == 0) {
if (func_80055464(0, 0) == 0) {
2020-09-18 22:07:15 +02:00
temp->fadeState = 0;
temp->fadeFlags |= 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);
2020-09-18 22:07:15 +02:00
temp1->fadeFlags &= ~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;
2020-09-18 22:07:15 +02:00
temp2->fadeState = 1;
return 1;
2020-08-12 04:08:48 +02:00
}