4. Mode 8 - screen memory usage

In mode 8 we have 8 different colours. To represent the values 0 to 7 we need at least 3 bits. As there is flashing allowed in mode 8, we need a bit for flash on or flash off as well. 4 bits per pixel is what we need and that is what we use.

In this mode, the green byte and the red byte are at the same addresses as in mode 4 with the green being even and the red being odd, but the layout is different. The green byte shares with the flash bit where the green bit is the odd numbered bit (7, 5, 3, 1) and the flash bits are in the even bits (6, 4, 2, 0). A similar arrangement goes on in the red byte with the red bits being even and the blue being odd. So the layout looks like this :

Table 8.3. Mode 8 Screen Memory Word Format

Green byte bits (even address)Red byte bits (odd address = green address + 1)
G3 F3 G2 F2 G1 F1 G0 F0R3 B3 R2 B2 R1 B1 R0 B0

Again the values for the colours represnt the mixing of the reds, greens and blues - much like colours in nature are just mixes of red, blue and yellow. (Light and inks mix differently and so have different primary colours. In photography, we use yellow, cyan and magenta!)

The colours are as follows :

Table 8.4. Mode 8 Colour Codes

ColourGRB (Binary)Value (Decimal)
Black0000
Blue0011
Red0102
Magenta0113
Green1004
Cyan1015
Yellow1106
White1117

So the following bit pattern in mode 8 :

Green byte = 0x 0x 1x 1xRed byte = 10 01 11 10

Ignoring the flash bits (shown as 'x' above)and combining the appropriate GRB bits from each byte we get the following table :

Bits (in each byte)Value (GRB in Binary)Colour
76010Red
54001Blue
32111White
10110Yellow

The flash bits are strange. At the beginning of each scan line, the flashing is turned off until such time as a flash bit is set - this turns flashing on until the next flash bit which is set is found. This turns flash off again - so the flash bits act like a toggle turning flash on and off each time a set bit is found.

Note

Most books I have read on the subject totally ignore the flash bits after this discussion - I am going to go into it in much more depth. Well that was a lie, I'm not!