Thursday, April 28, 2016

Apple II 4play Joystick Card





Introduction:

The 4play card plugs into any Apple II model that contains physical slots. Each card allows up to four digital (Atari configured) joysticks to be connected.


Background:

When was the last time you played a simultaneous multiplayer Apple II game with a group of friends? Was it on a keyboard with everyone squeezed around, each player trying to keep to their part of the keyboard or was it using the dual analog joystick configuration? Simultaneous multiplayer games give players a totally difference experience compared to single player games. The head to head challenge and comradery can lift gameplay to a whole new level. I've got great memories of doing this on other systems like arcade machines, home consoles (Nintendo 64, Wii, XBox), home computers (Commodore 64) and even on a Nintendo Game Boy using a link cable but not on the Apple II. I feel that the Apple II has always been lacking in this area.

The Apple II is designed with analog joysticks in mind but this doesn't stop it from supporting a multiplayer setup. In fact two joysticks can be connected using a Y splitter cable to give you that function. However, I'm only aware of a few games that took advantage it. One on One, SPY vs SPY and Superstar Ice Hockey are the few that come to mind.

Using special adapters the Apple II also supports digital joysticks. Several different methods have been derived to perform this task. A popular method was to map the digital signals to the analog axis limits. The beauty of this method was that certain games would just work with no software modifications required. The PQ Party Game system took this method a step further and instead of mapping the digital signals to the analog axis limits it instead divided up the analog ranges into multiple digital signals. This resulted in sixteen different digital positions ie four buttons for each of the four players. The big problem with all of these methods is that they are using the analog part of the game port interface. The analog interface is very slow compared to being able to drive digital signals straight onto the Apple II bus. For most cases this results in a practical limit of two simultaneous players.

Another common method of using digital joysticks with the Apple II is called the Atari Joyport option. This method uses the digital section of the game port interface. It uses multiplexing to turn three inputs and two outputs to obtain the ten digital signals required for two player gameplay. The games needed to be specially programmed to perform the multiplexing. There are quite a number of Apple II games which provide this option but due to the digital limitations of the game port interface this method is also limited to only two digital joysticks. It also suffered from a case of bad luck when the Apple IIe computer was released because the Apple IIe self-diagnostic test conflicted with the Joyport hardware. You can find more information on this method in this previous blog entry. http://lukazi.blogspot.com.au/2009/04/game-controller-atari-joysticks.html

The next logical progression would have been to use digital joysticks via the peripheral slots. There were digital joystick interfaces that took advantage of this. The one that I can think of is the Digital Joystick Interface by West Side Electronics. It only supported a single digital joystick but it was able to be used with either interrupt driven or polled communications. However I don't know of any commercial software which supported this setup. Why wasn't more effort put into supporting this type of interface method? In my opinion this is one of the easiest of hardware modifications you can do to a computer and the simplest in terms of software support. Perhaps it was due to the fact that there were different digital standards around and no one really knew which one would win out, or perhaps the chicken and egg problem played a big part ie most people would have had analog joysticks and the software base for analog joystick support was so extensive that also supporting digital may have been considered too big of a leap. I believe that digital joystick systems could have been supported with more ease than what most people realise.

Fast forward thirty odd years. Why would anyone be wanting to introduce yet another digital joystick interface at this point in time. Well, basically because none of the existing methods can provide four player gameplay. In early 2015 the group Ninjaforce released the long awaited game Kaboom! (a Bomberman clone). It was at the last OzKest gathering that we were given the opportunity to take advantage of this game's multiplayer features but I was disappointed in seeing this game being displayed more as a demo than the great multiplayer experience that it should have been. The keyboard interface just wasn't inviting enough to make this game shine to its fullest potential. I slept on it but didn't do anything about it. A few months later I attended a local Commodore 64 games night that is held annually. At this event I ended up playing Bomberman with a group of friends for a good part of the night. After that I wanted to give Kaboom! the interface it deserved.



