# SPDX-License-Identifier: MIT """A Mega Drive with a Sega CD on its expansion port, built the one way every caller should build it: ``build(machine, bios)`` makes the device and plugs it in at power-on (``System(..., port=device)``, socket 2). ``cartridge``: what is in the slot -- nothing (boot from the CD), a :class:`~segacd_python.ramcart.RAMCartridge`, or a game cartridge (mode 1: the cartridge boots and finds the CD at $400000). With a 32X in the slot (milestone 8) the two add-ons share the console: the 32X holds no cartridge, so /CART is high and the CD boots; where both claim $000000-$3FFFFF the port wins (megadrive-python's ``Board.update_claims``). HYPOTHESIS: the 32X manual gives the vector ROM to $000000 in its own boot; how a CD on the port and a 32X in the slot share $000000 is not documented here, and is checked only by running both add-ons (the CD + 32X titles' films).""" from __future__ import annotations from megadrive_python.machine import MACHINES from megadrive_python.system import System from .disc import Disc from .megacd import MegaCD def build(machine: str, bios: bytes, cartridge: object | None = None, *, disc: Disc | None = None, backup_ram: bytes | None = None, slot: object | None = None) -> tuple[System, MegaCD]: # fmt: skip """``slot``: a device for the cartridge slot instead of ``cartridge`` -- a 32X (sega32x-python's ``Sega32X``, which holds its own cartridge or none). The caller attaches that device's own sockets (its video timing, picture and sound).""" device = MegaCD(bios, disc=disc, backup_ram=backup_ram) system = System( MACHINES[machine], cartridge, slot=slot, port=device, # type: ignore[arg-type] ) # fmt: skip system.audio_sources.extend(device.audio_sources) return system, device __all__ = ["build"]