Skip to content

Gm1 file

Julian Offenhäuser edited this page Jan 6, 2020 · 1 revision

Gm1 files are containers for images/tiles.

File outline:

  • Header (88 bytes)
  • Color palette (5120 bytes)
  • Image offsets (4 bytes each)
  • Image sizes (4 bytes each)
  • Image headers (16 bytes each)
  • Image entries
struct Gm1Header {
    uint32_t u0[3];
    uint32_t numberOfEntries;
    uint32_t u1;
    uint32_t dataType;
    uint32_t u2[14];
    uint32_t length;
    uint32_t u3;
};

Entry types:

  1. 0x01: Interface element (Tgx compressed)
  2. 0x02: Animation (Each entry is one frame)
  3. 0x03: Tileset (Each entry consist of one image and one tile)
  4. 0x04: Font (Tgx compressed)
  5. 0x05: Uncompressed image
  6. 0x06: Compressed image
  7. 0x07: Like 0x05

Color palette:

Divided into 10 sections(unit colors), 256 colors of 2 bytes each.

Image offsets and sizes

Stores a uint32 for each entry in the file (number denoted in header).

Image headers:

Stores one header for each of the following images.

struct ImageHeader {
    uint16_t width;
    uint16_t height;
    uint16_t offsetX;
    uint16_t offsetY;
    uint8_t partID;
    uint8_t numParts;
    uint16_t tileOffsetY;
};

Image entries:

Depends on the stored entry type.

  1. For 0x01, 0x04, 0x06: One Tgx compressed image, see info above.
  2. For 0x02: One Tgx compressed frame, but uses an index into the palette instead of pixels. For multi-colored units, find color like this: pixel = (uint16*)palette[unit_color * 256 + index];
  3. For 0x03: One tile image plus one normal Tgx image for the building part

Tile image:

Placed under each image part. Consist of 16 lines of varying width. The individual widths are: 2, 6, 10, 14, 18, 22, 26, 30, 30, 26, 22, 18, 14, 10, 6, 2. Calculate the xy position of each pixel like this (placed in a 30x16 image):

x = 15 - line_width_lut[current_line] / 2 + current_pixel_in_line; y = current_line;

Clone this wiki locally