Jump to content

Photo

Next hardware project: snes2joy


51 replies to this topic

#1 ivop OFFLINE  

ivop

    Dragonstomper

  • 513 posts
  • Location:The Netherlands

Posted Sat Sep 16, 2017 11:46 AM

Hi all!

 

While I'm waiting on parts for the MIDI Interface, I spent the last couple of days working on a new hardware project (and avoiding working on a huge software project I'm also working on ;)).

 

Prototype:

 

snes2joy1.png

 

PCB:

 

snes2joy2.png snes2joy3.png

 

The SNES connecter's 3D model is a little borked (wild guess: some normals are flipped), but you'll get the idea.

 

Current firmware maps the D-Pad to its four directions, L to up, R to down (handy for diagonal jump games) and all other buttons to fire. This should make any SNES (compatible) controller work like a normal Atari Joystick.

 

There is however an extension. Select/Y/B are connected through 3 resistors to POTA. The same goes for X/A/Start and POTB. The resistors are chosen in such a way that all eight combinations of the three buttons can be clearly determined. Note that this is not a resistor DAC, because that would result in eight different voltages, but Pokey measures current at +5V. The firmware only outputs 5V "into" the resistors if the button is pressed. Otherwise the pin is tri-state (i.e. not connected) and the connected resistor is ignored. That way, eight currents can be measured by Pokey and the values are sufficiently apart. Several factors influence the actual readings, e.g. temperature, resistors used and Pokey itself. Therefore if a game was to be written to utilize these buttons, it has to calibrate itself first.

 

BTW J1 is an Arduino Nano (Clone), which can easily be programmed over USB (connector is already mounted on the Nano's PCB). I have decided to just piggyback it on top of this board, because I can never match its functionality for €2,=, which is what it costs to buy one from China, incl. S&H.

 

All files will be released eventually and will be open source.

 

Regards,

Ivo



#2 8Bitjunkie OFFLINE  

8Bitjunkie

    Moonsweeper

  • 293 posts
  • Location:Germany

Posted Sat Sep 16, 2017 12:20 PM

looks cool :-)



#3 Wrathchild OFFLINE  

Wrathchild

    Stargunner

  • 1,876 posts
  • Location:Reading, UK.

Posted Sat Sep 16, 2017 4:37 PM

Could firmware support a mode by which the A8 configures the button line as an output?

When this is low, the 4 joystick lines reflect the Up/Down/Left/Right states as usual.

When it is high, the 4 button states are output on the joystick lines instead.

 

[Edit] Start/Select would then be mapped to the two pots, going low when presses.
This could use a switch to permit the compatible mode to be used also.

 

Existing s/w could be patched for playing with multi-button support.
 


Edited by Wrathchild, Sat Sep 16, 2017 4:47 PM.


#4 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Sun Sep 17, 2017 4:03 AM

Sadly, the trigger inputs are handled by GTIA and cannot be set as outputs. But I see where's your going. It's way easier to read the buttons without the need to calibrate your POT readings.

 

The firmware could easily support different operating modes though. There's a reset button on the Nano, so pressing reset while holding a button combination could be used to select different modes.

 

A variation on your idea could be that snes2joy alternates between sending UDLR and ABXY, the first one without setting the trigger bit and the second one with the trigger bit set. Alternate, say, every 32 microseconds and the Atari should be able to sync to it and read both values within the duration of one scanline.



#5 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sun Sep 17, 2017 4:34 AM

I have always advocated that 2600/A8 games _must_ be played with a joystick but I totally love the SNES controller since it is so wonderful when playing SMW.

 

So I want one :)

 

What would be really cool is the possibility to make one of the buttons act as the space bar as this is the second action "button" in games like Dropzone. Could a OS hack be made to do that  so it is "transparant" for the games ? I guess some games probably scan the keyboard at a very low "level" ? not sure about that.


Edited by Level42, Sun Sep 17, 2017 4:35 AM.


#6 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Sun Sep 17, 2017 12:15 PM

Yeah, I agree that a joystick has more of the period feeling and reminds me of the eighties where I wrecked them (and my arm) by playing Decathlon :)

 

I also agree that the SNES controller is wonderful and IMHO the best controller up to the 16-bit consoles. They are still easily available. Mostly clones though, with varying level of quality.

 

As for the space bar, it indeed depends on whether the game uses the keyboard handler or not. Well, in the end, everything can be patched ;)

 

Suggestion for other modes of operation (of snes2joy I mean) are welcome!

 

Guess it could be nice to have one with auto-fire, i.e. A = single shot and B, X and Y "press" the fire button repeatedly at various frequencies.

 

 

 

Edit: perhaps should add an RGB LED to indicate which mode it is in? I have four GPIO pins left.


Edited by ivop, Sun Sep 17, 2017 12:34 PM.


#7 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sun Sep 17, 2017 2:19 PM

Was thinking.....could we create a little PCB inside the A8 machine that registers the value for "space bar" from the POT input and then simply "hard contacts" the space bar ?

 

Should be switchable of course for playing Paddle games.....



#8 Wrathchild OFFLINE  

