Fix Egregious Magic Numbers in GetBattleBGM

Whoever originally decomped this function must've been really fed up with this file.

Renamed GetMUS_ForBattle to GetBattleBGM to be consistent with pokeemerald.

This entire function was magic numbers, so I replaced them with the appropriate constants.
This commit is contained in:
Deokishisu
2021-01-08 04:09:59 -05:00
parent 135fd3948a
commit 90e5a5ff7e
+23 -22
View File
@@ -31,6 +31,7 @@
#include "constants/abilities.h" #include "constants/abilities.h"
#include "constants/flags.h" #include "constants/flags.h"
#include "constants/moves.h" #include "constants/moves.h"
#include "constants/songs.h"
#include "constants/trainer_classes.h" #include "constants/trainer_classes.h"
#include "constants/facility_trainer_classes.h" #include "constants/facility_trainer_classes.h"
#include "constants/hold_effects.h" #include "constants/hold_effects.h"
@@ -5661,40 +5662,40 @@ void ClearBattleMonForms(void)
gBattleMonForms[i] = 0; gBattleMonForms[i] = 0;
} }
static u16 GetMUS_ForBattle(void) static u16 GetBattleBGM(void)
{ {
if (gBattleTypeFlags & 0x1000) if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON)
return 0x12A; return MUS_VS_WILD;
if (gBattleTypeFlags & 0x4000) if (gBattleTypeFlags & BATTLE_TYPE_REGI)
return 0x10A; return MUS_RS_VS_TRAINER;
if (gBattleTypeFlags & 0x2) if (gBattleTypeFlags & BATTLE_TYPE_LINK)
return 0x10A; return MUS_RS_VS_TRAINER;
if (gBattleTypeFlags & 0x8) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
{ {
switch (gTrainers[gTrainerBattleOpponent_A].trainerClass) switch (gTrainers[gTrainerBattleOpponent_A].trainerClass)
{ {
case 0x5A: case CLASS_CHAMPION_2:
return 0x12B; return MUS_VS_CHAMPION;
case 0x54: case CLASS_LEADER_2:
case 0x57: case CLASS_ELITE_FOUR_2:
return 0x128; return MUS_VS_GYM_LEADER;
case 0x53: case CLASS_BOSS:
case 0x55: case CLASS_TEAM_ROCKET:
case 0x56: case CLASS_COOLTRAINER_2:
case 0x58: case CLASS_GENTLEMAN_2:
case 0x59: case CLASS_RIVAL_2:
default: default:
return 0x129; return MUS_VS_TRAINER;
} }
} }
return 0x12A; return MUS_VS_WILD;
} }
void PlayBattleBGM(void) void PlayBattleBGM(void)
{ {
ResetMapMusic(); ResetMapMusic();
m4aMPlayAllStop(); m4aMPlayAllStop();
PlayBGM(GetMUS_ForBattle()); PlayBGM(GetBattleBGM());
} }
void PlayMapChosenOrBattleBGM(u16 songId) void PlayMapChosenOrBattleBGM(u16 songId)
@@ -5704,7 +5705,7 @@ void PlayMapChosenOrBattleBGM(u16 songId)
if (songId) if (songId)
PlayNewMapMusic(songId); PlayNewMapMusic(songId);
else else
PlayNewMapMusic(GetMUS_ForBattle()); PlayNewMapMusic(GetBattleBGM());
} }
const u32 *GetMonFrontSpritePal(struct Pokemon *mon) const u32 *GetMonFrontSpritePal(struct Pokemon *mon)