During adventuring there are always two
palettes active. Because the Atari had only 16 colors there were
not enough colors to simultaneously display the portraits at the top of
the screen and the viewport. Especially this was true because the
viewport had to be able to be dimmed in low light levels while the
portraits had to remain at full intensity. So, while the screen
was being painted by the CRT electron gun, the lines were being
counted. When the viewport was about to be displayed, the palette
was quickly changed. Then, when the viewport was complete, the
palette was switched back again to display the text. So sixty
times per second (fifty in Europe) the palette was changed twice.
The 'viewport' palette has two colors that are variable, depending on
what monsters are present. They are colors number 9 and 10
(starting with zero). When the party enters a new level the list
of possible monsters is examined and colors 9 and 10 are modified
accordingly.
In the 'graphics.dat' file there is a graphic that CSBwin calls
'graphic #22e'. Among other things, it contains an array of
12-byte structures. The array contains 27 such structures (one
for each monster type, I suppose). Currently, this structure is
referred to as 'ITEM12' because at the time of its discovery the only
thing I knew about it was that it was 12 bytes long. Byte 11 of
the structure is used to set colors 9 and 10. If the upper 4-bit
nibble of byte 11 is non-zero then it is used to set color 9. If
the lower 4-bit nibble of byte 11 is non-zero then it is used to set
color 10.
There is also a capability of changing the
palette
used in the Viewport.