New, improved rcheck+ for Rainbow Magazine code
I’ve added a few new features to the rcheck script to make it more useful for typing in code from The Rainbow.
--debug | provide a hexdump of the tokenized BASIC file |
--rcheck | use the original rcheck rather than rcheck+ |
--shift <x> | shift all checksums by x |
--verbose | show checksums for all lines |
[xxx] | show checksum for line xxx |
[xxx:yyy] | verify line xxx against expected checksum yyy |
[:yyy] | verify checksum yyy at the end of the code |
rcheck+ for macOS (Zip file, 2.5 KB)
The big, important change is that you can now specify the expected checksums on the command line. You can continue to use rcheck as before, and its behavior will not change. But if you add “:yyy” to a line number, it uses “yyy” as the expected checksum. For the final line, you can use simply “:yyy” or “yyy”.
- ~/bin/rcheck MEMOCARD.BAS 130:15 210:170 320:9 :167
- 130: 15
- 210: 152 238 (-18); possibly a 4 where there should be an F?
- 320: 247 238 (-18)
- END: 149 238 (-18)
When a checksum does not match the expected checksum, the script shows the difference. This is extremely helpful, because often merely knowing that the checksum is off by, say, 32, tells you what the likely problem is—a missing or extra space, or an incorrectly-cased letter. In fact, some errors are common enough that I’ve put a check for them in the script, as you can see in the example.
- The dash is right next to the equals on my keyboard, so that’s a common mistake.
- I’ve no idea why I often type 4 where I should type F, but I do.
- Ditto with typing a dash instead of an equals sign.
- Also, very commonly spaces will not be obvious and so will not be typed when they appear in a remark, especially when they appear (I suspect) at the end of a remark.
- Multiples of 32 can be the result of case issues, since the difference between upper and lower case characters is 32 in ASCII, or multiple missing/extra spaces.
- Every once in a while, not only can’t I find the supposed error, but the very next block of code is also off—by the inverse of the amount the previous block was off. I suspect that these are typos in the Rainbow checksum block.
If you provide expected checksums, the script keeps track of the accumulated error, so that checkpoints that follow an erroneous checkpoint will be displayed with their correct error amount, or in green if that particular checkpoint has the “correct” checksum. That is, if, in the above MEMOCARD.BAS example, the checksum at 210 is 175 instead of 170, the script keeps track of the error, and will expect checkpoint 320 to be 14 and the end to be 172—that is, five above the listed checksum, since checkpoint 210 is five above its expected checksum.
I did this because I find myself typing either complete scripts or several columns, and so it’s nice to see all that green after one error. And I also occasionally put off looking for errors until later if I can’t find what I mistyped. By correcting for previous errors, the script makes it easier to check for errors in subsequent checkpoints without having to fix them in order.
Something you can’t see in that example is that the script also highlights good checksums with green text, and bad checksums with red. Here’s an example from Talking CoCo Cathead in the November, 1987 issue of The Rainbow:
Also, it will not show the end total if you give it a list of checksums and the highest line in the code is less than the highest line in your list of checksums; instead it will say “END: Not finished”, because, presumably, this cannot be the end total if there are still checksums to go.
While I updated the original code to include the --debug option, I never explained it. The --debug option is really only useful for debugging rcheck itself, although I did find it helpful for one program that had clearly been tokenized differently for The Rainbow than it was on my Color Computer. Le Lutin from the July 1987 Rainbow has apparently been compressed by removing spaces directly from the tokenized code. This makes the program impossible to type in as presented, because lines such as ONLGOSUB
get tokenized as if LGOSUB were a variable.1
I added the --shift option for that program, once I realized that all checksums after the offending code were off by the same amount once I fixed them. So that I was able to run
- ~/bin/rcheck LE\ LUTIN.BAS 5 13 28 48 68 84 94 104 116 124 140 160 183 198 214 219 228 236 247 260 272 277 290 296 302 310 317 321 332 346 --shift 43
to get the checksums after line 28 to match the checksums in the magazine.
I added this before I knew what the problem was with the checksum, except that as hard as I looked I couldn’t find it. So I decided to put off dealing with it and just go on typing the rest of the program, using --shift to adjust the checksum to take into account the errors at the beginning. Fortunately, those special cases only appeared at the beginning, and I was able to complete typing the rest of the program without further problems. Once I tried to run the program, the reason for the checksum discrepancy became obvious.
Even when the error is mine rather than the magazine’s, however, it is sometimes helpful to give up for a while and just move on to the rest of the program. Errors sometimes become more obvious when I stop looking for them.
I mentioned the --rcheck option as a quick update to TRS-80 Color Computer RCHECK+ in Perl. Before rcheck+ calculated checksums, The Rainbow included an rcheck not plus that simply checked the amount of RAM that the program was using.
- $ ~/bin/rcheck ENRAK.BAS 70 140 290 390 580 680 870 1100 1260 1360 1510 1610 1720 1830 --rcheck
- 70: 0426
- 140: 076F
- END: 07AF
I’m not sure how many errors this would pick up that wouldn’t also be picked up just by looking down the right-most column of the listing. Errors that cause a BASIC statement to not tokenize would be picked up, as would extra or missing characters in the final subline of a BASIC line, since the final subline in a Rainbow listing doesn’t usually reach the rightmost (32nd) column.
I also added a --verbose option to show checksums for all line numbers (this was originally part of --debug, but it tended to obscure the hexdump). This is rarely useful.
Other minor and not-so-minor fixes since I first announced the rcheck script are that the script now handles BASIC programs with spaces in their names correctly. It was a rarely-used feature, but Disk Extended Color BASIC didn’t care if programs had spaces—such as Le Lutin.
As a side note, the two characters after the line number that rcheck skips over, that I didn’t know what they were? I’m pretty sure now that they’re the hard address of the next line number in hexadecimal.
In response to TRS-80 Color Computer RCHECK+ in Perl: I much prefer to use a modern keyboard and modern windows to type in programs. But Rainbow’s RCHECK+ was too useful to give up. This script will run RCHECK+ on a text file in the macOS Terminal or any Linux/Unix command line.
The same is true of letter variables in front of THEN and GOTO. They require spaces, and in Le Lutin those required spaces had been removed.
↑
- 42 Astoundingly Useful Scripts and Automations for the Macintosh
- MacOS uses Perl, Python, AppleScript, and Automator and you can write scripts in all of these. Build a talking alarm. Roll dice. Preflight your social media comments. Play music and create ASCII art. Get your retro on and bring your Macintosh into the world of tomorrow with 42 Astoundingly Useful Scripts and Automations for the Macintosh!
- Check42 for verifying Astounding Scripts
- If you’ve been wanting to type scripts in from the book but were worried about typos, this script will help you find errors in any scripts you’ve typed in from 42 Astounding Scripts.
- rcheck+ for macOS (Zip file, 2.5 KB)
- Verify Rainbow Magazine rcheck checksums on the Macintosh command line.
More Color Computer
- Simple game menu for the Color Computer 2 with CoCoSDC
- This simple menu provides one screen for cartridges saved in the CoCoSDC’s flash ROM, and any number of screens for your favorite games for your friends to play.
- Rainbow Magazine preflight tool enhanced
- I’ve added several features to the Rainbow Magazine preflight tool, including a check for references to line numbers that don’t exist.
- CoCoFest! 2021
- Forty years later, I finally make it to CoCoFest!
- BASIC tokenization examined
- Why do old BASIC programs have strange characters in their .BAS files? Why do they look like they’re compiled code?
- What are the 8 bits in 8-bit computing?
- Retro computing is often called 8-bit computing. This is because the bytes that these computers use are composed of eight bits, and much of what the computer does is operating on these individual bits, not on the byte as a whole.
- 19 more pages with the topic Color Computer, and other related pages
More The Rainbow magazine
- Rainbow Magazine preflight tool enhanced
- I’ve added several features to the Rainbow Magazine preflight tool, including a check for references to line numbers that don’t exist.
- 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.
- 8 (bit) Days of Christmas: Day 10 (Up on the Rooftop)
- In the December 1986 Rainbow, J. D. German presented us with this game, involving flying and landing Santa to deliver presents!
- 8 (bit) Days of Christmas: Day 11 (O Christmas Tree)
- Day 11 of the 8 (bit) days of Christmas is the graphic accompaniment to “O Tannenbaum” from Robert T. Rogers “Holly Jolly Holidays”, from December 1984.
- 8 (bit) Days of Christmas: Day 100 (Hearth)
- Lower resolution graphics were more appropriate for animation, because you could page through up to eight screens like a flip book. This is Eugene Vasconi’s Holiday Hearth from December 1986.
- Five more pages with the topic The Rainbow magazine, and other related pages
I was inspired enough by rcheck to write a similar program for 42 Astoundingly Useful Scripts and Automations for the Macintosh, check42.