Electronics > Projects, Designs, and Technical Stuff
Cloning a Commodore PET-2001
GK:
--- Quote from: @rt on July 18, 2017, 04:51:15 pm ---, not only was the front cover intact, but I also had a spare! :D
--- End quote ---
I can't remember what happened to mine; IIRC it disappeared around 1995-1996 or so. Wonder if I'll still be sitting in front of my Samsung LCD in 20 years......
GK:
Just some playing around here. The PET 2001 wasn't designed with any sound-generation hardware, but a common hack back in the day for games was to use the CB2 pin of the VIA chip (provided at the parallel port) as an audio signal output.
If you set the 6522 VIA "ancillary control register" (ACR) (PET address 59467) to 16dec, the internal shift register (outputting to pin CB2) is programmed to free run at a clock rate determined by internal timer#2:
--- Quote ---2.13.1 Shift Out - Free Running at T2 Rate (100)
This mode is similar to mode 101 in which the shifting rate is determined by T2. However, in mode
100 the SR Counter does not stop the shifting operation. Since SR7 is re circulated back into SR0,
the eight bits loaded into the SR will be clocked onto the CB2 line repetitively.
--- End quote ---
So you basically have a primitive programmable-frequency (Timer 2 low-byte) arbitrary waveform generator. The shift register (SR) data register is PET address 59466. POKEing this register with a value of 15dec (00001111) gives you a square wave. 51dec (00110011) gives you a square wave one octave higher in frequency while 85dec (01010101) returns one octave higher again.
By doing this in conjunction with programming Timer 2 (PET register 59464) you can actually reproduce musical notes over a few octaves with reasonably good accuracy. Of course the single voice is monophonic so you can't do chords and there isn't any control over the amplitude either, but even this primitive capability sure is better than nothing.
My PET clone is to have a switchable (in/out) audio amplifier based on either an LM380 or an LM386 on-board. Just experimenting with/verifying the functionality of the prototype hardware this afternoon I translated a tune-playing BASIC program from one of my BBC Micro programming books (BBC Micro Sound and Graphics, Mooney) to run on the PET.
The BBC Micro had it's own sound hardware and associated "SOUND" BASIC statement, which the PET obviously lacks, so I had to re-write, substituting SOUND with the appropriate VIA register POKEs and an additional FOR/NEXT loop for the note duration. The DATA array values for the notes were also changed to produce the correct frequencies on the PET. It's a 5 note tune; A (440Hz), B, C, D and G.
The BBC book doesn't tell you what the tune is and I don't recognise it. I'd like to write up a tutorial page on PET sound programing for my website so it would be nice to know. Anyone here recognise it? Here is a digital recording of it in mp3 format, straight from the VIA CB2 pin: https://www.eevblog.com/forum/projects/otp-eprom-programmer/?action=dlattach;attach=340925
MK14:
It sounds like the classical Laurel and Hardy tune.
GK:
--- Quote from: MK14 on August 12, 2017, 07:32:33 am ---It sounds like the classical Laurel and Hardy tune.
--- End quote ---
Ah, I think you're right. I'm not quite vintage enough to recognise that one! :P
GK:
Hmmm, listening a few times again and I'm not too sure. One thing I omitted in my program was a FOR/NEXT loop to implement a brief delay with the sound POKE'd OFF to give a short silence between played notes. Without that I think the tune probably sounds less like it should, especially in parts where the same note is played a couple of times in a row.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version