def find_cmd0(cmd_stream, cmd) -> int:
    """Returns parameter of the first command in the stream that matches the given command"""
    for command in cmd_stream:
        if (command & 0xFFFF) == cmd.value:
            return (command >> 16) & 0xFFFF
    assert False, f"Not in command stream: {cmd}"