Subject: Re: Joystick Code... Help Please!
From: [email-masked] (Orion Pax)
Date: 26 Nov 1994 06:32:24 GMT
Newsgroups: comp.sys.apple2.programmer

Shawn Platkus ([email-masked]) wrote:
: I'm in need of some code to read the joystick values from 65816 assembly.

Here's the code I copied from Out of This World and used in Star Command GS:

readJoystick	START
*
*  Reads the values for the joystick paddles && returns values in the x/y regs
*  7/93 version 4.0.2
*
*  Code from Out of This World by Bill Heineman
*
       php                  ; save states of cpu
       phd
       pea $100             ; put maxReadBound on stack (values max at $FF)
       tsc                  ; point dp to maxReadBound
       tcd
       sei                  ; interrupts off
       lda >$C070           ; reset joystick i/o timer
       ldx #0               ; zero counters	
       txy
readLup anop
       lda >$C064           ; read x/y axises
       and #$8080
       beq quit             ; if neither valid, quit
checkY anop
       asl a
       bcc ySpinWheels      ; if invalid y, do dummy code for dummy cycle time
       iny                  ; else increment y counter
       bra checkX
ySpinWheels anop            ; dummy code of similiar cycle time
       nop
       nop
       nop
checkX anop
       asl a
       beq xSpinWheels      ; if invalidx, do dummy code for dummy cycle time
       inx
       bra maxDec
xSpinWheels anop            ; dummy code of similiar cycle time
       nop
       nop
       nop
maxDec anop
       dec <1               ; this makes sure values are <= 255
       bne readLup
quit anop
       pla
       pld                  ; restore cpu state
       plp
       rtl
       END

Joseph
--
[email-masked]   | Have you watched your Koko wa GreenWood, Yotoden,
-------------------------+ Gundam 0083, Bubble Gum Crisis/Crash!, Video Girl
II(> Creative 'Ware <)II | Ai, Tenchi Miyou, Ah! My Goddess, Maison Ikkoku,
 Cal-Animage Epsilon VP  | PatLabor, Ranma 1/2, and Five Star Stories today?