If the Battle scene (in Porymap) is MAP_BATTLE_SCENE_NORMAL
, then the game will use a default terrain based on various attributes. For example, being in tall grass sets the battle terrain to a tall grass background. Editing these requires adding new code at src/battle_setup.c#L637.
The default battle terrains are defined at src/battle_bg.c#L601 and the pointers to the graphics are defined at src/data/graphics/battle_terrrain.h#L60. You can replace the filepaths with the files of your choosing to replace the default battle terrains. Note that the pointers are scattered about the file so you'll need to track down all the pointers within src/data/graphics/battle_terrrain.h#L60.
For example, to replace the graphics for BATTLE_TERRAIN_GRASS
, you would look for BATTLE_TERRAIN_GRASS
in gBattleTerrainTable linked above
[BATTLE_TERRAIN_GRASS] =
{
.tileset = gBattleTerrainTiles_TallGrass,
.tilemap = gBattleTerrainTilemap_TallGrass,
.entryTileset = gBattleTerrainAnimTiles_TallGrass,
.entryTilemap = gBattleTerrainAnimTilemap_TallGrass,
.palette = gBattleTerrainPalette_TallGrass,
},
Then search all of the gBattleTerrain[...]
pointers within the braces in src/data/graphics/battle_terrrain.h#L60 and replace the filepaths for each INCBIN. For example, to replace the file for const u32 gBattleTerrainTiles_TallGrass[] = INCBIN_U32("graphics/battle_terrain/tall_grass/tiles.4bpp.lz");
, the path would be replaced with graphics/battle_terrain/<your_tall_grass>/tiles.4bpp.lz
.
(Note: The default battle terrain constants are defined in include/constants/battle.h#L348, but you shouldn't need to edit these).
You can also set a map wide battle terrain in Battle scene. The default map battle terrains are defined at include/constants/map_types.h#L15.
Adding a new map wide battle terrain:
First, add a new constant at include/constants/map_types.h#L23 after the given line.
For example, we may add #define MAP_BATTLE_SCENE_<YOUR_BATTLE_SCENE> 9
, replacing <YOUR_BATTLE_SCENE>
with your desired name. Note that the numbers need to be sequential whenever you add a new constant (i.e. +1 from the previous constant).
Go to src/battle_bg.c#L855 and insert the following above the line (rename <YourBattleScene>
and <YOUR_BATTLE_SCENE>
):
case MAP_BATTLE_SCENE_<YOUR_BATTLE_SCENE>:
LZDecompressVram(gBattleTerrainTiles_<YourBattleScene>, (void*)(BG_CHAR_ADDR(2)));
LZDecompressVram(gBattleTerrainTilemap_<YourBattleScene>, (void*)(BG_SCREEN_ADDR(26)));
LoadCompressedPalette(gBattleTerrainPalette_<YourBattleScene>, 0x20, 0x60);
break;
Then, at src/data/graphics/battle_terrain.h#L88, add the following below the line, again renaming <YourBattleScene>
and <your_battle_scene>
:
const u32 gBattleTerrainTiles_<YourBattleScene>[] = INCBIN_U32("graphics/battle_terrain/<your_battle_scene>/tiles.4bpp.lz");
const u32 gBattleTerrainPalette_<YourBattleScene>[] = INCBIN_U32("graphics/battle_terrain/<your_battle_scene>/palette.gbapal.lz");
const u32 gBattleTerrainTilemap_<YourBattleScene>[] = INCBIN_U32("graphics/battle_terrain/<your_battle_scene>/map.bin.lz");
Ensure that the relevant source files in <your_battle_scene>/
are there (i.e. tiles.png, map.bin, maybe palette.pal). Note that the animation will default to the animation used in the Building terrain (maybe add additional code to add new anims?).