Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, Swift, BASIC, and whatever else I happen to feel like hacking at.

Color Computer binaries from decimal values

Jerry Stratton, February 13, 2021

Space Hawk

At the end of my post on the first version of cocobin, I wrote:

It’s also likely that some binaries were provided as decimal instead of hexadecimal numbers.

And only a few weeks later, here I am. I found a really nice Galaxian/Space Invaders-style game by Rodger Smith in the February 1985 Hot CoCo.1

He used decimal numbers for his DATA statements, so I added that feature to cocobin. If a file or BASIC program contains decimal rather than hexadecimal numbers, add the option --decimal to the cocobin command line.

Also as expected, adding this feature also highlighted another common custom of the era: the DATA items often included a marker to denote the end of the data. Most commonly, as I recall, this was the word “END”, or (for machine code) a negative 1. Smith used the number 999. So I’ve added the ability to recognize “END”, “999”, or “-1” at the end of a line of DATA in a BASIC program. If the program sees any of those key words at the end of a DATA line, it assumes that that is the end of the data to be read.

Either of those keywords not at the end of a DATA line will still be seen as an error, since none of them represent valid POKEable numbers.

The script now accepts the following arguments:

load addressdecimal or hex address for location of binary data in CoCo RAM
exec addressdecimal or hex address for starting execution; defaults to load address
filenamesfile[s] to pull data from; data can also be piped
--basicthe text is a BASIC file; pull hex values from DATA lines
--columns <column count>verify that each line contains a specific column count
--decimalthe numbers are decimal numbers, not hexadecimal
--helpprint this text
--quietdo not output bin data
--verboseprovide information about the binary program

Also, while this is not a change, I did finally verify that the script works when used with multiple files. Charles Husak’s “The Little Runner” from the March 1984 Rainbow uses three BASIC programs to POKE the binary into memory. This command line worked to create a working binary from those three files:

  • cocobin --basic 13000 RUNNER*.BAS > RUNNER.BIN

Interesting little game!

In response to Create Color Computer binaries from hex values: Take a text file filled with hexadecimal numbers and create a TRS-80 Color Computer BIN file.

  1. Note, if you attempt to do this yourself, there is an update in the April 1985 issue of Hot CoCo, page 13; there was a typo in line 640. It should read:

    640 DATA 183,89,25,247,89,27,236

    Without that fix, cocobin will see an error: there will be no comma between the end of subline 2 and the beginning of subline 4—because subline 3 will be missing.