The Mega Drive contains a PSG chip closely related, derived from but not completely identical to the popular SN76489, integrated into the VDP. This chip is capable of producing three square wave channels at a variating volume and frequency, as well as one noise channel. Even though square waves should look like perfect squares, they don't rise and fall from full to ground potential immediately so some slanting will be visible, but this will be disregarded in examples in this article. The PSG chip is mapped into Motorola 68000 address space at $C00011, and at $7F11 on the Zilog Z80.
The SN76489 is programmed through the use of various registers. Frequencies are set in 10 bit registers and counted down until they reach 0, at which point the output waveform for that channel will toggle and the counter gets reloaded. This counter is ran at 3.58MHz, the same clock as the Z80. Higher values in these registers produce lower frequencies. The noise channel can be set as either a periodic or white noise mode. The noise channel's clock source can be chosen between the main clock divided by 2, 4 or 8, or the third tone channel. Attenuation can also be set, which allow variations in the volumes of the various channels, in 2 db steps down from 0 db to 28 db, with each step dividing the volume by two.
Setting the frequency of a PSG channel can be accomplished by writing two bytes to the PSG's memory area:
|Setting PSG frequency|
- R2 through R0: These bits specify the tone channel to write to. See the table below.
- d9 through d0: The 10 bit frequency counter value to write.
|Tone Channel Map|
Configuring Noise Channel
The noise channel can be used to create percussion effects. This trick is often used when the PSG chip is the only one available, although it may also be used to complement other percussion sounds created by the YM2612. The noise channel can be configured in two modes: A periodic type noise, and white noise. The frequency of the noise can be selected from four modes:
|0||0||Clock/2 (higher pitch, less coarse)|
|1||0||Clock/8 (lower pitch, more coarse)|
|1||1||Tone Generator 3|
With the clock source set to Tone Generator 3, its output square wave will be used as the clock source for the noise. The register is set like so:
- FB: When set, the noise will be white noise, periodic noise if clear.
- NF1 and NF0: Set the clock source for the noise as described above.
Each channel has an attenuator, which can be used to attenuate, or change the output level to make the channel quieter or louder. Each step down, for example from 0 db to 2 db halves the volume. The attenuator can be set in steps from 2 db, starting at 0 db (full volume) down to 28 db, after which the next step will completely disable sound. The attenuator can be set as follows:
- R2 to R0: Sets the channel to write to, as indicated in the table in the above section.
- A3 to A0: Sets the attenuation value, with 0000 being 0 db, and 1111 being off.
Note: Any writes to the Attenuators will reset the waveform to high level, as recently found out by TmEE. 
PSG abuse to play PCM
Afterburner II was probably the first game to implement PCM playback through a PSG channel. How this works is basically very simple.
- Set the frequency to 0Hz
- Set the attenuation (careful! Logarithmic! Advisable is to convert the PCM data beforehand!) to match PCM data.
Done! A side effect is of course only the positive phase gets used, and the quality isn't very good either, but this is somewhat mitigated by the fact that it's possible to write samples at whatever sample rate desired, basically as fast as the CPU can push data to it.
SN76489PSG) IC from Texas Instruments. Its main application has been entertainment and it has been used to provide music and sound effects in Game consoles, arcade hardware and home computers. It's also the chip used to provide PSG functionality in the Mega Drive.
Features of the SN76489 include:
- Three programmable square wave tone generators
- One programmable white noise generator
- Programmable attenuation
- Mono audio output
The frequency of the square waves produced at each channel is derived by two factors: the speed of the external clock and a value provided in a control register for that channel (called N). The eventual frequency is arrived at by dividing the external clock by 32 and then dividing the result by N for each channel. The SN76489 is included 'on-chip' in Sega's Video Display Processors (VDP) for their Master System, Game Gear, and Mega Drive game consoles.
- SMSPower.orgTmEE's discovery of waveform reset.