Allow game writes to header region in dynamic memory
write_word() was routing all header writes through game_set_header() which enforced overly strict per-byte permissions. Zork 1 legitimately writes to header address 2 on startup. Now uses the same dynamic/static boundary check that viola does, matching the reference implementation.
This commit is contained in:
parent
e0e2e84dc2
commit
61765fa6ba
1 changed files with 4 additions and 9 deletions
|
|
@ -262,15 +262,10 @@ class ZMemory:
|
||||||
"""Write the given 16-bit value at ADDRESS, ADDRESS+1."""
|
"""Write the given 16-bit value at ADDRESS, ADDRESS+1."""
|
||||||
if address < 0 or address >= (self._total_size - 1):
|
if address < 0 or address >= (self._total_size - 1):
|
||||||
raise ZMemoryOutOfBounds
|
raise ZMemoryOutOfBounds
|
||||||
# Handle writing of a word to the game headers. If write_word is
|
|
||||||
# used for this, we assume that it's the game that is setting the
|
|
||||||
# header. The interpreter should use the specialized method.
|
|
||||||
value_msb = (value >> 8) & 0xFF
|
value_msb = (value >> 8) & 0xFF
|
||||||
value_lsb = value & 0xFF
|
value_lsb = value & 0xFF
|
||||||
if 0 <= address < 64:
|
self._check_static(address)
|
||||||
self.game_set_header(address, value_msb)
|
self._check_static(address + 1)
|
||||||
self.game_set_header(address + 1, value_lsb)
|
|
||||||
else:
|
|
||||||
self._memory[address] = value_msb
|
self._memory[address] = value_msb
|
||||||
self._memory[address + 1] = value_lsb
|
self._memory[address + 1] = value_lsb
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue