PSG

From Intellivision Wiki

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)

Contents

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 provides 3 independent analog output channels. The PSG provides a dedicated square wave tone generator and D/A converter for each of the three output channels. It also provides a single noise generator and single volume envelope generator, both can be mixed with any combination of the three channels. The Intellivision mixes the output of the three analog channels directly to produce the final audio output.


The square wave tone generators work by dividing the PSG's sound clock by a 12-bit value. On NTSC systems, the effective sound clock is 3.579545MHz / 16 = 223721.5625Hz. On PAL systems, the sound clock is 4MHz / 16 = 250000Hz. The tone generator toggles at the rate (sound clock / pitch period). Because two toggles make a full square wave, the actual frequency of the resulting square wave is half that: (sound clock / pitch period / 2). This translates to a frequency range from 111860Hz to 27.31Hz on NTSC systems, and 125000Hz to 30.52Hz on PAL/SECAM. Note that a channel period value of zero actually indicates a period of 4096. The following equations convert pitch period to frequency for both systems:

           3.579545MHz
F_tone =  -------------  for NTSC
           32*P_channel

           4.000000MHz
F_tone =  -------------  for PAL 
           32*P_channel


Each channel has separate control bits to enable tone and noise. The output of the tone generator gets mixed with the output of the shared noise generator with the following equation:

   channel_output = (noise_enable OR noise_generator_output) AND (tone_enable OR tone_generator_output)

Because the PSG logically-ANDs the two sources together, the resulting output can sound "gritty", particularly when the tone generator outputs low pitched tones. Examples include the tank sound effects in Armor Battle, and the explosion sound effects in River Raid.


The PSG sends the binary 0/1 mixed output to the D/A converter. The D/A converter applies the channel's selected volume to this binary stream. For volume levels $00 through $0F, the PSG outputs a fixed volume level for the channel. For volume levels $30 - $3F, the PSG uses the current output level from the shared envelope generator.


Note: Some PSG variants have 5 volume control bits and some have 6. On devices with 5-bit volume registers, volumes $10 - $1F select the envelope generator as the volume source. On devices with 6-bit volume registers, $30 - $3F selects the envelope generator in the same manner. On these 6-bit volume devices, however, $10 - $1F select the envelope shifted right by 2 bits, and $20 - $2F select the envelope shifted right by 1 bit, resulting in "quiet" envelopes. For consistency across all variants, programs should write $3F to select the envelope generator for a particular channel, and should tolerate reading back $1F after having written $3F to a given channel's volume register.

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.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox