GOOD COMPUTER: Z-machine
GOOD COMPUTER continues!
I got bored with BASIC, and I’m waiting for parts to arrive, so I started something new: a Z-machine implementation, in AVR assembly, so we can play Zork!
my typical workspace layout for this stuff, if you’re interested. code and test setup on one, data inspection and other fiddling on another, and CPU docs on another. it’s not complicated
enough stuff in place to get initialisation and opening description on screen and ready for input. there’s A LOT under here. next up, the input handler and tokeniser, which seems like it should be massively complicated, but might end up being quite easy 🤷♂️
turns out it was massively complicated, at around 250 instructions. then a day of bug squashing, and there’s actually quite a lot of game running behind the scenes, though you can’t see it yet. next up is object tree management, so we can actually manipulate the environment
I’m not kidding about “a day of bug squashing”. not helped by the various bits of z-machine docs around the place being incomplete or misleading. eventually, in despair, I added instrumentation to a bunch of ops in my code and in frotz and compared their output. bit cheaty but eh
object management (mostly the INSERT_OBJ instruction) now in place, and we can actually sorta play the game! the remaining unimplemented instructions are all in fairly specific game situations, which is gonna make testing a bit awkward, but its nice to make it this far!
fair play to the troll, creative way to take me down
random number generator probably works, infinite lives cheat not so much
(unimplemented here is DEC, which I guess is trying to reduce my hitpoints)
this troll will not take no for an answer
(my guess at this late hour is that objects aren’t being properly removed from their parent, so after death the troll remains in the room, and so the room update function allows it to continue to bludgeon me)
originally posted on twitter at: https://twitter.com/robn/status/1274932574771490816