Wrathchild

    Stargunner

  • 1,876 posts
  • Location:Reading, UK.

Posted Sun Sep 17, 2017 3:29 PM

Probably easier to patch the software

#9 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sun Sep 17, 2017 3:41 PM

Probably easier to patch the software

 

I'm not too sure about that. Patching each game is going to be a PITA.

 

Patching OS ROMs might only work partially if non-standard ways of scanning the keyboard are used by games.

 

Hardware always works. 



#10 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sun Sep 17, 2017 3:45 PM

Ivo, maybe a stupid question: do you use through-hole parts for a reason ? You assemble the PCB yourself ? I assume that saves money in production ?



#11 Mathy OFFLINE  

Mathy

    River Patroller

  • 2,460 posts
  • Location:Heerlen, NL

Posted Sun Sep 17, 2017 5:55 PM

Hello guys

 

If you want to switch pins to output, why not use "Multijoy-Technology".  The multijoy can select up to 16 joysticks.  Let's say you only want 8 SNES-controllers max.  That would mean you'll have 8 PIA pins per SNES-controller, 4 for Up, Down, Left and Right and 4 for the extra buttons.  Plus two fire button signals.  That should be enough for 6 buttons.

 

Ofcourse, the hardware doesn't have to support 8 SNES-controllers.  It's just the max you could use using this methode.  If you'd make the hardware such that it only supports one SNES-controller (but uses two joystick ports), it should even be possible to use multiple "SNES-adaptors" together with the Multijoy-Interface.

 

Sincerely

 

Mathy



#12 Brentarian OFFLINE  

Brentarian

    Moonsweeper

  • 327 posts
  • Location:Columbus, Georgia USA

Posted Sun Sep 17, 2017 7:21 PM

Robotron would be cool using a SNES controller if the buttons could be mapped to joy1 and joy2 directions.

#13 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Mon Sep 18, 2017 1:55 AM

Ivo, maybe a stupid question: do you use through-hole parts for a reason ? You assemble the PCB yourself ? I assume that saves money in production ?

 

Yes, having it assembled in China would cost more. But the main reason is that it's fun to build it yourself :) Also, it makes for a nice beginners project. SMD would not save much space anyway in this design.



#14 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Mon Sep 18, 2017 2:11 AM

If you want to switch pins to output, why not use "Multijoy-Technology".  The multijoy can select up to 16 joysticks.  Let's say you only want 8 SNES-controllers max.  That would mean you'll have 8 PIA pins per SNES-controller, 4 for Up, Down, Left and Right and 4 for the extra buttons.  Plus two fire button signals.  That should be enough for 6 buttons.

 

Ofcourse, the hardware doesn't have to support 8 SNES-controllers.  It's just the max you could use using this methode.  If you'd make the hardware such that it only supports one SNES-controller (but uses two joystick ports), it should even be possible to use multiple "SNES-adaptors" together with the Multijoy-Interface.

 

I have considered using two joystick ports, but decided against it because I want the interface to work out-of-the-box as a "normal" joystick. No patching, just plug and play. In this compatibility mode, the other buttons can be read through the POT inputs. This allows for games to be "slightly patched" to make, let's say, the start button work as expected, but this is not necessary.

 

Non-compatible modes, selectable by holding a certain button when powering on, are of course free to do what they want. I think I'll go with the endless stream idea, synced to a clock signal on the trigger line, which I formulated earlier.

 

This interface, in default mode, should work as a normal joystick through a multijoy BTW.



#15 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Fri Sep 22, 2017 9:35 AM

Still waiting on parts for the MIDI Interface...

 

snes2joy-tester.png

 

Firmware is done, testing succeeded for both modes!

 



#16 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Sat Sep 23, 2017 5:28 AM

Hmmm, I really disliked having to calibrate the POT readings for every combination (would be 8 readings per POTx, so 32 if you had two controllers!).

 

So, I changed the circuit a little. Now the compatibility works without callibration, but at the expense of not being able to read B and Y when Select is pressed and A and X if Start is pressed. That's not a big deal IMHO, because why would a game want those combinations anyway? When start or select are pressed, most of the time game pauses or brings up some kind of options menu. I cannot think of any game on any platform where you would have to hold the start or select button while fiddling with other buttons during gameplay. So now you can read B, Y, B+Y, Select on POTA and  A, X, A+X, Start on POTB.

 

In extended mode/endless stream mode (how should I call this?) you can still read every combination you manage to press :)



#17 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Fri Sep 29, 2017 8:14 AM

I have ordered prototype PCBs. Expected to arrive within 10-14 days.



#18 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sat Sep 30, 2017 2:32 AM

Cool....if you need a "beta tester" I live close enough ;););)

#19 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Sun Oct 22, 2017 7:11 AM

10 PCBs have arrived.

 

BOM: (9p pin header not shown)

step01.png

 

Solder resistors:

step02.png

 

Use hacksaw to get two rows of 15 pins/holes:

step03.png

 

Solder pin headers to Arduino Nano. It's easiest to put the headers in a breadboard, so you can be sure they are solder on straight:

step04.png

 

Forgot to photograph soldering on the SNES socket.

