
| Overview | ||||||||||||||
| The AY-3-8910/8912 is a sound generator IC containing three tone generators and a white noise generator. In addition to its sound producing capabilities, the AY-3-8910 has two 8-bit I/O ports and the AY-3-8912 has one. | ||||||||||||||
| Pinouts (for the AY-3-8912 only) | ||||||||||||||
| 
               +----+--+----+
Channel C out -+  1 |__| 28 +- DA0
               |            |
       Test 1 -+            +- DA1
               |            |
          +5V -+            +- DA2
               |            |
Channel B out -+            +- DA3
               |            |
Channel A out -+            +- DA4
               |            |
          GND -+            +- DA5
               |            |
         IOA7 -+            +- DA6
               |            |
         IOA6 -+            +- DA7
               |            |
         IOA5 -+            +- BC1
               |            |
         IOA4 -+            +- BC2
               |            |
         IOA3 -+            +- BDIR
               |            |
         IOA2 -+            +- A8
               |            |  _____
         IOA1 -+            +- RESET
               |            |
         IOA0 -+ 14      15 +- CLK
               +------------+
DA0-DA7 are multiplexed data and address lines, as used in the range of GI
processors that this IC was originally part of. The BC1 and BDIR pins are
used to control the IC as follows:
Function       BDIR   BC1
        
Inactive         0     0
Read             0     1
Write            1     0
Latch address    1     1
In addition to using BC1 and BDIR, A8 should be taken high to enable the
chip. IOA0-IOA7 are the input/output pins (the AY-3-8910 has an additional
set marked IOB0-IOB7). The IC does not contain an internal oscillator - the
clock input to the CLK pin should fall between 1MHz-2MHz, so a typical Z80
system's clock would need to be divided. | ||||||||||||||
| Registers | ||||||||||||||
| The AY-3-8910/8912 contains 16 internal registers as follows: Register Function Range 0 Channel A fine pitch 8-bit (0-255) 1 Channel A course pitch 4-bit (0-15) 2 Channel B fine pitch 8-bit (0-255) 3 Channel B course pitch 4-bit (0-15) 4 Channel C fine pitch 8-bit (0-255) 5 Channel C course pitch 4-bit (0-15) 6 Noise pitch 5-bit (0-31) 7 Mixer 8-bit (see below) 8 Channel A volume 4-bit (0-15, see below) 9 Channel B volume 4-bit (0-15, see below) 10 Channel C volume 4-bit (0-15, see below) 11 Envelope fine duration 8-bit (0-255) 12 Envelope course duration 8-bit (0-255) 13 Envelope shape 4-bit (0-15) 14 I/O port A 8-bit (0-255) 15 I/O port B 8-bit (0-255)Notes: 
 The mixer (register 7) is made up of the following bits (low = enabled): 
Bit: 7        6        5        4        3        2        1        0
   _         _
   I/O       I/O   Noise    Noise    Noise     Tone     Tone     Tone
     B        A        C        B        A        C        B        A
The AY-3-8912 ignores bit 7 of this register. | ||||||||||||||
| Envelopes | ||||||||||||||
| The AY-3-8910/8912 contains the following preset envelopes or waveforms (set
using control register 13). Note that these affect volume only and not the
pitch: 
 0      \__________     single decay then off
 4      /|_________     single attack then off
 8      \|\|\|\|\|\     repeated decay
 9      \__________     single decay then off
10      \/\/\/\/\/\     repeated decay-attack
          _________
11      \|              single decay then hold
12      /|/|/|/|/|/     repeated attack
         __________
13      /               single attack then hold
14      /\/\/\/\/\/     repeated attack-decay
15      /|_________     single attack then off
 | ||||||||||||||
