42 Astoundingly Useful Scripts and Automations for the Macintosh

8 (bit) Days of Christmas

Eight holiday images created on the TRS-80 Color Computer, from the early to mid eighties.

Jerry Stratton, December 17, 2020

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

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”.

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

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
December 22, 2020: 8 (bit) Days of Christmas: Day 10 (Up on the Rooftop)

So far all of the Christmas images I’ve chosen have been drawings for display while music is playing. This image from J.D. German’s “Up on the Rooftop” from the December 1986 Rainbow is an image from a video game.

Actually, it’s not a game in the usual sense, since there is no scoring or clock to play against. But it is fun—so much fun that you may have trouble getting the kids to give up the computer when it’s your turn.

This is a genre of “game” that I saw several examples of in both The Rainbow and 80-Micro, the game for younger children that involved manipulating things on the screen but not in opposition to anything—unless the child created that opposition in their own mind, which of course they probably did.

Richard Ramella, in his 80 microcomputing column Fun House, made a lot of games like this for us to type in. And many were fun even for adults. His very short text adventures were a great way to relax in a very short amount of time. If you’re interested in games like this, look for Ramella’s “Fun House”, from his column in the September 1982 issue of 80 Micro. Ramella also wrote the occasional program for The Rainbow, such as Bubble War in the February, 1986 issue.

In German’s “Here Comes Santa Claus”, the player controls the reindeer on Santa’s sleigh.

…the reindeer and sleigh behave according to the laws of physics, having to overcome momentum to change their flight path.

The player can make the reindeer pull up and pull down, while the buildings glide by below. If all of the reindeer are on the ground, and the player presses the down arrow again, Santa stops; the up arrow resumes his flight. The reindeers’ hooves beat against the ground while they’re moving against it.

And that’s it. This is an extraordinarily simple game, but it’s also fun, especially for young children who (at least back then) got a great thrill simply by making the images on the computer respond to their own actions on the keyboard or joystick.

It’s also a great lesson for beginners on how to animate graphics in BASIC on the Color Computer. He uses multiple screens to create a (somewhat, given the limitations of the time) seamless animation—he prepares each scene on a hidden screen and then displays it, hiding the current screen, which then gets changed to be the next scene, and so on.

The animation is achieved by paging back and forth between two screens. While one screen is being displayed, the other is having the figures cleared and set to a new position.

To do this and still get four colors, he uses PMODE 3; that uses four pages per screen, and since Extended Color BASIC supported 8 pages, this gave him two screens to work with: one visible and one invisible.

Santa is added last, so that he appears to be in front of the objects on the ground.

December 21, 2020: 8 (bit) Days of Christmas: Day 11 (O Christmas Tree)

Robert T. Rogers’s article, “Holly Jolly Holidays”, from the December 1984 Rainbow presented seven images and melodies:

  1. A snowman to the tune of Frosty the Snowman;
  2. A Christmas tree to Oh Christmas Tree;
  3. A star to Silent Night;
  4. A computer to Holly Jolly Christmas;
  5. A house in winter, to White Christmas;
  6. A sing-along with lyrics, for Jingle Bells;
  7. Flags of various countries to Joy to the World.

Item four is a bit self-referential.

If you want more songs,

Anyone can add or change the scenes and add new songs easily; just tack them at the end and change the line with RUN in it.

This is a lot of stuff for a single program. “It should fit in 16K, even though it was written on a 32K machine. If necessary, remove one picture and its music.”

Rogers also includes some tips to save memory:

When typing the listing you can omit the semicolons in the PLAY statements… Also, many of the LINE and CIRCLE statements are on separate lines for clarity; however, they can be put together on the same lines to save memory/time, just watch out for a few GOSUBs. The different segments of the programs most usually end with PLAY statements and begin with PMODEs, so if you need to eliminate routines to conserve memory, look at these areas for hacking.

I am always amused by BASIC how-to books from the era that extolled the necessity of commenting your code. As I wrote in my review of John M. Nevison’s Little Book of BASIC Style,

By the time the book came out, the audience was mostly people to whom that advice made little sense. In the penultimate chapter, he writes that “bad reasons” for code brevity “includes every argument about machine storage… Machine storage is cheap.” For him it was cheap, because someone else was paying for it. For someone with a Timex Sinclair and 2 kilobytes of RAM, space for program code was very dear. Some of his very, very short programs include more comments than code, easily using a quarter to half or more of the memory available on personal computers.

Comments were used sparingly for a reason: they took precious space away from making the computer do something useful. Rogers, in this program, uses one of the very useful tricks of the era: rather than waste a lot of space on comments, waste a little space on making the code itself more readable, and then let the reader know what to do to save memory. Tim Hartnell often had similar advice in his books.

December 20, 2020: 8 (bit) Days of Christmas: Day 100 (Hearth)

