EasyManua.ls Logo

Epson PX-8 - Page 149

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...
10(H3
CLS
:
LOCATE
2";:'~
1 :
PRINT
"HIGH
SCORE";
H!3CORE
I
f
,3H3
LOCATE
20~
3 :
PRINT
"Your-
sc:or-e
was";
SCORE
1020
LOCATE
5:
PRINT
"Play
againCy/n)";:
Y$=INPlJT$(l)
1<)3<)
l~
SCORE HSCORE
THEN
HSC[JF'E = SCORE
H)4~::1
IF
Y$··
"Y"
AND
Y$
"y"
THEN
CLS :
END
ELSE
.31t)
1~::16('
"
4<)'",)
,
SUBROUTINE
FDFi
LOADING
MACHnJE
CODE
4<)1<)
CLS
4(12{;1
AD=~!.HC0{:H)
4('30
READ
DAT$
4(140
IF
DAT$="end"
THEN
424<)
4<,5',
IF
DAT$
=
"LB"
THEN
pm~E
AD.
PEEK
(1)
+ S,H6F :
AD=
AD
+ 1 : GOTO
403',
4,,60
IF
DAT$
=
"HB"
THEN
POKE
AD,
PEE
f··.
(2)
flO=
AD + 1 : GOT[J
4('3(1
4,,7(1
POKE
AD.
VAL
(
"!.,h"
+DAT$)
40.80
AD=AD+
1 : GOT[J
4()30
409t~
DATA
D5
4100
DATA
4E
4110
DATA
CD.LB,HB
4120
DATA
Dl·
413('
DATA
E6.
FC
4140
DATA
IF·
415',
DATA
IF
4160
DATA
12
417')
DATA
13
4180
DATA
AF
419')
DATA
12
4200
DATA
C9
4210
DATA
end
423(1
'
:
'PUSH
DE
:
'LD
C,
(HU
:'CALL
ADCVRT
:
'POP
DE
: ' AND
')FCH
:
'RRA
:
'RRA
:'
LD
(DE),
A
:'INC
DE
:'
XOR
A
: '
LD
(DE).
A
:
'RET
:
"end
PUSH
ADD!.
POINTEF'
SET
ADC
CHANNEL
CALL
AID
CONVERTER
PDP
ADD!.
POINTER
MASK
BITS
l1
AND 1
ROTATE
RIGHT
ROTATE
RIGHT
ADD!.
=
DATA
RETURNED
ADD:,
MSB
ZERO A
REGISTER
ADD!.
MSB
')
RETUF(N TO
BASIC
424'3
ADC=&HC(1(H)
,
ADDRE~3S
TO
CALL
MACH I NE CODE SUBFiCiUT
WE
4261)
,
DETERMINE
MAX
RESPONSE
TO
BATTEFW
4270
'
4280')
LOCATE
15,2
:
F'F:I~n
"TURN
RESISTOR
TO
GIVE
MAXII1L1M
VALUE"
4290
LOCATE
15,3
:
PRINT
"THEN
PRESS
SPACE
B,;R"
43()('
LOCATE
2t),
5 :
PR
I
NT
"F<E~:)PllN~3E
4·3Hl
CALI_ ADC
(CH!.,
?lOD!.) :
LOCATE
40,5,0
:
PF(INT
ADD!.
4.32('
IF
INJ-<EY1;
:::-
!'
"
THEN
BMAX
ADD~-;':
F~ETLJF~~...j
ELSE
4:::;;(1~)
The main
part
of
the program consists
of
a series
of
subroutines
to
move the
"ball"
on
the screen,
and
move the
"bat"
in response
to
changes in the posi-
tion
of
the resistor. These subroutines are
at
the beginning
of
the program (lines
50
to
230).
Line 200 reads the value
of
the voltage from the
AID
converter.
Lines 310
to
1040 form the main
part
of
the program which handles the ball.
Lines 4000
to
4190 load the machine code routine.
Lines 4260
to
4300 use the machine code routine
to
read the
AID
converter.
They also allow setting
of
the maximum value
of
the voltage returned
to
be
used in line 200, so
that
the maximum sensitivity
of
movement can be obtained
for the battery being used.
8-3
Since the object
of
this appendix is
to
show the use
of
the BIOS call, only the
machine code routine
and
the BASIC
CALL
will be described in detail.
The BASIC CALL statement is used with a list
of
parameters. This allows the
channel
of
the
AID
converter
to
be varied as well as returning a value
of
the
voltage into a named variable.
The
channel is passed
to
the machine code rou-
tine by means
of
the variable
CHOJo,
and
the voltage
is
read back into the varia-
ble
ADD%.
Further details
of
using the CALL statement are given in the BASIC
Reference Manual (Appendix D). When two parameters are passed
to
the
machine language subroutine, the location in memory
of
the first variable (in
this case the channel
CH%)
will be placed in register pair
HL.
The address
of
the second variable (in this case
ADD%)
will placed in register pair DE.
The machine code subroutine first stores the address
of
the variable
ADD%
on
the stack (data in line 4090).
It
then loads the channel number into register
C (data in line 4100). The ADCVRT routine
is
then called (data in line 4110).
In
order
to
specify the address
of
ADCVRT, BASIC lines 4050
and
4060 are
used. The low byte is determined by taking the low byte
of
WBOOT from loca-
tion
0001
in the main memory bank, and adding the offset for the ADCVRT
routine (6FH). The high byte is then obtained as the high byte
of
WBOOT ob-
tained from location 0002 in the main memory bank.
On
return from the
ADCVRT routine, register A contains the value
of
the voltage, in the
top
six
bytes. After retreiving the location
of
the variable
ADD%
from the stack (data
in line 4120), the two lowest bits
of
the returned voltage are made zero
by
an
AND
operation with the value
FCH,
so
that
any values in the lowest two bytes
do
not
affect the result. (Data in line 4130.)
If
no further change was made
the byte would give number in the range 4
to
255, since the least significant
bits are always zero. Thus two rotations are made (data in lines 4140
and
4150)
to
make the most significant bits always zero. The contents
of
register A are
then placed in the first byte
of
the variable
ADD%
by loading register A into
the address pointed
to
by register pair
DE
(data in line 4160). By incrementing
the value
of
register pair DE,
and
making register A zero performing
an
XOR
operation on register A with itself, the next byte
of
the variable
ADD%
is
made
zero. This ensures the variable
ADD%
is always a one byte variable. The
data
for these operations are
to
be found in lines 4170
to
4190. Finally the routine
returns
to
BASIC.
The address for the machine code subroutine
is
assigned
to
the variable
ADC
in line 4240. The BASIC
CALL
statement can only call
to
a variable.
8-4

Other manuals for Epson PX-8

Related product manuals