10REM Light pen test by C.J.Richardso
n for 8BS
20DEFFNS="LightPn"
30M%=0:REM MODE
40PROCsetup:REM SETUP INTERRUPT
50MODEM%:REM SET MODE
60VDU23;8202;0;0;0;:REM SWITCH OF CUR
SOR
70VDU19,0,3,0,0,0:REM SET YELLOW BACK
GROUND
80VDU19,1,1,0,0,0:REM SET RED FOREGRO
UND
90OX%=0
100OY%=0
110REPEAT
120A%=!&74:REM READ PEN POSITION
130IF A%<>0 A%=A%-O%-Offset%:PRINTTAB(
X%,Y%);" ";:REM IF PEN DETECTED SUBTRACT
OFFSETS AND BLANK OUT OLD POSITION
140X%=A%MOD80:REM WORK OUT NEW X AND Y
150Y%=A%DIV80
160PRINTTAB(X%,Y%);"*"
170UNTILFALSE
180DEFPROCsetup:REM INTERRUPT PUTS PEN
POSITION INTO !&74
190FORL%=0TO2STEP2
200P%=&900
210[:OPTL%:.i SEI
220LDA#f MOD256:STA&206:LDA#f DIV256:S
TA&207
230LDA#&88:STA&FE4E:CLI:RTS
240.f LDA&FC:PHA:TXA:PHA:TYA:PHA
250LDA&FE4D:AND#&88:CMP#&88:BNEout
260LDA&FE40:LDX#16:STX&FE00:INX
270LDA&FE01:CMP&71:STA&71
280BNEd:STX&FE00:LDA&FE01
290TAY:SBC&70:CLC:ADC#1:BMIe
300CMP#3:BCSe:STY&74:LDA&71
310STA&75:JMPout
320.d STX&FE00:LDY&FE01
330.e STY&70:LDA#0:STA&74:STA&75
340.out PLA:TAY:PLA:TAX:PLA:STA&FC:RTI
:]
350NEXT
360!&70=0:!&74=0
370*FX20,1
380CALLi:*FX233,247
390IFM%=0 O%=&606:C%=80:R%=32:E%=1:G%=
&3000:N%=16
400IFM%=1 O%=&606:C%=40:R%=32:E%=2:G%=
&3000:N%=16
410IFM%=2 O%=&606:C%=20:R%=32:E%=4:G%=
&3000:N%=32
420IFM%=3 O%=&806:C%=80:R%=25:E%=1:G%=
&4000:N%=8
430IFM%=4 O%=&B04:C%=40:R%=32:E%=1:G%=
&5800:N%=16
440IFM%=5 O%=&B04:C%=20:R%=32:E%=2:G%=
&5800:N%=32
450IFM%=6 O%=&C04:C%=40:R%=25:E%=1:G%=
&6000:N%=16
460IFM%=7 O%=&2808:C%=40:R%=25:E%=1:G%
=&7C00:N%=16
470Offset%=1:REM ALTER THIS TO GET THE
* UNDER THE PEN
480ENDPROC