For this tutorial, we will be changing the battle music for generic trainers depending on the map the player is on. In `GetBattleBGM` in [pokemon.c](https://github.com/pret/pokeemerald/blob/master/src/pokemon.c), this is where the magic happens. First, we need to define the region map sections constants at the top of the file: ```diff ... #include “constants/trainers.h” + #include ”constants/region_map_sections.h“ ``` Next, go to `GetBattleBGM` which should look like this: ```c u16 GetBattleBGM(void) { if (gBattleTypeFlags & BATTLE_TYPE_KYOGRE_GROUDON) return MUS_VS_KYOGRE_GROUDON; else if (gBattleTypeFlags & BATTLE_TYPE_REGI) return MUS_VS_REGI; else if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return MUS_VS_TRAINER; else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { u8 trainerClass; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) trainerClass = GetFrontierOpponentClass(gTrainerBattleOpponent_A); else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) trainerClass = TRAINER_CLASS_EXPERT; else trainerClass = gTrainers[gTrainerBattleOpponent_A].trainerClass; switch (trainerClass) { case TRAINER_CLASS_AQUA_LEADER: case TRAINER_CLASS_MAGMA_LEADER: return MUS_VS_AQUA_MAGMA_LEADER; case TRAINER_CLASS_TEAM_AQUA: case TRAINER_CLASS_TEAM_MAGMA: case TRAINER_CLASS_AQUA_ADMIN: case TRAINER_CLASS_MAGMA_ADMIN: return MUS_VS_AQUA_MAGMA; case TRAINER_CLASS_LEADER: return MUS_VS_GYM_LEADER; case TRAINER_CLASS_CHAMPION: return MUS_VS_CHAMPION; case TRAINER_CLASS_PKMN_TRAINER_3: if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) return MUS_VS_RIVAL; if (!StringCompare(gTrainers[gTrainerBattleOpponent_A].trainerName, gText_BattleWallyName)) return MUS_VS_TRAINER; return MUS_VS_RIVAL; case TRAINER_CLASS_ELITE_FOUR: return MUS_VS_ELITE_FOUR; case TRAINER_CLASS_SALON_MAIDEN: case TRAINER_CLASS_DOME_ACE: case TRAINER_CLASS_PALACE_MAVEN: case TRAINER_CLASS_ARENA_TYCOON: case TRAINER_CLASS_FACTORY_HEAD: case TRAINER_CLASS_PIKE_QUEEN: case TRAINER_CLASS_PYRAMID_KING: return MUS_VS_FRONTIER_BRAIN; default: return MUS_VS_TRAINER; } } else return MUS_VS_WILD; } ``` On `default` under the switch statement for trainer classes is where the normal trainer battle music plays for trainer classes that don’t have special music. It’s here that we’ll be adding in a check for the map section the player is on. For the sake of this tutorial, we will be making trainers on Route 102 map play `MUS_RG_VS_TRAINER` which is the standard trainer battle music for Pokémon FireRed and LeafGreen. Here’s how that would look: ```diff ... - default: - return MUS_VS_TRAINER; ... + default: + if (gMapHeader.regionMapSectionId == MAPSEC_ROUTE_102) + return MUS_RG_VS_TRAINER; + else + return MUS_VS_TRAINER; ``` `region_map_sections.h` needs to be included because without it, we won’t be able to use `MAPSEC_*` defines with `*` replacing the map name. If I didn’t mess anything up, that should work correctly.