AY Crudentials: Accessing the AY

Probably the most technical forum around. It does not have to be coding related, or assembly code only. Just talk about how you can use the AY chip to do cool sounding things :)
Post Reply
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

AY Crudentials: Accessing the AY

Post by Twilighte » Fri Jan 20, 2006 9:58 pm

The AY-3-8912 is not memory mapped in the Oric and the method of accessing it is obscure (to say the least).
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
Note: it is assumed that when starting, the control register is $DD

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.

User avatar
Dbug
Site Admin
Posts: 2389
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: AY Crudentials: Accessing the AY

Post by Dbug » Sun Jul 31, 2011 4:42 pm

Twilighte wrote: 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
...
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
I was checking my old replay code, and I found out that instead of FD and DD I have EC and CC:

Code: Select all

sta VIA_ORA
lda #$EC
sta VIA_PCR
lda #$CC
What's the actual difference and the impact?

telbee
Private
Posts: 7
Joined: Mon May 30, 2011 11:15 pm
Location: Northern Ireland
Contact:

Re: AY Crudentials: Accessing the AY

Post by telbee » Wed Aug 03, 2011 10:54 pm

I was checking my old replay code, and I found out that instead of FD and DD I have EC and CC:

Code: Select all

sta VIA_ORA
lda #$EC
sta VIA_PCR
lda #$CC
What's the actual difference and the impact?

Hi there.

Both bits of code will work equally well. The difference is in the CA1 and CB1 control bits in the PCR of the 6522 VIA. Bit 0 of the PCR (at location $30C on Oric) relates to CA1 which is the 'ACK' line of the printer port and bit 4 relates to CB1 which is connected to the Tape In circuitry.

Neither should make any difference as both the printer and tape routines in ROM set up the 6522 VIA anyway.

I guess the only way it could make a difference is if the VSYNC hack is implemented (on a real Oric!) as it's fed through the tape input.

I hope I haven't made this ten times more boring than it needed be!

T

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Thu Aug 04, 2011 9:13 am

Dbug, you have the advanced user guide, refer to page 38 and see that it controls four lines.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests