EasyManua.ls Logo

Commodore CBM - Page 303

Commodore CBM
447 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...
Sv replacing A
with
this equation. the
PET
will
calculate the screen address itself.
POKE32768+(COL-)+(40*ROW-11.X
"-
y----
POKE
A
.X
For instance.
if
COL
(C)
and
ROW
(R)
were input
as
5.3. and X
as
fi
then a
spade
would
be
POKEd
at screen location (3.5). address 32852.
10
INPUT c. R
..
~y~
20
POKE
32768+(C-l)+(40*(R-l»,X
= 32768+(COL-1)+(40·(ROW-1)),X
=
32768+(5-1)+(40'(3-1)),X
= 32768+4+(40*21.X
=
32768+4+80.X
= 3285
.X
11
5
Although the above equation
is
useful when vou do not know the exact
screen address. vou should not alwavs incorporate that long equation into vour
programs.
It
is
much neater and more concise if vou use the aforementioned for-
mula to calculate the screen address outside of the program. and then use the
screen address using
POKE
inside of the program:
POKE
32852,X
or
A=32852
POKE
A,X
Variables are acceptable in the
POKE
commando
as
long
as
the variables stay
within
the proper limits:
1.
POKE
32768+A.X
2.
POKE
A,X
where A
is
a number between 0
and
999 inclusive
(32768+999=33767).
where A
is
a number between 32768 and 33767
inclusive.
POKE
32768
..
>:;
ft=ft+10
POKE
:32768+ft,;"';
IF
ft<=1000
GOTO
30
or: 1
(1
;;~0
30
40
Using variables to represent the screen address
is
practicable when
POKE-
ing to a repeating sequence of screen spaces. For example. the
two
programs
below
POKE
the value of X ten spaces apart across the screen. This
is
a much
more efficient method of printing than programming several
PRINT
statements
and cursor movements.
1(1
ft=32768
2(1
POKE
A, X
:30 ft=ft+
10
40
IF
ft<=33767
GOTO
20
290

Table of Contents

Other manuals for Commodore CBM

Related product manuals