src/app/gpu/gpu_renderer.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles
// Polygon edge setup adapts runtime/raster.cpp's pinned MAME poly.h port.

src/app/gpu/m2.hlsl
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles
// Raster texture shading and optional polygon interpolation adapt the pinned
// MAME port in runtime/raster.cpp; see THIRD_PARTY.md.
// Shaders for the hardware (SDL_GPU) renderer: one source for every backend.
// scripts/build_shaders.py compiles it with DXC to SPIR-V (Vulkan) and DXIL
// (Direct3D 12), and SPIRV-Cross turns the SPIR-V into MSL (Metal); the result
// is src/app/gpu/shaders_gen.h. Resource spaces follow SDL_GPU: vertex
// uniforms space1; fragment textures and samplers space2.

src/app/gpu/model2_frame.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles
// Polygon edge setup adapts runtime/raster.cpp's pinned MAME poly.h port.

src/i960/timing.cpp
// license:BSD-3-Clause
// copyright-holders:Farfetch'd, R. Belmont
// Fixed m_icount deductions adapted from MAME src/devices/cpu/i960/i960.cpp
// commit dddd73680656e355bb2b5beecab1167c9f07bf81, SHA256
// f7d887add0cb070f91f585b22f3b35acc4fc94ab5c94a527eab5205ee9440fdd.
// Device framework/semantics removed; deductions become compiler metadata.
// Source describes remr as 67..75878 real cycles but deducts fixed 67;
// expr deducts 334 ('checkme'). Preserve these reference limitations.

src/i960/timing.h
// license:BSD-3-Clause
// copyright-holders:Farfetch'd, R. Belmont
// Compiler-side cycle accounting from pinned MAME's i960 executor.

src/m68k/timing.cpp
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
// Derived and differentially checked against MAME's generated M68000
// microcode at dddd73680656e355bb2b5beecab1167c9f07bf81, not its separate
// Musashi backend. m68000gen.py charges four cycles per bus completion and
// two per internal nanocode step. The generator resolves addressing modes;
// native code supplies branch, shift, bit-number and multiply decisions.

src/refcore/i960_ref.cpp
// license:BSD-3-Clause
// copyright-holders:Farfetch'd, R. Belmont
//
// TEST ORACLE ONLY. Never linked into the game.
//
// MAME's i960 instruction interpreter, transplanted from
// src/devices/cpu/i960/i960.cpp at dddd73680656e355bb2b5beecab1167c9f07bf81
// (BSD-3-Clause; notice above kept as the licence requires), over the
// runtime's Cpu context. m2replay runs the game through it to check the
// runtime and the replay against MAME independently of the recompiler.
// Changes: device framework and burst-stall machinery removed. Original
// opcode cycle deductions feed both m_icount (independent table metric) and
// Cpu::reference_cycles in their original positions. See THIRD_PARTY.md.

src/runtime/comm_board.cpp
// license:BSD-3-Clause
// copyright-holders:Ariane Fugmann
//
// MAME's m2comm_device (M2COMM_SIMULATION), transplanted: see comm_board.h.
// Changes: the sockets are a non-blocking LinkTransport, so read_frame keeps
// partial frames until whole instead of waiting; the frame-sync wait gives up
// after kSyncTimeout (MAME waits forever); messages through osd_printf_verbose
// are dropped.

src/runtime/comm_board.h
// license:BSD-3-Clause
// copyright-holders:Ariane Fugmann
//
// The Model 2 communication board (837-10537 on Daytona USA Revision A):
// link play between cabinets. Transplanted from MAME's m2comm device in its
// M2COMM_SIMULATION mode (src/mame/sega/m2comm.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81; BSD-3-Clause, notice above kept
// as the licence requires; see THIRD_PARTY.md): the board's Z80 program
// (EPR-16726) is not run; the protocol it carries is.
//
// Cabinets form a ring: each sends to the next and receives from the one
// before. At start the master (set in the game's test mode: LINK ID) sends a
// numbering token round the ring, so every cabinet learns its id and the
// count; then every frame each one passes its block of race data on, and the
// master sends a vsync token. The shared RAM is the game's (M2Board maps it
// at 0x01a00000); the bytes travel through a LinkTransport the host provides
// (TCP in the app), which never blocks. Without a transport the board is not
// here at all: M2Board keeps its plain registers and the game sees no link.

