Giter Site home page Giter Site logo

sukkopera / openpsx2amigapadadapter Goto Github PK

View Code? Open in Web Editor NEW
57.0 8.0 11.0 11.43 MB

Playstation to Commodore Amiga/CD32 Controller Adapter

License: Other

C++ 95.74% Python 4.26%
amiga amiga-hardware amiga-game playstation playstation-2 joystick joystick-control joystick-device joysticks openhardware

openpsx2amigapadadapter's Introduction

OpenPSX2AmigaPadAdapter

OpenPSX2AmigaPadAdapter is an Open Hardware adapter that allows using a Sony PlayStation controller on Commodore computers, including the Commodore 64, Amiga and CD32.

Board

Summary

The Commodore Amiga CD32 came with cumbersome and fragile controllers, most of which did not survive the challenge of time. While many third-party replacements have surfaced in the meantime, most of them are not as solid and comfortable as the ubiquitous Sony PlayStation controllers. These have more than enough buttons, are cheap and most people are familiar with them, as the same basic design has been around for nearly 25 years. This means they would be a very good replacement, if they just didn't use a different connector and communication protocol.

OpenPSX2AmigaPadAdapter is a simple Arduino-based board that adapts the connector and translates the protocol, allowing the use of many PlayStation controllers on Commodore computers. It can either behave as a simple 1/2-button Atari-style joystick or as a full-fledged 7-button CD32 gamepad. It can also appear as an Amiga mouse.

Operating Modes

The adapter has two leds:

  • LD1 lights up steadily when a supported controller is plugged in. It blinks when no controller - or an unsupported one - is connected.
  • LD2 indicates the current operating mode, to be interpreted as follows.

Two-Button Joystick Mode

When the adapter is powered on, it defaults to Atari-style Two-Button Mode, which is indicated by LD2 being off.

This mode has been throughly tested on several Amiga models, but it should work wherever an Atari-style joystick is supported, including the Commodore VIC-20, Commodore 16 (through an adapter), Commodore 64, etc. See below for a compatibility table.

While in this mode, the adapter supports different button mappings, which have been carefully designed and tailored to different game genres. The mappings can be switched by pressing Select in combination with other buttons. LD2 will blink quickly a few times to indicate what mapping has been activated.

Standard Mapping: Select +

Standard Mapping is the simplest mapping possible: both the D-Pad and Left Analog work as direction buttons. is B1 and is B2. This is the default mapping as it should be usable just about in every game out there. It might not be the most natural these days, but it's the way the game was meant to be played by the developers, thus it should never fail you.

Note that very few games were originally made to take advantage of two buttons, as even fewer controllers had that many (!) those days. Here is a list of Amiga games that somehow support two buttons, if it can be any useful.

LD2 will blink once when this mapping is activated.

Racing Mapping 1: Select +

Racing Mapping 1 is useful for all those racing games that use to accelerate and to brake. These have been mapped to and , respectively, which should make them much more natural to play. When accelerating and braking at the same time, braking wins. Left Analog can be used to steer, but its vertical axis is ignored, to avoid accidental accelerating/braking. The D-Pad is fully functional and is handy when moving through menus. B1 and B2 can be found on and .

This mode is probably best suited to games that do not involve shifting gears, as downshifting is usually performed through + B1 which is pretty hard to achieve ( + ).

LD2 will blink twice when this mapping is activated.

Racing Mapping 2: Select +

Racing Mapping 2 is an alternative mapping for racing games that was inspired by GTA V. It lets you use R2 (or R1) to accelerate and L2 (or L1) to brake (which means they map to and , respectively). B1 is mapped to its natural position. Steering and the D-Pad work as in Racing Mode 1.

Accidentally, this control scheme was found out to be very comfortable with games that use B1 to accelerate and and to shift gears. Since is probably used for braking as well, it has also been mapped to , while B2 has been moved to .

LD2 will blink three times when this mapping is activated.

Platform Mapping: Select +

Platform Mapping is very similar to Standard Mapping, it just makes jumping way easier on a joypad and more natural to all the Mario players out there, by replicating on . Consequently, B2 has been moved to .

LD2 will blink four times when this mapping is activated.

Custom Mappings: Select + R1/R2/L1/L2

What if the built-in mappings are not enough? OpenPSX2AmigaPadAdapter allows you to make your own! And you can have up to four different ones, which are stored internally so that they can be recalled at any time. By default they behave similarly to the Standard Mapping, but they can be customized so that any button produces either the press of a single button or even of a button combo!

