Super Simple ZX81 Scrolling Example


I modified an old demo program to create an infinite SIN wave of ZX’s

Although I've been busy working with the ZX81 this month, it has been with my Gem Quest game. Not much to share yet there, but I am working on it. To get in something for the month, I thought I’d share an updated demo program.

# An old beginning.

I was going through my old programs and found this one circa 1998. It was a really simple SCROLL demo that created a nice SIN wave. Here is the original listing:

[/code]
  10 FOR X=0 TO 30 STEP .3
  20 LET L=15+14*SIN X
  30 PRINT TAB L;"ZX"
  40 IF X>6.3 THEN SCROLL
  50 NEXT X
[/code]

I like the result, even if simplistic.

SCROLLEX, ZX81 screenshot by Steven Reid, 1998/2022SCROLLEX, ZX81 screenshot by Steven Reid, 1998/2022

Nothing too exciting, but I needed to tweak the code a bit.

# Starting something new.

Since the first thing I needed to do was make it auto-run, that was where I started. But in doing so, I realized that the original code had a finite ending. The FOR loop is finite and would run into the SAVE routine. So, I got to work fixing that.

This led to a couple of iterations of the program. The first was simply to add a CLS line and a RUN line to the code. That worked, but was jarring when the NEXT got to the end.

For the next version, I dropped the FOR loop altogether. This version would just increment X forever by .3. That worked as well, but at some point the floating point math would run out of digits. It would take awhile, but I decided that wasn’t the best solution.

The final version put the FOR loop back in, but ends after one wave. I forced a SCROLL each loop, removing the IF statement. I then added a RUN back in to make it an infinite loop.

SCROLLEX, ZX81 listing by Steven Reid, 2022SCROLLEX, ZX81 listing by Steven Reid, 2022

The resulting code isn’t much different, but with the stated goal of making it run forever. As a bonus, the 6.3 from the original worked perfect in this version. I hadn’t expected that, but it worked perfectly.

More next time!



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