Final Fantasy:World map data
Final Fantasy I (and Final Fantasy II as well) uses a 256×256-tile world map in this data format. The map data is not stored raw, but uses simple compression in a kind of run-length encoding. The ROM (in iNES format) stores its world map data starting at $4010.
From $4010 to $4210 there are 256 little-endian 16-bit integer values representing addresses in the NES memory map (with the $4010 ROM bank currently in place) that mark the left-hand-side beginnings of each 256-tile row of the map. (Because memory pointers are used in this fashion, it is entirely possible for more than one pointer to point to the identical memory location if they use identical row data, such as a 256-tile row of ocean.) Since this bank will loaded into the NES memory map at readable address $8000, all memory pointers in the ROM must point to the row's ROM file address + 0x3FF0. To translate a memory pointer back into a ROM file address, you subtract 0x3FF0 instead.
Because the row pointers point to active NES memory in which the $4010 must be active, all of the map data is confined to this bank. Unrelated data begins at file address $7F50, so all row data referenced by pointers must be located starting at $4210 and ending before $7F50, giving you 0x3D40 bytes to store your map row data.
Row data is stored sequentially as such:
- Byte values indicate a row's tiles from the left-edge, from left-to-right through the tiles, ending at the row's right edge.
- A single byte ranging 0x00 to 0x7F describes a single tile of a specific value. The next byte describes the tile to its right.
- A byte ranging 0x80 to 0xFE is the same as its value subtracted by 0x80 (or exclusive-or'ed by 0x80), but the immediately following byte indicates repetition of the tile value. A repetition byte value of 0x01 means no repetition, 0x02 means repeat once, 0x03 means repeat twice, 0x04 means repeat three times, and so on. 0x00 means to repeat 256 times, so that it can fill an entire row. A repetition value of 0xFF is prohibited.
- A byte value of 0xFF after the row's final tile terminates the row data.
So, for example:
- 1 tile valued 0x04
- 1 tile valued 0x73
- 0x96 0x01
- 1 tile valued 0x16
- 0x96 0x05
- 5 consecutive tiles valued 0x16
- 0x96 0x00 0xFF
- 256 consecutive tiles (an entire row) valued 0x16, and a row terminator
FF1 Overworld Tile Values
00 = Grass 01 = First Castle - Lower Left 02 = First Castle - Lower Right 03 = Forest - Top Left 04 = Forest - Top 05 = Forest - Top Right 06 = Grass - Bottom Right 07 = Grass - Bottom 08 = Grass - Bottom Left 09 = First Castle - Top Left 0A = First Castle - Top Right 0B = Elf Castle - Top Left 0C = Elf Castle - Top Right 0D = Tower of Illusion - Top 0E = Grotto 0F = Dock - Vertical Left 10 = Mountain - Top Left 11 = Mountain - Top 12 = Mountain - Top Right 13 = Forest - Left 14 = Forest - Bottom 15 = Forest - Right 16 = Grass - Right 17 = Ocean 18 = Grass - Left 19 = First Castle - Middle Left 1A = First Castle - Middle Right 1B = Elf Castle - Bottom Left 1C = Elf Castle - Bottom Right 1D = Tower of Illusion - Bottom 1E = Tower of Illusion - Shadow 1F = Dock - Vertical Right 20 = Mountain - Left 21 = Mountain 22 = Mountain - Right 23 = Forest - Bottom Left 24 = Forest - Bottom 25 = Forest - Bottom Right 26 = Grass - Top Right 27 = Grass - Top 28 = Grass - Top Left 29 = Elf Castle - Bottom Left (again?) 2A = Elf Castle - Bottom Right (again?) 2B = Grotto 2C = Village Fence - Top Left 2D = Village Fence - Top 2E = Village Fence - Top Right 2F = Grotto
FF2 tile values