MAP, PIC and PAL formats figured out ! (almost)

So I searched, and took a guess at one of the most basic and famous one: LZW.

I have just registered to get some more information about cived which source code I have been looking into to get better understanding of the Civilization.
Great work darkpanda, really appreciate you work although the code sometimes is difficult to grasp. Hope you can answer some of my question.
In the LZWDecoder's parseByteStreamToIndexes you are reading bytes in little endian mode and extracting only first 9 bits (mask 511dec), but I cannot understand why after first 256 bytes you switch to extracting 10 bits (mask 1023dec). Similar operation, switch to reading 11 bits happens at byte 512.
Is this some kind of non standard LZW or optimization you did?
Please elaborate if you can.
 
Last edited:
I have just registered to get some more information about cived which source code I have been looking into to get better understanding of the Civilization.
Great work darkpanda, really appreciate you work although the code sometimes is difficult to grasp. Hope you can answer some of my question.
In the LZWDecoder's parseByteStreamToIndexes you are reading bytes in little endian mode and extracting only first 9 bits (mask 511dec), but I cannot understand why after first 256 bytes you switch to extracting 10 bits (mask 1023dec). Similar operation, switch to reading 11 bits happens at byte 512.
Is this some kind of non standard LZW or optimization you did?
Please elaborate if you can.

Hi there,

I didn't review my code yet but the rough idea is that Civ's LZW implementation uses a dictionary with 3 types of indices: 9-bit, 10-bit and 11-bit indices.

IIRC one bit is always the same, so actual usable bits are 8, 9 and 10, which make it possible to store, respectively 256, 512 and 1024 index values for each index type.

Hope this helps !
 
I just threw a work-in-progress version online:

http://cived.tigermonkey.org

If you choose a local .map file, it will render the map to a canvas element. The functionality is in there to render the VGA/EGA graphics as well, but in moving on to map rendering, it's no longer exposed in the UI.

The code also leverages the Quintus JS Game Engine to make plotting TileSheets a bit simpler.

Still lots to do re: terrain improvements, plotting cities, units and stuff, but hey, it's a start! :)

Hey Illepokok,

Do you have your work here released separately anywhere and have you licensed it? I'm wondering as I've really like to make an official derivation of it to assist with the (yet another!) civ clone project I've been working on?

I've actually already taken the work you've done and made a small utility to work with the rest of my project, but would be happy to take it down and re-work separately at your request. What I've done is available here:

https://github.com/civ-clone/civ1-asset-extractor

(Sorry to bump an old thread everyone!)
 
Top Bottom