src/runtime/cpu.cpp
// license:BSD-3-Clause
// copyright-holders:Farfetch'd, R. Belmont
//
// The i960 context and the services recompiled code calls: memory access,
// call/return with MAME's 4-frame register cache, interrupt entry, IAC.
// Transplanted from MAME's src/devices/cpu/i960/i960.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81 (BSD-3-Clause; notice above kept
// as the licence requires). Changes: the device framework is removed;
// call/return deductions feed the monotonic reference cycle counter, memory
// goes through Cpu::bus, fatalerror/logerror map to the runtime. There is no instruction interpreter here: game code
// is statically recompiled. See THIRD_PARTY.md.

src/runtime/geo.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
//
// Model 2 geometrizer (HLE) and rasterizer front end, transplanted from
// MAME's src/mame/sega/model2_v.cpp at dddd73680656e355bb2b5beecab1167c9f07bf81
// (BSD-3-Clause; notice above kept as the licence requires). The code below
// is MAME's with these changes only: raw pointers are bounds-checked cursors
// (GeoPtr, GeoPtr16); kept polygons go to a flat list (Geo::polys) instead of
// MAME's per-z buckets; logerror is dropped and fatalerror throws. See
// src/runtime/geo.h and THIRD_PARTY.md.

src/runtime/geo.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
//
// Model 2 geometrizer and the rasterizer's front end (culling, clipping,
// z-sort keys): the display list, as native C++. The original Model 2's
// geometrizer runs code from ROM inside its DSP that nobody has dumped, so
// this is MAME's high-level implementation (src/mame/sega/model2_v.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81, BSD-3-Clause; notice above kept
// as the licence requires), transplanted: geo_parse and its commands,
// model2_3d_push, model2_3d_process_polygon. Memory is read through
// bounds-checked cursors, so a display list that runs off its buffer is a
// hard error instead of MAME's undefined behaviour. See THIRD_PARTY.md.

src/runtime/m2_board.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese
//
// The Model 2 board as native runtime (see m2_board.h). Register semantics
// follow MAME's src/mame/sega/model2.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81 (BSD-3-Clause; notice above kept):
// irq_request_r/irq_ack_w/irq_enable_w/irq_update, timers_w, videoctl_r/w,
// render_mode_r/w, tgpid_r, the model2o memory map. The I/O board's mailbox
// protocol was read from the game's own traffic (see IoBoard). See
// THIRD_PARTY.md.

src/runtime/m2_tgp_board.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese
//
// Model 2 geometry ports as the i960 sees them, transplanted from MAME's
// src/mame/sega/model2.cpp (copro_ctl1_w, copro_function_port_w,
// copro_fifo_r/w, geo_r/w, geo_prg_w, geo_ctl1_w, push_geo_data,
// copro_tgp_memory_r/w) at dddd73680656e355bb2b5beecab1167c9f07bf81
// (BSD-3-Clause; notice above kept as the licence requires). MAME's device
// FIFOs, halts and stalls are replaced by running the recompiled TGP on
// demand. See THIRD_PARTY.md.

