**********************************************************************
*                                                                    *
*                            TexDraw v1.2                            *
*                    (c) 2000 CarrotTop Software                     *
*                      carrottop@altavista.net                       *
*                             11/9/2000                              *
*                                                                    *
**********************************************************************

CONTENTS:
  I.  ABOUT TexDraw
 II.  DISCLAIMER AND RIGHTS
III.  HOW TO...
      A.  Installation
      B.  Use
 IV.  GENERAL NOTES
      A.  A Word About Alpha and Attribute Bits
      B.  Development Notes
      C.  What's New?
      D.  Future Enhancement Plans

APPENDIX A.  TEX File Format

**********************************************************************

  I.  ABOUT TexDraw

TexDraw is a utility written for the Ratbag Games title Dirt Track Racing.
It should work with their other titles as well.  If you encounter any
problems with other titles, please let me know!

Ratbag was kind enough to provide a tool (ExtractPF) to allow users to
extract the game files and look at their internals.  Unfortunately,
most of the files are in various proprietary or uncommon forms, so there
was little most editors could do with the game, particularly those
with little or no programming experience or tools.

TexDraw will (hopefully) begin to change that.  Most graphics files for
the game are stored in "TEX" files - for "texture", I presume.  TexDraw
allows you to view these TEX files and also supports exporting to the
Truevision Targa (TGA) format so that the images can be edited by
most popular image editing tools - Paint Shop Pro, Photoshop, etc.  TGA
files can then be imported back into the TEX file to replace the 
existing texture.

**********************************************************************

 II.  DISCLAIMER AND RIGHTS

TexDraw is a work-in-progress.  It is not warranted to meet your needs,
or those of anyone else for that matter.  I just thought it was cool.
Using TexDraw may affect DTR's operation.  That could be a good thing,
if that's what you're trying to do.  ;)  CarrotTop Software cannot be
held responsible for damage to your computer hardware or software that
results from use of TexDraw.  It works on my machine, so I don't expect
anyone to have any REAL problems with it.  But you've been warned.
CarrotTop Software can also not be held responsible for undesired social
implications such as loss of sleep or hair, damage inflicted by social
partners who've been ignored too long while you play with "that darn
computer", or weight loss (or gain...) caused by spending too many meal
times sitting at the computer.

TexDraw has been tested and found to work on Windows 98 and Windows NT
4.0.  It should work on other operating systems as well, but your
mileage may vary.  Windows 2000 in particular seems to have some
issues with some applications built with VC++ 6.0 SP4.

TexDraw may be distributed via any means - e-mail, FTP, camel courier -
as long as this file remains with it.  It will be offered for download
primarily from Sim Racing Connection - URL below - and new versions will
be released there first as well.  If you want to post it on another web
site or put it on a CD, please contact me first.  Not that I'm likely
to say no, I just like to know what's going on.

Sim Racing Connection:  http://simracingconnection.virtualave.net

**********************************************************************

III.  HOW TO...

      A.  Installation

To install, simply copy the TEXDRAW.EXE and README.TXT files to any
location.  Double-click TEXDRAW.EXE to begin.  If desired, you can
create a shortcut to the program and put it in your Start menu.  You
can also register TEX files with the application (use the Associations...
function described below) so that you can double-click a TEX file in
Windows Explorer and it'll open in TexDraw.

      B.  Use

The main window consists of the drawing area and the menu bar.  The
drawing area is pretty straightforward - the image will be drawn here.

The menu bar offers 4 choices, File, Header, Options and Help.

The File menu contains 6 commands, Open..., Save, Save As..., Import...,
Export... and Exit. There is also a list of the 4 most recently opened
TEX files, and you can open one of these by simply selecting it from
the menu.

Open... displays a standard file-open dialog.  The default filter is 
for TEX files, so they are the only files that will appear.  Browse to
the folder that contains the file you want to open, select the one you
want, and click Open.

Once you've imported a TGA file and modified the TEX file, the Save
options are active.  Press Save to save your changes back to the 
current TEX file.  Save As... will save the data to a different TEX file.

Import... displays a standard file-open dialog.  The default filter is
for TGA files, so they are the only files that will appear.  Select
the file you want to import, and click Open.  If there are any problems
with the file (format, etc.), you will receive a message regarding the
problem and be prompted for further action.  The default file name 
will be the same as the TEX file you loaded, but you can change
this easily by selecting a different file to import.

Export... displays a standard file-save dialog.  The default filter is
for TGA files, so they are the only files that will appear.  Browse to
the output folder you want to use, type in a file name or select one
from the folder (you will be prompted whether you want to overwrite it)
and click Save.  The default file name will be the same as the TEX
file you loaded, but you can change this if you wish.

Exit closes the application.

