home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / apple2 / 27427 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  3.9 KB

  1. Path: sparky!uunet!cs.utexas.edu!swrinde!emory!ogicse!cs.uoregon.edu!news.uoregon.edu!cie.uoregon.edu!nparker
  2. From: nparker@cie.uoregon.edu (Neil Parker)
  3. Newsgroups: comp.sys.apple2
  4. Subject: Re: Attention assembly programmers...
  5. Message-ID: <1jtvc5INNofg@pith.uoregon.edu>
  6. Date: 24 Jan 93 11:43:01 GMT
  7. Article-I.D.: pith.1jtvc5INNofg
  8. References: <2B59CDAB.12197@news.service.uci.edu> <aj74842@pro-gumbo.cts.com>
  9. Organization: The Universal Society for the Prevention of Reality
  10. Lines: 71
  11. NNTP-Posting-Host: cie.uoregon.edu
  12.  
  13. In article <aj74842@pro-gumbo.cts.com> tgeer@pro-gumbo.cts.com (System Administrator) writes:
  14. >In <2B59CDAB.12197@news.service.uci.edu>
  15. >andrep@balboa.eng.uci.edu (Andre Prellwitz) writes:
  16. >
  17. >>A while ago someone posted about how to read the joystick on a //gs in native
  18. >>mode.  They said that it was possible to read both paddles at once and there-
  19. >>fore get much more accurate readings.  I don't recall exactly how to do this,
  20. >>but I've been trying the following: strobe the analog paddle reset ($c070)
  21. >>and then read locations $c064 and $c065 and wait until both return to zero.
  22. >                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  23. >Only the high bit of these locations is valid.  When the high bit of either
  24. >location becomes 0 then the corresponding analog input has timed out.  You
  25. >will actually get more accurate results by reading them one after the other
  26. >with the accumulator set to 8 bits wide and the index registers used to hold
  27. >the counts (16 bits wide).  This allows for a much faster loop, giving better
  28. >resolution.  Assuming that this routine is called from full native mode, the
  29. >following code will do the trick:
  30. >
  31. >strobe   equ   $C070       ; analog input timing reset
  32. >pdl0     equ   $C064       ; analog input 0
  33. >pdl1     equ   $C065       ; analog input 1
  34. >
  35. >start    php               ; save processor status register
  36. >         phb               ; and data bank register
  37. >         sep   #%100000    ; make accumulator 8 bits wide
  38. >         lda   #0          ; make data bank = 0
  39. >         pha
  40. >         plb
  41. >         ldx   #0          ; initialize the counters
  42. >         txy
  43. >         lda   strobe      ; strobe the timing reset
  44. >loop1    inx               ; increment pdl0 count
  45. >         lda   pdl0        ; is high bit = 0?
  46. >         bmi   loop1       ; no, keep checking
  47.  
  48. (More code should probably go here...see below.)
  49.  
  50. >         lda   strobe      ; yes, strobe the timing reset again
  51. >loop2    iny               ; increment pdl1 counter
  52. >         lda   pdl1        ; is high bit = 0?
  53. >         bmi   loop2       ; no, keep checking
  54. >         plb               ; yes, restore data bank
  55. >         plp               ; and processor status register
  56. >         rts               ; return to caller (could be RTL)
  57.  
  58. And this doesn't cause you any problems with the Y value being wrong if the
  59. X value was a little bit less than the Y value?
  60.  
  61. The paddle trigger strobe only resets the timer circuits that are all done
  62. counting.  If one of the circuits is still counting, it will be unaffected
  63. by the strobe.  This means if the X axis of the joystick is set somewhat
  64. less than the Y axis, the strobe access at the end of the X-reading loop
  65. will have no effect on the Y-axis timer, which is still counting down from
  66. the original strobe access.  To really do it right, you need to wait until
  67. the Y axis goes low, and THEN trigger the strobe and start counting the Y
  68. axis.
  69.  
  70. I would stick the following code between your two loops:
  71.  
  72. loop3    lda   pdl1         ; Paddle 1 ready for reading yet?
  73.          bmi   loop3        ; If not, try again
  74.  
  75. The reasons for this behavior are discussed in detail in Apple IIe
  76. Technical Note #6.
  77.  
  78.                - Neil Parker
  79. --
  80. Neil Parker                 No cute ASCII art...no cute quote...no cute
  81. nparker@cie.uoregon.edu     disclaimer...no deposit, no return...
  82. parker@corona.uoregon.edu   (This space intentionally left blank:           )
  83.