Please extract to a temporary folder first!

AN ADVANCED SKINNING TUTORIAL
-----------------------------------------
Ferbuary 25th, 2003

Hi all,

I created this small utillity so skinners can easily determine where colours within EAW are taken from and as a primary guideline for modifying the entire EAW pallette. The files and these folders have the following use:
PALLYCHART.JPG         - showing a diagram with a SPIT 1A pallette and an explanation of the colours shown on screen
PALLYNOTES               - contains this text

EXAMPLES folder         -  this folder contains 8 example screenshots with explanations of the colour interpretation taken from Col.Gibbon's HR Spit 1A

PALLYFILES folder containing:
DAY_FADE.PAL           - modified to hold only 5 basic colours (purple, red, green, yellow and blue) 
PALLY.TPC                  - modified to hold a PCX with 4 times a pallette on it, to be renamed to the TPC files to be tested  
P101VIEW.CPT            - modified to hold only white in the extended colour section and to be renamed for the slot to be tested

The next list show all possible slots for EAW planes and the names that can be used to rename the P101VIEW.CPT (spitfire 1) to the slot you want to test.
---------------
SLOTS LIST as taken from Charles Gunst's notes
---------------
P001VIEW.CPT P38H
P011VIEW.CPT P38J
P021VIEW.CPT P47C
P031VIEW.CPT P47D
P041VIEW.CPT P51B
P051VIEW.CPT P51D
*P061VIEW.CPT B17F 
*P071VIEW.CPT B24D
*P081VIEW.CPT B26B
P091VIEW.CPT Hurricane
P101VIEW.CPT Spitfire I
P111VIEW.CPT Spitfire IX
P121VIEW.CPT Spitfire 14
P131VIEW.CPT Typhoon
P141VIEW.CPT Tempest
*P151VIEW.CPT Mosquito
P161VIEW.CPT Bf-109E
P171VIEW.CPT Bf-109G
P181VIEW.CPT Bf-109K
P191VIEW.CPT Bf-110C
P201VIEW.CPT Bf-110G
*P211VIEW.CPT Me-410
P221VIEW.CPT Fw-190A
P231VIEW.CPT Fw-190D
P241VIEW.CPT Me-262
*P251VIEW.CPT Ju-88A
*P261VIEW.CPT Ju-88C 
*P271VIEW.CPT Ju-87
*P281VIEW.CPT He-111
*P291VIEW.CPT V-1

*=not flyable 

How to use:

1st. make a backup of the files you are going to test since the next steps will overwrite any files with the same names
2nd.  copy the DAY_FADE.PAL into your EAW folder.
3rd. determine which slot (plane) you want to test and rename P101VIEW.CPT to the name found in the slots list and also copy it into your EAW folder
4th. copy and rename the PALLY.TPC to the TPC filenames you want to test as many times as needed (can be any TPC filename) and copy those into your EAW folder too
5th. Run the game, take a screenshot and compare the colours displayed with the colours in the PALLY diagram
6th. don't forget to restore your EAW or OAW folder

The colours in the screenshot will show: 

A. where your videocard is retrieving it's information from (TPC, DAY_FADE.PAL or P***VIEW.CPT) and on which part it is applied
B. which TPC files are using which parts of the pallettes and in which file they're stored or if modifications were made
C. influence of future modifications to the pallette files including altered code 6 3DZ's for GLIDE
D. Which parts of PCX pallettes can be modified to hold ANY colour you want
E. Which files need to be altered to change other parts of the palettes used (DAY_FADE.PAL or P***VIEW.CPT)
F. Which colours are hardcoded and can NEVER be altered and their use

Explanation of the PALLY daigram

