One of the demos I’ve carried across nearly all the platforms I’ve worked on is the rotating cube demo, typically with back-face culling (hidden line/face removal), perspective, and fast integer maths.
The code has been ported to the Gameboy, CPC, PC, Atari ST and Scratch. On more capable systems I usually add filled-in polygons with simple texture mapping and Gouraud shading
I first wrote this demo around 30-odd years ago for the Spectrum, and I stumbled across my original notes recently whilst tidying up my home-office area in preparation for the installation of a new Internet service.
And now it’s back where it belongs.
The code is heavily optimised and omits a handful of basic features such as edge-clipping, but serves as a good example of how code can be optimised on 8-bit micros.
The main features of this demo are:
- Fast integer maths routines for 8, 16 and 24 bit multiply and divide
- Fast line and filled shape routines for triangles, polygons and circles
- Fast offscreen buffer copy and clear routine using the stack pointer
There are still some optimisations to be made, and the code is not very well commented at the moment, but that notwithstanding, I’ve copied it down to my GitHub area, and can be compiled using the toolchain described here.