How to emulate an Atari ST from inside

Dr Andrew Lewis penned this Atari emulation tutorial especially for the latest issue of HackSpace magazine. If you like what you see, consider subscribing so you never miss out again.

How to emulate an Atari ST from inside

Like the Commodore Amiga, the Atari ST was an iconic home computer, offering many people their first glimpse of the 16-bit digital world. After almost 40 years, it’s still an engaging design, although the internal hardware may need a few repairs and upgrades to fit in with the modern standards. In this article, you’ll see how to replace the internal electronics of an Atari-ST with a Raspberry Pi, while retaining the original keyboard. None of the changes performed require modifications to the original case or to the circuitry of the Atari, making the process completely reversible in the future.

The Atari was hacked at some point to add a simple audio amplifier with an internal speaker, and an audio output on the rear 
of the case
The Atari was hacked at some point to add a simple audio amplifier with an internal speaker, and an audio output on the rear of the case

Simulating a classic system on new hardware is nothing new, and after 40+ years of technological advancement, emulating home computers, classic mainframes, and even full-blown arcade machines is well within the reach of a small computer like the Raspberry Pi. What desktop emulation doesn’t have is the classic ’feel’ of the original machine. A modern keyboard and joystick don’t have the same tactile impact as a classic machine, and if you want to recapture that feeling but have access to modern system tools, then you’ll need to consider repurposing an existing machine.

Talk to the Keys

The classic Atari ST case with the built-in keyboard and parallelogram F key design is one of those features you can’t emulate in software, but it isn’t too difficult to interface original Atari hardware with a modern microcontroller, and you don’t even need to solder any wires to do so. Remove the screws from the base of your Atari ST, and remove the lid. Remove the motherboard and all internal components, keeping the keyboard and outer case to one side. This isn’t a difficult process, and there are no hidden screws or clips to worry about. You can safely store all of the components that you don’t need so that the whole process is reversible.

The classic Atari ST came without many of the features found in its successors. Smaller than later models, although it sported the classic Atari keyboard design, the early ST had no built-in floppy drives or internal power supply to bulk 
up its size
The classic Atari ST came without many of the features found in its successors. Smaller than later models, although it sported the classic Atari keyboard design, the early ST had no built-in floppy drives or internal power supply to bulk
up its size

The original Atari keyboard has its own microcontroller built in to process key presses. Depending on your model of Atari, the keyboard will be connected to the motherboard by a single connector with either 8 or 18 connections. On earlier Atari machines, the 18-pin connector was used, routing joystick and mouse connections through the keyboard’s 6301 processor. On later machines like the 1040ST, only the keyboard signals were routed through the connector, so fewer pins were required.

1040ST Pinout
1 Ground
2 NC – Hole is blanked off to facilitate correct orientation of the plug
3 NC
4 5 V
5 RX
6 TX
7 Reset
8 NC
520ST Pinout
1 Ground
2 NC – Hole is blanked off
3 Joystick 0 Right
4 Joystick 0 Left
5 Joystick 0 Down
6 Joystick 0 Fire / Mouse Right Btn
7 Joystick 0 Up
8 Joystick 1 Right /Mouse YB
9 Joystick 1 Left / Mouse YA
10 Joystick 1 Down / Mouse XA
11 Joystick 1 Fire / Mouse Left Btn
12 Joystick 1 Up / Mouse XB
13 +5 V
14 RX Data
15 TX Data
16 Reset
17 NC
18 NC

