From 112e6ca1f224b1118b020dc19ef01662aac3cf32 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 1 May 2017 04:16:31 -0500 Subject: [PATCH] libretro: fix some scrambled framebuffers --- .../Libretro/LibretroApi_BRK.cs | 4 --- .../Libretro/LibretroApi_Enums.cs | 3 +- .../Libretro/LibretroApi_QUERY.cs | 14 +++------- .../Libretro/LibretroApi_SIG.cs | 26 +++++++++++++++--- .../Libretro/LibretroCore.cs | 5 ++++ LibretroBridge/vs2015/LibretroBridge.cpp | 9 +++--- output/dll/LibretroBridge.dll | Bin 112640 -> 112640 bytes 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs index 1c0711c539..98c89e17e1 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs @@ -10,10 +10,6 @@ namespace BizHawk.Emulation.Cores.Libretro { switch (msg) { - case eMessage.BRK_InputState: - comm->value = (uint)core.CB_InputState(comm->port, comm->device, comm->index, comm->id); - break; - default: return false; diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs index 8b861eb05b..0764d9d083 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs @@ -28,9 +28,8 @@ namespace BizHawk.Emulation.Cores.Libretro CMD_Unserialize, CMD_LAST, + SIG_InputState, SIG_VideoUpdate, - - BRK_InputState, }; diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs index 7c25bc5aa5..56470c30c1 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs @@ -6,17 +6,11 @@ namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi { - bool Handle_SIG(eMessage msg) + public Tuple QUERY_GetMemory(RETRO_MEMORY mem) { - switch (msg) - { - default: - return false; - - } //switch(msg) - - Message(eMessage.Resume); - return true; + comm->value = (uint)mem; + Message(eMessage.QUERY_GetMemory); + return Tuple.Create(new IntPtr(comm->buf[(int)BufId.Param0]), comm->buf_size[(int)BufId.Param0]); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs index 3cd7fb888d..6e0ab2afe6 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs @@ -6,11 +6,29 @@ namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi { - public Tuple QUERY_GetMemory(RETRO_MEMORY mem) + bool Handle_SIG(eMessage msg) { - comm->value = (uint)mem; - Message(eMessage.QUERY_GetMemory); - return Tuple.Create(new IntPtr(comm->buf[(int)BufId.Param0]), comm->buf_size[(int)BufId.Param0]); + //I know, ive done this two completely different ways + //both ways are sloppy glue, anyway + //I havent decided on the final architecture yet + + switch (msg) + { + case eMessage.SIG_InputState: + comm->value = (uint)core.CB_InputState(comm->port, comm->device, comm->index, comm->id); + break; + + case eMessage.SIG_VideoUpdate: + core.SIG_VideoUpdate(); + break; + + default: + return false; + + } //switch(msg) + + Message(eMessage.Resume); + return true; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs index a25c852283..ccbffb87e1 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs @@ -196,6 +196,11 @@ namespace BizHawk.Emulation.Cores.Libretro } } + public void SIG_VideoUpdate() + { + SetVideoBuffer(api.comm->env.fb_width, api.comm->env.fb_height); + } + int IVideoProvider.BufferWidth { get { return vidWidth; } } int IVideoProvider.BufferHeight { get { return vidHeight; } } diff --git a/LibretroBridge/vs2015/LibretroBridge.cpp b/LibretroBridge/vs2015/LibretroBridge.cpp index 3442dc7565..7918b7dbfc 100644 --- a/LibretroBridge/vs2015/LibretroBridge.cpp +++ b/LibretroBridge/vs2015/LibretroBridge.cpp @@ -93,9 +93,8 @@ enum eMessage : s32 CMD_Unserialize, CMD_LAST, + SIG_InputState, SIG_VideoUpdate, - - BRK_InputState, }; enum eStatus : s32 @@ -558,11 +557,11 @@ void retro_video_refresh(const void *data, unsigned width, unsigned height, size comm.env.fb_width = (s32)width; comm.env.fb_height = (s32)height; + //stash pitch if needed //notify c# of these new settings and let it allocate a buffer suitable for receiving the output (so we can work directly into c#'s int[]) //c# can read the settings right out of the comm env - //NOPE: not needed. for now, anyway. may want to notify later - //BREAK(eMessage::SIG_VideoUpdate); + BREAK(eMessage::SIG_VideoUpdate); ////if (BufferWidth != width) BufferWidth = (int)width; @@ -639,7 +638,7 @@ s16 retro_input_state(unsigned port, unsigned device, unsigned index, unsigned i comm.index = index; comm.id = id; - BREAK(eMessage::BRK_InputState); + BREAK(eMessage::SIG_InputState); return (s16)comm.value; } diff --git a/output/dll/LibretroBridge.dll b/output/dll/LibretroBridge.dll index 1b93178174fc7ffd7219740e8e2a27ed65365049..0c2d20523d4da2b142afe29a4cb6ee9dde0c9b66 100644 GIT binary patch delta 1683 zcmZ`(e@t6d6n>{G1V+2Q@w-eW6lQR9aBp$C`TAOB=syTpGK4UM5i=4clMpOQbXu@& zBEFSuviMkFC>zWAj|AT0Yu7Q*wqu8cMdFFE&|_kHJ_ z`@MT}Udv)+%VK1I6l{2JIkF=LPDD?{GEBb+OvADCEggQ?4f7qK8iR>}OR7}0s>V1V zMb<|^%Rss2`&8%}h}|yCsw}MdSppo{*g%1`wKe2RUf-@nFh!`yPT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