Loading Palette and Haze Files

The palette and haze table are initially loaded by init_palette in Vgbcol.asm. The init_palette routine loads the low 116 colors then calls g2d_load_haze_table_id. For non-haze drivers, this is simply a 'ret'.For haze drivers, Vgbpoly3.asm, VGB_LOAD_HAZE_TABLE_FAR (g2d_load_haze_table_id).

Whenever a palette (.pal) file is loaded, a haze file of the same name (but with a .haz extension) is loaded (if it exists). The haze_table_available flag is set if the haze table is available, and cleared if not. The following table describes the chain of events involved when the .pal and .haz files are loaded.

Note: In the following table “NA” indicates that the file isn't available on your hard disk.


.pal file name

.haz file name

Method invoked

.pal file loaded

.haz file loaded
haze_table_available flag

Description
NA NA Stale counter timeout triggers fs98.pal palette load fs98.pal fs98.haz 1 Scenery that uses only the lower 116 colors doesn't need a .pal file. In this case, the fs98.pal file is used to define the upper 64 colors and the fs98.haz file is used to enhance hazing by using the upper 64 colors to haze the lower 116.
This condition is detected by a stale counter timing out when no .pal files have been loaded.
NA Exists NA fs98.pal fs98.haz 1 Error Condition—This .haz file won't be used and should be eliminated.
Exists NA BGL Palette command fname.pal fs98.haze 0 Scenery that loads a .pal file is assumed to be using the file. Because no .haz table is available, it's impossible for the hazing system to haze the top 64-colors correctly. As a result, the hazing system is turned off.
Exists Exists BGL PALETTE command fname.pal fname.haz 1

If the database doesn't invoke a palette command within a short period of time, fs98.pal is loaded. The PALETTE_STALE_COUNT command found in the file Bglobj.asm is a ring counter that is counted down in the frame rate chain. The BGL_PALETTE command handler in the file Bgllight.asm resets the stale counter every time a PALETTE command is executed.