Decoded: The Wizard's Castle

My first exposure to RPG games (and *roguelikes) came with my first home PC (used) in the mid-1980s. The Wizard's Castle was on one of the disks in the box along with the GW-BASIC interpreter. Good times ensued! Between getting books magically stuck to my weapons, and turning myself in to a hobbit before being eaten by a Balrog, I probably logged several hundred games. Eventually, a clone of the same game came along called Leygref's Castle, which was a native DOS program and had a better looking map. I did manage to finish the game many times, but never with all the treasures.

A few days ago (in 2017), I found an original BASIC code release and gave it a shot in QBasic -- It worked without changes! I did not manage to escape the castle with the Orb of Zot this time around. I'll be back...

This source code walkthrough is my homage to the hours wasted.
(Original Source) (Code Walkthrough) (Variable List)


The level of programming in this project would be absolute beginner...if it wasn't 40 years old! It's still definitely beginner with a healthy side of bit rot. BASIC has its foibles. It lacks many simple features found in programming languages, such as pointers, prefix/postfix operators, and this variant of BASIC doesn't support SWITCH/SELECT CASE or subroutines. This means a lot of spaghetti code no-nos like GOTO. I'll point out the usual things along the way.

Due to source code size constraints back in 1980, the variable names are one or two letters. I've included a variable list for easy cross-reference

Enjoy the read!

If you want to know more about the game itself (not how it works), here is a serious review of The Wizard's Castle.

*Is this game considered a Roguelike since it pre-dates Rogue?

A handy procedure map of the Wizard's Castle BASIC code