[PJ64 NRage] some scope and spacing formatting clean-ups

This commit is contained in:
unknown 2015-03-17 18:47:32 -04:00
parent 5158883a86
commit a247ffe6b1
8 changed files with 192 additions and 175 deletions

View File

@ -497,11 +497,15 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData )
} }
if (pcController->bRapidFireEnabled) { if (pcController->bRapidFireEnabled)
if (pcController->bRapidFireCounter >= pcController->bRapidFireRate) { {
if (pcController->bRapidFireCounter >= pcController->bRapidFireRate)
{
w_Buttons = (w_Buttons & 0xFF1F); w_Buttons = (w_Buttons & 0xFF1F);
pcController->bRapidFireCounter = 0; pcController->bRapidFireCounter = 0;
} else{ }
else
{
pcController->bRapidFireCounter = pcController->bRapidFireCounter + 1; pcController->bRapidFireCounter = pcController->bRapidFireCounter + 1;
} }
} }
@ -546,7 +550,6 @@ bool GetNControllerInput ( const int indexController, LPDWORD pdwData )
(BYTE)(min( max( MINAXISVALUE, (long)(lAxisValueY * d_ModifierY )), MAXAXISVALUE) / N64DIVIDER ))); (BYTE)(min( max( MINAXISVALUE, (long)(lAxisValueY * d_ModifierY )), MAXAXISVALUE) / N64DIVIDER )));
} }
return true; return true;
} }
@ -788,7 +791,6 @@ bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID
switch( LOBYTE(dwDevType) ) switch( LOBYTE(dwDevType) )
{ {
case DI8DEVTYPE_KEYBOARD: case DI8DEVTYPE_KEYBOARD:
ppDiDataFormat = &c_dfDIKeyboard; ppDiDataFormat = &c_dfDIKeyboard;
break; break;

View File

@ -604,7 +604,6 @@ bool ProcessKey( DWORD dwKey, DWORD dwSection, LPCSTR pszLine, LPTSTR pszFFDevic
} }
break; break;
} }
return bReturn; return bReturn;
@ -1146,7 +1145,8 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave )
return false; return false;
} }
for ( ; nFilters > 0; nFilters--) { for ( ; nFilters > 0; nFilters--)
{
pszTemp += _tcslen(pszTemp); pszTemp += _tcslen(pszTemp);
pszTemp += 1; pszTemp += 1;
pszTemp += _tcslen(pszTemp); pszTemp += _tcslen(pszTemp);
@ -1160,7 +1160,6 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave )
szInitialDir[MAX_PATH+1] = _T(""), szInitialDir[MAX_PATH+1] = _T(""),
*pcSlash; *pcSlash;
if( pszFileName[1] == _T(':') || ( pszFileName[1] == _T('\\') && pszFileName[0] == _T('\\') )) if( pszFileName[1] == _T(':') || ( pszFileName[1] == _T('\\') && pszFileName[0] == _T('\\') ))
{ {
lstrcpyn( szInitialDir, pszFileName, ARRAYSIZE(szInitialDir) ); lstrcpyn( szInitialDir, pszFileName, ARRAYSIZE(szInitialDir) );
@ -1178,7 +1177,6 @@ bool BrowseFile( HWND hDlg, TCHAR *pszFileName, DWORD dwType, bool fSave )
lstrcpyn( szFileName, pszFileName, ARRAYSIZE(szFileName) ); lstrcpyn( szFileName, pszFileName, ARRAYSIZE(szFileName) );
} }
OPENFILENAME oFile; OPENFILENAME oFile;
oFile.lStructSize = sizeof (OPENFILENAME); oFile.lStructSize = sizeof (OPENFILENAME);

View File

@ -32,15 +32,18 @@ bool WriteCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data);
// Tries to read RTC data from separate file (not integrated into SAV) // Tries to read RTC data from separate file (not integrated into SAV)
// success sets the useTDF flag // success sets the useTDF flag
// failure inits the RTC at zero and maybe throws a warning // 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 // check useTDF flag
// write data from RTC to TDF file // write data from RTC to TDF file
} }
void UpdateRTC(LPGBCART Cart) { void UpdateRTC(LPGBCART Cart)
{
time_t now, dif; time_t now, dif;
int days; int days;
@ -57,13 +60,17 @@ void UpdateRTC(LPGBCART Cart) {
days = (int)(Cart->TimerData[3] + ((Cart->TimerData[4] & 1) << 8) + dif); days = (int)(Cart->TimerData[3] + ((Cart->TimerData[4] & 1) << 8) + dif);
Cart->TimerData[3] = (days & 0xFF); Cart->TimerData[3] = (days & 0xFF);
if(days > 255) { if (days > 255)
if(days > 511) { {
if (days > 511)
{
days &= 511; days &= 511;
Cart->TimerData[4] |= 0x80; Cart->TimerData[4] |= 0x80;
} }
if (days > 255) 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; Cart->timerLastUpdate = now;
@ -103,7 +110,9 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T
dwFilesize = GetFileSize(hTemp, NULL); dwFilesize = GetFileSize(hTemp, NULL);
CloseHandle(hTemp); CloseHandle(hTemp);
Cart->RomData = (const unsigned char *)MapViewOfFile( Cart->hRomFile, FILE_MAP_READ, 0, 0, 0 ); 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()); DebugWriteA("Couldn't load the ROM file, GetLastError returned %08x\n", GetLastError());
if (hTemp != INVALID_HANDLE_VALUE) if (hTemp != INVALID_HANDLE_VALUE)
CloseHandle(hTemp); // if file size was zero, make sure we don't leak the handle 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 #:"); DebugWriteA(" Cartridge Type #:");
DebugWriteByteA(Cart->RomData[0x147]); DebugWriteByteA(Cart->RomData[0x147]);
DebugWriteA("\n"); 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: case 0x00:
Cart->iCartType = GB_NORM; Cart->iCartType = GB_NORM;
Cart->bHasRam = false; Cart->bHasRam = false;
@ -287,7 +297,8 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T
} }
// assign read/write handlers // assign read/write handlers
switch (Cart->iCartType) { switch (Cart->iCartType)
{
case GB_NORM: // Raw cartridge case GB_NORM: // Raw cartridge
Cart->ptrfnReadCart = &ReadCartNorm; Cart->ptrfnReadCart = &ReadCartNorm;
Cart->ptrfnWriteCart = &WriteCartNorm; Cart->ptrfnWriteCart = &WriteCartNorm;
@ -318,7 +329,8 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T
// Determine ROM size for paging checks // Determine ROM size for paging checks
Cart->iNumRomBanks = 2; Cart->iNumRomBanks = 2;
switch (Cart->RomData[0x148]) { switch (Cart->RomData[0x148])
{
case 0x01: case 0x01:
Cart->iNumRomBanks = 4; Cart->iNumRomBanks = 4;
break; break;
@ -397,11 +409,13 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T
if( hTemp == INVALID_HANDLE_VALUE ) if( hTemp == INVALID_HANDLE_VALUE )
{// test if Read-only access is possible {// test if Read-only access is possible
hTemp = CreateFile( RamFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL ); 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)); Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC));
ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); ClearData(Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC));
} }
else { else
{
Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800);
ClearData(Cart->RamData, 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); WarningMessage( IDS_ERR_GBSRAMERR, MB_OK | MB_ICONWARNING);
return true; return true;
} }
} else { // file is OK, use a mapping }
else
{ // file is OK, use a mapping
if (Cart->bHasTimer && Cart->bHasBattery) if (Cart->bHasTimer && Cart->bHasBattery)
Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), NULL); Cart->hRamFile = CreateFileMapping( hTemp, NULL, PAGE_READWRITE, 0, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), NULL);
else else
@ -430,15 +446,21 @@ bool LoadCart(LPGBCART Cart, LPCTSTR RomFileName, LPCTSTR RamFileName, LPCTSTR T
if (Cart->hRamFile != NULL) if (Cart->hRamFile != NULL)
{ {
Cart->RamData = (LPBYTE)MapViewOfFile( Cart->hRamFile, FILE_MAP_ALL_ACCESS, 0, 0, 0 ); 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; DWORD dwBytesRead;
if (Cart->bHasTimer && Cart->bHasBattery) { if (Cart->bHasTimer && Cart->bHasBattery)
{
Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC)); Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC));
ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), &dwBytesRead, NULL); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800 + sizeof(gbCartRTC), &dwBytesRead, NULL);
} else { }
else
{
Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800); Cart->RamData = (LPBYTE)P_malloc(NumQuarterBlocks * 0x0800);
ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800, &dwBytesRead, NULL); ReadFile(hTemp, Cart->RamData, NumQuarterBlocks * 0x0800, &dwBytesRead, NULL);
} }
if (dwBytesRead < NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0)) if (dwBytesRead < NumQuarterBlocks * 0x0800 + ((Cart->bHasTimer && Cart->bHasBattery) ? sizeof(gbCartRTC) : 0))
{ {
ClearData(Cart->RamData, 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); 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. // Looks like there is extra data in the SAV file than just RAM data... assume it is RTC data.
gbCartRTC RTCTimer; gbCartRTC RTCTimer;
CopyMemory( &RTCTimer, &Cart->RamData[NumQuarterBlocks * 0x0800], sizeof(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; Cart->timerLastUpdate = RTCTimer.mapperLastTime;
UpdateRTC(Cart); UpdateRTC(Cart);
} }
else { else
{
ReadTDF(Cart); // try to open TDF format, clear/init Cart->TimerData if that fails ReadTDF(Cart); // try to open TDF format, clear/init Cart->TimerData if that fails
} }
} }
CloseHandle(hTemp); CloseHandle(hTemp);
} else { }
else
{
// no battery; just allocate some RAM // no battery; just allocate some RAM
Cart->RamData = (LPBYTE)P_malloc(Cart->iNumRamBanks * 0x2000); 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)) else if ((dwAddress >= 0xA000) && (dwAddress <= 0xBFFF))
{ {
if (Cart->bHasRam) if (Cart->bHasRam/* && Cart->bRamEnableState)*/)
{ // && Cart->bRamEnableState) { {
if (Cart->iCurrentRamBankNo >= Cart->iNumRamBanks) if (Cart->iCurrentRamBankNo >= Cart->iNumRamBanks)
{ {
ZeroMemory(Data, 32); ZeroMemory(Data, 32);
@ -742,7 +769,8 @@ bool WriteCartMBC2(LPGBCART Cart, WORD dwAddress, BYTE *Data)
else if ((dwAddress >= 0x2000) && (dwAddress <= 0x3FFF)) // ROM bank select else if ((dwAddress >= 0x2000) && (dwAddress <= 0x3FFF)) // ROM bank select
{ {
Cart->iCurrentRomBankNo = Data[0] & 0x0F; Cart->iCurrentRomBankNo = Data[0] & 0x0F;
if (Cart->iCurrentRomBankNo == 0) { if (Cart->iCurrentRomBankNo == 0)
{
Cart->iCurrentRomBankNo = 1; Cart->iCurrentRomBankNo = 1;
} }
DebugWriteA("Set ROM Bank: %02X\n", Cart->iCurrentRomBankNo); 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); CopyMemory(Data, &Cart->RamData[dwAddress - 0xA000 + (Cart->iCurrentRamBankNo * 0x2000)], 32);
DebugWriteA("RAM read: Bank %02X\n", Cart->iCurrentRamBankNo); DebugWriteA("RAM read: Bank %02X\n", Cart->iCurrentRamBankNo);
} }/*
//else { else
// ZeroMemory(Data, 32); {
// //for (i=0; i<32; i++) Data[i] = 0; ZeroMemory(Data, 32);
// DebugWriteA("Failed RAM read: (RAM not active)\n"); //for (i=0; i<32; i++) Data[i] = 0;
//} DebugWriteA("Failed RAM read: (RAM not active)\n");
}*/
} }
else else
{ {
@ -918,7 +947,6 @@ bool WriteCartMBC3(LPGBCART Cart, WORD dwAddress, BYTE *Data)
// Done // Done
bool ReadCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data) bool ReadCartMBC5(LPGBCART Cart, WORD dwAddress, BYTE *Data)
{ {
if ((dwAddress < 0x4000)) //Rom Bank 0 if ((dwAddress < 0x4000)) //Rom Bank 0
{ {
CopyMemory(Data, &Cart->RomData[dwAddress], 32); CopyMemory(Data, &Cart->RomData[dwAddress], 32);
@ -1029,9 +1057,10 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile)
DWORD NumQuarterBlocks = 0; DWORD NumQuarterBlocks = 0;
gbCartRTC RTCTimer; gbCartRTC RTCTimer;
if (Cart->bHasRam && Cart->bHasBattery) { if (Cart->bHasRam && Cart->bHasBattery)
// Write only the bytes that NEED writing! { // Write only the bytes that NEED writing!
switch (Cart->RomData[0x149]) { switch (Cart->RomData[0x149])
{
case 1: case 1:
NumQuarterBlocks = 1; NumQuarterBlocks = 1;
break; break;
@ -1046,7 +1075,8 @@ bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile)
break; break;
} }
FlushViewOfFile( Cart->RamData, NumQuarterBlocks * 0x0800 ); FlushViewOfFile( Cart->RamData, NumQuarterBlocks * 0x0800 );
if (Cart->bHasTimer) { if (Cart->bHasTimer)
{
// Save RTC in VisualBoy Advance format // Save RTC in VisualBoy Advance format
// TODO: Check if VBA saves are compatible with other emus. // TODO: Check if VBA saves are compatible with other emus.
// TODO: Only write RTC data if VBA RTC data was originaly present // 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; RTCTimer.mapperLastTime = Cart->timerLastUpdate;
CopyMemory(Cart->RamData + NumQuarterBlocks * 0x0800, &RTCTimer, sizeof(RTCTimer)); CopyMemory(Cart->RamData + NumQuarterBlocks * 0x0800, &RTCTimer, sizeof(RTCTimer));
FlushViewOfFile(Cart->RamData + NumQuarterBlocks * 0x0800, sizeof(gbCartRTC));
FlushViewOfFile( Cart->RamData + NumQuarterBlocks * 0x0800, sizeof(gbCartRTC));
} }
} }
return true; return true;
@ -1105,10 +1134,14 @@ void ClearData(BYTE *Data, int Length)
{ {
int i; int i;
for (i=0; i<Length; i++) { for (i = 0; i < Length; i++)
if ((i & 0x80) != 0x80) { {
if ((i & 0x80) != 0x80)
{
Data[i] = 0x00; Data[i] = 0x00;
} else { }
else
{
Data[i] = 0xFF; Data[i] = 0xFF;
} }
} }

View File

@ -558,11 +558,13 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
CheckDlgButton( hDlg, IDC_XINPUT_ENABLER, pcController->fXInput ? BST_CHECKED : BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_XINPUT_ENABLER, pcController->fXInput ? BST_CHECKED : BST_UNCHECKED );
if( hTabControl ) if( hTabControl )
DestroyWindow( hTabControl ); DestroyWindow( hTabControl );
if( pcController->fXInput ) if( pcController->fXInput )
hTabControl = CreateDialog ( g_hResourceDLL, MAKEINTRESOURCE( IDD_XCONTROLS ), hDlg, XControlsTabProc ); hTabControl = CreateDialog ( g_hResourceDLL, MAKEINTRESOURCE( IDD_XCONTROLS ), hDlg, XControlsTabProc );
else else
hTabControl = CreateDialog( g_hResourceDLL, MAKEINTRESOURCE( IDD_CONTROLS ), hDlg, ControlsTabProc ); hTabControl = CreateDialog( g_hResourceDLL, MAKEINTRESOURCE( IDD_CONTROLS ), hDlg, ControlsTabProc );
{ {
hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB ); hDlgItem = GetDlgItem( hDlg, IDC_CONTROLLERTAB );
@ -583,7 +585,6 @@ BOOL CALLBACK ControllerTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if( hTabControl ) if( hTabControl )
SendMessage( hTabControl, WM_USER_UPDATE, 0, 0 ); SendMessage( hTabControl, WM_USER_UPDATE, 0, 0 );
return TRUE; return TRUE;
default: default:
return FALSE; //false means the msg didn't got processed 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); LeaveCriticalSection(&g_critical);
GetButtonText( aButtons[dwButtonID[2]], szBuffer ); GetButtonText( aButtons[dwButtonID[2]], szBuffer );
SendMessage( GetDlgItem( hDlg, dwButtonID[1] ), WM_SETTEXT , 0, (LPARAM)szBuffer ); SendMessage( GetDlgItem( hDlg, dwButtonID[1] ), WM_SETTEXT , 0, (LPARAM)szBuffer );
if( hFocus != NULL ) 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; aButtons = g_ivConfig->Controllers[g_ivConfig->ChosenTab].aButton;
LeaveCriticalSection(&g_critical); LeaveCriticalSection(&g_critical);
if( wParam == 0 ) if( wParam == 0 )
{ {
CheckDlgButton( hDlg, IDC_N64RANGE, g_ivConfig->Controllers[g_ivConfig->ChosenTab].fRealN64Range ? BST_CHECKED : BST_UNCHECKED ); 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_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 ); 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 ); SendMessage( GetDlgItem( hDlg, IDC_CTRRANGE ), TBM_SETPOS, TRUE, g_ivConfig->Controllers[g_ivConfig->ChosenTab].bStickRange );
LoadString( g_hResourceDLL, IDS_C_RANGE, szTemp, 40 ); LoadString( g_hResourceDLL, IDS_C_RANGE, szTemp, 40 );
wsprintf( szBuffer, szTemp, g_ivConfig->Controllers[g_ivConfig->ChosenTab].bStickRange ); 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 )) if( !ReadXInputControllerKeys( hDlg, gController ))
for( int i = IDC_XC_A; i <= IDC_XC_RTS; i++ ) for( int i = IDC_XC_A; i <= IDC_XC_RTS; i++ )
SendDlgItemMessage( hDlg, i, CB_SETCURSEL, 0, ( LPARAM )0 ); SendDlgItemMessage( hDlg, i, CB_SETCURSEL, 0, ( LPARAM )0 );
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
@ -980,10 +977,12 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_CHECKED ); CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_DEADPANMOUSEX, BST_UNCHECKED );
if( pcController->bMouseMoveX == MM_BUFF ) if( pcController->bMouseMoveX == MM_BUFF )
CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_CHECKED ); CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEX, BST_UNCHECKED );
if( pcController->bMouseMoveX == MM_ABS ) if( pcController->bMouseMoveX == MM_ABS )
CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEX, BST_CHECKED ); CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEX, BST_CHECKED );
else else
@ -993,10 +992,12 @@ BOOL CALLBACK DevicesTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_CHECKED ); CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_DEADPANMOUSEY, BST_UNCHECKED );
if( pcController->bMouseMoveY == MM_BUFF ) if( pcController->bMouseMoveY == MM_BUFF )
CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_CHECKED ); CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_BUFFEREDMOUSEY, BST_UNCHECKED );
if( pcController->bMouseMoveY == MM_ABS ) if( pcController->bMouseMoveY == MM_ABS )
CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEY, BST_CHECKED ); CheckDlgButton( hDlg, IDC_ABSOLUTEMOUSEY, BST_CHECKED );
else 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 ) BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{ {
HWND hDlgItem; HWND hDlgItem;
long i,j; long i,j;
DWORD dwValue; DWORD dwValue;
@ -1071,14 +1071,12 @@ BOOL CALLBACK MoveModifierDialog( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
wsprintf( szBuffer, szTemp, i ); wsprintf( szBuffer, szTemp, i );
SendMessage( GetDlgItem( hDlg, IDT_XMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer ); SendMessage( GetDlgItem( hDlg, IDT_XMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer );
return TRUE; return TRUE;
case IDC_YMODIFIER: case IDC_YMODIFIER:
i = SendMessage( (HWND)lParam, TBM_GETPOS, 0, 0 ); i = SendMessage( (HWND)lParam, TBM_GETPOS, 0, 0 );
LoadString( g_hResourceDLL, IDS_M_MOVEVALUE, szTemp, DEFAULT_BUFFER ); LoadString( g_hResourceDLL, IDS_M_MOVEVALUE, szTemp, DEFAULT_BUFFER );
wsprintf( szBuffer, szTemp, i ); wsprintf( szBuffer, szTemp, i );
SendMessage( GetDlgItem( hDlg, IDT_YMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer ); SendMessage( GetDlgItem( hDlg, IDT_YMODIFIER ), WM_SETTEXT , 0, (LPARAM)szBuffer );
return TRUE; return TRUE;
default: default:
return FALSE; return FALSE;
} }
@ -1399,7 +1397,6 @@ void ModDescription( HWND hListView, int iEntry, const LPMODIFIER pModifier )
szBuffer[0] = '\0'; szBuffer[0] = '\0';
} }
ListView_SetItemText( hListView, iEntry, 2, szBuffer ); ListView_SetItemText( hListView, iEntry, 2, szBuffer );
} }
BOOL CALLBACK ModifierTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) 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; bMatch = true;
} }
if (!bMatch && g_devList[i].bEffType != 0 ) if (!bMatch && g_devList[i].bEffType != 0 )
{ {
if( g_devList[i].bProductCounter == 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 ); CheckDlgButton( hDlg, IDC_RUMBLE1, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_RUMBLE1, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_RUMBLE1, BST_UNCHECKED );
if( pcController->bRumbleTyp == RUMBLE_EFF2 ) if( pcController->bRumbleTyp == RUMBLE_EFF2 )
CheckDlgButton( hDlg, IDC_RUMBLE2, BST_CHECKED ); CheckDlgButton( hDlg, IDC_RUMBLE2, BST_CHECKED );
else else
CheckDlgButton( hDlg, IDC_RUMBLE2, BST_UNCHECKED ); CheckDlgButton( hDlg, IDC_RUMBLE2, BST_UNCHECKED );
if( pcController->bRumbleTyp == RUMBLE_EFF3 ) if( pcController->bRumbleTyp == RUMBLE_EFF3 )
CheckDlgButton( hDlg, IDC_RUMBLE3, BST_CHECKED ); CheckDlgButton( hDlg, IDC_RUMBLE3, BST_CHECKED );
else else
@ -2785,7 +2783,6 @@ BOOL CALLBACK ShortcutsTabProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
bScanRunning = false; bScanRunning = false;
iPlayer = 5; 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] == '\\' ))) if( szBuffer[0] != 0 && ( szBuffer[1] == ':' || ( szBuffer[1] == '\\' && szBuffer[0] == '\\' )))
{ {
CheckDlgButton( hDlg, IDC_MEMPAK_ABS, BST_CHECKED ); CheckDlgButton( hDlg, IDC_MEMPAK_ABS, BST_CHECKED );
GetDirectory( szBuffer, DIRECTORY_MEMPAK ); 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 ); SendMessage( GetDlgItem( hDlg, IDC_MEMPAK_REL_EDIT ), WM_SETTEXT, 0, (LPARAM)STRING_DEF_MEMPAKFILE );
} }
GetDirectory( szBuffer, DIRECTORY_MEMPAK ); GetDirectory( szBuffer, DIRECTORY_MEMPAK );
pcSlash = _tcsrchr( szBuffer, '\\' ); pcSlash = _tcsrchr( szBuffer, '\\' );
if( pcSlash && ( pcSlash[1] == '\0' )) *pcSlash = '\0'; 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'; if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0';
SendMessage( GetDlgItem( hDlg, IDC_GBROM_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); SendMessage( GetDlgItem( hDlg, IDC_GBROM_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer );
// GBSave Directory // GBSave Directory
lstrcpyn(szBuffer, g_aszDefFolders[DIRECTORY_GBSAVES], MAX_PATH); 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 ); GetDirectory( szBuffer, DIRECTORY_GBSAVES );
pcSlash = _tcsrchr( szBuffer, _T('\\') ); pcSlash = _tcsrchr( szBuffer, _T('\\') );
if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0'; if( pcSlash && ( pcSlash[1] == _T('\0') )) *pcSlash = '\0';
SendMessage( GetDlgItem( hDlg, IDC_GBSAVE_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer ); SendMessage( GetDlgItem( hDlg, IDC_GBSAVE_ABS_EDIT ), WM_SETTEXT, 0, (LPARAM)szBuffer );
return FALSE; // don't give it focus return FALSE; // don't give it focus
case WM_COMMAND: 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??? // 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...? // 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 ); wsprintf(Text[1], buff, btnButton.bOffset - 7 );
Text[2] = AxeID[2 + btnButton.bAxisID]; Text[2] = AxeID[2 + btnButton.bAxisID];
break; break;
case DT_KEYBUTTON: case DT_KEYBUTTON:
LoadString( g_hResourceDLL, iDevice[2], Text[0], 16 ); LoadString( g_hResourceDLL, iDevice[2], Text[0], 16 );
//TODO: this is great! can we do this for all of them? //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 ); LoadString( g_hResourceDLL, IDS_C_UNKNOWN, Text[1], 16 );
Text[2] = TEXT( "" ); Text[2] = TEXT( "" );
break; break;
case DT_MOUSEBUTTON: case DT_MOUSEBUTTON:
LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 ); LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 );
LoadString( g_hResourceDLL, iMouse[3], Text[1], 16 ); LoadString( g_hResourceDLL, iMouse[3], Text[1], 16 );
Text[2] = Btn; Text[2] = Btn;
wsprintf( Btn, TEXT( "%02u" ), btnButton.bOffset ); wsprintf( Btn, TEXT( "%02u" ), btnButton.bOffset );
break; break;
case DT_MOUSEAXE: case DT_MOUSEAXE:
LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 ); LoadString( g_hResourceDLL, iDevice[3], Text[0], 16 );
LoadString( g_hResourceDLL, iMouse[btnButton.bOffset], Text[1], 16 ); LoadString( g_hResourceDLL, iMouse[btnButton.bOffset], Text[1], 16 );
Text[2] = AxeID[btnButton.bAxisID]; Text[2] = AxeID[btnButton.bAxisID];
break; break;
case DT_UNASSIGNED: case DT_UNASSIGNED:
default: default:
LoadString( g_hResourceDLL, iDevice[0], Text[0], 16 ); LoadString( g_hResourceDLL, iDevice[0], Text[0], 16 );
@ -3574,7 +3560,6 @@ DWORD ScanMouse( LPDEVICE lpDevice, LPDWORD lpdwCounter, LPBUTTON pButton )
return FALSE; return FALSE;
} }
if ( bFirstScan ) if ( bFirstScan )
{ {
CopyMemory( rgbInitButtons, dm_Current.rgbButtons, sizeof(rgbInitButtons)); 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 ); hr = lpDevice->didHandle->GetDeviceState( sizeof(DIJOYSTATE), &lpDevice->stateAs.joyState );
if ( FAILED(hr) ) if ( FAILED(hr) )
{ {
hr = lpDevice->didHandle->Acquire(); hr = lpDevice->didHandle->Acquire();
return FALSE; return FALSE;
} }
if ( bFirstScan ) if ( bFirstScan )
@ -3971,7 +3956,6 @@ void UpdateControllerStructures()
g_pcControllers[i].guidFFDevice = GUID_NULL; g_pcControllers[i].guidFFDevice = GUID_NULL;
} }
g_pcControllers[i].fPakCRCError = false; g_pcControllers[i].fPakCRCError = false;
g_pcControllers[i].fPakInitialized = false; g_pcControllers[i].fPakInitialized = false;
@ -3986,7 +3970,8 @@ LRESULT CALLBACK BlockerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
PAINTSTRUCT ps; PAINTSTRUCT ps;
switch (msg) { switch (msg)
{
case WM_CREATE: case WM_CREATE:
return 0; return 0;
case WM_PAINT: case WM_PAINT:
@ -4027,7 +4012,6 @@ BOOL InitOverlay(void)
HWND MakeOverlay() HWND MakeOverlay()
{ {
HWND hwnd; HWND hwnd;
RECT size; RECT size;
GetWindowRect(g_hMainDialog, &size); GetWindowRect(g_hMainDialog, &size);
@ -4046,8 +4030,8 @@ HWND MakeOverlay()
g_hMainDialog, // owner window g_hMainDialog, // owner window
(HMENU) NULL, // menu (HMENU) NULL, // menu
g_strEmuInfo.hinst, // handle to application instance g_strEmuInfo.hinst, // handle to application instance
(LPVOID) NULL); // window-creation data (LPVOID) NULL // window-creation data
);
if (!hwnd) if (!hwnd)
return NULL; return NULL;

View File

@ -49,9 +49,10 @@ HMODULE LoadLanguageDLL(LANGID DesiredLanguage)
hDLL = LoadLibraryEx(SatellitePath, 0, 0); hDLL = LoadLibraryEx(SatellitePath, 0, 0);
if( hDLL ) if( hDLL )
return hDLL; return hDLL;
else { // try the primary language ID else
{ // try the primary language ID
DesiredLanguage = PRIMARYLANGID(DesiredLanguage); DesiredLanguage = PRIMARYLANGID(DesiredLanguage);
_stprintf(SatellitePath, _T("NRage-Language-%u.dll"), DesiredLanguage); _stprintf(SatellitePath, _T("NRage-Language-%u.dll"), DesiredLanguage);
hDLL = LoadLibraryEx(SatellitePath, 0, 0); hDLL = LoadLibraryEx(SatellitePath, 0, 0);
if( hDLL ) if( hDLL )
return hDLL; return hDLL;
@ -83,25 +84,25 @@ BOOL CALLBACK EnumLangProc(HANDLE hModule, LPCTSTR lpszType, LPCTSTR lpszName,
// the Hongkong SAR version // the Hongkong SAR version
LANGID GetNTDLLNativeLangID() LANGID GetNTDLLNativeLangID()
{ {
LANGINFO LangInfo; LANGINFO LangInfo;
LPCTSTR Type = (LPCTSTR) ((LPVOID)((WORD)16)); LPCTSTR Type = (LPCTSTR) ((LPVOID)((WORD)16));
LPCTSTR Name = (LPCTSTR) 1; LPCTSTR Name = (LPCTSTR) 1;
ZeroMemory(&LangInfo,sizeof(LangInfo)); ZeroMemory(&LangInfo,sizeof(LangInfo));
// Get the HModule for ntdll. // Get the HModule for ntdll.
HMODULE hMod = GetModuleHandle(_T("ntdll.dll")); HMODULE hMod = GetModuleHandle(_T("ntdll.dll"));
if (hMod==NULL) { if (hMod==NULL)
{
return(0); return(0);
} }
BOOL result = EnumResourceLanguages(hMod, Type, Name, (ENUMRESLANGPROC)EnumLangProc, (LONG_PTR) &LangInfo); 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 (0);
} }
return (LangInfo.LangID); return (LangInfo.LangID);
} }
@ -114,7 +115,8 @@ BOOL IsHongKongVersion()
IMMRELEASECONTEXT pImmReleaseContext; IMMRELEASECONTEXT pImmReleaseContext;
hMod = LoadLibrary(_T("imm32.dll")); hMod = LoadLibrary(_T("imm32.dll"));
if (hMod) { if (hMod)
{
pImmReleaseContext = (IMMRELEASECONTEXT)GetProcAddress(hMod,"ImmReleaseContext"); pImmReleaseContext = (IMMRELEASECONTEXT)GetProcAddress(hMod,"ImmReleaseContext");
if (pImmReleaseContext) { if (pImmReleaseContext) {
bRet = pImmReleaseContext(NULL,0); bRet = pImmReleaseContext(NULL,0);
@ -137,12 +139,12 @@ LANGID DetectLanguage()
DWORD Type, BuffLen = MAX_KEY_BUFFER; DWORD Type, BuffLen = MAX_KEY_BUFFER;
TCHAR LangKeyValue[MAX_KEY_BUFFER]; TCHAR LangKeyValue[MAX_KEY_BUFFER];
VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( !GetVersionEx(&VersionInfo) ) if( !GetVersionEx(&VersionInfo) )
return(0); return(0);
switch( VersionInfo.dwPlatformId ) { switch( VersionInfo.dwPlatformId )
{
// On Windows NT, Windows 2000 or higher // On Windows NT, Windows 2000 or higher
case VER_PLATFORM_WIN32_NT: case VER_PLATFORM_WIN32_NT:
if( VersionInfo.dwMajorVersion >= 5) // Windows 2000 or higher if( VersionInfo.dwMajorVersion >= 5) // Windows 2000 or higher
@ -156,10 +158,13 @@ LANGID DetectLanguage()
uiLangID = fpGetLang(); uiLangID = fpGetLang();
} // and if we couldn't load kernel32.dll, just fall back to default language } // 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(); uiLangID = GetNTDLLNativeLangID();
if (uiLangID == 1033) { // special processing for Honkong SAR version of NT4 if (uiLangID == 1033)
if (IsHongKongVersion()) { { // special processing for Honkong SAR version of NT4
if (IsHongKongVersion())
{
uiLangID = 3076; uiLangID = 3076;
} }
} }
@ -169,13 +174,15 @@ LANGID DetectLanguage()
case VER_PLATFORM_WIN32_WINDOWS: case VER_PLATFORM_WIN32_WINDOWS:
// Open the registry key for the UI language // Open the registry key for the UI language
if( RegOpenKeyEx(HKEY_CURRENT_USER,_T("Default\\Control Panel\\Desktop\\ResourceLocale"), 0, 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 // Get the type of the default key
if( RegQueryValueEx(hKey, NULL, NULL, &Type, NULL, NULL) == ERROR_SUCCESS if( RegQueryValueEx(hKey, NULL, NULL, &Type, NULL, NULL) == ERROR_SUCCESS
&& Type == REG_SZ ) { && Type == REG_SZ )
// Read the key value { // Read the key value
if( RegQueryValueEx(hKey, NULL, NULL, &Type, (LPBYTE)LangKeyValue, &BuffLen) if( RegQueryValueEx(hKey, NULL, NULL, &Type, (LPBYTE)LangKeyValue, &BuffLen)
== ERROR_SUCCESS ) { == ERROR_SUCCESS )
{
uiLangID = _ttoi(LangKeyValue); uiLangID = _ttoi(LangKeyValue);
} }
} }
@ -184,7 +191,8 @@ LANGID DetectLanguage()
break; break;
} }
if (uiLangID == 0) { if (uiLangID == 0)
{
uiLangID = GetUserDefaultLangID(); uiLangID = GetUserDefaultLangID();
} }
// Return the found language ID. // Return the found language ID.

View File

@ -236,7 +236,8 @@ EXPORT void CALL DllConfig ( HWND hParent )
} }
EnterCriticalSection( &g_critical ); 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->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_DEVICE );
g_sysMouse.didHandle->Acquire(); 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 InitiatePaks( false ); // only re-init the mempaks and such if the user clicked Save or Use
} }
if( g_sysMouse.didHandle ) { if( g_sysMouse.didHandle )
if ( g_bExclusiveMouse ) { // if we have exclusive mouse, we need to relock mouse after closing the config {
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->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE );
g_sysMouse.didHandle->Acquire(); g_sysMouse.didHandle->Acquire();
if (g_strEmuInfo.fDisplayShortPop) if (g_strEmuInfo.fDisplayShortPop)
@ -270,7 +273,8 @@ EXPORT void CALL DllConfig ( HWND hParent )
CreateThread(NULL, 0, MsgThreadFunction, g_pszThreadMessage, 0, NULL); CreateThread(NULL, 0, MsgThreadFunction, g_pszThreadMessage, 0, NULL);
} }
} }
else { else
{
g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_KEYBOARD ); g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_KEYBOARD );
g_sysMouse.didHandle->Acquire(); g_sysMouse.didHandle->Acquire();
} }
@ -413,7 +417,8 @@ EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo)
PrepareInputDevices(); PrepareInputDevices();
if( g_bExclusiveMouse ) { if( g_bExclusiveMouse )
{
// g_sysMouse.didHandle->Unacquire(); // g_sysMouse.didHandle->Unacquire();
// g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); // PrepareInputDevices does this. // g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); // PrepareInputDevices does this.
g_sysMouse.didHandle->Acquire(); g_sysMouse.didHandle->Acquire();
@ -517,7 +522,8 @@ EXPORT void CALL GetKeys(int Control, BUTTONS * Keys )
{ {
EnterCriticalSection( &g_critical ); EnterCriticalSection( &g_critical );
if( g_pcControllers[Control].fPlugged ) { if( g_pcControllers[Control].fPlugged )
{
if (Control == g_iFirstController ) if (Control == g_iFirstController )
{ {
GetDeviceDatas(); GetDeviceDatas();
@ -667,8 +673,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command )
GetNControllerInput( Control, (DWORD*)&Command[3] ); GetNControllerInput( Control, (DWORD*)&Command[3] );
} }
break; break;
case RD_READPAK: case RD_READPAK:
#ifdef ENABLE_RAWPAK_DEBUG #ifdef ENABLE_RAWPAK_DEBUG
WriteDatasA( "ReadPak-PreProcessing", Control, Command, 0); WriteDatasA( "ReadPak-PreProcessing", Control, Command, 0);
@ -688,7 +692,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command )
DebugWriteA( NULL ); DebugWriteA( NULL );
#endif #endif
break; break;
case RD_WRITEPAK: case RD_WRITEPAK:
#ifdef ENABLE_RAWPAK_DEBUG #ifdef ENABLE_RAWPAK_DEBUG
WriteDatasA( "WritePak-PreProcessing", Control, Command, 0); WriteDatasA( "WritePak-PreProcessing", Control, Command, 0);
@ -707,7 +710,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command )
DebugWriteA( NULL ); DebugWriteA( NULL );
#endif #endif
break; break;
case RD_READEEPROM: case RD_READEEPROM:
// Should be handled by the Emulator // Should be handled by the Emulator
WriteDatasA( "ReadEeprom-PreProcessing", Control, Command, 0); WriteDatasA( "ReadEeprom-PreProcessing", Control, Command, 0);
@ -720,7 +722,6 @@ EXPORT void CALL ReadController( int Control, BYTE * Command )
WriteDatasA( "WriteEeprom-PostProcessing", Control, Command, 0); WriteDatasA( "WriteEeprom-PostProcessing", Control, Command, 0);
DebugWriteA( NULL ); DebugWriteA( NULL );
break; break;
default: default:
// only accessible if the Emulator has bugs.. or maybe the Rom is flawed // only accessible if the Emulator has bugs.. or maybe the Rom is flawed
WriteDatasA( "ReadController: Bad read", Control, Command, 0); 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) ); LoadString( g_hResourceDLL, IDS_P_NONE, pszMessage, ARRAYSIZE(pszMessage) );
LeaveCriticalSection( &g_critical ); LeaveCriticalSection( &g_critical );
break; break;
case SC_MEMPAK: case SC_MEMPAK:
if (PAK_NONE == g_pcControllers[iControl].PakType) if (PAK_NONE == g_pcControllers[iControl].PakType)
{ {
@ -1018,7 +1018,6 @@ void DoShortcut( int iControl, int iShortcut )
bEjectFirst = true; bEjectFirst = true;
} }
break; break;
case SC_RUMBPAK: case SC_RUMBPAK:
if (PAK_NONE == g_pcControllers[iControl].PakType) if (PAK_NONE == g_pcControllers[iControl].PakType)
{ {
@ -1060,7 +1059,6 @@ void DoShortcut( int iControl, int iShortcut )
bEjectFirst = true; bEjectFirst = true;
} }
break; break;
case SC_VOICEPAK: case SC_VOICEPAK:
if (PAK_NONE == g_pcControllers[iControl].PakType) if (PAK_NONE == g_pcControllers[iControl].PakType)
{ {
@ -1076,7 +1074,6 @@ void DoShortcut( int iControl, int iShortcut )
bEjectFirst = true; bEjectFirst = true;
} }
break; break;
case SC_ADAPTPAK: case SC_ADAPTPAK:
if (PAK_NONE == g_pcControllers[iControl].PakType) if (PAK_NONE == g_pcControllers[iControl].PakType)
{ {
@ -1092,7 +1089,6 @@ void DoShortcut( int iControl, int iShortcut )
bEjectFirst = true; bEjectFirst = true;
} }
break; break;
case SC_SWMEMRUMB: case SC_SWMEMRUMB:
bEjectFirst = true; bEjectFirst = true;
if( g_pcControllers[iControl].PakType == PAK_MEM ) if( g_pcControllers[iControl].PakType == PAK_MEM )
@ -1104,7 +1100,6 @@ void DoShortcut( int iControl, int iShortcut )
iShortcut = PAK_MEM; iShortcut = PAK_MEM;
} }
break; break;
case SC_SWMEMADAPT: case SC_SWMEMADAPT:
bEjectFirst = true; bEjectFirst = true;
if( g_pcControllers[iControl].PakType == PAK_MEM ) if( g_pcControllers[iControl].PakType == PAK_MEM )
@ -1116,7 +1111,6 @@ void DoShortcut( int iControl, int iShortcut )
iShortcut = PAK_MEM; iShortcut = PAK_MEM;
} }
break; break;
default: default:
DebugWriteA("Invalid iShortcut passed to DoShortcut\n"); DebugWriteA("Invalid iShortcut passed to DoShortcut\n");
EnterCriticalSection( &g_critical ); EnterCriticalSection( &g_critical );