The full pinout is shown here for completeness, but to interface with the keyboard, only five pins are actually necessary. The 5 V and Ground lines are needed to power the keyboard’s microprocessor, and the RX/TX pins are used to communicate. The Reset pin is needed to initialise the keyboard, and contrary to what you might read online, failing to connect this pin can lead to some very strange behaviour from the keyboard. Talking to the keyboard with a Raspberry Pi is just a matter of connecting these five pins to a suitable microcontroller that can be configured as a USB HID, reading the outputs from the keyboard’s microcontroller using a serial connection, and mapping the outputs to a modern-day USB keyboard equivalent. The keyboard communicates using a slightly unusual 7812 bps connection, and the connections are made RX to RX, TX to TX, which is frustrating but not uncommon. The process of translating the keyboard signals has been made easier, thanks to the work of Kevin Peat where you can find code for the Arduino Leonardo. The connection between the keyboard and the Arduino Leonardo can be accomplished with male DuPont connectors, meaning that no soldering or wire-cutting is necessary. A small dab of hot glue or Kapton tape will hold the connection together, and can be easily removed in the future.

You can add 3D-printed blanks for sockets on the case you’re not using without needing to modify the case itself
You can add 3D-printed blanks for sockets on the case you’re not using without needing to modify the case itself

Waggle Your Joystick

After the keyboard, the most iconic thing about Atari computers (and, likely, the first thing that people think of when you say the name Atari) is probably the classic black joystick. Originating with the Atari 2600, the joystick is digital, with five internal switches connected to a 9-pin D-sub plug. This 9-pin joystick connector remained in use across many computers and consoles for many years, with some changes to the internal wiring. On early Atari ST computers, the first joystick socket was shared with the system mouse. On later versions of the ST, the 9-pin sockets were replaced with a 15-pin variant that allowed for more connected devices. Connecting a classic joystick to a modern computer is a common task, and there are a variety of different ways that you can accomplish the task. One option is to use an off-the-shelf converter that has the correct socket fitted to a USB plug. This is the easiest solution, and requires zero tinkering to get working. However, from an aesthetic point of view, it requires USB cables going into the classic case, and it can look a little bit odd. For a classic Atari ST with side-mounted sockets, it’s much neater to mount a USB joystick encoder inside the Atari ST, wired to D-sub connectors in their proper place on the side of the case. There is a 3D-printed mount provided in the files for this project that will let you mount the sockets to a board that matches the PCB layout of the Atari ST motherboard. This means you can place in a dummy PCB, and mount the 3D-printed socket adapter into the Atari without needing to use any permanent fixings. The pinout for the Atari joysticks is very simple, as you can see from the table here.

1 Up
2 Down
3 Left
4 Right
5 Reserved
6 Fire
7 +5 V
8 Ground
9 NC

If you’re wondering about the reason behind the Reserved and NC pins, those pins were used on the original Atari console for paddle controllers. In theory, you could use a joystick encoder to reproduce this functionality for emulation purposes, even though it isn’t a function found on Atari ST itself.

Of Mice and Mending

The difficult choice at this point is what to do with the mouse socket. The traditional Atari ST mouse plugged into the side of the Atari next to the joystick. If you wanted to play a game with two joysticks, you needed to remove the mouse and plug it in or build an external switch-box. With a modern machine, this isn’t an issue. You can either opt for a Bluetooth mouse, add extra USB sockets, or remain faithful to the original design and dedicate one of your sockets to being a mouse socket. If you’re lucky enough to have a working Atari ST mouse and want to do this, then there are adapters around that will let you connect the mouse via USB in the same way that you can connect the keyboard or joystick. If you prefer to find out how the mouse works and have a go at implementing this yourself, you can start by having a look at this Shaft Encoder Interface for an explanation of how the Atari mouse works. However, even the most ardent fan of the Atari ST will admit that the ball mouse was a bit of a brick by modern standards, and after decades of use, many old mice have failed microswitches or encoders. For the sake of simplicity, it’s probably a good idea to rely on a modern Bluetooth or USB mouse to control the Raspberry Pi, and then dedicate the original mouse port exclusively for joysticks. If you’d like to add a more authentic look, you can use this STL file of an Atari ST mouse and 3D-print your own version.

The Atari keyboard has its own processor to deal with the key matrix. Different versions of the Atari ST had different internal connectors. This keyboard has the 18-pin connection, which also routes the keyboard and mouse sockets through the keyboard processor. Later versions had sockets with a smaller number of connections
The Atari keyboard has its own processor to deal with the key matrix. Different versions of the Atari ST had different internal connectors. This keyboard has the 18-pin connection, which also routes the keyboard and mouse sockets through the keyboard processor. Later versions had sockets with a smaller number of connections

