- Joined: 26 Aug 2008
- Posts: 292
- Location: Australia
|
Japanese Sports Pad
Posted: Fri Jul 31, 2009 2:13 pm
|
After implementing the sports pad from the sega documentation I got to wondering about the Japanese sports pad. Now if the Japanese sports pad has 2 buttons, how exactly is it supposed to tell which nibble is being sent? The TH pin is the only thing left which is readable but that only has 2 states. Is there some kind of funkiness going on here or just errors in the documentation?
From my initial reverse engineering it seems it has a different way of reading the sports pad (basically the buttons and directions are all sent as nibbles it appears), yet MEKA and REGEN both work fine with the game and MEKA at least doesn't appear to have any special handling for the japanese sports pad. I'm probably missing something real easy here?
|
- Joined: 26 Aug 2008
- Posts: 292
- Location: Australia
|
Posted: Fri Jul 31, 2009 2:33 pm
|
Well typical, you ask for help and solve the problem within 20 minutes after spending a few hours on it.
Seems MEKA patches the ROM :-
ROM[0173] = 0C
And this seems to trigger it into using the non japanese sports pad, aswell as apparently fixing another bug (listed by MEKA). I guess REGEN is using this patch as well? I've never seen mention of the Japanese sports pad being different on this forum though, so at least the information is here now.
|
- Site Admin
- Joined: 19 Oct 1999
- Posts: 14744
- Location: London
|
Posted: Fri Jul 31, 2009 5:05 pm
|
I never got too far into the sports pad (it's a bad controller for bad games), but I remember thinking that the Sega documentation also didn't seem to tell you what the current value was. I thought you were supposed to use the timings to figure it out, but as I said I didn't look very closely.
|
- Joined: 26 Aug 2008
- Posts: 292
- Location: Australia
|
Posted: Sat Aug 01, 2009 12:48 am
|
Well I spent an hour tweaking the sports pad when I did it because I thought the value was permanently stored, so I spent a while looking around for some hidden bug that didn't exist, but it seems to just be offsets from 0. This isn't really referenced anywhere. The sports pad games are horrible though as you subtly said, makes me wonder why I wasted so much time on them.
Here is the japanese sports pad reading code (PORT1). Funny thing is it has loops which will be stuck forever if you put a normal joypad in and push button 1 or 2. In my emulator the music just goes to a single tone if you hold the button as it gets stuck in the loops below.
It's fairly obvious what it seems to be doing, but bit 4 and 5 seem to be the ways the device communicates. Must be some awful careful timing in there. :)
120d 1e08 ld e,#08
120f dbdc in a,(#dc)
1211 cb6f bit 5,a
1213 280a jr z,#121f ; (10) : if bit5 is zero jump to main routine
1215 1d dec e : else dec e and try again until bit5 is zero or it's done 8 times
1216 20f7 jr nz,#120f ; (-9)
1218 af xor a
1219 3296c2 ld (#c296),a
121c 3297c2 ld (#c297),a
121f dbdc in a,(#dc) : read DC input
1221 cb6f bit 5,a : test bit 5 of DC input
1223 28fa jr z,#121f ; (-6) : jump back to read input until bit5 is set (a forever loop)
1225 e5 push hl : delay?
1226 e1 pop hl : delay?
1227 dbdc in a,(#dc) : read DC again, into A
1229 2191c2 ld hl,#c291 : C291/C292/C293 seem to store the 3 bits of info we want, buttons and two axis
122c e60f and #0f : only want directional bits as they store the nibble
122e 77 ld (hl),a : load C291 with this lower 4 bits, assume this is the buttons since it only stores 4bits
122f 23 inc hl
1230 0602 ld b,#02 : want to do next loop twice
1232 1e08 ld e,#08 : START OF LOOP
1234 dbdc in a,(#dc) : read DC input
1236 cb67 bit 4,a
1238 2803 jr z,#123d ; (3) : if bit4 is set jump to delay
123a 1d dec e : else try upto 8 more times until it is
123b 20f7 jr nz,#1234 ; (-9)
123d e5 push hl : delay?
123e e1 pop hl : delay?
123f dbdc in a,(#dc) : read DC
1241 e60f and #0f : only want directional bits
1243 07 rlca
1244 07 rlca
1245 07 rlca
1246 07 rlca : move 4 bits to upper 4 bits of byte
1247 4f ld c,a : store in C
1248 dbdc in a,(#dc) : read dc again
124a cb67 bit 4,a :
124c 28fa jr z,#1248 ; (-6) : if zero jump back and read again (FOREVER)
124e e5 push hl : delay
124f e1 pop hl : delay
1250 dbdc in a,(#dc) : read dc again
1252 e60f and #0f
1254 b1 or c : combine lower 4 bits just received with previous result
1255 77 ld (hl),a : C292 contains this 8bit result
1256 23 inc hl : moves it to C293 to store second result
1257 10d9 djnz #1232 ; (-39) : do loop once more
1259 2194c2 ld hl,#c294
125c d9 exx
125d 1192c2 ld de,#c292
1260 2196c2 ld hl,#c296
1263 0602 ld b,#02
1265 1a ld a,(de)
1266 96 sub (hl)
1267 d9 exx
1268 77 ld (hl),a
1269 23 inc hl
126a d9 exx
126b 23 inc hl
126c 13 inc de
126d 10f6 djnz #1265 ; (-10)
126f 2192c2 ld hl,#c292
1272 1196c2 ld de,#c296
1275 010200 ld bc,#0002
1278 edb0 ldir
127a c9 ret
|
- Joined: 03 Mar 2008
- Posts: 25
|
Posted: Sat Aug 01, 2009 3:00 pm
|
PoorAussie wrote I guess REGEN is using this patch as well? I've never seen mention of the Japanese sports pad being different on this forum though, so at least the information is here now.
No, its not patching the ROM. And Japanese sportspad is not handled differently.
Its been quite long since I've worked on this stuff but at least I remember that it uses Z80 cycles to determine what nibble should be sent or something like that (seriously can't recall right now). When, I get access to my source, I'll send you my implementation.
|
- Joined: 26 Aug 2008
- Posts: 292
- Location: Australia
|
Posted: Sat Aug 01, 2009 3:28 pm
|
AamirM wrote No, its not patching the ROM. And Japanese sportspad is not handled differently.
Well that's interesting since the Japanese SMS supposedly doesn't have port 3F. I look forward to your findings! :)
|
- Joined: 26 Aug 2008
- Posts: 292
- Location: Australia
|
Posted: Sat Aug 01, 2009 3:56 pm
|
BTW, if you disable the YM2413 emulator in Regen you get the same behaviour as I've seen in other emulators and mine without the "Japanese sports pad", ie it doesn't work. It seems to be related to looking for the FM chip as to which region it does the sports pad. The patch Meka does seems to force the game into "export" region and it's right after it reads port F2 .
Maybe the way you handle FM emulation is forcing the game into "export mode".
|
- Joined: 07 Aug 2007
- Posts: 220
- Location: Yach, Germany
|
Posted: Mon Feb 20, 2017 8:48 am
|
Has any new information on the Japanese Sports pad come up?
It would make sense for the Japanese one to not rely on TH, since TH is not available on the Mark III.
The paddle controllers also would have worked differently in their Japanese vs. Western versions, with the Western ones relying on TH and the Japanese ones using an oscillator in the controller.
Philipp
|