However, with a little knowledge, it is easy enough to write and read from any register.
The AY-3-8912 is linked to the system by the way of one data/register port and 2 control lines.
The control lines are known as CA2 and CB2 since they are held within the VIA 6522 and may be set/reset in Memory location $030C.
The Data/Register Port is also used by the Printer Port (Which may also be attached to a joystick interface) and appears at location $030F.
The control line Register (Also known as the PCR) actually controls the behaviour of CA1,CA2,CB1 and CB2, but for the most part, we can get away with 3 values directly poked into this location.
The three values are...
$DD == $030F is inactive
$FD == $030F holds data for a preset Register
$FF == $030F holds a Register number
The AY-3-8912 has 15 Registers numbered $00 to $0E.
00 Bits 0 to 7(0-255) - Pitch Register LSB Channel A
01 Bits 0 to 3(0-15) - Pitch Register MSB Channel A
02 Bits 0 to 7(0-255) - Pitch Register LSB Channel B
03 Bits 0 to 3(0-15) - Pitch Register MSB Channel B
04 Bits 0 to 7(0-255) - Pitch Register LSB Channel C
05 Bits 0 to 3(0-15) - Pitch Register MSB Channel C
06 Bits 0 to 4(0-31) - Noise Pulsewidth
07 Bit 0(0-1) - Link Pitch A to Output D/A converter A
07 Bit 1(0-1) - Link Pitch B to Output D/A converter B
07 Bit 2(0-1) - Link Pitch C to Output D/A converter C
07 Bit 3(0-1) - Link Noise to Output D/A converter A
07 Bit 4(0-1) - Link Noise to Output D/A converter B
07 Bit 5(0-1) - Link Noise to Output D/A converter C
08 Bits 0-3(0-15) - D/A Converter Amplitude(Volume) A
08 Bit 4 - Envelope Generator controls Amplitude of A
09 Bits 0-3(0-15) - D/A Converter Amplitude(Volume) B
09 Bit 4 - Envelope Generator controls Amplitude of B
0A Bits 0-3(0-15) - D/A Converter Amplitude(Volume) C
0A Bit 4 - Envelope Generator controls Amplitude of C
0B Bits 0 to 7(0-255) Envelope Generator Period Counter LSB
0C Bits 0 to 7(0-255) Envelope Generator Period Counter MSB
0D Bits 0 to 3(0-15) Envelope Generator Cycle Register
So to write the value of 15 into register 8 (Volume of channel A) the following code could be used...
Code: Select all
LDA #8 'Set the register to 8
STA $030F
LDA #$FF
STA $030C
LDA #$DD
STA $030C
LDA #15 'Set the Value for this register
STA $030F
LDA #$FD
STA $030C
LDA #$DD 'Reset the state of the control lines
STA $030C
It is also worth mentioning that when setting the register, the last value in $030C is taken so in some scenarios it is unneccasary to set the control lines inactive whilst setting the Register.