Sir Clive Sinclair, born in 1940 is an entrepreneur and inventor that many will know. You may know him for his quirky Sinclair C5 battery powered “velomobile” which was set to solve commuters problems in 1985. But many will know him for a range of electronic products that bear his name. Sinclair Radionics was formed in 1961 and it created cost effective electronic products such as pocket calculators and portable televisions.
But, in 1980, Sinclair's company released the ZX80 computer for £99.95 and it was marketed as the “first personal computer for under £100”. The ZX80 proved a cost effective means to get your first computer and learn how to code but it did have a few quirks, famously causing the screen to flicker as each key was pressed. The ZX81 released in 1981 and retailing for half the price of the ZX80 addressed this and other issues while providing a solid base for learners eager to code. An agreement with Timex saw the ZX81 hit the US market as the Timex Sinclair 1000, and an unauthorised clone, the TK85 was released in Brazil via Microdigital Eletronica.
The ZX81 was a success and from that initial success more “ZX” machines were released with better graphics, and infamous rubber keys. The first ZX spectrum, released in 1982 introduced the rubber keys and diminutive size of the iconic classic computer. It is here where we start our journey into emulating the ZX Spectrum machines, chiefly the 48K and 128K aka “The Toastrack”. Can emulation give us the same nostalgic glow, can we create BASIC code projects and what is the best way to emulate a ZX Spectrum? Below, we show you two methods: one which turns your Raspberry Pi into a Spectrum and another which gives you a simple emulator that should work in Ubuntu and other flavors of Linux.
Emulating the Spectrum with Raspberry Pi
We don’t need much computing power to emulate a Spectrum and so, even your oldest Linux machine ,should be up to the job. There are emulators available for Windows, macOS, smartphones and even Nokia’s range of Linux Internet Tablets from the late 2000s.
ZXBaremulator is a bare metal emulator which runs directly on the Raspberry Pi. It is compatible with all models of Pi excluding the Raspberry Pi 4, which makes ZXBaremulator an ideal candidate to reuse an old Raspberry Pi. The bare metal emulation runs directly on the Pi hardware and provides precise emulation of the Z80 processor. It can also be used with real hardware thanks to the Raspberry Pi GPIO. This means that we can embed a Pi inside the shell of a broken “Speccy” and reuse the original keyboard.
To install ZXBaremulator you will need a spare micro SD card. Used used a 128MB card.
- Format the SD card as a FAT device.
- Download the All Files Needed archive from the website.
- Extract the contents of the download to the SD card.
- Eject the SD card and insert it into the Raspberry Pi.
- Connect your Pi accessories and power on.
In just a few seconds we will see the ZXBaremulator boot into a Spectrum 48K. If you would like to emulate a 128K, then press ALT + F3, a Spectrum +2A is ALT + F4, returning to a 48K Speccy via ALT + F2.
Writing a few lines of BASIC
The BASIC (Beginners All-Purpose Symbolic Instruction Code) language was the Python of the 1980s. It typically came pre-installed as a ROM chip that the machine booted directly from. Writing BASIC is relatively simple as it is a human-readable language. The classic and easiest BASIC project is “Hello World” and it looks like this.
10 PRINT “Hello World” 20 GO TO 10 RUN
Line 10 will write “Hello World” to the screen and line 20 instructs the code to go back to line 10 in an infinite loop. Typing RUN will start the code.
To write this for ourselves we need to remember that the keyboard of a Spectrum is very different than what we use now. The keys of a Spectrum have multiple uses and it can be easy to get confused. Pressing ALT + K will open the keyboard help menu, showing the Spectrum keyboard layout and color coded keywords.
- Press SHIFT + P to insert PRINT.
- Press CTRL + P to insert “ then type your message, in this case “Hello World”. Don’t forget to add another “ at the end of the message.
- Press Enter for a new line. Type 20.
- To insert GO TO press SHIFT + G.
- To type RUN, press R and the word will appear.
- Press Enter to run the code.
The code will print the message on to the screen and once the text fills the screen we are asked if we would like to scroll the text. Press Y or N as you see fit.
Emulating a Spectrum on Any Linux Computer
We installed Fuse (Free Unix Spectrum Emulator) on Ubuntu 18.04. Fuse is considered the de facto emulator for Sinclair machines. Open a terminal and type the following to install the Fuse app and Spectrum machine ROMs.
$ sudo apt update $ sudo apt-get install fuse-emulator-gtk $ sudo apt install spectrum-roms
Once installed, launch the application by typing this command.
Getting to Grips With BASIC and Fuse
When Fuse starts we are presented with the 48K BASIC interpreter. So let's fire up a little BASIC code and learn a few of its quirks. Firstly it shares the same multiple function per key keyboard layout that all Sinclair machines have. So to write the simple Hello World script.
The BASIC code for this project is a little more complicated than before. The code will loop round five times, asking for a number each time. These numbers are added together to produce a sum at the end. It demonstrates how to create a for loop, and create variables in BASIC.
1. Type 10 to start the line, then press SHIFT + L to insert LET. This is used to create a variable, total, and store the integer value of zero.
10 LET total=0
2. Type 20 and then press SHIFT + F to insert FOR, then type c=1 and press CTRL + F to insert TO. Type the integer 5. This creates a for loop that will iterate five times.
20 FOR c=1 TO 5
3. Type 30 and press SHIFT + I to insert the INPUT keyword, this will capture the numbers from the user and save them to a variable called “a”. The INPUT keyword takes an extra argument that enables the prompt to ask a question / give an instruction to the user.
30 INPUT “Number”,a
4. Type 40 and using another LET (SHIFT+L) we update the value stored in the total variable, adding the next integer to the sum.
40 LET total=total+a
5. Type 50, then press SHIFT + N to insert NEXT, then add the variable c. This will update the value stored in c, used to control our FOR loop.
50 NEXT c
6. Type 60 and insert PRINT (SHIFT + P) to print the value stored in the total variable.
60 PRINT total
Press R to trigger RUN to appear on the screen. Press Enter and provide five numbers. The code will add each number together and once all five are entered it will show the final amount.
Complete Code Listing
10 LET total=0 20 FOR c=1 TO 5 30 INPUT “Number”,a 40 LET total=total+a 50 NEXT c 60 PRINT total
If you would like to add a running total to the code, add a new line, 45 which prints the total each time the for loop iterates.
45 PRINT total
A version of this article originally appeared in an issue of Linux Format Magazine.
Even then the horrible membrane keypad seemed unnecessarily cheap and nonfunctional. The pain involved in retyping every session made it essentially non functional.
I was introduced to coding but it seemed tedious and unrewarding.
But soon I would get the chance to use an Apple II at school. Color screen, good keyboard and 5 1/4 floppy disks!
Also Commodore came and destroyed Spectrum to pieces in Europe back in the day.
But reason for my writing is actually Raspberry Pi emulating Spectrum. Seriously, what's the point to "downgrade" Raspberry Pi to an 40 years old budget comp? What a waste of time.
Same situation here. It was introduction to computers for many kids in Europe cause Apple II was too expensive. And big.
Later I, my parents, bought Apple II replica for, think, some 1500 DEM while Spectrum vas like 200 DEM.
I just googled and this is what they say on Wiki:
Oh my God! 3 times in 40 years!
Commodore 64 was ~$550 not ten times more expensive . and it destroyed all home pc market in Europe lol .
and Atari 400 in USA at the time was about the same price as well .
I also remember MSX from Japan was competing at $499
MSX was also a hit ,in 1983 , and Konami made the first Metal Gear game on it.
ZX spectrum had no hope compared to these PCs back in the day.
by the way , my father owned all of them :p , including Apple //e as well , and ZX Spectrum .
In short, you have no idea how it was back then.
you are simply wrong.