42 Astoundingly Useful Scripts and Automations for the Macintosh

8 (bit) Days of Christmas: Day 0 (Go Tell It On the CoCo!)

Day 0 of the 8 (bit) days of Christmas. Christmas Eve, and the cattle are lowing.

Jerry Stratton, December 24, 2020

Arron W. Branigan did some pretty cool art for his Christmas program. On Day 110 I used his snowman image from the December, 1986 Rainbow article “Go Tell It On the CoCo”, and I chose his nativity scene from the same program for today. It’s Christmas Eve, and the cattle are lowing.

Would you like to know what cattle look like in Extended Color BASIC?

  • 1270 REM ***COW***
  • 1280 LINE (24,156)-(0,156),PSET
  • 1290 LINE -(0,140),PSET
  • 1300 CIRCLE (8,141),8,8,1,.50,.75
  • 1310 LINE (8,134)-(28,130),PSET
  • 1320 LINE -(36,132),PSET
  • 1330 LINE (40,144)-(36,130),PSET
  • 1340 LINE -(48,130),PSET:LINE -(44,144),PSET:LINE -(40,144),PSET
  • 1350 LINE (46,141)-(44,156),PSET
  • 1360 LINE -(28,152),PSET
  • 1370 LINE -(16,152),PSET
  • 1380 LINE (24,156)-(24,152),PSET
  • 1390 LINE (36,140)-(40,153),PSET
  • 1400 LINE -(28,152),PSET
  • 1410 CIRCLE (42,116),25,2,.5,.15,.38
  • 1420 PSET (39,133,2):PSET (45,133,2)
  • 1430 PAINT (20,144),8,8
  • 1440 CIRCLE (8,152),15,3,1,.75,1
  • 1450 CIRCLE (36,150),15,3,1,.50,.25
  • 1460 COLOR 2,1
  • 1470 LINE (42,132)-(42,138),PSET

The LINE statement acted a little like the turtle in the old LOGO programming language. There’s a pencil position, and LINE remembers it. If you leave out the starting position, as Branigan does several times here, ECB assumes that the line starts where the previous line left off. If there was no previous line, it starts in the middle, location (128, 96). And remember that locations are mode independent in Extended Color BASIC. It doesn’t matter if you’re in high resolution, medium resolution, or low resolution, the location numbers will be the same.

If you want to see just the cow, add a line 1269 and a line 1471:

  • 1269 PMODE 3,1:SCREEN 1,0:PCLS 3:COLOR 4,1
  • 1471 GOTO 1471

Then, type GOTO 1269.

Most of the programs I’ve featured over the last eight days have also used music. Except for John Mosley’s Do You Hear What I Hear?, they all used the PLAY statement for that music. Branigan separates his melodies into subroutines. If you’ve loaded the program onto your CoCo or appropriate emulator, you can type GOSUB 1700 to hear “Away In the Manger”.

  • 1710 FOR X=1 TO 2
  • 1720 PLAY "V27;L4;O4;C;L4.;C;L8;
  • O3;B-;L4;A;L4.;A;L8;G;L4;F;P30;F
  • ;E;D;L2;C;L4;P30;C;L4.;P30;C;L8;
  • D;L4;C;P30;C;G;E;D;C;F;L2;A;L4;O
  • 4;C;P30;L4.;C;L8;O3;B-;L4;A;L4.;
  • A;L8;G;L4;F;P30;F;E;D"
  • 1730 PLAY "L2;C;L4;P30;C;L4.;B-;
  • L8;A;L4;G;A;G;F;G;D;E;L2;F"
  • 1740 NEXT X
  • 1750 PLAY "L1;F"
  • 1760 RETURN

I’ve chosen to display this the way it ran in The Rainbow rather than the way it would appear in a printout, because line 1720 is a long line. Melodies often were. The play statement was very cool, because rather than sound frequencies and durations, it used musical notes. Any letter from A to G was that note. The letter O set the octave; L set note lengths with 1 being a whole note, 2 being a half note, 4 being a quarter note, and so on; T set the tempo, V set the volume, and P was a pause. It wasn’t a rest, because P did not act like a note: you had to put the pause length after the letter P. It would not assume the length like notes did. Durations could even be dotted just as on a musical staff, the pound symbol denoted a sharp, and the dash a flat.

I used the same technique for the piano script in 42 Astoundingly Useful Scripts and Automations for the Macintosh, except that I do use a true rest, and I put dots on the note instead of on the duration.

This makes it very easy to translate music from paper to the computer. You can read the melody from the PLAY string: volume 27, quarter notes, note C, dotted quarter, another C, eighth note, octave 3, B-flat, and so on. Branigan uses semicolons to make the items more readable, but they’re not necessary.

On my piano script, you might play Beethoven’s famous four-note opening like this:

  • piano --key E- --tempo 108 R - 12 G G G 2 v+++ -E

Using the PLAY statement, it would go like this:

  • PLAY "V5;T2;O2;P2;L12;G;G;G;L2;V9;E-"

The PLAY statement could not play multiple voices at once. That’s one of the reasons Mosley wrote his own machine code for his tunes. Likely, another reason is that the one voice it does have is not the best that the CoCo can produce. But what PLAY lacked in quality, it made up in simplicity. You didn’t need any special knowledge of frequencies or even programming to make music. All you needed was the ability to read music. Because of this, The Rainbow contained a lot of music programs by people who wouldn’t otherwise have written computer programs. And if you did know programming, writing music editors was as simple as string manipulation. PLAY could even take a library of tunes or motifs and mix them up. A letter X followed by a string variable inserted the value of that string variable into the melody. Branigan used that feature in Frosty the Snowman:

  • 4660 '***FROSTY THE SNOWMAN***
  • 4680 F1$="EFL2G":F2$="EDL2C"
  • 4720 PLAY "T5;XF$;XF1$;XF$;XF2$;XS$;XF$;XF2$;XT$;XL$;"
  • 4725 RETURN

The PLAY statement on line 4720 is made up entirely of a tempo and then predefined parts. Careful use of the substring function in PLAY allowed you to alter tempo, volume, duration, and even octave while reusing the same melody.

Branigan’s Nativity: Arron W. Branigan’s Nativity scene from the December 1986 Rainbow’s “Go Tell It On the CoCo”, on the TRS-80 Color Computer.; Christmas; Color Computer; CoCo, TRS-80 Color Computer

Away in a manger, the baby awakes…

In response to 8 (bit) Days of Christmas: Eight holiday images created on the TRS-80 Color Computer, from the early to mid eighties.

  1. <- Day 1 Merry Christmas!