| Pitch values | ||||||||||||||
| The course and fine pitch registers for each channel are used in the
following fashion (assuming channel A): Registers 0 and 1 operate together to form channel A's final pitch. The eight least significant bits are sent to register 0 and the four most significant bits are sent to register 1. The output frequency is equal to the IC's incoming clock frequency divided by 16 and then further divided by the number written to the course and fine pitch registers, so the higher the number written to these, the lower the pitch. For example, if a frequency of 1KHz was required and the IC's clock frequency was 1MHz, a total division rate of 1000 would be needed. The sound generator itself divides by 16 so the course and fine pitch registers must provide a further division by 62.5 (due to the fact that 1000/16 is 62.5). A division rate of 62 or 63 will be accurate enough, since the registers can only store whole numbers. Therefore, 62 or 63 would be written to register 0 and 0 would be written to register 1. The following frequency table may be useful in musical applications: Note Frequency (Hz) Note Frequency (Hz) A 220 D# 311.1 A# 233.3 E 329.63 B 246.94 F 349.23 middle C 261.63 F# 370 C# 277.2 G 392 D 293.66 G# 415.3 | ||||||||||||||
| Applications | ||||||||||||||
| The AY-3-8910/8912 (and derivatives) found its way into a variety of
home computers and games consoles including the following: 
 There are also numerous emulators for various platforms that will emulate an entire ZX Spectrum along with the AY-3-8912. A notable mention if you wish to emulate only the Z80 and AY-3-8912 is "DeliAY" by Patrik Rak for the Commodore Amiga. This comes as an add-on for "DeliTracker" (a music player) and emulates a Z80 and AY-3-8912 (in a Spectrum-like fashion) giving very accurate results. A fair number of Spectrum tunes have been gathered together to run under this player. For the PC, an emulator can be used, or a program (available stand-alone or as a WinAmp plugin) called STSound can play back AY/Yamaha music. This works on files containing the values sent to the soundchip rather than by emulating a CPU and running the original code. As a result, it can play back Atari ST, Amstrad CPC and ZX Spectrum 128 music. Also worth looking at, though slightly off-topic, are SIDPlay, PlaySID and its derivatives for both the Amiga and the Linux, BeOS or Windows-based PC. This emulates the 6502/6510 and the SID chip of the Commodore 64 and can play back its tunes. | ||||||||||||||
| ZX Spectrum 128 specifics | ||||||||||||||
| The Spectrum's "control" and "data" output ports are as follows: 
 So, to produce a simple sound from BASIC ... 
        10 LET ayctrl=65533
        20 LET aydata = 49149
        30 OUT ayctrl,7 : REM select the mixer register
        40 OUT aydata,62 : REM enable channel A only
        50 OUT ayctrl,1 : REM channel A course pitch
        60 OUT aydata,7 : REM set it
        70 OUT ayctrl,8 : REM channel A volume
        80 OUT aydata,15 : REM set it to maximum
... or from assembler ...
        ayctrl  EQU     65533
        aydata  EQU     49149
        start   ld      d,7             ; select the mixer register
                ld      e,62            ; enable channel A only
                call    outer           ; send it to PSG
                ld      d,1             ; channel A course pitch
                ld      e,7             ; pitch value
                call    outer           ; send it to PSG
                ld      d,8             ; channel A volume
                ld      e,15            ; maximum
                call    outer           ; send it to PSG
                ret
        outer   ld      bc,ayctrl       ; select control port
                out     (c),d           ; send specified value
                ld      bc,aydata       ; select data port
                out     (c),e           ; send specified value
                ret
For an easy way to generate the required course and fine pitch values, try
the following program:
        10 INPUT "Note value ",n
        20 INPUT "Octave ",o
        30 LET f=INT(n/2^o)
        40 LET c=INT(f/256)
        50 PRINT "Fine = ";f;"  Course = ";c
The pitch values required by this program are as follows:Note Value Note Value C 3421 F# 2419 C# 3228 G 2283 D 3047 G# 2155 D# 2876 A 2034 E 2715 A# 1920 F 2562 B 1892 | ||||||||||||||
| References | ||||||||||||||
| Micro Interfacing Circuits - Book 2, by R. A. Penfold, ISBN 0-85934-106-2, Sinclair ZX Spectrum 128 manual, © 1986 Sinclair Research Ltd, Sinclair User magazine, 1986 (issue unknown). This text was created on 4th April 1995 and finally converted into HTML (and updated slightly) on 22nd February 2000. Please feel free to contact me regarding anything mentioned here. I don't suppose there are many people still using this! | 
| © 1995-2000 ACB: 04/04/95 - 22/02/00   |