I’m working on a Z-Machine interpreter/debugger, and was wondering if when writing to a location in memory, does the address need to be properly aligned if it is a standard location? For example, if the game or interpreter tries to write a byte at address 0x23 (screen width in units + 1), would this fail?
For that specific byte, it’s illegal for the game to write to it. Some interpreters will consider it an error; others will silently ignore it. (When a header byte is not writable by the game, that’s mostly an assurance that the interpreter can cache the value and not worry about it changing unexpectedly. Header bytes that can be written by the game need to be more closely monitored.)
In general, though, there’s nothing wrong with reading or writing bytes anywhere you want. Z-machine memory is generally treated as a huge array of bytes, and you can read and write any of those bytes with wanton abandon, even if they’re (e.g.) in the middle of the object hierarchy data, or the Unicode translation table.
1 Like