MOS file format

Applies to:
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2

File versions

General Description
This file format describes static graphics in a tile based bitmap format. Such files are used for mini-maps and GUI backgrounds.

NOTE: if you want to create a mini-map, scale your source image by 32/3 (10.66667) for the original BG games, 32/4 for IWDs or by 6.4 for the EEs.

Overall structure:


Offset Size (data type) Description
0x0000 4 (char array) Signature ('MOS ')
0x0004 4 (char array) Version ('V1  ')
0x0008 2 (word) Width (pixels)
0x000a 2 (word) Height (pixels)
0x000c 2 (word) Columns (blocks)
0x000e 2 (word) Rows (blocks)
0x0010 4 (dword) Block size (pixels)
0x0014 4 (dword) Offset (from start of file) to palettes


This is an array of palettes. Each palette contains 256 entires, and each entry is an RGBAQUAD. The palette blocks are found in the same order as the pixel blocks they correspond to (i.e. by increasing column number, then by increasing row number).


This section immediately follows the palettes. This is an array of columns * rows dwords, which are the offsets from the beginning of the pixel data to each tile's pixel data. These pointers are in the same order as the palette data.


This section contains the tile data, ordered left-to-right, top-to-bottom order. The blocks on the right and the bottom rows are only as large as they need to be (i.e. width modulo 64 and height modulo 64) based on the width in pixels and the blocksize of 64 pixels. In general, the block layout looks like:

Image
Block 0,0
64*64 pixels
Block 1,0
64*64 pixels
Block 2,0
64x64 pixels
... Block (n-1),0
64*64 pixel
Block n,0
x*64 pixels
Block 0,1
64*64 pixels
Block 1,1
64*64 pixels
Block 2,1
64x64 pixels
... Block (n-1),1
64*64 pixel
Block n,1
x*64 pixels
... ... ... ... ... ...
Block 0,m
64*y pixels
Block 1,m
64*y pixels
Block 2,m
64*y pixels
... Block (n-1),m
64*y pixels
Block n,m
x*y pixels




MOSC file format

Overall structure:
  • Header
  • zlib compressed data


  • A MOSC file consists of a 12 byte header followed by a zlib compressed MOS file.

    Offset Size (data type) Description
    0x0000 4 (char array) Signature ('MOSC')
    0x0004 4 (char array) Version ('V1 ')
    0x0008 4 (dword) Uncompressed data length