Skip to content
View of Bilbo Baggins' pathway and front door of his hobbit-hole in The Shire. There are pretty wildflowers on the right and left of the path and a giant pumpkin in a wooden wheelbarrow to the left of the green circular front door.

Porting the ZX Spectrum Hobbit to OSX

Back in 1982, in the early days of the 8-bit computer era, The Hobbit, a somewhat remarkable game was released on the ZX Spectrum. Although built in Australia (by Veronika Megler and Philip Mitchel for Beam Software), in the UK it is a cultural Icon.

Back in 1982, in the early days of the 8-bit computer era, The Hobbit, a somewhat remarkable game was released on the ZX Spectrum.

Although built in Australia (by Veronika Megler and Philip Mitchel for Beam Software), in the UK it is a cultural Icon.  Veronika went on to a distinguished career at IBM (where coincidentally I also spent several years), working with big data, and is now a big data solutions architect at Amazon Web Services.  For anyone interested in the game, beyond this short blog post, find it here. 

What made The Hobbit different than other text adventure games of the era was that the game was different every time you played. The characters within the game went about their routine much the same way as the player did, and were (largely) subject to the same rules as the player. Whilst this might seem like a “well, duh!” situation now, thirty years ago, with 48K to play with, it was actually a really big deal.  The other major difference was the quality of the parser; It will understand commands such as say to Thorin ‘climb into the barrel’ then throw the barrel through the trap door and jump onto it”.

The opening location of the game will be familiar to anyone who was a (slightly nerdy) teenager in 1982…

Screen shot of the Hobbit game showing a tunnel like hall

As someone who had never done any development for the Mac (but plenty on the Mac), and had no experience of Swift, The Hobbit seemed like an interesting Hello World” application to learn a bit more about OSX (and by extension iOS) development.

Screenshot from The Hobbit - The Troll's Clearing
Troll's clearing - avoid at night-time...

As a learning experience, it was great, as it had simple AI, language parsing, lots of vector illustrations for the “chrome” around the application (there is a lot of fun in drawing old-school computers!).

The chrome was all done using Indeoo iDraw, which was subsequently purchased by Autodesk (and is now called Autodesk graphic). It is basically Illustrator, but inexpensive and minus a few features. I got very sick of drawing keyboards, particularly as the ZX Spectrum has a LOT of text on the keyboard! It is pretty easy to create (almost) photo realistic illustrations of physical objects from scratch with iDraw.

Dynamic map of The Hobbit game, with the character Bard overlayed in the right bottom corner

In order to justify (to myself) the effort of building the game, I felt it needed to add something beyond that which could be gained by emulator play, so I added a dynamic map of the game which shows where any of the characters are at any given time, and what they are up to.  

Of course, that meant going back to iDraw and drawing lots of little character avatars…

Character avatar from The Hobbit drawn by Stu Craig

The Classic 48K Spectrum (A Great Looking Little Machine)

I opted not to reverse-engineer the original application (which is Z80A Machine code), largely building the game world through emulator play and observation. The original game uses early text-compression to fit the whole thing into 48K, so arguably this approach was actually easier.

The ZX Spectrum

The original game was developed on a Dick Smith System 80, a Taiwanese-Australian clone of the Tandy TRS-80. Sadly, the game was never released on the “Trash-80” (as the decision was made to port to Spectrum in order to have graphics), so we can only speculate as to exactly how the game would have looked.  

Dick Smith System 80

Nevertheless, it gave me an excuse to draw a TRS-80 and monitor and provide a green-screen version of the game…

The Dick Smith System 80 - TRS-80

Playing the Game in 1982

The original game gives the illusion of the story unfolding by writing the text to the screen a character at a time teletype-style and then scrolling up line-by line (with pauses when graphics are displayed).  Whether this illusion was deliberate or a limitation of the processing speed of the Spectrum is open to debate. It was a pain to emulate, involving (mostly) decoupling the output from the engine , and using a thread to slowly churn the output out the screen (unless the game is paused or you are restoring a saved game, in which case it needs to not output at all or load up instantly).

Old video monitor displaying green text

Apple don’t seem to be able to decide how they want to handle their coordinate systems, and some of Cocoa used bottom left as the origin and some uses top-left. It changes from OS to OS (so Yosemite made it more consistent and some of the graphics on the map started to render upside-down – one day I will fix it). Similar issues with Z-order; X-Code is far from world-class for non-storyboard applications (and given the option again, I would use storyboards).

Overall, it was a good introduction to Swift, although “Hello World” should probably not take several hundred hours – maybe using the Swift Playgrounds in XCode would have been a saner way to grips. Since finishing The Hobbit, I have had absolutely no requirement to use Swift…. Oh well, it was fun… I think.

Find out more here. 


Banner image: Photo by Zac Smith on Unsplash

Media Suite
is now

All things change, and we change with them. But we're still here to help you build the right thing.

If you came looking for Media Suite, you've found us, we are now MadeCurious.

Media Suite MadeCurious.