HACKING!
Changing The Civilization2 In-Game Graphics
by Mercator
Contents
Foreword
Some time ago I read on Dorian Credé's first Civilization III homepage how to change the kings' portraits. The description was far from complete and only talked about one file. I started experimenting, and managed to get through...
Just recently Rune Berge made a wonderful free application to easily replace the GIF images in the DLL files. That is still in its developing stage, though, and a bit buggy. Although he more or less made this page obsolete, it is still wise to read/download the information I offer here. The reason for that is that his program has the same restrictions as replacing them by hand.
Finally I have achieved to have a look at the portraits and more... In fact, there are eight files (apart from the regular GIF - files) that contain graphics:
- Civ2art.dll
- Cv.dll
- Intro.dll
- Mk.dll
- Pv.dll
- Ss.dll
- Tiles.dll
- Wonder.dll
Since there are so many images, I compiled a list of all graphics.
Introduction
There are two important things you need, to edit the images:
- A hex editor. I recommend AXE 2.1, a free hex editor. After some time away, AXE seems to have resurfaced on the Internet with a new and improved version 3.0. It's no longer free, though.
- An image editor. It just depends on what you prefer, but I use Paint Shop Pro.
There are two restrictions to editing the images:
- All images must retain the same size (width x height), you can't mess with the size of images.
- All images have a preset palette, you can't change that.
ONE EXTRA NOTE: make a backup of the file you are going to mess with!!
So, now you have all the equipment, "Let's go bonk some heads!!".
Isolating An Image
- The first step in replacing or adjusting an image is of course to determine which one you want to change. Since you downloaded my info HTML file, you know which image is in which file.
Open the right *.dll - file with AXE (or whatever editor you're using) and search for the (ANSI-) String GIF87a. You can simply do this by first searching for the first string by clicking on a button similar to this one:
, after which the search menu will appear:
After this, use the 'search down' button:
to search further to the 2nd string, 3rd string etc. So when you want to edit the 20th image in a file, you have to search for the 20th GIF87a string.
Well, you have reached the beginning of the image you want, but now what?
Make sure you remember the offset-number (see image below: the left-most column, in this case 00002400) of the line with the GIF87a string you want...
Got it? Search for the GIF87a string one more time, so you end up at the beginning of the next image. Put the cursor left of GIF87a and scroll back up to the previous GIF87a (remember the offset-number?).
- Now hold down Shift and click, with the left-mouse button, left of the GIF87a-string. You now (should) have a selection starting with the HEX-code: 47 49 46 38 37 61 (see image above) and ending with the HEX code: 3B 00 00 ...(several lines of zeros, different with every image)... 00 00, the next image starts right after that.
- A special case is the last image in a dll file, since you can't search for another GIF87a-string. After the last image (ending with 3B 00 00 00 ..., just like the other images) you will find the HEX-code: 4E 42 30 32 FF FF ... (lots of weird code after this). So with the last image the selection should stop right before this.
- You just selected one image. Copy this to your clipboard, and paste it again into a new file in AXE
- Remove the last character (00 in HEX), since that one was created automatically with the new file, and doesn't belong to the GIF image.
- Last but not least: save the image, for instance as image.gif (don't forget the extension!)
Editing An Image
Open the image you just isolated with your favorite image-editor and use your inspiration. Most of this part is up to your own imagination. The only things you have to remember are:
- Don't change the pallette,
- Don't change the width and/or height of the image,
- Make sure the total size (in bytes) of the image doesn't exceed its original size.
- Save your image when you're done, preferably with a new name (e.g. image_new.gif). The easiest way to check if the size doesn't exceed the original size, is just to compare the sizes (in bytes!!) of the original and edited images.
Replacing An Image
So, you managed to edit an image? Aren't you nervous that you made just a tiny mistake and have to start all over? You'll know very soon!
It's hardly possible to make sure that both the original and edited image is the same size, so I'll just explain how to replace the original part with the (smaller) edited part:
- Open both the original and the edited images with AXE
- Make sure that you view both files with the same width of the bytes:-column (see image above).
- Add 'zeros' (00 in the 'bytes:'-column) at the end of the edited file until both files have exactly the same size. Checking this is easiest by comparing the offset number of the last lines of both files as well as the number of 00's in the last line. Those should be the same, obviously.
- Select the entire file of the edited image, just as mentioned in the 'isolating' - part.
- Copy the file to the clipboard.
- Open the *.dll file you originally got the image from.
- Select the image in the *.dll file (you do still know which file you edited don't you?) as mentioned before in the 'Isolating an image' section.
- Paste the previously copied file into the selection,
- save the *.dll file (you did make a backup didn't you?).
Start CIVILIZATION2 and check it out!!
Last updated: 18 July 2007