Skip to content

Commit de4d39f

Browse files
authored
Merge pull request #375 from DizzyEggg/music_players
Merge sSEMusicPlayers and sBGMusicPlayers
2 parents cae1ac0 + ae00bd5 commit de4d39f

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

include/music.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#define STOP_BGM 999
1313

1414
#define MAX_VOLUME 256
15-
#define NUM_BG_PLAYERS (INDEX_FANFARE - INDEX_BGM) + 1 // 2
16-
#define NUM_SE_PLAYERS (INDEX_SE6 - INDEX_SE1) + 1 // 6
1715

1816
enum MusicPlayerIndex
1917
{
@@ -25,6 +23,7 @@ enum MusicPlayerIndex
2523
INDEX_SE4,
2624
INDEX_SE5,
2725
INDEX_SE6,
26+
MUSIC_PLAYERS_COUNT
2827
};
2928

3029
// TODO: continue to doc the rest of BG/Fanfare Player States
@@ -73,4 +72,4 @@ void UpdateSound(void);
7372
extern void SoundBiasReset(void);
7473
extern void SoundBiasSet(void);
7574

76-
#endif //GUARD_MUSIC_H
75+
#endif //GUARD_MUSIC_H

src/music.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ static EWRAM_DATA u16 sFanfareMusicPlayerState = {0};
1212
static EWRAM_DATA u16 sMusicTransitionCounter = {0};
1313
static EWRAM_DATA bool8 sRestartBGM = {0};
1414

15-
static IWRAM_DATA PMDMusicPlayer sBGMusicPlayers[NUM_BG_PLAYERS] = {0};
16-
static IWRAM_DATA PMDMusicPlayer sSEMusicPlayers[NUM_SE_PLAYERS] = {0};
15+
static IWRAM_DATA PMDMusicPlayer sMusicPlayers[MUSIC_PLAYERS_COUNT] = {0};
1716

1817
static u16 GetMusicPlayerIndex(u16 songIndex);
1918
static bool8 IsBGSong(u32 songIndex);
@@ -46,7 +45,7 @@ void InitMusic(void)
4645
sMusicTransitionCounter = 0;
4746
sRestartBGM = FALSE;
4847

