Avara

She/Her
Seen 1 Week Ago
Posted April 10th, 2022
1,306 posts
10.5 Years
Part 5: Adding New Battle Backgrounds

First things first, we have to add a #define for our new battle background. Open “pokeemerald\include\constants\battle.h” and add an entry at the end (my example is numbered 10):
// Battle terrain defines for gBattleTerrain.
#define BATTLE_TERRAIN_GRASS        0
#define BATTLE_TERRAIN_LONG_GRASS   1
#define BATTLE_TERRAIN_SAND         2
#define BATTLE_TERRAIN_UNDERWATER   3
#define BATTLE_TERRAIN_WATER        4
#define BATTLE_TERRAIN_POND         5
#define BATTLE_TERRAIN_MOUNTAIN     6
#define BATTLE_TERRAIN_CAVE         7
#define BATTLE_TERRAIN_BUILDING     8
#define BATTLE_TERRAIN_PLAIN        9
#define BATTLE_TERRAIN_ACADEMY      10
Now you will want to open “pokeemerald\include\graphics.h” and add entries for each of the files used for your new battle background, for example:
// battle terrains
extern const u32 gBattleTerrainTiles_Academy[];
extern const u32 gBattleTerrainTilemap_Academy[];
extern const u32 gBattleTerrainAnimTiles_Academy[];
extern const u32 gBattleTerrainAnimTilemap_Academy[];
extern const u32 gBattleTerrainPalette_Academy[];
Next, open “pokeemerald\src\data\graphics\battle_terrain.h” and add entries for your tiles, palette and tilemaps like this:
const u32 gBattleTerrainTiles_Academy[] = INCBIN_U32("graphics/battle_terrain/academy/tiles.4bpp.lz");
const u32 gBattleTerrainPalette_Academy[] = INCBIN_U32("graphics/battle_terrain/academy/palette.gbapal.lz");
const u32 gBattleTerrainTilemap_Academy[] = INCBIN_U32("graphics/battle_terrain/academy/map.bin.lz");

const u32 gBattleTerrainAnimTiles_Academy[] = INCBIN_U32("graphics/battle_terrain/academy/anim_tiles.4bpp.lz");
const u32 gBattleTerrainAnimTilemap_Academy[] = INCBIN_U32("graphics/battle_terrain/academy/anim_map.bin.lz");
After that, open “pokeemerald\src\battle_bg.c” and add an entry for your new battle background, which should look like this:
	    [BATTLE_TERRAIN_ACADEMY] =
    {
        .tileset = gBattleTerrainTiles_Academy,
        .tilemap = gBattleTerrainTilemap_Academy,
        .entryTileset = gBattleTerrainAnimTiles_Academy,
        .entryTilemap = gBattleTerrainAnimTilemap_Academy,
        .palette = gBattleTerrainPalette_Academy,
    },
Final steps now! You'll want to open “pokeemerald\src\battle_anim_utility_funcs.c” and add a new entry there, too.
	case BATTLE_TERRAIN_ACADEMY:
        gBattleAnimArgs[4] = RGB(31, 31, 31);
        break;
As my example background is an indoor one, I've just copied what the entry was for the Building background - the same in “pokeemerald\src\battle_intro.c”, where mine now looks like this.
static const TaskFunc sBattleIntroSlideFuncs[] =
{
    BattleIntroSlide1, // BATTLE_TERRAIN_GRASS
    BattleIntroSlide1, // BATTLE_TERRAIN_LONG_GRASS
    BattleIntroSlide2, // BATTLE_TERRAIN_SAND
    BattleIntroSlide2, // BATTLE_TERRAIN_UNDERWATER
    BattleIntroSlide2, // BATTLE_TERRAIN_WATER
    BattleIntroSlide1, // BATTLE_TERRAIN_POND
    BattleIntroSlide1, // BATTLE_TERRAIN_MOUNTAIN
    BattleIntroSlide1, // BATTLE_TERRAIN_CAVE
    BattleIntroSlide3, // BATTLE_TERRAIN_BUILDING
    BattleIntroSlide3, // BATTLE_TERRAIN_PLAIN
    BattleIntroSlide3, // BATTLE_TERRAIN_ACADEMY
};
All that's left to do now is test! If you've done everything correctly, your brand new battle background should show up in-game without a hitch :)