The diagram first shows the PCX pallette of a Spitfire 1a. Any parts in the screenshot showing these colours can be freely edited after having determined which parts of it are shown. 
On the right the colours are shown which occupy the DAY_FADE.PAL. These colours also refer to above mentioned picture on the left on which can be seen which part of the pallette is activated in the DAY_FADE.PAL.
Purple   - row 1 colours 2 to C                  (which come from the EAW.INI) and cannot be altered unless the INI is altered
Red       - row 1 DEFG and rows 2 to 5       (generally used by cockpits and instruments)
Green    - row 6 to A                                (first part of the standard pallette used by skinners most often)
Yellow     - row B and C                             (part of of the standard pallette not widely used by skinners)
Blue       - row D to G                               (seccond part of the standard pallette most widely used by skinners)

The last colour white is the colour which occupies the entire extended 1 pallette in the P***VIEW.CPT.

These are the colours which will show up on your screenshot and will make identifying easy (I hope)

The bottom diagram shows general information found by extensive testing with guidelines (remarks) on how to make these colours available for skinners.
A. refers to the extended 1 pallette (colours wich change corresponding to the slot in use or depending on the drivers in use)   
B. refers to the standard pallette (colours which can allways be used in skins and are driver independent)

The table further shows a  red cross where in general the colours are stored for the two most widely used video drivers (D3D and Glide) but need not be the same for other drivers. PALLY will give you the details of your videocard drivers.

The DAY_FADE.Pal can also be used as standalone, in which case the files which use the TPC or the P***VIEW.CPT pallette will not be altered. This is usefull for testing if a file allready uses the extended pallette from this file. Without the PALLY.TPC it will however not show if an extended 1pallette can be used, unless a testfile allready uses the extended 1 pallette from this file.  
The same goes for the P***VIEW.CPT in which case only the files using the extended 2D cockpit pallette will be shown in white.
The PALLY.TPC is needed to show if an extended 1 pallette can be applied to the tested file's PCX's. For this the extended colours of the Spit's pallette (as shown in the diagram) must show up in the screenshot taken.   

Hex editing notes

The pallette within EAW consists of 256 colours and each colour  contains 3 RGB values, thus a complete pallette contains 3 * 256 = 768 bytes.
In a PCX file these bites are located at the end of the file (last 768 bytes) and are allways preceded with the Hex byte 0C. The PCX starts with a header which contains info about the size of the picture and what format is used. (8 or 16 bit)
In a TPC file the bytes are placed in front of the picture data and start from byte 9 in the file prededed by an 8 byte header which allways contains 00 05 31 00 0100 01 after which the pallette info is stored (768 bytes). The bytes 00 01 00 01 as a 16 bit integer hex.nr. mean 256 - 256 in decimals and are the size of most PCX files in pixels.
The  .CPT file contains a header of 4 bytes after which the palette info is stored (204 bytes of the extended 1 pallette).
The .PAL file contains a header of 8 bytes which contains 00 05 73 00 00 00 00 00 after which the pallette info is stored (768 bytes).

The PCX pallette

This is the only pallette which can be freely modified without having any effect on the rest of the EAW world. This pallette is ONLY used by the file for which it was created. PALLY will show if the PCX pallette is in use and which part of it (Standard and/or Extended). After determining which part is used, modifications can be made which are skin specific. As with the P***VIEW.CPT the PCX's can have a seperate extended 1 pallette for each plane (mostly for D3D). However due to the different video drivers these changes will only show up when the driver uses the PCX pallette for the same purpose. Cards which take pallette info from a different source will not show the changes to the PCX pallette unless these files are supplied with the same pallette. This means for compattabillity that it is only wise to make these changes when you are sure that the other drivers also get their pallette info for this file from the same source (PCX/TPC). The PALLY chart can provide you with this information. 

The P***VIEW.CPT extended 1 pallette

