Music (Bill Bernard)

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Music

Draws a two-octave piano keyboard and offers twelve tunes, chosen with the keys A to L: Funeral March of a Marionette, Stars and Stripes Forever, Mozart’s Symphony No. 40, the Mexican Hat Dance, Dvořák’s Humoresque, La Cucaracha, Pop! Goes the Weasel, Yankee Doodle, Sakura, the Blue Danube waltz, scales and Old MacDonald. The tune’s name appears above the keyboard, and a note symbol flashes on each key while it plays. When a tune ends, the menu waits for the next choice.

The REM in line 1 credits Bill Bernard of the Cincinnati, Ohio T/S group and explains that the music program was converted from SOUND to BEEP; the original SOUND statements are kept as REMs. The zip also holds “Music 2.1”, a version compiled with Timachine by Kristian Boisvert of Byte Power magazine: a short loader and 6,223 bytes of compiled code at 59005 that plays the same tunes.

Program Analysis

Structure

  • Lines 1000–1095: the player. It reads a key number and a length, marks the key with UDG a using OVER 1, plays the note and then removes the mark.
  • Lines 1100–1600: the keyboard picture, the selection menu, the note UDG and the key-to-column table k().
  • Lines 2000–2140: a table of AY register values for 88 notes, used by the original SOUND version and loaded into n() before the program was saved.
  • Lines 3000–5750: the tunes, each starting with a tempo and a title, followed by note and length pairs ending in -1,-1.

Playing a Note

Notes are numbered as piano keys, so BEEP w*t/60,v-40 converts key v to a semitone offset from middle C, and the length w times the tempo t gives the duration in sixtieths of a second. Key 0 is a rest, played with PAUSE. Only keys 39 to 64 appear on the drawn keyboard; notes outside that range play without a mark.

Notable Techniques

  • The variables a to l are set to 1–12, so VAL w$ of the pressed letter gives the selection number, and RESTORE 2750+250*w jumps to that tune.
  • The key mark is printed and later reprinted with OVER 1, which removes it without redrawing the key; POINT decides whether it belongs on a white or a black key.
  • The program is saved to start at line 2085 with ON ERR GO TO 2099, so the screen is drawn without re-reading the note table, which is saved with the variables.

Potential Issues

  • The keyboard is only polled between tunes, so a tune cannot be stopped except with BREAK.

This program came from an Oliger (JLO SAFE) disk and was converted to load from tape. Only the slash in its SAVE / (and the slashes in the compiled version’s loader) had to be removed. Both versions were tested in ZEsarUX.

Related Content

Image Gallery