Put finished Arduino in female headers, again, so you can be sure they are solder straight on the PCB:

step05.png

 

Et voìla:

step06.png

 

Two small leds (green is compatibility mode, red is alternative mode):

step07.png

 

9p male pin header:

step08.png

 

Flash firmware, finished:

step09.png

 

Instead of a 9p pin header, you can also solder an old cut-off joystick cable directly to the PCB. They need to have ALL 9 pins connected. Some joysticks only pass through GND, trig and the four directions.

 

Now I'm deliberating on what to offer and at what price. I'm considering:

 

1) PCB + parts (kit) for those who want to DIY (firmware flashed already)

2) Fully build, except for the joystick cable (or send me one with all 9 pins passed through and I connect it to the PCB)

3) 1 or 2 of the above, including a clone SNES controller (might get a reduced price if I order a bunch at once)

 

plus shipping and handling...

 

BTW yesterday we tested the device on an Atari 2600 and a Commodore C64 and both worked flawlessly.


Edited by ivop, Sun Oct 22, 2017 7:13 AM.


#20 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Sun Oct 22, 2017 8:08 AM

BTW2 I'm also going to draw a PCB with the connector reversed, because all suppliers supply pairs of connectors and one of them is mirrored:

snesfront.png

 

Bending the pins to match the other is possible, but a pain in the neck and breaking a pin is too great a risk IMHO.

 

 

Edit: oh, just took a better look at the connectors and I can easily turn the pins 180 degrees. No need for a second type of PCB :)


Edited by ivop, Sun Oct 22, 2017 8:23 AM.


#21 Level42 ONLINE  

Level42

    Stargunner

  • 1,520 posts
  • Location:Ridderkerk, The Netherlands

Posted Sun Oct 22, 2017 8:35 AM

Option 1) for me please :)

#22 gozar OFFLINE  

gozar

    Dragonstomper

  • 802 posts
  • Location:Ohio

Posted Sun Oct 22, 2017 1:14 PM

10 PCBs have arrived.

 

BOM: (9p pin header not shown)

attachicon.gifstep01.png

 

Solder resistors:

attachicon.gifstep02.png

 

Use hacksaw to get two rows of 15 pins/holes:

attachicon.gifstep03.png

 

Solder pin headers to Arduino Nano. It's easiest to put the headers in a breadboard, so you can be sure they are solder on straight:

attachicon.gifstep04.png

 

Forgot to photograph soldering on the SNES socket.

Put finished Arduino in female headers, again, so you can be sure they are solder straight on the PCB:

attachicon.gifstep05.png

 

Et voìla:

attachicon.gifstep06.png

 

Two small leds (green is compatibility mode, red is alternative mode):

attachicon.gifstep07.png

 

9p male pin header:

attachicon.gifstep08.png

 

Flash firmware, finished:

attachicon.gifstep09.png

 

Instead of a 9p pin header, you can also solder an old cut-off joystick cable directly to the PCB. They need to have ALL 9 pins connected. Some joysticks only pass through GND, trig and the four directions.

 

Now I'm deliberating on what to offer and at what price. I'm considering:

 

1) PCB + parts (kit) for those who want to DIY (firmware flashed already)

2) Fully build, except for the joystick cable (or send me one with all 9 pins passed through and I connect it to the PCB)

3) 1 or 2 of the above, including a clone SNES controller (might get a reduced price if I order a bunch at once)

 

plus shipping and handling...

 

BTW yesterday we tested the device on an Atari 2600 and a Commodore C64 and both worked flawlessly.

 

I'd be interested in options 2 or 3.



#23 ivop OFFLINE  

ivop

    Dragonstomper

  • Topic Starter
  • 513 posts
  • Location:The Netherlands

Posted Fri Oct 27, 2017 8:34 AM

Update: Now that I'm also getting into 3D modelling and printing, I'm thinking about creating an enclosure for this project as well. Also, the idea of people sending me 30 y.o. cut-off joystick cables that might or might not work is putting me off.
I could modify the board for something like this (idea of SenorRossie), but that still doesn't fit our joystick port correctly. So how about 3D printing DB9 connectors without the mounting flaps/wings/whatever they're called? I've googled around, but no models seem to exist. Only shells for modern DB9 connectors. I think it must doable, so I'm looking into this next week.

 

Edit: hmm, where did I store the Atari joystick patent of which I borrowed an image for my avatar. Perhaps it contains a proper dimensions diagram of the connector, too?


Edited by ivop, Fri Oct 27, 2017 8:59 AM.


#24 Mathy OFFLINE  

Mathy

    River Patroller

  • 2,460 posts
  • Location:Heerlen, NL

Posted Fri Oct 27, 2017 4:16 PM

Hello Ivo

 

I believe I read somewhere that you can take the metal part of the modern DB9 connector off.

 

Sincerely

 

Mathy



#25 Matej OFFLINE  

Matej

    Moonsweeper

  • 323 posts

Posted Fri Oct 27, 2017 7:00 PM

You can buy china megadrive gamepad for 3usd... or contact manufacturer of those.I am sure that joy db9 cable is still in production in Asia...




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users