DMExtract v1.0
Written by Paul Gross aka rain`

Introduction
===========================
The map editing community of DM/CSB has been steady for a long time, but I always felt that in order to make a custom "dungeon", you needed to make a few other changes to the gameplay.  Simple things like changing a few graphics, or changing statistics on monsters/items were not able to be done.  So I decided that I would create a tool to edit the graphics.dat files of CSB, DM, and DMII for all platforms.


Whats new in version 1.0?
===========================
-Added support for .MAP files (Map files created by Christophe Fontanel).
-Added full functional support for DM2 graphics.dat files (Unfortunately palette's are not correct at the moment)
-Added autodetection of endianness.  Now if you happen to specify the wrong endian, it will detect it and fix it for you (Note: specifying correct endianness is suggested when creating graphics.dat files)
-Source code available
-Now only 2 BAT files, change them when needed


What is it?
===========================
DMExtract is a dos program that can extract and create graphics.dat files for DM and CSB.  DM2 graphic.dat file is planned for the future. *Note: As of version 1.0, DM2 graphics.dat are fully supported.


How to use
===========================
DMExtract is a simple dos command line program that will extract files from graphics.dat's into a specified directory or create a graphics.dat from a directory's contents.  As of now, DMExtract will extract text, images, and fonts into BMP's, txt files, and BMP's respectively.  The Images are stored in 8bpp BMP files (8bpp was needed because 4 bpp only allows 16 colors, while CSB uses 16 colors and a transparent pixel).  All other files are stored exactly as they would be in the graphics.dat file except they are LZW-decompressed and saved seperately.  This still allows you to edit these files however you wish, but you are responsible for the format.

The 6 basic functions of DMExtract can be done via the .BAT files included in the zip.  In order for the BAT files to work, their must be a folder and/or a graphics.dat file in the directory with the correct names.  For example, to use extract_dmgraphics.bat, you must have a PC-Dungeon Master graphics.dat file in the folder called "dmgraphics.dat", and a folder called "dmgraphics".  This will extract all the information from dmgraphics.dat into the folder.  In order to create a graphics.dat file, you must have a folder with the dmout.dat file (which contains the information for the format of the graphics.dat file).  It will then create a file called newdmgraphics.dat which you can then place where you would like.

Command line options are as follows:

	-x <path>.... expand a graphics.dat
	-c <path>.... construct a graphics.dat file
	-d <path>.... specify output/input directory
	-e <endian> . specify BIG or LITTLE endian
	-i 1/2/3/4... Alter primary IMG encoding
	............... default: IMG1/2
	-m <path>.... use .MAP file when extracting


Using MAP files
===========================
To use a .MAP file included with DMExtract, simply add the following to the command line

-m "MAPS/mapfile.map"

where mapfile is one of the map files in the MAPS directory.  When creating a new graphics.dat file, MAP files are not used.  All file information is stored in the .GIL file when extracted.


Editing
===========================
When working with DMExtract, it is important to remember that the graphics.dat file you extracted will be of the same size (by size, im referring to the number of items) as the one before.  Therefore in this version of DMExtract, you cannot add new items to the file, you can only edit existing ones (Which works for the time being since all DM/CSB applications that read a graphics.dat file will only use the items that were originally in it).  If you wish to make a graphics.dat file with new items, email me and I'll see if I can work something out.

Editing .BMP's
---------------
When editing BMP's, you must abide by the 17 pixel palette specified.  This means that if you for some reason add a new color to the palette (using an alternate shade of red perhaps), it will be not show up in DM/CSB the way it looks in the BMP.  If you wish to make transparent pixels (used in Animations mainly, this is different from the orange, blue, or grey backround that exists in certain monster/item pictures), use the 17th color (light purple).

You must save the BMP in the same format as it was previously, or you may experience altered results.

If editing the font, then the maximum colors will be 2 (black or white), and must stay that way.

Editing .TXT's
---------------
Should be self explanitory, for each line is a text.  If editing the text for CSB/DM, each line of text contains an item's name (which I believe corresponds to the graphics in the dmout040.bmp range).

Editing .DAT's
---------------
You may edit DAT's in any which way you like using a hex editor etc, 
so long as the DAT file exists when reconstructing the graphics.dat 
file


Credits
===========================
Credits go to the following people for samples of code (copied or used as reference):

Christophe Fontanel
	For the file-format document which helped greatly (especially the IMG1/2 format), the LZW decomprression code, and hosting the best DM/CSB website/forums.  Thank you very much!

Paul Stevens:
	Excellent job in porting CSB4win to windows/linux and also for releasing the source which allows for people like me to go ahead and research ways of editing data files for a 15+ year old game.

Brian ???:
	The source code for DMDecode helped me in my initial attempts at extracting graphics from graphic.dat files

