Site logo, www.grelf.net
 

The Forest - history

In May 2014 I had a blast from the past about some games I wrote for the Sinclair ZX Spectrum and similar machines 30 years earlier. It seemed that the current resurgence of interest in popular programming may be reviving the ideas behind the games. I had a particular technique of my own for generating terrain on a large enough scale to be explorable, despite the lack of memory in those early machines (the Spectrum had only 48k bytes - and that was the larger version). Indeed, one of my games was simply called Explorer. Its predecessor, The Forest, was a simulation of the sport of orienteering.

The first PC I owned was a Tandy (Radio Shack) TRS-80 with 16 kilobytes of rewritable memory and a BASIC interpreter in read-only memory. In those days BASIC (Beginners All-purpose Symbolic Instruction Code) was the programming language available on most home computers because it was not only easy for beginners to write but also relatively easy to interpret by programs written in the more fundamental language of the hardware processor. The microprocessor in the TRS-80 was a Z80, from a company called Zilog. It was a neat development from the earliest microprocessors because some of its 8-bit registers could be used in pairs, as 16 bits: values could range from 0 to 65,535 (2 to the power 16) and this not only enabled reasonable arithmetic but it meant that 64 kilobytes of memory could be addressed easily.

I set about developing algorithms that could generate maps, first in BASIC and then I taught myself the Z80 assembly language to program the processor directly (for greater speed and compactness, to get more program in the memory available, but at the cost of less easily comprehended programs).

The graphics on the TRS-80 were very crude, just green and black. Nevertheless I managed to produce a first simulation of orienteering and a printed map to go with it. The program and map were published by a company called Molimerx which specialised in programs for the TRS-80.

In 1983 I obtained a Sinclair ZX Spectrum. This machine was based on the same Z80 processor but it had much more rewritable memory available: 48 kilobytes. I was able to use my existing assembly program, wrap it in a bit of program written in Sinclair's slightly different version of BASIC and extend it with several additional features. The Spectrum version of The Forest was published in 1984 by Phipps Associates.

I agreed with a fellow orienteer, Chris Barrington-Brown, that he could convert The Forest to run on the BBC Microcomputer which used a different processor, with a different assembly language. That version appeared a year or two later.

A different game based on the same core of program was called Explorer. It was developed as more of a team effort. The programming was still all mine but the graphics were created by Simon Dunstan, of the RamJam Corporation in London. He was able to do wonderful things in the extremely limited graphical environment of the Spectrum. RamJam got the program published through Electric Dreams.

There is a web site called Spectrum Computing where a group of people are attempting to assemble an archive of all programs written for the ZX Spectrum and make many of them available to download and run in one of the many Spectrum simulators that are now also available for free. They have listed my two programs here (The Forest)and here (Explorer).

There is also an interesting article looking back at Explorer on Mark Green's blog, Pixelatron.

Technology has advanced so much in 30 years that much better versions of such games are now practical. For one thing processor clock speeds have gone up by a factor of nearly 1,000 - the Spectrum ran (I think) at 3.5 MHz. It is common now to have multiple processors in a single machine (eg, the Intel Core i5 etc), giving another potential speed increase. Also the processing of graphics is now usually hived off to a separate Graphics Processing Unit (GPU) rather than the Central Processing Unit having to do everything, as was the case all those years ago. Today's processors also have special instructions built into their hardware for frequently used computations. I think it was in the mid-1980s that Intel processors (such as 80286) started to have companion chips called coprocessors, for doing non-integer arithmetic. Devices on silicon have now been so much further miniaturised that all such work can now be done on a single chip rather than requiring a coprocessor.

It is now common to have gigabytes of main memory. The Surface tablet/laptop on which I am writing this has 16 Gbytes of RAM, which is 333,000 times that of the Spectrum. It almost goes without saying that we can now have very much better graphics, of photographic quality, something I could only dream of in the 1980s.

I have shown that it is possible to re-implement the Forest/Explorer games in HTML5 with JavaScript, making them available on just about any platform that can browse the web. Despite the fact that JavaScript is run interpretively by the browser, which is in principle much less efficient than the assembly code I wrote for the Spectrum's Z80 microprocessor, speeds are still much better than 30 years ago. The HTML5/JavaScript version can be seen here: myforest.uk. It runs entirely in the browser, there is nothing executed on the server. The entire source program is just over 200 kilobytes, so it downloads and starts almost instantly (unlike some Steam programs that take many hours to download because they include vast amounts of data). The JavaScript has not been compacted or compressed because I want others to be able to understand the techniques and perhaps develop them further.

 Then and now

19842018
HardwareSinclair ZX Spectrum
(also for TRS-80 & BBC)
Any PC/tablet/phone
with internet access
SoftwareZ80 assembler
+ a little BASIC
JavaScript (client side)
+ a little HTML
Processor(s)Single processsor for program & graphics,
16-bit arithmetic
Multi-core, separate graphics
64-bit, floating point
Clock3.5 MHzaround 3 GHz
RAM available48 kilobytesSeveral gigabytes
Graphics256 x 192
15 colours (in 8 x 8 blocks)
1920 x 1080 or more
Millions of colours at every pixel
Scene positions
plotted
Only ten,
10m ahead
Thousands, from 1m
to 300m ahead
DisplayPlug into TV
(tube, analogue,
interlaced, not steady)
Integral LCD
OtherNo discs, no internet,
load from cassette tape
via audio cable
Download over air

 Some Spectrum screens

The last of those is from Explorer, showing Simon Dunstan's clever technique with the very blocky Spectrum graphics.

 Map comparison - 1984 & now

The printed map from 1984, with part of an O-course:
The on-screen map of today:

These extracts are centred on x = 1800, y = 2300. The contours are clearly the same (allowing for the limited accuracy of manual plotting) but vegetation types have been changed and point features are deliberately more sparse in the new version. It is pleasing to see that my rather obscure Z80 assembly code all those years ago was generating what I expected, by comparison with today's much clearer Javascript.

 Earlier writings

A 1984 review of the original version, in Crash magazine.

In 1982 I had two articles published in the now long-defunct British magazine "Practical Computing". The articles described the basic techniques I was using to generate terrain from mathematical functions rather than storing it in memory. Following here are links to scanned images of the articles.

March 1982

Cover image

Page 93

Page 95

September 1982

Cover image

Page 127

Page 129

Page 130

Next page