src/core32x/bus.c
/*
 * Kega Refusion 32X device bus.
 * Derived from PicoDrive pico/32x/memory.c and 32x.c, revision
 * 07abb00550528f7bf53087d932dd3d747cf2d0df.
 * (C) notaz, 2009,2010,2013; (C) irixxxx, 2019-2024.
 * MAME noncommercial terms: third_party/picodrive32x/COPYING.
 * Modified for Kega Refusion: explicit state/host API, master-clock timestamps,
 * bounded two-bank DREQ FIFO, real blanking signals instead of read-count
 * toggles, no donor MD/CD execution or global Pico state.
 */

src/core32x/machine.c
/* Kega Refusion: one owned 32X attachment to the existing GPX machine.
 * Address map and byte-lane rules adapted from PicoDrive 07abb005 memory.c;
 * (C) notaz 2009,2010,2013; (C) irixxxx 2019-2024.
 * See third_party/picodrive32x/COPYING. Changed: explicit ownership/callbacks,
 * absolute master-clock timeline and independently allocated CPU contexts. */

src/core32x/audio/pwm.c
/*
 * PicoDrive PWM adaptation for Kega Refusion
 * (C) notaz, 2009,2010,2013
 * (C) irixxxx, 2019-2023
 *
 * Derived from pico/32x/pwm.c, revision
 * 07abb00550528f7bf53087d932dd3d747cf2d0df.
 * This work is licensed under the terms of the MAME noncommercial license.
 * See third_party/picodrive32x/COPYING.
 *
 * Explicit instances, GPX master-clock timestamps and amplitude deltas replace
 * donor globals/PCM storage. The programmed IRQ interval is never adapted.
 */

src/core32x/video/compositor.c
/*
 * Kega Refusion: isolated 32X video compositor, 2026.
 * Display decoding/priority rules adapted from PicoDrive pico/32x/draw.c:
 * (C) notaz, 2009,2010
 * (C) irixxxx, 2019-2026
 * Licensed under the accompanying noncommercial MAME-style LICENSE.
 * See PROVENANCE.md for donor revision, local changes and integration limits.
 */

src/core32x/sh2/sh2_interpreter.c
/*
 * Kega Refusion host-independent SH-2 reference bridge.
 * Adapted from PicoDrive cpu/sh2/sh2.c and mame/sh2pico.c:
 * (C) notaz, 2009,2010; (C) irixxxx, 2019-2024.
 * Licensed under the non-commercial terms in third_party/picodrive32x/COPYING.
 * Changed for Kega Refusion: per-instance callbacks, cycle accounting,
 * pointer-free snapshots, and no Pico/global CPU/frontend dependencies.
 * The included opcode implementation retains its notice; ORIGIN.txt records
 * the narrow well-defined sign-extension corrections.
 */

src/core32x/sh2/soc.c
/*
 * Kega Refusion SH-2 SoC, adapted from PicoDrive sh2soc.c at 07abb00550528f7b.
 * (C) notaz, 2013; (C) irixxxx, 2019-2024.
 * Non-commercial terms: third_party/picodrive32x/COPYING.
 * Changed: per-instance host callbacks, native-cycle deadlines, bounded queued
 * DMA, safe division overflow, FRT and pointer-free peripheral state.
 *
 * FRT/DIVU behavior cross-checked against ares dc4f4659d49693ac91705389e6c37734c016bf16.
 * Copyright (c) 2004-2025 ares team, Near et al.
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

third_party/picodrive32x/cpu/sh2/mame/sh2.c
/* Kega Refusion: disp8/disp12 branch and EXTS sign extension uses bounded
 * arithmetic instead of overflowing signed left shifts. Original notice follows. */
/*****************************************************************************
 *
 *   sh2.c
 *   Portable Hitachi SH-2 (SH7600 family) emulator
 *
 *   Copyright Juergen Buchmueller <pullmoll@t-online.de>,
 *   all rights reserved.
 *
 *   - This source code is released as freeware for non-commercial purposes.
 *   - You are free to use and redistribute this code in modified or
 *     unmodified form, provided you list me in the credits.
 *   - If you modify this source code, you must add a notice to each modified
 *     source file that it has been changed.  If you're a nice person, you
 *     will clearly mark each change too.  :)
 *   - If you wish to use this for commercial purposes, please contact me at
 *     pullmoll@t-online.de
 *   - The author of this copywritten work reserves the right to change the
 *     terms of its usage and license at any time, including retroactively
 *   - This entire notice must remain in the source code.
 *
 *  This work is based on <tiraniddo@hotmail.com> C/C++ implementation of
 *  the SH-2 CPU core and was adapted to the MAME CPU core requirements.
 *  Thanks also go to Chuck Mason <chukjr@sundail.net> and Olivier Galibert
 *  <galibert@pobox.com> for letting me peek into their SEMU code :-)
 *
 *****************************************************************************/
