[Coco] Commodore 10 PRINT maze in Color BASIC / Assembly

robert.gault at att.net robert.gault at att.net
Tue Jun 21 21:31:18 EDT 2022


Allen, Your asm program is probably as small as is possible but is not really random. If you want to use the ROM routine for random numbers RND you could try the enclosed. RobertSent from my LG Mobile------ Original message------From: Allen Huffman via Coco Date: Mon, Jun 20, 2022 11:33 PMTo: CoCoList for Color Computer Enthusiasts;Cc: Allen Huffman;Subject:[Coco] Commodore 10 PRINT maze in Color BASIC / AssemblyI 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/ 


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 

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



-- 
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Random.asm
Type: application/octet-stream
Size: 661 bytes
Desc: not available
URL: <https://pairlist5.pair.net/pipermail/coco/attachments/20220621/8ddb92ac/attachment.obj>


More information about the Coco mailing list