So, back in, what was in, 2015, I proposed a couple of new Glulx opcodes to make UNDO handling just a little bit cleaner.
The opcodes look like this:
Test whether a VM state is available in temporary storage. S1 is set to 0 if a state is available, 1 if not. If this returns 0, then
@restoreundois expected to succeed.
Discard a VM state (the most recently saved) from temporary storage. If none is available, this does nothing.
The simplest way to make use of this would be to add a
@discardundo opcode to the “I didn’t recognize that command” parser error. Then muffed command inputs wouldn’t take up an UNDO slot.
(You’d do a
@gestalt feature test before calling the opcode, so it wouldn’t crash on older interpreters. They just wouldn’t get the benefit. They’d behave the way all games do today, where unrecognized verbs do take an UNDO slot.)
You could do this for other parser errors as well. Although this might start to cause problems for games that convert parser errors into real game actions. (Some games certainly do this.)
You could go deeper with this – make UNDO less of a hack in the whole parser loop. But I’d definitely want to start with a conservative change.
Anyhow, the first step is to get the opcodes into interpreters (and the I6 compiler). It turns out I did the implementation back in 2015, and then… um… never got around to pushing it out? I really can’t remember what the stumbling block was.
If you remember – too late! I’ve already merged the change into the Glulxe and Quixe interpreter source. And posted pull requests for Inform 6 and the Git interpreter.
Once those are in circulation, I’ll figure out an I7 parser patch (the “didn’t recognize that command” change).