Mechanized Assault & eXploration Reloaded



#1 Feb 09, 2019 4:01 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: M.A.X 2 Data Extractor
Hello everyone!

Few days ago I've started experimenting with reverse engineering MAX2 asset packages, mostly as fun/learning project.

So far I've got following to work:

- isolate assets from file
- decompress and unpack images with color palettes (eg. unit portraits, logos, interface backgrounds)
- isolate TXT files
- isolate UI files no idea how to get color for those (yet!)

The code can be found here:

https://github.com/rafalp/max2-extractor

Currently I am working on correctly isolating assets of type 5, which appear to be small images used around the UI. Eg. here's the lightbulb units sometimes display. It has 10 bytes long header followed by pixel data. First 4 bytes are image dimensions, but meaning of next 6 bytes I can't fathom.

But for now I don't know how to find colors for those pixels. It appears that those assets aren't compressed and are using palette stored elsewhere:

0F001900 07000C00 20000000 00001313 13131313 13000000 00000000 13F1F111 11111111 13000000 000013A9 11111111 11111111 13000000 13A911A0 A0111111 11111111 130013F1 11ACA011 11111111 11111111 13131111 A0111111 11111111 11111113 13111111 11111111 11111111 11111313 11111111 11111111 11111111 11131311 1111112C 112C112C 11111111 13131111 11112C11 11112C11 11111113 13111111 1111112C 11111111 11111300 13111111 112C112C 11111111 13000000 13111111 0A110A11 11111300 00000013 1111110A 110A1111 A9130000 00000013 1111B311 B411A913 00000000 00001311 11F111F1 11F11300 00000000 00001311 F1F5F111 13000000 00000000 001311F1 F5F11113 00000000 00000013 13B1AFB7 C0C01313 00000000 00001313 B7AFC5C7 C7131300 00000000 000013C3 C0B7C0BE 13000000 00000000 0013C5C5 CAC6C313 00000000 00000013 13B7AFC5 C7C71313 00000000 00000013 13D4D2D1 13130000 00000000 00000013 13CD1313 00000000 00

I've got some success by reusing the palette from M.A.X1 GFX tool, but while it produces good results for some images, it completely shredded others.

I've also managed to isolate binary data of what appears to be audio files (file header appears to contain bitrate number) but no idea how to convert those to WAV. Are there any resources available on how binary data for audio looked like in M.A.X 1?

Thumbnails of attached images:
BULB.PNG
Filetype: File Type Information for: png png
Downloads: 5351
Filesize: 434 Byte
Image size: 15 x 25 Pixels
5_BULB.png
Filetype: File Type Information for: png png
Downloads: 5311
Filesize: 450 Byte
Image size: 15 x 25 Pixels
5_BNMUMULT.png
Filetype: File Type Information for: png png
Downloads: 5175
Filesize: 3.38 KB
Image size: 273 x 38 Pixels

This post has been edited 3 times. Last edit on Feb 09, 2019 4:40 pm by riess. ↑  ↓

#2 Feb 11, 2019 1:40 pm
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,525


Subject: Re: M.A.X 2 Data Extractor
Hey riess!
Welcome and thanks for sharing. Looks pretty neat!
Any bigger plans with the assets after you got them all?

Keep us updated =)
Cheers!
A.H.
- easy logic -
↑  ↓

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


Subject: Re: M.A.X 2 Data Extractor
Hey!

No plans for now. I would like to extract the assets firsts Smiling

By some sheer luck I've managed to find one of the colors from game in `MAX2.RES` (I was rendering 3 bytes corresponding to colors I've known + next 12 bytes from the file). Palettes start at offset 36829628 and there is 207 256-color palettes total. Fifth digit is indeed palette ID.

I'll update the extractor tomorrow and if results are good, I'll move on to next asset type.

Thumbnails of attached images:
72.png
Filetype: File Type Information for: png png
Downloads: 5528
Filesize: 2.78 KB
Image size: 512 x 512 Pixels
51.png
Filetype: File Type Information for: png png
Downloads: 5529
Filesize: 3.03 KB
Image size: 512 x 512 Pixels

This post has been edited 1 times. Last edit on Feb 11, 2019 9:54 pm by riess. ↑  ↓

#4 Feb 11, 2019 11:45 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
Bingo, I need to work out transparent pixel color now (because it appears to differ from palette to palette), but most of type 5 assets came out nicely!

