Close

Three Years Later

A project log for Novasaur CP/M TTL Retrocomputer

Retrocomputer built from TTL logic running CP/M with no CPU or ALU

alastair-hewittAlastair Hewitt 02/21/2022 at 22:270 Comments

In keeping with the first and second year updates... here is year three! Normally it is a look ahead at the next phase of development, but things are pretty much complete at this point.

There is an outstanding issue causing a crash when running the ed command in CP/M and not much progress has been made in tracking that down yet. Enough of CP/M is working to run some of the existing CPU compatibility testers out there and these helped clear up the last remaining bugs. Unfortunately the ed problem persists, so there's something more to this than just the 8080 interpreter.

Sound Instructions

After no progress on the remaining bug the gears were switched to add some extended instructions to control the sound features of the platform (the plan is to also add some extended graphics instructions to plot points and draw lines natively).

There are 16 new extended instructions as follows:

Config Voice

Four 3-cycle instructions are used to configure each of the 4 voices with the following 8080 registers:

Set Note

Three 2-cycle instructions are used to set the note for voices 1-3 using the 8080 accumulator:

This instruction will also update the specific version of the sawtooth and square waves to band limit the harmonics for the note frequency and prevent aliasing.

Since the frequency of voice 0 is fixed at the vertical video frequency, the instruction that would represent this note is used to control the level of voice 3. This is needed when using 60Hz video modes since the ADSR for the 3rd voice is only updated in the 75Hz VGA mode.

Gate On/Off

Eight 1-cycle instructions are used to gate each voice on and off. Gate on will start the attack/decay to the preset sustain level. Gate off will release the note back to zero.

PCM Playback

A new feature was also added to the audio thread to play back PCM samples. The sampled data is stored in bank zero and played back by specifying the start and stop page of the sample data. The sample size is capped at 32k to leave the other half of the memory for the display.

The simplest playback method is to write one byte per block to the audio register. This is a sample resolution of 8 bits at a rate of 9,593bps giving a bandwidth of around 4.8kHz. This is definitely not CD quality, but that rate is still fairly fast and 32k will only provide 3.4 seconds of playback.

A couple of other schemes can be used to increase the playback time: Halving the sample rate and companding. Half rate skips every other block to drop the sample rate to 4797bps with a somewhat underwater sounding 2.4kHz bandwidth.

The companding method (shown below) stores the log of the 8-bit sample as 3 bits plus a sign bit. This also halves the storage requirements as each sample takes up just one nibble. Combining these two schemes gives a maximum playback of 13.66 seconds for 32k of data.

log: rounded  :  range
...:..........:.........
-8 : 10000000 : -80..-41
-7 : 11000000 : -40..-21
-6 : 11100000 : -20..-11
-5 : 11110000 : -10..-09
-4 : 11111000 : -08..-05
-3 : 11111100 : -04..-03
-2 : 11111110 : -02
-1 : 11111111 : -01
 0 : 00000000 :  00
 1 : 00000001 :  01
 2 : 00000011 :  02..03
 3 : 00000111 :  04..07
 4 : 00001111 :  08..0F
 5 : 00011111 :  10..1F
 6 : 00111111 :  20..3F
 7 : 01111111 :  40..7F

The PCM playback is handled as a separate audio mode and the various playback schemes are added as an additional four audio modes. The complete list of modes is as follows:

Discussions