src/runtime/model2_eeprom.cpp
// license:BSD-3-Clause
// copyright-holders:Aaron Giles and contributors
//
// Adapted from MAME src/devices/machine/{eeprom,eepromser}.{cpp,h}, pinned at
// dddd73680656e355bb2b5beecab1167c9f07bf81 (https://github.com/mamedev/mame).
// Source SHA-256:
// eepromser.cpp 51431fe4a70163b0bf56a30bbb293c0ba8872e7cd6fe051a6bdf2e17f8824caa
// eepromser.h   0877cdad4d2e8c300386d2dce1737c51210c40d94115837c00482b628a7adf74
// eeprom.cpp    e28f650aa8eda8c54897ae08047092bab3053f4dd84c66c72d6711a950423ef6
// eeprom.h      415e84a2e995904615f4c7532c6b73664a4e513832c0bdbde1844af8ef8887fb
//
// Reference limitations deliberately retained: a write/erase changes cells and
// starts its busy interval at the final command/data clock, not at CS falling;
// WRAL programs existing_word & data and thus requires ERAL to restore ones.
// DO is ready/busy only after CS is reasserted. Non-streaming reads reproduce
// the reference's 32-bit output shift register even when overclocked.
// ST DS1077 Rev 20 (https://www.st.com/resource/en/datasheet/m93c46-w.pdf),
// sections 5-8, independently confirms command width, dummy zero, MSB-first
// output, optional sequential wrap, write locking and erased FF. That modern
// part starts programming on CS falling and checks the exact pulse count;
// these differences and analog setup/hold/propagation delays are not modeled.
// The fixed 1750/1000/8000us timings are MAME defaults, not measured Sega PCB
// timings. No power-failure corruption model or save-state format is provided.
//
// Copyright (c) Aaron Giles and contributors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice,
//    this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

src/runtime/model2_eeprom.h
// license:BSD-3-Clause
// copyright-holders:Aaron Giles and contributors
// Native adapter of MAME's 93C46 serial EEPROM contract; see .cpp for provenance.

src/runtime/model2_io.cpp
// license: BSD-3-Clause
// copyright-holders: Dirk Best
// Sega 315-5649 register semantics transplanted from MAME
// src/mame/sega/315_5649.cpp, dddd73680656e355bb2b5beecab1167c9f07bf81.
// Source SHA256: 06cc79c2b00b478bbcbba7c5ec7735f0cb48fe25795bc5b3d94a77ebca03943d.
// Changes: no device framework/logging; plain callbacks/state; explicit peek
// flag replaces machine().side_effects_disabled(). Unbound callback values
// are MAME's resolver defaults, not invented cabinet inputs.

src/runtime/model2_io.h
// license: BSD-3-Clause
// copyright-holders: Dirk Best
// Sega 315-5649 register behavior adapted from MAME src/mame/sega/315_5649.*
// at dddd73680656e355bb2b5beecab1167c9f07bf81. Device framework and save-state
// registration become plain state; callbacks have the reference's offset 0
// removed. Address decoding and cabinet wiring belong to the board adapter.

src/runtime/model2_priority.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles, Ben Templeman and contributors
//
// Shared Model 2 priority from this project's geo.cpp, raster.cpp and
// app/gpu/gpu_renderer.cpp. C-compatible so other lifted Model 2 games use
// the same quantization, order and GPU ownership rules. Z conversion is
// the Aaron Giles 1.8.23 -> 4.12 conversion retained from MAME model2_v.cpp.

src/runtime/model2_scsp.cpp
// license:BSD-3-Clause
// copyright-holders:ElSemi, R. Belmont, Carl, Miodrag Milanovic
// thanks-to:kingshriek
// Native adaptation of MAME dddd73680656e355bb2b5beecab1167c9f07bf81.
// scsp.cpp SHA256 11750fa03db0324cedc8a56ac481537df1991e58d3ef522e6ca737694dc1a259
// scsp.h SHA256 82636b35d049e2e07f0df5b778d1fd87cc3152e5a7d53fe0da64e3bd1206b1d5
// diserial.cpp SHA256 34ab348975fcafebaf7f5154fcce722b942ea1aefe10a0f5f78296b467310803
// machine.cpp SHA256 a537d3033b37a795781e076ff55c76c11a7b17cc3f03617bf82d81809a875dbc
// disound.cpp SHA256 d65485c3597fbd93f6c8e16ce1c51204974fe58c8af4a846423eb2fd805df87c
//
// Retains source limitations: approximate EG/LFO/noise, immediate DMA,
// missing 1Fs IRQ, and reference FIFO/interrupt quirks. No main IRQ wire or
// external digital input is connected on this Model2A board. The sample
// engine runs at first observable nanosecond boundaries of the source
// stream's floor(time*44100)+1 rule (except time0, which does no work).
// This proactive native schedule is not MAME's lazy stream/timeslice engine.
// Timer attosecond delays round upward to ns; recurring sample phase uses
// an absolute rational index and never accumulates rounded periods.