The programming procedure is as follows:

  1. Press and hold Select, then press and hold one of R1/R2/L1/L2 until LD2 starts blinking, finally release both buttons. You are now in Programming Mode.
  2. Press the button you want to configure. LD2 will flash quickly a few times.
  3. Press and hold the single button or button combo you want to be assigned to the button you pressed before. At this stage the D-Pad directions have their obvious meaning, while represents B1 and represents B2. LD2 will again flash quickly a few times.
  4. Release the button or combo you were holding.
  5. Repeat steps 2-4 for every button you want to customize.
  6. When you are done, press Select to store the mapping and leave Programming Mode. LD2 will stop blinking and you will be back to Two-Button Joystick Mode.

Note that a mapping you have just programmed is not activated automatically, so you will have to press Select and one of R1/R2/L1/L2 (and release them quickly) to switch to it.

The Custom Mappings cannot be configured so that overrides or so that the vertical axis of Left Analog is ignored, still they might be useful here and there. For instance, having B1 + on and B1 + on makes the Amiga version of Golden Axe much more playable.

Commodore 64 Mode

Button 2 on Commodore 64 usually behaves in the opposite way at the electrical level, with respect to the other buttons. So a tweak can be enabled to invert the behaviour of button 2, use it if you find that your game of choice always sees it pressed or if it triggers on release rather than on press.

Just hold Select and press Start briefly. LD2 will flash once when this tweak is enabled and twice when it is disabled.

Mouse Mode

Whenever the right analog stick is moved, the adapter switches to Amiga Mouse Mode. In this mode, the right stick emulates the movements of a mouse. Movement speed is somewhat proportional to how far the stick is moved.

This mode can be useful as an emergency mouse, and it will be particularly handy if you have the adapter connected to port 1 of an Amiga computer and you need to use a mouse for short while (maybe to do some settings in a cracktro). Instead of unplugging the adapter, plugging in a mouse, and then the adapter again, you can take advantage of this feature.

Mouse mode is indicated by LD2 blinking. Press any direction on the D-Pad to go back to Joystick or CD32 Mode.

CD32 Controller Mode

When the adapter is connected to a CD32 console, it will automatically switch into this mode, which will emulate all 7 buttons of the original CD32 controller. LD2 will light up steadily.

By default, buttons are mapped as follows:

  • : Red
  • : Blue
  • : Yellow
  • : Green
  • L1/L2/L3: L
  • R1/R2/R3: R
  • Start: Start/Pause

If you press Select, the 4 main buttons get "rotated":

  • : Red
  • : Blue
  • : Yellow
  • : Green

Both the D-Pad and Left Analog always work as direction buttons.

Components and Assembly

The board is basically a customized Arduino Uno, this means it was designed to work with an ATmega328P microcontroller, but you can also use ATmega88/A/P/PA or ATmega168/P microcontrollers, as they are pin-compatible and slightly cheaper. The A/P/PA suffixes usually identify somewhat minor chip revisions, the board should work with all of them. If you can, use P or PA versions, which consume less power. Note that at the moment the firmware uses 99% of the flash space available on an ATmega88 and any possible future improvements and/or new features are likely to overflow that, so you'd better use an ATmega168 at least.

A noteworthy exception to this rule is the ATmega328PB, which is NOT 100% pin-compatible with the 328P. Nevertheless, it MIGHT just work as well. It might also destroy whatever you connect the adapter to, so do it at your own risk.

You are recommended to solder the microcontroller first. The TQFP-32 package is easier to solder than it looks, watch some videos on YouTube and develop your own technique. Just make sure to orient it correctly.

Solder the oscillator then. You can either use a through-hole crystal with its caps (these will depend on the crystal, but usually 18-22pF are a good bet) or a 3-pin resonator. Whichever you choose, it shall have a frequency of 16 MHz. If you choose the crystal, you might want to put some insulation tape under it to avoid it touching the pads for the resonator.

Solder all the remaining parts in the order you prefer, just keep the controller connectors last.

Note that the PlayStation controller is powered at 3.3V and the interface signals use the same voltage. Due to the particular circuit used for level shifting (the microcontroller works at 5V), the MOSFETs should really be BSS138.

The PlayStation controller connector can be found from many Chinese sellers as a spare part. Get one with 90° pins, otherwise the adapter will be pretty awkward to use. The pins will be pretty short, but you should manage to solder it in place. Make sure it sits level on the board, otherwise it might not fit in the 3D-printable case, which you are recommended to use in order to make the adapter more mechanically solid. In alternative, some hot glue behind the connector (where the pins are) seems to do the same job, but it won't look as pretty.

Hint: If you don't have the PCB, you can build a full adapter with an Arduino Uno/Nano/Whatever board. This is not supported though, so you are on your own, but all the information you need is in the schematics or in the firmware code :).