Eugene Vasconi did several Christmas programs for The Rainbow. This is from “Holiday Hearth” in December 1986.

Christmas Fireplace is a warm addition to your holiday cheer and uses a graphics technique put forth by John Fraysse in the October 1983 Rainbow.

This is low resolution graphics—PMODE 1—with four colors. The advantage of low resolution graphics was partly that it used less memory, and partly that because it used less memory it could be manipulated more easily. These computers were very slow compared to modern computers. Drawing the graphics took time, and the user could visibly see the shapes drawing slowly on the screen.

That second number that always accompanies PMODE is the page of memory to start the graphics on. The Color Computer had eight pages for graphics, depending on how you allocated it. Higher resolution, or more colors, used more pages for each screen.

PMODEResolutionColorsResolutionPages per screen
4high2256x1924
3medium4128x1924
2medium2128x1922
1low4128x962
0low2128x961

This combines the tables on pages 98 and 100 of Getting Started with Extended Color BASIC.

By using low resolution, Vasconi was able to get four colors and four screens (8 pages, divided by 2 pages per screen). So he could draw on one screen, and then copy the drawing, page by page, to another screen.

  • 95 PMODE1,7
  • 96 PCOPY 3 TO 7:PCOPY 4 TO 8

Here, he copies the two pages of the screen that are on pages 3 and 4 to pages 7 and 8, after switching to the screen starting at page 7.

Copying pages made animation a little easier: you could copy a scene from one set of pages to another, and then draw over just the changes. It works just like the old flip books that kids used to draw in their notebooks. Each frame rapidly replaced the previous frame creating the illusion of motion. In this case, an animated fire in with four frames.

This is the Fraysse graphics technique Vasconi mentioned in the introduction:

Part one of the program creates the basic graphics scene while part two holds the animation loop of four fires, light patterns, and the music.

December 19, 2020: 8 (bit) Days of Christmas: Day 101 (Rudolph)

In December 1985, George and Ellen Aftamonow’s “Rudolph the Red-Nosed Reindeer” article gave us an illustrated Christmas carol.

Your computer’s screen will present a series of graphics illustrations, which match the song’s lyrics, while playing the famous holiday tune. Rudolph the Red-Nosed Reindeer takes advantage of the POKE 178 command, which allows a brilliantly colored screen that otherwise would not be possible.

The infamous POKE 178 was related to artifact colors. Like Arron Branigan’s snowman, the Aftamonows’ story-telling graphics and music program uses artifact colors.

When the program first starts, you will see a large dot on your screen. This dot should be red. If not, press Reset and RUN until you get a red dot, or instead you’ll have “Rudolph the Blue-Nosed Reindeer.”

The POKE command allowed you to change values in your computer’s memory. This included the parts of your computer’s memory that controlled hardware and that were the operating system. Modern computers won’t generally let you do this, for the obvious reason that you can really screw things up, as well as the less obvious reason that in a world of networked computers it’s a gigantic security risk. If you’ve ever seen a program crash with a segmentation fault, that program was likely trying to do something with or to memory it shouldn’t have been.

What POKE 178, X did was change the value of memory at location 178. By default it was three. This value controlled the color that commands such as LINE or CIRCLE drew.

Most of the time, their program poked a low value in location 178, such as 1:

  • 670 DRAW"BM24,34"+SA$:POKE178,1:PAINT(32,38),,1:POKE178,3

This changed the solid color pattern to another solid color pattern, depending on the random startup of the video display generator; did the paint, and then went back to the default value.

But larger numbers produced multi-colored stripes.

  • 420 POKE178,155:PAINT(52,146),,1:PAINT(100,148),,1:POKE178,3

This was one way that more than two colors could be displayed on the TRS-80 Color Computer’s two-color graphics mode. If you have a Color Computer, or an emulator such as xroar, you can play around with them using this program:

December 18, 2020: 8 (bit) Days of Christmas: Day 110 (Snowman)

Arron Branigan’s snowman from the December 1986 Rainbow article, “Go Tell It On The CoCo”, uses the Color Computer’s high-resolution graphics mode, giving it a full 256 by 192 pixels, but only two colors. So how is it that you can see more than two colors in this image?

Due to the limitations of the NTSC signal and the phase relationship between the VDG clock and colorburst frequency, it is not actually possible to display 256 dots across the screen reliably… when one switches to the white and black colorset, instead of a muddy gray as you would expect, you will get either red or blue. Reversing the order of the alternating dots will give the opposite color…. Unfortunately the VDG internally can power up on either the rising or falling edge of the clock, so the bit patterns that represent red and blue are not predictable. Most CoCo games would start up with a title screen and invited the user to press the reset button until the colors were correct!

I hope to have an example of that—a program that asks you to reset until you get the correct artifact colors—by Christmas Eve.