src/runtime/model2_scsp.h
// license:BSD-3-Clause
// copyright-holders:ElSemi, R. Belmont, Carl, Miodrag Milanovic

src/runtime/model2_scsp_dsp.cpp
// Native adaptation of MAME dddd73680656e355bb2b5beecab1167c9f07bf81.
// Upstream SCSP/DSP semantics and documented imperfections are retained.
// Source SHA256 9d4b1de166e5d7d5128b591c612eff3fd5cec78af79c1acabb9d5e93341917fd
// license:BSD-3-Clause
// copyright-holders:ElSemi, R. Belmont

src/runtime/model2_scsp_dsp.h
// license:BSD-3-Clause
// copyright-holders:ElSemi, R. Belmont
// scspdsp.h SHA256 db522ecaa04665063e46f7f6c699eb7781c672fd7624ac58a60b0b180652d3cc
// emumem.h SHA256 4285ca50a0c14b6038c7443bab45340834f0e4b741f0549a127c4ba7cc1c3e2e

src/runtime/model2_uart.cpp
// license:BSD-3-Clause
// copyright-holders:smf, Robbbert, Carl, Miodrag Milanovic, Vas Crabb
// Adapted from MAME dddd73680656e355bb2b5beecab1167c9f07bf81:
// src/devices/machine/i8251.cpp SHA256274e29a659c75302acdc8ab746034b88c7e337e8122135eac9372db6b0832931;
// i8251.h SHA256a99ee4e12ad03574fd99901ec5a88c84314c3972f5111be0897a07fd2f5f94f2;
// src/emu/diserial.cpp SHA25634ab348975fcafebaf7f5154fcce722b942ea1aefe10a0f5f78296b467310803;
// diserial.h SHA256a787f56d47cc003b6f13918e81ba7115908de28549d3d69a8fc6da951637c53f.
// Changes: plain state/callbacks replace device framework/timers/logging;
// physical clock edges are supplied externally. Idle synchronous programming
// and reset recovery are supported; synchronous serial activity is fenced.
// Reference limitations and callback order are retained; no SCSP sound core.
//
// Copyright (c) smf, Robbbert, Carl, Miodrag Milanovic, Vas Crabb.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice,
//    this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

src/runtime/model2_uart.h
// license:BSD-3-Clause
// copyright-holders:smf, Robbbert, Carl, Miodrag Milanovic, Vas Crabb
// Edge-driven asynchronous i8251/uPD71051, from pinned public MAME.

src/runtime/model2a_clock.cpp
// license:BSD-3-Clause
// copyright-holders:Ben Templeman and contributors
//
// Scheduling/phase contracts checked against MAME
// dddd73680656e355bb2b5beecab1167c9f07bf81 (https://github.com/mamedev/mame):
// src/emu/schedule.cpp adjust/timer_list_insert: equal deadlines retain
// insertion order; rescheduling receives a new position among tied timers.
// SHA256 d7a54f21126144df71ba9a4b40fc3451c5bef1096fe96f89653922015b3c21f9
// src/emu/screen.cpp device_start/configure/time_until_pos/vblank_begin/end:
// SHA256 00950a7da23d4468573dc0c1314b441821802ceccdf67a2e4b8320e6c6006ce0
// src/emu/screen.h time_until_vblank_start/frame_number:
// SHA256 a3ee394293462d5f4319349b09d8c70209ab9dce73dc58925508d633c7f4631b
// src/mame/sega/model2.cpp model2_screen/screen_vblank:
// SHA256 359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6
//
// 16MHz pixels, 656x424 total, 384 visible lines => 41us lines, 17.384ms
// frames, 1.640ms vblank. Startup time is already relative to vblank start;
// time_until_pos(384) advances a full frame. Thus first begin is 17.384ms,
// first end is 19.024ms, with no startup end callback at 1.640ms. Model 2's
// frame latch updates at begin; screen's counter increments after end render.
//
// This native queue has no MAME timeslices, CPU clock, partial-screen updates,
// dynamic video configuration or frame-rate override. It preserves event
// ordering only for devices attached to the same queue. Whole-machine timing
// parity still requires CPU/UART/device scheduling against the reference.

