DaveTCode / zmachine-golang

A Z-Machine interpreter written in golang specifically to learn a little about golang and because it's fun
MIT License
0 stars 0 forks source link

Memory corruption issue means can't open pocket of dressing gown in HHGTG #18

Closed DaveTCode closed 2 weeks ago

DaveTCode commented 2 weeks ago

HHG lets me run the first few commands but then the opcode at 0x6c27 gets overwritten by something. The actual operation doing the overwriting is an ADD L02, #01 -> (-SP) at line 0x6c98 but haven't yet walked back to find out what put the dodgy address in the stack pointer

DaveTCode commented 2 weeks ago

The function at 0x6c8b should only be called once but is getting called multiple times after opening the pocket for some reason

DaveTCode commented 2 weeks ago

Looks like the object graph has got into an exciting state where the gown is a sibling of itself somehow!

DaveTCode commented 2 weeks ago

Looks like if you move an object from it's current parent to the same parent again then this causes a sibling loop. wearing the gown moves the object from "it" to "it"

DaveTCode commented 2 weeks ago

Resolved by simply exiting early when attempting to move an object from A -> A as noop rather than tweaking the algorithm