This program plays an arrangement of Bach’s “Minuet in G” using the TS2068’s hardware sound chip, accessed through the BASIC SOUND command. The piece is divided into multiple sections (Part I and Part II), each repeated via loop counters (variables a, b, c, d, g), with the subroutine at line 5000 silencing all sound channels between notes to prevent bleed. The SOUND command addresses individual chip registers directly — register 0/2/4 for tone period low byte, 1/3/5 for tone period high byte, 7 for mixer control, and 8/9/10 for amplitude — enabling two- and three-voice polyphony alongside BEEP for melody. The title screen uses FLASH, randomized PAPER and BORDER colors, and double-rectangle PLOT/DRAW borders, and the program loops back to the title display after a set number of full repeats via the counter g.
Program Analysis
Program Structure
The program is organized into a title/intro section, three main musical parts, and a silence subroutine. Execution begins at line 1 with a REM header, sets up the display at lines 2–4, then enters the music loop at line 10. The overall flow is:
- Lines 2–4: Randomized color setup, double-border graphics, and flashing title display.
- Lines 5–1070: Part I — the main minuet theme, repeated twice via counter
a. - Lines 1080–2000: Part II — the contrasting section, repeated twice via counter
b. - Lines 2010–3620: Part III — an extended passage with counters
canddcontrolling inner repeats. - Line 3650: Resets
a=2andb=5then jumps back to line 10 for a da capo. - Counter
gat line 1993 triggers a full restart (back to line 2) after a complete performance cycle. - Line 5000–5010: Silence subroutine — sets mixer register and zeros all tone channels.
Sound Architecture
The TS2068’s AY-3-8910 (or compatible) sound chip is driven entirely through the SOUND command, which writes directly to chip registers. The general pattern used throughout is:
SOUND 0,n;1,0;8,15— sets channel A tone period (low byte in reg 0, high byte 0 in reg 1) at full amplitude (reg 8 = 15).SOUND 2,n;3,h;9,15— sets channel B tone period and amplitude similarly.SOUND 4,n;5,h;10,15— sets channel C, used briefly in Part II for three-voice chords.SOUND 7,56in the subroutine sets the mixer register to enable tone output on all active channels.
The BEEP command is used in parallel for the primary melody line, providing duration control (in seconds) and pitch (in semitones relative to middle A). This dual-channel approach — SOUND for sustained harmonic/bass tones and BEEP for melody — is a common TS2068 music technique.
Silence Subroutine (Line 5000)
The subroutine at line 5000 is called frequently between notes (over 50 times across the program). It executes:
SOUND 7,56— configures the mixer (binary 00111000), which enables tone on channels A/B/C and disables noise.SOUND 0,0;1,0;2,0;3,0;4,0;5,0— zeros all tone period registers for all three channels, effectively silencing them.
This prevents notes from sustaining indefinitely after a BEEP ends, since the AY chip holds its last register state.
Loop and Repeat Logic
Musical repeats are managed with integer counters rather than FOR/NEXT loops:
| Variable | Controls | Repeat Count |
|---|---|---|
a | Part I repetitions | 2 (exits at a=3) |
b | Part II repetitions | 2 (exits at b=3) |
c | Part III section A repetitions | 2 (exits at c=3) |
d | Part III section B repetitions | 2 (exits at d=3) |
g | Full performance cycles before title reset | 2 (exits at g=3) |
At line 3650, a is set to 2 (not 1) before the da capo jump, ensuring Part I plays only once on the repeat rather than twice, which is musically correct for a minuet da capo.
Display and Title Screen
Line 2 randomizes PAPER and BORDER colors using INT(RND*6)+1, which selects from colors 1–6 (avoiding black=0). INK 9 sets a contrast color. Line 3 draws a double rectangle border using PLOT and DRAW — an outer box from (0,0) to (255,175) and an inner box inset by 10 pixels. Line 4 uses FLASH 1 to highlight the composer credit (“CARL CHADA”) with blank padding lines above and below for a bordered box effect.
Notable Anomalies
Line 2815 sets LET d=1 but this line is only reached when c < 3 (i.e., the IF c=3 THEN GO TO 2820 at line 2800 is not taken). When c=3, execution falls through to line 2820 with d uninitialized from its previous value, which may cause d‘s repeat loop to behave differently on the second pass through Part III. Lines 3680–3700 are unreachable dead code, never jumped to by any part of the program. The MOVE "minuet.bas",1 at line 9999 is a TS2068 DOS command to move a file, used here as a utility line outside normal execution.
Content
Source Code
1 REM "minuet""(17093)
2 PAPER INT (RND*6)+1: INK 9: BORDER INT (RND*6)+1: CLS
3 PLOT 0,0: DRAW 255,0: DRAW 0,175: DRAW -255,0: DRAW 0,-175: PLOT 10,10: DRAW 235,0: DRAW 0,155: DRAW -235,0: DRAW 0,-155
4 PRINT AT 3,8;" ": PRINT AT 4,8;" ""MINUET IN G"" ": PRINT AT 5,8;" ": PRINT AT 9,7;"PERFORMED ON THE": PRINT AT 11,6;"TIMEX/SINCLAIR 2068": PRINT AT 13,14;"BY": FLASH 1: PRINT AT 15,9;" ": PRINT AT 16,9;" CARL CHADA ": PRINT AT 17,9;" ": FLASH 0
5 LET a=1
9 LET g=1
10 GO SUB 5000
20 SOUND 0,221;1,0;8,15
30 SOUND 2,23;3,1;9,15
40 PAUSE 30
50 GO SUB 5000
60 SOUND 0,209;1,0;8,15
70 SOUND 2,248;3,0;9,15
80 PAUSE 15
90 SOUND 0,186;1,0;8,15
100 SOUND 2,221;3,0;9,15
110 BEEP .5,-17
120 SOUND 0,197;1,0;8,15
130 SOUND 2,234;3,0;9,15
140 PAUSE 15
150 SOUND 0,186;1,0;8,15
160 SOUND 2,221;3,0;9,15
170 BEEP .5,-13
180 SOUND 0,197;1,0;8,15
190 SOUND 2,234;3,0;9,15
200 PAUSE 15
210 SOUND 0,186;1,0;8,15
220 SOUND 2,221;3,0;9,15
230 BEEP .5,-10
240 SOUND 0,197;1,0;8,15
250 SOUND 2,234;3,0;9,15
260 PAUSE 15
270 SOUND 0,186;1,0;8,15
280 SOUND 2,221;3,0;9,15
290 BEEP .75,-5: BEEP .75,-17
300 SOUND 0,165;1,0;8,15
310 SOUND 2,209;3,0;9,15
320 PAUSE 30
330 SOUND 0,221;1,0;8,15
340 SOUND 2,7;3,1;9,15
350 PAUSE 15
360 SOUND 0,209;1,0;8,15
370 SOUND 2,248;3,0;9,15
380 BEEP .75,-10: BEEP .75,-22
390 SOUND 0,186;1,0;8,15
400 SOUND 2,221;3,0;9,15
410 PAUSE 30
420 SOUND 0,248;1,0;8,15
430 SOUND 2,39;3,1;9,15
440 PAUSE 15
450 SOUND 0,221;1,0;8,15
460 SOUND 2,23;3,1;9,15
470 BEEP .75,-5: BEEP .75,-17
480 SOUND 0,23;1,1;8,15
490 SOUND 2,186;3,1;9,15
500 PAUSE 30
510 SOUND 0,248;1,0;8,15
520 SOUND 2,116;3,1;9,15
530 PAUSE 15
540 SOUND 0,221;1,0;8,15
550 SOUND 2,23;3,1;9,15
560 BEEP .5,-17
570 SOUND 0,234;1,0;8,15
580 SOUND 2,39;3,1;9,15
590 PAUSE 15
600 SOUND 0,221;1,0;8,15
610 SOUND 2,23;3,1;9,15
620 BEEP .5,-13
630 SOUND 0,234;1,0;8,15
640 SOUND 2,39;3,1;9,15
650 PAUSE 15
660 SOUND 0,221;1,0;8,15
670 SOUND 2,23;3,1;9,15
680 BEEP .5,-9
690 SOUND 0,234;1,0;8,15
700 SOUND 2,39;3,1;9,15
710 PAUSE 15
720 SOUND 0,221;1,0;8,15
730 SOUND 2,23;3,1;9,15
740 BEEP .75,-8: BEEP .75,-6
750 SOUND 0,248;1,0;8,15
760 SOUND 2,39;3,1;9,15
770 BEEP .5,-5
780 SOUND 2,23;3,1;9,15
790 SOUND 0,75;1,1;8,15
800 PAUSE 15
805 GO SUB 5000
810 SOUND 0,75;1,1;8,15
820 SOUND 2,23;3,1;9,15
830 BEEP .5,-3
840 SOUND 0,186;1,0;8,15
850 SOUND 2,39;3,1;9,15
860 PAUSE 15
865 GO SUB 5000
870 SOUND 0,186;1,0;8,15
880 SOUND 2,39;3,1;9,15
890 PAUSE 30
900 SOUND 0,248;1,0;8,15
910 SOUND 2,39;3,1;9,15
920 PAUSE 15
930 GO SUB 5000
940 SOUND 0,75;1,1;8,15
950 SOUND 2,23;3,1;9,15
960 BEEP .5,-15
970 SOUND 0,75;1,1;8,15
980 SOUND 2,138;3,1;9,15
990 PAUSE 15
1000 GO SUB 5000
1010 SOUND 0,116;1,1;8,15
1020 BEEP .75,-10
1030 GO SUB 5000
1040 BEEP .75,2
1050 LET a=a+1
1060 IF a=3 THEN GO TO 1080
1070 GO TO 10
1080 REM PART II
1085 LET b=1
1090 GO SUB 5000
1100 SOUND 0,186;1,0;8,15
1120 PAUSE 22.5
1130 SOUND 0,139;1,0;8,15
1140 PAUSE 22.5
1150 SOUND 0,139;1,0;8,15
1160 SOUND 2,186;3,0;9,15
1170 SOUND 4,116;5,1;10,15
1180 BEEP .75,-1
1190 SOUND 0,147;1,0;8,15
1200 SOUND 2,209;3,0;9,15
1210 SOUND 4,116;5,1;10,15
1220 BEEP .75,-3
1230 SOUND 0,139;1,0;8,15
1240 SOUND 2,221;3,0;9,15
1250 SOUND 4,116;5,1;10,15
1260 BEEP .75,-5
1270 SOUND 0,124;1,0;8,15
1280 SOUND 2,248;3,0;9,15
1290 SOUND 4,116;5,1;10,15
1300 BEEP .75,-6: BEEP .75,-10
1310 SOUND 0,139;1,0;8,15: PAUSE 7.5: GO SUB 5000
1320 SOUND 0,147;1,0;8,15: PAUSE 7.5: GO SUB 5000
1330 SOUND 0,165;1,0;8,15: PAUSE 7.5: GO SUB 5000
1340 SOUND 0,186;1,0;8,15: PAUSE 7.5: GO SUB 5000
1350 SOUND 0,209;1,0;8,15
1360 SOUND 2,248;3,0;9,15
1370 BEEP .75,-5
1380 SOUND 0,221;1,0;8,15
1390 SOUND 2,23;3,1;9,15
1400 BEEP .75,-5
1410 SOUND 0,165;1,0;8,15
1420 SOUND 2,209;3,0;9,15
1430 BEEP .5,-12
1440 SOUND 0,209;1,0;8,15
1450 SOUND 2,248;3,0;9,15
1460 PAUSE 15
1470 SOUND 0,221;1,0;8,15
1480 SOUND 2,23;3,1;9,15
1490 BEEP .75,-10
1500 SOUND 0,248;1,0;8,15
1510 SOUND 2,39;3,1;9,15
1515 PAUSE 45
1520 SOUND 0,23;1,1;8,15
1530 SOUND 2,186;3,1;9,15
1540 PAUSE 30
1545 GO SUB 5000
1550 SOUND 0,248;1,0;8,15
1570 PAUSE 15
1580 SOUND 0,221;1,0;8,15
1590 SOUND 2,116;3,1;9,15
1600 BEEP .5,-17
1610 SOUND 0,234;1,0;8,15
1620 SOUND 2,138;3,1;9,15
1630 PAUSE 15
1640 SOUND 0,221;1,0;8,15
1650 SOUND 2,116;3,1;9,15
1660 BEEP .5,-13
1670 SOUND 0,234;1,0;8,15
1680 SOUND 2,138;3,1;9,15
1690 PAUSE 15
1700 SOUND 0,221;1,0;8,15
1710 SOUND 2,116;3,1;9,15
1720 BEEP .5,-10
1730 SOUND 0,234;1,0;8,15
1740 SOUND 2,138;3,1;9,15
1750 PAUSE 15
1760 SOUND 0,221;1,0;8,15
1770 SOUND 2,116;3,1;9,15
1780 BEEP .75,-5: BEEP .75,-7
1790 SOUND 0,209;1,0;8,15
1800 SOUND 2,75;3,1;9,15
1810 BEEP .5,-8
1820 SOUND 0,7;1,1;9,15
1830 SOUND 2,186;3,1;9,15
1840 PAUSE 15
1850 SOUND 0,248;1,0;8,15
1860 SOUND 2,162;3,1;9,15
1870 BEEP .75,-8: BEEP .75,-9
1880 SOUND 0,221;1,0;8,15
1890 SOUND 2,116;3,1;9,15
1900 BEEP .5,-10
1910 SOUND 0,39;1,1;8,15
1920 SOUND 2,241;3,1;9,15
1930 PAUSE 15
1940 SOUND 0,23;1,1;8,15
1950 SOUND 2,186;3,1;9,15
1960 BEEP .75,-17
1970 LET b=b+1
1980 IF b=3 THEN GO TO 2010
1990 BEEP .75,-5
1992 LET g=g+1
1993 IF g=3 THEN GO SUB 5000: PAUSE 200: CLS : GO TO 2
2000 GO TO 1090
2010 SOUND 0,46;1,2;8,15: PAUSE 15: GO SUB 5000
2015 LET c=1
2020 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
2030 SOUND 0,197;1,0;8,15: PAUSE 15: GO SUB 5000
2040 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
2050 SOUND 0,221;1,0;8,15
2060 BEEP .25,-17
2070 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
2080 SOUND 0,23;1,1;8,15
2090 BEEP .25,-10
2100 SOUND 0,221;1,0;8,15: PAUSE 15: GO SUB 5000
2110 SOUND 0,116;1,1;8,15
2120 BEEP .25,-5
2130 SOUND 0,221;1,0;8,15: PAUSE 15: GO SUB 5000
2140 SOUND 0,248;1,0;8,15
2150 BEEP .25,-12
2160 SOUND 0,209;1,0;8,15: PAUSE 15: GO SUB 5000
2170 SOUND 0,39;1,1;8,15
2180 BEEP .25,-10
2190 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
2200 SOUND 0,116;1,1;8,15
2210 BEEP .25,-6
2220 SOUND 0,39;1,1;8,15: PAUSE 15: GO SUB 5000
2230 SOUND 0,23;1,1;8,15
2240 BEEP .25,-13
2250 SOUND 0,39;1,1;8,15: PAUSE 15: GO SUB 5000
2260 SOUND 0,23;1,1;8,15
2270 BEEP .25,-10
2280 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
2290 SOUND 0,221;1,0;8,15
2300 BEEP .25,-5
2310 SOUND 0,209;1,0;8,15: PAUSE 15: GO SUB 5000
2320 SOUND 0,186;1,0;8,15
2330 BEEP .25,-6
2340 SOUND 0,197;1,0;8,15: PAUSE 15: GO SUB 5000
2350 SOUND 0,186;1,0;8,15
2360 BEEP .25,-3
2370 SOUND 0,165;1,0;8,15: PAUSE 15: GO SUB 5000
2380 SOUND 0,186;1,0;8,15
2390 BEEP .25,2
2400 SOUND 0,209;1,0;8,15: PAUSE 15: GO SUB 5000
2410 SOUND 0,221;1,0;8,15
2420 BEEP .25,-5
2430 SOUND 0,234;1,0;8,15: PAUSE 15: GO SUB 5000
2440 SOUND 0,221;1,0;8,15
2450 BEEP .25,-1
2460 SOUND 0,209;1,0;8,15: PAUSE 14: GO SUB 5000
2470 SOUND 0,221;1,0;8,15
2480 BEEP .25,-9
2490 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
2500 SOUND 0,23;1,1;8,15
2510 BEEP .25,-8
2520 SOUND 0,221;1,0;8,15: PAUSE 15: GO SUB 5000
2530 SOUND 0,248;1,0;8,15
2540 BEEP .25,-11
2550 SOUND 0,23;1,1;8,15: PAUSE 15: GO SUB 5000
2560 SOUND 0,39;1,1;8,15
2570 BEEP .25,-10
2580 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
2590 SOUND 0,75;1,1;8,15
2600 BEEP .25,-17
2610 SOUND 0,39;1,1;8,15: PAUSE 15: GO SUB 5000
2620 SOUND 0,23;1,1;8,15: PAUSE 15
2630 SOUND 0,75;1,1;8,15: PAUSE 15
2640 SOUND 0,138;1,1;8,15
2650 BEEP .25,-15
2660 SOUND 0,241;1,1;8,15: PAUSE 15: GO SUB 5000
2670 SOUND 0,116;1,1;8,15
2680 BEEP .5,-10
2790 LET c=c+1
2800 IF c=3 THEN GO TO 2820
2815 LET d=1
2820 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
2830 SOUND 0,197;1,0;8,15: PAUSE 15: GO SUB 5000
2840 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
2850 SOUND 0,165;1,0;8,15
2860 BEEP .25,-10
2870 SOUND 0,209;1,0;8,15: PAUSE 15: GO SUB 5000
2880 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
2890 SOUND 0,221;1,0;8,15
2900 BEEP .25,2
2910 SOUND 0,248;1,0;8,15
2920 BEEP .25,1
2930 SOUND 0,221;1,0;8,15
2940 BEEP .25,2
2950 SOUND 0,209;1,0;8,15
2960 BEEP .25,4
2970 SOUND 0,248;1,0;8,15
2980 BEEP .25,0
2990 SOUND 0,39;1,1;8,15
3000 BEEP .25,-3
3010 SOUND 0,186;1,0;8,15
3020 BEEP .25,-1
3030 SOUND 0,197;1,0;8,15
3040 BEEP .25,-2
3050 SOUND 0,186;1,0;8,15
3060 BEEP .25,-1
3070 SOUND 0,165;1,0;8,15
3080 BEEP .25,0
3090 SOUND 0,209;1,0;8,15
3100 BEEP .25,-3
3110 SOUND 0,248;1,0;8,15
3120 BEEP .25,-6
3130 SOUND 0,221;1,0;8,15
3140 BEEP .25,-5
3150 SOUND 0,248;1,0;8,15
3160 BEEP .25,-6
3170 SOUND 0,221;1,0;8,15
3180 BEEP .25,-5
3190 SOUND 0,209;1,0;8,15
3200 BEEP .25,-3
3210 SOUND 0,248;1,0;8,15
3220 BEEP .25,-6
3230 SOUND 0,39;1,1;8,15
3240 BEEP .25,-10
3250 SOUND 0,186;1,0;8,15
3260 BEEP .25,-10
3270 SOUND 0,197;1,0;8,15
3280 BEEP .25,-8
3290 SOUND 0,186;1,0;8,15
3300 BEEP .25,-6
3310 SOUND 0,221;1,0;8,15
3320 BEEP .25,-5
3330 SOUND 0,186;1,0;8,15: PAUSE 15: GO SUB 5000
3340 SOUND 0,23;1,1;8,15
3350 BEEP .25,-1
3360 SOUND 0,221;1,0;8,15: PAUSE 15: GO SUB 5000
3370 SOUND 0,116;1,1;8,15
3380 BEEP .25,-13
3390 SOUND 0,139;1,0;8,15: PAUSE 15: GO SUB 5000
3400 SOUND 0,165;1,0;8,15
3410 BEEP .25,-12
3420 SOUND 0,139;1,0;8,15: PAUSE 15: GO SUB 5000
3430 SOUND 0,209;1,0;8,15
3440 BEEP .25,-8
3450 SOUND 0,165;1,0;8,15: PAUSE 15: GO SUB 5000
3460 SOUND 0,248;1,0;8,15
3470 BEEP .25,-3
3480 SOUND 0,209;1,0;8,15: PAUSE 15: GO SUB 5000
3490 SOUND 0,39;1,1;8,15
3500 BEEP .25,-6
3510 SOUND 0,248;1,0;8,15: PAUSE 15: GO SUB 5000
3520 SOUND 0,116;1,1;8,15
3530 BEEP .25,-3
3540 SOUND 0,75;1,1;8,15: PAUSE 15: GO SUB 5000
3550 SOUND 0,57;1,1;8,15
3560 BEEP .25,0
3570 SOUND 0,39;1,1;8,15: PAUSE 15: GO SUB 5000
3580 SOUND 0,248;1,0;8,15
3590 BEEP .65,0
3600 SOUND 0,23;1,1;8,15
3610 BEEP .25,-1
3620 LET d=d+1
3630 IF d=3 THEN GO TO 3650
3640 GO TO 2820
3650 LET a=2: LET b=5
3660 GO TO 10
3680 GO TO 1080
3690 PAUSE 100
3700 GO TO 2
5000 SOUND 7,56
5010 SOUND 0,0;1,0;2,0;3,0;4,0;5,0: RETURN
9996 SAVE "Minuet" LINE 1: STOP
9998 STOP
9999 MOVE "minuet.bas",1
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
