Z-machine: changing undo message only at game's end?

There’s nothing like Glulx’s ability to protect memory locations on the Z-machine.

Only two bits (two bits that are declared legal for the running game to modify, that is) survive the memory reset of an undo operation: The first controls whether or not transcripting is on, the second whether or not fixed-width pitch is on. Setting of either bit by the story triggers a change in state in the interpreter, such that it will either ask how to handle transcript output (with a file prompt window, usually) or it will start printing in fixed-width font.

If you’re not using fixed-width font in your game, you can use that bit as the carrier of a signal, at the cost of modifying text output while the bit is set. (If you’re always using fixed width font, then I suppose clearing that bit can be used as a signal, too.)

The theoretically better alternative would be to use an external file to save state and restore from it, as specified in ZMS 1.1. However, most Z-machine interpreters don’t respect a request to save without a file prompt (see Which interpreters comply with ZMS 1.1 regarding prompt parameter of @save/@restore opcodes?), though WinFrotz and the latest version of Bocfel do.

2 Likes