AY-3-8912 Music Demo

Developer(s): Rene Bruneau
Date: 1994
Type: Program
Platform(s): ZX81, TS 1000
Tags: Sound

The machine code and demo program for Rene Bruneau’s AY-3-8912 sound board for the ZX81 and TS1000, built from the article’s schematic. The 568 bytes of code sit in a REM in line 1 and add three commands, written as IF USR M THEN LPRINT command;parameters with M=16586: P (play: duration, envelope, noise and tone channels), M (music: volume, note, octave, channel) and S (sound: volume, pitch, channel). Commands can be chained with semicolons, and USR 17037 reads the chip’s I/O port. The demo menu has a sound sweep, an envelope player and a run through twelve notes in seven octaves.

The download is the finished program the article describes. Line 1 is the PRINT line of 80 zeros, turned into a REM by POKE 16513,234, holding the Figure 5 bytes; the Figure 6 demo follows it. Start it with GOTO 100, because RUN begins with SAVE “MUSIC”. It needs the sound board (ports 215 and 223). As printed, menu option 1 stops at line 205 with report I: lines 205 and 240 put a comma after the command letter where the other lines have a semicolon; changing them to ; fixes it. Line 3 says the REM holds 650 bytes; the code is 568.

Published in Sinc-Link July-August 1994 (Sound for the ZX81).

Image Gallery

Source Code

Figure 5. Machine Code Data (16514-17081, in the line 1 REM)
16514 - 7676F57EFE1A2802 = 929
16522 - CF18F1C9221640CD = 998
16530 - 550FE5CDCD15E1C9 = 1186
16538 - 221640CD550FE5CD = 859
16546 - A70EE1C9CD8E40CD = 1223
16554 - 8440C9CD9A40CD84 = 1157
16562 - 40C92A16407EFE19 = 798
16570 - 2824FE762802CF0D = 710
16578 - E1221640010000C9 = 547
16586 - 2A16407EFEDE2802 = 772
16594 - CF11E5237E11C240 = 889
16602 - D5FEE120F3D111B4 = 1373
16610 - 40D5237E47237EFE = 924
16618 - 7628E5FE1920F678 = 1064
16626 - FE32CA0641FE38CA = 1089
16634 - 8241FE35CAE741C3 = 1195
16642 - D240CF0A23CDA640 = 961
16650 - FE162872A72002C6 = 829
16658 - 16323D4023CDA640 = 667
16666 - FE0D3062A7285FD6 = 929
16674 - 0187E52175420600 = 587
16682 - 4F097E23464FED43 = 702
16690 - 3F40E123CDA640FE = 1076
16698 - 0730433CED4B4040 = 622
16706 - 473A3F401807CB19 = 515
16714 - CBB9CB1FA710F732 = 1102
16722 - 3F407932414023CD = 667
16730 - 8E40FE043020A728 = 751
16738 - 1DF5C607323C40F1 = 894
16746 - D60187323E403C32 = 636
16754 - 4040E50603213C40 = 523
16762 - CD6A42C3B440CF15 = 1044
16770 - 23CDA640FE103036 = 842
16778 - A72002C610323D40 = 590
16786 - 23CDAD4079323F40 = 775
16794 - 7832414023CD8E40 = 745
16802 - FE07301AA72817F5 = 810
16810 - FE043014C607323C = 641
16818 - 40F1D60187323E40 = 831
16826 - 3C324040181BCF1B = 523
16834 - C604323C40F13E06 = 685
16842 - 323E403240403A3F = 475
16850 - 40324140FE20D2C0 = 931
16858 - 41E50603213C40CD = 665
16866 - 6A42C3B44023CDAD = 1024
16874 - 4079323D4078323F = 593
16882 - 403E0B323C403C32 = 421
16890 - 3E4023CDA640FE09 = 859
16898 - 3043A72802C60732 = 579
16906 - 41403E0D3240403E = 444
16914 - 0732424023CDA640 = 657
16922 - FE083029CB27CB27 = 835
16930 - CB2732434023CD8E = 805
16938 - 40FE083018E52143 = 727
16946 - 40B62F324340FEFF = 983
16954 - 280D0604213C40CD = 425
16962 - 6A42C3B440CF18AF = 1017
16970 - 323C40323D400614 = 375
16978 - 213C407ED3D73423 = 796
16986 - 7ED3DF10F33E07D3 = 1099
16994 - D73EFFD3DFC3B440 = 1405
17002 - 7ED3D7237ED3DF23 = 1182
17010 - 10F6C9F1068E0630 = 906
17018 - 06D70583053405E9 = 652
17026 - 04A20460042004E6 = 536
17034 - 03AE033E07D3D7DB = 894
17042 - D7CBB7D3DF3E0ED3 = 1322
17050 - D7DBD7EEFF4F0600 = 1227
17058 - C93E07D3D7DBD7CB = 1333
17066 - F7D3DF3E0ED3D73A = 1241
17074 - 3240D3DFC9000000 = 749

