EasyManua.ls Logo

Epson PX-8 - Page 148

Epson PX-8
168 pages
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...
Appendix H
SOME
EXAMPLE
PROGRAMS
Two examples
of
programs are given in this appendix. They show different uses
of
function calls. One covers the use
of
the
AID
Converter, which can only
be used with a BIOS call. This
is
then linked
to
BASIC to show how the two
can be combined. The second shows how the screen data can be saved
to
disk,
and so covers examples
of
sending and receiving data to the
6301
slave proces-
sor.
It
also covers disk handling
and
a certain amount
of
error checking. Two
programs are given, to save and read the screen data. Again they are linked
to BASIC,
but
as they are longer programs this needs to be done in a different
way. They could be poked in,
but
the code has be written to locate itself into
the correct position before BASIC
is
loaded.
H-l.
A
simple
game
illustrating
use
of
the
AID
converter.
HIGH
SCOF:E ,)
o
Bat
~
-
The following program shows the use
of
the ADCVRT BIOS routine
to
enable
the voltage across a variable resistor to be read. By rotating the shaft
of
the
resistor the voltage read by the
AID
converter will vary in proportion
to
the
amount
of
rotation. This can then be used as a means
of
altering the position
of
a
"bat"
on the screen to
playa
simple game. This game shows how the BIOS
routine can be used and how it can be linked
to
a BASIC program through
the CALL statement
of
BASIC.
H-1
The circuit for the game
is
as follows:
1.5V
r---------,
+
'--------0
Analog
Input
GND
Not
used
t
t I T
GND
AID
The circuit comprises a battery to provide the voltage, a variable resistor and
the necessary connecting wires. The connections to the
AID
interface are shown
in section
4.
6.
The program listing
is
as follows:
10'.
AID
CONVERTER
IN
A GAME *
2~)
"
3t)
CLEAF~
,~.:HCX"J(?:
GOSlIB
4·t:'(h):
GClTCl
3~)()
4·(1
'
SUBROUT
I
NES
5<, L.OCATE
X,
Y :
F'RUH
"0";
: X
1.
,.
X :
Yl
Y:
RETURN
60
l_OCATE
Xl,
YI
:
PRINT
"
";
:
RETURN
7')
X "'x + DX
80
IF
X(2
THEN
X -
4-X
: DX -
-DX
90
IF
X>79
THEN
x =
15S--X
: DX =
-DX
100
RETURN
110
'
20<,
CAL.L. ADC
(CHI.,
ADD:O
:
ADDI.
=
ADDI.
*
74/BMAX
+"
IF
ADDI.>75
THEN
ADDI.
75
210
PX
=
ADDI.
220
L.OCATE
PX1,S
:
PRINT"
";
CHR$H,HIE)
230
L.OCATE
PX,S
:
PRINT
STRING$(5,
140>;
CHR$(~,HIE)
PXI
PX
RETURN
240
250
"
290
'MAIN
PROGRAM
300
'
310
SCREEN
3,,0
: CL.S
CHI.
0:
PX
- 2 :
PXI
- 2 : X - 2 :
XI
= 2 :
SCORE
- 0 : N - 0 : BAL.L. - I
320
LINE
(5.0)
-
(5.63)
:
LINE
(475,O)
-
(475,63)
330
L.OCATE
i0,1
:
PRINT
"SCORE"
: L.OCATE
30,1
:
PRINT
"BAL.L.
NUMBER";
BAL.L.
340
X -
lNT(RND*7S)
+ 2 : DX -
FIX
«RND*2-1)*(N/5+1»
360
Y - 2 : GOSUB
200
GOSUB
50
370
FOR
Y - 3 TO 7
38',
GOSUB
70
:
GOSUB
200
: GOSUB 6(1 : GOSUB
50
:
GOSUB
20',
390
NEXT
Y
400
Y = 8 : GOSUB
70
: GOSUB
2')0
410
IF
X =
PX
OR X =
PX+4
THEN
SOUND
1200,20
:
DSCORE
_ I : GOTO
800
420
IF
X -
PX+I
OR X -
PX+3
THEN
SOUND
18')0,20
:
DSCORE
_ 2 : GOTO
800
430
IF
X -
PX+2
THEN
SOUND
2400,20
:
DSCORE
- 3 : GOTO
800
440
DSCORE
-
0:
GOSUB
60
:
GOSUB
5',
: SOUND
60'~,
50
800
SCORE
=
SCORE
+
DSCORE
: L.OCATE
IS,I
:
PRINT
SCORE;
810
BAL.L. =
BALl_
+ 1 :
IF
BAL.L. >
20
TH5N
100<3
82<3 GOSUB
60
83',
N -
N+
1 :
GClTCI
330
H-2

Other manuals for Epson PX-8

Related product manuals