Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #4810

Re: IIGS joystick programming?

From D Finnigan <dog_cow@macgui.com>
Newsgroups comp.sys.apple2.programmer
Subject Re: IIGS joystick programming?
Date 2018-10-08 16:30 +0000
Organization Mac GUI
Message-ID <dog_cow-1539016247@macgui.com> (permalink)
References <2b07d07b-e1c1-4bec-8444-39e06979271c@googlegroups.com>

Show all headers | View raw


paul.s.macmillan wrote:
> I scanned all my IIGS textbooks and none of them mention the joystick. Is
> there a new way to read the joystick on the IIGS or is the old PREAD
> firmware call still the only way to go?  

See here: https://macgui.com/usenet/?group=2&id=22257


011- A while ago someone posted about how to read the joystick on  
     a GS in native mode. They said that it was possible to read  
     both paddles at once and therefore get much more accurate  
     readings?  
Only the high bit of these locations is valid. When the high bit of either
location becomes 0 then the corresponding analog input has timed out.  

You will actually get more accurate results by reading them one after the
other with the accumulator set to 8 bits wide and the index registers used
to hold the counts (16 bits wide). This allows for a much faster loop,
giving better resolution. Assuming that this routine is called from full
native mode, the following code will do the trick:  
   

strobe equ $C070 ; analog input timing reset 
pdl0 equ $C064   ; analog input 0 
pdl1 equ $C065   ; analog input 1 

start php        ; save processor status register 
phb              ; and data bank register 
sep #%100000     ; make accumulator 8 bits wide 
lda #0           ; make data bank = 0 
pha 
plb 
ldx #0           ; initialize the counters 
txy 
lda strobe       ; strobe the timing reset 
loop1 inx        ; increment pdl0 count 
lda pdl0         ; is high bit = 0? 
bmi loop1        ; no, keep checking 
lda strobe       ; yes, strobe the timing reset again 
loop2 iny        ; increment pdl1 counter 
lda pdl1         ; is high bit = 0? 
bmi loop2        ; no, keep checking 
plb              ; yes, restore data bank 
plp              ; and processor status register 
rts              ; return to caller (could be RTL) 

Notice that the actual counting loops are only 9 cycles long. This gives the
best possible resolution. You will need your counters to be 16 bits wide as
the results will easily overflow the capacity of an 8 bit counter.  
Using memory locations as counters will only serve to slow the counting loop
down. If X and Y contain valid data before entry, you will need to save them
off to the stack and pull them back in after interpreting the joystick
results. I have used this exact method to read the analog inputs on my
Science Toolkit box which connects to the joystick port.  

The results have been extremely accurate (much more than would be needed for
a game which reads the joystick). --tgeer@pro-gumbo.cts.com (System
Administrator)  

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

IIGS joystick programming? paul.s.macmillan@gmail.com - 2018-10-08 06:57 -0700
  Re: IIGS joystick programming? D Finnigan <dog_cow@macgui.com> - 2018-10-08 16:30 +0000
    Re: IIGS joystick programming? Michael J. Mahon <mjmahon@aol.com> - 2018-10-08 15:25 -0500
      Re: IIGS joystick programming? John Brooks <jbrooks@blueshiftinc.com> - 2018-10-08 19:10 -0700
        Re: IIGS joystick programming? paul.s.macmillan@gmail.com - 2018-10-08 19:17 -0700
          Re: IIGS joystick programming? John Brooks <jbrooks@blueshiftinc.com> - 2018-10-10 07:42 -0700
            Re: IIGS joystick programming? D Finnigan <dog_cow@macgui.com> - 2018-10-10 16:35 +0000
              Re: IIGS joystick programming? paul.s.macmillan@gmail.com - 2018-10-10 10:45 -0700
            Re: IIGS joystick programming? Michael J. Mahon <mjmahon@aol.com> - 2018-10-10 16:26 -0500

csiph-web