JeST - PSX to Atari Style JoyPad/Mouse Adapter

This project took about 2-months to be completed.  The initial objective was to get the core 'joystick' features in place, be it up down left right fire, and then to expand on them.  What actually sits in the middle of it all is a command handler, which sounds straight forward in conversation, yet squeezing it into a 256-byte block written is RISC assembly language is a feat to say the least.  That leaves 768-bytes to do everything else.  It certainly is all packed in there!


Features

Aside from the main requirements of, up down left right fire, JeST does a whole lot more.  It certainly seemed a waste to have this little computer on a chip and not to use it.

* Atari style joystick emulation with thumbpad
* Atari ST mouse emulation with thumbstick and thumbpad
* Thumbstick buttons operate as mouse buttons
* Variable thumbstick mouse speed
* Fully assignable fire buttons
* Fully assignable autofire buttons
* Fully assignable auto leftright buttons (e.g. HyperSports)
* Autofire repeat rate can be changed
* FIRE1 mapped to pin-6 (left button)
* FIRE2 mapped to Pin-9 (right button)
* FIRE3 mapped to Pin-5 (middle button, 7800 FIRE2)
* Amiga 3-button mouse emulation
* Tested with Atari ST, Amiga, Commodore-64, Sinclair Spectrum
* Compatible with Atari 7800 (uses pin-5)
* Fully user configurable
* Four savable user setups
* Original 'factory' setups recoverable
* Draws 30mA 5v in operation
* Extremely small and tidy, it couldn't be smaller


The End Result

This is what we ended up with.

PCBCableControllerManual


The Command Handler

Command handler sounds very important and critical doesn't it!  Well it is!  OK, so what happens?  Essentially you have 2-bytes which are collected from the PSX controller when a certain combination of buttons are pressed.  Once you have those two bytes, you then have to decide what to do.  The command handler works down the list in a heirarchical fashion, first matching the leading byte, and then matching the trailing byte.  This all sounds good so far.  That is until you realise that the RISC assembly language of these processors has only 35-instructions.  Most are mathmatical functions, whereby flags are set depending on what happens.  There is no 'IF A=B THEN DO C' function available, so you have to do it all by hand.

The following few lines of code are what's required to see if a number matches.  This is the much taken for granted 'IF A=B THEN DO C.'

MOVLW
XORWF
BTFSC
CALL
0x10
psx_byte5_select_cmd_, W
STATUS, Z
CMD_VAR_0910

When you consider that there's about 20-commands in JeST at the time of writing, version _006, it all starts to mount up.  That snippet of code is 8-bytes, and when multiplied by 20 that equals 160-bytes, which doesn't even include leading byte or the procedures which are called.  Certainly the fair bulk of the firmware which JeST runs is dedicated to the additional features and flow control.


Roughly how it works

A flow chart.  There!  This covers the core operation of JeST, but doesn't include things such as the command handling.  For the majority of the time in normal use this is precisely what JeST does.