src/runtime/model2a_clock.h
// license:BSD-3-Clause
// copyright-holders:Ben Templeman and contributors

src/runtime/model2a_comm.cpp
// license:BSD-3-Clause
// copyright-holders:Ariane Fugmann and contributors
//
// Mapping: MAME src/mame/sega/model2.cpp model2_base_mem, revision
// dddd73680656e355bb2b5beecab1167c9f07bf81 (https://github.com/mamedev/mame).
// Registers/protocol: unchanged inherited runtime/comm_board.{h,cpp}, adapted
// from that revision's src/mame/sega/m2comm.{h,cpp} (M2COMM_SIMULATION).
// Pinned source SHA256:
// model2.cpp 359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6
// m2comm.cpp 4fdc712070b8766e76ba03fdf64be1844f159ea48b6023ee865162973467d204
// m2comm.h   6f626674189b0c14fb4a576f7e70a846213ca409dbf1ab19b435f8e533e15ae6
//
// The pinned header enables M2COMM_SIMULATION. CN=1 initializes the shared
// protocol data, then a failed connection leaves status=0 and id/count=ff.
// A fixed disconnected transport reproduces that path without any sockets.
// CN=0 clears CN/FG/ZFG, preserving shared cells; FG stores only bit zero.
// Readback is CN|fe and FG|7e|(~ZFG<<7), including when no peer is connected.
// The byte-wide flag registers leave their neighboring byte lanes unmapped
// (zero). We claim only the containing dword, not M2Board's wider device page.
// No communication firmware, bank-switching Z80, HDLC or actual network runs
// here. The simulation's initialization is not proof of firmware execution;
// missing firmware remains a separate full-machine reference limitation.

src/runtime/model2a_comm.h
// license:BSD-3-Clause
// copyright-holders:Ariane Fugmann and contributors
// Model 2A mapping for the inherited MAME-derived CommBoard; see .cpp.

src/runtime/model2a_control.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels and contributors
//
// Adapted from MAME revision dddd73680656e355bb2b5beecab1167c9f07bf81:
// https://github.com/mamedev/mame
// src/mame/sega/model2.cpp: timers_r/w, model2_timer_cb, irq_request_r,
// irq_enable_r/w, irq_ack_w, irq_mask_delayed_update, irq_update,
// machine_reset, screen_vblank and sound_ready_w.
// SHA256 359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6
// src/emu/schedule.cpp: adjust and timer_list_insert (equal deadlines FIFO).
// SHA256 d7a54f21126144df71ba9a4b40fc3451c5bef1096fe96f89653922015b3c21f9
// src/emu/emumem.h: memory_write_generic (zero-extend/shift subword data).
// SHA256 4285ca50a0c14b6038c7443bab45340834f0e4b741f0549a127c4ba7cc1c3e2e
// src/emu/emumem_hedp.cpp: write32smo_delegate passes data, discarding mask.
// SHA256 27b25423ab39477d1b719b8922dc7dab16f712cac43a24d4974890ad7af1aeee
//
// Reference quirks retained: partial ACK clears request bits outside its data
// lanes; timer writes combine with the last read latch, not a fresh countdown;
// mask writes replace their pending event and combine with the active mask;
// mask delivery calls irq_update only for ready+enabled sound; mask disable
// never clears latched requests; timer expiry requests only if then enabled.
// Soft reset does not cancel the delayed-enable timer in machine_reset.
//
// Host scheduling replaces MAME's attotime/timeslice machinery. These devices'
// 40/80ns periods are integral nanoseconds. advance dispatches due callbacks
// before the next host access and preserves insertion order on equal times;
// the host must schedule real CPU/UART/vblank events at their board times.
// This does not establish whole-machine timeslice or instruction-cycle parity.
// IRQ callbacks report changed line levels, never run a CPU interrupt handler.

