Print Like a Pro on the ZX81 with This Updated Smooth Scroll Routine


This updated print scroll routine mimics the ZX81’s PRINT command, offering smoother, more flexible output.

After wrapping up the last print scroll routine, I immediately dove into improving it. While functional, the original version felt a bit limited. With this update, you’ll find more flexibility in printing displays, though at a slight cost to speed.

# Let’s dive into the enhancements.

The biggest drawback of the previous version was how purpose-built it was, assuming continuous printing. While flexible in what it could print, it wasn’t ideal for general use. This update makes it operate more like the familiar PRINT command on other computers, giving you a lot more options.

In this version, printing will automatically move to a new line unless you end with a semicolon, mimicking the ZX81’s PRINT behavior. This makes it easy to mix into existing code. Unlike before, it will also autoscroll; if you fill the last line, the display scrolls up for a smoother experience.

Another improvement is that you can now use a semicolon to concatenate multiple statements, just as with the usual PRINT command. Previously, concatenation required a plus symbol. Now, you can print with the flow and convenience of standard syntax.

Print Scroll 2, ZX81 Screenshot, 2024 by Steven ReidPrint Scroll 2, ZX81 Screenshot, 2024 by Steven Reid

# Limitations and Caveats

While more flexible, there are still a few limitations. As before, TAB or AT functions aren’t supported. Technically, you can mix in regular PRINT statements as long as you don’t need them to scroll. For instance, you can use PRINT AT to move the cursor, then call the print scroll routine.

Additionally, while you can use commas, they won’t print spaces. You could use a comma as a substitute for a semicolon, but note that the routine doesn’t print numbers by itself; you’ll need to use STR$ to convert numbers if needed. If you rely on this behavior, you’ll need to stick with the standard PRINT command and its quirks.

# A Quick Test Program

To troubleshoot, I created a small test program to confirm things were working. It doesn’t explore every possible use, so if you’re adventurous, you can tweak it to try different options. Here are a few examples to get you started:

PRINT USR 16514               ; scrolls
PRINT USR 16514;"HI" ; prints HI + newline
PRINT USR 16514;"HI "; ; prints HI
PRINT USR 16514;"$";A$ ; prints $ + A$ + newline
PRINT USR 16514;"$";A$;" "; ; prints $ + A$

I tried to replicate the PRINT command’s behavior as closely as possible. So, the routine no longer scrolls unless a character forces it to. For instance, if you print with a semicolon and are on the last character, it won’t scroll, but printing without a semicolon will. To test this, modify the demo program and remove the semicolon on line 30.

Print Scroll 2, ZX81 Listing Screenshot, 2024 by Steven ReidPrint Scroll 2, ZX81 Listing Screenshot, 2024 by Steven Reid

# Sprinkling in Some New Code

With the added functionality, the routine is a bit longer. While it works similarly to before, a few extra checks were needed. For example, checking for the trailing semicolon at the end of the routine now requires determining if we’re on the last line.

To accomplish this, I use the S_POSN address, which tracks the cursor’s screen position. If already at line 4—the last printable line—the routine will scroll; otherwise, it adds a return. To prevent newline interference, I use a ROM routine for tidy handling.

To preserve cursor position, I’ve slightly modified the scroll routine. First, I reordered it to check for a scroll line before printing each character. Then, I set S_POSN to correct values after scrolling, ensuring end-of-line checks behave as expected.

# More to Do?

This updated print scroll works significantly better than the first version, providing a consistent experience similar to BASIC’s PRINT command. There’s still room for improvement, though. The comma behavior, for instance, could be more flexible.

Default comma behavior is mostly unhelpful, but a version that inserts eight spaces, mimicking a tab, could be a nice enhancement. Better still, a customizable tab option could open up new possibilities for text-based programs.

Ultimately, I wonder how useful others might find this routine. It’s relatively easy to work around scrolling behavior, and a machine-language routine could achieve even more. Still, I had fun experimenting with print scroll in a few BASIC programs. You can easily adapt the demo program for your own projects, and I’d love to see what others come up with!



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