If one was going to build a multiple joystick adapter, for the Apple II, that currently is not supported by any software where better to start than a blockbuster title and where software is still fresh in the developer's mind. I contacted Jesse from Ninjaforce to see if he was up for the project. He loved the idea so over several emails we worked out a design that both of us were happy with. I built the prototype and after a few hiccups it worked just as expected. The next problem was to get the solution to Jesse so he could test any Kaboom! modifications. I wasn't confident in the prototype surviving the trip so the other two options were to develop the card in an emulator or to build another card and send that. I was worried about timing issues popping up if choosing the emulator option so instead I concentrated on getting another card made. It was the right call as we did have some trigger debounce issues to sort out later on. The card is a really simple design so I took the opportunity to develop my printed circuit board design skills as someday I would like to get some of my other projects developed as well. The PCB was designed and sent off to a board manufacturer. When the boards arrived back I soldered one up only to find that it did not work. I was spitting chips (not literally) when I realised that I had made a schematic error that flowed through to the PCB design. I'm glad now that I only ordered a few boards. A short modification later and the card was working as expected. Off to Jesse it went.    




Debounce timing if required needs to be done in software.


Hardware specifications:

The hardware design of the card is extremely simple. It's a straight forward 32 bit digital input/output card with the output part stripped out. Cables have been added to support the Atari style digital joystick format. Due to popularity of the Atari/Commodore computers as game machines the Atari digital joysticks are still readily available, either in their original form or reproductions sold by third party manufactures. It was decided that the card should provide power for joysticks with auto fire and support joysticks with two/three fire buttons. Not that Kaboom! would need this but any future games should be given this option. We decided to build the card using simple TTL logic (as opposed to using chips such as the 6522 VIA) so that the boards would be easy to maintain, the replacement parts would be available for a long time to come and software would be easy to configure and program for.


Schematic of the Apple II 4play Joystick Card including supported joysticks and adapters.

The following is a list of joysticks and their supported functions:-

Atari Joystick
  Up, Down, Left, Right, Trigger 1

C64 Joystick
  Up, Down, Left, Right, Trigger 1

C64 Extended Joystick
  Up, Down, Left, Right, Trigger 1, Trigger 2, Trigger 3

Amiga Joystick
  Up, Down, Left, Right, Trigger 1

Amiga Extended Joystick
  Up, Down, Left, Right, Trigger 1

Amiga Extended Joystick plus special adapter
  Up, Down, Left, Right, Trigger 1, Trigger 2, Trigger 3

Amiga CD32 Joystick
  Not supported without an adapter

Amiga CD32 Joystick plus adapter (see above schematic)
  Up, Down, Left, Right, Trigger 1

Sega Genesis (Maga Drive) 3/6 button Gamepad
  Not supported without adapter

Sega Genesis (Maga Drive) 3/6 button Gamepad plus adapter (see above schematic)
  Up, Down, Left, Right, Trigger 1, Trigger 2

With more adapters other digital joystick standards may also be supported.

Note: When processing extended triggers the logic is inverted compared to Trigger 1. This is the result of how the Commodore 64 joysticks were wired up (digital signals were made from the POT pins). If using Amiga joysticks then the standard ones will work fine since they are wired in the Atari joystick format. Some Amiga joysticks have multiple buttons but these buttons are all wired to the Trigger 1 pin. These joysticks are ok use as well. However the Amiga joysticks that have been modified to provide extended triggers will not function correctly. This is because the wiring on the Commodore 64 extended triggers is different from the wiring on the Amiga extended triggers. You can plug these Amiga joysticks into the 4play card and it will not damage the card. The directions and Trigger 1 will work correctly but the extended trigger buttons will not function. Special adapters can be used (placed in between the specific Amiga joysticks and the 4play cables) if one would like to add the extended trigger functionality.

