Files
psxrecomp/docs/beetle_sio_trace_hook.patch
Claude 21e57a82cc docs+patch: psx-beetle oracle on Linux (pinned beetle-psx base + SIO trace hook)
beetle_libretro.cpp targets the C++ beetle-psx tree; upstream master has
been converted to plain C and no longer compiles against it. Documented
the working recipe: pin beetle-psx at 5759277b (the wtrace patch's base,
located via the patch's own blob hash), apply beetle_wtrace_hook.patch,
and apply the new beetle_sio_trace_hook.patch — FrontIO::SetSIOTraceCallback
(fires once per completed SIO byte exchange), a hook beetle_libretro.cpp
required that was missing from the committed patch set.

Verified on Linux/Xvfb: psx-beetle boots Kula World to demo gameplay and
serves ping/screenshot over the shared TCP debug protocol, alongside
kula-runtime — the two-process oracle setup from CLAUDE.md §16 now works
in this environment. Runtime-created per-game .mcr files are gitignored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdjxoRB1f9VQsNzZayCgGS
2026-07-02 17:08:19 +00:00

36 lines
1.3 KiB
Diff

diff --git a/mednafen/psx/frontio.cpp b/mednafen/psx/frontio.cpp
index a35b022f..02e7ce0b 100644
--- a/mednafen/psx/frontio.cpp
+++ b/mednafen/psx/frontio.cpp
@@ -783,6 +783,10 @@ int32_t FrontIO::Update(int32_t timestamp)
ReceiveInProgress = false;
ReceiveBufferAvail = true;
+ /* PSXRecomp oracle hook: byte exchange complete. */
+ if(MDFN_UNLIKELY(sio_trace_cb))
+ sio_trace_cb(TransmitBuffer, ReceiveBuffer, (uint16_t)Control);
+
if(Control & 0x800)
{
istatus = true;
diff --git a/mednafen/psx/frontio.h b/mednafen/psx/frontio.h
index 8a67f5af..d9a260ca 100644
--- a/mednafen/psx/frontio.h
+++ b/mednafen/psx/frontio.h
@@ -95,8 +95,15 @@ class FrontIO
int StateAction(StateMem* sm, int load, int data_only);
+ /* PSXRecomp oracle hook: fires once per completed SIO byte exchange
+ * (tx byte sent, rx byte received, current Control register). */
+ typedef void (*sio_trace_cb_t)(uint8_t tx, uint8_t rx, uint16_t ctrl);
+ void SetSIOTraceCallback(sio_trace_cb_t cb) { sio_trace_cb = cb; }
+
private:
+ sio_trace_cb_t sio_trace_cb = nullptr;
+
void DoDSRIRQ(void);
void CheckStartStopPending(int32_t timestamp, bool skip_event_set = false);