Mechanized Assault & eXploration Reloaded



#11 Feb 13, 2019 9:20 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


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.

Thumbnails of attached images:
SCOUT_14.png
Filetype: File Type Information for: png png
Downloads: 3701
Filesize: 1.19 KB
Image size: 43 x 24 Pixels
KNIB_310.png
Filetype: File Type Information for: png png
Downloads: 3515
Filesize: 501 Byte
Image size: 23 x 16 Pixels
TANK_7.png
Filetype: File Type Information for: png png
Downloads: 3444
Filesize: 1.08 KB
Image size: 32 x 25 Pixels

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

#12 Feb 13, 2019 10:17 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
So, here's list of asset types appearing in RES and CAF files, with their use:

DownloadSource code (Text):
  1. 0 - (Unknown, maybe metadata for #2 and #3)
  2. 1 - Image with own palette
  3. 2 - Image container
  4. 3 - Image container (mono)
  5. 4 - Text
  6. 5 - Single image
  7. 6 - (Not used)
  8. 7 - Text
  9. 8 - Sound
  10. 9 - Image container same as #2, appears unused in game

I would like to do some cleanup work on my codebase before moving on to types 0 or 8. I would also like to extract game maps from WLD files, but I'm not sure how easy that would be.
↑  ↓

#13 Feb 14, 2019 12:55 am
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,525


Subject: Re: M.A.X 2 Data Extractor
Love the progress ! Respect
A.H.
- easy logic -
↑  ↓

#14 Feb 15, 2019 8:30 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
I've moved on to WLD files yesterday. Those files store game worlds (maps) and after few hours of fiddling around I've worked out the file format.

First part of file is 9-bytes long header:

DownloadSource code (Text):
  1.     Offset  Length  Description
  2.     0       3       Ascii string spelling "WLD"
  3.     3       2       Unknown, seems to equal to "1" in all maps
  4.     5       2       Integer, map's grid width
  5.     7       2       Integer, map's grid height

Width and height order is presumed because it looks like that all WLD maps size is 112 x 112.

Next width x height bytes is minimap. Each byte is id of color from file's palette.

This is followed by width x height x 2 bytes. This is list of numbers (each being 2-bytes long), describing the order in which map data is laid out.

Order is followed by height map, which is (width + 1) x (height + 1) long, with every byte representing next vertice's height.

At the end of height map there is two-bytes number containing number of grid cells. It equals to width x height, and seems to always be 12544 because all maps are 112 x 112.

Next is list of pixels. It's organized into blocks of 32 x 32 length. Order of blocks is specified earlier in the file, and every cell/sector has 1024 bytes. This amounts to 12845056 bytes total for 112 x 112 map.

List of pixels is followed by 768 bytes that contain color palette for the map (used by main image and minimap).

Palette is followed by width * height bytes, each byte representing map's cell/sector type (water, blocked, etc.). This map is split into 4 blocks of even length, each representing other quarter of the world.
This post has been edited 1 times. Last edit on Feb 15, 2019 8:37 pm by riess. ↑  ↓

#15 Feb 16, 2019 12:06 am
beko beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Posts: 2,279


Subject: Re: M.A.X 2 Data Extractor
Map format sounds alot like in MAX.
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."
↑  ↓

#16 Mar 13, 2019 12:30 am
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
No update for some time, but after sudden moment of clarity (and Fallout 2 modding website) I've managed to crack the audio format that type 8 assets are using, producing audible mp3 files from MAX2 sources. Wink

Turns out type 8 assets are metadata + ACM encoded audio. ACM is proprietary audio format created by Interplay ages ago and used by many of their games, Fallouts and Planescape Torment being most famous ones.

So simplest way to convert this file to something useful is to read length of the ACM data stored on first 4 bytes of the file, then trim the file to number of bytes read from fourst 4 bytes, starting from end of the file. This will produce the ACM file that then can be converted to any format you like using the FFMPEG and specifying the "interplayacm" as input. Smiling
↑  ↓

#17 Mar 13, 2019 1:00 am
beko beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Posts: 2,279


Subject: Re: M.A.X 2 Data Extractor
FFMPEG In love
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."
↑  ↓

#18 Mar 13, 2019 1:07 am
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
For own amusement I've tried other media files in game dir. FFMPEG supports also interplay's "MVE" files, so I guess I'll update extractor over coming days to extract ALL media formats from M.A.X 2 Wink
↑  ↓

#19 Mar 13, 2019 2:03 am
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,525


Subject: Re: M.A.X 2 Data Extractor
So cool, nice update! Grinning
A.H.
- easy logic -
↑  ↓

#20 Mar 13, 2019 9:25 am
beko beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Posts: 2,279


Subject: Re: M.A.X 2 Data Extractor
Quote by riess:
For own amusement I've tried other media files in game dir. FFMPEG supports also interplay's "MVE" files, so I guess I'll update extractor over coming days to extract ALL media formats from M.A.X 2 Wink
Yeah.. our MVE player in MAXR is probably based on this. I dunno for sure tho. It's so long ago and wasn't done by me so no idea.
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."
↑  ↓

Pages (2): 1, 2


All times are GMT +01:00. Current time: 12:07 am.