A ZX Spectrum Raytracer, In BASIC

[Gabriel Gambetta] knows a few things about ray tracers, being the author of Tiny Raytracer, a raytracer written in just 912 bytes of JavaScript. As a long-time fellow sufferer of the UK-designed ZX Spectrum, could these two love affairs be merged? Could the Tiny Raytracer fit on the ZX Spectrum? In BASIC? The answer is an affirmative, albeit with our beloved speccy’s many limitations.

Ray tracing with only 15 primary colours

The story starts with [Gabriel]’s Computer Graphics From Scratch (CGFS) raytracer algorithms and an existing code base that was ported to the ZX Spectrum’s very limited BASIC dialect, using VSCode for editing, BAS2TAP to generate a tape image file (essentially an audio track) and executed with FUSE. With the toolchain sorted, [Gabriel] adds just enough code to deal with the ray intersection equations of a sphere, and renders a three-sphere scene to a 32×22 pixel colour image, taking a mere 15 minutes of runtime. Fellow sufferers will remember the spectrum had a 32×22 block attribute array (or colour array) with two colour values for foreground and background pixels. Each attribute block contains 8×8 pixels, each of which could be foreground (on) or background (off.) The next stage was then to expand the code to handle pixels as well as blocks, by simply expanding the raytracing to the full 256×176 resolution, and for each block simply determine the two most common colours, and run with those for the whole block. It sort of works, in a very spectrum-esq ‘attribute clash’ kind of fashion.

Continue reading “A ZX Spectrum Raytracer, In BASIC

How To Chase The Beam With A Z80

The more accomplished 8-bit microcomputers of the late 1970s and early 1980s had a dedicated display chip, a CRT controller. This took care of all the jobs associated with driving a CRT display, generating the required timing and sequencing all the dots to make a raster. With a CRT controller on hand the CPU had plenty of time to do other work, but on some cheaper machines there was no CRT controller and the processor had to do all the work of assembling the display itself.

[Dr. Matt Regan] had a Sinclair ZX81 which relied on this technique, and he’s put up the first of what will become a series of videos offering a deep dive into this method of creating video. The key to its operation lies in very careful use of timing, with operations executed to keep a consistent number of clock cycles per dot on the display. He’s making a very low resolution version of the display in the first video, which he manages to do with only an EPROM and a couple of 74 logic chips alongside the Z80. We’re particularly impressed with the means of creating the sync pulses, using opcodes carefully chosen to do nothing of substance except setting a particular bit.

This method of assembling a display on such a relatively slow microprocessor has the drawback of no means of creating a grayscale, and of course it’s only available in glorious black and white. But it’s the system which gave a first experience of computing to millions, and for that we find the video fascinating. Take a look, below the break.

If this has caused you to yearn for all things Sinclair, read our tribute to the man himself.

Continue reading “How To Chase The Beam With A Z80”

Even Amstrad Spectrums Need Their Bugs Fixing

The history of the Sinclair ZX Spectrum is one that mirrors the fortunes of the British home computer industry, one of an early 8-bit boom followed by a sharp decline as manufacturers failed to capitalise on the next generation of 16-bit machines. The grey ZX Spectrum on [Keri Szafir]’s bench is one that encapsulates that decline perfectly, being one of the first models produced under the ownership of Amstrad after Sir Clive’s company foundered. Amstrad made many improvements to the Spectrum, but as she demonstrates, there are still some fixes needed.

The machine came her way because of a hum from the tape deck circuitry. The read amplifier was picking up electrical noise, and she fixed it without mods to the circuit but with the simple expedient of powering the analogue circuit from the tape motor switch so it only works when needed.

Beyond that, this machine demonstrates another ’80s innovation, the SCART/Peritel AV connector. These first appeared on early-80s French TV sets, but by the later half of the decade had made it to the UK where Amstrad included support for an adapter cable from the DIN socket on the back of their Spectrum.  Even then they didn’t get it quite right, and she modifies some links on the board to better support it.

Sinclair were famous for on-board bodges, and even in new ownership continued. There’s a reversed transistor and at least one bodged-on component, but of course, it wouldn’t be a Spectrum without bugs, would it!

Continue reading “Even Amstrad Spectrums Need Their Bugs Fixing”

Digitizing Sound On An Unmodified Sinclair ZX81

Whatever the first computer you used to manipulate digital audio was, the chances are it came with dedicated sound hardware that could play, and probably record, digitized audio. Perhaps it might have been a Commodore Amiga, or maybe a PC with a Sound Blaster. If you happen to be [NICKMANN] though, you can lay claim to the honor of doing so on a machine with no such hardware, because he managed it on an unmodified Sinclair ZX81.

