[Coco] Commodore 10 PRINT maze in Color BASIC / Assembly
Allen Huffman
alsplace at pobox.com
Mon Jun 20 23:33:41 EDT 2022
I expect most/many here are familiar with the famous Commodore 10 PRINT maze program:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
It generates a random maze using PETSCII diagonal characters, like a forward and backslash but they go all the way to the corners of the character.
CHR$(250) is one slash, and CHR$(206) is the other.
On the CoCo, the best we can do is forward slash CHR$(47) and backslash CHR$(92). That makes the math a bit harder, since you start with a base value — 47 — and either add 0 or 45 based on random. I tried it like this:
10 PRINT CHR$(47+(RND(2)-1)*45); : GOTO 10
I discussed this in an article I wrote, after YouTube showed me a BASIC driving game using this maze created by Robin of 8-Bit Show and Tell:
https://subethasoftware.com/2020/04/03/porting-10-print-racer-by-8-bit-show-and-tell-to-the-coco/ <https://subethasoftware.com/2020/04/03/porting-10-print-racer-by-8-bit-show-and-tell-to-the-coco/>
QUESTION 1:
Any better ways to do this in Color BASIC?
QUESTION 2:
Robin also ported the program to Commodore 6502 assembly:
https://www.youtube.com/watch?v=IPP-EMBQPhE <https://www.youtube.com/watch?v=IPP-EMBQPhE>
In his assembly version, he makes use of a ROM call to output the actual character, but generated the random number several ways, each time making the program smaller. Initially, it was using bits from the sound generator. Eventually, it was using “random” data in the ROM (which pleased me, since I just ported my BIGMAZE BASIC program to assembly and ended up doing something similar to create “random” values for it).
Mine would look like this:
—10printasm.asm---
org $3f00
start
ldy #$A000 * Color BASIC ROM
mainloop
cmpy #$B000 * Arbitrary spot in ROM.
beq start * If there, GOTO start.
lda #'/ * A="/"
tst ,y+ * Test NEG bit (high bit).
bmi print * Branch if NEG set.
lda #'\ * A="\"
print
jsr [$a002] * Print what is in A.
bra mainloop * GOTO mainloop.
END
How much smaller can it be made?
--
Allen Huffman - PO Box 7634 - Urbandale IA 50323 - 515-999-0227 (vmail/TXT only)
http://www.subethasoftware.com - https://www.facebook.com/subethasoftware
More information about the Coco
mailing list