49-
for (playerIndex = INDEX_BGM, musicPlayer = &sBGMusicPlayers[0]; playerIndex < INDEX_SE6 + 1; playerIndex++, musicPlayer++) {
48+
for (playerIndex = INDEX_BGM, musicPlayer = &sMusicPlayers[0]; playerIndex < MUSIC_PLAYERS_COUNT; playerIndex++, musicPlayer++) {
5049
musicPlayer->unk0 = 0;
5150
musicPlayer->songIndex = STOP_SOUND_EFFECT;
5251
musicPlayer->volume = 0;
@@ -274,7 +273,7 @@ void PlayFanfareSE(u16 songIndex, u16 volume)
274273
return;
275274

276275
playerIndex = GetMusicPlayerIndex(songIndex);
277-
musicPlayer = &sBGMusicPlayers[playerIndex]; // need to load this before comparison to match
276+
musicPlayer = &sMusicPlayers[playerIndex]; // need to load this before comparison to match
278277

279278
if (playerIndex < INDEX_SE1)
280279
nullsub_20(songIndex);
@@ -310,7 +309,7 @@ UNUSED static void SetSoundEffectVolume(u16 songIndex, u16 volume)
310309
if (!IsFanfare(songIndex) && IsSoundEffect(songIndex)) {
311310
playerIndex = GetMusicPlayerIndex(songIndex);
312311
info = gMPlayTable[playerIndex].info;
313-
musicPlayer = &sBGMusicPlayers[playerIndex];
312+
musicPlayer = &sMusicPlayers[playerIndex];
314313
if (playerIndex >= INDEX_SE1) {
315314
interruptFlag = DisableInterrupts();
316315
if (musicPlayer->songIndex == songIndex)
@@ -329,7 +328,7 @@ void StopFanfareSE(u16 songIndex)
329328
PMDMusicPlayer *musicPlayer;
330329
bool8 interruptFlag = DisableInterrupts();
331330

332-
for (playerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
331+
for (playerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
333332
m4aMPlayStop(gMPlayTable[playerIndex].info);
334333
musicPlayer->unk0 = 0;
335334
musicPlayer->songIndex = STOP_SOUND_EFFECT;
@@ -343,7 +342,7 @@ void StopFanfareSE(u16 songIndex)
343342
else if (IsSoundEffect(songIndex)) {
344343
u32 playerIndex = GetMusicPlayerIndex(songIndex);
345344
struct MusicPlayerInfo *info = gMPlayTable[playerIndex].info;
346-
PMDMusicPlayer *musicPlayer = &sBGMusicPlayers[playerIndex];
345+
PMDMusicPlayer *musicPlayer = &sMusicPlayers[playerIndex];
347346

348347
if (playerIndex < INDEX_SE1)
349348
nullsub_21(songIndex);
@@ -406,7 +405,7 @@ void FadeOutFanfareSE(u16 songIndex, u16 speed)
406405
PMDMusicPlayer *musicPlayer;
407406
bool8 interruptFlag = DisableInterrupts();
408407

409-
for (playerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
408+
for (playerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; playerIndex < INDEX_SE6; playerIndex++, musicPlayer++) {
410409
if (musicPlayer->songIndex != STOP_SOUND_EFFECT) {
411410
if (IsMusicPlayerPlaying(playerIndex))
412411
m4aMPlayFadeOut(gMPlayTable[playerIndex].info, speed);
@@ -425,7 +424,7 @@ void FadeOutFanfareSE(u16 songIndex, u16 speed)
425424
}
426425
else if (IsSoundEffect(songIndex)) {
427426
s32 playerIndex = GetMusicPlayerIndex(songIndex);
428-
PMDMusicPlayer *musicPlayer = &sBGMusicPlayers[playerIndex];
427+
PMDMusicPlayer *musicPlayer = &sMusicPlayers[playerIndex];
429428
struct MusicPlayerInfo *playerInfo = gMPlayTable[playerIndex].info;
430429
bool8 interruptFlag = DisableInterrupts();
431430

@@ -487,7 +486,7 @@ bool8 IsFanfareSEPlaying(u16 songIndex)
487486
}
488487
else if (IsSoundEffect(songIndex)) {
489488
playerIndex = GetMusicPlayerIndex(songIndex);
490-
musicPlayer = &sBGMusicPlayers[playerIndex];
489+
musicPlayer = &sMusicPlayers[playerIndex];
491490
if (INDEX_SE1 > playerIndex)
492491
return FALSE;
493492
if (musicPlayer->songIndex == songIndex)
@@ -622,7 +621,7 @@ void UpdateSound(void)
622621
}
623622
}
624623

625-
for (musicPlayerIndex = INDEX_SE1, musicPlayer = &sSEMusicPlayers[0]; musicPlayerIndex < INDEX_SE6; musicPlayerIndex++, musicPlayer++) {
624+
for (musicPlayerIndex = INDEX_SE1, musicPlayer = &sMusicPlayers[INDEX_SE1]; musicPlayerIndex < INDEX_SE6; musicPlayerIndex++, musicPlayer++) {
626625
if (musicPlayer->songIndex != STOP_SOUND_EFFECT) {
627626
switch (musicPlayer->unk0){
628627
case 1:

src/party_list_menu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ void PartyListMenu_HandleMenu2(void)
653653
{
654654
u32 nextState;
655655
struct unkStruct_8090F58 temp;
656-
int menuAction;
656+
s32 menuAction;
657657
Item slot;
658658

659659
menuAction = 0;

src/trade_items_menu.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void sub_80365AC(void)
187187

188188
void sub_8036674(void)
189189
{
190-
int menuAction;
190+
s32 menuAction;
191191

192192
menuAction = -1;
193193
sub_801CA08(FALSE);
@@ -272,7 +272,7 @@ void sub_8036788(void)
272272

273273
void TradeItem_SendItemConfirm(void)
274274
{
275-
int menuAction;
275+
s32 menuAction;
276276
u16 load;
277277

278278
if (sub_80144A4(&menuAction) == 0)
@@ -297,7 +297,7 @@ void TradeItem_SendItemConfirm(void)
297297

298298
void sub_803689C(void)
299299
{
300-
int menuAction;
300+
s32 menuAction;
301301

302302
if (sub_80144A4(&menuAction) == 0) {
303303
switch(menuAction){
@@ -314,7 +314,7 @@ void sub_803689C(void)
314314

315315
void sub_80368D4(void)
316316
{
317-
int menuAction;
317+
s32 menuAction;
318318

319319
if (sub_80144A4(&menuAction) == 0) {
320320
switch(menuAction){
@@ -480,7 +480,7 @@ void nullsub_52(void)
480480

481481
void sub_8036B28(void)
482482
{
483-
int linkStatus;
483+
s32 linkStatus;
484484

485485
switch(sTradeItemsMenu->currMenu) {
486486
case TRADE_ITEMS_MAIN_MENU:

src/wonder_mail_main_menu.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void PrintWonderMailMainMenuError(u32 status)
323323

324324
void HandlePasswordEntryScreen(void)
325325
{
326-
int iVar2;
326+
s32 iVar2;
327327

328328
iVar2 = sub_80154F0();
329329
MemoryFill8(gUnknown_203B3E8->UNK38.unk38_u8, 0, sizeof(gUnknown_203B3E8->UNK38));
@@ -357,7 +357,7 @@ void HandlePasswordEntryScreen(void)
357357

358358
void AdvanceToPasswordEntryScreen(void)
359359
{
360-
int iVar2;
360+
s32 iVar2;
361361
if(sub_80144A4(&iVar2) == 0)
362362
{
363363
SetWonderMailMainMenuState(PASSWORD_ENTRY_SCREEN);
@@ -380,7 +380,7 @@ void HandlePasswordSuccess(void)
380380

381381
void HandlePrepareSaveScreen(void)
382382
{
383-
int iVar2;
383+
s32 iVar2;
384384
if(sub_80144A4(&iVar2) == 0)
385385
{
386386
SetWonderMailMainMenuState(SAVE_ADVENTURE);
@@ -390,7 +390,7 @@ void HandlePrepareSaveScreen(void)
390390

391391
void ReturnToGameLinkCableMenu(void)
392392
{
393-
int iVar2;
393+
s32 iVar2;
394394
if(sub_80144A4(&iVar2) == 0)
395395
{
396396
SetWonderMailMainMenuState(GAME_LINK_CABLE_MENU);
@@ -399,7 +399,7 @@ void ReturnToGameLinkCableMenu(void)
399399

400400
void HandleSaveAdventureScreen(void)
401401
{
402-
int iVar2;
402+
s32 iVar2;
403403
if(sub_80144A4(&iVar2) == 0)
404404
{
405405
if(!WriteSavePak())
@@ -412,7 +412,7 @@ void HandleSaveAdventureScreen(void)
412412

413413
void HandleWonderMailAddedScreen(void)
414414
{
415-
int iVar2;
415+
s32 iVar2;
416416
if(sub_80144A4(&iVar2) == 0)
417417
{
418418
SetWonderMailMainMenuState(EXIT_TO_MAIN_MENU);
@@ -444,7 +444,7 @@ void nullsub_54(void)
444444

445445
void WonderMailMainMenuCallback(void)
446446
{
447-
int linkStatus;
447+
s32 linkStatus;
448448
unkStruct_803B344 *temp;
449449

450450
switch(gUnknown_203B3E8->state) {

0 commit comments

Comments
 (0)