RetroChallenge 2022/10 – Final reflections
First things first – how far did I get against my original aims?
| Primary aim: An implementation of “The Valley” for the Compukit UK101 – starting with the FPGA hardware version, running CEGMON and 40K RAM on a 64 column x 32 row screen layout. | Big tick against this one. I ended up with two versions – Version 1 being a vanilla implementation of the original magazine listing, with Version 2 being refactored, enhanced for the 64×32 display and with the more interesting of the published variations added. |
| Stretch goal 1: An 8K version of the game using the original monitor, suitable for running on the real hardware I have. | Big tick against this one as well. I ended up with three more versions on the way to an 8K version running with the original monitor. Version 3 – CEGMON, 16K RAM, 64×32 display Version 4 – CEGMON, 16K RAM, 48×16 display Version 5 – Original monitor, 16KRAM, 48×16 display Version 6 – Original monitor, 8K RAM, 48×16 display. Needs the preloader run first (more of that later). |
| Stretch goal 2: Repair the cassette interface on my real hardware and run the game. | I shall be attempting this today – Saturday November 5th 🙂 (See end of this post). |
So I’m going to award myself a B minus for progress. Could have done better.
A little more about Version 6. The final few days of the challenge were all about finding ways of taking 16K of code and squeezing it into 8K (7,423 bytes to be precise). I succeeded – but at a high cost to my sanity. Here’s a piece of paper from the final day of the challenge (there were similar pieces of paper generated for several days before …). Each figure on the paper is the free space I had available after the program had been edited and loaded (reported by FRE(X)) as I reduced the RAM I needed down from 10K, which is where I started the final day of the challenge.

I went through 65(!) iterations on the final day before I had a version that worked reliably. To get there I used every trick in the book, including:
- Removing (nearly all) REMS and spaces.
- FInding ways to get rid of all arrays except one (and shortening or removing many string declarations) to free up runtime space. My thesaurus was put to heavy use (Vim instead of Stamina? Yes please – that saves 4 bytes!).
- Making sure that I used single character variable names wherever possible.
- Renumbering BASIC lines to make better use of low numbers (and hence save space on GOTO and GOSUB statements).
- Fitting as many statements as I could into the meagre 71 characters allowed per line.
- Implementing a preloader. This is run before the game proper and sets up the single USR function allowed by the BASIC interpreter (a polled keyboard input routine) and POKES the monster strengths (which used to be in arrays) into a free bit of memory that BASIC doesn’t use. These remain persistent after the preloader has been NEWed and the game proper loaded – saving yet more precious bytes.
All of this effort meant that on the playing side of the game I managed to retain both the main Valley scene and the Black Tower – a good result and far better than I was expecting (I’d would have originally been happy with just the Tower being left).
I did lose all of the variations from Version 2 bar one (circles of evil remain evil). You can only enter The Valley as a Barbarian (but who would want to be anything else?) and a few of the monster types have gone – but joyfully there’s now a Wumpus, as a nod to the very first UNIX game I spent far too many hours playing when I should have been learning Pascal.
What is obvious, even 40 years on from the original publication of the game, is that the original authors succeeded in creating what, for the time, was beautifully modular and portable(ish) BASIC code. A quick glance through my Computing Today and Practical Electronics archives from the early 1980s shows how unusual this was, compared with much of the GOTO spaghetti that filled the printed magazines of my teenage years. But the 8K version I’ve created is, I hope, a fitting testament to the spaghetti heaven that so many loved and fought so hard to retain (Pascal? Pah!).
From the rarified vantage point of 2022 it’s much easier to take The Valley, understand the code and then reimplement it (even if you need to hack it to pieces to squeeze it into 8K) than say, to read David Ahl’s Super Star Trek code and understand how that works. As an 18 year old inputting the code for the first time in 1982, The Valley enthused me enough to decide to drop my original idea of studying for a degree in physics and opting for computer science instead.
Given the 8K version of the game works (and I’ve even managed to leave a REM statement on line 1) I’ve clearly cut a little too much away (there is, after all, 2,028 bytes free before the game is run). I could spend the next few days slowly putting things back in I guess – but I really should do something to restore my original hardware. Even a software geek occassionally needs to break out the soldering iron.
I’ve enjoyed my first RetroChallenge and I hope to be back for the next one, assuming the competition organisers will let me in for a second time. If not, then there are always plenty of Dragons to slay on the way to finding the Helm of Evanna, restoring order to The Valley once again.

Postscript – Saturday 5th November
I removed the old cassette tape interface wires, cleaned up my botched soldering from a few years ago and put a new cable in.

It now almost works … but there’s clearly something not quite right. I suspect I’m going to have to replace some of the componentry in the audio circuits and try again. And the 5v power supply and regulator worry me a little too much to carry on experimenting.
Maybe a project in its own right for the next RetroChallenge …

Let’s leave the last word on RetroChallenge 2022/10 to the real machine.