Firmware

Before you can use the adapter, you will need to load some firmware (i.e.: an Arduino sketch) on it. This can be found under the firmware directory, along with instructions.

Compatibility

Computers and Consoles

System Compatible Notes
Commodore Amiga (All models) Yes Tested on A500+ and A1200 (1.D3), it is expected to be compatible with all models in both 2- and 7-button Joystick modes and in Mouse mode.
Commodore Amiga CD32 Yes Both 2- and 7-button Joystick modes and Mouse mode. Games not using lowlevel.library might be a bit of hit-and-miss, please report any misbehaviours.
Commodore CDTV Maybe Not tested yet, but expected to work in 2-button Joystick mode and Mouse mode through a connector adapter.
Commodore 64 Yes Tested in 2-button Joystick mode, but second button untested. Mouse mode might damage CIA chips though, be careful not to turn it on!
Commodore 16 Maybe Not tested yet, but expected to work in 2-button Joystick mode through OpenC16JoyAdapter. C16 only supports Button 1 though.
Commodore VIC-20 Maybe Not tested yet, but expected to work in 2-button Joystick mode. Be careful with Mouse mode.
Sega Master System No Would probably work in 2-button Joystick mode if power was routed from pin 5 on the SMS controller port to pin 7 of the adapter.
Sega Mega Drive/Genesis No Would probably work as an SMS controller with the same mod as above. Some more pin rerouting AND a custom firmware could make it appear as a Mega Drive 6-button controller.
MSX No Would probably work in 2-button Joystick mode by swapping a few pins on the controller port.

Controllers

The latest versions of the OpenPSX2AmigaPadAdapter firmware use PsxNewLib to read the PlayStation controller. This makes it compatible with (almost) all controllers.

Please refer to the PsxNewLib Compatibility List for details.

Current Consumption

Following are the results of some rough measurements:

  • An ATmega88PA-based OpenPSX2AmigaPadAdapter with an original Sony Dual Shock/Dual Shock 2 controller connected draws about 20 mA.
  • Consumption rises to 25 mA with the dongle of my EastVita wireless controller, when the controller is connected. It peaks to 35 mA while it is searching for the controller.
  • Using an ATmega328P bumps all consumptions by 5 mA.

This means that the current absorbed by the adapter is "reasonable" and that it should be safe to use in all cases. It is well below the 100 mA maximum available from any Amiga controller ports, for instance.

Enclosure

Three different 3D-printable enclosures are currently available for this board:

  • The first one was kindly contributed by Petros Kokotis and needs screws for assembly.
  • A second one was designed by Lemaru and uses a snap-in design. It also has holes for the LEDs.
  • Another one was made by Gary Ogden and is better suited for use with the CD32, as it has some kind of bottom support.

My gratitude goes to all the three guys for their great work and support!

Releases

If you want to get this board produced, you are recommended to get the latest release rather than the current git version, as the latter might be under development and is not guaranteed to be working.

Every release is accompanied by its Bill Of Materials (BOM) file and any relevant notes about it, which you are recommended to read carefully.

License

The OpenPSX2AmigaPadAdapter documentation, including the design itself, is copyright © SukkoPera 2019-2020.

OpenPSX2AmigaPadAdapter is Open Hardware licensed under the CERN OHL v. 1.2.

You may redistribute and modify this documentation under the terms of the CERN OHL v.1.2. This documentation is distributed as is and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES whatsoever with respect to its functionality, operability or use, including, without limitation, any implied warranties OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE or infringement. We expressly disclaim any liability whatsoever for any direct, indirect, consequential, incidental or special damages, including, without limitation, lost revenues, lost profits, losses resulting from business interruption or loss of data, regardless of the form of action or legal theory under which the liability may be asserted, even if advised of the possibility or likelihood of such damages.

A copy of the full license is included in file LICENSE.pdf, please refer to it for applicable conditions. In order to properly deal with its terms, please see file LICENSE_HOWTO.pdf.

The contact points for information about manufactured Products (see section 4.2) are listed in file PRODUCT.md.

Any modifications made by Licensees (see section 3.4.b) shall be recorded in file CHANGES.md.

The Documentation Location of the original project is https://github.com/SukkoPera/OpenPSX2AmigaPadAdapter/.

Support the Project

Since the project is open you are free to get the PCBs made by your preferred manufacturer, however in case you want to support the development, you can order them from PCBWay through this link:

PCB from PCBWay

You get my gratitude and cheap, professionally-made and good quality PCBs, I get some credit that will help with this and other projects. You won't even have to worry about the various PCB options, it's all pre-configured for you!