src/runtime/model2a_control.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels and contributors
// Model 2 IRQ/timer handlers adapted from pinned MAME; provenance in .cpp.

src/runtime/model2a_io.cpp
// license: BSD-3-Clause
// copyright-holders: R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Wiring/defaults transplanted from MAME model2.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81 (SHA256
// 359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6).
// Changes: explicit external EEPROM time and editable input bytes; drive CPU
// IRQ/firmware omitted, command and lamp lines latched with optional callbacks.

src/runtime/model2a_io.h
// license: BSD-3-Clause
// copyright-holders: R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Model2A/Sega Rally wiring adapted from MAME src/mame/sega/model2.cpp,
// dddd73680656e355bb2b5beecab1167c9f07bf81. This adapter runs the I/O register
// chip, not the drive board CPU/firmware or a serial timing model.

src/runtime/model2a_sound_bus.cpp
// license:BSD-3-Clause
// copyright-holders:Ben Templeman and contributors
// Map/reset contracts from MAME dddd73680656e355bb2b5beecab1167c9f07bf81:
// src/mame/sega/model2.cpp, model2_snd/model2snd_ctrl/reset_model2_scsp.
// SHA256 359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6
// This adapter has no SCSP emulation, UART, CPU cycle clock or wait states.
// Unknown access is an explicit bring-up frontier, not an invented value.

src/runtime/model2a_sound_bus.h
// license:BSD-3-Clause
// copyright-holders:Ben Templeman and contributors

src/runtime/model2a_uart.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Address/mask/reset and SCSP UART clock wiring from MAME model2.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81,
// SHA256359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6.
// Framework replaced by DeviceModel; serial peer/clock supplied externally.
// No SCSP or 68000 execution and no fabricated sound acknowledgement.

src/runtime/model2a_uart.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Model2A uPD71051/i8251 bus/clock-pin wiring from pinned MAME model2.cpp.

src/runtime/model2a_video.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Adapted from Daytona M2Board/Video and public MAME at
// dddd73680656e355bb2b5beecab1167c9f07bf81: src/mame/sega/model2.cpp
// SHA256359d7fa309c0bca6c93f5c0826011a7054ae8f04068e9df995188a6256c995b6;
// model2_v.cpp SHA25664511d032b7382df5ded6829b3f3e618c8f09fb602016dc7be35a7cd924e6892;
// segaic24.cpp SHA256d6e2283b1e02e27fe4e28c78d8c86f6e3c2177e6c7db396e7b666d397a037b96.
// Changes: exact range/mirror decoding replaces the coarse Daytona page map;
// palette/tile/char notifications reuse Video; external callbacks supply frame
// and geometry state. Luma remains CPU-strided for existing VideoMem consumers.
// Framebuffer storage is supported; framebuffer test-mode presentation is not.

src/runtime/model2a_video.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels
// Model2A video bus adapter for the existing native Daytona Video/Geo path.
// Register/memory contracts: pinned MAME dddd73680656e355bb2b5beecab1167c9f07bf81.

src/runtime/multipcm.cpp
// MultiPCM, from MAME's src/devices/sound/multipcm.cpp and gew.cpp
// (license: BSD-3-Clause, copyright-holders: Miguel Angel Horna). Framework
// (streams, save states, device_rom_interface) replaced by plain members;
// the arithmetic is unchanged.

src/runtime/raster.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles
//
// Model 2 3D layer, CPU reference: MAME's model2_3d_project,
// render_polygons, model2_3d_render, model2rd.ipp and the poly.h triangle
// and polygon setup, transplanted (see raster.h). Changes: polygons are drawn
// immediately (MAME's work queue keeps the same per-pixel order); float to
// int conversions that can overflow or see a NaN are pinned to the x86 result
// MAME's reference build gives, so every host agrees.

