m64p: Configure controller 1 to be plugged in. Flesh out the plugin somewhat
N64: Pass controller 1 data to the core
This commit is contained in:
parent
f535979705
commit
2a0c6c4daf
|
@ -69,11 +69,34 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
public void FrameAdvance(bool render, bool rendersound)
|
public void FrameAdvance(bool render, bool rendersound)
|
||||||
{
|
{
|
||||||
m64pFrameComplete = false;
|
m64pFrameComplete = false;
|
||||||
|
InpSetKeys(0, ReadController(1), 0, 0);
|
||||||
m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);
|
m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);
|
||||||
while (m64pFrameComplete == false) { }
|
while (m64pFrameComplete == false) { }
|
||||||
Frame++;
|
Frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ReadController(int num)
|
||||||
|
{
|
||||||
|
int buttons = 0;
|
||||||
|
|
||||||
|
if (Controller["P1 DPad R"]) buttons |= (1 << 0);
|
||||||
|
if (Controller["P1 DPad L"]) buttons |= (1 << 1);
|
||||||
|
if (Controller["P1 DPad D"]) buttons |= (1 << 2);
|
||||||
|
if (Controller["P1 DPad U"]) buttons |= (1 << 3);
|
||||||
|
if (Controller["P1 Start"]) buttons |= (1 << 4);
|
||||||
|
if (Controller["P1 Z"]) buttons |= (1 << 5);
|
||||||
|
if (Controller["P1 B"]) buttons |= (1 << 6);
|
||||||
|
if (Controller["P1 A"]) buttons |= (1 << 7);
|
||||||
|
if (Controller["P1 C Right"]) buttons |= (1 << 8);
|
||||||
|
if (Controller["P1 C Left"]) buttons |= (1 << 9);
|
||||||
|
if (Controller["P1 C Down"]) buttons |= (1 << 10);
|
||||||
|
if (Controller["P1 C Up"]) buttons |= (1 << 11);
|
||||||
|
if (Controller["P1 R"]) buttons |= (1 << 12);
|
||||||
|
if (Controller["P1 L"]) buttons |= (1 << 13);
|
||||||
|
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeterministicEmulation { get; set; }
|
public bool DeterministicEmulation { get; set; }
|
||||||
|
|
||||||
public byte[] ReadSaveRam() { return null; }
|
public byte[] ReadSaveRam() { return null; }
|
||||||
|
@ -127,6 +150,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
AudPluginShutdown();
|
AudPluginShutdown();
|
||||||
FreeLibrary(AudDll);
|
FreeLibrary(AudDll);
|
||||||
|
|
||||||
|
InpPluginShutdown();
|
||||||
|
FreeLibrary(InpDll);
|
||||||
|
|
||||||
RspPluginShutdown();
|
RspPluginShutdown();
|
||||||
FreeLibrary(RspDll);
|
FreeLibrary(RspDll);
|
||||||
|
|
||||||
|
@ -253,6 +279,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
private delegate int GetBufferSize();
|
private delegate int GetBufferSize();
|
||||||
GetBufferSize AudGetBufferSize;
|
GetBufferSize AudGetBufferSize;
|
||||||
|
|
||||||
|
// Input plugin specific
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
private delegate int SetKeys(int num, int keys, byte X, byte Y);
|
||||||
|
SetKeys InpSetKeys;
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate void ReadAudioBuffer(short[] dest);
|
private delegate void ReadAudioBuffer(short[] dest);
|
||||||
ReadAudioBuffer AudReadAudioBuffer;
|
ReadAudioBuffer AudReadAudioBuffer;
|
||||||
|
@ -269,10 +300,12 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
PluginStartup GfxPluginStartup;
|
PluginStartup GfxPluginStartup;
|
||||||
PluginStartup RspPluginStartup;
|
PluginStartup RspPluginStartup;
|
||||||
PluginStartup AudPluginStartup;
|
PluginStartup AudPluginStartup;
|
||||||
|
PluginStartup InpPluginStartup;
|
||||||
|
|
||||||
PluginShutdown GfxPluginShutdown;
|
PluginShutdown GfxPluginShutdown;
|
||||||
PluginShutdown RspPluginShutdown;
|
PluginShutdown RspPluginShutdown;
|
||||||
PluginShutdown AudPluginShutdown;
|
PluginShutdown AudPluginShutdown;
|
||||||
|
PluginShutdown InpPluginShutdown;
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void DebugCallback(IntPtr Context, int level, string Message);
|
public delegate void DebugCallback(IntPtr Context, int level, string Message);
|
||||||
|
@ -319,6 +352,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
IntPtr GfxDll;
|
IntPtr GfxDll;
|
||||||
IntPtr RspDll;
|
IntPtr RspDll;
|
||||||
IntPtr AudDll;
|
IntPtr AudDll;
|
||||||
|
IntPtr InpDll;
|
||||||
|
|
||||||
Thread m64pEmulator;
|
Thread m64pEmulator;
|
||||||
|
|
||||||
|
@ -340,6 +374,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
GfxDll = LoadLibrary("mupen64plus-video-rice.dll");
|
GfxDll = LoadLibrary("mupen64plus-video-rice.dll");
|
||||||
RspDll = LoadLibrary("mupen64plus-rsp-hle.dll");
|
RspDll = LoadLibrary("mupen64plus-rsp-hle.dll");
|
||||||
AudDll = LoadLibrary("mupen64plus-audio-bkm.dll");
|
AudDll = LoadLibrary("mupen64plus-audio-bkm.dll");
|
||||||
|
InpDll = LoadLibrary("mupen64plus-input-bkm.dll");
|
||||||
|
|
||||||
m64pCoreStartup = (CoreStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreStartup"), typeof(CoreStartup));
|
m64pCoreStartup = (CoreStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreStartup"), typeof(CoreStartup));
|
||||||
m64pCoreShutdown = (CoreShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreShutdown"), typeof(CoreShutdown));
|
m64pCoreShutdown = (CoreShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreShutdown"), typeof(CoreShutdown));
|
||||||
|
@ -361,6 +396,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
AudReadAudioBuffer = (ReadAudioBuffer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "ReadAudioBuffer"), typeof(ReadAudioBuffer));
|
AudReadAudioBuffer = (ReadAudioBuffer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "ReadAudioBuffer"), typeof(ReadAudioBuffer));
|
||||||
AudGetAudioRate = (GetAudioRate)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetAudioRate"), typeof(GetAudioRate));
|
AudGetAudioRate = (GetAudioRate)Marshal.GetDelegateForFunctionPointer(GetProcAddress(AudDll, "GetAudioRate"), typeof(GetAudioRate));
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -377,7 +416,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64
|
||||||
result = m64pCoreAttachPlugin(m64p_plugin_type.M64PLUGIN_AUDIO, AudDll);
|
result = m64pCoreAttachPlugin(m64p_plugin_type.M64PLUGIN_AUDIO, AudDll);
|
||||||
|
|
||||||
// Set up a null input plugin
|
// Set up a null input plugin
|
||||||
result = m64pCoreAttachPlugin(m64p_plugin_type.M64PLUGIN_INPUT, IntPtr.Zero);
|
result = AudPluginStartup(CoreDll, "Input", (IntPtr foo, int level, string Message) => { });
|
||||||
|
result = m64pCoreAttachPlugin(m64p_plugin_type.M64PLUGIN_INPUT, InpDll);
|
||||||
|
|
||||||
// Set up and connect the graphics plugin
|
// Set up and connect the graphics plugin
|
||||||
result = RspPluginStartup(CoreDll, "RSP", (IntPtr foo, int level, string Message) => { });
|
result = RspPluginStartup(CoreDll, "RSP", (IntPtr foo, int level, string Message) => { });
|
||||||
|
|
Binary file not shown.
|
@ -89,6 +89,8 @@ static int romopen = 0; // is a rom opened
|
||||||
|
|
||||||
static unsigned char myKeyState[SDL_NUM_SCANCODES];
|
static unsigned char myKeyState[SDL_NUM_SCANCODES];
|
||||||
|
|
||||||
|
BUTTONS controllers[4];
|
||||||
|
|
||||||
#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];
|
||||||
|
@ -355,6 +357,7 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
Function: GetKeys
|
Function: GetKeys
|
||||||
Purpose: To get the current state of the controllers buttons.
|
Purpose: To get the current state of the controllers buttons.
|
||||||
|
@ -365,7 +368,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 )
|
||||||
{
|
{
|
||||||
// Use a call back function here, or look up a buffer
|
(*Keys).Value = controllers[Control].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -380,12 +383,18 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
|
||||||
EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
|
EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
memset( controller, 0, sizeof( SController ) * 4 );
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
controller[i].control = ControlInfo.Controls + i;
|
||||||
|
|
||||||
for( i = 0; i < 4; i++ )
|
for( i = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
controller[i].control->Plugin = PLUGIN_MEMPAK;
|
controller[i].control->Plugin = PLUGIN_MEMPAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controller[0].control->Present = 1;
|
||||||
|
|
||||||
DebugMessage(M64MSG_INFO, "%s version %i.%i.%i initialized.", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION));
|
DebugMessage(M64MSG_INFO, "%s version %i.%i.%i initialized.", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,3 +464,23 @@ EXPORT void CALL SDL_KeyUp(int keymod, int keysym)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT void CALL SetKeys(int num, int keys, unsigned char X, char Y)
|
||||||
|
{
|
||||||
|
controllers[num].R_DPAD = (keys >> 0) & 0x01;
|
||||||
|
controllers[num].L_DPAD = (keys >> 1) & 0x01;
|
||||||
|
controllers[num].U_DPAD = (keys >> 2) & 0x01;
|
||||||
|
controllers[num].D_DPAD = (keys >> 3) & 0x01;
|
||||||
|
controllers[num].START_BUTTON = (keys >> 4) & 0x01;
|
||||||
|
controllers[num].Z_TRIG = (keys >> 5) & 0x01;
|
||||||
|
controllers[num].B_BUTTON = (keys >> 6) & 0x01;
|
||||||
|
controllers[num].A_BUTTON = (keys >> 7) & 0x01;
|
||||||
|
controllers[num].R_CBUTTON = (keys >> 8) & 0x01;
|
||||||
|
controllers[num].L_CBUTTON = (keys >> 9) & 0x01;
|
||||||
|
controllers[num].U_CBUTTON = (keys >> 10) & 0x01;
|
||||||
|
controllers[num].D_CBUTTON = (keys >> 11) & 0x01;
|
||||||
|
controllers[num].R_TRIG = (keys >> 12) & 0x01;
|
||||||
|
controllers[num].L_TRIG = (keys >> 13) & 0x01;
|
||||||
|
|
||||||
|
controllers[num].X_AXIS = 0;
|
||||||
|
controllers[num].Y_AXIS = 0;
|
||||||
|
}
|
Loading…
Reference in New Issue