The sound chip used in Pacman is a 3-channel Waveform Sound Generator (WSG) custom-made by Namco. It allows up to three simultaneous voices each with independent control over its volume, frequency and waveform. All of the chip functions are controlled by the following 4-bit registers:
Register Description 00h-04h Voice #1 frequency counter 05h Voice #1 waveform (only 3 bits used) 06-09h Voice #2 frequency counter 0Ah Voice #2 waveform (only 3 bits used) 0Bh-0Eh Voice #3 frequency counter 0Fh Voice #3 waveform (only 3 bits used) 10h-14h Voice #1 frequency 15h Voice #1 volume 16h-19h Voice #2 frequency 1Ah Voice #2 volume 1Bh-1Eh Voice #3 frequency 1Fh Voice #3 volume
Frequencies and counters are 20-bit values stored with the least significant nibble first. Voice #2 and #3 are missing the register for the least significant nibble and it is assumed to be always zero.
These registers are usually mapped into the memory space of the CPU. In the Pacman hardware the memory locations at 5040h-505Fh map the sound registers, so for example writing a value at the address 505Ah sets the volume of voice #2.
Sound generation is based on a table that contains 8 different waveforms, where each waveform is described by 32 4-bit entries. For versatility and reuseability, this data is kept outside of the chip in a 256 byte PROM.
The chip itself is clocked at 96 KHz, which is the main CPU clock (3.072 MHz) divided by 32. At each cycle the frequency counter for each voice is incremented by the voice frequency, then the most significant 5 bits are used as an index to retrieve the current wave sample from the waveform table. The sample is then multiplied by the voice volume and sent to the amplifier for output. Note that a voice is actually muted if its volume or frequency is zero.
Copyright (c) 1997-2004 Alessandro Scotti. All rights reserved.