The InputCallbackSystem on this Core is now fully operational. https://www.youtube.com/watch?v=g7-tskP0OzI
This commit is contained in:
parent
7f2e06b0b5
commit
7f7f490b6d
|
@ -25,6 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
public int vheight;
|
||||
public IntPtr sptr;
|
||||
public int slen;
|
||||
public int padread;
|
||||
};
|
||||
|
||||
public enum LeftPortDevice : uint
|
||||
|
@ -43,6 +44,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
Justifier = 5
|
||||
}
|
||||
|
||||
[UnmanagedFunctionPointer(CC)]
|
||||
public delegate void InputCallback();
|
||||
|
||||
const CallingConvention CC = CallingConvention.Cdecl;
|
||||
|
||||
[BizImport(CC)]
|
||||
|
@ -67,5 +71,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
public abstract void biz_get_memory_area(int which, [In, Out] memory_area mem);
|
||||
[BizImport(CC)]
|
||||
public abstract void biz_post_load_state();
|
||||
[BizImport(CC)]
|
||||
public abstract void biz_set_input_callback(InputCallback callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
[ServiceNotApplicable(typeof(IDriveLight))]
|
||||
public class Snes9x : IEmulator, IVideoProvider, ISoundProvider, IStatable,
|
||||
ISettable<Snes9x.Settings, Snes9x.SyncSettings>,
|
||||
ISaveRam
|
||||
ISaveRam, IInputPollable
|
||||
{
|
||||
private LibSnes9x _core;
|
||||
private PeRunner _exe;
|
||||
|
@ -71,6 +71,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
PutSettings(settings);
|
||||
InitMemoryDomains();
|
||||
InitSaveram();
|
||||
|
||||
_inputCallback = InputCallbacks.Call;
|
||||
}
|
||||
|
||||
#region controller
|
||||
|
@ -301,6 +303,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
|
||||
public void FrameAdvance(IController controller, bool render, bool rendersound = true)
|
||||
{
|
||||
_core.biz_set_input_callback(InputCallbacks.Count > 0 ? _inputCallback : null);
|
||||
|
||||
if (controller.IsPressed("Power"))
|
||||
_core.biz_hard_reset();
|
||||
else if (controller.IsPressed("Reset"))
|
||||
|
@ -311,6 +315,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
LibSnes9x.frame_info frame = new LibSnes9x.frame_info();
|
||||
|
||||
_core.biz_run(frame, _inputState);
|
||||
IsLagFrame = frame.padread == 0;
|
||||
if (IsLagFrame)
|
||||
LagCount++;
|
||||
using (_exe.EnterExit())
|
||||
{
|
||||
Blit(frame);
|
||||
|
@ -444,9 +451,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
|
||||
#endregion
|
||||
|
||||
// TODO
|
||||
public int LagCount { get; private set; }
|
||||
public bool IsLagFrame { get; private set; }
|
||||
private LibSnes9x.InputCallback _inputCallback;
|
||||
|
||||
public int LagCount { get; set; }
|
||||
public bool IsLagFrame { get; set; }
|
||||
|
||||
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
|
||||
|
||||
#region IStatable
|
||||
|
||||
|
@ -479,6 +489,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
|||
LagCount = reader.ReadInt32();
|
||||
IsLagFrame = reader.ReadBoolean();
|
||||
// any managed pointers that we sent to the core need to be resent now!
|
||||
_core.biz_set_input_callback(null);
|
||||
|
||||
_core.biz_post_load_state();
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
Subproject commit 431f7453b322661b60d9bae20a8730bb9399f847
|
||||
Subproject commit 69b89b25c7e2d0c97412a27081d21a0834137319
|
Loading…
Reference in New Issue