Monday 10 July 2017

Wizard's Castle

David Ahl was one of the giants of the earliest era of  personal computers in the late 1970s and 80s. He edited Creative Computing magazine and published several major type-in program books such as Basic Computer Games, which sold millions of copies.

I thought he was the author behind a game I had in my collection (VENTURE.C10) for the MC-10 called "Castle Adventure." The title screen mentions his name:
The instructions mention a "Wizard Bergal" and a "Orb of Zot."  I don't know where I got this piece of code. Its been in my collection for quite some time, and might have been one of the programs I had from tapes for my original MC-10 from the 1980s. Recently I came across some discussion on the Net for a "classic" Basic game called "The Wizard's Castle" by Joseph Power. The discussion mentioned the "orb of Zot," which triggered my memory of Venture. However, as I explored people's discussion of Power's game and its influence I began to realize that it was a very different program from the one I had. For example, in Power's game there are flares that can be used to shine light into all the cells immediately surrounding the one you are in. Also, you can buy a lamp, but it never runs out of oil. You can also choose other equipment (and can find better equipment in the dungeon). People commented about the simple but interesting D&D like character creation (Hobbits, Elves, Human, etc.) and equipping choices in Wizard's Castle. Such features, along with others that occur while you are exploring, were completely absent from Venture:
Clearly the program in my collection was not the classic program by Power. I had to lay my hands on the source code of the original and take a look. I went to my standby go to source for source, software repositories for the original TRS-80. I easily found references to Power's Wizard's Castle. Once I had the source roughly converted (including removing a modification that simply revealed all the locations) it was obvious that its 8X8X8 multi-dimensional array blew the lid off the memory requirements of a standard MC-10 with just the 16K RAM pack expansion. I would have to do some cutting or figure out a way to organize the info into a less memory demanding form than 5 byte floating point numbers for each array element. I began to suspect that the "Venture" program I had was a significantly simplified version of the game that made space for the massive numeric array by removing many of the minor, more quixotic features, of the original. Sadly, these features were what gave the program much of its charm. If I was going to preserve these features, I'd have to be creative.

I realized that each location in the array only needed to store an ASCII character representing the different items in each room, "B" for books, "C" for chests, etc. All I needed was to create a string space so each item could be stored as a single byte character poked into that space. As I read more about Power's efforts to create the program for the 16K Exidy Sourcerer computer he developed the game on, he'd had to do a similar thing. In fact, he used a memory space used for storing user definable characters. When someone had ported the program to TRS-80 they had simply removed this stuff and substituted simpler integer numeric array references. But the subroutines for doing all the fancy "poking" were all still there for me to re-engineer back into place a routine for poking the memory into a string space using VARPTR command (to find the appropriate locations in that space).

Eventually I got the program pared down (removing spaces, creating long multi-command lines, etc) to work in a standard 20K of the MC-10 with RAM pack. I even had enough space left over to create a simple "castle" graphic to wrap around the presentation of the grid map. The parring down also helped with the speed of set-up for the map layout, which was quite long.  Here are videos of the first version and the final product. Notice the difference in the length of time for setup: