-
Notifications
You must be signed in to change notification settings - Fork 23
Gm1 file
Julian Offenhäuser edited this page Jan 6, 2020
·
1 revision
Gm1 files are containers for images/tiles.
- 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;
};
- 0x01: Interface element (Tgx compressed)
- 0x02: Animation (Each entry is one frame)
- 0x03: Tileset (Each entry consist of one image and one tile)
- 0x04: Font (Tgx compressed)
- 0x05: Uncompressed image
- 0x06: Compressed image
- 0x07: Like 0x05
Divided into 10 sections(unit colors), 256 colors of 2 bytes each.
Stores a uint32 for each entry in the file (number denoted in header).
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;
};
Depends on the stored entry type.
- For 0x01, 0x04, 0x06: One Tgx compressed image, see info above.
- 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];
- For 0x03: One tile image plus one normal Tgx image for the building part
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;