Show whole topic Feb 13, 2019 10:20 pm
riess Offline
Approved Member
Registered since: Feb 09, 2019
Location: -

Subject: Re: M.A.X 2 Data Extractor
Thank you!

Now that I've got "single image" files working, I've went after multi-image files. I've been thinking that one of bytes is identificator, but I was wrong Wink

This is a container file format that holds many images. Here is header:

DownloadSource code (Text):
  1. Offset      Len     Description
  2. 0           2       Number of images stored in file
  3. 2           2       Palette id

Next they have list of offsets of every image in file, four bytes each. If there's one image, it will be single 4-byte offset equaling to "8". There is as many offsets as there are images in the container.

Every image has following header starting at specified offset:

DownloadSource code (Text):
  1. Offset      Len     Description
  2. 0           2       Image width
  3. 2           2       Image height
  4. 4           2       Center X coord
  5. 6           2       Center Y coord

Image is then followed by number of "segment" offsets - each being 4 bytes long.

Each segment follows this structure:

DownloadSource code (Text):
  1. Offset      Len     Description
  2. 0           2       Start pixels
  3. 2           2       N of pixels

After N is read, next N of bytes are how many N pixels should be drawn, and in what colors. For example, if first 3 pixels are empty, but next five aren't, it will be "3 5 6 7 8 9 10", where 6-10 are numbers of colors from image's palette. (Shadow images skip color bytes altogether).

If byte "FF" is reached, transparent pixels should be added until image width is reached. After that pixels counter should be reset and second row of image should be drawn.

It looks like units have "faction color ring" baked in, which makes me sad, but it appears to have constant color, so should be easy to filter off.

Didn't check for sure, but it seems that there are three "type 2" asset files:

DownloadSource code (Text):
  1. Name        Description
  2. ASSET       Complete asset file
  3. I_ASSET     Asset file containing only single image
  4. S_ASSET     Asset shadows images

I am guessing the "I_*" variants were introduced for memory conservation reasons, so if you want to, say, display tank in the building UI, you have single image to load instead of many.

Downloads: 350
Filesize: 1.19 KB
Downloads: 354
Filesize: 501 Byte
Downloads: 297
Filesize: 1.08 KB

This post has been edited 2 times. Last edit on Feb 13, 2019 10:40 pm by riess.