Skip to content
SaveState edited this page May 15, 2019 · 11 revisions

In Pokemon Red, the town map is stored in a more compressed form than Pokemon Crystal. After some practice, though editing the layout gets very easy.

All you really need is a hex editor.

Contents

  1. The tileset
  2. How the compression works
  3. Editing the layout

1. The Tileset

Pokemon Red uses a very simple and basic tile set for the town map, made of 16 tiles. It looks like this:

Pokemon Red Map Tile Set

You can edit this tile set in gfx/town_map.png

I added those numbers above it in the screenshot to aid in editing the layout.

2. How the compression works

Unlike Pokemon Crystal, Pokemon Red's town map layout uses a type of encoding called run-length encoding (RLE), which I will explain here.

Now, go ahead and open up gfx/town_map.rle in a hex editor. My personal favorite hex editor is FlexHEX, but any hex editor should work.

You should see that it starts with "7F 75 6C". If it doesn't, maybe you've edited this before, or you're looking at the wrong file (or you somehow aren't using your hex editor correctly)!

How RLE compression works is it takes it one byte at a time. We'll take the first one, $7F, for the first example.

First, the first digit in a byte represents the tile to be placed. in this one, it is tile 7, which, as you can see in my image above, is the blank white tile.

The second byte is how many of that tile will be placed in a row. For this byte, that value is $F, or 15 in decimal. That means that the engine will place 15 white tiles in a row, starting on the top-left of the screen. This is visible as the white part on the top of the screen behind where the names of locations are displayed.

Pokemon Red Town Map

The GBC screen is 20 tiles wide, so 5 more white tiles would need to be placed after this for the white line on top of the screen, and this is accomplished by the second byte, which is $75. Two bytes were needed for one type of tile because the highest number you can have using one digit of hex is 15. You can see that the rest of the code fits the rest of the map using the same method. Keep in mind that when the placement of tiles reaches the right-hand side of the screen, it will continue to place them on the left-hand side, one row down.

3. Editing the Layout

Now, editing the layout shouldn't be that hard, provided you've been paying attention so far. It might be easier to start with a mockup of your map, and then converting that information into RLE code.

All you have to do here is take the number of the tile you want to be placed next, then how many of them you want in a row (as a hexadecimal number). Remember, you can only place 15 tiles in a row with one byte. In order to add more, simply use the next byte for the same tile. KEEP IN MIND THAT THE CODE MUST END WITH BYTE $00.

The beauty of the disassembly is that the data for the new tile map can be larger than the original, without tedious repointing. If you run out of room, you can simply make the file larger, and it will still compile perfectly.

After you're done with this, save the .rle file, compile the ROM, and that's it! Done!

Clone this wiki locally