Also, if you still have to register to that site, you can use this link to get some bonus initial credit (and yield me some more).

Again, if you want to use another manufacturer, feel free to, don't feel obligated :). But then you can buy me a coffee if you want:

Buy Me a Coffee at ko-fi.com

Get Help

If you need help or have questions, you can join the official Telegram group.

Thanks

openpsx2amigapadadapter's People

Contributors

kokotisp avatar ogg1e avatar sukkopera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openpsx2amigapadadapter's Issues

it's not an issue just an question

I asked about the ressonator and the crystal... but then I read your read.me... ;)

now I used the ATMEGA 88, there was lag... not with the 328 (I removed the 88, and soldered the 328p) not that many, but annoying. could be an malfunction chip? I wonder...

ha another cup of coffe to you.. for you to give to charity... if you want Sukkopera!
I bought 5 pcb from pcbway.... so I already give one to a friend of mine... ;) that I don't know in person... free of charge! the way this should allways be... FREE or as we portuguese say... GRATIS... is better!

CD32 mode constantly when connected to port 1 of C64

Doing more testing and found that while connected to port 1 of the C64 it is constantly in CD32 mode where LED 2 is constantly lit.
Port 2 works as expected and I can change do different modes etc.

Also in my Amiga 500 it seems to default to CD32. Is there are way to change this to a 2 button default mode is needed?

Thanks

Some questions regarding design

Hi!

First off, sorry for opening an issue for something that clearly isn't an issue. Secondly, thank you so much, this seems like a very interesting project and very well documented, cleanly implemented and open one at that.

So, I'm thinking of cobbling one of these together as I've got most of the parts lying around and I do want a better controller for my Commodore machines. I just have a few questions.

Why the bidirectional level shifting for the controller? ps_data_3v3 and ps_ack_3v3 are outputs and could be directly connected to the MCU (maybe with a weak pull-up and/or a current limiting resistor). ps_cmd_3v3, ps_clk_3v3 and ps_attn_3v3 are inputs and could use a simple voltage divider to get from 5 to 3.3v. Or am I missing something?

Why the pull-up on ami_fire? I guess there is a reason, I'm just curious as to what it is :)
Same for ami_poty (though I can guess that this has to do either with CD32 or possibly C64 button 2)?

Finally, what are the capacitors on ami_potx and ami_poty about? 820p and 220p seems small and very specific. I'm guessing again this has to do with signal conditioning for CD32 mode. How crucial are these (and their values)?

Thanks again for your very cool and very well maintained work!

Best regards from Sweden,
Mats

Force CD32 mode for regular Amiga

Hello there. Great project. I am just about to finish a board and just realised that you mention the controller switches to CD32 mode automatically when connected to CD32. Is there a way to force this so can be used in a regular Amiga 500 or 1200 etc?
A lot of games are being ported over using WHDLoad and would be great to used CD32 mode controller.
Thanks and sorry if this is a silly question.

Atmega88PB and Atmega328PB

Hey there. I have a bunch of Atmega88PB and Atmega328PB chips available which I would like to finally use for something.
There is a bootloader for the 328PB in the github but nothing for the 88PB. Can I just use the bootloader from Ardunio IDE?
Last thing the firmware 88p and 328p. Can I use these files with the PB chips or do I have to recompile the binaries again? Probably a silly question but I am not great with these things.

Thanks!

Power saving

The following lines should turn off a few unused AVR peripherals, helping us save some power. I don't know how effective the saving will be, but I think it's a good idea to try and minimize our current draw, as some PSX controllers might already be quite demanding:

ADCSRA &= ~(1 << ADEN);  // Turn off ADC
ACSR |= (1 << ACD); // Turn off Analog Comparator
DIDR1 |= (1 << AIN1D) | (1 << AIN0D); // Turn off AIN digital input buffer
PRR |= (1 << PRTWI) | \  // Turn off TWI/I2C Interface
       (1 << PRTIM2) | \  // Turn off Timer 2
       (1 << PRTIM1) | \  // Turn off Timer 1
       (1 << PRSPI) | \  // Turn off SPI Interface
#ifndef ENABLE_SERIAL_DEBUG
       (1 << PRUSART0) | \  // Turn off Serial Port
#endif
       (1 << PRADC);   // Turn off ADC

The last command might make the others redundant. I guess we should take some measures.

B2 always pressed on C64

Button 2 on the C64 works differently from what we are doing now. The few games that support it expect pin 9 to be HIGH when it is pressed and LOW when it is released, which is exactly the opposite of how all other pins work.

So currently it will be reported as always pressed except when it is actually pressed.

We should come up with a way of enabling the logic levels for B2 to flipped.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.