PSG

From Intellivision Wiki
Revision as of 07:31, 20 May 2010 by Mr z (talk | contribs)
Jump to: navigation, search

The Programmable Sound Generator (PSG) is responsible for most of the Intellivision's sound generating capability. It also provides an interface to hand controllers and the ECS's keyboard and piano. Various PSGs were used in the Intellivision from the AY-3-891x family, including the AY-3-8914, AY-3-8916 and AY-3-8917.

The text below is just a bunch of notes for now, to be organized into something meaningful eventually.

Clock speed is 3579545/16 (223721.5625 Hz)

Registers

The PSG has 16 registers, numbered R0 through R15. They appear consecutively in the CP1610's address map, with R0 at the starting address for the PSG, and R15 at the last address for the PSG. The Master Component's PSG registers appear at $01F0 - $01FF in the memory map, and the ECS's PSG registers appear at $00F0 - $00FF in the memory map.

Note: A related part, the AY-3-8910, uses different register numbers and has a different memory map. The AY-3-8910 and AY-3-8914 are otherwise nearly equivalent. Be aware of the memory map differences if you happen across AY-3-8910 documentation.

RegisterAddressData BitsOn BitsOff BitsDescription
MasterECS
R0$01F0$00F0$00FF$0000$FF00Lowest 8 bits of 12-bit period for channel A. Note that a channel period value of zero actually indicates a period of $1000.
R1$01F1$00F1$00FF$0000$FF00Lowest 8 bits of 12-bit period for channel B. Note that a channel period value of zero actually indicates a period of $1000.
R2$01F2$00F2$00FF$0000$FF00Lowest 8 bits of 12-bit period for channel C. Note that a channel period value of zero actually indicates a period of $1000.
R3$01F3$00F3$00FF$0000$FF00Lowest 8 bits of 16-bit envelope period. The envelope period value is multiplied by two to determine the actual period. Note that an envelope period value of zero actually indicates a true envelope period of $20000.
R4$01F4$00F4$000F$0000$FFF0Upper 4 bits of 12-bit period for channel A. Note that a channel period value of zero actually indicates a period of $1000.
R5$01F5$00F5$000F$0000$FFF0Upper 4 bits of 12-bit period for channel B. Note that a channel period value of zero actually indicates a period of $1000.
R6$01F6$00F6$000F$0000$FFF0Upper 4 bits of 12-bit period for channel C. Note that a channel period value of zero actually indicates a period of $1000.
R7$01F7$00F7$00FF$0000$FF00Upper 8 bits of 16-bit envelope period. The envelope period value is multiplied by two to determine the actual period. Note that an envelope period value of zero actually indicates a true envelope period of $20000.
R8$01F8$00F8$00FF$0000$FF00Channel enables for tone, noise. I/O port direction selection.
R9$01F9$00F9$001F$0000$FFE0Noise period
R10$01FA$00FA$0000$0000$FFFFEnvelope characteristics / trigger register (write only)
R11$01FB$00FB$003F$0000$FFC04-bit Volume / 2-bit Envelope Select for channel A
R12$01FC$00FC$003F$0000$FFC04-bit Volume / 2-bit Envelope Select for channel B
R13$01FD$00FD$003F$0000$FFC04-bit Volume / 2-bit Envelope Select for channel C
R14$01FE$00FE$00FF$0000$FF008 bit I/O port A
R15$01FF$00FF$00FF$0000$FF008 bit I/O port B

Channels

The PSG contains 3 independent channels, a single noise generator, and a single envelope generator. Each channel includes a square wave tone generator and is capable of mixing any combination of the output from its respective tone generator with the noise generator and the envelope generator. Output from each of the 3 channels is then mixed together to produce the final audio output.
Channel periods are 12-bit values indicating a range of period from 1 PSG clock cycle up to 4096 PSG clock cycles. This translates to a frequency range from. Note that a channel period value of zero actually indicates a period of 4096.
In the simplest case, where channel output is affected only by its respective tone generator and not by either noise or envelope, the PSG generates channel output by counting the number of PSG clock cycles indicated by the channel period and then toggling the channel output between zero (0) and the currently selected volume for that channel.
square wave output optionally modified by the envelope generator and/or the noise generator
Volume (0-15) Period (1-4096) Tone Enabled Envelope Enabled Noise Enabled

16 volume levels, independent to each channel

Envelope Generator

Period Atak, Cont, Hold, Altr Volume (0-15) 16-bit period value multiplied by two, from 2 PSG clock cycles to $20000


Noise Generator

The random noise generator adheres to the following formula once per PSG clock cycle.

   noise = (noise >> 1) ^ ((noise & 1) ? 0x14000 : 0);

The lowest bit resulting from this calculation is used to add noise to any channel with noise enabled.