This file contains the info of the 2D cockpit views as well as the instruments and gauges (3DZ and maybe some other info). The 2D cockpit TPC files within the .CPT are allways beginning with the TPC header of 8 bytes 00 05 71 00 80 02 E0 01 and can be safed as a ***.TPC and converted by searching for the next header and safing the block found (PICPAC will automattically discard any unneeded information and create a normal PCX). Sofar editing of the files cannot be done since replacing them into the CPT file is still uncharted territory. 
The TPC files in the P101VIEW.CPT start at hex adresses:
002C0 upper left front
067A9 left front
15CED upper left (no drawing)
1B088 left wing
2AF6A left back
3AC05 right back
479DF upper right (no drawing)
4C5AA right wing
5866A upper right front
5E523 right front
6D4DD front up
7774C instruments
By changing the pallette info in this file the 2D cockpit will become useless unless a way is found to force it to use the standard pallette. Changing it has also a profound effect on the EAW world when the extended pallette is used on other objects or aircraft in GLIDE mode. This is because Glide is using this pallette more often. When using this extended pallette for skins the different drivers take the extended pallette from different sources and use it for different purposes which may lead to incompattabilities unless the same changes are made to the extended pallette of the DAY_FADE.PAL.
One single CPT file can be used for all planes (copy/paste) thus limiting the amount of extra colours and giving each plane the same extended pallette or each plane can have different colours in it's P***VIEW.CPT. Since the file is needed for both D3D and GLIDE this file MUST be added to the ZIP's and will make them rather large, unless a way is found to remove most info in it (which will become useless anyway and is not needed for Virtual Cockpit users).

The DAY_FADE.PAL

This file holds, in its Standard pallette, most of the colours for most objects in the EAW world and are also used by most drivers. They are lets say the basis on which the EAW world is built and can be found in nearly every TPC file. The colours in it guarantee the 100% compattabillity amongst video drivers as long as only these colours are used to create skins. This file however can also house an extended 1 pallette but the default file has left this spot open (not used). Adding an extended pallette to this file will have NO impact on the EAW world unless the colours are used in skins. Here too different drivers will use these extended  colours for different purposes. It has been observed for instance that Glide will use the P***VIEW.CPT  and D3D will use the DAY_FADE.PAL  for it's extended palette info (unless a TPC is be used), thus adding to the general confusion. Minor modifications could be made to the standard pallette of the DAY_FADE.PAL  to create slightly different sceneries for the EAW world. How far one can go depends totally on checking the results and testing of all skins within the EAW world and on the knowledge and skill of the programmer. 


Quick PCX pallette change (changing colours from a skin while retaining the original picture)

By attaching a different pallette to a PCX file and by converting back to a pallette used by EAW (using the nearest colour option) skins can quickly be altered to suit different theatres. The whole process takes about a minute (using Hex editing cut and paste) and when care is taken in the creation of the quick pallette the results can be quite effective and only minor changes need to be made to the converted PCX. Knowledge on this subject can only be gathered by trial and error. By erasing entire rows in the pallette and converting  to the nearest colour a PCX can be forced to use entirely different rows of colours which may be usefull to eliminate unwanted effects (purple or black colours) or force the PCX to use a different part of the pallette (usefull for forcing the PCX to use the DAY_FADE.PAL , P***VIEW.CPT or PCX pallettes).

Curing conversion errors (or the purple bug fix)

Converting from Paintshop or Photoshop or other editors to a PCX (using nearest colour option) can cause unwanted colours. The reasons for this are that a PCX can hold the same colour several times in different locations and conversion usually takes the first one available. By changing this colour to a colour not used in your drawing you can force the conversion to use the colour you need. This also works for colour zero (transparent) which MUST be set to a colour not used in your picture unless you WANT this colour to be transparent or if you want it to use the colour stored in one of the afore mentioned files. These changes to the pallette will NOT affect the display of the object. When having black (or another colour) in a skin which shows up as transparent in game this method can also be used or one could superimpose the whole picture onto a picture filled with a slightly different after which conversion to a PCX (using the nearest colour option) may force the PCX to use a more appropriate colour. A lot of errors are caused by the HUD colours in row one and which depend on the settings in the EAW.INI file. These colours can best not be used since they will introduce differrent colours as specified by the .INI .
  
