Tuesday 6 August 2013

Adventure by Program Power - 4: A Few Fixes & Enhancements

Analyzing the Program Code

Athough the program can be listed quite readily, it still presented a bit of a challenge to dissect as it is written in a heavily obfuscated manner - probably to save memory rather than being intentional - with liberal use of GOTOs, global variables, variables in place of line number destinations and so on. The main program is written in BASIC, with text, location exits and other status information being stored and looked up separately in memory.

Below is a list of minor fixes / enhancements made to the program. The main motivation was to improve the display of the text and to make the game winnable by giving some feedback to the player once the princess is rescued.

Enhancement 1: Fix Loader for BBC Version

The first problem was that the BBC disk image I found online did not work "as is" when run from disk. I was able to get this working using a technique similar to that used in the Electron version, which involved adjusting the loader program to run at a more suitable memory location and tacking on a short assembly language routine to the end of the main program which switches to *TAPE mode (to avoid overwriting game data that is loaded into an area of memory that can be corrupted), sets PAGE appropriately and then runs the program.

Enhancement 2: Fix for Word Wrapping

The game is happy to let words in the location descriptions & other messages break across the end of a line. This was easily remedied by adding a check for the cursor location before printing the next word, and moving down a line if needed.

Enhancement 3: Mixed Case

The game stores all its text in memory in capital letters, and looks up the appropriate word or phrase to print. While printing all in capitals simplifies the program code, it is much easier for the player to have mixed case.

It turned out not to be too complicated to add support for mixed case by adjusting the message printing routine to add the following logic rules:
(1) The first word of every sentence should start with a capital letter.
(2) If a full stop, exclamation mark or colon is found then start the next word with a capital letter.
(3) Otherwise print in lower case.

Original text display: words are all-caps and break across lines

Easier to read: word wrapping and mixed case

Enhancement 4: Adjust Check for Dropping the Princess

One puzzle/frustration in the game is that the princess will "run off into the dark" if she is dropped in any location, whereupon she is moved back to the white tower. However the game does not differentiate between locations, leading to the bizarre situation of her running back into the caverns (presumably through the closed cavern entrance) even if dropped outside at the Left Luggage Office!

To remedy this I added a small check so that she only runs off if the location is a dark one (i.e. one that requires your lamp to be lit). This feels more in keeping with the intention of the message. This means that she can be dropped without running off once you are outside the caverns, or in a location that is not considered to be dark.

Enhancement 5: More Informative SCORE

The player's score is linked both to the number of turns taken (which decreases the score) and the number of treasures found (which increases the score). To help track their contribution to the score, and to provide some feedback on progress with the treasure hunt, SCORE now shows the number of turns taken and the number of treasures found so far.
Extended SCORE information: turns & treasures found

Enhancement 6: Making the Game Winnable

Finally, the original game logic does not contain any logic to check if the player has succeeded in bringing back the Princess, leaving the player feeling unsatisfied. After considering what would be an appropriate condition for winning, I enhanced the logic to print a successful end-of-game message on DROPping the princess in the Left Luggage Office (to be consistent with the location where you drop the treasures).

No comments:

Post a Comment