The Header menu contains a single option, Show...  Clicking this option
displays a dialog containing the header info for the TEX file.  There
is currently a 20-byte chunk of stuff that I have no idea regarding 
its purpose.  This data is shown (in hexadecimal) in the "Filler?" box.
The horizontal (X) and vertical (Y) resolutions and the bits per pixel
(BPP) are shown in individual edit boxes.  This data cannot be edited.
Even if you change any of the values, they revert to their defaults as
soon as you close the dialog.  A future version may include the ability
to edit the information, particularly once we begin to understand what
the "unknown" section is for.

The Options menu contains a two options, Background... and Associate...

Background... changes the default background color for the main drawing
window.  I noticed that some images were quite difficult to see with the
default background of white.  I personally prefer the gray tones, but
you're free to select whatever is easiest on your eyes.

Associate... will modify the file associations of TEX files so that you
can double-click on one and it'll open it in TexDraw automatically.  You
can also use this dialog to reset or remove the association.  Note that
once you've associated TEX files with the program, you have to leave
the program where it is or else reset the association, or Windows will
complain that it can't find TexDraw.

The Help menu also contains a single option, About TexDraw...  This
opens a standard "About..." dialog.  Nothing really to see here, unless
you wonder where the name CarrotTop Software came from.

**********************************************************************

 IV.  GENERAL NOTES

      A.  A Word About Alpha and Attribute Bits

32-BPP images include 1 byte per pixel of "Alpha" information.  This
"alpha channel" is typically used to mark areas of the image that are
transparent or semi-transparent.  Since some TEX files are 32 BPP, they
support this info, so when you export a TEX file of this type, the TGA
file is 32 BPP also.  Check your paint program's documentation on 
working with the alpha channel.  One note:  As of PSP 5, they had this
completely bass-ackwards from Photoshop.  So in PSP you had to select
the portion that you wanted to be transparent AND THEN INVERT SELECTION
before going to "Save to Alpha Channel..."  If you're editing one of
these with PSP, just something you should be aware of.  I don't know if
it's changed in PSP 6 or not.

16-BPP images include 1 "attribute" bit for each pixel.  I don't know
what this is for, or if the image editor just ignores it completely.
Some pixels in the TEX file have their attribute bit set, so I've
preserved the information when exporting the TGA file.  When
importing, any attribute bits that were set in the TGA file will
also be preserved in the TEX.

      B.  Development Notes

* TexDraw was created with Microsoft Visual C++ 5.0 and MFC 4.2
* Release executables built with Visual C++ 6.0 SP4
* Total development time so far - about 15 hours

      C.  What's New?

* Added save of window style - minimized, maximized, etc.
* Added ability to associate with TEX files
* Fixed some minor bugs you probably never noticed  =D

      D.  Future Enhancement Plans

* Barring some breakthrough or major bug, development on TexDraw will
  be frozen at version 1.2

**********************************************************************

APPENDIX A.  TEX File Format

It would be nice to know what these other (unknown) values represent.
I've provided some observations below.

Header:  32 bytes
Byte Ordering:  Intel  (for a value 0x0FA0, bytes stored as A00F)

Offset  Length  Purpose
------  ------  -------
  0       1     Unknown.  Always 0x02 in every file I've looked at.
  1       1     Unknown.  For 16-BPP images it's almost always 0x00.  
                For 32-BPP images, it's almost always NOT 0x00.
                Seems to have SOMETHING to do with number of "sections"
                in image.
  2       4     Unknown.  Occasionally see a 0x0100 value in here.
  6       1     Unknown.  Almost always 0x80
  7       1     Unknown.  Almost always 0x41
  8       4     Some kind of size/distance parameter?
                Seems to always be 0x00 for 32x32 images, 0x01 for
                64x64 images, 0x02 for 128x128 images, and 0x03 for
                256x256 images.
 12       4     Unknown.  Always 0x00 in every file I've looked at.
 16       4     Unknown.  Always 0x01 in every file I've looked at.
 20       4     Horizontal (X) resolution
 24       4     Vertical (Y) resolution
 28       4     Bits Per Pixel (BPP)

Note:  Resolutions are always square.  Furthermore, they always fall
into one of 32x32, 64x64, 128x128 or 256x256.  The upper left corner
is the origin.

The remainder of the file is the image data.  Starting at the origin
(upper left corner), the pixels for the first (top) row are in order
from left to right, followed by the second row, etc.

For 32-BPP images, the bytes are ordered BGRA (blue, green, red, 
alpha) or, if you read it into an unsigned long, B would be in
the lowest byte and A would be in the highest order byte.  (byte 
ordering again...)

I haven't seen any 24-BPP TEX images yet.  I suspect that the engine
uses 16 most of the time and only uses 32 for images that require
the alpha channel.  However, TexDraw supports 24-BPP images since it
only took about 30 seconds to implement them once 32-BPP images
were done.

For 16-BPP images, there are 5 bits each for red, green and blue,
and 1 remaining bit for the "attribute".  If you read the value
into an unsigned short, the bits would look like:  rrrrrgggggabbbbb.
Note that the attribute bit is stored between the blue and green
values.  (Don't forget that, in practice, because of the stored
byte order, in a hex editor you'd see it as ggabbbbb rrrrrggg.)
