Sunday 11 September 2022

Tut-Tut for the Commodore PET

This is one of those occasions where I go to find a link for someone to an old blog post, there isn't one. This one I wrote for Patreon, but had not moved it over to the blog, so now I have.

The PET remake of 3D Monster Maze seemed to have gone well (although it hadn't been released yet), so I thought I would have a go at another favourite game.

Tut-Tut started life as a type in BASIC program for the ZX Spectrum, by David Stephenson, published in Paleotronic magazine in November 2019.

This version has most of the features, but being written in BASIC is a bit slower compared to later versions, particularly when drawing the screen.

This was then expanded by David to a full ZX81 game, released on tape by Cronosoft.

This did well to make use of the ZX81 character set, and added more levels to the mix. It ran much faster as it had been written in C.

This was followed by a fuller Spectrum version. This time in a complied version of Spectrum BASIC. This added sound and joystick support and more levels.

Next came a version for the Jupiter Ace / Minstrel 4th, but not this time by David Stephenson, but by George Beckett. This was written in Forth (as is customary on the Ace), and was the first (and so far only) commercial game released for the Minstrel 4th.

So, it's a great game and seems suited to the type of machine I like to work on. The PET version couldn't use user define graphics like the Ace and Spectrum versions, but it did have (almost) all of the characters used on the ZX81.

Not as problematic as the missing half black half grey tiles that let to the remapping of the screen on 3D Monster Maze, but just the lack of a £ symbol.

It's an odd thing because there is no £ symbol on the PET, even the later 80 column business version with a different keyboard did not get a £ sign. Seems a bit lacking for a dedicated business machine. And yet the low end games machine that followed a few years later, the VIC 20, not only had a £ sign (replacing the \ on the PET), but it had a dedicated key for it. You had to press shift + 4 for a $ sign, but £ had it's own key. Never understood why.

The PET did have some extra characters, including playing card symbols. The clubs symbol (♣) seemed a good choice for the Ankh amulet, so I used that.

Behind the scenes, the code required some work to compile for the 6502. It had been written in C and used lots of 16 bit integers and arrays of arrays of structures. This was all a bit much for the poor 6502 with no 16 bit registers and no 16 bit commands, so I rewrote a lot of that code to use 8 bit bytes and simplified the memory structures to result in less pointer arithmetic.

Even though the PET's 6502 running at 1Mhz is less than one third of the 3.25MHz Z80 in the ZX81, it sort of balances out as many of the Z80 instructions require quite a lot of cycles where the 6502 most are one or two.

Even after all that, like most games of this type, most of the time is actually spent it loops waiting to redraw the screen or for the player to move.

Movement was a bit of an issue as I originally used the cgetch() routines in the gcc complier to read the keyboard. These do not support key repeat, so there was a lot of keypresses to move from one side of the screen to the other. I ended up writing a new keyboard scanning routine, so you could move by holding the key down as you would expect.

The PET screen is 40 characters wide, the ZX81 32 characters, and the Tut-Tut levels 24 characters. I wanted to maintain the level data from the ZX81 version, I could have adapted it, but I didn't want to risk breaking some of the later levels that I didn't actually know how to complete.

The easiest option was the one I chose, padding the screen with four blank characters at each side and otherwise following the ZX81 screen layout. That led to a few interesting issues such as the starting positions of the player and the mummies which is calculated as the offset in the ZX81 display file from the top left character in the playfield. The ZX81 display file includes a newline character at the end of each line, so it is 32 characters + newline for each line, 33 bytes per line. I had to convert that to a position in the PET display which is 40 characters per line, with no newline character.

The 33 bytes per line issues also affected the animated player and mummy graphics as the characters used were alternated based on the low bit of the horizontal position when moving left and right, so they alternated as the player moved along the line. Vertically, this also alternated with 33 characters per line, but with 40 characters per line, it was always the same, so an artificial wiggle needed to be added when moving up or down.

I took a few features from the fuller Spectrum implementation, including sound and the  pause feature (I was particularly proud of the pause graphics for some reason). The sound was written for the Spectrum using it's BEEP routine to play a tune which was almost, but not quite, entirely unlike "Walk like an Egyptian" by the Bangles.

In order to play the tune, I did a lot of research into the musical abilities of the PET. I didn't find much, so I worked it out and wrote it up here:

The game was starting to come together. Time to add the title screen

I kept the credits on the title screen, which included a nod to Rod Bell (Villordsutch). I couldn't resist adding a similar line for The Future Was 8 bit's Rod Hull.

That seemed a little unfair, so I added a little animation of a Mummy correcting that.

So that is Tut-Tut for the Commodore PET, available on tape from The Future Was 8 bit (cover artwork by David Stephenson)

And also as a digital download from my page:

There is a review here with links to all of the other versions on download and cassette.

Here are the four cassette versions.

And to complete the collection, my PET remake of 3D Monster Maze alongside the two earlier release.


A reminder that there is a specially updated version of Tut-Tut built into the Minstrel 4D.

The Minstrel 4D is available for preorder from The Future Was 8 bit


You can support me via Patreon, and get access to advance previews of posts like this and behind the scenes updates. This now also includes access to my new Patreon only Discord server for even more regular updates.