42 Astoundingly Useful Scripts and Automations for the Macintosh

8 (bit) Days of Christmas: Day 1 (Do You Hear What I Hear?)

For day 1 of the 8 (bit) days of Christmas, John Mosley’s “Do You Hear What I Hear?” from the December, 1987, Rainbow Magazine. Mosley coaxes four-voice music out of the CoCo 1 and 2 using a machine-language program.

Jerry Stratton, December 23, 2020

By the end of 1987, most of the cool programs in the Rainbow were for the Color Computer 3. The CoCo 3 was a giant leap forward, both in its innate capabilities—better graphics, better text manipulation on graphics displays, better text output if you had a good monitor—and in the software available for it. OS-9 Level 2 was a phenomenal operating system. All for only $129.95!1

But there was still life left in the old system, too, as John Mosley showed us in “Do You Hear What I Hear?” in the December 1987 issue of The Rainbow. What we heard was some of the best music to come out of the Color Computer 1 and 2. “Your ears do not deceive—it’s CoCo singing in four voices!”

That music didn’t come without some work on the part of the reader. If you didn’t subscribe to the tape or disk version of the magazine, you had to first type in a program that asked you for a starting memory address to POKE the code into, and then the program asked you, one `INPUT` at a time, for the hexadecimal values of the code:

Enter Listing 3 one hexadecimal value at a time… When you are through entering Listing 3, or when you have to stop entering, type S and press ENTER… If you are just stopping temporarily and plan to resume entering later, write down the number to the left of the ‘S’ you typed before you press ENTER… When you are ready to resume entering, use that number as your start address. You will have to load the old file you saved before you can resume entering Listing 3.

He doesn’t mention what to do if the music doesn’t play—if you made a mistake entering those four thousand hexadecimal values. I probably would have provided another short program to PEEK the values in memory, displaying them twelve to a line for verification against the printed text. But perhaps it was assumed that people would know how to do this. I’ll show how I entered those hex values in a week or two.

Long-time readers of this blog will not be surprised to learn that I did not type them in to an `INPUT` prompt one at a time.

Like Eugene Vasconi’s Holiday Hearth, Mosley’s program uses multiple files. In his case, however, one file is the combined machine language program/musical notes and the other is a simple 42-line BASIC program to wish us Merry Christmas while the music plays. The relevant code for that loop is:

  • 350 EXEC&H3F00
  • 360 FORT=1TO3000:NEXTT:GOTO350

These two lines come after the code for drawing the Christmas greeting, and before the very few subroutines that the program uses. Line 350 executes the machine language code at memory location (in hexadecimal) 3F00. That’s 16,128 in decimal, which means that this program require 32 kilobytes. It looks to me like the BASIC program and the machine language program/data ought to be able to fit into 16k, but the addition of a single screen of PMODE 4 graphics adds 6 kilobytes to the memory needed. Add in the 4 kilobytes of machine language code and data, and that’s going to start cutting it close.

Line 360 pauses for approximately six and a half seconds before going back to line 350 to play the music again. This one line of code was very common back then, and is the strangest thing to see today. It puts the computer into a loop of wasted CPU time in order to do nothing! This was possible then because the computer wasn’t doing anything else. Nowadays, two things would happen if a programmer tried to use loops to create pauses. First, it wouldn’t work, because the duration of a loop would not be predictable. The computer is doing other things, and those other things will put varying demands on the computer, making the loop have varying durations. And second, depending on the code used for the loop, every other app on the computer would slow down, possibly even appearing to lock up.

But when this program was running, it was the only program running. So its loops had predictable durations, and there was nothing else to complain about wasting processing power.

By 1987, even on the Color Computer, there were alternatives to this. The OS-9 operating system that could be purchased for the Color Computer had, even as far back as 1980, a sleep command that, like the sleep command on modern Unix-like OSes, put the current process to sleep for a specified number of seconds. But of course OS-9 was a multi-process and even multi-user operating system, so CPU time mattered outside of the current process. On Extended Color BASIC, it, for all practical purposes, didn’t.2

This was the official means of pausing for x seconds; it’s on page 35 of the Getting Started with Extended Color BASIC manual.

Along with using PMODE 4 graphics, it also uses the NTSC artifacts trick to display more colors; this means having to verify that the computer hit the correct “rising or falling edge of the clock” when it was turned on, and resetting it if it did not. You can see this in the video; the program displays an ostensibly blue block, and then asks the user to verify the block’s color. If the block is not blue, the user is asked to reset their computer to get it blue. I had to reset my computer seven times to get that block to display blue when testing this program.

You might notice that the question and the block are not on the screen at the same time. One of the greatest features of the new Color Computer 3 was the ability to display text on its graphics screens. The Color Computer 1 and 2 could not do so—text and graphics were completely different modes. That’s the reason that programs such as Joseph Kohn’s greeting card used graphics commands to draw letters.

Have yourself a merry little Christmas!

John Mosley’s Merry Christmas: “Merry Christmas!” from John Mosley in the December 1987 issue of The Rainbow.; graphics; Christmas; Color Computer; CoCo, TRS-80 Color Computer

This image—and the music that came with it—is the inspiration for 8 (bit) days of Christmas.

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. The CoCo 3 with OS-9 was the computer I used from about 1987 to sometime in the mid-nineties; I don’t remember exactly why I stopped using it, but it probably had to do with not working well on the Internet and when interacting with the computers I used at work. But I continued to miss its functionality and the speed of doing multiple things at once until the Unix-like OS/9 came out on the Macintosh.

  2. If the computer had a print spooler, or it was running a disk OS, then it might be possible that there would be one process other than the BASIC program to complain. But disk operations would be unlikely to be running during a BASIC loop.

  1. <- Day 10 Help Santa
  2. Day 0 Nativity ->