;****************** Constant Definitions ****************** symbol control = outpinsA ;control lines to the AY chip symbol BC1 = A.0 ;A.0 is BC1 on the AY chip symbol BDIR = A.1 ;A.1 is BDIR on the AY chip symbol bus = outpinsB ;data/address bus to AY chip symbol AYpulse = 4 ;2.5 uSec for pulsout ;AY-8910 control codes and register addresses symbol inactive = %00000000 symbol latchAddr = %00000011 symbol Reg7 = %00000111 ;Register 7 - data direction symbol Reg14 = %00001110 ;Register 14 - Port IOB symbol IOAOut = %11110111 ;enable IOA and noise on A ;****************** Variable Definitions ****************** symbol value = b0 ;register number (0-15) symbol register = b1 ;value to store in register symbol i = b2 ;index ;********************** Main Program ********************** pgm: setfreq em64 ;64 MHz external resonator dirsA = %00001111 ;A.0-A.3 are outputs dirsB = %11111111 ;B.0-B.7 are outputs dirsC = %00000010 ;C.1 is AY clock pwmout C.1, 7, 16 ;start AY clock at 2 MHz gosub init ;set up the AY chip register = 8 ;make Noise fixed on value = %00001111 gosub store main: for i = 31 to 0 step -1 register = 6 ;Noise Frequency value = i gosub store pause 800 next i ;endless loop to play A 440 goto main end ;************* Initialize AY on power-up ************* init: control = inactive ;clear BC1, BDIR ;set up the AY Port IOA for output control = latchAddr ;latch address to register 7 bus = Reg7 control = inactive bus = IOAOut ;enable IOA and Tone A pulsout BDIR,AYpulse control = latchAddr ;latch address to register 15 bus = Reg14 control = inactive bus = $FF ;turn all gates off pulsout BDIR,AYPulse return ;*************** Send Value to AY Register ************** ;Pass in register and value at entry store: control = inactive ;clear BC1, BDIR control = latchAddr ;latch address of register bus = register control = inactive bus = value ;get value and pulsout BDIR,AYPulse ;store it return