And read that carefully: “the NTSC signal”. If you lived in a locale that didn’t use NTSC, but rather used PAL, none of these tricks worked. Because that’s what they were: tricks. You didn’t find this stuff in the official manuals. They were passed by way of poorly-copied newsletters, third-party magazines, and computer clubs, like the arcane formulae of magic spells.

While Branigan uses a handful of DRAW commands, most of his image is drawn with more basic shapes: lines, circles, and boxes. Here’s an example from the part of his code that draws the snowman:

  • 4500 CIRCLE (63,117),35,1,.5,.80,.65
  • 4510 PAINT (15,160),1,1
  • 4520 CIRCLE (128,135),67.5,0,.5,.83,.15
  • 4530 CIRCLE (128,135),67.5,0,.5,.35,.6
  • 4540 CIRCLE (128,90),45,0,.5,.83,.50
  • 4550 LINE (52,102)-(80,76),PRESET
  • 4560 LINE (0,0)-(256,192),PRESET,B

The circles are somewhat obvious; the command takes a point for the center, a radius, and then the less obvious color value, height/width ratio, and start and end—that is, the CIRCLE command can also create ellipses (by altering the ratio) and arcs (by providing a start/end point).

The PAINT command takes a point, and a color, and a border color, and fills that color in on the screen until it reaches the color specified as the border. This is how circles can become disks, for example.

December 17, 2020: 8 (bit) Days of Christmas: Day 111 (Dual Greeting Card)

The December issue of The Rainbow, a magazine for the TRS-80/Tandy Color Computer, always contained several Christmas programs, and many of those were Christmas art made on the very low color graphics of the era.

Here’s what the code tended to look like in the magazine:

[toggle code]

  • 60 DIM A$(90)
  • 70 A$(33)="U4E2F2D2NL4D2BR3" 'A
  • 80 A$(34)="U6R3F1D1G1NL3F1D1G1L3BR7" 'B
  • 90 A$(35)="BR3E1BU4H1L2G1D4F1R2BR4"'C
  • 100 A$(36)="U6R3F1D4G1L3BR7" 'D
  • 110 A$(37)="R4BU6L4D3NR2D3BR7" 'E
  • 120 A$(38)="U6NR4D3NR2D3BR7" 'F
  • 130 A$(39)="BR4BU5H1L2G1D4F1R3U2NL1D2BR3" 'G
  • 140 A$(40)="U6D3R4U3D6BR3" 'H
  • 150 A$(41)="BU6BR1R2L1D6L1R2BR4" 'I
  • 160 A$(42)="BU1F1R2E1U5BD6BR3"  'J
  • 170 A$(43)="U6D3R1NE3F3BR3" 'K
  • 180 A$(44)="NU6R4BR3" 'L
  • 190 A$(45)="U6F2ND1E2D6BR3" 'M
  • 200 A$(46)="U6F4U4D6BR3" 'N

That’s from Joseph Kohn’s December 1984 code for “Season’s Greetings”. Each of those lines beginning with A$ after the line number is the code for drawing a letter. The Color Computer had a DRAW command that took one-letter directions such as U for up, E for heading up at a 45-degree angle, F for heading down at a 135-degree angle, D for down, and so on.

Line 70, the letter A, draws a line up 4 pixels, then goes right and up—at a 45-degree angle—for 2 pixels, down and right (a 135 degree angle) for 2 pixels, down for 2 pixels, goes left without updating the pen position (NL) for 4 pixels to draw the crossbar for the letter A, then completes the A’s right leg by drawing down for 2. Finally, it moves the pen right without drawing (BR) three pixels to prepare for the next letter.

If you have a Color Computer, or the emulator xroar, you can see it happening using this program:

  • 10 REM DRAW LETTER A
  • 20 DATA U4,E2,F2,D2,NL4,D2,BR3,END
  • 30 PMODE 3,1
  • 31 PCLS 2
  • 32 SCREEN 1,0
  • 40 READ D$
  • 41 IF D$="END" THEN 100
  • 42 DRAW D$
  • 43 FOR I=1 TO 800:NEXT I
  • 44 GOTO 40
  • 100 GOTO 100

The DRAW command is how most of these images were made. By using an array of instructions, Kohn was able to put messages on the screen—and was able to let the person on the other end of the magazine, typing it in, change that message by changing which letters were drawn. This is the subroutine he used for that:

  • 930 FORX1=1TO LEN(X$):Y1=ASC(MID$(X$,X1,1))-32:DRAW"XA$(Y1);":NEXT:RETURN
  1. Repeat for each position in the string to be displayed (X$).
  2. Get the ASCII code for the letter at the current position, reducing it by 32.
  3. Use that code as the position in the A$ array, and use the draw instructions at that position.