PSG (TG-16)

From Data Crystal
Revision as of 04:46, 3 March 2016 by Zonk47 (talk | contribs)
Jump to navigation Jump to search

(the following is an excerpt from the research notes of David Shadoff, for TGHack)

Register Map

Note: all addresses are segment $FF-relative.

[code]

$0800 Voice Select select voice # $07 (only 3 bits used)
$0801 Main Volume

Most sig. 4 bits = left channel

Least sig. 4 bits = right channel

not a voice-dependent register

$FF
$0802 Frequency (low) Least sig. 8 bits of 12-bit frequency counter, for voice selected by 'Voice Select' $FF
$0803 Frequency (high) Most sig. 4 bits of 12-bit frequency counter, for voice selected by 'Voice Select' $0F
$0804 Channel on/dda/volume

bit 7 = voice enabled

bit 6 = 'dda' - 'Direct digital-to-analogue'(?) With this flag set, any value written into the 'wave data' location will directly appear on the channel's output, rather than be stored in the circular wave buffer

bit 0-4 = voice volume

voice-dependent register

$CF
$0805 Pan volume ('balance')

Most sig. 4 bits = left channel

Least sig. 4 bits = right channel

voice-dependent register

$FF
$0806 Wave data Samples are inserted into a 32-address circular buffer when this address is written to. Only 5 data bits are used. (voice-dependent register) $1F
$0807 Noise (available only to voices 5 & 6)

bit 7 = noise enable

bit 0-4 = noise frequency (for more details, see patent)

voice-dependent register

$9F

The LFO is not a per-voice attribute. Unfortunately, I don't know much else about it, or understand how these affect sound:

Address Name Mask Description
$0808 LFO Frequency $FF
$0809 LFO Control $83 bit 7 = LFO trigger (?)

bit 0&1 = LFO Control (?)

About the 'frequency' values:

First, I discovered that the values are inverse - a higher value means a lower tone. Second, I had to use the value $1b4 to get a 256Hz tone from the PC-Engine. From this, I worked out that the sound chip has a base clock of 3.58MHz (common in these systems, since this is the NTSC colorburst frequency), and uses the 'frequency' value as a down-counter (or divider). Once the value reaches 0, a 'step' is performed. In this case, the 'step' means advancing to the next sample in the 5-bit, 32-sample waveform for that voice.

So, 3.58Mhz / $1b4 (436 decimal) / 256Hz = 32 samples/cycle

This all starts to make sense when you realize that the PCE put the sound generator inside the CPU -- it's all simple digital stuff, up until the D/A output. [/code]