Adding FRLG Style Doors - Pawkkie/Team-Aquas-Asset-Repo GitHub Wiki

Pawkkie ft. ShinyDragonHunter, written for pokeemerald-expansion 1.7.X

First, you'll want to grab this commit from ShinyDragonHunter's cleanup branch, which extends the vanilla doors to allow for the 1x1 tile (or 16x16 pixel) doors that FRLG uses. If you get confused, here's my commit adding the full functionality to my pokeemerald-expansion project.

From here you need to add your new door animation. I'd recommend using the pre-existing sprites from FRLG as a reference, but ultimately you just need to end up with a 16 pixel wide, 48 pixel high sprite, with each 16x16 section containing a door animation frame. The top is mostly partyway open, the middle is mostly open, and the bottom is completely open. The usual rule of spriting for decomps apply (16 colours, indexed palette, etc.).

Next you'll need to add a metatile label to your door tile in porymap, making sure that each door tile has a unique label. If you make the labels in porymap in should automatically generate them for you, but double check to be sure. Also ensure all of your new door tiles have the MB_ANIMATED_DOOR metatile behavior.

image

In include/constants/metatile_labels.h, the labels should look something like

// gTileset_SomeTileset
#define METATILE_SomeTileset_MyNewDoor1    0x24A 
#define METATILE_SomeTileset_MyNewDoor2    0x23C 

where the hex numbers at the end are unique.

You'll also need to add your actual door animation images. The last entry in the list in vanilla is sDoorAnimTiles_TrainerHillRoofElevator, so look for that line and follow the pattern:

In src/field_door.c,

static const u8 sDoorAnimTiles_BattleDomePreBattleRoom[] = INCBIN_U8("graphics/door_anims/battle_dome_pre_battle_room.4bpp");
static const u8 sDoorAnimTiles_BattleTentInterior[] = INCBIN_U8("graphics/door_anims/battle_tent_interior.4bpp");
static const u8 sDoorAnimTiles_TrainerHillLobbyElevator[] = INCBIN_U8("graphics/door_anims/trainer_hill_lobby_elevator.4bpp");
static const u8 sDoorAnimTiles_TrainerHillRoofElevator[] = INCBIN_U8("graphics/door_anims/trainer_hill_roof_elevator.4bpp");

Lastly, in the tileset palette images themselves, make sure you have enough space for the door animation frames to be loaded to VRAM. If you don't, you'll end up overwriting whatever tiles are being stored in the locations the door animation frames use, and it'll have a weird effect that looks something like this:

https://github.com/Pawkkie/Team-Aquas-Asset-Repo/assets/61265402/b07146af-b14d-4435-9111-626b9e7911b1

There's a comment explaining where this is in src/field_door.c:

// NOTE: The tiles of a door's animation must be copied to VRAM because they are not already part of any given tileset.
//       This means that if there are any pre-existing tiles in this copied region that are visible when the door
//       animation is played they will be overwritten.
#define DOOR_TILE_START_SIZE1 (NUM_TILES_TOTAL - 8)
#define DOOR_TILE_START_SIZE2 (NUM_TILES_TOTAL - 16)

Size 1 (and size 0 in ShinyDragonHunter's code) start at tile 1024 - 8. In porymap, that's the bottom row of the palette image, shown here:

image

The error shown above resulted from my having the building at the bottom in the very bottom row, and the last two tiles being overwritten. Moving it up a row solved the issue.

Feel free to ask questions if you run into any issues, and we'll try to keep this tutorial up to date from there!