Phaeron Turns the VBXE Blitter into a Real-Time FFT Engine

On 22 March 2025, phaeron (Avery Lee, the author of the Altirra emulator) posted a short VBXE demo on AtariAge, along with its source. It plays a 45-second music clip as 4-bit samples at about 15.7 kHz and shows a live spectrum analyser at the same time. The interesting part is where the maths happens. The FFT behind the bar graph is not run by the 6502. It is computed every frame by the VBXE's blitter, the graphics board's block-copy engine, driven by one very large blit list.

How it works

Each frame, the 6502 only plays the audio, copies the current playback position into VBXE memory and restarts the blitter. The blit list then:

  1. copies a 512-sample window around the playback position out of the sample buffer;
  2. reduces it to 128 samples with a box filter;
  3. runs a 128-point real FFT, built as a 64-point, 14-bit signed fixed-point complex FFT in three radix-4 decimation-in-time stages, plus the real-to-complex conversion;
  4. applies a Hann window in the frequency domain;
  5. computes the magnitudes of the middle 60 frequency bins and draws them as bars in the VBXE overlay.

Unlike the particle demo, the FFT also needs multiplications. Writing the list by hand was "awful", and MADS had trouble with deeply nested macros, so Lee generated the blit program with a Python script (makefft.py). The memory budget uses most of the board's 512 KB of local RAM: 358 KB for the sample, 26 KB for the blit list and 56 KB for the FFT twiddle factors. He had to put a transpose into the middle radix-4 stage to keep the blit list from growing too large. By his timing analysis the whole list uses only about 30% of a frame. He also thought the 6502 had enough spare time to stream audio into the VBXE from an IDE or SD device instead of holding a fixed clip.

The particle system that came first

The FFT built on an earlier experiment. In January 2023 Lee published a VBXE particle system in which the blitter does everything: it draws and erases 256 particles, updates their position, velocity and acceleration in 8.7 fixed point, checks bounds and even runs a 32-bit LFSR random-number generator. A 15-bit addition takes six blitter steps, and the bounds test is reduced to bitwise operations on the coordinates. The only CPU code is a tiny VBI stub in page 6 that restarts the blit list. As a result the effect keeps running in the background after you exit to DOS or start another program, and Lee said that was intentional.

Reception

Lee wrote both demos in emulation, because he did not own a VBXE. One owner soon confirmed that the FFT demo works on real hardware, and Candle, who produced the later VBXE revisions, replied by asking whether Lee's shipping address had changed. Others asked for documented source. The first ZIP lacked the Python generator, and Lee posted a fixed archive and offered to answer questions. Another developer working on a VBXE library for MADS offered his own workarounds for nesting macros.

Where to get it

Both demos are attachments in their AtariAge threads, "VBXE FFT sound spectrum" (with vbxefft-srcfixed.zip for the full source) and "VBXE particle system". To run them you need a VBXE, or Altirra with VBXE emulation enabled in the system configuration. The particle demo expects the board at $D600.

Credits