Chapter
6:
Graphics 183
on which it appears.
For
example,
to
change the character color
to
green
from the keyboard, you would type
CTRL-6. The POKE value would be
5.
If
you keep this rule in mind, you will find a handy reference to the POKE
values right on the keyboard.
Unlike other areas of
VI
C memory, color memory has only four bits per
location. Three
of
these bits hold the color number
(0
to
7), and the fourth
is
used for multicolor mode graphics, which
we
will discuss later in this
chapter.
(For
now, you should make sure this bit
is
always zero by POKEing
only numbers from 0 through 7 into color memory.) Since the upper four
bits are not used, Commodore did not include memory chips to hold them.
If
you POKE a number larger than
15
into a color memory location, the part
of
it held in those "missing" bits will be lost.
10101010
1010
11111111
1111
00000111
0111
A value
of
204, when the upper 4 bits are dropped,
is
stored as a
12
A 255
becomes a
15
A value
of
7,
however,
is
not changed.
Since there
is
no memory chip to supply the upper four bits when
reading color memory locations, they will take on unpredictable values.
Remember
that
a bit must be either a 1
or
a
0;
even if there
is
no signal
present on a chip's input pin, the chip must assign it some value. With no
signal coming into the pins for the upper four bits, the chip arbitrarily gives
them either a 1
or
a 0 value. When PEEKing color memory, always discard
the nonexistent bits. This can be done by using AND
to
mask them, as
described in Chapter
5.
10
BY=PEEK(38402)
AND
15
Screen
Display Codes
Once you understand where to POKE to change the display, you will
need to know what value to
put
there. Commodore computers, including the
VIC, do not use the same character code in screen memory
that
they use in
programs. Most computers store characters in a standard code called ASCII
(American Standard Code for Information Interchange). Commodore
computers use
an
"extended" ASCII for all purposes other than represent-
ing characters in screen memory. The "extensions"are the graphics charac-