darkpanda
Dark Prince
- Joined
- Oct 28, 2007
- Messages
- 843
CIVED has been refurbished and is now released as bundle in the JCivED toolbox: see this thread.
The original thread was kind of development log, and started as follows:
---------------------------------------
Hi there,
For my first post here, a little story:
I've been wanting to hack into Civ savefiles (SVE and MAP) for so many years, I finally took it upon me to progress on it...
I have been hacking SVE for a long time, and only parts of it remain mysterious (e.g. REPLAY data). The real challenge was to hack MAP files.
Through this journey, I read a couple of weeks ago this thread that indicated that a small fan soft for Microprose Darklands (PicViewer, see here) could actually open .MAP files as pictures.
I was intrigued, and read the doc accompanying PicViewer, that provided some insight into the Microprose PIC file formats, including Civ's MAP.
As the C source of PicViewer is available, I decided to (try to) port it to Java, but didn't succeed... The main issue was that neither PicViewer's author (his C code is partly reversed-engineered from CIV.EXE assembly) nor anyone I found so far could figure out exactly the details of the dictionary-based compression algorithm used on top of RLE for pictures.
So I searched, and took a guess at one of the most basic and famous one: LZW.
After a lot of research for various open source implementations of LZW (copyright-free since a couple years ago), trial and error, I could finally code a full, exact, parser of Civ's MAP files in Java!
Turns out, with a little more coding to parse color palette data, I can also extract all Civ's PIC files! At least in VGA, I am still working on EGA 16-colors palette format...
Saving back to MAP seems to work (Civ can load the savegame) but so far I failed to achieve identical byte-to-byte LZW compression when compressing back... Somehow I can't handle the LZW dictionary reset like Civ does when it gets full.
I didn't try for PIC files yet, just been working today.
Just for the sake, I am attaching a screenshot of my CIV folder, full of extracted GIFs!
TTYL