From 3172a3d1d43d5d1d3d42adcc63673a6d4fd1342a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 22:33:10 -0500 Subject: [PATCH] [N-Rage] fixed non-compliance to official 1.1 specs --- .../ControllerSpecs/Controller #1.1.h | 13 ++++++- Source/nragev20/NRagePluginV2.cpp | 38 ++++++++++++++----- Source/nragev20/NRagePluginV2.h | 8 ++++ 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Source/nragev20/ControllerSpecs/Controller #1.1.h b/Source/nragev20/ControllerSpecs/Controller #1.1.h index ff305862e..13a836797 100644 --- a/Source/nragev20/ControllerSpecs/Controller #1.1.h +++ b/Source/nragev20/ControllerSpecs/Controller #1.1.h @@ -16,6 +16,10 @@ extern "C" { #define PLUGIN_TYPE_CONTROLLER 4 +#ifndef SPECS_VERSION +#define SPECS_VERSION 0x0101 +#endif + /*** Conteroller plugin's ****/ #define PLUGIN_NONE 1 #define PLUGIN_MEMPAK 2 @@ -181,7 +185,14 @@ extern "C" { the emulator to know how to handle each controller. output: none *******************************************************************/ - EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); +#if (SPECS_VERSION < 0x0101) +EXPORT void CALL InitiateControllers(void * hMainWindow, CONTROL Controls[4]); +#elif (SPECS_VERSION == 0x0101) +EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); +/* Typo in the official specs, but it works! */ +#else +EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); +#endif /****************************************************************** Function: ReadController diff --git a/Source/nragev20/NRagePluginV2.cpp b/Source/nragev20/NRagePluginV2.cpp index 193a68385..4ec982240 100644 --- a/Source/nragev20/NRagePluginV2.cpp +++ b/Source/nragev20/NRagePluginV2.cpp @@ -36,7 +36,7 @@ // ProtoTypes // bool prepareHeap(); -void FillControls(CONTROL Controls[]); +void FillControls(CONTROL * Controls); void InitiatePaks( bool bInitialize ); void DoShortcut( int iPlayer, int iShortcut ); DWORD WINAPI MsgThreadFunction( LPVOID lpParam ); @@ -156,7 +156,7 @@ EXPORT void CALL GetDllInfo ( PLUGIN_INFO* PluginInfo ) sprintf(PluginInfo->Name,"N-Rage For PJ64: %s",VER_FILE_VERSION_STR); #endif PluginInfo->Type = PLUGIN_TYPE_CONTROLLER; - PluginInfo->Version = 0x0101; + PluginInfo->Version = SPECS_VERSION; } /****************************************************************** @@ -311,15 +311,36 @@ EXPORT void CALL DllTest ( HWND hParent ) the emulator to know how to handle each controller. output: none *******************************************************************/ -EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) +EXPORT void CALL InitiateControllers( +#if (SPECS_VERSION < 0x0101) + void * hMainWindow, CONTROL Controls[4] +#elif (SPECS_VERSION == 0x0101) + CONTROL_INFO ControlInfo +#else + CONTROL_INFO * ControlInfo +#endif +) { DebugWriteA("CALLED: InitiateControllers\n"); if( !prepareHeap()) return; - g_strEmuInfo.hMainWindow = ControlInfo->hMainWindow; -// g_strEmuInfo.MemoryBswaped = ControlInfo->MemoryBswaped; -// g_strEmuInfo.HEADER = ControlInfo->HEADER; +#if (SPECS_VERSION < 0x0101) + g_strEmuInfo.controllers = &Controls[0]; + g_strEmuInfo.hMainWindow = hMainWindow; + // g_strEmuInfo.MemoryBswaped = TRUE; // Or FALSE. Really does not matter. + // g_strEmuInfo.HEADER = NULL; +#elif (SPECS_VERSION == 0x0101) + g_strEmuInfo.controllers = ControlInfo.Controls; + g_strEmuInfo.hMainWindow = ControlInfo.hMainWindow; + // g_strEmuInfo.MemoryBswaped = ControlInfo.MemoryBswaped; + // g_strEmuInfo.HEADER = ControlInfo.HEADER; +#else + g_strEmuInfo.controllers = ControlInfo->Controls; + g_strEmuInfo.hMainWindow = ControlInfo->hMainWindow; + // g_strEmuInfo.MemoryBswaped = ControlInfo->MemoryBswaped; + // g_strEmuInfo.HEADER = ControlInfo->HEADER; +#endif // UNDONE: Instead of just storing the header, figure out what ROM we're running and save that information somewhere // The emulator expects us to tell what controllers are plugged in and what their paks are at this point. @@ -430,8 +451,7 @@ EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) LeaveCriticalSection( &g_critical ); - FillControls(ControlInfo->Controls); - + FillControls(g_strEmuInfo.controllers); return; } // end InitiateControllers @@ -884,7 +904,7 @@ void InitiatePaks( bool bInitialize ) // Unfortunately the spec doesn't work that way. Fixed the func and changed the func name to something that makes more sense. // FillControls takes a Controls array from InitiateControllers and fills it with what we know about whether // a controller is plugged in, accepting raw data, and what type of pak is plugged in. -void FillControls(CONTROL Controls[4]) +void FillControls(CONTROL * Controls) { for( int i = 4-1; i >= 0; i-- ) { diff --git a/Source/nragev20/NRagePluginV2.h b/Source/nragev20/NRagePluginV2.h index a9d7208de..4e57663d5 100644 --- a/Source/nragev20/NRagePluginV2.h +++ b/Source/nragev20/NRagePluginV2.h @@ -62,6 +62,14 @@ typedef struct _EMULATOR_INFO LANGID Language; bool fDisplayShortPop; // do we display shortcut message popups? +/* + * 2015.11.09 cxd4 + * Added to keep the real address of the CONTROL array stored. + * + * This became necessary due to conflicts between specs #1.0, #1.1 and #1.2. + */ + CONTROL * controllers; + // BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre // bswap on a dword (32 bits) boundry, only effects header. // eg. the first 8 bytes are stored like this: