Cat’s Can Be Fun on Computers Too


A simple cat animation converted from GW-BASIC to the ZX81.

A recent post in a Facebook BASIC group of a cat animation. A couple of other members converted it to their BASIC code of choice. Mine being the ZX81, I promptly worked on a version for it. I created a mostly full screen version, which tends to show how slow the ZX81 really was. In any case, it was quite a fun little exercise.

# Quick and dirty animation.
So this is a bit convoluted. I thought the program was written by the poster. However, the video link is over a year old (at this time) from a different author. In the description for that video, it states that the cat animation was sourced from an 1984 book called “Create Your Own - Games Computers Play” by Keith S. Reid-Green. The code is on pages 57 - 58 and is also on the book‘s cover.

Now the original program is written in GW-BASIC and uses the DATA and READ commands to load, store and display the animation. Obviously this won’t work for me as the ZX81 doesn't have those commands. In addition, the way the cat is displayed with color is a bit hard on this black and white computer. Of course, that didn’t stop me from trying.

[Image]cat [2023-01-17 22:26:59] by Steven Reid, on Flickr

# Having fun with code.
Seeing an MSX conversation, I decided to go the easy route and just print the cat as large blocks. Each frame is 32x13, which fits nicely in the ZX81’s screen which is 32 characters wide. This makes the animation quite large, and a bit slow. But I like the large full screen effect. Reminds me a bit of a rotoscope movie.

Cat Animation, 2023, ZX81 version by Steven ReidCat Animation, 2023, ZX81 version by Steven Reid

For the first conversion, I simplified the program to just print each frame instead of reading the data into an array. I actually used the BASIC complier in JSZeddy and then edited the text code to replace the characters with black boxes. it was a straight forward modification that worked well enough.

Now, the original animation had some movement, but given I filled the screen it just runs in place. Maybe the cat is on a treadmill. After playing a bit, I decided to see if I could speed it up any. I converted the lines to load them into a multidimensional string array. Each frame was an entry in that array.

Cat Animation, Another Frame, 2023, ZX81 version by Steven ReidCat Animation, Another Frame, 2023, ZX81 version by Steven Reid

In testing, I found the string version was just a hair faster. You could see it slowly move ahead of the print. I don't know why this is. I ran both versions side by side to verify. I could have created a bench mark of sorts by measuring the frame counter. But, I decided to to just eyeball it and pick one. String won out.

# Could do more, but why.
Now, a better exercise would be to shrink the animation into the smaller pixel graphics of the ZX81. This would allow the animation to move a bit, although not far given the small screen size. I suspect it could be a bit faster as the lines are smaller. But I'd have to display each line separately. In the end, I stuck with the larger block version.

Obviously a faster, and actually easy to program version, would be to convert to machine code. That would be quite simple, but ultimately this was shared in a BASIC forum. As such, I left it in BASIC. Perhaps it would make a fun little game animation for someone. I should go find that book to see what the author had to say about that.

In any case, there are now a cat running around my ZX81. Not a bad way to enjoy the evening.



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