Different joystick standards can be supported via adapters. By not trying to support every digital format with the actual card allows the hardware to stay simple. The Amiga CD32 joysticks fall into this group. These joysticks are part digital and part serial therefore a special adapter is required to lock them into working as digital joysticks. The Sega Genesis (Maga Drive) 3/6 button gamepads use multitasking to read more buttons than there are lines going to the computer hence this gamepad requires an adapter to keep it sending only one set of signals which results in the Atari joystick format plus and extra trigger.


Software specifications:

To read the card, the first address of each slot is $C0N0 where N = 8 + slot number. (Slot1 = 49296, Slot2 = 49312, Slot3 = 49328 etc)
Joystick 1 is read from the first byte address, joystick 2 is read from the second byte address etc
The bit representation of each joystick is as follows :-

Bit 0 = Up, Active High
Bit 1 = Down, Active High
Bit 2 = Left, Active High
Bit 3 = Right, Active High
Bit 4 = Not Used, Always Low
Bit 5 = /Trigger 3, Active Low
Bit 6 = /Trigger 2, Active Low
Bit 7 = Trigger 1, Active High

The default value for each joystick is $60 (96 in decimal) ie a joystick that is not being used or an empty joystick port.

So to test which slot the card is in you just read the first four consecutive addresses for each slot and test to see if they all equal $60 (96). If peek(49296)=96 and peek(49297)=96 and peek(49298)=96 and peek(49299)=96 then the card is located in slot 1. If the joystick card is in slot 1 and you want to find out if the trigger is pressed on joystick 2 then you would read the byte using peek(49297). If bit 7 of this byte is 1 then the trigger is pressed. That is as complex as it gets. Now who wouldn't be able to add that into their software?

I believe that modified or specifically written software that supports this card should be given compliance. For example, if it supports a single digital joystick then it should be 4play-1 compliant, if it supports two joystick then it should be 4play-2 compliant, and so on. Most of the existing Apple II software is single player so a label like this would have been unnecessary however I see this card as a multiplayer tool so being able to instantly determine which games you would want to play given the number of people you have about would be ideal. Game developers take note. The interface is now available so porting those multiplayer games to the Apple II may now warrant a new look in.



In looking at converting some old software I started with an old favourite of mine ie the game Star Blazer. It is easier to convert the keyboard handler of the game than it is to convert the joystick handler. All one needs to do is to find the keyboard entry point then just use a hex editor to convert the keyboard direction keys to the 4play direction positions. If you don't mind hard coding the 4play to a specific slot and selecting 4play operation by selecting the keyboard option within the game then this is an extremely effective hack. The resultant code is smaller than the original keyboard handler code so you can fit it all into the existing game memory. The picture above shows the original code in the yellow square and the converted code in the red square. Given a bit more time and a bit more memory a better conversion could be performed without too much more effort.

My next set of conversions were on SuperPuckman and Pac-Man (Atari version). I chose this software for a very special reason. Pac Man was one of several arcade games that were designed to be played using a 4 way joystick. I've yet to hook this up and see if I can replicate the way this game was meant to be played. A 4 way joystick mechanically limits only one direction to be active at a time (compared to a standard Atari joystick which is an 8 way joystick ie when you select a diagonal position two directions are sent to the computer simultaneously).


Conclusion:

The 4play printed circuit board makes it easy to resolder the few pull-down resistors into pull-ups so that with different attachment cables the board becomes a 32 bit digital input card.

In the attached file you can find the schematics of the 4play, Y cable and the Digital Joystick Interface by West Side Electronics. Disk images containing examples and converted software are also in this file https://docs.google.com/file/d/0B5PVarmqxaOnUUN6OVIteWFqalk.

This project took a lot longer to implement than I had expected. Thank-you Jesse for being there to bounce ideas off, your effort in converting Kaboom! and your patience.

Jesse has done a outstanding job of converting Kaboom! to be 4play-4 compliant. Not only is the gameplay converted but so is the menu navigation. This makes playing, configuring and starting games a breeze even if you are sitting back in your lounge chair, away from the computer. You can get the latest version of this amazing game here http://www.ninjaforce.com/html/products_kaboom.html.

Thank-you to everyone else who helped out with tools, advice, testing and the product release. Your time and effort is greatly appreciated.

As I write this blog I'm itching to get back to my testing (huge smiley face). Happy gaming.


Update 4th May 2016.

The schematics have been modified with the card now being able to support two triggers from the Sega Genesis (Megadrive) gamepad (via the adapter). We are also looking into other controller options.

5 comments:

AverageGuy said...

Aside from the screenshot above, is there a programming reference? I'll support it.

Lukazi said...

S = 3 :Set the slot number, 3 in this example
J1 = 49280 + (S*16) :PEEK(J1) to get the status of Joystick 1
J2 = J1 + 1 :PEEK(J2) to get the status of Joystick 2
J3 = J1 + 2 :PEEK(J3) to get the status of Joystick 3
J4 = J1 + 3 :PEEK(J4) to get the status of Joystick 4

The status is broken up into bits MSB to LSB

Trigger1 : /Tigger2 : /Tigger3 : Not Used : Right : Left : Down : Up

There are examples on the provided disk which show how to determine the slot pro grammatically. Also on the disk are examples in basic and assembly for using the card and show you how to determine each status bit.

Cheers,
Alex.

Anonymous said...


Hi,

Just my 2 cents.

Having extra josyticks for the Apple II is great.

BUT I find the Atari joystick the worst joystick ever for the control. It is very painfull after few minutes.

The ONE button is also in the opposite of Apple spirit, where games at least use 2 buttons.

Even if the Amiga / Atari ST joystick like Quickshot II are less painfull, they are noisy (click click clik) and become rare nowdays (especially outside Europe).

IMHO, the best choice would be to create a card inside the Apple II to control 2 or 3 Genesys (Megadrive) joypads. They are not expensive (millions of units have been sold, retro companies like PlayAsia are still selling clones), they have 4 buttons (3+1) so the Start button could be mapped to ESC which in most Apple II games PAUSE the game. The 3 other buttons A B C could be mapped to Button 0 - Button 1 - Button 0, so depending of the game you can map it as expected (Lode Runner expect the Fire-Left to be mapped on the Left button).

Because the Apple II has already ONE joystock port, and most of us have such joystick, we simply need to add 2 or 3 extra joypads. So existing games would use classic analogic Apple II Joystickt and new (or patched) game would take advantage of extra ones.

Regards,

Lukazi said...

I've played with Atari joysticks for hours on end and I've never had any problems with them. I guess it's a personal thing. I do like gamepads and I agree that they are easier to use than joysticks.

The 4play card can support the Sega Genesis (Megadrive) gamepad in several different ways. This gamepad uses multiplexing to read two sets of buttons. I have shown in the blog one way to do this and that is by using an adapter to force it into Atari joystick mode (1 trigger). An alternate way is just to rewire the gamepad via the DE9 to give you 3 triggers or rewire straight to the card socket to give you 4 triggers. I think that's better than having more complicated hardware and more complicated software (to handle multiplexing). It's then up to the software to map the triggers to whatever Apple II keys you want.

Personally I'm not even bothering with that. Indirectly, Antoine gave me an idea which I am currently in the process of trying out. That is buying a usb gamepad. They are only about $4 including shipping. I'm stripping out the usb part and rewiring to get a gamepad with 3 triggers.

Cheers,
Alex.

Anonymous said...


Hi,

USB pad support would be great. That will remove the need of extra cable and drop down the final price of the card.

Genesis joypad are great but if you support them, I think that will be better to do not ask people to re-wire them. Most of people do not know (or don't want) to modify or solder anything in the joypad. And from memory, the PCB inside the joypad is covered by a kind of plastic layer so you have first to scratch it to remove the protection. Not easy task for every one. I would vote for a plug and play solution.