This commit is contained in:
zilmar 2012-09-29 18:02:32 +10:00
commit d592afc787
3 changed files with 56 additions and 59 deletions

View File

@ -455,56 +455,54 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) {
} }
bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) { bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) {
int count;
BYTE RomData[0x1000]; BYTE RomData[0x1000];
if (!LoadDataFromRomFile(pRomInfo->szFullFileName,RomData,sizeof(RomData),&pRomInfo->RomSize,pRomInfo->FileFormat)) { return FALSE; } if (!LoadDataFromRomFile(pRomInfo->szFullFileName,RomData,sizeof(RomData),&pRomInfo->RomSize,pRomInfo->FileFormat))
return FillRomInfo2(pRomInfo,RomData, sizeof(RomData));
}
bool CRomBrowser::FillRomInfo2(ROM_INFO * pRomInfo, BYTE * RomData, DWORD RomDataSize )
{
int count;
if (strstr(pRomInfo->szFullFileName,"?") != NULL)
{ {
strcpy(pRomInfo->FileName,strstr(pRomInfo->szFullFileName,"?") + 1); return false;
} else {
char drive[_MAX_DRIVE] ,dir[_MAX_DIR], ext[_MAX_EXT];
_splitpath( pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext );
} }
if (m_Fields[RB_InternalName].Pos() >= 0) { else
memcpy(pRomInfo->InternalName,(void *)(RomData + 0x20),20); {
for( count = 0 ; count < 20; count += 4 ) { if (strstr(pRomInfo->szFullFileName,"?") != NULL)
pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; {
pRomInfo->InternalName[count + 3] ^= pRomInfo->InternalName[count]; strcpy(pRomInfo->FileName,strstr(pRomInfo->szFullFileName,"?") + 1);
pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; } else {
pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2]; char drive[_MAX_DRIVE] ,dir[_MAX_DIR], ext[_MAX_EXT];
pRomInfo->InternalName[count + 2] ^= pRomInfo->InternalName[count + 1]; _splitpath( pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext );
pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2];
} }
pRomInfo->InternalName[21] = '\0'; if (m_Fields[RB_InternalName].Pos() >= 0) {
memcpy(pRomInfo->InternalName,(void *)(RomData + 0x20),20);
for( count = 0 ; count < 20; count += 4 ) {
pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3];
pRomInfo->InternalName[count + 3] ^= pRomInfo->InternalName[count];
pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3];
pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2];
pRomInfo->InternalName[count + 2] ^= pRomInfo->InternalName[count + 1];
pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2];
}
pRomInfo->InternalName[21] = '\0';
}
pRomInfo->CartID[0] = *(RomData + 0x3F);
pRomInfo->CartID[1] = *(RomData + 0x3E);
pRomInfo->CartID[2] = '\0';
pRomInfo->Manufacturer = *(RomData + 0x38);
pRomInfo->Country = *(RomData + 0x3D);
pRomInfo->CRC1 = *(DWORD *)(RomData + 0x10);
pRomInfo->CRC2 = *(DWORD *)(RomData + 0x14);
pRomInfo->CicChip = GetCicChipID(RomData);
FillRomExtensionInfo(pRomInfo);
if (pRomInfo->SelColor == -1) {
pRomInfo->SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1));
} else {
pRomInfo->SelColorBrush = (DWORD)CreateSolidBrush(pRomInfo->SelColor);
}
return true;
} }
pRomInfo->CartID[0] = *(RomData + 0x3F);
pRomInfo->CartID[1] = *(RomData + 0x3E);
pRomInfo->CartID[2] = '\0';
pRomInfo->Manufacturer = *(RomData + 0x38);
pRomInfo->Country = *(RomData + 0x3D);
pRomInfo->CRC1 = *(DWORD *)(RomData + 0x10);
pRomInfo->CRC2 = *(DWORD *)(RomData + 0x14);
pRomInfo->CicChip = GetCicChipID(RomData);
FillRomExtensionInfo(pRomInfo);
if (pRomInfo->SelColor == -1) {
pRomInfo->SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1));
} else {
pRomInfo->SelColorBrush = (DWORD)CreateSolidBrush(pRomInfo->SelColor);
}
return TRUE;
} }
void CRomBrowser::GetRomFileNames( strlist & FileList, CPath & BaseDirectory, stdstr & Directory, bool InWatchThread ) void CRomBrowser::GetRomFileNames( strlist & FileList, CPath & BaseDirectory, stdstr & Directory, bool InWatchThread )
{ {
@ -782,7 +780,7 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
char zname[132]; char zname[132];
unzFile file; unzFile file;
file = unzOpen(FileName); file = unzOpen(FileName);
if (file == NULL) { return FALSE; } if (file == NULL) { return false; }
port = unzGoToFirstFile(file); port = unzGoToFirstFile(file);
FoundRom = FALSE; FoundRom = FALSE;
@ -790,15 +788,15 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0); unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0);
if (unzLocateFile(file, zname, 1) != UNZ_OK ) { if (unzLocateFile(file, zname, 1) != UNZ_OK ) {
unzClose(file); unzClose(file);
return FALSE; return true;
} }
if( unzOpenCurrentFile(file) != UNZ_OK ) { if( unzOpenCurrentFile(file) != UNZ_OK ) {
unzClose(file); unzClose(file);
return FALSE; return true;
} }
unzReadCurrentFile(file,Test,4); unzReadCurrentFile(file,Test,4);
if (CN64Rom::IsValidRomImage(Test)) { if (CN64Rom::IsValidRomImage(Test)) {
FoundRom = TRUE; FoundRom = true;
//RomFileSize = info.uncompressed_size; //RomFileSize = info.uncompressed_size;
memcpy(Data,Test,4); memcpy(Data,Test,4);
len = unzReadCurrentFile(file,&Data[4],DataLen - 4) + 4; len = unzReadCurrentFile(file,&Data[4],DataLen - 4) + 4;
@ -806,23 +804,23 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
if ((int)DataLen != len) { if ((int)DataLen != len) {
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
unzClose(file); unzClose(file);
return FALSE; return false;
} }
*RomSize = info.uncompressed_size; *RomSize = info.uncompressed_size;
if(unzCloseCurrentFile(file) == UNZ_CRCERROR) { if(unzCloseCurrentFile(file) == UNZ_CRCERROR) {
unzClose(file); unzClose(file);
return FALSE; return false;
} }
unzClose(file); unzClose(file);
} }
if (FoundRom == FALSE) { if (FoundRom == false) {
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
port = unzGoToNextFile(file); port = unzGoToNextFile(file);
} }
} }
if (FoundRom == FALSE) { if (FoundRom == false) {
return FALSE; return false;
} }
FileFormat = Format_Zip; FileFormat = Format_Zip;
} else { } else {
@ -833,19 +831,19 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
NULL); NULL);
if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } if (hFile == INVALID_HANDLE_VALUE) { return false; }
SetFilePointer(hFile,0,0,FILE_BEGIN); SetFilePointer(hFile,0,0,FILE_BEGIN);
ReadFile(hFile,Test,4,&dwRead,NULL); ReadFile(hFile,Test,4,&dwRead,NULL);
if (!CN64Rom::IsValidRomImage(Test)) { CloseHandle( hFile ); return FALSE; } if (!CN64Rom::IsValidRomImage(Test)) { CloseHandle( hFile ); return false; }
SetFilePointer(hFile,0,0,FILE_BEGIN); SetFilePointer(hFile,0,0,FILE_BEGIN);
if (!ReadFile(hFile,Data,DataLen,&dwRead,NULL)) { CloseHandle( hFile ); return FALSE; } if (!ReadFile(hFile,Data,DataLen,&dwRead,NULL)) { CloseHandle( hFile ); return false; }
*RomSize = GetFileSize(hFile,NULL); *RomSize = GetFileSize(hFile,NULL);
CloseHandle( hFile ); CloseHandle( hFile );
FileFormat = Format_Uncompressed; FileFormat = Format_Uncompressed;
} }
ByteSwapRomData(Data,DataLen); ByteSwapRomData(Data,DataLen);
return TRUE; return true;
} }
void CRomBrowser::ByteSwapRomData (BYTE * Data, int DataLen) void CRomBrowser::ByteSwapRomData (BYTE * Data, int DataLen)

