Extended color mode

From C64-Wiki
Jump to navigationJump to search

Extended color mode is a special feature of the VIC-II's text screen: By setting bit 6 (weight 64) in 53265/$D011, each individual character on the text screen may have one of four different background colors. The "trade-off" is that the character set is limited to the first 64 out of normally 256 available characters. Colors are selected by POKEing the color values into four bytes, 53281-53284.

The two most significant bits in the character code for each position on the screen determines which of the four background colors applies to that character:

  • 00xxxxxx gives the background color specified in 53281/$D021
  • 01xxxxxx gives the background color specified in 53282/$D022
  • 10xxxxxx gives the background color specified in 53283/$D023
  • 11xxxxxx gives the background color specified in 53284/$D024

The remaining six bits indicate which of the first 64 characters in the current character set should appear at that position. Due to the layout of the character set, bit six is set by holding the SHIFT  key while typing, and bit seven is set by turning on reverse text. Therefore:

  • 53281 is invoked by typing normally
  • 53282 is invoked by typing with the SHIFT  key
  • 53283 is invoked by turning on reverse mode
  • 53284 is invoked by using SHIFT  with reverse mode

After extended color mode is enabled, typing with the SHIFT  key down will cause the characters to appear in the alternate background color, rather than upper-case or as glyphs.


If using PETSCII codes in the CHR$() function: the 64 characters available for use are in the range 32 - 95.

  • For characters 32 - 62: add 192 to get the "shifted" version, for example to produce a 1 with background colour 53282 you can use PRINT CHR$(ASC("1")+192). Or, you can type it as CBM-E
  • For characters 63 to 95: add 128 e.g. PRINT CHR$(ASC("63")+128) gives a "?" question mark with background colour 53282

If reverse mode is on, with above examples you get background colour 53283 with codes 32 - 95, or 53284 when you add 192/128


If using Screen Codes (e.g. POKE 1024, X to set the top left character), the 64 characters are in the range 0 - 63 (where codes 32 - 63 map to PETSCII codes 32 - 63, and codes 0 to 31 map with PETSCII codes 64 to 95).

  • To use background 53282, add 64 to the code. For example, POKE 1024, 4 gives "E" on background 53281: POKE 1024, 68 gives "E" on background 53282
  • To use background 53283, add 128 to the code. For example POKE 1024, 132 gives "E" on background 53283
  • To use background 53284, add 192 to the code. For example POKE 1024, 196 gives "E" on background 53284
Decimal Binary 2 high bits BG (dec) BG (hex)
4 00 000100 00 53281 $D021
68 01 000100 01 53282 $D022
132 10 000100 10 53283 $D023
196 11 000100 11 53284 $D024

Example[edit | edit source]

This BASIC example demonstrates the extended color mode:

10 POKE 53281,1
20 POKE 53282,2
30 POKE 53283,5
40 POKE 53284,6
50 POKE 53265,PEEK(53265) OR 64
60 PRINT "ABC abc ";CHR$(18);"ABC abc"

RUN

ABC ABC ABC ABC

READY.

The first four lines set up the four background colors; white, red, green, and blue, in their respective registers. Line 50 engages the extended color mode, and line 60 prints the example text. Note that CHR$(18) is the control character for "reverse on", and the letters shown as lowercase would actually be shifted (capital letters in the big/small character set, or graphics in the big/graphics character set).

Do not use along with multicolor mode![edit | edit source]

Extended color mode should not be used simultaneously with multicolor mode for the text screen: The VIC-II seems to "lock up" if both modes are engaged, showing a blank, black screen. The problem clears as soon as either multicolor or extended color mode is disabled.