File Formats
Table of Contents
Graphics Files
There are three types of graphics:
- CGA (files starting with "CGA")
- T1K (files starting with "T1K")
- EGA (files starting with "EGA")
Each file contains a tileset. For example, the CGATILES.BIN file contains 52 tiles, each having dimensions of 16x16 pixels. These numbers vary from one file to another - for example, CGATOWN.BIN contains 51 tiles, each being 8x8 pixels.
The CGA and T1K formats are conceptually simple and work similarly to each other. The data for each pixel from left to right, and then from top to bottom, is stored sequentially in the file. CGA uses 2 bits per pixel to index one of 4 possible colours, while T1K uses 4 bits per pixel to index one of 16 different colours. The value given by these 2 or 4 bits are an offset to a standard palette that defines the colour.
T1K actually stands for Tandy 1000, a line of computers from the 80s which had 16 colours and was EGA-compatible.
The EGA format is more complicated. It consists of non-contiguous pixel data in BGRA channels, where each channel is a 4-bit actual colour value, and the alpha value acts as a multiplier to the three colour channels. If A == 1, then a bright colour is obtained by multiplying the colour channels by 0xFF; otherwise, they are multiplied by 0x7F for a dimmer colour.
The structure of the EGA format for the EGATILES.BIN and the EGATOWN.BIN is known; however it seems to work a little differently for tilesets where the tiles aren't square (e.g. EGASPACE.BIN) so it has not yet been thoroughly understood.
More information about the CGA/EGA/VGA file formats can be found at:
Savegame Files
There are four slots for savegames - PLAYER1.U1 through PLAYER4.U1. Additionally, there is also another file called INUSE.U1 that is used to pass player data from one executable to another (see Executable Flow).
These files are 820 bytes long. They consist mostly of 16-bit integer values in little endian format (read bytes from right to left). I have managed to decode a significant part of their format.
- Download the Savegame file format [Excel, 17KB].
- Read about how this information was gathered in my blog post, "Ultima 1 Reverse Engineering: Decoding Savegame Files".
- A text file listing character byte locations in the savegame file was written by Bryan Carter and can be found at either Bryan's projects page or his list of text files.
Map Files
MAP.BIN contains the world map. The following is taken from technical notes provided by Johnny Wood:
The world map consists of 13104 bytes. The world map itself is 168x156 or 26208. Therefore, for each byte read in on the world map, the byte represents two tiles. The low 4
bytes[bits] represent the first tile while the next fourbytes[bits] represent the second. The numbers themselves need no conversion and are simply offset into the tileset generated from the xxxtiles.bin file. For example, a value of '10' will equal a grass tile '1' followed by a water tile '0'.
TCD.BIN contains the town and castle maps. They are stored as 10x38x18 [this info also comes from Johnny Wood's notes]. This means that towns and castles are 38 tiles wide and 18 tiles high, and there are 10 of them. This is because there are 8 different towns and 2 castles, and they are repeated across each continent.