Close

Does this project spark your interest?

Become a member to follow this project and don't miss any updates

Zorkduino

Play Zork on your TV with an Arduino.

3 26 21

This project was created on 04/29/2014 and last updated 6 months ago.

Description
Who doesn’t love Zork? Who doesn’t love Arduinos? Why not grab a few cheap components and build an Arduino gadget capable of playing all the classic Infocom games on your TV from the comfort of your couch.
Details

A few years ago I ported a Z-Machine player to a little arduino-like device. Ever since I have been meaning to get around to a project that would work on a TV with a real keyboard and once again rekindle fond memories of long nights playing Zork on my Atari 800.

You will need:

  • Arduino UNO, Pro, Pro Mini or equivalent.
  • SD card or micro SD card + breakout board (from Adafruit, eBay etc).
  • RCA A/V Cable (eBay).
  • 470ohm, 1k and 100k resistors.
  • Breadboard, wires etc.
  • WebTV or MsnTV IR Keyboard or PS2 a nasty old PS2 keyboard (eBay).
  • IR receiver TSOP38238,TSOP4838 or equivalent (Adafruit, Mouser etc).

Building it

The schematic is very simple:

 +----------------+ +-----------------+
 | | | |
 | 13 |-----------| SCK micro\SD |
 | 12 |-----------| MISO card |
 | 11 |-----------| MOSI module |
 | 10 |-----------| CS |
 | | 5v <-| |
 | | GND <-| |
 | arduino | +-----------------+
 | uno/pro |
 | | 5v <--+-+ IR Receiver
 | | GND <--| ) TSOP4838
 | 8 |-------------+-+
 | |
 | 6 |----[ 100k ]--------> AUDIO
 | |
 | 9 |----[ 1k ]----+---> VIDEO
 | | |
 | 1 |----[ 470 ]----+
 | |
 | 3 |----------------> *PS2 CLOCK
 | 2 |----------------> *PS2 DATA
 | |
 +----------------+

Layout on an Arduino Uno…

…and on a Mini Pro.

Just about any SD card or microsd card breakout will do. Some of the very cheap ones (<$1) don’t have 5v to 3v3 level converters and may fry your SD card so caveat emptor. As always, Adafruit has nice ones.

WebTV keyboards come in various guises: WebTV, MsnTV, Displayer, UltimateTV etc. They all should work just fine. A few places have the nice Philips variant new for $11.95 w/ free shipping (search for ‘SWK-8630′). This one comes with a nice PS2 IR receiver; more on it later.

IR receivers come in a number of different forms. You are looking for a 38khz version with a known pinout: Some have the center pin as GND, some as V+. Make sure you know what kind you have. When in doubt, Adafruit.

I like using iPhone/iPod video cables for TV projects. Because they no longer work (their MFI chips long since revoked) they are inexpensive, are labeled internally and have a strain relief grommet.

If you have an IR keyboard then good for you. If not, connect your nasty old PS2 clock and data lines to pins 3 and 2 then order an IR keyboard.


Code and Files

https://github.com/rossumur/Zorkduino

The microsdfiles folder contains a zd.mem pagefile along with several sample games:

tutorial.z3 Introduction to interactive fiction and a little bit of Zork I

sampler1.z5Samples of Planetfall, Infidel, and The Witness.

sampler2.z3Samples of Zork I, Leather Goddesses of Phobos, and Trinity

minizork.z3 A nice big chunk of Zork I that was given away with the British Commodore users’ magazine “Zzap! 64″ no. 67. in 1990.

Copy these files to a freshly formatted sd or microsd card. You can find lots of other Zorkduino compatible games at the Interactive Fiction Archive. Insert the card and run the zorkduino.inosketch from the zorkduino folder. When it is all up and running, it should look like this (depending on how many games you found):


How it works

Squeezing Zork into the limited footprint of an Arduino proved to be a bit of a challenge. The code uses a port of Mark Howell and John Holder’s JZIP, a Z-machine interpreter. The Z-machine was created in 1979 to play large (100k!) adventure games on small (8K!) personal computers. Long before Java the implementors at Infocom built a virtual machine capable of paging, loading and saving complete runtime state that ran on a wide variety of CPUs. Clever stuff.

The trouble is the Arduino only has 2k of ram. The Z-machine interpreter uses 2k for its stack alone, leaving no room for dynamic memory, disk buffers, video frame buffers, avr stack and other program state. The solution is to virtualize all stack and memory accesses from the interpreter down to a 160 byte cache and a 512 byte disk buffer. Thats where the zd.mem file comes in – a megabyte or so of virtual stack, memory and save-game slots.

Virtualizing everything slows...

Read more »

Project logs

View project log

Discussions

Jasmine wrote 4 months ago null point

We've updated the submission process for The Hackaday Prize, so If you want to officially enter this project - login and use the 'submit to' under your project images on the left hand side.

Also, we will start community judging soon, so you may want to add some updates.

Let me know if you have any questions.

Are you sure? [yes] / [no]

Eric Evenchick wrote 6 months ago null point

Thanks for the great write up!

Out of curiosity, I wanted to compare the Atari 800 and the Arduino. The Atari uses a MOS 6502, the Arduino uses an ATmega328p. 6502 runs at 1.79 MHz, ATmega328p goes up to 20 MHz.

Are you sure? [yes] / [no]

rossumur wrote 6 months ago null point

The 6502 is roughly half the MIPS/mhz of the AVR, so clock speed does not tell the whole story. Futhermore in the Zorkduino about 80% of the CPU is busy generating video, and the limited memory and tiny cache means that the microsd card might get read 100 times more often than the Atari disk. That said the Atari disk had slow moving parts with huge rotational latency and a 19200 baud serial link (http://rossumblog.com/2011/05/04/a-little-atari-810-disk-drive/). With all these different characteristics its a funny coincidence that the performance feels (and sounds) about the same.

Are you sure? [yes] / [no]

Similar projects