Show whole topic Sep 29, 2008 8:07 am
Artlav Offline
Approved Member
Registered since: Jul 16, 2008
Location: Moscow


Subject: Re: max file formats
Quote by shaktazuki:
I did find .FON file info - here: http://www.teamx.ru/rus/bd/fon_format.shtml , but it is in russian and therefore not very understandable to me - I would love an english translation of that and the RES file format, if you would.
Right, the program there seems to work nicely, althrough the result is less than i expected - just a bitmap font?

Here are the details in english:
DownloadSource code (Text):
  1. Offset  Size    Type                    Meaning
  2. Header:
  3. 0x0000  4       int                     Number of glyphs in file. Designated as num below
  4. Caution: Some glyphs may be absent.
  5.  
  6. 0x0004  4       int                     Font height in pixels
  7. 0x0008  4       int                     Distance between two neighbored glyphs in pixels.
  8.  
  9. 0x000C  4       FontInfo*               Pointer to symbol descriptions array
  10. 0x0010  4       unsigned char*  Pointer to symbol images array
  11. Caution: These two fields are not defined in actual file and are filled in memory.
  12.  
  13. Symbol description array:
  14. 0x0014  4       int                     Width of glyph 0
  15. 0x0018  4       int                     Position of glyph 0
  16. 0x001!  4       int                     Width of glyph 1
  17. 0x0020  4       int                     Position of glyph 1
  18. ...     ...     ...     ...
  19. 0x0014 + 8 * num        1       unsigned char           Glyph image data
I hope the code fills the rest.

max.res file basis and image formats:
DownloadSource code (Text):
  1. max.res
  2. Header:
  3. Offset  Length  Description
  4. 0               4               `RES0` - File ID
  5. 4               4               Directory offset
  6. 8               4               Directory length
  7.  
  8. Directory consists of a sequence of file elements:
  9. Offset  Length  Description
  10. 0               8               ASCII File name trimmed by 0's
  11. 8               4               File start offset
  12. 12              4               File size
  13.  
  14. --------------------------
  15.  
  16. Simple palette graphics file
  17. (max.res:\a_*; max.res:\p_*; max.res:\e_*; max.res:\endgame*; etc)
  18.  
  19. Header:
  20. Offset  Length  Description
  21. 0               4               Undefined, commonly 0
  22. 4               2               Image width in pixels
  23. 6               2               Image height in pixels
  24. 8               768             Image pallette
  25. Followed by compressed data in form:
  26. SWORD - byte count
  27. If negative, repeat next byte WORD times
  28. If positive, copy next WORD of bytes
...More to come later...

Quote by shaktazuki:
I also am interested in whatever you know about the savegame file format. I was hex editing a DTA file today and noticed that it had at least two separate map save states - I could tell because the data section lengths were 112*112, and 2*112*112 - I assume one is for resources, and the other for units, but I don't know.
Quote by Sal:
looks better in the doc file ...
http://www.zshare.net/download/19605201885d7382/
It's an order of magnitude more complex than that.

The basic scheme is map header, followed by two maps - passage map and resource map.
Then, four records about four respective players.
That ends the static part of the file, starting a dynamic part.

In the dynamic part there are objects, identified by a word-sized object id, the format is somewhat cryptic in terms of generation, but quite straight-forward in reading.

At the start of dynamic part is a set of unit parameters descriptions for 4 players, one by one, averagely 32 bytes per unit - 2 for object id, 30 for info. If id is 0 or a repeat, then the record (30 bytes part) is empty.

After descriptions there goes unit positions and dynamics table, in similar format of object id followed by info. There are also size-looking bytes in the middle of the stream whose origin i don't understand yet, but they are detectable. The units dynamics are in no way fixed format, and still have blind spots.

After unit dynamics there goes some rather cryptic piece, having something to do with units, or maybe storage, then goes the scan maps and event log&statistics, latter undecoded completely.

I can give you the approximate schemes for the static part - the header and maps are 100% clear, the player infos have blind spots in less important parts, but dynamic part algorithms are better to be left for until they will be more certain.
Artyom Litvinovich