202 The VIC 20
User
Guide
WrHlng
Programs
that
Make
Use
Of
Custom
Characters
Once you have your characters defined, you will want to put them to
work for you in programs. Programs that use custom characters are not
much different from those
that
use the standard character set. You still have
the option
of
using either
PRINT
or
POKE
(or both) to build your displays.
There are two differences, however: the reduced memory available and the
absence
of
the standard character set.
REDUCING
MEMORY
LOSS
Custom characters use up memory in two ways. Some memory must be
set aside as character memory. In our examples
we
use
an
area
of
2048
bytes,
but you can reduce this to as few as 512 bytes by using only 64 custom
characters. The section "Changing the Location
of
Screen and Character
Memory," near the end
of
this chapter, explains how to do this.
Memory
is
also needed to hold the program
and
DATA statements to
load your custom characters. This loss will
not
be large
if
you use only a few
characters, but can be significant if you are defining many. A DATA
statement to hold a custom character definition will use from
25
to 40 bytes,
depending
on
the number
of
digits in its values. Remember that spaces in a
DATA statement are stored with the program, so you can reduce the amount
of
memory used by eliminating them. While
we
generally recommend
that
you use spaces in your programs to improve readability, the commas that
separate the values in DATA statements can do that
job
adequately.
You can make more memory available to your main program by
splitting it into two programs: one to build the characters and one to do the
main work.
If
you run the character builder first, the program can be
replaced by the main program when it
is
finished. You can even do this
automatically, by placing a LOAD statement in the character builder.
If
you
are loading the program from tape, save the character builder first, then the
main program (the order does not matter on a disk drive). Make the last two
statements
of
the character builder a
CLR
and a LOAD.
10e
REM
LOAD
CUSTOM
CHARACTERS
110
DATA
6,16