Sunsoft 5B audio
The Sunsoft 5B is a superset of the Sunsoft FME-7. It is identical to the FME-7 except it contains extra audio hardware. This audio hardware was only used in one game, Gimmick!
Registers
The audio hardware is a type of the General Instrument AY-3-8910 PSG, or Yamaha's YM2149F variant.
Audio Register Select ($C000)
7......0 ----RRRR ++++- The 4-bit internal register to select for use with $E000
Audio Register Write ($E000)
7......0 VVVVVVVV ++++++++- The 8-bit value to write to the internal register selected with $C000
Internal audio registers
The AY-3-8910 has 16 internal audio registers, selected with $C000 and written to with $E000.
Register | Bitfield | Description |
---|---|---|
$00 | LLLL LLLL | Channel A low period |
$01 | ---- HHHH | Channel A high period |
$02 | LLLL LLLL | Channel B low period |
$03 | ---- HHHH | Channel B high period |
$04 | LLLL LLLL | Channel C low period |
$05 | ---- HHHH | Channel C high period |
$06 | ---P PPPP | Noise period |
$07 | --CB Acba | Noise enable on channels C/B/A, Tone enable on channels c/b/a |
$08 | --EV VVVV | Channel A envelope enable (E), volume (V) |
$09 | --EV VVVV | Channel B envelope enable (E), volume (V) |
$0A | --EV VVVV | Channel C envelope enable (E), volume (V) |
$0B | LLLL LLLL | Envelope low period |
$0C | ---- HHHH | Envelope high period |
$0D | ---- CAaH | Envelope shape: continue (C), attack (A), alternate (a), hold (H) |
$0E | ---- ---- | I/O port A (unused) |
$0F | ---- ---- | I/O port B (unused) |
Sound
There are three channels that output a square wave tone. In addition there is one noise generator, and one envelope generator, both of which may be used by any of the three channels.
Tone
TODO frequency formula
Noise
TODO noise frequency / generator
Envelope
TODO envelope period formula
The envelope shape has four parameters: continue, attack, alternate, and hold.
- Continue specifies whether the envelope continues to oscillate after the attack. If it is 0, the alternate and hold parameters have no effect.
- Attack specifies whether the attack goes from high to low (0) or low to high (1).
- Alternate specifies whether the signal continues to alternate up and down after the attack. If combined with hold it provides an immediate flip after the attack followed by the hold.
- Hold specifies that the value shall be held after the attack. If combined with alternate, the value at the end of the attack will be immediately flipped before holding.
Value | Continue | Attack | Alternate | Hold | Shape |
---|---|---|---|---|---|
$00 - $03 | 0 | 0 | x | x | \_______ |
$04 - $07 | 0 | 1 | x | x | /_______ |
$08 | 1 | 0 | 0 | 0 | \\\\\\\\ |
$09 | 1 | 0 | 0 | 1 | \_______ |
$0A | 1 | 0 | 1 | 0 | \/\/\/\/ |
$0B | 1 | 0 | 1 | 1 | \""""""" |
$0C | 1 | 1 | 0 | 0 | //////// |
$0D | 1 | 1 | 0 | 1 | /""""""" |
$0E | 1 | 1 | 1 | 0 | /\/\/\/\ |
$0F | 1 | 1 | 1 | 1 | /_______ |
Output
The tone channels each produce a 4-bit signal which is then converted to analog with a logarithmic DAC.
TODO details of log conversion, and final mixing.