Files
psxrecomp/tools/build_oracle.sh
Matthew Stanley 82aeca98a7 feat: embed Beetle PSX libretro core as golden oracle for RAM comparison
Adds a new psx-beetleoracle build target that embeds beetle-psx-libretro
(mednafen PSX core) alongside the recompiled BIOS. Both execute the same
SCPH1001.BIN and advance in lock-step, enabling byte-level RAM comparison
via the TCP debug server.

New infrastructure:
- psx_oracle_backend.h: abstract oracle backend interface (init, run_frame,
  get_ram, get_vram, get_scratchpad, read_byte/word, get_cpu_regs, sync_to_state)
- beetle_psx_bridge.cpp: libretro bridge with CPU register access via
  PSX_CPU->GetRegister(), VRAM via GPU_get_vram(), scratchpad via ScratchRAM
- psx_oracle_cmds.c: TCP commands — find_first_divergence, emu_read_ram,
  emu_read_vram, emu_read_scratchpad, emu_cpu_regs, emu_step, emu_sync,
  emu_sync_press
- psx_oracle_stub.c: no-op stubs for non-oracle builds
- tools/oracle_diff.py: standalone Python RAM comparison tool
- tools/build_oracle.sh: build script for beetle-psx + oracle target

Also includes: SIO card probe diagnostic counters (mc_probes, mc_acks,
mc_cmds, tx_writes), enhanced dispatch miss logging with register context,
memory_get_ram_ptr() for oracle RAM comparison.

Build: cd beetle-psx && make platform=mingw_x86_64 STATIC_LINKING=1 HAVE_LIGHTREC=0
       cd runtime/build && cmake --build . --target psx-beetleoracle

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 00:15:01 -07:00

61 lines
1.6 KiB
Bash

#!/bin/bash
# Build the psx-dsoracle target (MSVC, links DuckStation oracle).
#
# Prerequisites:
# - DuckStation built via: bash tools/duckstation/build.sh
# - MSVC 2022 installed (detected via vswhere)
# - CMake in PATH
#
# Usage:
# bash tools/build_oracle.sh
# bash tools/build_oracle.sh clean # clean + rebuild
set -e
cd "$(dirname "$0")/.."
ROOT="$(pwd)"
echo "=== psxrecomp-v4: build oracle ==="
# Check DuckStation is built.
if [ ! -f "duckstation/build/src/core/Release/core.lib" ]; then
echo "ERROR: DuckStation not built. Run: bash tools/duckstation/build.sh"
exit 1
fi
# Download SDL2 MSVC dev package if not present.
if [ ! -d sdl2-msvc/SDL2-* ] 2>/dev/null; then
echo "Downloading SDL2 MSVC development package..."
curl -L -o sdl2-dev.zip \
"https://github.com/libsdl-org/SDL/releases/download/release-2.30.12/SDL2-devel-2.30.12-VC.zip"
mkdir -p sdl2-msvc
unzip -q -o sdl2-dev.zip -d sdl2-msvc/
rm -f sdl2-dev.zip
fi
# Configure with MSVC generator.
BUILD_DIR="runtime/build-msvc"
if [ "$1" = "clean" ]; then
echo "Cleaning build directory..."
rm -rf "$BUILD_DIR"
fi
if [ ! -d "$BUILD_DIR" ]; then
echo "Configuring CMake (MSVC x64)..."
cmake -S runtime -B "$BUILD_DIR" \
-G "Visual Studio 17 2022" -A x64
fi
# Build psx-dsoracle target.
echo "Building psx-dsoracle..."
cmake --build "$BUILD_DIR" --target psx-dsoracle --config Release -- /m
echo ""
echo "=== Build complete ==="
echo "Binary: $BUILD_DIR/Release/psx-dsoracle.exe"
# Copy SDL2.dll if not already there.
if [ -f "$BUILD_DIR/Release/psx-dsoracle.exe" ]; then
echo "Oracle binary ready."
fi