Page Index Toggle Pages: 1 Send TopicPrint
STE/Falcon/Jaguar: How to detect teamtap reliably! (Read 854 times)
ggn
D-Bug member
Reboot Member
*****
Offline


D-Bug debugger

Posts: 1463
Location: Somewhere in Greece
Joined: 22.02.07
Gender: Male
STE/Falcon/Jaguar: How to detect teamtap reliably!
24.07.10 at 18:03:47
Print Post  
Recently I've been messing around with Jagpad input and while I sorted it out easily, I wanted to add support for the teamtap as well. Not wanting to reinvent the wheel, I asked around for some advice on the matter. Zerosquare of CVSD pointed me to two solutions for this.

One was to use heuristics (i.e. make the user press a jagpad button and see if the button press is shadowed on other pads on the same port - if yes, the user most certainly doesn't have one installed), and the other was in fact a method by Matthias Domin, which reads a seemingly unused bit on the jagpad matrix on jagpad #4. Matthias claimed that if this bit (C1 on the jaguar docs) is inactive (at least on Falcon, jagpad bits are all set to 1 when the user doesn't press any button on the pad), then there's a teamtap installed.

That was just what I needed! So I quickly wrote a test program in GFA Basic and sent it to SH3 (I forgot to mention that I don't own a jagpad Wink). And that didn't work 100%. It turns out that this bit can change if there's no teamtap installed and the user presses the pause button. Fortunately we noticed that only bit C1 changes when you insert the teamtap in the port. So Matthias' claim was partly correct. The check that works 100% is:

  • if (bit c1 in jagpad #4)=set and (bit c2 in jagpad #4)=set then the user is using a single jagpad without teamtap and pressing pause
  • if (bit c1 in jagpad #4)=unset and (bit c2 in jagpad #4)=set then we have a teamtap! (the trick here is that when a teamtap is installed, then if jagpad #1 pause is set, you don't have any shadowing to the other pads)
  • if (bit c1 in jagpad #4)=unset and (bit c2 in jagpad #4)=unset then we have a normal jagpad, pause is not pressed


(note: "unset" means that the bit is in it's natural state and "set" means it's changed. As I mentioned, on the Falcon it's 1 for unset and 0 for set Smiley)
(note #2: there's a 4th combination of bits, but I don't think it's possible to achieve this with a normal teamtap, so it's left out)

I hope I didn't screw anything up - after all, I tested at blind (sh3 was my eyes Smiley). If you find any inaccuracies, please mention them to me so I'll fix the text Smiley


Addendum: The shitty GFA program I used to test all of the above. It's not anything brainblasting, but at least it works (it's for port #1 btw) and it displays all ports' pad bits in the same screen.

Code
Select All
DO
  PRINT AT(0,1)
  PRINT "teamtap port a"
  SDPOKE &HFFFF9202,&HFFFE
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFFD
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFFB
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF7
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  '
  PRINT "teamtap port b"
  SDPOKE &HFFFF9202,&HFFF0
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF1
  PRINT BIN$(x1%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF2
  PRINT BIN$(x2%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF3
  PRINT BIN$(x3%,16)'BIN$(DPEEK(&HFFFF9202),16)
  '
  PRINT "teamtap port c"
  SDPOKE &HFFFF9202,&HFFF4
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF5
  PRINT BIN$(x1%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF6
  PRINT BIN$(x2%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFF8
  PRINT BIN$(x3%,16)'BIN$(DPEEK(&HFFFF9202),16)
  '
  PRINT "teamtap port d"
  SDPOKE &HFFFF9202,&HFFF9
  PRINT BIN$(DPEEK(&HFFFF9200),16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFFA
  x1%=DPEEK(&HFFFF9200)
  PRINT BIN$(x1%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFFC
  x2%=DPEEK(&HFFFF9200)
  PRINT BIN$(x2%,16)'BIN$(DPEEK(&HFFFF9202),16)
  SDPOKE &HFFFF9202,&HFFFF
  x3%=DPEEK(&HFFFF9200)
  PRINT BIN$(x3%,16)'BIN$(DPEEK(&HFFFF9202),16)
  '
  PRINT
  PRINT "C1=";BTST(x1%,0);", C2=";BTST(x2%,0);", C3=";BTST(x3%,0)
  PRINT "So..."'
  IF BTST(x1%,0)=1 AND BTST(x2%,0)=0
    PRINT "you have a teamtap installed!"
  ELSE
    PRINT "you DO NOT have a teamtap installed!"
  ENDIF
LOOP UNTIL INKEY$<>""
 

  
Back to top
 
IP Logged
 
sh3-rg
D-Bug member
Reboot Member
*****
Offline


reservoir reboot

Posts: 499
Location: b0lt0n-Uk
Joined: 23.02.07
Gender: Male
Re: STE/Falcon/Jaguar: How to detect teamtap reliably!
Reply #1 - 27.07.10 at 06:54:09
Print Post  
So how does GodLib test for team taps? Does it use the force?
  

Back to top
WWW  
IP Logged
 
ggn
D-Bug member
Reboot Member
*****
Offline


D-Bug debugger

Posts: 1463
Location: Somewhere in Greece
Joined: 22.02.07
Gender: Male
Re: STE/Falcon/Jaguar: How to detect teamtap reliably!
Reply #2 - 27.07.10 at 06:56:48
Print Post  
sh3-rg wrote on 27.07.10 at 06:54:09:
So how does GodLib test for team taps? Does it use the force?


I found no specialised code that detects the teamtaps. My guess is that they have to be enabled from somewhere in the options menu.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
 
  « Board Index ‹ Board  ^Top