View File

@ -146,7 +146,6 @@ class CRomBrowser
void DeallocateBrushs ( void ); void DeallocateBrushs ( void );
void FillRomExtensionInfo ( ROM_INFO * pRomInfo ); void FillRomExtensionInfo ( ROM_INFO * pRomInfo );
bool FillRomInfo ( ROM_INFO * pRomInfo ); bool FillRomInfo ( ROM_INFO * pRomInfo );
bool FillRomInfo2 ( ROM_INFO * pRomInfo, BYTE * RomData, DWORD RomDataSize );
void FillRomList ( strlist & FileList, CPath & BaseDirectory, stdstr & Directory, const char * lpLastRom ); void FillRomList ( strlist & FileList, CPath & BaseDirectory, stdstr & Directory, const char * lpLastRom );
void FixRomListWindow ( void ); void FixRomListWindow ( void );
static int GetCicChipID ( BYTE * RomData ); static int GetCicChipID ( BYTE * RomData );

View File

@ -537,8 +537,8 @@ void RSP_SW_DMEM ( DWORD Addr, DWORD Value ) {
} }
*(BYTE *)(RSPInfo.DMEM + (Addr ^ 3)) = (BYTE)(Value >> 0x18); *(BYTE *)(RSPInfo.DMEM + (Addr ^ 3)) = (BYTE)(Value >> 0x18);
*(BYTE *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) = (BYTE)(Value >> 0x10); *(BYTE *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) = (BYTE)(Value >> 0x10);
*(BYTE *)(RSPInfo.DMEM + ((Addr + 2) ^ 3)) = (BYTE)(Value >> 0x8); *(BYTE *)(RSPInfo.DMEM + ((Addr + 2) ^ 3)) = (BYTE)(Value >> 0x8 &0xFF);
*(BYTE *)(RSPInfo.DMEM + ((Addr + 3) ^ 3)) = (BYTE)(Value); *(BYTE *)(RSPInfo.DMEM + ((Addr + 3) ^ 3)) = (BYTE)(Value &0xFF);
return; return;
} }
*(DWORD *)(RSPInfo.DMEM + Addr) = Value; *(DWORD *)(RSPInfo.DMEM + Addr) = Value;