[Project64] change AsciiToHex to std::strtoul in rom browser

This commit is contained in:
zilmar 2015-11-07 12:45:59 +11:00
parent a1d9af57a6
commit 6a2e88a25c
2 changed files with 697 additions and 748 deletions

View File

@ -231,15 +231,11 @@ int CRomBrowser::CalcSortPosition (DWORD lParam)
{ {
Right = (float)NewTestPos; Right = (float)NewTestPos;
} }
} }
End = (int)Left; End = (int)Left;
break; break;
} }
} }
} }
//Compare end with item to see if we should do it after or before it //Compare end with item to see if we should do it after or before it
@ -335,48 +331,6 @@ void CRomBrowser::AllocateBrushs (void)
} }
} }
DWORD CRomBrowser::AsciiToHex (char * HexValue)
{
DWORD Count, Finish, Value = 0;
Finish = strlen(HexValue);
if (Finish > 8 ) { Finish = 8; }
for (Count = 0; Count < Finish; Count++)
{
Value = (Value << 4);
switch( HexValue[Count] ) {
case '0': break;
case '1': Value += 1; break;
case '2': Value += 2; break;
case '3': Value += 3; break;
case '4': Value += 4; break;
case '5': Value += 5; break;
case '6': Value += 6; break;
case '7': Value += 7; break;
case '8': Value += 8; break;
case '9': Value += 9; break;
case 'A': Value += 10; break;
case 'a': Value += 10; break;
case 'B': Value += 11; break;
case 'b': Value += 11; break;
case 'C': Value += 12; break;
case 'c': Value += 12; break;
case 'D': Value += 13; break;
case 'd': Value += 13; break;
case 'E': Value += 14; break;
case 'e': Value += 14; break;
case 'F': Value += 15; break;
case 'f': Value += 15; break;
default:
Value = (Value >> 4);
Count = Finish;
}
}
return Value;
}
void CRomBrowser::CreateRomListControl(void) void CRomBrowser::CreateRomListControl(void)
{ {
m_hRomList = (HWND)CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, m_hRomList = (HWND)CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
@ -466,20 +420,20 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo)
//Get the text color //Get the text color
char String[100]; char String[100];
m_RomIniFile->GetString("Rom Status", pRomInfo->Status, "000000", String, 7); m_RomIniFile->GetString("Rom Status", pRomInfo->Status, "000000", String, 7);
pRomInfo->TextColor = (AsciiToHex(String) & 0xFFFFFF); pRomInfo->TextColor = (std::strtoul(String, 0, 16) & 0xFFFFFF);
pRomInfo->TextColor = (pRomInfo->TextColor & 0x00FF00) | ((pRomInfo->TextColor >> 0x10) & 0xFF) | ((pRomInfo->TextColor & 0xFF) << 0x10); pRomInfo->TextColor = (pRomInfo->TextColor & 0x00FF00) | ((pRomInfo->TextColor >> 0x10) & 0xFF) | ((pRomInfo->TextColor & 0xFF) << 0x10);
//Get the selected color //Get the selected color
sprintf(String, "%s.Sel", pRomInfo->Status); sprintf(String, "%s.Sel", pRomInfo->Status);
m_RomIniFile->GetString("Rom Status", String, "FFFFFFFF", String, 9); m_RomIniFile->GetString("Rom Status", String, "FFFFFFFF", String, 9);
int selcol = AsciiToHex(String); int selcol = std::strtoul(String, 0, 16);
if (selcol < 0) if (selcol < 0)
{ {
pRomInfo->SelColor = -1; pRomInfo->SelColor = -1;
} }
else else
{ {
selcol = (AsciiToHex(String) & 0xFFFFFF); selcol = (std::strtoul(String, 0, 16) & 0xFFFFFF);
selcol = (selcol & 0x00FF00) | ((selcol >> 0x10) & 0xFF) | ((selcol & 0xFF) << 0x10); selcol = (selcol & 0x00FF00) | ((selcol >> 0x10) & 0xFF) | ((selcol & 0xFF) << 0x10);
pRomInfo->SelColor = selcol; pRomInfo->SelColor = selcol;
} }
@ -487,7 +441,7 @@ void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo)
//Get the selected text color //Get the selected text color
sprintf(String, "%s.Seltext", pRomInfo->Status); sprintf(String, "%s.Seltext", pRomInfo->Status);
m_RomIniFile->GetString("Rom Status", String, "FFFFFF", String, 7); m_RomIniFile->GetString("Rom Status", String, "FFFFFF", String, 7);
pRomInfo->SelTextColor = (AsciiToHex(String) & 0xFFFFFF); pRomInfo->SelTextColor = (std::strtoul(String, 0, 16) & 0xFFFFFF);
pRomInfo->SelTextColor = (pRomInfo->SelTextColor & 0x00FF00) | ((pRomInfo->SelTextColor >> 0x10) & 0xFF) | ((pRomInfo->SelTextColor & 0xFF) << 0x10); pRomInfo->SelTextColor = (pRomInfo->SelTextColor & 0x00FF00) | ((pRomInfo->SelTextColor >> 0x10) & 0xFF) | ((pRomInfo->SelTextColor & 0xFF) << 0x10);
} }
@ -591,7 +545,6 @@ void CRomBrowser::NotificationCB ( LPCWSTR Status, CRomBrowser * /*_this*/ )
g_Notify->DisplayMessage(5, Status); g_Notify->DisplayMessage(5, Status);
} }
void CRomBrowser::AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File) void CRomBrowser::AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File)
{ {
if (FileList.size() > 3000) if (FileList.size() > 3000)
@ -656,7 +609,6 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory,
{ {
try try
{ {
C7zip ZipFile(SearchPath); C7zip ZipFile(SearchPath);
if (!ZipFile.OpenSuccess()) if (!ZipFile.OpenSuccess())
{ {
@ -741,7 +693,7 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory,
for (int x = 0; x < 0x40; x += 4) for (int x = 0; x < 0x40; x += 4)
{ {
*((DWORD *)&RomData[x]) = AsciiToHex(&szHeader[x*2]); *((DWORD *)&RomData[x]) = std::strtoul(&szHeader[x * 2], 0, 16);
} }
WriteTrace(TraceDebug, __FUNCTION__ ": 14"); WriteTrace(TraceDebug, __FUNCTION__ ": 14");
@ -914,7 +866,6 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i
unzCloseCurrentFile(file); unzCloseCurrentFile(file);
port = unzGoToNextFile(file); port = unzGoToNextFile(file);
} }
} }
if (FoundRom == false) if (FoundRom == false)
{ {
@ -1577,7 +1528,6 @@ void CRomBrowser::RomList_SortList(void)
} }
} }
/* /*
* SaveRomList - save all the rom information about the current roms in the rom brower * SaveRomList - save all the rom information about the current roms in the rom brower
* to a cache file, so it is quick to reload the information * to a cache file, so it is quick to reload the information
@ -1952,6 +1902,4 @@ void CRomBrowser::WatchThreadStop( void )
m_WatchThread = NULL; m_WatchThread = NULL;
m_WatchThreadID = 0; m_WatchThreadID = 0;
WriteTrace(TraceDebug, __FUNCTION__ ": 5"); WriteTrace(TraceDebug, __FUNCTION__ ": 5");
} }

View File

@ -80,13 +80,15 @@ class C7zip;
class CRomBrowser class CRomBrowser
{ {
enum { IDC_ROMLIST = 223 }; enum { IDC_ROMLIST = 223 };
enum { RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2, enum {
RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2,
RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5, RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5,
RB_PluginNotes = 6, RB_UserNotes = 7, RB_CartridgeID = 8, RB_PluginNotes = 6, RB_UserNotes = 7, RB_CartridgeID = 8,
RB_Manufacturer = 9, RB_Country = 10, RB_Developer = 11, RB_Manufacturer = 9, RB_Country = 10, RB_Developer = 11,
RB_Crc1 = 12, RB_Crc2 = 13, RB_CICChip = 14, RB_Crc1 = 12, RB_Crc2 = 13, RB_CICChip = 14,
RB_ReleaseDate = 15, RB_Genre = 16, RB_Players = 17, RB_ReleaseDate = 15, RB_Genre = 16, RB_Players = 17,
RB_ForceFeedback = 18, RB_FileFormat = 19 }; RB_ForceFeedback = 18, RB_FileFormat = 19
};
enum FILE_FORMAT { enum FILE_FORMAT {
Format_Uncompressed, Format_Uncompressed,
@ -150,7 +152,6 @@ class CRomBrowser
void AddRomToList(const char * RomLocation, const char * lpLastRom); void AddRomToList(const char * RomLocation, const char * lpLastRom);
void AddRomInfoToList(ROM_INFO &RomInfo, const char * lpLastRom); void AddRomInfoToList(ROM_INFO &RomInfo, const char * lpLastRom);
void AllocateBrushs(void); void AllocateBrushs(void);
DWORD AsciiToHex ( char * HexValue );
static void ByteSwapRomData(BYTE * Data, int DataLen); static void ByteSwapRomData(BYTE * Data, int DataLen);
int CalcSortPosition(DWORD lParam); int CalcSortPosition(DWORD lParam);
void CreateRomListControl(void); void CreateRomListControl(void);