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
Back to previous page