A New Take on the Infinite Maze for the ZX81


I decided to build a different version of the infinite maze using my print scroll 2 routine.

After updating my print scroll routine, I started thinking about how I could use it to create a different version of my infinite maze program. The original used graphic characters and spaces since the ZX81 lacked a backslash. This new version takes a different approach, using alternate graphics to build a more visually interesting maze while leveraging a better machine scrolling routine.

# A new look, but not a new idea.

This version of Infinite Maze only uses two characters to create a more structured maze pattern: a left horizontal bar and a bottom horizontal bar. Together, they form a visually appealing maze that fills the screen. Thanks to the print scroll 2 routine, I don’t have to handle scrolling manually. Instead, the maze builds naturally from the top of the screen down.

PS2 Infinite Maze, ZX81 Screenshot, 2024 by Steven ReidPS2 Infinite Maze, ZX81 Screenshot, 2024 by Steven Reid

The result is a nice little screen saver for your ZX81 (whether hardware or emulator) that doesn’t require much memory. However, since it fills the entire screen with characters, I still recommend a 16K memory pack. Otherwise, it’s a simple and efficient program.

An interesting note: the characters can actually form a few different configurations by alternating vertical and horizontal graphics. There are four variations that look good. I considered adding more variety, but the program works well as is.

# The BASIC code couldn't be much simpler.

Since the Print Scroll 2 machine code routine handles scrolling, the BASIC code itself is minimal—just two lines:

  20 PRINT USR 16514; "[5][6]"(RND+1);
  30 GOTO 20

Here, [5] represents Shift Graphics 5 (the vertical left bar), and [6] is Shift Graphics 6 (the horizontal bottom bar). The code randomly selects one of these two characters and prints it, then repeats. Simple and effective.

PS2 Infinite Maze, ZX81 Listing, 2024 by Steven ReidPS2 Infinite Maze, ZX81 Listing, 2024 by Steven Reid

Looking at the code, I realized I could have simplified it further by omitting the CLS. The RUN command already clears the screen, making line 10 redundant. Simplicity at its best!

# Need more ideas.

With this complete, I think I’m done playing with the print scroll code. I set aside modifying it further—sure, I could add more variety to the maze generation or refine the PS2 routines even more, but no, this is enough fun for now.

As a side note, I toyed with the idea of calling USR routines to create a one-liner similar to the C64’s classic “10 PRINT” maze code. While digging around, I found someone else had already done it. Sigh. For completeness, here’s the routine:

  10 PRINT "[5][6]"(RND+NOT PEEK USR
 (3085+ABS (PEEK 16441-17)=16))
*USR 3663);

I wish I’d thought of that! It works well, and no, I won’t try to explain it. At least not today.

Enjoy!



Comments on this article:

No comments so far.

Write a comment:

Type The Letters You See.
[captcha image][captcha image][captcha image][captcha image][captcha image][captcha image]
not case sensitive