A little over three years ago I released Atari Sid III. A few days ago, just when I wanted to get some sleep, I got an idea about how to improve its player routine. I got out of bed, started coding and here's the result
13kB of tables have been compressed to circa 512 bytes, including the decompression and noise generation routines. This improves load times tremendously.
The time spent in the timer IRQ handler has been reduced from 98 cycles down to 84 cycles (per scan line).
Added multiple song support; you can switch songs by pressing one of the three console keys
Instead of using three Pokey channels, it now uses just one. That means that the per channel dynamic range has decreased slightly from the previous version, but instead it sounds a little more balanced and it saves some precious cycles
Currently I waste 1248 cycles by visualizing the current waveform, but that's just to differentiate the "play" screen from version 3.
Because now only one Pokey channel/timer is used, the other three are free for some Pokey fun! And because there's a lot more CPU time left, one could have a 3 channel Pokey tune combined with a 3 channel Sid tune. Ninja/Goattracker + RMT :-)
Attached you'll find the full source code and a zip with a few sample songs (Cybernoid, Cybernoid II, Commando, Metal Warrior 2, Nintendo Metal).
There's still room for improvement though. The noise sounds a bit metalic at times. This could be reduced by refilling (parts of) the noise tables every frame, but this is not implemented yet as it would also possibly eliminate the ability to combine Pokey channels with a softsynth SID emulation, in which case you have Pokey do the drums.
As for emulating the emulator, Altirra should work (cannot test as my machine is way too slow), atari800 only works with a patch I recently posted to its mailinglist, implementing Read-Modify-Write instructions for Pokey registers.
Anyway, it sounds best on real hardware of course
The source is still in my weird shasm65 format, as I based this on my previous code, but it should be fairly readable