Listing of file='JOYUT2.MAC;01' on disk='vmedia/joystick_sound-sector.ccvf'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; JOYSTICK UTILITY ROUTINES ; TITLE JOYUTL ; ; APPLICABLE TO BOTH ROUTINES: ; ; VALUES ON ENTRY: ; A REG - NUMBER OF JOYSTICK (0-3) ; ; *** NOTE: AN OUT OF RANGE NO. WILL PRODUCE GARBAGE ; ; DESTROYS: ; A REG ONLY ; XREG EQU 0A0H ;ADC-0809 CHIP JOYSTICK # 0 YREG EQU 0A1H ; ; READ THE JOYSTICK POSITION ; ; RETURNS: ; BC - X AND Y COORDS RESPECTIVELY ; ENTRY JOYSTK JOYSTK: RLC ;SET UP PORT NUMBERS ADI XREG STA XSTRT STA XINP INR A STA YSTRT STA YINP JOY10: MVI C,100 ;TIME-OUT COUNT DB 0D3H XSTRT: DB XREG NOP ;NOTE THE NOP'S - ESSENTIAL NOP JOY20: DCR C ;SEE IF A/D HAS TIMED OUT JZ JOY10 ; AND TRY AGAIN IF NECESSARY CALL STATUS ;CHECK FOR END-OF-CONVERSION ANI 80H JZ JOY20 ;LOOP UNTIL EOC DB 0DBH ;READ X-REGISTER XINP: DB XREG MOV B,A ;SAVE IN B JOY30: MVI C,100 ;REPEAT FOR Y-REGISTER DB 0D3H YSTRT: DB YREG NOP NOP JOY40: DCR C JZ JOY30 CALL STATUS ANI 80H JZ JOY40 DB 0DBH YINP: DB YREG MOV C,A ;SAVE IN C RET ; ; CHECK A PUSH BUTTON ; ; RETURNS: ; FLAGS SET AS FOLLOWS: <Z> BUTTON IS DEPRESSED ; <NZ> BUTTON NOT DEPRESSED ; ENTRY PSHBUT PSHBUT: PUSH B ;SAVE BC MOV B,A MVI A,4 PSHB10: RLC ;GENERATE CORRECT MASK DCR B JP PSHB10 MOV B,A CALL STATUS ;READ PUSH-BUTTON REGISTER ANA B ;SEE IF BUTTON DEPRESSED POP B ;RESTORE BC RET ; ; READ STATUS REGISTER ON AY-3-8910 CHIP ; (REGISTER NUMBER 14) ; SNDCHP EQU 0B0H ;AY-3-8910 SOUND CHIP ADDR REGISTER REGNO EQU 14 ;NO. OF PUSH BUTTON REG ON AY-3-8910 ; (I/O PORT A) ENTRY STATUS STATUS: MVI A,REGNO DI OUT SNDCHP IN SNDCHP EI RET END