Thumbnails of attached images:
PTR_GOLD.PNG
Filetype: File Type Information for: png png
Downloads: 5403
Filesize: 3.75 KB
Image size: 38 x 190 Pixels
BNUDHUMN.PNG
Filetype: File Type Information for: png png
Downloads: 5404
Filesize: 6.51 KB
Image size: 87 x 51 Pixels
SLFDOPN4.PNG
Filetype: File Type Information for: png png
Downloads: 5333
Filesize: 9.44 KB
Image size: 81 x 77 Pixels

↑  ↓

#5 Feb 12, 2019 11:37 am
beko beko Offline
Developer, Administrator
Registered since: Jun 04, 2004
Posts: 2,279


Subject: Re: M.A.X 2 Data Extractor
Respect Looks good. I'm not sure, but didn't Artlav write an res file extractor for MAX2 back then? Memory is foggy, since I don't care much about MAX2 at all Undecided
Bernd Kosmahl
"Sir, we are surrounded!" - "Great - we can attack in any direction."
↑  ↓

#6 Feb 12, 2019 11:07 pm
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
Looking at output images, for 99% of them assumption that color 0 in palette is transparency color works well. There are few images that appear to have no transparency, and some that have non-standard color for transparency. I am guessing that this is decided by game likely using "draw without transparency" and "draw with transparency" functions for drawing.

@beko I've used res file extractor in past (we may be thinking of same tool), but I'm not aware if its source is available or there's proper description for MAX2 file formats, so I've started this little experiment to see how for I'll get to those.

Moving on, I am now working on in-game sprites (asset type 2). I've got human water platform + some extra data I don't yet understand.

Thumbnails of attached images:
WTRPLTFM.png
Filetype: File Type Information for: png png
Downloads: 5750
Filesize: 1.22 KB
Image size: 35 x 32 Pixels

This post has been edited 2 times. Last edit on Feb 13, 2019 12:05 am by riess. ↑  ↓

#7 Feb 13, 2019 1:02 am
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
Ok, it looks like type 2 assets follow this structure:

[unknown][unknown (subtype?)][width][height][center x][center y][first segment offset][second segment offset][...][segment start position][segment len][segment data][255 - segment terminator][segment start position][segment len][segment data][255 - segment terminator]

If asset name is prefixed by "S_" (subtype 6), asset contains shadow data, in which case segment data is non-existing.

If asset name is not prefixed (subtype 7), asset also includes byte containing color palette identificator.

I've cooked naive implementation for this algorithm and got 1:1 image of water platform In love Sadly things went out of order when I've tried to render road, so maybe there's something else or just bug in my implementation.

Thumbnails of attached images:
WTRPLTFM.png
Filetype: File Type Information for: png png
Downloads: 5140
Filesize: 1.38 KB
Image size: 32 x 32 Pixels
ROAD.png
Filetype: File Type Information for: png png
Downloads: 5236
Filesize: 997 Byte
Image size: 32 x 32 Pixels

This post has been edited 4 times. Last edit on Feb 13, 2019 1:59 am by riess. ↑  ↓

#8 Feb 13, 2019 2:11 am
riess riess Offline
Approved Member
Registered since: Feb 09, 2019
Posts: 11


Subject: Re: M.A.X 2 Data Extractor
Quote by riess:
Sadly things went out of order when I've tried to render road, so maybe there's something else or just bug in my implementation.

Nevermind, I've forgot to fill line in image with transparent pixels when line length is incomplete but I'm on line terminator. Its working now Smiling

Thumbnails of attached images:
ROAD.png
Filetype: File Type Information for: png png
Downloads: 5436
Filesize: 974 Byte
Image size: 32 x 32 Pixels

↑  ↓

#9 Feb 13, 2019 11:42 am
Sal Sal Offline
, G-Mod
Registered since: Jun 07, 2004
Posts: 1,525


Subject: Re: M.A.X 2 Data Extractor
Loving the effort you are putting in.
Just seeing that road again makes me want to play again Grinning
A.H.
- easy logic -
↑  ↓

#10 Feb 13, 2019 11:43 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:

@beko I've used res file extractor in past (we may be thinking of same tool), but I'm not aware if its source is available or there's proper description for MAX2 file formats, so I've started this little experiment to see how for I'll get to those.
I took the liberty to set up an git account in our GIT space for you. Feel free to use it and/or browse around. There's also the resinstaller that extracts data from MAX.

You may also mirror your own tool there of course. Up to you Smiling
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:46 am.