Ultima 5 File Formats (Sharp X86000 version)
============================================

Last updated on 19-March-2004.
Please send additions, corrections and feedback to this e-Mail address:
Remove space + vowels from "marc winterrowd" and append "at yahoo dot com"


General Notes
-------------

Conversations with NPC's and a few displayed texts are in Japanese (Kanji).
The rest of the game is in English (runes or Latin characters).


*.16
----

These files are LZW-compressed.
File format:

file = number_of_entries, set of offset32, set of image
number_of_entries = uint16
offset32 = uint32

image = width, height, image_data

image_data = blue_plane, red_plane, green_plane

blue_plane  = bitplane
red_plane   = bitplane
green_plane = bitplane

bitplane = set of uint8 (1 bit per pixel)

Notes:
1) "width" is the number of bytes per row per bitplane, not the actual
width. You can calculate the real width like this:
real_width = width*8


UL??.BIN
--------

The music files.
File format is currently unknown.


*.CH
----

    NPC.CH
    ------
    This file contains the NPC tiles.
    Tile format: 32x32 pixels, 4 bits per pixel (blue, red, green, alpha)

    struct NPC_CH {
        Tile tiles[0x100];
    }

    struct Tile {
        Tile_Row blue[0x20];    // blue bitplane
        Tile_Row red[0x20];     // red bitplane
        Tile_Row green[0x20];   // green bitplane
        Tile_Row alpha[0x20];   // alpha bitplane
    }

    struct Tile_Row {
        uint8 pixel_data[4];    // 32 pixels, 1 bit per pixel
    }


    TILES.CH
    --------
    This file contains the world tiles.
    Tile format: 32x32 pixels, 3 bits per pixel (blue, red, green)

    struct TILES_CH {
        Tile tiles[0x100];
    }

    struct Tile {
        Tile_Row blue[0x20];    // blue bitplane
        Tile_Row red[0x20];     // red bitplane
        Tile_Row green[0x20];   // green bitplane
    }

    struct Tile_Row {
        uint8 pixel_data[4];    // 32 pixels, 1 bit per pixel
    }


*.DAT
-----

    BRIT.DAT
    --------
    Map of Britannia.
    Its size is 256x256 tiles, and each tile is stored as a uint8.
    The way the map is stored differs from the PC version:
    1) The map is not compressed in any way.
       In the PC version, all-water chunks were left out to save space.
    2) The map is not divided into chunks. In other words:
       brit_dat[y*0x100 + x] = tile(x,y)


    DNG?.DAT
    --------
    These files are not compressed.
    They have the same format as the uncompressed *.16 files.

    Notes:
    1) In DNG?.DAT, offsets 0x8 and 0x18 are zero.


    ITEMS.DAT
    ---------
    This file is not compressed.

    items_dat = number_of_entries, set of offset32, set of image
    number_of_entries = uint16
    offset32 = uint32

    image = width, height, image_size, image_data

    width = uint16
    height = uint16
    image_size = uint16
    image_data = blue_plane, red_plane, green_plane, alpha_plane

    blue_plane  = bitplane
    red_plane   = bitplane
    green_plane = bitplane
    alpha_plane = bitplane

    bitplane = set of uint8 (1 bit per pixel)

    Notes:
    1) "width" is the number of bytes per row per bitplane, not the actual
    width. You can calculate the real width like this:
    real_width = width*8
    2) image_size = width*height (number of bytes per bitplane)


    MON?.DAT
    --------
    These files are LZW-compressed.
    Uncompressed, they have the same format as ITEMS.DAT.


    SIGNS.DAT
    ---------
    This file has the same format as the PC version's.


    UNDER.DAT
    ---------
    Map of the underworld.
    The file format is identical to that of BRIT.DAT.


*.NPC
-----

These files contain information about NPC's.
The file format is the same as the PC version's.


*.TLK
-----

These files contain conversation scripts.
File format:

tlk_file = number_of_entries, set of offset16, script_data

number_of_entries = uint16
offset16 = uint16
script_data = set of kanji_char

kanji_char = uint8, uint8

Notes:
1) In the PC version, the *.TLK files contain compressed words. There are
no compressed words in X86000 version, because every Kanji character is a
word.
2) Unlike the PC version, the X86000 version doesn't store the NPC numbers
in the *.TLK file header.


Sources
-------
Nytegard 

    Source: geocities.com/nodling/ultima/text/ultima5

               ( geocities.com/nodling/ultima/text)                   ( geocities.com/nodling/ultima)                   ( geocities.com/nodling)