Figure 6. Music Demo
1 PRINT (80 zeros separated by plus signs), then POKE 16513,234
2 REM  MACHINE CODE SAVED IN           LINE 1
3 REM  LINE 1 CONTAINS 650             BYTES
10 SAVE "MUSIC"
100 LET M=16586
110 IF USR M THEN LPRINT P;0,0,0,0
120 GOTO 1000
200 REM SOUND DEMO                      VOLUME 0-15                     PITCH  0-65335                  CHANNEL 1-6
205 IF USR M THEN LPRINT P,0,0,0,1
210 FOR P=1 TO 500 STEP 10
220 IF USR M THEN LPRINT S;5,8*P,1
230 PAUSE 10
240 IF USR M THEN LPRINT S,5,4*P,1
250 PAUSE 10
260 IF USR M THEN LPRINT S;5,12*P,1
270 PAUSE 10
280 NEXT P
290 IF USR M THEN LPRINT P;0,0,0,0
295 GOTO 1000
300 REM PLAY DEMO                       DURATION 0-32767                ENVELOPE 0-7                    NOISE CHANNEL 0-7               TONE CHANNEL 0-7
305 CLS
310 PRINT "INPUT ENVELOPE SHAPE"
320 INPUT E
325 IF E>8 THEN GOTO 1000
330 PRINT "INPUT DURATION"
340 INPUT D
350 IF USR M THEN LPRINT S;0,150,1;P;D,E,0,1
360 PRINT AT 10,2;"PRESS ANY KEY TO RE-ENTER"
370 PAUSE 4E4
375 IF USR M THEN LPRINT S;0,150,1;P,0,0,0,1
380 CLS
390 GOTO 300
400 REM MUSIC DEMO                      VOLUME 0-15                     NOTE 1-12                       OCTAVE 0-6                      CHANNEL 1-3
405 CLS
410 IF USR M THEN LPRINT P;0,0,0,1
420 FOR O=0 TO 6
425 PRINT O;" ";
430 FOR N=1 TO 12
435 PRINT N;" ";
440 IF USR M THEN LPRINT M;3,N,0,1
460 NEXT N
465 PRINT
470 NEXT O
480 IF USR M THEN LPRINT P;0,0,0,0
1000 CLS
1010 PRINT "AY-8210 SOUND DEMO"
1020 PRINT AT 6,5;"1.  SOUND DEMO"
1030 PRINT AT 8,5;"2.  PLAY DEMO"
1040 PRINT AT 10,5;"3.  MUSIC DEMO"
1050 PRINT AT 20,5;"PRESS 1,2, OR 3"
1060 IF INKEY$="" THEN GOTO 1060
1070 IF INKEY$="1" THEN GOTO 200
1080 IF INKEY$="2" THEN GOTO 300
1090 IF INKEY$="3" THEN GOTO 400
2000 PRINT AT 20,5;"PRESS 1,2, OR 3"
2010 GOTO 1050
8000 PRINT USR 17037
8001 PAUSE 10
8002 GOTO 8000

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.