Linus Åkesson's Kaleidoscopico Turns a Raspberry Pi Pico 2 Into a Powerful Demoscene Machine
Commodore Amiga-inspired project, totaling 17,000 lines of RISC-V assembler, shows just what the RP2350 can do.
Demoscene coder Linus Åkesson has pushed the Hazard3 RISC-V cores of the Raspberry Pi RP2350-powered Raspberry Pi Pico 2 to their limit in order to create a Commodore Amiga-inspired audiovisual extravaganza dubbed Kaleidoscopico.
"Kaleidoscopico is a microcontroller demo that runs on a Raspberry Pi Pico 2. It placed 2nd in the Wild compo at Revision 2025," Åkesson explains of his creation. "One thing I really love about the [Raspberry Pi] Pico 2 as a demo platform is that it can, technically, accommodate a big conventional framebuffer of truecolour pixels in RAM — but this approach isn't necessarily optimal, because it leaves little room for anything else in memory. If you step outside of the box and think of creative ways to compose the video signal on the fly, racing the beam, you can put out full-screen, full-framerate effects that would otherwise be impossible on the system."
Åkesson's approach to making the most of the Raspberry Pi RP2350's resources — two 32-bit RISC-V Hazard3 cores, used here over the other two proprietary Arm Cortex-M33 cores on the chip, plus 520kB of static RAM (SRAM) and some clever programmable input/output (PIO) hardware — is heavily inspired by the Commodore Amiga, which included several task-specific coprocessors to boost performance.
"One of the [RP2350] CPU cores takes the role of the [Amiga-style] custom chips," Åkesson explains. "It is controlled by a set of global variables (similar in spirit to the hardware registers of the Amiga chipset), and it spends all of its time in a tight loop, one iteration per scanline, performing various realtime tasks that are tightly coupled to the hardware."
The rest of the hardware is minimal: a Raspberry PI Pico 2 board is mounted to a custom carrier board that uses resistor ladders to turn general-purpose input/output (GPIO) pin signals into red, green, and blue video signals, plus horizontal and vertical sync signals. Two more pins are used for stereo audio — but there are no active components beyond the RP2350 microcontroller itself, which is run at the slower-than-usual speed of 130MHz to better match the video output of 1024×768 at 60 frames per second with a 65MHz pixel clock and 4,096 possible colors.
"A PIO contains four programmable state machines. I use three of them to generate three separate layers of pixels," Åkesson says. "The PIO has a built-in priority mechanism that causes higher-numbered state machines to override the outputs of lower-numbered state machines, allowing the layers to have transparent pixels where lower-numbered layers shine through. The fourth state machine is responsible for the overall timing of a scanline: it waits for the horizontal sync pulse (generated by PWM [Pulse-Width Modulation] and visible as an input signal on the GPIO pad), tells the other state machines when it's time to start emitting pixels, and it also produces a solid black border outside the visible part of the screen. The border is used to implement smooth scrolling in the x-direction: the layers can start emitting pixels early, in which case the black edge covers the first few pixels."
With enough computational resources left to run a tracker for the soundtrack, Kaleidoscopico is complete — and includes all the usual tricks you'd expect to see from a demo inspired by or running on a Commodore Amiga, including scene transitions and raycasting. "I had a lot of fun making this demo, and learned a lot as well," Åkesson concludes. "The RP2350 turned out to be a charming chip in many ways, the RISC-V instruction set was surprisingly fun to work with, and the Pico 2 makes it all very accessible. I recommend that you give it a try!"
A full technical write-up is available on Åkesson's website, along with downloads for the demo and schematics for the carrier board under a Creative Commons Attribution-NonCommercial-ShareAlike license.