Add a HEADER opcode that emits the 7-byte video header, used to

select the playback mode (HGR/DHGR).
This commit is contained in:
kris 2019-04-25 16:26:38 +01:00
parent 6bde085d5e
commit 2a76e3d48f

View File

@ -11,6 +11,7 @@ def _op_cmds():
"""Construct names of player opcodes."""
op_cmds = [
"HEADER",
"TERMINATE",
"NOP",
"ACK",
@ -45,7 +46,7 @@ class Opcode:
@staticmethod
def emit_command(opcode: "Opcode") -> Iterator[int]:
# Emit address of next opcode
# Emit address of opcode
yield opcode._START >> 8
yield opcode._START & 0xff
@ -56,6 +57,35 @@ class Opcode:
pass
class Header(Opcode):
"""Video header opcode."""
COMMAND = OpcodeCommand.HEADER
def __init__(self, mode: "video.Mode"):
self.video_mode = mode
def __data_eq__(self, other):
return self.video_mode == other.video_mode
@staticmethod
def emit_command(opcode: "Opcode") -> Iterator[int]:
# This is special in that it does not explicitly vector to the next
# opcode
return
def emit_data(self) -> Iterator[int]:
# Pad bytes to same size as Tick opcode, to make it easier to schedule
# ACK opcodes.
yield 0xff
yield 0xff
yield 0xff
yield 0xff
yield 0xff
yield 0xff
yield self.video_mode.value
class Nop(Opcode):
"""NOP pad opcode that does nothing except vector to the next one."""
COMMAND = OpcodeCommand.NOP
@ -158,6 +188,7 @@ def _fill_opcode_addresses():
_OPCODE_ADDRS = _parse_symbol_table()
_OPCODE_CLASSES = {
OpcodeCommand.HEADER: Header,
OpcodeCommand.TERMINATE: Terminate,
OpcodeCommand.NOP: Nop,
OpcodeCommand.ACK: Ack,