For those of you unfamiliar with the ZX, it embodied Clive Sinclair’s usual blend of inflated promises on minimal hardware and came with the very minimum required to generate a black-and-white TV picture from a Zilog Z80 microprocessor. All it had in the way of built-in expansion was a cassette interface, 1-bit read and write ports exposed as 3.5 mm jacks on its side. It’s these that in an impressive feat of hackery he managed to use as a 1-bit sampler with some Z80 assembler code, capturing a few seconds of exceptionally low quality audio in an ’81 with the plug-in 16k RAM upgrade.

From 2023 of course, it’s about as awful as audio sampling gets, but in 1980s terms it’s pulling off an almost impossible feat that when we tried it with a 1-bit PC speaker a few years later, we didn’t succeed at. We’re impressed.

The ’81 may be one of the simplest of the 8-bit crop, but in its day it set many a future software developer on their career path. It’s still a machine that appears here today, from time to time.

Building A Sinclair ZX81 In 2022 With All New Parts

As the supply of genuine retrocomputers dwindles and their prices skyrocket, enthusiasts are turning their eyes in other directions to satisfy their need for 8-bit pixelated goodness. Some take the emulation route, but others demand a solution that’s closer to the original hardware. Following the latter path, [iNimbleSloth] is answering the question as to whether it’s possible to build a Sinclair ZX81 from all-new parts in 2022.

The ZX81 was Sir Clive’s second Z80-based computer, and its low price made it an instant success which paved the way for the legendary ZX Spectrum. From here in 2022 the original Ferranti ULA chip that contained all the logic is unobtainable except by raiding another ’81, so he’s using a design that has the same functionality in 74 series logic. The PCB is the same size as the original, and he’s paired it with a keyboard PCB using tactile switches. The video below the break is the first of what is to be a series, and he will be looking at a readily available 3D printed ZX81 case and the re-manufactured membrane keyboard.

For those of us who first learned to code in its meager 1k of memory the ’81 will always be a special computer. Sure it had many faults, but simply having an affordable real computer at all in 1981 was special. To see one being made from scratch is special then, and it would be nice to think that a few other people might learn how a computer works the Sinclair way.

Continue reading “Building A Sinclair ZX81 In 2022 With All New Parts”

Loki Is Part Cyberdeck, Part Sinclair Spectrum, And Pretty Tricky

You’ve got to watch out for Loki — he’s a trickster, after all, and he might make you think this semi-cyberdeck mash-up machine is named after him, when the backstory on this build is more interesting than anything in the current Marvel scene.

According to [Steve Anderson], Loki was the name of a mocked-up machine that Sinclair teased in the mid-1980s as a competitor for the Amiga. [Steve] coveted the vaporware machine and never quite got over it, but rather than pine for something that never existed, he created his own Loki. He only loosely qualifies the machine as a cyberdeck — it has some features of the genre, like a Raspberry Pi and a cast-off iPad screen for a display, but isn’t really intended to be as portable as a real cyberdeck. To scratch his Sinclair itch, the machine also includes a ZX Uno, which is an FPGA emulator of the Sinclair Spectrum. The keyboard is hand-wired using mechanical switches, and is backed up by a Pico running custom software so it can talk both USB and PS/2.

[Steve] has much more detail on Loki and his other cyberdeck builds over on his blog, which you should probably check out. Somewhat surprisingly, it doesn’t look like he’s entered Loki in our new Cyberdeck Contest that just launched. Hopefully that’s just an oversight.

Reviving A 1974 Sinclair Scientific Calculator

When a treasure of retrotechnology fails to work, the natural next step is to have a go at repairing it. [Adam Wilson] found himself in this position when he acquired a 1974 Sinclair Cambridge Scientific calculator, and his progress with the device makes for an interesting read.

First up is something of value to all old Sinclair enthusiasts, he’s found a solution to the original battery connectors being prone to failure. A couple of parts stocked by RS can be used as replacements, which should save quite a lot of Sinclairs with crusty connectors.

Saving the connectors should have fixed the calculator, but only served to reveal that it had an electronic fault. Some detective work traced this to the power supply, which is a small switching circuit. The 1974 chip and associated coil had both failed, which rather drew the project to a halt. A second repair-or-spares Cambridge Scientific was sourced, and by good luck it happened to have a working PCB. So [Adam] got a working calculator, and we hope he’ll succumb to the temptation to shoehorn in a PSU from 2022 to get the other one working.

Anyone curious about this slightly unusual calculator should take a look at our teardown of one.