# Restart rules This repository is a restart. The earlier `segacd-python` (local only, never pushed) was built from 2026-11-09 under the practice its Phase 0 brief set: "nothing copied from Genesis Plus GX, BlastEm, jgenesis, clownmdemu-core or MAME: read and cite, never copy". Its provenance audit (2026-11-13, family wave 1) found that the CD-ROM decoder was written with Genesis Plus GX's `cdc.c` open "as a detector for how the rules fit together", and that about twenty rules across the gate array, the memories, the drive, the graphics unit, the RAM cartridge and the port device were taken from Genesis Plus GX (non-commercial licence) or BlastEm (GPL-3.0) by name. The wave-2 rewrite (2026-11-19) also found that "every rule cites the mcd-verificator error that checks it" was done by reading mcd-verificator's C source, and that repository's `LICENSE` is GPL-3.0. Forbidden source was the working model across most of the board, so the rules (`emulator-lineage`'s wave-2 rewrite rules, "Choosing in place or restart") call for a restart rather than an in-place edit. The old repository is archived locally as `/data/backup/sega-restart/zzz-segacd-python` (never read again). It had no remote, so there is nothing to archive on GitHub. This one restarts from its last commit before the build began, `0dd43b1` ("Record the decided names"): the Phase 0 documents, the pins, the fetch script and the closed-box runners. Everything after that point is rebuilt under these rules. ## The rules 1. **No GPL, LGPL, MPL, non-commercial or unlicensed source is read.** Not to learn a mechanism, check a constant or settle a doubt. For this board that covers Genesis Plus GX and PicoDrive (non-commercial), BlastEm, jgenesis, the MiSTer core's HDL and KRIKzz's FPGA core (GPL), clownmdemu-core (AGPL), MAME's GPL files, and **mcd-verificator's source** (`src/*.c`, `*.s`; GPL-3.0 by its repository's `LICENSE`). Check `/data/emu/emulator-lineage/docs/sources.md` for anything else. The checkouts stay under `reference/src/` because the runners build from them: building is allowed, opening a source file is not. 2. **The archived repository is not read**, in any form: code, tests, documents, commit messages. The only things taken from it are listed under "Carried over" below. 3. **Translating a program statement by statement is copying**, whatever the language. Code is written from a written description of behaviour. 4. **Permitted sources** (cite page, section, revision): - Sega's Mega-CD Hardware Manual, PCM Sound Source manual, BIOS manual, Software Development Manual, technical bulletins, maintenance and service manuals; the Sanyo LC8951 and LC7883 data sheets; the CDRWIN CUE manual (`scripts/pinned_files.json`). [manual-registers.md](manual-registers.md) is this repository's own reading of the hardware manual's page images. - MAME's BSD-3-Clause files (check each file's first line): `src/mame/sega/megacd.cpp`, `megacd.h`, `src/mame/shared/megacdcd.cpp` (the CDC and drive), `rf5c68.cpp`, `cdrom.cpp`. Code taken from them keeps MAME's notice (`NOTICE`) and is an emulator fact (OBSERVED tier, named), not a hardware fact. - Permissive programs, readable with their notice: clownmdemu-mcd-boot (0BSD; a free boot program), clowncd (0BSD), sega-cd-asic-demo (Unlicense), md-mode1-mcd-asic-test (CC0), SegaCDMode1PCM, megadev, msu-md (MIT), libchdr (BSD-3), ares (ISC). - Hardware recordings, used as data: KRIKzz's drive logs (`mcd-verificator/cd-log/`) and the MiSTer repository's SignalTap screenshots of a real Mega-CD (`MegaCD_MiSTer/docs/mcd logs/`): pictures and logs, not code. - Community documents reporting hardware findings, prose only, cited: KRIKzz's notes (`mcd-verificator/notes/*.txt`), his readme, the pinned forum threads (Ti_'s speed test, t3166), jvisser's README results. Code fragments inside any document stay unread. - **Programs run as closed boxes** (results only): mcd-verificator's binary, as BIOS and in mode 1 (its rows and error numbers as printed on screen are its published results; what an error number checks is not looked up in its source), the 240p suite, megacdTest, the user's own BIOS and discs. - DarkMorford's BIOS disassembly is a derivative of Sega's firmware: interoperability facts only (the backup RAM format's marks), never shipped. 5. **An emulator may be run, never read.** Genesis Plus GX, BlastEm and PicoDrive are built and driven through `scripts/libretro_run.py`, MAME through `scripts/mame_cd.py`. A value got this way is tagged `OBSERVED` (emulator and pinned commit named); a document or hardware result that disagrees overrules it. 6. **A difference from a closed box is written down, not fixed**, unless a document or a hardware result independently says the board is wrong; then cite that. 7. **Every rule in the code names its source** with an evidence tag (MEASURED, TEST ROM, DOC, OBSERVED, FITTED, HYPOTHESIS). 8. **The middle rule, as the owner ruled it (2026-11-19).** A fact is usable when someone established it on real hardware and says so in prose; cite them. "Verified on hardware" must be accurate: an emulator's comment claiming verification is not a hardware fact. **There is no Sega CD hardware here**, so nothing in this board is `MEASURED` unless a cited hardware source (KRIKzz's logs, the SignalTap captures, a test program's published hardware results) says so; a mcd-verificator row passing is `TEST ROM` (its author ran it on a CDX and a Mega-CD 2). 9. **An author who objects to AI use of their work is left out**, even where the licence would allow it. ## Carried over (2026-11-19) Copied from the archive by the session that set up the restart; nothing else was: - The tools, at the archive's latest revision (audited clean, own work): the referee builds, the libretro and MAME runners, the fetch script and its pins, the drive-log replay (`scripts/`). - [manual-registers.md](manual-registers.md) (written from the manual's page images; "no emulator source was consulted"), with three references to Genesis Plus GX struck. - `disc.py` (the CUE/BIN reader, from the CDRWIN manual and Redump's layout), `console.py` (the build glue; a PicoDrive citation struck) and `__main__.py` (the command line), all audited clean. - `pyproject.toml` at the archive's pins. - From outside the repository (git-ignored, not content): the virtual environments, the fetched `reference/` tree, the user's BIOS images and disc images under `runs/`. Not carried: the board's hardware modules, their tests, the worklog, and the Phase 0 documents `start-here.md`, `timing.md` and `undocumented-behavior.md`, which describe other emulators' code paths throughout (they stay in this repository's history at `0dd43b1` for the record and are not to be read for the rebuild). The remaining Phase 0 documents (`handoff-brief.md`, `sockets.md`, `validation.md`, `mame-oracle.md`, the READMEs) are scrubbed before any code is written: every statement that rests on reading another implementation's source is struck or re-sourced. ## The archived board's results, as targets only Numbers only, so the rebuild can be compared; none of the archived board's code or reasoning comes with them. 36 unit tests; mcd-verificator v1.02 as BIOS: every row OK but REG 2006 (error 02, a stated choice); as a cartridge in mode 1 under a real BIOS: every row OK; Sonic CD (USA) playable into its first zone; with sega32x-python in the slot the six CD + 32X titles each played their first film. ## Dependencies to follow `megadrive-python@5c6d1b7` pins the archived Nuked-derived sound cores (`ym2612-python@2c2ab23`, `sn76489-python@b0acbc8`). The board must be repinned to a megadrive-python revision on the restarted cores (branch `pin-2-od2` from `41f92f2` on) once that repository's own wave-2 rewrite lands. ## Scrub record (2026-11-19) The six carried-over Phase 0 documents were read and scrubbed; no source file of a forbidden program was opened to do it. Re-sourcing used [manual-registers.md](manual-registers.md) (Sega's hardware manual), MAME's BSD-3 Sega CD files (their first lines checked: `megacd.cpp`, `megacdcd.cpp`, `rf5c68.cpp`, `cdrom.cpp`, `chd.cpp`) and Motorola's 68000 timing tables. Each document now starts with an SPDX line. - **sockets.md** (most affected). Struck about 20 citations of Genesis Plus GX and BlastEm source (file names, line ranges, function names), including 13 quoted source comments, and the pointer to the Phase 0 emulator trees. Re-sourced 9 points to the manual: the mode 1 / mode 2 swap of `$000000` and `$400000` (p.5), level 2 as main-to-sub (p.56), the word-RAM DMA one-cycle delay and its +2 remedy (p.61), the Z80 prohibition (p.62), the sub CPU hanging on word RAM it does not own (p.24), the power-on / other-reset distinction (p.27), the 12.5 MHz and 50 MHz clocks (p.1, p.iv), the LC7883 filter (p.iv), the HINT vector (p.58); DIVS's 158-clock worst case to Motorola. Became open items: the register mirror to `$A120FF`, what an unowned read returns, what the reset button does to the CD (grade changed from "wrong" to "refine"), what the first word of a word-RAM DMA receives (the two emulators' differing behaviour is struck), what a Z80 access to CD space does, whether a hand-over releases a hung sub CPU, whether level-2 acknowledge clears IFL2. The drive's 16.9344 MHz clock became a HYPOTHESIS. The port-clock argument now rests on reasoning about shared-register polls instead of the games and tests an emulator's comments named. The MAME `megacd.cpp` citation (BSD-3) stayed. - **handoff-brief.md**. Replaced the "read and cite, never copy" constraint with a pointer to these rules; added a preamble saying so. Struck the list of games named in an emulator's comments (milestone 3) and the "decide GPGX vs BlastEm" framing (re-sourced to the manual's p.61); replaced the "GPGX only" citation kind with `OBSERVED` from a closed-box run; added the write-down-not-fix rule to the working agreement. The three deleted documents (`start-here.md`, `timing.md`, `undocumented-behavior.md`) are now marked as to be rewritten from permitted sources, with manual-registers.md as the reference meanwhile (4 places). Open decision 5 corrected: mcd-verificator's source is GPL-3.0, run only. Milestones, decisions and the owner's rulings kept as they were. - **validation.md**. Corrected the mcd-verificator row (GPL-3.0, not "No licence"; source never opened) and dropped "Genesis Plus GX cites it ... as verified on real hardware". Struck three emulator notes that came from reading or could not be told apart from reading (GPGX "the most hardware-cited", BlastEm's "CDD MCU model on the drive's clock", PicoDrive "partly from GPGX"); added a use column (closed box / readable) to the emulator table; tagged the mcd-verificator results as closed-box `OBSERVED`; noted that the t=3020 posts' and KRIKzz's notes' code fragments stay unread, that DarkMorford's disassembly gives interoperability facts only, and the BSD-3 status of libchdr and MAME's CHD files; pointed the disagreement record away from the deleted quirks document. Hardware rows, specification rows and run results unchanged. - **mame-oracle.md**. Recorded that the three MAME Sega CD files are BSD-3 (readable, OBSERVED tier) and the GPL files are not opened; tagged the driver facts; replaced two machine paths in the example command with `$MAME_ROMPATH` and a placeholder. Nothing struck. - **docs/README.md**. Five gathering findings re-sourced from emulator source to the manual (level 2, the slot's range, the DMA delay, reset, `/DTACK`) or to reasoning (the port clock); one quoted source comment struck; the document table updated (restart.md and manual-registers.md in, the three deleted documents out, marked to be rewritten); mcd-verificator noted as GPL-3.0, run only. - **README.md**. Status updated to the restart; reading list updated as above; the licence paragraph's "read and cited, never copied" replaced by the closed-box rule. Nothing else rested on reading source.