Files
psxrecomp/docs/beetle_cdc_dma_peek_hook.patch
Shokunin 055c33aaa1 docs: complete the Beetle oracle patch set; add a macOS recipe
beetle-linux.md told builders to re-land several Beetle hooks by hand
because they were never exported to docs/: the rtrace and IRQ callbacks,
the guest-cycle clock, PS_CDC::PSXRecomp_GetDecodeVolume and the CDC/DMA
IRQ peeks that beetle_libretro.cpp links against, plus the SPU event
calls and the per-instruction hook the real cyc_watch now needs. Ship
them, one patch per hook, all against the 5759277b base:

- beetle_rtrace_irq_hook.patch
- beetle_guest_cycles_hook.patch
- beetle_cdc_dma_peek_hook.patch
- beetle_spu_event_hook.patch

beetle_cdcmd_trace_hook.patch was generated from a tree that already had
the wtrace block, so applying it after the wtrace patch redefined the
wtrace globals and typedefs and needed a manual fix. It is now a diff on
top of the wtrace and SIO patches; the resulting tree is unchanged.

beetle-macos.md is the macOS recipe, verified from a fresh official
clone on Apple Silicon: `git apply` of all seven patches, the osx static
build, the psx-beetle configure on current master, OpenBIOS under the
retail file names (Beetle otherwise boots its own, different OpenBIOS),
headless runs through SDL's dummy driver, and ruler #2 as the check
before trusting a build. beetle-linux.md now uses the full patch set,
notes the current configure requirements and the headless option, and
gives psx-beetle's actual default port (4382).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 11:06:14 -07:00

59 lines
1.8 KiB
Diff

diff --git a/mednafen/psx/cdc.cpp b/mednafen/psx/cdc.cpp
index a6b31b66..f2c460b9 100644
--- a/mednafen/psx/cdc.cpp
+++ b/mednafen/psx/cdc.cpp
@@ -2438,3 +2438,23 @@ PS_CDC::CDC_CTEntry PS_CDC::Commands[0x20] =
{ /* 0x1E, */ 0, 0, "ReadTOC", &PS_CDC::Command_ReadTOC, &PS_CDC::Command_ReadTOC_Part2 },
{ /* 0x1F, */ 0, 0, NULL, NULL, NULL },
};
+
+/* PSXRecomp oracle peeks. */
+void PS_CDC::PSXRecomp_GetDecodeVolume(uint8 out[2][2]) const
+{
+ for(unsigned i = 0; i < 2; i++)
+ for(unsigned j = 0; j < 2; j++)
+ out[i][j] = DecodeVolume[i][j];
+}
+
+uint8 PS_CDC::PSXRecomp_GetIRQBuffer(void) const
+{
+ return IRQBuffer;
+}
+
+/* INT type of the pending CD interrupt (low nibble of IRQBuffer:
+ * 1=data ready, 2=complete, 3=acknowledge, 4=data end, 5=error). */
+extern "C" unsigned psxrecomp_cdc_irq_type(void)
+{
+ return PSX_CDC ? (unsigned)(PSX_CDC->PSXRecomp_GetIRQBuffer() & 0xF) : 0u;
+}
diff --git a/mednafen/psx/cdc.h b/mednafen/psx/cdc.h
index fabf2053..c582b9f5 100644
--- a/mednafen/psx/cdc.h
+++ b/mednafen/psx/cdc.h
@@ -44,6 +44,10 @@ class PS_CDC
int DriveStatus;
#endif
+ /* PSXRecomp oracle peeks (read-only, no side effects). */
+ void PSXRecomp_GetDecodeVolume(uint8 out[2][2]) const; // [data_source][output_port], 0x80 = unity
+ uint8 PSXRecomp_GetIRQBuffer(void) const;
+
private:
CDIF *Cur_CDIF;
bool DiscChanged;
diff --git a/mednafen/psx/dma.cpp b/mednafen/psx/dma.cpp
index 27da2cd2..2f58b8ca 100644
--- a/mednafen/psx/dma.cpp
+++ b/mednafen/psx/dma.cpp
@@ -727,3 +727,10 @@ int DMA_StateAction(StateMem *sm, int load, int data_only)
return(ret);
}
+
+/* PSXRecomp oracle peek: per-channel DMA completion flags (DICR bits 24-30,
+ * bit n = channel n completed). */
+extern "C" unsigned psxrecomp_dma_int_status(void)
+{
+ return (unsigned)DMAIntStatus;
+}