Close

Sound

A project log for PZ1 6502 laptop

I am building a laptop with a W65C02, lots of memory, SID-sound, decent graphics and a filesystem.

adamklotblixtadam.klotblixt 05/07/2020 at 10:120 Comments

One very fun and interesting aspect of retro computing is the different methods of limited sound capabilities that were available. I chose to implement a SID-emulator and a simple 8-bit DAC with FIFO.

The SID-emulator was hard to get right, and I spent a LOOONG time on it. I started with a library that sounded really wrong, then I switched to tinySID by Christian Bauer. I've stripped the filters out, only use one SID-chip and use floating point math. It sounds good and doesn't take too many CPU cycles mixing at 44100Hz. I've written hard-coded test-code that can play most psids from the C64, sounding the way they are supposed to. One of the near-future projects is to write a loader that can use the bank-switched memory and have a tune play in the background while running other code.
A small trick I picked up from the BBC micro SID-player: the PZ1 uses its own SID-addresses. After each SID-play loop, the contents of the memory addresses the C64-SID use are copied to the PZ1 equivalents. It takes a few more 6502-cycles but works really well.

The 8-bit DAC is simple to use in the 6502-space. Every frame there are 44100 / 50 = 882 samples to poke to a specific address, that will fill the FIFO. The emulation code mixes these samples with the SID sound.

I started out using the built-in MQS sound output of the Teensy, which sounded decent, but I wanted something a bit better. A cheap external I2S 16-bit stereo DAC is now connected to the Teensy. The sound is the same in both channels.

Discussions