As I tinker around more with the idea of Frotz running one command, saving, and then exiting, I keep coming across problems caused by the Z-machine being interrupted in ways not intended and then restored to an inconsistent state. To get around this, I’m trying to get a clearer picture of what’s actually in a Quetzal file and how to manipulate one to avoid these problems.
After I stepping away from the idea of calling
save_quetzal() at the end of a turn, I went back to injecting a
SAVE command into the input stream. This works for V3 games, but V5 and higher get corrupted. That shouldn’t be happening because as far as the Z-machine is concerned, it doesn’t know that the
SAVE command didn’t come from the player.
In a Quetzal file, there is the
IFhd chunk which contains the stored program counter, but I don’t understand where it’s supposed to point. I think it has something to do with the return value from the
@save instruction. Following that is the
UMem chunk (compressed or uncompressed). After making Frotz make a
UMem chunk, I figured out that this contains the dynamic memory of the Z-machine. Then comes the stack chunk:
Stks. I don’t understand this one at all. Why does it need to exist if stack data lives in dynamic memory?