15 April 2020, 22:56 | #21 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
They're easy connectors to find anyway, and the pin numbers are usually embossed on the connectors themselves (albeit very small numbering). This diagram is for a serial port, but the pin numbers are the same. Bear in mind that the female pin numbering is mirrored, so that pin 1 connects to pin 1 etc.
As for reading them, I've only written Blitz Basic code to read MD pads, so you'd probably want someone writing routines in ASM instead as that would be better suited to integrating into your slaves. But it's really not that involved. Detection is easy in theory because a normal D-pad or joystick can't have left and right pressed simultaneously, but on the Amiga there's a 25% chance a mouse will give the very same signal, so you couldn't rely on it. |
15 April 2020, 23:13 | #22 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
|
blitz basic routine would be a good start if you can share it. And for the detection, one can cheat by assuming that a mouse isn't likely to be plugged in port 1, or this can be forced by a slave configuration. And that would only affect 2-player games.
|
16 April 2020, 00:55 | #23 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
Indeed, having it as a force option in configs would be good. I'll dig up some code for it tomorrow.
|
17 April 2020, 23:33 | #24 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,369
|
Okay, sorry about the delay, but instead of just posting code segments, I put together a quick and dirty executable. It's attached, along with Blitz source, and when run from the Shell, it will detect any MD pads attached and output any button or D-pad activity. I included 6-button reading and detecting code, but I've only tested it with a 3-button pad because I don't actually have a 6-button pad. In theory it should work anyway...
There's some extra stuff in there to make it a self contained executable. I originally included management of the potgo resource for multitasking friendliness, but with most games that's out the window so I took some of it out again for simplicity. This means though that it doesn't play nice with other hardware using pin 5 of the ports at the same time, such as scroll wheel mice or CD32 pads. It still tries to be sensible by restoring the status of the register when reading is completed. The key routines are as follows: The joydir{} function returns a byte where the low 4 bits represent the directions, up, down, left, right from LSB up. The port parameter tells it which game port to examine. It's pretty straightforward and reads the registers directly. Running it in-line with other code might be more efficient because you could drop all the shifting that neatens things up here, but this keeps the routine self-contained. Code:
Function.b joydir{port.b} SHARED debug result.b = 0 If port = 1 bytes.w = Peek.w($DFF00C) Else bytes.w = Peek.w($DFF00A) End If bit9.w = bytes & %0000001000000000 bit8.w = bytes & %0000000100000000 bit1.w = bytes & %0000000000000010 bit0.w = bytes & %0000000000000001 result = result | (((bit9 LSR 1) EOR bit8) LSR 8) ; Up result = result | (bit1 LSL 2) ; Right result = result | (bit1 EOR (bit0 LSL 1)) ; Down result = result | (bit9 LSR 7) ; Left Function Return result End Function Code:
Function.b joybuttons{port.b} SHARED debug result.w = 0 buttonbyte.b = Peek.b($BFE001) ; Button 1 / pin 6 If port = 1 result = (buttonbyte & %0000000010000000) LSR 7 Else result = (buttonbyte & %0000000001000000) LSR 6 End If ; Button 2 / pin 9 bytes.w = (Peek.w($DFF016) LSR (9+(port*4))) result = result | (bytes & %0000000000000010) bytes.w = (Peek.w($DFF016) LSR (6+(port*4))) result = result | (bytes & %0000000000000100) Function Return result End Function !delayloop{50} is a macro that inserts a simple delay loop that does the given number of reads from a CIA. This is because a certain amount of time (something like 200-300 microseconds) is needed after switching the pin 5 state before it takes effect, and CIA reads are a predictable time, unlike simply busy-looping on the CPU which is obviously CPU speed dependent. This appears to work fine and gives a safe, reliable delay on both an 030 and an 060, but there's probably scope for fine-tuning there. The controller is cycled high and low until the third low cycle, which makes no difference to a 3-button pad's behaviour, but a 6-button pad will use to report all D-pad directions active on this cycle. You can then check if the bit pattern matches a 3-button of 6-button controller, bearing in mind that a mouse can also generate those pattern coincidentally. Code:
For i.w = 0 To 1 If controllers(i)\potalloc If i = 1 potgoon.w = %0010000000000000 ; Pin 5 low potgooff.w = %0011000000000000 ; Pin 5 high Else potgoon.w = %0000001000000000 potgooff.w = %0000001100000000 End If Disable_ savepotgo.w = Peek.w($DFF016) Poke.w $DFF034,potgoon !delayloop{50} Poke.w $DFF034,potgooff !delayloop{50} Poke.w $DFF034,potgoon !delayloop{50} Poke.w $DFF034,potgooff !delayloop{50} Poke.w $DFF034,potgoon !delayloop{50} dir = joydir{i} Poke.w $DFF034,potgooff !delayloop{50} Poke.w $DFF034,savepotgo Enable_ End If If dir & %1100 = %1100 ;dpad\left <> 0 AND dpad\right <> 0 NPrint "Megadrive controller detected on port ", i \mode = 1 ; Now check for 6-button pad If dir = %1111 ;dpad\up <> 0 AND dpad\down <> 0 NPrint "6-Button controller detected" \mode = 2 Else NPrint "3-Button controller detected" End If End If Next i If controllers(0)\mode = 0 AND controllers(1)\mode = 0 NPrint "No Megadrive controllers detected" End End If The "standard buttons" are B and C, and can be read directly from the output of the joybuttons{} function. Pin 5 is set low then and joybuttons{} is used again to read A and Start before setting it high again (high should be the default resting state). Then, if a 6-button controller was detected, the pad is cycled low, high, low (the controller ID cycle) and high (the extra buttons cycle). When in this state, reading the D-pad instead reads the extra 4 buttons, with up corresponding to Z, down to Y, left to X and right to Mode. These 4 bits from joydir{} are simply added to the upper half of the results byte, so all 8 bits represent all 8 buttons. Code:
Function.b readpad{port.b} SHARED allocmask, debug, controllers() result.b = 0 If port = 1 potgoon.w = %0010000000000000 potgooff.w = %0011000000000000 Else potgoon.w = %0000001000000000 potgooff.w = %0000001100000000 End If Disable_ savepotgo.w = Peek.w($DFF016) ; Read standard buttons !delayloop{50} result=(joybuttons{port} & %0000000000000011) LSL 1 Poke.w $DFF034,potgoon !delayloop{50} ; Read alternative buttons buts.w = joybuttons{port} & %0000000000000011 result = result | ((buts & %0000000000000010) LSL 2) ; Start result = result | (buts & %0000000000000001) ; A Poke.w $DFF034,potgooff !delayloop{50} If controllers(port)\mode = 2 ; 6-button pad Poke.w $DFF034,potgoon !delayloop{50} Poke.w $DFF034,potgooff !delayloop{50} Poke.w $DFF034,potgoon ; Cycle 3 low !delayloop{50} Poke.w $DFF034,potgooff ; Cycle 3 high !delayloop{50} buts.w = joydir{port} LSL 4 result = result | buts End If Poke.w $DFF034, savepotgo Function Return result End Function |
18 April 2020, 01:01 | #25 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
|
That seems non-trivial. Asm conversion won't be a problem. Testing / detecting all joypads properly will take more time thanks, it helps.
(I'm currently fighting to make non-standard CD32 adapters work in some games) |
05 January 2023, 00:55 | #26 |
Registered User
Join Date: Nov 2017
Location: NRW/Germany
Posts: 31
|
unfortunately, the combination does not work for me. Which firmware version does the Rys MK2 adapter have?
|
05 January 2023, 07:40 | #27 |
Missile Command Champion
Join Date: Aug 2005
Location: Germany
Age: 52
Posts: 12,453
|
I don't know which version exactly. But have you tried to update?
https://retro.7-bit.pl/?lang=en&go=pomoc |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sega Megadrive official 6 Button Pad on CD32/A1200?!? | Ebster | support.Hardware | 60 | 28 December 2021 10:26 |
Wireless Controllers | Washac | support.OtherUAE | 3 | 01 March 2012 22:21 |
FS: Sega Megadrive II with all leads/controllers + games | Smiley | MarketPlace | 3 | 05 July 2011 00:54 |
Sega Saturn or Dreamcast for A1200 Memory or 030 Accelerator | fitzsteve | Swapshop | 3 | 09 September 2009 14:07 |
Sega controllers? | one1 | support.Hardware | 33 | 24 August 2007 15:43 |
|
|