Merge pull request #375 from DizzyEggg/music_players
Some checks are pending
GithubCI / build (push) Waiting to run

Merge sSEMusicPlayers and sBGMusicPlayers
This commit is contained in:
Seth Barberee
2025-03-21 17:10:16 -07:00
committed by GitHub
5 changed files with 25 additions and 27 deletions

View File

@@ -12,8 +12,6 @@
#define STOP_BGM 999
#define MAX_VOLUME 256
#define NUM_BG_PLAYERS (INDEX_FANFARE - INDEX_BGM) + 1 // 2
#define NUM_SE_PLAYERS (INDEX_SE6 - INDEX_SE1) + 1 // 6
enum MusicPlayerIndex
{
@@ -25,6 +23,7 @@ enum MusicPlayerIndex
INDEX_SE4,
INDEX_SE5,
INDEX_SE6,
MUSIC_PLAYERS_COUNT
};
// TODO: continue to doc the rest of BG/Fanfare Player States
@@ -73,4 +72,4 @@ void UpdateSound(void);
extern void SoundBiasReset(void);
extern void SoundBiasSet(void);
#endif //GUARD_MUSIC_H
#endif //GUARD_MUSIC_H

View File

@@ -12,8 +12,7 @@ static EWRAM_DATA u16 sFanfareMusicPlayerState = {0};
static EWRAM_DATA u16 sMusicTransitionCounter = {0};
static EWRAM_DATA bool8 sRestartBGM = {0};
static IWRAM_DATA PMDMusicPlayer sBGMusicPlayers[NUM_BG_PLAYERS] = {0};
static IWRAM_DATA PMDMusicPlayer sSEMusicPlayers[NUM_SE_PLAYERS] = {0};
static IWRAM_DATA PMDMusicPlayer sMusicPlayers[MUSIC_PLAYERS_COUNT] = {0};
static u16 GetMusicPlayerIndex(u16 songIndex);
static bool8 IsBGSong(u32 songIndex);
@@ -46,7 +45,7 @@ void InitMusic(void)
sMusicTransitionCounter = 0;
sRestartBGM = FALSE;
for (playerIndex = INDEX_BGM, musicPlayer = &sBGMusicPlayers[0]; playerIndex < INDEX_SE6 + 1; playerIndex++, musicPlayer++) {
for (playerIndex = INDEX_BGM, musicPlayer = &sMusicPlayers[0]; playerIndex < MUSIC_PLAYERS_COUNT; playerIndex++, musicPlayer++) {
musicPlayer->unk0 = 0;
musicPlayer->songIndex = STOP_SOUND_EFFECT;
musicPlayer->volume = 0;
@@ -274,7 +273,7 @@ void PlayFanfareSE(u16 songIndex, u16 volume)
return;
playerIndex = GetMusicPlayerIndex(songIndex);
musicPlayer = &sBGMusicPlayers[playerIndex]; // need to load this before comparison to match
musicPlayer = &sMusicPlayers[playerIndex]; // need to load this before comparison to match
if (playerIndex < INDEX_SE1)
nullsub_20(songIndex);
@@ -310,7 +309,7 @@ UNUSED static void SetSoundEffectVolume(u16 songIndex, u16 volume)
if (!IsFanfare(songIndex) && IsSoundEffect(songIndex)) {
playerIndex = GetMusicPlayerIndex(songIndex);
info = gMPlayTable[playerIndex].info;
musicPlayer = &sBGMusicPlayers[playerIndex];
musicPlayer = &sMusicPlayers[playerIndex];
if (playerIndex >= INDEX_SE1) {
interruptFlag = DisableInterrupts();
if (musicPlayer->songIndex == songIndex)
@@ -329,7 +328,7 @@ void StopFanfareSE(u16 songIndex)
PMDMusicPlayer *musicPlayer;
bool8 interruptFlag = DisableInterrupts();
for (playerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
for (playerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
m4aMPlayStop(gMPlayTable[playerIndex].info);
musicPlayer->unk0 = 0;
musicPlayer->songIndex = STOP_SOUND_EFFECT;
@@ -343,7 +342,7 @@ void StopFanfareSE(u16 songIndex)
else if (IsSoundEffect(songIndex)) {
u32 playerIndex = GetMusicPlayerIndex(songIndex);
struct MusicPlayerInfo *info = gMPlayTable[playerIndex].info;
PMDMusicPlayer *musicPlayer = &sBGMusicPlayers[playerIndex];
PMDMusicPlayer *musicPlayer = &sMusicPlayers[playerIndex];
if (playerIndex < INDEX_SE1)
nullsub_21(songIndex);
@@ -406,7 +405,7 @@ void FadeOutFanfareSE(u16 songIndex, u16 speed)
PMDMusicPlayer *musicPlayer;
bool8 interruptFlag = DisableInterrupts();
for (playerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
for (playerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
if (musicPlayer->songIndex != STOP_SOUND_EFFECT) {
if (IsMusicPlayerPlaying(playerIndex))
m4aMPlayFadeOut(gMPlayTable[playerIndex].info, speed);
@@ -425,7 +424,7 @@ void FadeOutFanfareSE(u16 songIndex, u16 speed)
}
else if (IsSoundEffect(songIndex)) {
s32 playerIndex = GetMusicPlayerIndex(songIndex);
PMDMusicPlayer *musicPlayer = &sBGMusicPlayers[playerIndex];
PMDMusicPlayer *musicPlayer = &sMusicPlayers[playerIndex];
struct MusicPlayerInfo *playerInfo = gMPlayTable[playerIndex].info;
bool8 interruptFlag = DisableInterrupts();
@@ -487,7 +486,7 @@ bool8 IsFanfareSEPlaying(u16 songIndex)
}
else if (IsSoundEffect(songIndex)) {
playerIndex = GetMusicPlayerIndex(songIndex);
musicPlayer = &sBGMusicPlayers[playerIndex];
musicPlayer = &sMusicPlayers[playerIndex];
if (INDEX_SE1 > playerIndex)
return FALSE;
if (musicPlayer->songIndex == songIndex)
@@ -622,7 +621,7 @@ void UpdateSound(void)
}
}
for (musicPlayerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; musicPlayerIndex < INDEX_SE6; musicPlayerIndex++, musicPlayer++) {
for (musicPlayerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; musicPlayerIndex < INDEX_SE6; musicPlayerIndex++, musicPlayer++) {
if (musicPlayer->songIndex != STOP_SOUND_EFFECT) {
switch (musicPlayer->unk0){
case 1:

View File

@@ -653,7 +653,7 @@ void PartyListMenu_HandleMenu2(void)
{
u32 nextState;
struct unkStruct_8090F58 temp;
int menuAction;
s32 menuAction;
Item slot;
menuAction = 0;

View File

@@ -187,7 +187,7 @@ void sub_80365AC(void)
void sub_8036674(void)
{
int menuAction;
s32 menuAction;
menuAction = -1;
sub_801CA08(FALSE);
@@ -272,7 +272,7 @@ void sub_8036788(void)
void TradeItem_SendItemConfirm(void)
{
int menuAction;
s32 menuAction;
u16 load;
if (sub_80144A4(&menuAction) == 0)
@@ -297,7 +297,7 @@ void TradeItem_SendItemConfirm(void)
void sub_803689C(void)
{
int menuAction;
s32 menuAction;
if (sub_80144A4(&menuAction) == 0) {
switch(menuAction){
@@ -314,7 +314,7 @@ void sub_803689C(void)
void sub_80368D4(void)
{
int menuAction;
s32 menuAction;
if (sub_80144A4(&menuAction) == 0) {
switch(menuAction){
@@ -480,7 +480,7 @@ void nullsub_52(void)
void sub_8036B28(void)
{
int linkStatus;
s32 linkStatus;
switch(sTradeItemsMenu->currMenu) {
case TRADE_ITEMS_MAIN_MENU:

View File

@@ -323,7 +323,7 @@ void PrintWonderMailMainMenuError(u32 status)
void HandlePasswordEntryScreen(void)
{
int iVar2;
s32 iVar2;
iVar2 = sub_80154F0();
MemoryFill8(gUnknown_203B3E8->UNK38.unk38_u8, 0, sizeof(gUnknown_203B3E8->UNK38));
@@ -357,7 +357,7 @@ void HandlePasswordEntryScreen(void)
void AdvanceToPasswordEntryScreen(void)
{
int iVar2;
s32 iVar2;
if(sub_80144A4(&iVar2) == 0)
{
SetWonderMailMainMenuState(PASSWORD_ENTRY_SCREEN);
@@ -380,7 +380,7 @@ void HandlePasswordSuccess(void)
void HandlePrepareSaveScreen(void)
{
int iVar2;
s32 iVar2;
if(sub_80144A4(&iVar2) == 0)
{
SetWonderMailMainMenuState(SAVE_ADVENTURE);
@@ -390,7 +390,7 @@ void HandlePrepareSaveScreen(void)
void ReturnToGameLinkCableMenu(void)
{
int iVar2;
s32 iVar2;
if(sub_80144A4(&iVar2) == 0)
{
SetWonderMailMainMenuState(GAME_LINK_CABLE_MENU);
@@ -399,7 +399,7 @@ void ReturnToGameLinkCableMenu(void)
void HandleSaveAdventureScreen(void)
{
int iVar2;
s32 iVar2;
if(sub_80144A4(&iVar2) == 0)
{
if(!WriteSavePak())
@@ -412,7 +412,7 @@ void HandleSaveAdventureScreen(void)
void HandleWonderMailAddedScreen(void)
{
int iVar2;
s32 iVar2;
if(sub_80144A4(&iVar2) == 0)
{
SetWonderMailMainMenuState(EXIT_TO_MAIN_MENU);
@@ -444,7 +444,7 @@ void nullsub_54(void)
void WonderMailMainMenuCallback(void)
{
int linkStatus;
s32 linkStatus;
unkStruct_803B344 *temp;
switch(gUnknown_203B3E8->state) {