Tone Generator

Author(s): Nels Anderson
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v4 n1 (Volume 4, Issue 1)
Date: January 1983
Pages: 16-17

You can generate tones on your ZX/TS by building this circuit and using a machine code routine with it connected. The hardware memory maps from 32K to 64K. Any address that turns on A15 strobes the 4013 D-flip flop. Output of the 4013 drives an audio amplifier. The capacitor, resistor and diode connected to 4013 reset it on powerup.

   1 REM .............................................................................................................................................
10 FOR I=1 TO 141
20 INPUT A
30 POKE 16513+I,A
40 SCROLL
50 PRINT 16513+I,PEEK (16513+I)
60 NEXT I

RUN this program and enter the numbers from Table 1 one at a time. After the program stops, delete all lines except 1.

                  Table 1
042 041 064 017 005 000 025 034 013
065 042 013 065 205 224 064 200 237
083 011 065 205 224 064 200 237 083
009 065 034 013 065 001 000 000 042
011 065 229 084 093 025 025 017 025
000 025 235 042 009 065 003 175 237
082 242 181 064 087 225 229 050 255
255 043 124 181 032 251 205 070 015
210 166 003 122 214 001 087 121 222
000 079 120 222 000 071 177 178 032
224 193 024 172 126 254 118 200 214
028 023 023 023 023 230 240 087 035
126 214 028 178 087 035 126 214 028
023 023 023 023 230 240 095 035 126
214 028 179 095 035 035 246 001 201
000 000 000 000 000 000

To use the tone generator call USR 16514. Put the tones and their lengths in a REM statement right after the USR call. Tone and duration are both four digit hex numbers and any number of pairs may be used. Experiment to determine what numbers give desired durations.

Line 1 REM as listed after the machine code is POKEd in
Line 1 REM as listed after the machine code is POKEd in
   2 FAST
10 RAND USR 16514
20 REM 0079 0300 0045 0300 005D 0100 0061 0100 006D 0100 003D 0300 0051 0300 005D 0100 0061 0100 006D 0100 003D 0300 0051 0300 005D 0100 0061 0100 005D 0100 006D 0300.
SYNTACTIC SUM: 20138, 8K ROM

The numbers must be in pairs (4 digit tone, space, 4 digit duration) and must be separated by spaces. A period must be at the end of the line.

Use this table for a specific note’s tone number (be sure to add two leading zeros for 4 digits):

C   F1 F#  B1 C   79 F#  59 C   3D F#  2C
C#  E1 G   A1 C#  71 G   51 C#  39 G   29
D   D9 G#  99 D   6D G#  4D D   37 G#  27
D#  D1 A   91 D#  69 A   49 D#  35 A   25
E   C1 A#  89 E   61 A#  45 E   31 A#  23
F   B9 B   81 F   5D B   41 F   2F B   21

If you would like to try the routine without building the circuit, listen through the record jack by plugging in an audio amplifier or by recording on tape and playing back. You will hear noise when the tones are not being generated. Change the USR routine as follows to listen this way:

POKE 16575,0
POKE 16576,211
Tone generator circuit (7410, 4013, LM386 amplifier)
Tone generator circuit (7410, 4013, LM386 amplifier)

Use these fingers on the ZX81 edge connector:

WR: 17A   MREQ: 14A   A15: 11B   +5V: 1B   GROUND: 4B

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