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.

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 World of Spectrum 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 (they have promised to correct the spelling of my name).

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 4 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: www.grelf.net/forest. It runs entirely in the browser, there is nothing executed on the server. The entire source program is about 100 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

 Earlier writings

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