View File

@ -199,7 +199,6 @@ bool InitControllerPak( const int iControl )
} }
} }
break; break;
case PAK_RUMBLE: case PAK_RUMBLE:
{ {
g_pcControllers[iControl].pPakData = P_malloc( sizeof(RUMBLEPAK)); 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 ) * 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 ); //CreateFile( g_pcControllers[iControl].szTransferSave, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL );
tPak->iCurrentAccessMode = 0; tPak->iCurrentAccessMode = 0;
tPak->iCurrentBankNo = 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("") ); 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" ); DebugWriteA( "*** Init Transfer Pak - Success***\n" );
} else { }
else
{
DebugWriteA( "*** Init Transfer Pak - FAILURE***\n" ); DebugWriteA( "*** Init Transfer Pak - FAILURE***\n" );
} }
bReturn = true; bReturn = true;
} }
break; break;
/*case PAK_VOICE: /*case PAK_VOICE:
{ {
g_pcControllers[iControl].pPakData = P_malloc( sizeof(VOICEPAK)); g_pcControllers[iControl].pPakData = P_malloc( sizeof(VOICEPAK));
@ -261,7 +261,6 @@ bool InitControllerPak( const int iControl )
bReturn = true; bReturn = true;
} }
break;*/ break;*/
case PAK_ADAPTOID: case PAK_ADAPTOID:
if( !g_pcControllers[iControl].fIsAdaptoid ) if( !g_pcControllers[iControl].fIsAdaptoid )
g_pcControllers[iControl].PakType = PAK_NONE; g_pcControllers[iControl].PakType = PAK_NONE;
@ -281,8 +280,6 @@ bool InitControllerPak( const int iControl )
bReturn = true; bReturn = true;
} }
break; break;
/*case PAK_NONE: /*case PAK_NONE:
break;*/ break;*/
} }
@ -369,18 +366,25 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command )
FillMemory(Data, 32, 0x84); FillMemory(Data, 32, 0x84);
break; break;
case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF))
if (tPak->iEnableState == true) { if (tPak->iEnableState == true)
{
DebugWriteA( "Query Cart. State:" ); DebugWriteA( "Query Cart. State:" );
if (tPak->bPakInserted) { if (tPak->bPakInserted)
if (tPak->iCurrentAccessMode == 1) { {
if (tPak->iCurrentAccessMode == 1)
{
FillMemory(Data, 32, 0x89); FillMemory(Data, 32, 0x89);
DebugWriteA( " Inserted, Access Mode 1\n" ); DebugWriteA( " Inserted, Access Mode 1\n" );
} else { }
else
{
FillMemory(Data, 32, 0x80); FillMemory(Data, 32, 0x80);
DebugWriteA( " Inserted, Access Mode 0\n" ); DebugWriteA( " Inserted, Access Mode 0\n" );
} }
Data[0] = Data[0] | tPak->iAccessModeChanged; Data[0] = Data[0] | tPak->iAccessModeChanged;
} else { }
else
{
FillMemory(Data, 32, 0x40); // Cart not inserted. FillMemory(Data, 32, 0x40); // Cart not inserted.
DebugWriteA( " Not Inserted\n" ); DebugWriteA( " Not Inserted\n" );
} }
@ -391,7 +395,8 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command )
case 0xD: case 0xD:
case 0xE: case 0xE:
case 0xF: // if ((dwAddress >= 0xC000)) case 0xF: // if ((dwAddress >= 0xC000))
if (tPak->iEnableState == true) { if (tPak->iEnableState == true)
{
DebugWriteA( "Cart Read: Bank:%i\n", tPak->iCurrentBankNo ); DebugWriteA( "Cart Read: Bank:%i\n", tPak->iCurrentBankNo );
DebugWriteA( " Address:%04X\n", ((dwAddress & 0xFFE0) - 0xC000) + ((tPak->iCurrentBankNo & 3) * 0x4000) ); 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 #ifdef ENABLE_RAWPAK_DEBUG
DebugWriteA( "TPak Data: " ); 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 " ); if ((i < 31) && ((i & 7) == 0)) DebugWriteA( "\n " );
DebugWriteByteA(Data[i]); DebugWriteByteA(Data[i]);
if (i < 31) { if (i < 31)
{
DebugWriteA( ", "); DebugWriteA( ", ");
} }
} }
@ -421,10 +428,8 @@ BYTE ReadControllerPak( const int iControl, LPBYTE Command )
bReturn = RD_OK; bReturn = RD_OK;
} }
break; break;
/*case PAK_VOICE: /*case PAK_VOICE:
break;*/ break;*/
case PAK_ADAPTOID: case PAK_ADAPTOID:
if( ReadAdaptoidPak( iControl, dwAddress, Data ) == DI_OK ) if( ReadAdaptoidPak( iControl, dwAddress, Data ) == DI_OK )
{ {
@ -552,7 +557,6 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors
Data[32] = DataCRC( Data, 32 ); Data[32] = DataCRC( Data, 32 );
bReturn = RD_OK; bReturn = RD_OK;
break; break;
case PAK_TRANSFER: case PAK_TRANSFER:
{ {
LPTRANSFERPAK tPak = (LPTRANSFERPAK)g_pcControllers[iControl].pPakData; 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 #ifdef ENABLE_RAWPAK_DEBUG
DebugWriteA( " Data: "); DebugWriteA( " Data: ");
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++)
if ((i < 31) && ((i & 7) == 0)) DebugWriteA( "\n " ); {
if ((i < 31) && ((i & 7) == 0))
{
DebugWriteA( "\n " );
}
DebugWriteByteA( Data[i]); DebugWriteByteA( Data[i]);
if (i < 31) { if (i < 31)
{
DebugWriteA( ", " ); DebugWriteA( ", " );
} }
} }
@ -577,15 +586,18 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors
switch (dwAddress >> 12) switch (dwAddress >> 12)
{ {
case 0x8: // if ((dwAddress >= 0x8000) && (dwAddress <= 0x8FFF)) case 0x8: // if ((dwAddress >= 0x8000) && (dwAddress <= 0x8FFF))
if (Data[0] == 0xFE) { if (Data[0] == 0xFE)
{
DebugWriteA("Cart Disable\n" ); DebugWriteA("Cart Disable\n" );
tPak->iEnableState = false; tPak->iEnableState = false;
} }
else if (Data[0] == 0x84) { else if (Data[0] == 0x84)
{
DebugWriteA("Cart Enable\n" ); DebugWriteA("Cart Enable\n" );
tPak->iEnableState = true; tPak->iEnableState = true;
} }
else { else
{
DebugWriteA("WARNING: Unusual Cart Enable/Disable\n" ); DebugWriteA("WARNING: Unusual Cart Enable/Disable\n" );
DebugWriteA(" Address: " ); DebugWriteA(" Address: " );
DebugWriteWordA(dwAddress); DebugWriteWordA(dwAddress);
@ -596,17 +608,20 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors
} }
break; break;
case 0xA: // if ((dwAddress >= 0xA000) && (dwAddress <= 0xAFFF)) case 0xA: // if ((dwAddress >= 0xA000) && (dwAddress <= 0xAFFF))
if (tPak->iEnableState == true) { if (tPak->iEnableState == true)
{
tPak->iCurrentBankNo = Data[0]; tPak->iCurrentBankNo = Data[0];
DebugWriteA("Set TPak Bank No:%02X\n", Data[0] ); DebugWriteA("Set TPak Bank No:%02X\n", Data[0] );
} }
break; break;
case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF)) case 0xB: // if ((dwAddress >= 0xB000) && (dwAddress <= 0xBFFF))
if (tPak->iEnableState == true) { if (tPak->iEnableState == true)
{
tPak->iCurrentAccessMode = Data[0] & 1; tPak->iCurrentAccessMode = Data[0] & 1;
tPak->iAccessModeChanged = 4; tPak->iAccessModeChanged = 4;
DebugWriteA("Set TPak Access Mode: %04X\n", tPak->iCurrentAccessMode); 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("WARNING: Unusual Access Mode Change\n" );
DebugWriteA(" Address: " ); DebugWriteA(" Address: " );
DebugWriteWordA(dwAddress); DebugWriteWordA(dwAddress);
@ -634,10 +649,8 @@ end_rumble: // added so after xinput controller rumbles, gets here --tecnicors
bReturn = RD_OK; bReturn = RD_OK;
} }
break; break;
/*case PAK_VOICE: /*case PAK_VOICE:
break;*/ break;*/
case PAK_ADAPTOID: case PAK_ADAPTOID:
if(( dwAddress == PAK_IO_RUMBLE ) && ((ADAPTOIDPAK*)g_pcControllers[iControl].pPakData)->fRumblePak ) 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; break;
/*case PAK_NONE: /*case PAK_NONE:
break;*/ break;*/
} }
@ -700,7 +712,6 @@ void SaveControllerPak( const int iControl )
break; break;
case PAK_ADAPTOID: case PAK_ADAPTOID:
break; break;
/*case PAK_NONE: /*case PAK_NONE:
break;*/ break;*/
} }
@ -750,10 +761,8 @@ void CloseControllerPak( const int iControl )
break; break;
case PAK_VOICE: case PAK_VOICE:
break; break;
case PAK_ADAPTOID: case PAK_ADAPTOID:
break; break;
/*case PAK_NONE: /*case PAK_NONE:
break;*/ break;*/
} }
@ -789,8 +798,6 @@ inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes
return wRemainingBlocks; return wRemainingBlocks;
} }
void FormatMemPak( LPBYTE aMemPak ) void FormatMemPak( LPBYTE aMemPak )
{ {
FillMemory( aMemPak, 0x100, 0xFF ); FillMemory( aMemPak, 0x100, 0xFF );
@ -825,8 +832,6 @@ void FormatMemPak( LPBYTE aMemPak )
aMemPak[0x30+14] = aMemPak[0x70+14] = aMemPak[0x90+14] = aMemPak[0xD0+14] = aCode[6]; 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]; aMemPak[0x30+15] = aMemPak[0x70+15] = aMemPak[0x90+15] = aMemPak[0xD0+15] = aCode[7];
// Index // Index
ZeroMemory( &aMemPak[0x100], 0x400 ); ZeroMemory( &aMemPak[0x100], 0x400 );
@ -834,9 +839,7 @@ void FormatMemPak( LPBYTE aMemPak )
for( int i = 0x00b; i < 0x100; i += 2 ) for( int i = 0x00b; i < 0x100; i += 2 )
aMemPak[0x100+i] = aMemPak[0x200+i] = 03; aMemPak[0x100+i] = aMemPak[0x200+i] = 03;
FillMemory( &aMemPak[0x500], 0x7B00, 0xFF ); FillMemory( &aMemPak[0x500], 0x7B00, 0xFF );
} }
// Translates a mempak header into a real Unicode string, for display in the Mempaks window // 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]; bBlock = aMemPak[iPos];
aMemPak[iPos] = 0x03; aMemPak[iPos] = 0x03;
} }
int i = 0, iSum = 0; int i = 0, iSum = 0;
for( i = 0x10A; i < 0x200; i++ ) for( i = 0x10A; i < 0x200; i++ )
iSum += aMemPak[i]; iSum += aMemPak[i];
aMemPak[0x101] = iSum % 256; aMemPak[0x101] = iSum % 256;
CopyMemory( &aMemPak[0x200], &aMemPak[0x100], 0x100 ); CopyMemory( &aMemPak[0x200], &aMemPak[0x100], 0x100 );
ZeroMemory( &aMemPak[0x300 + iNote*32], 32 ); ZeroMemory( &aMemPak[0x300 + iNote*32], 32 );
return true; return true;
} }
BYTE AddressCRC( const unsigned char * Address ) BYTE AddressCRC( const unsigned char * Address )
{ {
bool HighBit; bool HighBit;
@ -1433,7 +1432,6 @@ BYTE AddressCRC( const unsigned char * Address )
Remainder = (Remainder << 1) & 0x1E; Remainder = (Remainder << 1) & 0x1E;
Remainder += ( bBit < 11 && Data & (0x8000 >> bBit )) ? 1 : 0; Remainder += ( bBit < 11 && Data & (0x8000 >> bBit )) ? 1 : 0;
Remainder ^= (HighBit) ? 0x15 : 0; Remainder ^= (HighBit) ? 0x15 : 0;
bBit++; bBit++;