Choices, Choices

The Atari Lynx has always been a favorite console of mine, not just because I’ve always been obsessed with Atari, but because its a fantastic little piece of hardware in its own right.

A while ago I was pondering what I could do for the Lynx on the new hardware front, and two ideas came to mind — an LCD replacement and an SD cartridge (allowing you to play ROM images stored on an SD card). After a bit of searching I found that Candle on AtariAge had a working LCD replacement prototype (although development had been stalled for some time), so I decided an SD cartridge was a good place to start. If nothing ever came of the LCD project, I could look into that next.

As it happened, while developing the SD cartridge, a chap known as McWill on AtariAge came up with a finished LCD replacement and quite promptly started selling them — and a fantastic mod it is!

The Proof of Concept

Atari Lynx - "Insert Game"

Atari Lynx – “Insert Game”

Thankfully the Lynx doesn’t give up. The main challenge with the SD cartridge was getting the Lynx to somehow reboot on demand or hold it in reset until the contents of the SRAM connected to the cartridge bus were programmed. The Lynx cartridge bus is effectively an 8-bit, block indexed serial interface (a bit like an SD card, oddly enough), rather than being directly connected to the CPU system bus as ROM, like many consoles of the day. So at the cartridge connector there is no control over the reset line of the CPU — another method had to be found.

After a sift through the boot ROM disassembly, the answer was thankfully easy — the Lynx repeatedly attempts to load from the cartridge if the data received fails the integrity check, displaying the infamous “INSERT GAME” screen. So the answer was as simple as disconnecting the Lynx cartridge bus from the SRAM and having a microcontroller program the contents of the SRAM before returning the bus to the Lynx whereby it would load the game.

This was the proof of concept — getting the Lynx to boot from an image loaded from the SD card. But the Lynx still needed some way of communicating with the microcontroller on the cartridge to allow different ROM images to be loaded and run.

Are you receiving me? Over.

This is where the Lynx’s 2nd I/O port comes in handy. The Lynx has two possible data I/O ports for accessing the cartridge bus, each one pulls a different signal on the cartridge low to indicate a read or write on that port. The one port is used by the system as the normal input port for the cartridge data, but the second is not used. Well, this is not entirely true — it is not used by any commercial games, but has been used by some homebrew cartridges and prototypes for save game purposes. In the case of the SD cartridge, I am using this port, along with the single auxiliary I/O line, to communicate with the cartridge. Any existing ROM image using this port for save state would need to be modified to now read and write its save data on the SD card.

To facilitate writing to the microcontroller from the cartridge bus there is an 8-bit latch used to capture data written by the Lynx such that the microprocessor doesn’t have any time constraints on reading the value. When the microprocessor gets an interrupt to indicate a write has occurred, it can then query the latch and find out what data was written. Using this, along with the auxiliary pin for handshaking, a simple communication protocol was developed which allowed bidirectional data transfer between the Lynx and the microcontroller on the cartridge with the microprocessor acting as a server responding to commands from the Lynx.

From here it was just a matter of donkey work to create a series of commands which the cartridge would respond to, allowing the Lynx to query the contents of the SD card and ask the microcontroller to write specific file contents to the SRAM.

Eeny Meeny Miny Moe

The final piece of the design is the menu system allowing you to select a ROM image to play. On booting, the microprocessor loads “menu.bin” from the SD card root directory into SRAM and allows the Lynx to execute it. This ROM image then communicates with the microcontroller getting the SD card directory and file information before finally displaying it in a list on the Lynx. From here you can select any of the ROM files found which then loads the image into SRAM and kicks off the Lynx boot process again, loading up the game.

The source code for the menu, and the library code for accessing the features of the SD cartridge has been added to the Atari Lynx Code Repository so anyone can freely create their own front ends (the one included is very simple) or create games which make direct use of the SD card.