Implement extended opcode decoder for V5+
The 0xBE prefix byte triggers extended opcode parsing. Reads the opcode number from the next byte, then parses operand types using the same format as VAR opcodes. Required for all V5+ games.
This commit is contained in:
parent
11d939a70f
commit
e61dcc3ac4
1 changed files with 11 additions and 2 deletions
|
|
@ -70,7 +70,7 @@ class ZOpDecoder:
|
||||||
log(f"Decode opcode {opcode:x}")
|
log(f"Decode opcode {opcode:x}")
|
||||||
|
|
||||||
# Determine the opcode type, and hand off further parsing.
|
# Determine the opcode type, and hand off further parsing.
|
||||||
if self._memory.version == 5 and opcode == 0xBE:
|
if self._memory.version >= 5 and opcode == 0xBE:
|
||||||
# Extended opcode
|
# Extended opcode
|
||||||
return self._parse_opcode_extended()
|
return self._parse_opcode_extended()
|
||||||
|
|
||||||
|
|
@ -134,7 +134,16 @@ class ZOpDecoder:
|
||||||
|
|
||||||
def _parse_opcode_extended(self):
|
def _parse_opcode_extended(self):
|
||||||
"""Parse an extended opcode (v5+ feature)."""
|
"""Parse an extended opcode (v5+ feature)."""
|
||||||
raise NotImplementedError("Extended opcodes (v5+) not yet implemented")
|
log("Opcode is extended")
|
||||||
|
|
||||||
|
# Read the extended opcode number
|
||||||
|
opcode_num = self._get_pc()
|
||||||
|
log(f"Extended opcode number: {opcode_num:x}")
|
||||||
|
|
||||||
|
# Parse the operand types byte and retrieve operands
|
||||||
|
operands = self._parse_operands_byte()
|
||||||
|
|
||||||
|
return (OPCODE_EXT, opcode_num, operands)
|
||||||
|
|
||||||
def _parse_operand(self, operand_type):
|
def _parse_operand(self, operand_type):
|
||||||
"""Read and return an operand of the given type.
|
"""Read and return an operand of the given type.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue