lackey@Alliant.COM (Stan Lackey) (03/17/88)
Routines for interfacing the trak-ball by Stan Lackey ; ; Code to track the trak-ball ; OLDVAL = $CB HORIZ = $CD VERT = $CE JOYST = 54016 ORG $0600 TYA ; Save Y. The Atari saves A. PHA LDA JOYST ; Get new val TAY ; Save it in Y EOR OLDVAL ; Test for a change AND #2 ; Clear all but horiz motion bit BEQ TSTVER ; If not, test for vertical motion TYA ; get new val AND #1 ; Horiz change. Test direction. BNE RIGHT DEC HORIZ ; Left motion - decr coordinate. CLC BCC TSTVER RIGHT: INC HORIZ ; Right motion. TSTVER: TYA ; get new val EOR OLDVAL ; Test for change AND #8 ; Clear all but vert motion bit BEQ EXIT ; If no change, exit TYA ; new val AND #4 ; Vert change. Test direction. BEQ UP ; INC VERT ; Down - incr coordinate. CLC BCC EXIT UP: DEC VERT ; Up - decr coord. EXIT: STY OLDVAL ; Update old value PLA TAY ; Restore Y PLA ; Restore A RTI ; END Now - the interrupt vector and some other stuff needs to be set up. I just do it in Basic. 5 F=100 ; Timer frequency - This value seems to work OK 10 OPEN #4,4,0,"D1:TRAK.OBJ" ; The binary of the above prog 20 GET #4,X:GET #4,X:GET #4,X:GET #4,X ; Strip the header 30 GET #4,X:GET #4,Y ; Length is in X (less than 256) 40 ADDR=6*256 ; Start of page 6 50 FOR I=ADDR TO ADDR+X 60 GET #4,X 70 POKE I,X ; Load image 80 NEXT I 90 CLOSE #4 ; Done 110 POKE 528,0:POKE 529,6 ; Set up $600 into timer interr vector 130 POKE 53761,0 ; Set volume to off - enables counter 140 POKE 53760,F ; Set up interrupt frequency 150 POKE 53769,255 ; Turn on timers 160 POKE 16,193 ; Enable timer1 interrupt Now - a little program to test it 200 TRAP 200 ; Restart if coord's go offscreen 210 GRAPHICS 8+16 220 H=205:V=206 ; The coord's 230 POKE H,20:POKE V,20 ; Initialize coord's 240 PLOT PEEK(H),PEEK(V) 250 DRAWTO PEEK(H),PEEK(V) 260 GOTO 250 Good luck. Check for typo's (I don't think there are any, but who knows?) -Stan