src/runtime/raster.h
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese, Matthew Daniels, Ville Linde, Aaron Giles
//
// CPU reference rasterizer for the Model 2 3D layer: projects, orders and
// draws a frame's display list (Geo::polys) into a 512x512 RGB32 layer.
// Transplanted from MAME at dddd73680656e355bb2b5beecab1167c9f07bf81
// (BSD-3-Clause; notices above kept as the licence requires):
// src/mame/sega/model2_v.cpp (model2_3d_project, render_polygons,
// model2_renderer::model2_3d_render), src/mame/sega/model2rd.ipp (scanline
// shaders, bilinear texel fetch) and the parts of src/devices/video/poly.h
// they use (render_triangle, render_polygon, round_coordinate), drawn
// immediately in order instead of through MAME's work queue. This is the
// ground truth for the GPU renderer, checked against MAME frame by frame.
// See THIRD_PARTY.md.

src/runtime/snd_cpu.cpp
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
// The division cycle-accounting helpers adapt the pinned MAME M68000
// microcode; its original notice is retained above. The remaining native
// sound context and board services are project code. See THIRD_PARTY.md.

src/runtime/tgp.cpp
// license:BSD-3-Clause
// copyright-holders:R. Belmont, Olivier Galibert, ElSemi, Angelo Salese
//
// The TGP's I/O space on the Model 2 CPU board: the sin/cos, atan, 1/x and
// 1/sqrt table ports and the banked window onto buffer RAM and the copro data
// ROM. Transplanted from MAME's src/mame/sega/model2.cpp (model2_tgp_state)
// at dddd73680656e355bb2b5beecab1167c9f07bf81 (BSD-3-Clause; notice above
// kept as the licence requires). See THIRD_PARTY.md.

src/runtime/tgp.h
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
//
// Fujitsu MB86234 TGP (Model 2 geometry coprocessor): context and the inline
// operations that recompiled TGP code (tools/m2tgprecomp output) is built
// from. The semantics are MAME's src/devices/cpu/mb86233/mb86233.cpp at
// dddd73680656e355bb2b5beecab1167c9f07bf81 (BSD-3-Clause; notice above kept
// as the licence requires), split into templates on the instruction's
// constant fields so each generated instruction folds to straight-line code.
// The board side (table ports, banked memory) is model2.cpp's
// model2_tgp_state. There is no MB86233 interpreter: the TGP's program (the
// 2,024 words the i960 uploads) is statically recompiled. See THIRD_PARTY.md.

src/runtime/video.cpp
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert, R. Belmont, ElSemi, Angelo Salese
//
// Model 2 screen output, transplanted from MAME (see video.h): segaic24's
// tile_info, draw_rect (rgb32) and draw_common; model2_state::palette_w,
// colorxlat_w, horizontal/vertical_sync_w, render_polygons' frame logic and
// screen_update. MAME's tilemap engine is replaced by build_layer (the same
// pixmap and flags MAME's tilemap caches hold) and tilemap_draw (the same
// pixel rule as tilemap_t::draw with one scroll value).

src/runtime/video.h
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert, R. Belmont, ElSemi, Angelo Salese
//
// Model 2 screen output: the Sega System 24 tilemap chip (segaic24: four
// 64x64-tile layers, per-line scroll, 8-pixel window masks), the palette the
// tilemaps use, the CRTC offsets, and the composition of the 2D layers with
// the 3D layer (Raster), as MAME's model2_state::screen_update does.
// Transplanted from MAME at dddd73680656e355bb2b5beecab1167c9f07bf81
// (src/mame/sega/segaic24.cpp, model2_v.cpp, model2.cpp; BSD-3-Clause,
// notices above kept as the licence requires). MAME's generic tilemap engine
// is replaced by a direct renderer with the same pixel rules. See
// THIRD_PARTY.md.
