From a6600a5c0a42eed4d8db4ffaaefb39e4fd57346f Mon Sep 17 00:00:00 2001 From: pjgat09 Date: Mon, 6 May 2013 23:50:24 +0000 Subject: [PATCH] N64: Implemented the lag indicator and lag count --- .../Consoles/Nintendo/N64/N64.cs | 2 ++ .../Consoles/Nintendo/N64/mupen64plusApi.cs | 23 ++++++++++++++++++ .../output/dll/mupen64plus-input-bkm.dll | Bin 9728 -> 9728 bytes libmupen64plus/mupen64plus-input-bkm/plugin.c | 13 ++++++++++ 4 files changed, 38 insertions(+) diff --git a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs index aba70c6915..67a3a08823 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs @@ -75,6 +75,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 */ api.set_buttons(0, ReadController(1), x, y); api.frame_advance(); + IsLagFrame = api.IsLagFrame(); + if (IsLagFrame) LagCount++; Frame++; } diff --git a/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs b/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs index d2363ef707..9c55dbff03 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs @@ -288,6 +288,21 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 private delegate int SetKeys(int num, int keys, sbyte X, sbyte Y); SetKeys InpSetKeys; + /// + /// Resets the internal lag indicator to true. + /// + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void ResetLagFlag(); + ResetLagFlag InpResetLagFlag; + + /// + /// Checks the internal lag indicator. It will be set to 0 if the input has been read since it was last reset + /// + /// + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int CheckLagFlag(); + CheckLagFlag InpCheckLagFlag; + // 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)); InpPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(InpDll, "PluginShutdown"), typeof(PluginShutdown)); 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)); RspPluginShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(RspDll, "PluginShutdown"), typeof(PluginShutdown)); @@ -594,10 +611,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 public void frame_advance() { + InpResetLagFlag(); m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero); m64pFrameComplete.WaitOne(); } + public bool IsLagFrame() + { + return (InpCheckLagFlag() == 1 ? true : false); + } + public int SaveState(byte[] buffer) { return m64pCoreSaveState(buffer); diff --git a/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll b/BizHawk.MultiClient/output/dll/mupen64plus-input-bkm.dll index daf98f61326774f858237de60be47869b92da0a7..aa2b6c7cf4c5c8e3c17845112ced4647d200c4e1 100644 GIT binary patch delta 1058 zcmY+CZERCj7{{M;+m61jWoxl3>+H5>ZbY_DcJH}8xA&Hev0yf31Sc62Gh#-s+n6M< zNQ`U?vxzV!9Vg(_NQM&)`azST@g>5bVpE+)GZcv$(2Q6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0)Ib(M_Ile1ye$7t2_j>>d6*J5thFYOce*4Q7A^le?DvRx(Sf*^ITOW)(yI{nHuy z^uByPA4<8v5jupO@gtkJddLd<-P%LKjM}~?7g%xWh*L8G91P?Vw@A!Aor$@2?bvBF zvje659bXj{Qe~4tBN5C&BDe+%fwfzh)!^|Hl7XDD8P8@H%$8PgU^t&m=JEE4{WcOa z8-C_0TOzAzdz1J3LZT3Ff=u4&#=GpuJ3TloW<%k^H_R2bv%{64lp9wwtk>=#N7z1l z8+nYqZ*SqdIIJ>kFy}RNxVHwVqt~_d=x?|m?b(7FT z{oTs?B4S}*Y)qoOx9aZFE7i9JI*to$rmB{F&Q4X;njfqO$K(29)j-jI-e)`j=oX-D z>)em)3FM@QJy2IOnQ{U|kvLMA7kCS~h>~Sw1+m--P>pyH5eXnY$S!0LGJ+I}a8Lv$ zFhenH01NO?0#+D_MS~HsJsOTZ(=rr^#>QH9KQ-cgG8~4^rz2yd>H58Fto{%_+?(Fi zs{h$^f#??38X;$xx$*7EzuIkrQ>YP|gnI;^uua%5^a+m&qrwZqed3_FSB!|`;$iWq zcuYJYej=U`e-&?tAep7DQo9t82BlGHT-qyl-&&#Le59E*JPvv>}TX{)dlX+i*Z_Iam(s$L@K)28q+D3h}gKneS>BDq@?xsUD zN+)QX9-yz#WAp?)Nk61>^h^33{efPg%k(;3rDcj!sZ*L2K~a>4ls!sBnNnU?W|dzQ zL*e~p{23 ZKWUdWL%XJ}Xg4+J(9bosb1%1A{sBKYJoW$p diff --git a/libmupen64plus/mupen64plus-input-bkm/plugin.c b/libmupen64plus/mupen64plus-input-bkm/plugin.c index 794dbc7c6c..083521be62 100644 --- a/libmupen64plus/mupen64plus-input-bkm/plugin.c +++ b/libmupen64plus/mupen64plus-input-bkm/plugin.c @@ -91,6 +91,8 @@ static unsigned char myKeyState[SDL_NUM_SCANCODES]; BUTTONS controllers[4]; +int LagFlag = 1; + #ifdef __linux__ static struct ff_effect ffeffect[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 ) { (*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].Y_AXIS = Y; +} + +EXPORT void CALL ResetLagFlag() +{ + LagFlag = 1; +} + +EXPORT int CALL CheckLagFlag() +{ + return LagFlag; } \ No newline at end of file