I've been doing a few small things on the NGPC lately. Here's the latest one: playback of a 16 kHz stereo IMA-ADPCM-encoded song.
ROM + full source code (runs fine on a real NGPC, but not in any emulator that I know of)
youtube video recorded while running it on my NGPC. (Warning: there's a loud burst of noise right before the clip ends. I don't stop/loop the song when it ends, so when it goes past the end of the song it starts writing junk to the audio DACs).
A few technical details for those of you not familiar with this system:
The main CPU is a Toshiba TLCS-900/H, which is nice sort-of successor to the Z80 (32-bit registers, more orthogonal ISA, more addressing modes, etc). There's also an actual Z80 which is used to control the sound chip, but the Z80 isn't used at all in this demo.
The 900/H runs at a max frequency of 6.144 Mhz. Two clock cycles is called a state, and the fastest instructions execute in two states.
At 16 kHz stereo I need to generate 32000 samples every second, so I'm allowed to spend at most 3072000/32000 = 96 states per sample. Even with the optimizations I've made in the decoding routine I'm just barely below that limit (the last time I measured the performance I got something like 94 states/sample).
The decoder routine reads 4-bit encoded samples from ROM, decodes them into 16-bit signed PCM samples which are then rounded down to unsigned 8-bit samples and stored in a circular buffer in RAM. The actual audio output is handled by a microDMA channel (another feature of the 900/H package), which is set up to copy one byte each to the left and right audio DAC at 16 kHz.
ROM + full source code (runs fine on a real NGPC, but not in any emulator that I know of)
youtube video recorded while running it on my NGPC. (Warning: there's a loud burst of noise right before the clip ends. I don't stop/loop the song when it ends, so when it goes past the end of the song it starts writing junk to the audio DACs).
A few technical details for those of you not familiar with this system:
The main CPU is a Toshiba TLCS-900/H, which is nice sort-of successor to the Z80 (32-bit registers, more orthogonal ISA, more addressing modes, etc). There's also an actual Z80 which is used to control the sound chip, but the Z80 isn't used at all in this demo.
The 900/H runs at a max frequency of 6.144 Mhz. Two clock cycles is called a state, and the fastest instructions execute in two states.
At 16 kHz stereo I need to generate 32000 samples every second, so I'm allowed to spend at most 3072000/32000 = 96 states per sample. Even with the optimizations I've made in the decoding routine I'm just barely below that limit (the last time I measured the performance I got something like 94 states/sample).
The decoder routine reads 4-bit encoded samples from ROM, decodes them into 16-bit signed PCM samples which are then rounded down to unsigned 8-bit samples and stored in a circular buffer in RAM. The actual audio output is handled by a microDMA channel (another feature of the 900/H package), which is set up to copy one byte each to the left and right audio DAC at 16 kHz.