In terms of hardware, there’s little else to consider. Any holes left in the Atari ST case can be filled with 3D-printed plugs. No glue is required because the plugs are held in place with a rubber O-ring. A short HDMI extender fits neatly into the space previously occupied by the monitor socket, and a 2.5 mm socket mounted in the old power plug location can be used to provide power to the Raspberry Pi. USB extenders can bring out the USB sockets to the outside of the case in the same way.

Once you’ve connected up all of the necessary cables to your Raspberry Pi, it’s time to start thinking about emulation. The standard option for Atari ST emulation on a Raspberry Pi is Hatari, but since you’re already here, why not install support for something more than just the Atari ST?

A generic joystick board is the easiest way to connect Atari (or custom) controllers to the Raspberry Pi. The board shows up as a generic joystick device, and will return events when the joystick moves or a button is pressed. Although the board in this image supports modern analogue joysticks, it will work fine with a retro digital joystick
A generic joystick board is the easiest way to connect Atari (or custom) controllers to the Raspberry Pi. The board shows up as a generic joystick device, and will return events when the joystick moves or a button is pressed. Although the board in this image supports modern analogue joysticks, it will work fine with a retro digital joystick

RetroPie is a specialised system that brings together several emulation projects on the Raspberry Pi, including the Hatari emulator. You can either install it onto an existing system, or you can download an installation image for the Raspberry Pi that does the majority of the work for you. Installing RetroPie is as easy as downloading the appropriate image from retropie.org.uk, then write the image to a microSD card, insert the card into the Raspberry Pi, turn on the power, and follow the on-screen prompts.

The RetroPie website has excellent documentation, and this is the best place to start. Once RetroPie is installed, you’ll need to do a little bit of extra work to set up the Atari ST emulation. The Hatari emulator needs a valid TOS image installed in order to work.

The TOS image needs to be installed to the folder ~/RetroPie/BIOS/tos.img, while game images are copied to /home/pi/RetroPie/roms/atarist. The Hatari emulator uses disk images to load games from a virtual floppy drive (or drives). Starting the emulator with a disk image inserted
into the drive will automatically load that image. Loading games that require multiple disks means that you need to open up the Hatari emulator settings, and change the disk inserted in the virtual drive. You can find more information on this in the RetroPi docs and also from the Hatari user’s manual.

HackSpace magazine issue 69 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get HackSpace from the Raspberry Pi Press online store or your local newsagents.

How to emulate an Atari ST from inside
Print Friendly, PDF & Email

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Server Status

Aradippou Chat 1 Chat 2 Larnaca Limassol Nicosia

Chat Links

Official Links.

1. Chat 1.
2. Chat 2.

Alternative Mirror Links.

1. KiwiIRC 1.
2. KiwiIRC 2.

Other Web Clients.

1. IrcCloud.

Recent Posts

Related Posts:

Advertisement

Archives

Super Club Radio

Mighty Deals

CyIRC

CyIRC Tweets

Scroll Up
Fatal error: Uncaught WMAC\JSMin_UnterminatedStringException: WMAC\JSMin: Unterminated String at byte 1180: "+o.accessToken}}).then(e=>{if(!e.ok)throw e;return e});return a.catch(e=>{console.error(`Failed to logout chatrix session. deviceId: ${o.deviceId}`)}),a}})(); in /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php:215 Stack trace: #0 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php(157): WMAC\JSMin->action(2) #1 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php(96): WMAC\JSMin->min() #2 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/class-main.php(375): WMAC\JSMin::minify('(function(){"us...') #3 /home/bszucbfe/public_html/wp-includes/class-wp-hook.php(310): WMAC_PluginMain->jsSnippetcacher('(function(){"us...', '/home/bszucbfe/...') #4 /home/bszucbfe/public_h in /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php on line 215