N64: Implemented the lag indicator and lag count
This commit is contained in:
parent
371dcc8f40
commit
a6600a5c0a
|
@ -75,6 +75,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
*/
|
*/
|
||||||
api.set_buttons(0, ReadController(1), x, y);
|
api.set_buttons(0, ReadController(1), x, y);
|
||||||
api.frame_advance();
|
api.frame_advance();
|
||||||
|
IsLagFrame = api.IsLagFrame();
|
||||||
|
if (IsLagFrame) LagCount++;
|
||||||
Frame++;
|
Frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,21 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
private delegate int SetKeys(int num, int keys, sbyte X, sbyte Y);
|
private delegate int SetKeys(int num, int keys, sbyte X, sbyte Y);
|
||||||
SetKeys InpSetKeys;
|
SetKeys InpSetKeys;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the internal lag indicator to true.
|
||||||
|
/// </summary>
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate void ResetLagFlag();
|
||||||
|
ResetLagFlag InpResetLagFlag;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the internal lag indicator. It will be set to 0 if the input has been read since it was last reset
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate int CheckLagFlag();
|
||||||
|
CheckLagFlag InpCheckLagFlag;
|
||||||
|
|
||||||
|
|
||||||
// These are common for all four plugins
|
// These are common for all four plugins
|
||||||
|
|
||||||
|
@ -488,6 +503,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
InpPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginStartup"), typeof(PluginStartup));
|
InpPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginStartup"), typeof(PluginStartup));
|
||||||
InpPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginShutdown"), typeof(PluginShutdown));
|
InpPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginShutdown"), typeof(PluginShutdown));
|
||||||
InpSetKeys = (SetKeys)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetKeys"), typeof(SetKeys));
|
InpSetKeys = (SetKeys)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "SetKeys"), typeof(SetKeys));
|
||||||
|
InpResetLagFlag = (ResetLagFlag)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "ResetLagFlag"), typeof(ResetLagFlag));
|
||||||
|
InpCheckLagFlag = (CheckLagFlag)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "CheckLagFlag"), typeof(CheckLagFlag));
|
||||||
|
|
||||||
RspPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginStartup"), typeof(PluginStartup));
|
RspPluginStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginStartup"), typeof(PluginStartup));
|
||||||
RspPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginShutdown"), typeof(PluginShutdown));
|
RspPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginShutdown"), typeof(PluginShutdown));
|
||||||
|
@ -594,10 +611,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
|
|
||||||
public void frame_advance()
|
public void frame_advance()
|
||||||
{
|
{
|
||||||
|
InpResetLagFlag();
|
||||||
m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);
|
m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);
|
||||||
m64pFrameComplete.WaitOne();
|
m64pFrameComplete.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsLagFrame()
|
||||||
|
{
|
||||||
|
return (InpCheckLagFlag() == 1 ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
public int SaveState(byte[] buffer)
|
public int SaveState(byte[] buffer)
|
||||||
{
|
{
|
||||||
return m64pCoreSaveState(buffer);
|
return m64pCoreSaveState(buffer);
|
||||||
|
|
Binary file not shown.
|
@ -91,6 +91,8 @@ static unsigned char myKeyState[SDL_NUM_SCANCODES];
|
||||||
|
|
||||||
BUTTONS controllers[4];
|
BUTTONS controllers[4];
|
||||||
|
|
||||||
|
int LagFlag = 1;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static struct ff_effect ffeffect[3];
|
static struct ff_effect ffeffect[3];
|
||||||
static struct ff_effect ffstrong[3];
|
static struct ff_effect ffstrong[3];
|
||||||
|
@ -369,6 +371,7 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
|
||||||
EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
|
EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
|
||||||
{
|
{
|
||||||
(*Keys).Value = controllers[Control].Value;
|
(*Keys).Value = controllers[Control].Value;
|
||||||
|
LagFlag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -483,4 +486,14 @@ EXPORT void CALL SetKeys(int num, int keys, char X, char Y)
|
||||||
|
|
||||||
controllers[num].X_AXIS = X;
|
controllers[num].X_AXIS = X;
|
||||||
controllers[num].Y_AXIS = Y;
|
controllers[num].Y_AXIS = Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT void CALL ResetLagFlag()
|
||||||
|
{
|
||||||
|
LagFlag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT int CALL CheckLagFlag()
|
||||||
|
{
|
||||||
|
return LagFlag;
|
||||||
}
|
}
|
Loading…
Reference in New Issue