NewWad 1.2
(originally pcx2wad by daniel gilliland);
Modified by Christopher Wise

NewWad is a program to add textures in pcx, bmp or lbm formats
to the WAD2 files that are used by qbsp.

NewWad is my modification to PCX2WAD 0.98 by daniel gilliland.
pcx2wad now performs anti-aliasing on the smaller mipmaps using 
a 2 dimensional sinc function. 

Usage:
The command line syntax is:
newwad <scriptfile> <wadfile>

<scriptfile> is the full name of the script that newwad reads.
<wadfile> is the full name of the wad file to which the textures 
are to be added. If you specify a wad file name that already 
exists the textures will be added to the file. Your script file 
should contain only the new entries if you are adding to the file.

WARNING: MAKE SURE TO BACK UP YOUR WAD FILES AS THIS PROGRAM HAS 
NOT BEEN EXTENSIVELY TESTED AND COMES WITH NO GUARANTEE.

If the program exits with an error during the script reading 
process the original wad file should be untouched. However if 
there is an error during the writing procedure the wad file will
be corrupted, so keep a backup copy of your wad file.

Scriptfiles:
A script file is just a list of the inupt filenames and the 
corresponding texture name that will be included in the wad file.
The texture name can be up to 16 characters long and can include 
the '*' and '+' characters for animated textures. There should be 
one entry per line. Comments are prefixed by // and can appear after 
an entry or on a separate line.
NewWad supports pcx/bmp/lbm formats but only with 256 colour images 
and dimensions that are a multiple of 16.

For example:
----script.txt-----
tech06_2.pcx    TECH06_2
stairs.lbm      STAIRS
// this is a comment
crate0~1.bmp    CRATE
lava1.pcx    *LAVA1  // this is a comment 
-------------------

Running "newwad script.txt wadfile.wad" would do the following:

If a file called wadfile.wad does not exist then a file called 
'wadfile.wad' would be created, and it would contain 4 mip textures: 
TECH06_2, STAIRS, CRATE and *LAVA1. Use these names in .map files to 
specify which texture you want each face to have.  Also files called 
palette.lmp and colormap.lmp would be written to disk. If you are 
using the quake palette you can ignore/delete these files.

If a file called wadfile.wad exists then the 4 mip textures would be 
added to the file. Palette.lmp and colormap.lmp would NOT be created.



Palettes.

The quake palette consists of 256 indexed colours, numbered from 0 to 255. 
Color 255 is used as a transparency colour. Palette entries 240 to 254 
are used as fullbright colours, that is these colours stay the same 
intensity regardless of the surrounding light level in the game. In quake 
they are used in lights, red sigils etcetera. Color 0 is the transparency 
colour for sky textures. Sky textures are a 256x128 bitmap, the left 
128x128 portion is the partially transparent part of the sky (fast-moving, 
lower clouds), and the right 128x128 portion is the higher, slow-moving, 
solid cloud texture. Palette index 0 is used for transparency.

The sub images only use the first 240 colours unless there is a direct match 
to a fullbright colour  or the transparent colour (palette entry 255). 

NewWad now uses the palette from each file that is read. Thus it is 
possible to create a wad2 file with textures based on another palette 
for a total conversion. However, it is still the user's responsibility 
to ensure that the palettes of all the input files are all the same.


Limitations: 
You can't add a picture that is bigger than 512x256. 

The imput image MUST have dimensions that are a multiple of 16 pixels.

The program exits if an error is encountered. A valid wad file is only 
created if no errors are encountered so you must fix the error in the 
script file or source images and rerun the program.

History: 

0.99 I was going to write a complete utility but then I saw this 
program and it's source and thought 'why reinvent the wheel?'. 
Given that daniel gilliland wrote that he did not intend to update 
the program I decided to do it myself. I had already written the 
decimation routine so I just slotted it into the source and recompiled. 

1.0 I have added the ability to update an existing wad file as well as 
create a new wad file. 

Email: Contact me (Christopher Wise) at wise@eng2.eng.monash.edu.au
Feel free to ask questions. I would like feedback if the program doesn't 
work properly. I will try to fix any bugs, time permitting and may add 
new features. I hope this program is of use to level creators.