/*****************************************************************************
    Changes
    20130129 Angelo Salese
    - added illegal opcode exception handling, side effect of some Saturn games
      on loading like Feda or Falcom Classics Vol. 1
      (i.e. Master CPU Incautiously transfers memory from CD to work RAM H, and
            wipes out Slave CPU program code too while at it).

    20051129 Mariusz Wojcieszek
    - introduced memory_decrypted_read_word() for opcode fetching

    20050813 Mariusz Wojcieszek
    - fixed 64 bit / 32 bit division in division unit

    20031015 O. Galibert
    - dma fixes, thanks to sthief

    20031013 O. Galibert, A. Giles
    - timer fixes
    - multi-cpu simplifications

    20030915 O. Galibert
    - fix DMA1 irq vector
    - ignore writes to DRCRx
    - fix cpu number issues
    - fix slave/master recognition
    - fix wrong-cpu-in-context problem with the timers

    20021020 O. Galibert
    - DMA implementation, lightly tested
    - delay slot in debugger fixed
    - add divide box mirrors
    - Nicola-ify the indentation
    - Uncrapify sh2_internal_*
    - Put back nmi support that had been lost somehow

    20020914 R. Belmont
    - Initial SH2 internal timers implementation, based on code by O. Galibert.
      Makes music work in galspanic4/s/s2, panic street, cyvern, other SKNS games.
    - Fix to external division, thanks to "spice" on the E2J board.
      Corrects behavior of s1945ii turret boss.

    20020302 Olivier Galibert (galibert@mame.net)
    - Fixed interrupt in delay slot
    - Fixed rotcr
    - Fixed div1
    - Fixed mulu
    - Fixed negc

    20020301 R. Belmont
    - Fixed external division

    20020225 Olivier Galibert (galibert@mame.net)
    - Fixed interrupt handling

    20010207 Sylvain Glaize (mokona@puupuu.org)

    - Bug fix in INLINE void MOVBM(UINT32 m, UINT32 n) (see comment)
    - Support of full 32 bit addressing (RB, RW, RL and WB, WW, WL functions)
        reason : when the two high bits of the address are set, access is
        done directly in the cache data array. The SUPER KANEKO NOVA SYSTEM
        sets the stack pointer here, using these addresses as usual RAM access.

        No real cache support has been added.
    - Read/Write memory format correction (_bew to _bedw) (see also SH2
        definition in cpuintrf.c and DasmSH2(..) in sh2dasm.c )

    20010623 James Forshaw (TyRaNiD@totalise.net)

    - Modified operation of sh2_exception. Done cause mame irq system is stupid, and
      doesnt really seem designed for any more than 8 interrupt lines.

    20010701 James Forshaw (TyRaNiD@totalise.net)

    - Fixed DIV1 operation. Q bit now correctly generated

    20020218 Added save states (mokona@puupuu.org)

 *****************************************************************************/

third_party/picodrive32x/cpu/sh2/compiler.c
/* Kega Refusion modifications: callback-only memory and instruction fetch,
 * independent CPU pointers, bounded checked emission, recoverable compiler
 * failures, instruction slice boundaries, no MD/CD or Pico global state.
 * See ORIGIN.txt for the pinned upstream source and retained license. */
/*
 * SH2 recompiler
 * (C) notaz, 2009,2010,2013
 * (C) irixxxx, 2018-2024
 *
 * This work is licensed under the terms of MAME license.
 * See COPYING file in the top-level directory.
 *
 * notes:
 * - tcache, block descriptor, block entry buffer overflows result in oldest
 *   blocks being deleted until enough space is available
 * - link and list element buffer overflows result in failure and exit
 * - jumps between blocks are tracked for SMC handling (in block_entry->links),
 *   except jumps from global to CPU-local tcaches
 *
 * implemented:
 * - static register allocation
 * - remaining register caching and tracking in temporaries
 * - block-local branch linking
 * - block linking
 * - some constant propagation
 * - call stack caching for host block entry address
 * - delay, poll, and idle loop detection and handling
 * - some T/M flag optimizations where the value is known or isn't used
 *
 * TODO:
 * - better constant propagation
 * - bug fixing
 */

third_party/picodrive32x/cpu/drc/emit_x86.c
/* Kega Refusion: checked cache writes/relative calls; original notice retained. */
/*
 * Basic macros to emit x86 instructions and some utils
 * Copyright (C) 2008,2009,2010 notaz
 * Copyright (C) 2019-2024 irixxxx
 *
 * This work is licensed under the terms of MAME license.
 * See COPYING file in the top-level directory.
 *
 * note:
 *  temp registers must be eax-edx due to use of SETcc and r/w 8/16.
 * note about silly things like emith_eor_r_r_r:
 *  these are here because the compiler was designed
 *  for ARM as it's primary target.
 */