Advanced skinning with the new knowledge,

To use the extended pallettes, the instrument panel (P****X.TPC) and the 3d cockpit (P****V.TPC) which both use the (2D) P***VIEW.CPT extended 1 pallette (this file is needed in both D3D and GLIDE) must be forced to use the standard pallette in order to free up these colours for editing and use in skins. Changing this file's palette info will render the 2D cockpits useless since it's colours are solely taken from  it. When it becomes possible in the near future to change the respective 2D views and replace them in the P***VIEW.CPT the TPC's could be forced to use the standard pallette without loosing to much information. If this is at all possible remains a mystery sofar. 
Since the colour info for planes come from 3 different files (which need not neccessarily have to contain the same colours) this also implies that more colours can be used then the initial 256. By using PALLY and determining where the colours are taken from you can create skins that for instance use the full PCX pallette for the P***TEX whereas a file that uses the DAY_FADE.PAL or P***VIEW.CPT extended 1 pallette can use entirely different colours. Care also should be taken when trying to modify the DAY_FADE.PAL's standard pallette. These colours are the basic colours of the EAW world and changing them will have an effect on all objects which use the modified colours. They can be used to create campaign or season specific colours but probably every 3D object within EAW needs to be reskinned to make the best use of the changes. However minor changes can be easily made without to much influence on used addons and could be used for dramatic effects, for instance by darkening all greentones which will give all trees a darker colour (but will also change skins which use these colours).
Since D3D and GLIDE use extended pallette information from different sources and use them for different purposes one must realise that when DAY_FADE.PAL and P***VIEW.CPT files are added to skins or campaigns, all used addons will dramatically change when they also take their pallette information from these files! The only way to make it all work is to create entire packs (CAMPAIGNS) which have 
A. a complete set of aircraft skins
B. a complete set of groundobject skins
C. the neccessary DAY_FADE.PAL and ALL P***VIEW.CPT's
and which will force the game to use these instead of any loaded addon. The use of OAW will be a great help in this respect.


Conclusions

Using the extensive knowledge described here will not be easy, but I have proven it is possible to add about 96 colours to the EAW world in general without loosing compattabillity. When making good use of PALLY and  these notes, insight in the workings of the pallettes can be gained. It is pretty difficult to understand but not impossible to learn. When the proper rules are applied the EAW world could probably have about 3000 extra colours in it, per campaign! Selective editing is possible and one could for instance use 1 single line for nose art in a specific PCX whilst at the same time using this line from the .CPT or DAY_FADE.PAL, containing different colours for other parts of the planes.  Choices should be made as to wether seperate files for differrent drivers are created or just 1 single file for all. Since both drivertypes need the same files for a "complete" pallette, the 2nd option  seems to be the best solution and will guarantee compattabillity for both. The consequences of other files replacing one of the above mentioned files either through OAW or by manual editing should also be contemplated. 
To new skinners I would recommend to get the proper info from others first before even attempting to use this knowledge, this is only for the advanced. In due time you may want to try out these theories and I hope you will create an even more colourfull EAW world for the community. I may have forgotten to mention certain topics or difficulties but will gladly answer any questions on this subject through either E-mail or on SimmHQ's Bulletin Board. If any worth mentioning comes to mind, I will update this document. It's implications are rather far reaching and I have no idea what will come of this.
 I would like to end with a quotation from the greatest statesman who ever lived. "This is not the end. It is not even the beginning of the end. But it is ,perhaps, the end of the beginning" (Winston Churchill, after the Battle of Brittain)

VonBeerhofen
E-mail:
se023166@12move.nl

SimmHQ:
http://www.simhq.com/cgi-bin/ultimatebb.cgi?ubb=forum;f=41

Thanks to:
Mr.Johnson
Pobs (IIJG2_Lemmke)
Col.Gibbon