# SPDX-License-Identifier: MIT """Shared fixtures: the BYOR program images, read in place from MAME's device sets. The sets are found on ``MAME_ROMPATH`` (one or more folders separated by ``;``, as MAME's ``-rompath``); tests that need an image skip when the variable or the set is absent. Nothing is copied or committed. """ from __future__ import annotations from pathlib import Path import pytest from upd7725_python import load_image from upd7725_python.rompath import find_set, rompath_dirs #: True when ``MAME_ROMPATH`` names at least one existing folder. HAVE_ROMPATH = any(folder.is_dir() for folder in rompath_dirs()) # program name -> (MAME device set, chip) PROGRAMS = { "dsp1": ("sns_dsp1leg", "upd7725"), "dsp1b": ("sns_dsp1bleg", "upd7725"), "dsp2": ("sns_dsp2leg", "upd7725"), "dsp3": ("sns_dsp3leg", "upd7725"), "dsp4": ("sns_dsp4leg", "upd7725"), "st010": ("sns_seta10leg", "upd96050"), "st011": ("sns_seta11leg", "upd96050"), } def image_path(name: str) -> Path | None: """The device set holding program ``name`` on ``MAME_ROMPATH``, or ``None``.""" return find_set(PROGRAMS[name][0]) def require_image(name: str) -> tuple[list[int], list[int]]: path = image_path(name) if path is None: pytest.skip(f"BYOR: {PROGRAMS[name][0]}.zip is not on MAME_ROMPATH") return load_image(path)