0100 ; LIGHT GUN DETECTORõ0110 ; BY MATTHEW RATCLIFFõ0120 ; (c)1988, ANTIC PUBLISHINGõ0130 *= $5000õ0140 .OPT OBJõ0150 ;õ0160 LPENH = 564õ0170 LPENV = 565õ0180 STICK0 = 632õ0190 GUNHERE = 14 ; Reading on port with gunõ0200 GUNFIRE = 15 ; Gunport=15 when trigger pressedõ0210 GUNPORT = $0600 ; Store gun port index hereõ0220 ;õ0230 ; GUNDET -Look for the light gunõ0240 ; don't return until found.õ0250 ; When found, return the portõ0260 ; number of the gun in theõ0270 ; X register, and put itõ0280 ; in the GUNPORT memory locationõ0290 ; NOTE:õ0300 ; Detect LOW to HIGH on joystickõ0310 ; ports since the OS on XL/XE'sõ0320 ; copy ports 0 & 1 to 2 & 3.õ0330 ; On 400/800, any port 0-3õ0340 ; is valid for gun.õ0350 ;õ0360 GUNDETõ0370 LDX #0 ; First portõ0380 WAITõ0390 LDA STICK0,Xõ0400 CMP #GUNHEREõ0410 BEQ GUNFOUNDõ0420 ;õ0430 INX õ0440 CPX #3õ0450 BNE WAITõ0460 ;õ0470 BEQ GUNDETõ0480 ;õ0490 GUNFOUNDõ0500 STX GUNPORTõ0510 RTS õ0520 ;õ0530 ; GUNREAD - A successful GUNDETõ0540 ; is assumed, and GUNPORT RAMõ0550 ; register is set to the properõ0560 ; joystick port for readingõ0570 ; the light gun.õ0580 ;õ0590 ; On Exit:õ0600 ; X = LPENHõ0610 ; Y = LPENVõ0620 ; A = STICk(GUNPORT)õ0630 ; Zero flag is SET if theõ0640 ; trigger is being pressed.õ0650 ;õ0660 GUNREADõ0670 LDX GUNPORTõ0680 LDA STICK0,Xõ0690 LDX LPENHõ0700 LDY LPENVõ0710 CMP #GUNFIREõ0720 RTS õ0730 ;õ0740 ; A simple test routineõ0750 ; to use from DDT.õ0760 ; The first BRK occurs afterõ0770 ; the gun is detected.õ0780 ; At this BRK inspectõ0790 ; the X register for the properõ0800 ; port number. Continue programõ0810 ; from there. The next breakõ0820 ; occurs when the trigger isõ0830 ; pressed.õ0840 ;õ0850 *= $6000õ0860 GUNTESTõ0870 JSR GUNDETõ0880 BRK õ0890 ;õ0900 SHOOTEMUPõ0910 JSR GUNREADõ0920 BNE SHOOTEMUPõ0930 ;õ0940 BRK õ