DrupalZM – Save and Restore

Things have been a bit hectic lately – with the massive cooking and cleanup of Thanksgiving, and preparing for the TPUG WoC expo (and driving to and from Toronto to get there), I haven’t had a ton of time to do much coding. I did manage to slip in a couple hours last night and finished up the save/restore code.

It was actually pretty easy – what’s nice about DrupalZM is since it’s being driven from the web, it needs to save the state of the z-machine to the DB every page refresh. The save/restore code simply copies the current state of the machine to a save slot. Specifically, the table that stores the state of the zmachine now has a “slot” field associated with each record. Slot 0 indicates the current state, while slots 1-9 are saved games. Anytime a game is saved, DrupalZM simply copies the record in slot 0 to the desired slot, and restoring does vice versa.

I’m implementing a simple block to allow for easy saving/restoring. Classically one would type “save” or “restore” during gameplay, but typing these commands out in DrupalZM instructs the player to use the functionality in the block. The block will make saving/restoring much faster, plus an added bonus is the screen buffer is completely stored during the save process, so when a user restores a game, it shows them all the text on their screen exactly how it was at the time of saving.

To Do

Most of the zmachine is functional for versions 1-3 of zcode, but the following is still left to do (not necessarily in order of how I’ll tackle it):

1. Debug current issues (picking up “all” items seems to fail, zcharacter->ascii translator is still missing small bits of functionality, out of the 3 games I’ve tried, 2 work but 1 gets caught in an endless loop processing upon issuing the first command)
2. Finish all opcodes for versions 4-8 of the zmachine
3. Implement an AJAX interface
4. Finish the save/restore block
5. Implement room location/moves status bar (as well as exporting this with scores to be used elsewhere on site (e.g. location of currently logged in users, high scores per game, etc)
6. Experiment with extra functionality (quasi-multiplayer, automapping, integrating zmachine objects with drupal nodes/fields)

Leave a Reply

Your email address will not be published.