From 25a5449a4851c623d5aac0364c5e973c38e3f9d1 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Fri, 12 Jun 2020 15:22:46 -0400 Subject: [PATCH] Work around mono marshalling issue Fixes #2116, but it'd be nice if mono fixed it too --- src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs | 7 ++++++- src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Cd.cs | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs index ae51b12cf8..9a8d436db2 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs @@ -176,8 +176,13 @@ namespace BizHawk.Emulation.Cores.Waterbox [MarshalAs(UnmanagedType.ByValArray, SizeConst = 101)] public Track[] Tracks; } + /// + /// Callback to receive a disk TOC + /// + /// + /// Deposit a LibNymaCore.TOC here [UnmanagedFunctionPointer(CC)] - public delegate void CDTOCCallback(int disk, [In, Out]TOC toc); + public delegate void CDTOCCallback(int disk, IntPtr dest); [UnmanagedFunctionPointer(CC)] public delegate void CDSectorCallback(int disk, int lba, IntPtr dest); [BizImport(CC)] diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Cd.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Cd.cs index 031586300e..a51332274b 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Cd.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Cd.cs @@ -32,9 +32,11 @@ namespace BizHawk.Emulation.Cores.Waterbox } } - private void CDTOCCallback(int disk, [In, Out]LibNymaCore.TOC t) + private void CDTOCCallback(int disk, IntPtr dest) { - SetupTOC(t, _disks[disk].TOC); + var toc = new LibNymaCore.TOC { Tracks = new LibNymaCore.TOC.Track[101] }; + SetupTOC(toc, _disks[disk].TOC); + Marshal.StructureToPtr(toc, dest, false); } private void CDSectorCallback(int disk, int lba, IntPtr dest) {