NewWad 1.6

(originally pcx2wad 0.98 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 performs averaging to anit-
alias the smaller sized textures.


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 willbe 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 also 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.


Limitations:
You can't add a picture that is bigger than 1024x512. Since the 
largest textures in registered Quake are 320x192 pixels I think that 
this limit is more than large enough.

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.


Notes on Palettes:
The quake palette consists of 256 indexed colours, numbered from 0 to 
255. Colour 255 is used as a transparency colour. Palette entries 224 
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 224 colours unless there there is a
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.

If you are making a total conversion you should put them in the gfx 
sub-directory of your game directory. (e.g. make a directory under the 
Quake directory called "mygame". Then make a sub-directory called gfx 
in which you put the .lmp files. Your levels should go in the 
quake\mygame\maps directory. Start quake with the command line 
quake -game mygame and the modified palette will be included.  If you 
are going to change the palette you will need to change the palette
mapping of each of the .lmp, .spr and .mdl files. 

To convert the .lmp, .spr and .mdl files I suggest you use swchpal by
Andy Bay. (Look for SWCHPAL.ZIP on ftp.cdrom.com or mirrors)

Put all the lump files (except for colormap.lmp and palette.lmp) in a
directory with swchpal.exe. Copy the original palette.lmp as oldpal.pal 
and the new palette.lmp as newpal.pal.

Make a batch file eg: switch.bat that contains the lines:
-------switch.bat----------------
for %%f in (*.lmp) do swchpal %%f
for %%f in (*.mdl) do swchpal %%f
for %%f in (*.spr) do swchpal %%f
---------------------------------
(note the double % signs are supposed to be used)

All the .lmp files in gfx.wad can be converted at once by the command
swchpal gfx.wad


ConPal:
ConPal is a utility to convert bitmap images from an arbitary palette
to the quake palette. The input file may be any type that NewWad 
supports, namely 256 colour pcx, lbm or bmp files. The output file is 
a pcx file with the same name. If you run it on a file that already 
has the quake palette, any fullbright colours will be removed and 
replaced with normal colours that are the closest fit.

The input file has its palette converted to the quake palette.
The first colour and the last 32 colours in the quake palette
are not used as these are the sky transparency and fullbright
colours. If you want these colours in the texture you should
hand edit the texture after conversion.

Usage: conpal <inputfile>

IF THE INPUT FILE IS A PCX FILE THEN IT WILL BE OVERWRITTEN.

If you want to convert a lot of bitmaps in one go, make a batchfile
like this
-----------convert.bat------------
for %%f in (*.bmp) do conpal %%f
----------------------------------

This will convert all the bmp files in the directory to pcx files 
with the quake palette.


WadView and BspView:
The utilities WadView and BspView are included. You can browse an 
existing wadfile or bsp file and extract the textures to pcx files.
The command line usage is simple:
wadview <wadfile>
or
bspview <bspfile> [/hexen]

<wadfile> and <bspfile> are the full names of the .wad file or .bsp 
file that you want to view.

use /hexen with bspview if you want to view hexen bsp's.
I don't know if it will work with the full version.

WadView will use the pallete lump if there is one in the wad file or 
the Quake palette otherwise. BspView always uses the Quake palette. 
The size of the image is reduced by a factor of two for large textures; 
there is now a size indicator in the top left corner of the screen.


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. I have also added a rudimentry check on an 
existing .wad file to see if it has a directory entry (i.e. is not 
corrupted) before attempting to add textures to it.

1.2 Added palette handling to NewWad and the creation of palette.lmp 
and colourmap.lmp files. Added WadView and BspView utilities to the 
distribution. The ammount of output text has been greatly reduced.

1.3 The method of downsampling was changed to simple averaging.
This is computationally quicker so the program runs much faster and 
still produces good results.  This also removes a problem of visual 
artefacts at the edge of sub-images that occured with the previous 
versions. The maximum image size was increased to 1024x512 pixels. 
WadView and BspView now display the sub-images as well as the main 
image.

1.4 NewWad now treats the last 32 colours as fullbrights rather than 
the last 16. Colour map generation has been removed from NewWad which 
should speed up NewWad's operation.  For those that are using a 
different palette a separate program called GCM is included which can 
generate a colour map from an imput palette. GCM has the option to 
avoid having fullbright colours. If you are using an alternative 
palette and don't want any of the colours to be fullbright you should 
use the option -nfb with gcm.exe.

1.5 The newwad15.zip was uploaded with the 1.4 executable.
A utility has been added to convert bitmaps to the quake palette,
without any fullbright colours.
WadView and BspView will now run under windows 95 without a warning
message.

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 that this program is of use to level 
creators.
