222 The VIC 20
User
Guide
can access 65,536 bytes
of
memory (though most VICs will use less
than
that). The VIC chip, on the other hand, can access only 16,384 bytes. There
is
another difference between the two. Most of the computer
is
based on
"normal" bytes
of
eight bits, but the VIC chip uses
12
for screen memory:
eight for the character and four for the color. This was done to make the VIC
chip faster, allowing it to get all the information it needs
about
a screen
character
at
one time.
To enable the two different chips to communicate through the same
memory, the VIC was designed so the VIC chip had a "window" through
which it could access only a part
of
computer memory. This window allows
the VIC chip to read two different areas, each 8192 bytes long, as though
they were one area
of
16,384 bytes. The layout
of
this window
is
shown in
Figure 6-7.
Notice that the first half
is
in the upper portion
of
memory, while the
second half starts
at
location
O.
This must be kept in mind if you move screen
or
character memory by POKEing the VIC chip's memory pointers. This
map also explains how
we
were able
to
get
both
custom characters and
standard characters
on
the same screen.
By
setting the reverse bit in the
character in screen memory, the character memory address overflowed and
"wrapped
around"
to 0 again (the carry
is
thrown away). This caused the
VIC chip to get the reversed character out
of
the normal portion of the
built-in set.
Color memory
is
treated differently from screen
and
character mem-
ory. The screen and character memory areas have a common set
of
connec-
tions for accessing
data
that
is
shared by the VIC chip and the rest
of
the
computer. Color memory has two sets: one
that
allows the VIC chip to read
it as the
top
part
of
its 12-bit byte, and one that allows the rest
of
the
computer to access it as the lower part
of
an
8-bit byte. The connections for
location numbers also differ. While the rest
of
the computer "sees" color
memory only at locations 37888 through 38911, to the VIC chip it appears to
be everywhere in the second half
of
its window. Byte 0 in the color memory
chip, which your program sees as location 37888,
is
read by the VIC chip at
locations 8192, 9216, 10240, 11264, 12288, 13312, 14336, and 15360 in its
window. Byte 1 appears at locations 8193, 9217,10241,
and
so on. Thus, no
matter where you move screen memory, the same color memory chip
is
used.
Notice, however, that the color memory chip has 1 024 locations, so that only
half
of
it
is
used
at
one time. The half
that
is
used depends
on
the location
of
screen memory:
If
screen memory starts
on
an
even 1024-byte boundary (for