Source Code

    1 REM BILL BERNARD CINCINNATI, OH.T/S GROUP*** MUSIC PROGRAM CONVERTED FROM SOUND TO BEEP WITH REM STATEMENTS
   10 GO TO 1100
 1000 READ V,W
 1010 IF V=-1 THEN RETURN : REM SOUND 8,0;9,0: RETURN 
 1015 REM IF V=0 THEN LET V=1
 1020 IF V>64 OR V<39 THEN GO TO 1060
 1030 LET U=K(V-38)
 1040 IF POINT (U*8+4,130)=0 THEN PRINT AT 11,U; OVER 1;"a": GO TO 1060
 1050 PRINT AT 7,U; OVER 1;"a"
 1060 REM SOUND 0,N(V,2);1,N(V,1);2,N(v,2);3,N(V,1);7,60;8,31;9,31;11,64;12,64;13,11
 1065 REM SOUND 9,0
 1070 REM PAUSE w*t
 1071 IF v<>0 THEN BEEP w*t/60,v-40: GO TO 1080
 1072 PAUSE w*t
 1080 IF V>64 OR V<39 THEN GO TO 1000
 1085 IF POINT (U*8+4,130)=0 THEN PRINT AT 11,U; OVER 1;"a": GO TO 1000
 1090 PRINT AT 7,U; OVER 1;"a"
 1095 GO TO 1000
 1100 CLS 
 1102 BORDER 3: PAPER 7: INK 0: CLS 
 1105 PRINT AT 1,0; PAPER 6;,,,,,,
 1108 PLOT 0,136: DRAW 255,0
 1109 PLOT 0,63: DRAW 255,0
 1110 FOR y=0 TO 240 STEP 16
 1115 PLOT y,136: DRAW 0,-73
 1120 NEXT y
 1125 PLOT 255,136: DRAW 0,-73
 1130 FOR y=2 TO 14: FOR x=5 TO 9
 1135 IF y=4 OR y=8 OR y=11 THEN GO TO 1145
 1140 PRINT AT x,y*2;" "
 1145 NEXT x: NEXT y
 1148 PAPER 4
 1150 PRINT AT 15,2; BRIGHT 1;" ------- selections ------- "
 1155 PRINT AT 16,2;" A-MARCH  E-HUMOR  I-SAKURA "
 1160 PRINT AT 17,2;" B-STARS  F-BUG    J-BLUE   "
 1165 PRINT AT 18,2;" C-FORTY  G-POP    K-SCALES "
 1170 PRINT AT 19,2;" D-HAT    H-DANDY  L-FARMER "
 1180 PAPER 7
 1230 RESTORE 2900
 1240 DIM k(26)
 1250 FOR y=1 TO 26
 1260 READ w
 1270 LET k(y)=w
 1280 NEXT y
 1290 LET a=1: LET b=2: LET c=3
 1300 LET d=4: LET e=5: LET f=6
 1310 LET g=7: LET h=8: LET i=9
 1320 LET j=10: LET k=11: LET l=12
 1330 POKE USR "a"+0,BIN 00110000
 1340 POKE USR "a"+1,BIN 00101100
 1350 POKE USR "a"+2,BIN 00100010
 1360 POKE USR "a"+3,BIN 00100010
 1370 POKE USR "a"+4,BIN 01100010
 1380 POKE USR "a"+5,BIN 11100110
 1390 POKE USR "a"+6,BIN 01001110
 1400 POKE USR "a"+7,BIN 00000100
 1410 PRINT AT 21,1;"ENTER SELECTION ==> "; FLASH 1;" "
 1420 IF INKEY$<>"" THEN GO TO 1420
 1430 IF INKEY$="" THEN GO TO 1430
 1435 LET w$=INKEY$
 1438 LET w=CODE w$
 1439 IF w>90 THEN LET w=w-32: REM lower to upper case
 1440 IF w<65 THEN GO TO 1420: REM < A?
 1442 IF w>76 THEN GO TO 1420: REM > L?
 1445 PRINT AT 21,21; FLASH 0;w$
 1450 LET w=VAL w$
 1550 RESTORE 2750+250*w
 1560 READ t,s$
 1580 PRINT AT 2,(32.5-LEN s$)/2; PAPER 8; INK 9;s$
 1590 GO SUB 1000
 1595 PRINT AT 2,0; PAPER 8;,,
 1600 GO TO 1410
 2000 DIM n(88,2)
 2010 RESTORE 2100
 2015 LET y=0
 2020 READ v,w
 2030 IF v=-1 THEN GO TO 2080
 2040 LET y=y+1
 2050 LET N(y,1)=v: LET N(y,2)=w
 2070 GO TO 2020
 2080 SAVE "MUSIC" LINE 2085
 2085 ON ERR GO TO 2099
 2090 GO TO 1100
 2099 ON ERR CONTINUE 
 2100 DATA 0,0,0,0,0,0,13,16,12,84,11,163,10,252,10,94,9,201,9,60,8,184,8,58
 2105 DATA 7,196,7,85,6,235,6,136,6,42,5,209,5,126,5,47
 2110 DATA 4,228,4,158,4,92,4,29,3,226,3,170,3,117,3,68,3,21
 2115 DATA 2,232,2,191,2,151,2,114,2,79,2,46,2,14
 2120 DATA 1,241,1,213,1,186,1,162,1,138,1,116,1,95,1,75,1,57,1,39,1,23,1,7
 2125 DATA 0,248,0,234,0,221,0,209,0,197,0,186,0,175,0,165,0,156,0,147,0,139,0,131,0,124,0,117,0,110,0,104
 2130 DATA 0,98,0,93,0,87,0,82,0,78,0,73,0,69,0,65,0,62,0,58,0,55,0,52,0,49,0,46,0,43
 2135 DATA 0,41,0,39,0,36,0,34,0,32,0,31,0,29,0,27,0,26
 2140 DATA -1,-1
 2900 DATA 1,3,4,5,6,7,9,10,11,12,13,14,15,17,18,19,20,21,23,24,25,26,27,28,29,31
 3000 DATA 3.2,"Funeral March of a Marionette"
 3005 DATA 37,1,0,2,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,3,37,1,0,2
 3010 DATA 30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,3,37,3,42,3,0,3,45,3
 3015 DATA 49,6,47,3,45,3,0,3,49,3,52,6,50,3,49,3,0,3,53,3,56,6,54,3,53,3,50,3
 3020 DATA 49,3,47,3,45,3,44,3,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3
 3025 DATA 0,3,37,1,0,2,30,1,0,5,42,3,42,3,41,3,39,3,41,3,0,3,42,3,44,3,0,3
 3030 DATA 37,3,45,3,0,3,49,3,52,6,50,3,49,3,47,3,45,3,43,3,47,3,50,3,42,3
 3035 DATA 41,3,42,3,44,3,0,3,45,1,0,2,44,9,42,1
 3040 DATA -1,-1
 3250 DATA 3.2,"Stars and Stripes Forever"
 3255 DATA 54,6,54,6,52,3,51,3,51,6,50,3,51,3,51,16,0,2,50,3
 3260 DATA 51,3,51,6,50,3,51,3
 3265 DATA 54,6,51,3,54,3,52,12,49,6,0,3,49,3,49,6,48,3,49,3
 3270 DATA 49,6,48,3,49,3
 3275 DATA 52,16,0,2,51,3,49,3,51,3,54,9,56,9,56,3,49,16,0,2,54,6
 3280 DATA 54,6,52,3,51,3,51,6,50,3,51,3,51,16,0,2,50,3,51,3,51,6,50,3,51,3
 3285 DATA 52,3,51,3,49,5,46,1,49,12,47,6,0,3,47,3,47,6,46,3,47,3,50,6,49,3,47,3
 3290 DATA 59,15,0,3,47,3,49,3,51,3,54,1,0,2,47,3,49,3,51,3,54,1,0,2,42,3,44,5
 3295 DATA 51,1,49,12,47,1
 3300 DATA -1,-1
 3500 DATA 3.2,"Symphony #40 by Mozart"
 3510 DATA 55,2,54,2,54,4,55,2,54,2,54,4,55,2,54,2,54,4,62,4,0,4
 3515 DATA 62,2,61,2,59,4,59,2,57,2,55,4,55,2,54,2
 3520 DATA 52,4,52,4,0,4,54,2,52,2,52,4,54,2,52,2,52,4,54,2,52,2
 3525 DATA 52,4,61,4,0,4,61,2,59,2,58,4,58,2,55,2,54,4,54,2,52,2
 3530 DATA 50,4,50,4,0,4,62,2,61,2,61,4,64,4,58,4,61,4
 3535 DATA 59,4,54,4,0,4,62,2,61,2,61,4,64,4,58,4,61,4
 3540 DATA 59,4,62,4,61,2,59,2,57,2,55,2,54,4,46,4,47,4,49,4
 3545 DATA 50,4,52,2,50,2,49,4,47,4,54,4,0,4,64,8
 3550 DATA 65,2,0,6,64,8,65,2,0,6,64,8
 3555 DATA 65,4,64,4,65,4,64,4,65,4
 3560 DATA -1,-1
 3750 DATA 3.2,"Mexican Hat Dance - Traditional"
 3760 DATA 52,2,57,2,0,2,52,2,57,2,0,2,52,2,57,6,0,4,52,2,57,2,59,2,57,2,56,4
 3765 DATA 57,2,59,2,0,8,52,2,56,2,0,2,52,2,56,2,0,2,52,2,56,6,0,4,52,2
 3770 DATA 56,2,57,2,56,2,54,4,56,2,57,2,0,6,64,2,63,2,64,2,61,2,60,2,61,2
 3775 DATA 57,2,56,2,57,2,52,2,0,4,49,2,50,2,52,2,54,2,56,2,57,2,59,2,61,2
 3780 DATA 62,2,59,2,0,4,62,2,61,2,62,2,59,2,58,2,59,2,56,2,55,2,56,2,52,2
 3785 DATA 0,4,64,2,63,2,64,2,66,2,64,2,62,2,61,2,59,2,57,2
 3790 DATA -1,-1
 4000 DATA 3.2,"Humoresque by Dvorak"
 4010 DATA 47,3,0,2,49,1,47,3,0,2,49,1,51,3,0,2,54,1,56,3,0,2,54,1
 4015 DATA 59,3,0,2,58,1,61,3,0,2,59,1,58,3,0,2,61,1,59,3,0,2,56,1
 4020 DATA 54,3,0,2,54,1,56,3,0,2,54,1,59,3,0,2,56,1,54,3,0,2,51,1
 4025 DATA 49,24,47,3,0,2,49,1,47,3,0,2,49,1,51,3,0,2,54,1,56,3,0,2,54,1
 4030 DATA 56,3,0,2,58,1,61,3,0,2,59,1,58,3,0,2,61,1,59,3,0,2,56,1
 4035 DATA 54,3,0,2,54,1,59,3,0,2,47,1,49,6,54,6,47,18
 4040 DATA -1,-1
 4250 DATA 3.2,"La Cucaracha"
 4260 DATA 42,1,0,1,42,1,0,1,42,1,0,1,47,1,0,5,51,1,0,3,42,1,0,1,42,1,0,1
 4265 DATA 42,1,0,1,47,1,0,5,51,1,0,5,30,1,0,1,30,1,0,1,35,1,0,3,47,1,0,1
 4270 DATA 47,1,0,1,46,1,0,1,46,1,0,1,44,1,0,1,44,1,0,1,42,8,0,2,42,1,0,1
 4275 DATA 42,1,0,1,42,1,0,1,46,1,0,5,49,1,0,3,42,1,0,1,42,1,0,1,42,1,0,1
 4280 DATA 46,1,0,5,49,1,0,5,37,1,0,1,37,1,0,1,30,1,0,3,54,2,56,2,54,2,52,2
 4285 DATA 51,2,49,2,47,8
 4290 DATA -1,-1
 4500 DATA 3.2,"Pop! Goes the Weasle"
 4510 DATA 47,2,0,2,47,2,49,2,0,2,49,2,51,2,54,2,51,2,47,2,0,2,42,2
 4515 DATA 47,2,0,2,47,2,49,2,0,2,49,2,51,6,47,2,0,2,42,2,47,2,0,2,47,2,49,2
 4520 DATA 0,2,49,2,51,2,54,2,51,2,47,2,0,4,56,2,0,4,49,2,0,2,52,2,51,6,47,2
 4525 DATA 0,4,59,2,0,2,59,2,56,2,0,2,59,2,58,2,61,2,58,2,54,2,0,4,59,2,0,2
 4530 DATA 59,2,56,2,0,2,59,2,58,6,54,2,0,2,51,2,52,2,0,2,51,2,52,2,0,2,54,2
 4535 DATA 56,2,0,2,58,2,59,2,0,4,56,2,0,4,49,2,0,2,52,2,51,6,47,2
 4540 DATA -1,-1
 4750 DATA 3.2,"Yankee Doodle - Anonymous"
 4760 DATA 50,3,50,3,52,3,54,3,50,3,54,3,52,3,45,3,50,3,50,3,52,3,54,3,50,6,49,3,0,3
 4765 DATA 50,3,50,3,52,3,54,3,55,3,54,3,52,3,50,3,49,3,45,3,47,3,49,3,50,6,50,3,0,3
 4770 DATA 47,5,49,1,47,3,45,3,47,3,49,3,50,3,0,3,45,5,47,1,45,3,43,3,42,6,45,3,0,3
 4775 DATA 47,5,49,1,47,3,45,3,47,3,49,3,50,3,47,3,45,3,50,3,49,3,52,3,50,6,50,6
 4780 DATA -1,-1
 5000 DATA 3.2,"Sakura - Japanese Folk Melody"
 5010 DATA 49,8,49,8,51,12,0,4,49,8,49,8,51,12,0,4,49,8,51,8,52,8,51,8
 5015 DATA 49,8,51,4,49,4,45,16,44,8,40,8,44,8,45,8
 5020 DATA 44,8,44,4,40,4,39,16,49,8,49,8,51,12,0,4,49,8,51,12,0,4
 5025 DATA 40,8,44,8,45,8,49,8,51,4,49,4,45,8,44,16
 5030 DATA -1,-1
 5250 DATA 3.2,"Blue Danube Waltz by J.S.Strauss"
 5260 DATA 42,4,46,4,49,4,49,4,0,4,61,2,0,2,61,2,0,6,58,2,0,2,58,2,0,6,42,4,42,4
 5265 DATA 46,4,49,4
 5270 DATA 49,4,0,4,61,2,0,2,61,2,0,6,59,2,0,2,59,2,0,6,41,4,41,4,44,4,51,4,51,4
 5275 DATA 0,4,63,2,0,2,63,2,0,6,59,2,0,2
 5280 DATA 59,2,0,6,41,4,41,4,44,4,51,4,51,4,0,4,63,2,0,2,63,2,0,6,58,2,0,2,58,2
 5285 DATA 0,6,42,4
 5290 DATA 42,4,46,4,49,4,54,4,0,4,66,2,0,2,66,2,0,6,61,2,0,2,61,2,0,6,42,4
 5295 DATA 42,4,46,4,49,4,54,4,0,4,66,2,0,2
 5300 DATA 66,2,0,6,63,2,0,2,63,2,0,6,44,4,44,4,47,4,51,2,0,2,51,14,0,2,48,4
 5305 DATA 49,4,58,16
 5310 DATA 54,4,46,4,46,8,44,4,51,8,49,4,42,4,0,2,42,2,42,4,0,8,49,2,0,2,47,2
 5315 DATA 0,6,49,2,0,2
 5320 DATA 47,2,0,6,49,4,58,16,56,4,49,2,0,2,46,2,0,6,49,2,0,2,46,2,0,6,49,4
 5325 DATA 56,16,54,4,49,2,0,2,47,2,0,6,49,2,0,2,47,2,0,6,49,4,58,16
 5330 DATA 56,4,49,4,54,4,56,4,58,4,61,8,59,4,58,2,58,2,58,4,56,2,0,2,54,4,0,8
 5335 DATA -1,-1
 5500 DATA 3.2,"Scales"
 5505 DATA 38,1,39,1,40,1,41,1,42,1,43,1,44,1,45,1,46,1,47,1
 5510 DATA 48,1,49,1,50,1,51,1,52,1,53,1,54,1,55,1,56,1
 5515 DATA 57,1,58,1,59,1,60,1,61,1,62,1,63,1,64,1,65,8,0,4
 5520 DATA 65,8,64,1,63,1,62,1,61,1,60,1,59,1,58,1,57,1
 5525 DATA 56,1,55,1,54,1,53,1,52,1,51,1,50,1,49,1,48,1
 5530 DATA 47,1,46,1,45,1,44,1,43,1,42,1,41,1,40,1,39,1,38,8
 5535 DATA -1,-1
 5750 DATA 8,"Old MacDonald"
 5760 DATA 44,2,44,2,44,2,39,2,41,2,41,2,39,3,48,2,48,2,46,2,46,2,44,3,39,2,44,2,44,2,44,2,39,2,41,2,41,2,39,3,48,2,48,2,46,2,46,2,44,3
 5765 DATA -1,-1
 9999 SAVE "MUSIC" LINE 2085: BEEP 1,33

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