Bringing an Old ZX81 Sketch to Life with BASIC Is Absolutely Crazy


Yep, I’m losing it. Found this old Star Wars graph I did in 1983 and decided to do something with it.

ZX81 screen shot, Star Wars by Steven Reid, 2017Foreign to many developers today, I have a notepad and binder full of ideas from my ZX81 days. The notepad contains early program snippets. In contrast, I have sketches and designs crammed into a binder. Flipping through it, I landed on a Star Wars sketch that became the basis for this month’s program.

Paper was king.
My programming of today is more computer centric. I keep notes and sketches in folders now. Seldom do I sit down with pencil in hand to write or draw something. That doesn’t mean I won’t, but this isn’t 1983.

I’ve had so many little ideas I’ve written down here and there. Some ideas I’ve got reams of notes for.
– Bryan Lee O'Malley

Back then, computers were single purpose. There wasn’t much value in sketching on a ZX81 since I couldn’t do much with it. It was often faster to type in than to load things from tape. Plus, the ZX81 had a nasty habit of reseting if bumped wrong.

I did write a note taking program, but I meant for you to print out your notes. Not very portable. So, for much of my earlier life, I carried paper around and wrote things down. There is much more in those books than I would ever get around to programming.

Bringing ideas to life.
The one advantage of writing down notes is that I still have them. Much of my work on the C64, for example, is now long gone. Almost all my programs were on disks that I ended up giving away when I sold it for an Amiga. C'est la vie.

Browsing those notes I found myself reliving the ideas I’d jotted down. Sketches sparked inspiration that caused my brain to kick into programming mode. Questions formed. How would I move that? What is the purpose? How might those fit together? Why didn’t I finish this?

The last question, more than any other, is what prompted me to action. The Star Wars sketch, in particular, stuck in my head. My mind started to percolate on it, much like it did when I was a teenager. Questions solidified into answers, which often means code.

Star Wars ZX81 Sketch, by Steven Reid 1983

Transported back in time, I decided to write a newish program for April. An animation started to form in my mind and I spent much of Saturday coding in various ideas. The result is very much like something I would have coded in 1983. A bit more ambitious, but still in the realm of possible.

BASIC is new again.
More entertaining than it should be, writing in ZX81 BASIC was quite thrilling. The simplistic language can be both fun and frustrating. In creating this demo program, I broke up the various art into groups. The planets, ships, etc. became their own sections. Doing so allowed me to test each section before assembling them.

The first section was the planets. Although not something in the Star Wars universe, I left them as is. The sketch was the inspiration and i wanted to stay lose to it. To save space, I did use TAB more than I did in the past.

That done, I focused on the smaller star destroyers. I wanted them to float around, so they have variables that get nudged from time to time. I had planned to group them, but in the end they are each on their own.

The larger star destroyer was a bit of a challenge. It needed to float up into the picture. Using SCROLL would have required repainting the other elements. I tried using a string array, but found it would overwrite parts of the planets. In the end, I used PRINT routines with a simple IF statement to determine when to display each line.

Then came the laser blasts and princess’s ship, each their own sections. These both required a lot of trial and error, but are variations of the same code. The new here is floating point math. I used fractional numbers to move the objects. In doing so, I also found some nuances to how the ZX81 rounded. That caused me to adjust a few lines to prevent errors.

Putting all that together, I had a decent demo that was pretty close to the original sketch. I had to fix a few things since the sketch used the last two lines of the screen. Although I could have made it work, I wasn’t standard nor something I would have done. I also left out the tractor beam which isn’t visible in the movie.

Credits can be hard work.
A last minute inspiration was to include some sort of closing credits. I wanted to replicate the scroll of the movie. Wow, that was way more work than expected. The code was pretty straight forward, but my mind struggled with the math.

I spent the better part of the evening writing down different math problems in OneNote. It’s obvious I hadn’t written any graphic routines in some time. Although short, here is the code I landed with.

1820 LET LTH=LEN S$
1830 LET GRW=(30-LTH)/6
1840 FOR X=5 TO 0 STEP -1
1850 LET M$=L$
1860 LET SIZE=LTH+X*GRW
1870 LET SPC=SIZE/LTH
1880 LET CTR=(30-SIZE)/2
1890 FOR Y=1 TO LTH
1900 LET M$(CTR+Y*SPC)=S$(Y)
1910 NEXT Y
1920 PRINT AT 6+X*2,0;M$;AT 8+X*
2,0;L$
1930 NEXT X

Yeah, not even going to try to explain it. I still see things I missed or would like to fix. But I won’t. It’s good enough, looking better than I expected.

A fun program.
In the end, it was fun bringing an old idea back to the future. If I ever run out of old printouts, at least I know I can revisit my notes for more inspiration. As much as I enjoy modern paradigms and languages, it is refreshing to revisit the past.

My Star Wars demo doesn’t break any new ground, but does well to remind us how far we’ve come. It may not be fast, but the ZX81 was a great little computer that people did a great many things with.

If I tried to do the same thing with a modern computer, I’d spend more than a weekend getting the graphics up to snuff. Instead, I have a quick little demo that is fun for a moment and worth the mental investment.



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