# Tiled and tmx2ea

## Inserting Custom Maps

Adding your custom maps is made easy using the tiled program and tmx2ea.

Things you will need:\
[Tiled](https://www.mapeditor.org/)\
[tmx2ea](https://feuniverse.us/t/tmx2ea-v2-0-released-insert-tiled-maps-using-event-assembler/1830)\
[Vanilla FE Tilesets](https://github.com/Klokinator/FE-Repo/tree/main/Tilesets/Vanilla%20FEGBA%20Tilesets%20%7BZoramine%7D)

## Creating a New Map in Tiled

To start, create a new map file using tiled. GBAFE map tiles are 16x16, so set the tile height and width accordingly. The rest of the default settings are fine. Next, select "new tileset" in the lower right hand corner. Select the tileset you want as the image source, and ensure the "embed tileset in map" checkbox is checked. From there, you can create your map! Remember that maps can only use one tileset at a time.

## Adding Tile Changes

Tile changes refer to any change in tiles on the map, such as doors and chests being opened. To create a tile change, simply create a new map layer in tiled using the layer menu in the upper right. Do note that layers must be rectangular in shape - you can create different shapes by using the "blank tile" (the first tile of the tileset) to fill in spaces you don't want to be changed.

## Map Properties

Map properties let tmx2ea know your intentions for the map, including what chapter the map is for, what tileset it will be using, and so on. Below are the properties for the "main" layer of the map.

| Property     | Description                                                                                                                                | Type                |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- |
| Main         | Defines the "main" layer of the map. Required when there are multiple layers. Make sure there is only one main layer.                      | None (has no value) |
| ChapterID    | Which chapter this map is for. (Index in the Chapter Data Table).                                                                          | Byte                |
| ObjectType   | The object set to use. This refers to the graphics for the tileset. (Index in the Event Pointer Table).                                    | Byte                |
| PaletteID    | This refers to the palette to use for the tileset. (Index in the Event Pointer Table).                                                     | Byte                |
| TileConfig   | The tile config to use. This refers to the terrain types and orientation of map tiles for the tileset. (Index in the Event Pointer Table). | Byte                |
| MapID        | Index of this map in the Event Pointer Table.                                                                                              | Byte                |
| MapChangesID | Index of this map's tile changes in the Event Pointer Table.                                                                               | Byte                |
| Anims1       | The tile animations to use for the tileset. (Index in the Event Pointer Table).                                                            | Byte                |
| Anims2       | The tile color changes to use for the tileset. (Index in the Event Pointer Table).                                                         | Byte                |

ObjectType, PaletteID, TileConfig, Anims1 and Anims2 all refer to the specific tileset being used. ChapterID, MapID, and MapChangesID should all be unique for each map.

The following properties are for non-main layers, or tile change layers. Do note that all of these properties will be automatically generated by tmx2ea, though you may still wish to define them manually.

<table><thead><tr><th>Property</th><th width="150">Description</th><th>Type</th></tr></thead><tbody><tr><td>ID</td><td>The ID for this specific tile change. Each tile change should have a unique ID, starting from 0.</td><td>Byte</td></tr><tr><td>X</td><td>The x coordinate of the top leftmost tile of this tile change.</td><td>Byte</td></tr><tr><td>Y</td><td>The y coordinate of the top leftmost tile of this tile change.</td><td>Byte</td></tr><tr><td>Width</td><td>The width of this tile change, in tiles.</td><td>Byte</td></tr><tr><td>Height</td><td>The height of this tile change, in tiles.</td><td>Byte</td></tr></tbody></table>
