From MegaDrive Wiki
Revision as of 11:29, 16 March 2015 by Tristanseifert (talk | contribs) (13 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
A 1 kHz square wave under ideal conditions

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 Frequency

A 1 kHz square wave.

Setting the frequency of a PSG channel can be accomplished by writing two bytes to the PSG's memory area:

Setting PSG frequency
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 R2 R1 R0 d3 d2 d1 d0 0 0 d9 d8 d7 d6 d5 d4
  • 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
R2 R1 R0 Tone Channel
0 0 0 Channel 1
0 1 0 Channel 2
1 0 0 Channel 3

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:

NF1 NF0 Clock Source
0 0 Clock/2 (higher pitch, less coarse)
0 1 Clock/4
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:

Setting Noise
7 6 5 4 3 2 1 0
1 1 1 0 0 FB NF1 NF0
  • 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:

Setting Attenuator
7 6 5 4 3 2 1 0
R2 R1 R0 1 A3 A2 A1 A0
  • 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. [1]

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.


SN76489 chip
The SN76489 is a TTL compatible, 4 channel Programmable Sound Generator (PSG) 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.



  1. SMSPower.orgTmEE's discovery of waveform reset.