From a247ffe6b11079acdce0b73855ce5126720ae5da Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Mar 2015 18:47:32 -0400 Subject: [PATCH] [PJ64 NRage] some scope and spacing formatting clean-ups --- Source/nragev20/DirectInput.cpp | 16 ++-- Source/nragev20/FileAccess.cpp | 6 +- Source/nragev20/GBCart.cpp | 111 +++++++++++++++++---------- Source/nragev20/Interface.cpp | 50 ++++-------- Source/nragev20/International.cpp | 48 +++++++----- Source/nragev20/NRagePluginV2.cpp | 34 ++++---- Source/nragev20/PakIO.cpp | 100 ++++++++++++------------ Source/nragev20/XInputController.cpp | 2 +- 8 files changed, 192 insertions(+), 175 deletions(-) diff --git a/Source/nragev20/DirectInput.cpp b/Source/nragev20/DirectInput.cpp index 14d1b1ba9..006f2218b 100644 --- a/Source/nragev20/DirectInput.cpp +++ b/Source/nragev20/DirectInput.cpp @@ -497,11 +497,15 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) } - if (pcController->bRapidFireEnabled) { - if (pcController->bRapidFireCounter >= pcController->bRapidFireRate) { + if (pcController->bRapidFireEnabled) + { + if (pcController->bRapidFireCounter >= pcController->bRapidFireRate) + { w_Buttons = (w_Buttons & 0xFF1F); pcController->bRapidFireCounter = 0; - } else{ + } + else + { pcController->bRapidFireCounter = pcController->bRapidFireCounter + 1; } } @@ -545,7 +549,6 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData ) MAKEWORD( (BYTE)(min( max( MINAXISVALUE, (long)(lAxisValueX * d_ModifierX )), MAXAXISVALUE) / N64DIVIDER ), (BYTE)(min( max( MINAXISVALUE, (long)(lAxisValueY * d_ModifierY )), MAXAXISVALUE) / N64DIVIDER ))); } - return true; } @@ -745,7 +748,7 @@ BOOL CALLBACK EnumSetObjectsAxis( LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef diprg.diph.dwObj = lpddoi->dwType; diprg.lMin = MINAXISVALUE; diprg.lMax = MAXAXISVALUE; - + lpDirectInputDevice->SetProperty(DIPROP_RANGE, &diprg.diph); // HACK: Usually works, but not all devices support setting range. return DIENUM_CONTINUE; @@ -788,7 +791,6 @@ bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID switch( LOBYTE(dwDevType) ) { - case DI8DEVTYPE_KEYBOARD: ppDiDataFormat = &c_dfDIKeyboard; break; @@ -1130,7 +1132,7 @@ HRESULT DirectRumbleCommand( LPDIRECTINPUTDEVICE8 lpDirectInputDevice, DWORD cmd esc.dwCommand = ADAPT_RUMBLE; // send rumble command esc.lpvInBuffer = &cmd; // 1=go, 0=stop esc.cbInBuffer = 4; - esc.lpvOutBuffer = NULL; + esc.lpvOutBuffer = NULL; esc.cbOutBuffer = 0; HRESULT hr = lpDirectInputDevice->Escape(&esc); diff --git a/Source/nragev20/FileAccess.cpp b/Source/nragev20/FileAccess.cpp index ab47ac27c..a08104dac 100644 --- a/Source/nragev20/FileAccess.cpp +++ b/Source/nragev20/FileAccess.cpp @@ -604,7 +604,6 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic } break; - } return bReturn; @@ -1146,7 +1145,8 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave ) return false; } - for ( ; nFilters > 0; nFilters--) { + for ( ; nFilters > 0; nFilters--) + { pszTemp += _tcslen(pszTemp); pszTemp += 1; pszTemp += _tcslen(pszTemp); @@ -1160,7 +1160,6 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave ) szInitialDir[MAX_PATH+1] = _T(""), *pcSlash; - if( pszFileName[1] == _T(':') || ( pszFileName[1] == _T('\\') && pszFileName[0] == _T('\\') )) { lstrcpyn( szInitialDir, pszFileName, ARRAYSIZE(szInitialDir) ); @@ -1178,7 +1177,6 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave ) lstrcpyn( szFileName, pszFileName, ARRAYSIZE(szFileName) ); } - OPENFILENAME oFile; oFile.lStructSize = sizeof (OPENFILENAME); diff --git a/Source/nragev20/GBCart.cpp b/Source/nragev20/GBCart.cpp index b06d06dec..8b5600825 100644 --- a/Source/nragev20/GBCart.cpp +++ b/Source/nragev20/GBCart.cpp @@ -32,15 +32,18 @@ bool WriteCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data); // Tries to read RTC data from separate file (not integrated into SAV) // success sets the useTDF flag // failure inits the RTC at zero and maybe throws a warning -void ReadTDF(LPGBCART Cart) { +void ReadTDF(LPGBCART Cart) +{ } -void WriteTDF(LPGBCART Cart) { +void WriteTDF(LPGBCART Cart) +{ // check useTDF flag // write data from RTC to TDF file } -void UpdateRTC(LPGBCART Cart) { +void UpdateRTC(LPGBCART Cart) +{ time_t now, dif; int days; @@ -57,13 +60,17 @@ void UpdateRTC(LPGBCART Cart) { days = (int)(Cart->TimerData[3] + ((Cart->TimerData[4] & 1) << 8) + dif); Cart->TimerData[3] = (days & 0xFF); - if(days > 255) { - if(days > 511) { + if (days > 255) + { + if (days > 511) + { days &= 511; Cart->TimerData[4] |= 0x80; } if (days > 255) - Cart->TimerData[4] = (Cart->TimerData[4] & 0xFE) | (days > 255 ? 1 : 0); + { + Cart->TimerData[4] = (Cart->TimerData[4] & 0xFE) | (days > 255 ? 1 : 0); + } } Cart->timerLastUpdate = now; @@ -103,7 +110,9 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T dwFilesize = GetFileSize(hTemp, NULL); CloseHandle(hTemp); Cart->RomData = (const unsigned char *)MapViewOfFile( Cart->hRomFile, FILE_MAP_READ, 0, 0, 0 ); - } else { + } + else + { DebugWriteA("Couldn't load the ROM file, GetLastError returned %08x\n", GetLastError()); if (hTemp != INVALID_HANDLE_VALUE) CloseHandle(hTemp); // if file size was zero, make sure we don't leak the handle @@ -124,7 +133,8 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T DebugWriteA(" Cartridge Type #:"); DebugWriteByteA(Cart->RomData[0x147]); DebugWriteA("\n"); - switch (Cart->RomData[0x147]) { // if we hadn't checked the file size before, this might have caused an access violation + switch (Cart->RomData[0x147]) + { // if we hadn't checked the file size before, this might have caused an access violation case 0x00: Cart->iCartType = GB_NORM; Cart->bHasRam = false; @@ -287,7 +297,8 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T } // assign read/write handlers - switch (Cart->iCartType) { + switch (Cart->iCartType) + { case GB_NORM: // Raw cartridge Cart->ptrfnReadCart = &ReadCartNorm; Cart->ptrfnWriteCart = &WriteCartNorm; @@ -318,7 +329,8 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T // Determine ROM size for paging checks Cart->iNumRomBanks = 2; - switch (Cart->RomData[0x148]) { + switch (Cart->RomData[0x148]) + { case 0x01: Cart->iNumRomBanks = 4; break; @@ -397,11 +409,13 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T if( hTemp == INVALID_HANDLE_VALUE ) {// test if Read-only access is possible hTemp = CreateFile( RamFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); - if (Cart->bHasTimer && Cart->bHasBattery) { + if (Cart->bHasTimer && Cart->bHasBattery) + { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); } - else { + else + { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); ClearData(Cart->RamData, NumQuarterBlocks * 0x0800); } @@ -421,7 +435,9 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T WarningMessage( IDS_ERR_GBSRAMERR, MB_OK | MB_ICONWARNING); return true; } - } else { // file is OK, use a mapping + } + else + { // file is OK, use a mapping if (Cart->bHasTimer && Cart->bHasBattery) Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), NULL); else @@ -430,15 +446,21 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T if (Cart->hRamFile != NULL) { Cart->RamData = (LPBYTE)MapViewOfFile( Cart->hRamFile, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); - } else { // could happen, if the file isn't big enough AND can't be grown to fit + } + else + { // could happen, if the file isn't big enough AND can't be grown to fit DWORD dwBytesRead; - if (Cart->bHasTimer && Cart->bHasBattery) { + if (Cart->bHasTimer && Cart->bHasBattery) + { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), &dwBytesRead, NULL); - } else { + } + else + { Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800, &dwBytesRead, NULL); } + if (dwBytesRead < NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0)) { ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0)); @@ -451,9 +473,11 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T } } - if (Cart->bHasTimer && Cart->bHasBattery) { + if (Cart->bHasTimer && Cart->bHasBattery) + { dwFilesize = GetFileSize(hTemp, 0); - if (dwFilesize >= (NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC) ) ) { + if (dwFilesize >= (NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC) ) ) + { // Looks like there is extra data in the SAV file than just RAM data... assume it is RTC data. gbCartRTC RTCTimer; CopyMemory( &RTCTimer, &Cart->RamData[NumQuarterBlocks * 0x0800], sizeof(RTCTimer) ); @@ -470,13 +494,16 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T Cart->timerLastUpdate = RTCTimer.mapperLastTime; UpdateRTC(Cart); } - else { + else + { ReadTDF(Cart); // try to open TDF format, clear/init Cart->TimerData if that fails } } CloseHandle(hTemp); - } else { + } + else + { // no battery; just allocate some RAM Cart->RamData = (LPBYTE)P_malloc(Cart->iNumRamBanks * 0x2000); } @@ -582,8 +609,8 @@ bool ReadCartMBC1(LPGBCART Cart, WORD dwAddress, BYTE *Data) } else if ((dwAddress >= 0xA000) && (dwAddress <= 0xBFFF)) { - if (Cart->bHasRam) - { // && Cart->bRamEnableState) { + if (Cart->bHasRam/* && Cart->bRamEnableState)*/) + { if (Cart->iCurrentRamBankNo >= Cart->iNumRamBanks) { ZeroMemory(Data, 32); @@ -742,7 +769,8 @@ bool WriteCartMBC2(LPGBCART Cart, WORD dwAddress, BYTE *Data) else if ((dwAddress >= 0x2000) && (dwAddress <= 0x3FFF)) // ROM bank select { Cart->iCurrentRomBankNo = Data[0] & 0x0F; - if (Cart->iCurrentRomBankNo == 0) { + if (Cart->iCurrentRomBankNo == 0) + { Cart->iCurrentRomBankNo = 1; } DebugWriteA("Set ROM Bank: %02X\n", Cart->iCurrentRomBankNo); @@ -820,12 +848,13 @@ bool ReadCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) { CopyMemory(Data, &Cart->RamData[dwAddress - 0xA000 + (Cart->iCurrentRamBankNo * 0x2000)], 32); DebugWriteA("RAM read: Bank %02X\n", Cart->iCurrentRamBankNo); - } - //else { - // ZeroMemory(Data, 32); - // //for (i=0; i<32; i++) Data[i] = 0; - // DebugWriteA("Failed RAM read: (RAM not active)\n"); - //} + }/* + else + { + ZeroMemory(Data, 32); + //for (i=0; i<32; i++) Data[i] = 0; + DebugWriteA("Failed RAM read: (RAM not active)\n"); + }*/ } else { @@ -918,7 +947,6 @@ bool WriteCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data) // Done bool ReadCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data) { - if ((dwAddress < 0x4000)) //Rom Bank 0 { CopyMemory(Data, &Cart->RomData[dwAddress], 32); @@ -1029,9 +1057,10 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile) DWORD NumQuarterBlocks = 0; gbCartRTC RTCTimer; - if (Cart->bHasRam && Cart->bHasBattery) { - // Write only the bytes that NEED writing! - switch (Cart->RomData[0x149]) { + if (Cart->bHasRam && Cart->bHasBattery) + { // Write only the bytes that NEED writing! + switch (Cart->RomData[0x149]) + { case 1: NumQuarterBlocks = 1; break; @@ -1046,7 +1075,8 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile) break; } FlushViewOfFile( Cart->RamData, NumQuarterBlocks * 0x0800 ); - if (Cart->bHasTimer) { + if (Cart->bHasTimer) + { // Save RTC in VisualBoy Advance format // TODO: Check if VBA saves are compatible with other emus. // TODO: Only write RTC data if VBA RTC data was originaly present @@ -1063,8 +1093,7 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile) RTCTimer.mapperLastTime = Cart->timerLastUpdate; CopyMemory(Cart->RamData + NumQuarterBlocks * 0x0800, &RTCTimer, sizeof(RTCTimer)); - - FlushViewOfFile( Cart->RamData + NumQuarterBlocks * 0x0800, sizeof(gbCartRTC)); + FlushViewOfFile(Cart->RamData + NumQuarterBlocks * 0x0800, sizeof(gbCartRTC)); } } return true; @@ -1105,10 +1134,14 @@ void ClearData(BYTE *Data, int Length) { int i; - for (i=0; ifXInput ? BST_CHECKED : BST_UNCHECKED ); if( hTabControl ) - DestroyWindow( hTabControl ); + DestroyWindow( hTabControl ); + if( pcController->fXInput ) hTabControl = CreateDialog ( g_hResourceDLL, MAKEINTRESOURCE( IDD_XCONTROLS ), hDlg, XControlsTabProc ); else hTabControl = CreateDialog( g_hResourceDLL, MAKEINTRESOURCE( IDD_CONTROLS ), hDlg, ControlsTabProc ); + { hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); @@ -583,7 +585,6 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( hTabControl ) SendMessage( hTabControl, WM_USER_UPDATE, 0, 0 ); return TRUE; - default: return FALSE; //false means the msg didn't got processed } @@ -718,7 +719,6 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara LeaveCriticalSection(&g_critical); - GetButtonText( aButtons[dwButtonID[2]], szBuffer ); SendMessage( GetDlgItem( hDlg, dwButtonID[1] ), WM_SETTEXT , 0, (LPARAM)szBuffer ); if( hFocus != NULL ) @@ -770,7 +770,6 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara aButtons = g_ivConfig->Controllers[g_ivConfig->ChosenTab].aButton; LeaveCriticalSection(&g_critical); - if( wParam == 0 ) { CheckDlgButton( hDlg, IDC_N64RANGE, g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRealN64Range ? BST_CHECKED : BST_UNCHECKED ); @@ -779,7 +778,6 @@ BOOL CALLBACK ControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara CheckDlgButton( hDlg, IDC_CONFIG2, ( g_ivConfig->Controllers[g_ivConfig->ChosenTab].bAxisSet == 1 ) ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_CONFIG3, ( g_ivConfig->Controllers[g_ivConfig->ChosenTab].bAxisSet == 2 ) ? BST_CHECKED : BST_UNCHECKED ); - SendMessage( GetDlgItem( hDlg, IDC_CTRRANGE ), TBM_SETPOS, TRUE, g_ivConfig->Controllers[g_ivConfig->ChosenTab].bStickRange ); LoadString( g_hResourceDLL, IDS_C_RANGE, szTemp, 40 ); wsprintf( szBuffer, szTemp, g_ivConfig->Controllers[g_ivConfig->ChosenTab].bStickRange ); @@ -842,7 +840,6 @@ BOOL CALLBACK XControlsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar if( !ReadXInputControllerKeys( hDlg, gController )) for( int i = IDC_XC_A; i <= IDC_XC_RTS; i++ ) SendDlgItemMessage( hDlg, i, CB_SETCURSEL, 0, ( LPARAM )0 ); - return TRUE; case WM_COMMAND: @@ -980,10 +977,12 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_UNCHECKED ); + if( pcController->bMouseMoveX == MM_BUFF ) CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_UNCHECKED ); + if( pcController->bMouseMoveX == MM_ABS ) CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEX, BST_CHECKED ); else @@ -993,10 +992,12 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_UNCHECKED ); + if( pcController->bMouseMoveY == MM_BUFF ) CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_UNCHECKED ); + if( pcController->bMouseMoveY == MM_ABS ) CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEY, BST_CHECKED ); else @@ -1030,7 +1031,6 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { - HWND hDlgItem; long i,j; DWORD dwValue; @@ -1065,20 +1065,18 @@ BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP case WM_VSCROLL: switch (GetWindowLong( (HWND)lParam, GWL_ID )) { - case IDC_XMODIFIER: + case IDC_XMODIFIER: i = SendMessage( (HWND)lParam, TBM_GETPOS, 0, 0 ); LoadString( g_hResourceDLL, IDS_M_MOVEVALUE, szTemp, DEFAULT_BUFFER ); wsprintf( szBuffer, szTemp, i ); SendMessage( GetDlgItem( hDlg, IDT_XMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer ); return TRUE; - - case IDC_YMODIFIER: + case IDC_YMODIFIER: i = SendMessage( (HWND)lParam, TBM_GETPOS, 0, 0 ); LoadString( g_hResourceDLL, IDS_M_MOVEVALUE, szTemp, DEFAULT_BUFFER ); wsprintf( szBuffer, szTemp, i ); SendMessage( GetDlgItem( hDlg, IDT_YMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer ); return TRUE; - default: return FALSE; } @@ -1399,7 +1397,6 @@ void ModDescription( HWND hListView, int iEntry, const LPMODIFIER pModifier ) szBuffer[0] = '\0'; } ListView_SetItemText( hListView, iEntry, 2, szBuffer ); - } BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) @@ -2571,7 +2568,6 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam bMatch = true; } - if (!bMatch && g_devList[i].bEffType != 0 ) { if( g_devList[i].bProductCounter == 0 ) @@ -2667,10 +2663,12 @@ BOOL CALLBACK RumblePakProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam CheckDlgButton( hDlg, IDC_RUMBLE1, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_RUMBLE1, BST_UNCHECKED ); + if( pcController->bRumbleTyp == RUMBLE_EFF2 ) CheckDlgButton( hDlg, IDC_RUMBLE2, BST_CHECKED ); else CheckDlgButton( hDlg, IDC_RUMBLE2, BST_UNCHECKED ); + if( pcController->bRumbleTyp == RUMBLE_EFF3 ) CheckDlgButton( hDlg, IDC_RUMBLE3, BST_CHECKED ); else @@ -2785,7 +2783,6 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar switch(uMsg) { case WM_INITDIALOG: - bScanRunning = false; iPlayer = 5; @@ -3069,7 +3066,6 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( szBuffer[0] != 0 && ( szBuffer[1] == ':' || ( szBuffer[1] == '\\' && szBuffer[0] == '\\' ))) { - CheckDlgButton( hDlg, IDC_MEMPAK_ABS, BST_CHECKED ); GetDirectory( szBuffer, DIRECTORY_MEMPAK ); @@ -3093,7 +3089,6 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SendMessage( GetDlgItem( hDlg, IDC_MEMPAK_REL_EDIT ), WM_SETTEXT, 0, (LPARAM)STRING_DEF_MEMPAKFILE ); } - GetDirectory( szBuffer, DIRECTORY_MEMPAK ); pcSlash = _tcsrchr( szBuffer, '\\' ); if( pcSlash && ( pcSlash[1] == '\0' )) *pcSlash = '\0'; @@ -3132,7 +3127,6 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0'; SendMessage( GetDlgItem( hDlg, IDC_GBROM_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); - // GBSave Directory lstrcpyn(szBuffer, g_aszDefFolders[DIRECTORY_GBSAVES], MAX_PATH); @@ -3171,13 +3165,11 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - GetDirectory( szBuffer, DIRECTORY_GBSAVES ); pcSlash = _tcsrchr( szBuffer, _T('\\') ); if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0'; SendMessage( GetDlgItem( hDlg, IDC_GBSAVE_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); - return FALSE; // don't give it focus case WM_COMMAND: @@ -3312,8 +3304,6 @@ BOOL CALLBACK FoldersDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - - /////////////////////////////////////////////////////////////////////////////// // A wonderful n squared algorithm to store the key names in a string... what for??? // called by EnumObjects in MainDlgProcess to enumerate the keys on the keyboard...? @@ -3486,7 +3476,6 @@ bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) wsprintf(Text[1], buff, btnButton.bOffset - 7 ); Text[2] = AxeID[2 + btnButton.bAxisID]; break; - case DT_KEYBUTTON: LoadString( g_hResourceDLL, iDevice[2], Text[0], 16 ); //TODO: this is great! can we do this for all of them? @@ -3496,20 +3485,17 @@ bool GetButtonText( const BUTTON& btnButton, LPTSTR Buffer ) LoadString( g_hResourceDLL, IDS_C_UNKNOWN, Text[1], 16 ); Text[2] = TEXT( "" ); break; - case DT_MOUSEBUTTON: LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 ); LoadString( g_hResourceDLL, iMouse[3], Text[1], 16 ); Text[2] = Btn; wsprintf( Btn, TEXT( "%02u" ), btnButton.bOffset ); break; - case DT_MOUSEAXE: LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 ); LoadString( g_hResourceDLL, iMouse[btnButton.bOffset], Text[1], 16 ); Text[2] = AxeID[btnButton.bAxisID]; break; - case DT_UNASSIGNED: default: LoadString( g_hResourceDLL, iDevice[0], Text[0], 16 ); @@ -3574,7 +3560,6 @@ DWORD ScanMouse( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton ) return FALSE; } - if ( bFirstScan ) { CopyMemory( rgbInitButtons, dm_Current.rgbButtons, sizeof(rgbInitButtons)); @@ -3650,8 +3635,8 @@ DWORD ScanGamePad ( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton, in hr = lpDevice->didHandle->GetDeviceState( sizeof(DIJOYSTATE), &lpDevice->stateAs.joyState ); if ( FAILED(hr) ) { - hr = lpDevice->didHandle->Acquire(); - return FALSE; + hr = lpDevice->didHandle->Acquire(); + return FALSE; } if ( bFirstScan ) @@ -3971,7 +3956,6 @@ void UpdateControllerStructures() g_pcControllers[i].guidFFDevice = GUID_NULL; } - g_pcControllers[i].fPakCRCError = false; g_pcControllers[i].fPakInitialized = false; @@ -3986,7 +3970,8 @@ LRESULT CALLBACK BlockerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; - switch (msg) { + switch (msg) + { case WM_CREATE: return 0; case WM_PAINT: @@ -4027,7 +4012,6 @@ BOOL InitOverlay(void) HWND MakeOverlay() { HWND hwnd; - RECT size; GetWindowRect(g_hMainDialog, &size); @@ -4046,8 +4030,8 @@ HWND MakeOverlay() g_hMainDialog, // owner window (HMENU) NULL, // menu g_strEmuInfo.hinst, // handle to application instance - (LPVOID) NULL); // window-creation data - + (LPVOID) NULL // window-creation data + ); if (!hwnd) return NULL; diff --git a/Source/nragev20/International.cpp b/Source/nragev20/International.cpp index 846f08922..2a2a69dae 100644 --- a/Source/nragev20/International.cpp +++ b/Source/nragev20/International.cpp @@ -49,9 +49,10 @@ HMODULE LoadLanguageDLL(LANGID DesiredLanguage) hDLL = LoadLibraryEx(SatellitePath, 0, 0); if( hDLL ) return hDLL; - else { // try the primary language ID + else + { // try the primary language ID DesiredLanguage = PRIMARYLANGID(DesiredLanguage); - _stprintf(SatellitePath, _T("NRage-Language-%u.dll"), DesiredLanguage); + _stprintf(SatellitePath, _T("NRage-Language-%u.dll"), DesiredLanguage); hDLL = LoadLibraryEx(SatellitePath, 0, 0); if( hDLL ) return hDLL; @@ -83,25 +84,25 @@ BOOL CALLBACK EnumLangProc(HANDLE hModule, LPCTSTR lpszType, LPCTSTR lpszName, // the Hongkong SAR version LANGID GetNTDLLNativeLangID() { - LANGINFO LangInfo; - LPCTSTR Type = (LPCTSTR) ((LPVOID)((WORD)16)); + LPCTSTR Type = (LPCTSTR) ((LPVOID)((WORD)16)); LPCTSTR Name = (LPCTSTR) 1; ZeroMemory(&LangInfo,sizeof(LangInfo)); - + // Get the HModule for ntdll. HMODULE hMod = GetModuleHandle(_T("ntdll.dll")); - if (hMod==NULL) { + if (hMod==NULL) + { return(0); } BOOL result = EnumResourceLanguages(hMod, Type, Name, (ENUMRESLANGPROC)EnumLangProc, (LONG_PTR) &LangInfo); - - if (!result || (LangInfo.Count > 2) || (LangInfo.Count < 1) ) { + + if (!result || (LangInfo.Count > 2) || (LangInfo.Count < 1) ) + { return (0); } - return (LangInfo.LangID); } @@ -114,7 +115,8 @@ BOOL IsHongKongVersion() IMMRELEASECONTEXT pImmReleaseContext; hMod = LoadLibrary(_T("imm32.dll")); - if (hMod) { + if (hMod) + { pImmReleaseContext = (IMMRELEASECONTEXT)GetProcAddress(hMod,"ImmReleaseContext"); if (pImmReleaseContext) { bRet = pImmReleaseContext(NULL,0); @@ -137,12 +139,12 @@ LANGID DetectLanguage() DWORD Type, BuffLen = MAX_KEY_BUFFER; TCHAR LangKeyValue[MAX_KEY_BUFFER]; - VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if( !GetVersionEx(&VersionInfo) ) return(0); - switch( VersionInfo.dwPlatformId ) { + switch( VersionInfo.dwPlatformId ) + { // On Windows NT, Windows 2000 or higher case VER_PLATFORM_WIN32_NT: if( VersionInfo.dwMajorVersion >= 5) // Windows 2000 or higher @@ -156,10 +158,13 @@ LANGID DetectLanguage() uiLangID = fpGetLang(); } // and if we couldn't load kernel32.dll, just fall back to default language } - else { // for NT4 check the language of ntdll.dll + else + { // for NT4 check the language of ntdll.dll uiLangID = GetNTDLLNativeLangID(); - if (uiLangID == 1033) { // special processing for Honkong SAR version of NT4 - if (IsHongKongVersion()) { + if (uiLangID == 1033) + { // special processing for Honkong SAR version of NT4 + if (IsHongKongVersion()) + { uiLangID = 3076; } } @@ -169,13 +174,15 @@ LANGID DetectLanguage() case VER_PLATFORM_WIN32_WINDOWS: // Open the registry key for the UI language if( RegOpenKeyEx(HKEY_CURRENT_USER,_T("Default\\Control Panel\\Desktop\\ResourceLocale"), 0, - KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS ) { + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS ) + { // Get the type of the default key if( RegQueryValueEx(hKey, NULL, NULL, &Type, NULL, NULL) == ERROR_SUCCESS - && Type == REG_SZ ) { - // Read the key value + && Type == REG_SZ ) + { // Read the key value if( RegQueryValueEx(hKey, NULL, NULL, &Type, (LPBYTE)LangKeyValue, &BuffLen) - == ERROR_SUCCESS ) { + == ERROR_SUCCESS ) + { uiLangID = _ttoi(LangKeyValue); } } @@ -184,7 +191,8 @@ LANGID DetectLanguage() break; } - if (uiLangID == 0) { + if (uiLangID == 0) + { uiLangID = GetUserDefaultLangID(); } // Return the found language ID. diff --git a/Source/nragev20/NRagePluginV2.cpp b/Source/nragev20/NRagePluginV2.cpp index c998d8e32..f63a1fbb4 100644 --- a/Source/nragev20/NRagePluginV2.cpp +++ b/Source/nragev20/NRagePluginV2.cpp @@ -236,7 +236,8 @@ EXPORT void CALL DllConfig ( HWND hParent ) } EnterCriticalSection( &g_critical ); - if( g_sysMouse.didHandle ) { // unlock mouse while configuring + if( g_sysMouse.didHandle ) + { // unlock mouse while configuring g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_DEVICE ); g_sysMouse.didHandle->Acquire(); } @@ -258,8 +259,10 @@ EXPORT void CALL DllConfig ( HWND hParent ) InitiatePaks( false ); // only re-init the mempaks and such if the user clicked Save or Use } - if( g_sysMouse.didHandle ) { - if ( g_bExclusiveMouse ) { // if we have exclusive mouse, we need to relock mouse after closing the config + if( g_sysMouse.didHandle ) + { + if ( g_bExclusiveMouse ) + { // if we have exclusive mouse, we need to relock mouse after closing the config g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); g_sysMouse.didHandle->Acquire(); if (g_strEmuInfo.fDisplayShortPop) @@ -270,7 +273,8 @@ EXPORT void CALL DllConfig ( HWND hParent ) CreateThread(NULL, 0, MsgThreadFunction, g_pszThreadMessage, 0, NULL); } } - else { + else + { g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_KEYBOARD ); g_sysMouse.didHandle->Acquire(); } @@ -413,7 +417,8 @@ EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) PrepareInputDevices(); - if( g_bExclusiveMouse ) { + if( g_bExclusiveMouse ) + { // g_sysMouse.didHandle->Unacquire(); // g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); // PrepareInputDevices does this. g_sysMouse.didHandle->Acquire(); @@ -448,7 +453,7 @@ EXPORT void CALL RomOpen (void) ErrorMessage(IDS_ERR_NOINIT, 0, false); return; } - + EnterCriticalSection( &g_critical ); // re-init our paks and shortcuts InitiatePaks( true ); @@ -517,7 +522,8 @@ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ) { EnterCriticalSection( &g_critical ); - if( g_pcControllers[Control].fPlugged ) { + if( g_pcControllers[Control].fPlugged ) + { if (Control == g_iFirstController ) { GetDeviceDatas(); @@ -667,8 +673,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) GetNControllerInput( Control, (DWORD*)&Command[3] ); } break; - - case RD_READPAK: #ifdef ENABLE_RAWPAK_DEBUG WriteDatasA( "ReadPak-PreProcessing", Control, Command, 0); @@ -688,7 +692,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) DebugWriteA( NULL ); #endif break; - case RD_WRITEPAK: #ifdef ENABLE_RAWPAK_DEBUG WriteDatasA( "WritePak-PreProcessing", Control, Command, 0); @@ -707,7 +710,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) DebugWriteA( NULL ); #endif break; - case RD_READEEPROM: // Should be handled by the Emulator WriteDatasA( "ReadEeprom-PreProcessing", Control, Command, 0); @@ -720,7 +722,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command ) WriteDatasA( "WriteEeprom-PostProcessing", Control, Command, 0); DebugWriteA( NULL ); break; - default: // only accessible if the Emulator has bugs.. or maybe the Rom is flawed WriteDatasA( "ReadController: Bad read", Control, Command, 0); @@ -1003,7 +1004,6 @@ void DoShortcut( int iControl, int iShortcut ) LoadString( g_hResourceDLL, IDS_P_NONE, pszMessage, ARRAYSIZE(pszMessage) ); LeaveCriticalSection( &g_critical ); break; - case SC_MEMPAK: if (PAK_NONE == g_pcControllers[iControl].PakType) { @@ -1018,7 +1018,6 @@ void DoShortcut( int iControl, int iShortcut ) bEjectFirst = true; } break; - case SC_RUMBPAK: if (PAK_NONE == g_pcControllers[iControl].PakType) { @@ -1060,7 +1059,6 @@ void DoShortcut( int iControl, int iShortcut ) bEjectFirst = true; } break; - case SC_VOICEPAK: if (PAK_NONE == g_pcControllers[iControl].PakType) { @@ -1076,7 +1074,6 @@ void DoShortcut( int iControl, int iShortcut ) bEjectFirst = true; } break; - case SC_ADAPTPAK: if (PAK_NONE == g_pcControllers[iControl].PakType) { @@ -1092,7 +1089,6 @@ void DoShortcut( int iControl, int iShortcut ) bEjectFirst = true; } break; - case SC_SWMEMRUMB: bEjectFirst = true; if( g_pcControllers[iControl].PakType == PAK_MEM ) @@ -1104,7 +1100,6 @@ void DoShortcut( int iControl, int iShortcut ) iShortcut = PAK_MEM; } break; - case SC_SWMEMADAPT: bEjectFirst = true; if( g_pcControllers[iControl].PakType == PAK_MEM ) @@ -1116,7 +1111,6 @@ void DoShortcut( int iControl, int iShortcut ) iShortcut = PAK_MEM; } break; - default: DebugWriteA("Invalid iShortcut passed to DoShortcut\n"); EnterCriticalSection( &g_critical ); @@ -1144,7 +1138,7 @@ void DoShortcut( int iControl, int iShortcut ) CreateThread(NULL, 0, DelayedShortcut, lpmNextShortcut, 0, NULL); iControl = -2; // this is just a hack to get around the check that appends "Changing Pak X to ..." } - + if( g_strEmuInfo.fDisplayShortPop && _tcslen(pszMessage) > 0 ) { if( iControl >= 0 ) diff --git a/Source/nragev20/PakIO.cpp b/Source/nragev20/PakIO.cpp index 6e6a8b5d6..efc621e81 100644 --- a/Source/nragev20/PakIO.cpp +++ b/Source/nragev20/PakIO.cpp @@ -199,7 +199,6 @@ bool InitControllerPak( const int iControl ) } } break; - case PAK_RUMBLE: { g_pcControllers[iControl].pPakData = P_malloc( sizeof(RUMBLEPAK)); @@ -233,7 +232,6 @@ bool InitControllerPak( const int iControl ) * Here, both files should be opened and the handles stored in tPak ( modify the struct for Your own purposes, only bPakType must stay at first ) */ - //CreateFile( g_pcControllers[iControl].szTransferSave, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); tPak->iCurrentAccessMode = 0; tPak->iCurrentBankNo = 0; @@ -242,16 +240,18 @@ bool InitControllerPak( const int iControl ) tPak->bPakInserted = LoadCart( &tPak->gbCart, g_pcControllers[iControl].szTransferRom, g_pcControllers[iControl].szTransferSave, _T("") ); - if (tPak->bPakInserted) { + if (tPak->bPakInserted) + { DebugWriteA( "*** Init Transfer Pak - Success***\n" ); - } else { + } + else + { DebugWriteA( "*** Init Transfer Pak - FAILURE***\n" ); } bReturn = true; } break; - /*case PAK_VOICE: { g_pcControllers[iControl].pPakData = P_malloc( sizeof(VOICEPAK)); @@ -261,7 +261,6 @@ bool InitControllerPak( const int iControl ) bReturn = true; } break;*/ - case PAK_ADAPTOID: if( !g_pcControllers[iControl].fIsAdaptoid ) g_pcControllers[iControl].PakType = PAK_NONE; @@ -281,8 +280,6 @@ bool InitControllerPak( const int iControl ) bReturn = true; } break; - - /*case PAK_NONE: break;*/ } @@ -338,7 +335,7 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) FillMemory( Data, 32, 0x80 ); else ZeroMemory( Data, 32 ); - + if( g_pcControllers[iControl].fXInput ) // xinput controller rumble --tecnicors VibrateXInputController( g_pcControllers[iControl].xiController.nControl, 0, 0); else if (g_apFFDevice[iControl]) @@ -369,18 +366,25 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) FillMemory(Data, 32, 0x84); break; case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) - if (tPak->iEnableState == true) { + if (tPak->iEnableState == true) + { DebugWriteA( "Query Cart. State:" ); - if (tPak->bPakInserted) { - if (tPak->iCurrentAccessMode == 1) { + if (tPak->bPakInserted) + { + if (tPak->iCurrentAccessMode == 1) + { FillMemory(Data, 32, 0x89); DebugWriteA( " Inserted, Access Mode 1\n" ); - } else { + } + else + { FillMemory(Data, 32, 0x80); DebugWriteA( " Inserted, Access Mode 0\n" ); } Data[0] = Data[0] | tPak->iAccessModeChanged; - } else { + } + else + { FillMemory(Data, 32, 0x40); // Cart not inserted. DebugWriteA( " Not Inserted\n" ); } @@ -391,7 +395,8 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) case 0xD: case 0xE: case 0xF: // if ((dwAddress >= 0xC000)) - if (tPak->iEnableState == true) { + if (tPak->iEnableState == true) + { DebugWriteA( "Cart Read: Bank:%i\n", tPak->iCurrentBankNo ); DebugWriteA( " Address:%04X\n", ((dwAddress & 0xFFE0) - 0xC000) + ((tPak->iCurrentBankNo & 3) * 0x4000) ); @@ -406,10 +411,12 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) #ifdef ENABLE_RAWPAK_DEBUG DebugWriteA( "TPak Data: " ); - for (int i = 0; i < 32; i ++) { + for (int i = 0; i < 32; i ++) + { if ((i < 31) && ((i & 7) == 0)) DebugWriteA( "\n " ); DebugWriteByteA(Data[i]); - if (i < 31) { + if (i < 31) + { DebugWriteA( ", "); } } @@ -421,16 +428,14 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) bReturn = RD_OK; } break; - /*case PAK_VOICE: break;*/ - case PAK_ADAPTOID: if( ReadAdaptoidPak( iControl, dwAddress, Data ) == DI_OK ) { Data[32] = DataCRC( Data, 32 ); bReturn = RD_OK; - + if( ((ADAPTOIDPAK*)g_pcControllers[iControl].pPakData)->fRumblePak ) { BYTE bId = ((ADAPTOIDPAK*)g_pcControllers[iControl].pPakData)->bIdentifier; @@ -444,7 +449,7 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command ) } } break; - + /*case PAK_NONE: break;*/ } @@ -480,7 +485,7 @@ BYTE WriteControllerPak( const int iControl, LPBYTE Command ) // Switched to memory-mapped file // That way, if the computer dies due to power loss or something mid-play, the savegame is still there. MEMPAK *mPak = (MEMPAK*)g_pcControllers[iControl].pPakData; - + if( dwAddress < 0x8000 ) { CopyMemory( &mPak->aMemPakData[dwAddress], Data, 32 ); @@ -552,7 +557,6 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors Data[32] = DataCRC( Data, 32 ); bReturn = RD_OK; break; - case PAK_TRANSFER: { LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; @@ -563,10 +567,15 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors #ifdef ENABLE_RAWPAK_DEBUG DebugWriteA( " Data: "); - for (int i = 0; i < 32; i++) { - if ((i < 31) && ((i & 7) == 0)) DebugWriteA( "\n " ); + for (int i = 0; i < 32; i++) + { + if ((i < 31) && ((i & 7) == 0)) + { + DebugWriteA( "\n " ); + } DebugWriteByteA( Data[i]); - if (i < 31) { + if (i < 31) + { DebugWriteA( ", " ); } } @@ -577,15 +586,18 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors switch (dwAddress >> 12) { case 0x8: // if ((dwAddress >= 0x8000) && (dwAddress <= 0x8FFF)) - if (Data[0] == 0xFE) { + if (Data[0] == 0xFE) + { DebugWriteA("Cart Disable\n" ); tPak->iEnableState = false; } - else if (Data[0] == 0x84) { + else if (Data[0] == 0x84) + { DebugWriteA("Cart Enable\n" ); tPak->iEnableState = true; } - else { + else + { DebugWriteA("WARNING: Unusual Cart Enable/Disable\n" ); DebugWriteA(" Address: " ); DebugWriteWordA(dwAddress); @@ -596,17 +608,20 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors } break; case 0xA: // if ((dwAddress >= 0xA000) && (dwAddress <= 0xAFFF)) - if (tPak->iEnableState == true) { + if (tPak->iEnableState == true) + { tPak->iCurrentBankNo = Data[0]; DebugWriteA("Set TPak Bank No:%02X\n", Data[0] ); } break; case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) - if (tPak->iEnableState == true) { + if (tPak->iEnableState == true) + { tPak->iCurrentAccessMode = Data[0] & 1; tPak->iAccessModeChanged = 4; DebugWriteA("Set TPak Access Mode: %04X\n", tPak->iCurrentAccessMode); - if ((Data[0] != 1) && (Data[0] != 0)) { + if ((Data[0] != 1) && (Data[0] != 0)) + { DebugWriteA("WARNING: Unusual Access Mode Change\n" ); DebugWriteA(" Address: " ); DebugWriteWordA(dwAddress); @@ -634,10 +649,8 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors bReturn = RD_OK; } break; - /*case PAK_VOICE: break;*/ - case PAK_ADAPTOID: if(( dwAddress == PAK_IO_RUMBLE ) && ((ADAPTOIDPAK*)g_pcControllers[iControl].pPakData)->fRumblePak ) { @@ -659,7 +672,6 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors } } break; - /*case PAK_NONE: break;*/ } @@ -700,7 +712,6 @@ void SaveControllerPak( const int iControl ) break; case PAK_ADAPTOID: break; - /*case PAK_NONE: break;*/ } @@ -750,10 +761,8 @@ void CloseControllerPak( const int iControl ) break; case PAK_VOICE: break; - case PAK_ADAPTOID: break; - /*case PAK_NONE: break;*/ } @@ -789,12 +798,10 @@ inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes return wRemainingBlocks; } - - void FormatMemPak( LPBYTE aMemPak ) { FillMemory( aMemPak, 0x100, 0xFF ); - + aMemPak[0] = 0x81; // generate a valid code( i hope i can calculate it one day) @@ -825,8 +832,6 @@ void FormatMemPak( LPBYTE aMemPak ) aMemPak[0x30+14] = aMemPak[0x70+14] = aMemPak[0x90+14] = aMemPak[0xD0+14] = aCode[6]; aMemPak[0x30+15] = aMemPak[0x70+15] = aMemPak[0x90+15] = aMemPak[0xD0+15] = aCode[7]; - - // Index ZeroMemory( &aMemPak[0x100], 0x400 ); @@ -834,9 +839,7 @@ void FormatMemPak( LPBYTE aMemPak ) for( int i = 0x00b; i < 0x100; i += 2 ) aMemPak[0x100+i] = aMemPak[0x200+i] = 03; - FillMemory( &aMemPak[0x500], 0x7B00, 0xFF ); - } // Translates a mempak header into a real Unicode string, for display in the Mempaks window @@ -1404,21 +1407,17 @@ bool RemoveNote( LPBYTE aMemPak, const int iNote ) bBlock = aMemPak[iPos]; aMemPak[iPos] = 0x03; } + int i = 0, iSum = 0; for( i = 0x10A; i < 0x200; i++ ) iSum += aMemPak[i]; aMemPak[0x101] = iSum % 256; - CopyMemory( &aMemPak[0x200], &aMemPak[0x100], 0x100 ); - ZeroMemory( &aMemPak[0x300 + iNote*32], 32 ); - return true; } - - BYTE AddressCRC( const unsigned char * Address ) { bool HighBit; @@ -1433,7 +1432,6 @@ BYTE AddressCRC( const unsigned char * Address ) Remainder = (Remainder << 1) & 0x1E; Remainder += ( bBit < 11 && Data & (0x8000 >> bBit )) ? 1 : 0; - Remainder ^= (HighBit) ? 0x15 : 0; bBit++; diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index 64480c2e6..1e2c9daa2 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -418,7 +418,7 @@ TCHAR * GetN64ButtonFromXInputControl( LPXCONTROLLER gController, int XInputButt N64ButtonCode |= gController->stButtons.iR & XInputButton ? R : 0; N64ButtonCode |= gController->stButtons.iStart & XInputButton ? Start : 0; N64ButtonCode |= gController->stButtons.iZ & XInputButton ? Z : 0; - + return GetN64ButtonNameFromButtonCode( N64ButtonCode ); }