EasyManua.ls Logo

Commodore VIC-20 - Page 107

Commodore VIC-20
308 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
This
gives
the
display
code
of
the
character
you
want
to
change.
To
find
the
proper
row
in
the
character,
use
this
formula:
ROW
=
{Y/8
-
INT(Y/8)) "8
Therefore,
the
byte
in
which
character
memory
dot
(X,Y)
is
located
is
calculated
by:
BYTE
= 7168
+
CHAR'S
-
ROW
The
last
thing
we
have
to
calculate
is
which
bit
should
be
modified.
This
is
given
by:
BIT
-
7-
(X-
(INT(X/8)"8)
To
turn
on
any
bit
on
the
grid
with
coordinates
(X,
Y),
use
this
line:
POKE
BYTE,
PEEK
(BYTE)
OR
(2
\
BIT)
Let's
add
these
calculations
to
the
program.
In
the
following
example,
the
VIC
will
plot
a
sine
curve:
50
FOR
X
=
0
TO
63
60
Y =
INT(
32
+
31
"
SIN
(X/10))
70
CH
=
INT(X/8)*8
-
INT(Y/8)
80
RO
=
(Y/8
-
INT(Y/8))
"
8
90
BY
=
7168
+
8"CH
-
RO
100
Bl
=
7-
(X-
INT(X/B}*8)
110
POKE
BY,
PEEK(BY)
OR
(2
f
Bl)
120
NEXT
130
GOTO
130
The
calculation
in
line
60
will
change
the
values
for
the
sine
function
from
a range
of
-
1
to
-1
to
a
range
from
0
to
63.
Lines
70
to
100
calculate
the
character,
row,
byte,
and
bit
being
affected,
using
the
formulas
as
given
before.
Line
130
freezes
the
program
by
putting
it
into
an
infinite
loop.
When
you
have
finished
looking
at
the
display,
just
hold
down
RUN'STOP
and
hit
RESTORE.
As
a
further
example,
you
can
modify
the
sine
curve
program
to
display
a
circle.
Here
are the
lines
to
type
to
make
the
changes:
55
Y1
=
32
+
SQR(64'X
-X*X)
56
Y2
=
32
-
SQR(64'X
-X*X)
60
FOR
Y
=
Y1
TO
Y2
STEP
Y2-Y1
125
NEXT
This
will
create
a
circle
in
the
HI-RES
area
of
the
screen.
Notice
that
the
rest of
the
screen
fills
up
with
a
stripe
pattern.
This
is
because
the
empty
spaces
on
the
screen
are
filled
with
character
code
32,
which
is
normally
a
space—and
is
now
one
of
the
91