From 8942ae2b47f2f90e9bebaceb142460f3989525c0 Mon Sep 17 00:00:00 2001 From: "Derek \"Turtle\" Roe" Date: Fri, 2 Apr 2021 02:43:33 -0500 Subject: [PATCH] Update RomList.cpp Fix comments, and fix some log and trace typos --- Source/Project64-core/RomList/RomList.cpp | 79 +++++++++++------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 88f864407..d8884e4d5 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -93,7 +93,7 @@ void CRomList::RefreshRomList(void) { if (m_RefreshThread.isRunning()) { - WriteTrace(TraceRomList, TraceVerbose, "already refreshing, ignoring"); + WriteTrace(TraceRomList, TraceVerbose, "Already refreshing, ignoring"); return; } WriteTrace(TraceRomList, TraceDebug, "Starting thread"); @@ -105,11 +105,11 @@ void CRomList::RefreshRomList(void) void CRomList::RefreshRomListThread(void) { WriteTrace(TraceRomList, TraceVerbose, "Start"); - //delete cache + // Delete cache CPath(g_Settings->LoadStringVal(RomList_RomListCache)).Delete(); - WriteTrace(TraceRomList, TraceVerbose, "Cache Deleted"); + WriteTrace(TraceRomList, TraceVerbose, "Cache deleted"); - //clear all current items + // Clear all current items RomListReset(); m_RomInfo.clear(); @@ -134,7 +134,7 @@ void CRomList::AddRomToList(const char * RomLocation) } else { - WriteTrace(TraceRomList, TraceVerbose, "Failed to fill rom information, ignoring"); + WriteTrace(TraceRomList, TraceVerbose, "Failed to fill ROM information, ignoring"); } WriteTrace(TraceRomList, TraceVerbose, "Done"); } @@ -158,7 +158,7 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) WriteTrace(TraceRomList, TraceVerbose, "Found: \"%s\" m_StopRefresh = %s", (const char *)SearchDir, m_StopRefresh ? "true" : "false"); if (m_StopRefresh) { - WriteTrace(TraceRomList, TraceVerbose, "stop refresh set, stopping"); + WriteTrace(TraceRomList, TraceVerbose, "Stop refresh set, stopping"); break; } @@ -262,7 +262,7 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) WriteTrace(TraceUserInterface, TraceDebug, "11a %s", RomHeader.c_str()); int32_t CicChip = CN64Rom::GetCicChipID(RomData); - //save this info + // Save this info WriteTrace(TraceUserInterface, TraceDebug, "12"); m_ZipIniFile->SaveString(SectionName.c_str(), FileName.c_str(), RomHeader.c_str()); m_ZipIniFile->SaveNumber(SectionName.c_str(), stdstr_f("%s-Cic", FileName.c_str()).c_str(), CicChip); @@ -310,7 +310,7 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) } catch (...) { - WriteTrace(TraceUserInterface, TraceError, "exception processing %s", (LPCSTR)SearchDir); + WriteTrace(TraceUserInterface, TraceError, "Exception processing %s", (LPCSTR)SearchDir); } } #endif @@ -421,9 +421,9 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_ uint32_t diskidoffset = 0x43670; uint32_t romdataoffset = 0x738C0; bool isValidDisk = false; - //Could still be a Disk Image + // Could still be a disk image - //System Data + // System data const uint8_t blocks[7] = { 2, 3, 10, 11, 1, 8, 9 }; for (int i = 0; i < 7; i++) { @@ -462,7 +462,7 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_ } else if (CN64Disk::IsValidDiskImage(Test)) { - //Is a Disk Image + // If it is a disk image uint32_t sysdataoffset = 0; uint32_t diskidoffset = 0x100; uint32_t romdataoffset = 0x200; @@ -564,7 +564,7 @@ bool CRomList::FillRomInfo(ROM_INFO * pRomInfo) void CRomList::FillRomExtensionInfo(ROM_INFO * pRomInfo) { - //Initialize the structure + // Initialize the structure pRomInfo->UserNotes[0] = '\0'; pRomInfo->Developer[0] = '\0'; pRomInfo->ReleaseDate[0] = '\0'; @@ -588,29 +588,29 @@ void CRomList::FillRomExtensionInfo(ROM_INFO * pRomInfo) } } - //Rom Notes + // ROM notes strncpy(pRomInfo->UserNotes, m_NotesIniFile->GetString(Identifier, "Note", "").c_str(), sizeof(pRomInfo->UserNotes) / sizeof(char)); - //Rom Extension info + // ROM extension info strncpy(pRomInfo->Developer, m_ExtIniFile->GetString(Identifier, "Developer", "").c_str(), sizeof(pRomInfo->Developer) / sizeof(char)); strncpy(pRomInfo->ReleaseDate, m_ExtIniFile->GetString(Identifier, "ReleaseDate", "").c_str(), sizeof(pRomInfo->ReleaseDate) / sizeof(char)); strncpy(pRomInfo->Genre, m_ExtIniFile->GetString(Identifier, "Genre", "").c_str(), sizeof(pRomInfo->Genre) / sizeof(char)); m_ExtIniFile->GetNumber(Identifier, "Players", 1, (uint32_t &)pRomInfo->Players); strncpy(pRomInfo->ForceFeedback, m_ExtIniFile->GetString(Identifier, "ForceFeedback", "unknown").c_str(), sizeof(pRomInfo->ForceFeedback) / sizeof(char)); - //Rom Settings + // ROM settings strncpy(pRomInfo->GoodName, m_RomIniFile->GetString(Identifier, "Good Name", pRomInfo->GoodName).c_str(), sizeof(pRomInfo->GoodName) / sizeof(char)); strncpy(pRomInfo->Name, m_RomIniFile->GetString(Identifier, "Good Name", pRomInfo->Name).c_str(), sizeof(pRomInfo->Name) / sizeof(char)); strncpy(pRomInfo->Status, m_RomIniFile->GetString(Identifier, "Status", pRomInfo->Status).c_str(), sizeof(pRomInfo->Status) / sizeof(char)); strncpy(pRomInfo->CoreNotes, m_RomIniFile->GetString(Identifier, "Core Note", "").c_str(), sizeof(pRomInfo->CoreNotes) / sizeof(char)); strncpy(pRomInfo->PluginNotes, m_RomIniFile->GetString(Identifier, "Plugin Note", "").c_str(), sizeof(pRomInfo->PluginNotes) / sizeof(char)); - //Get the text color + // Get the text color stdstr String = m_RomIniFile->GetString("Rom Status", pRomInfo->Status, "000000"); pRomInfo->TextColor = (strtoul(String.c_str(), 0, 16) & 0xFFFFFF); pRomInfo->TextColor = (pRomInfo->TextColor & 0x00FF00) | ((pRomInfo->TextColor >> 0x10) & 0xFF) | ((pRomInfo->TextColor & 0xFF) << 0x10); - //Get the selected color + // Get the selected color String.Format("%s.Sel", pRomInfo->Status); String = m_RomIniFile->GetString("Rom Status", String.c_str(), "FFFFFFFF"); uint32_t selcol = strtoul(String.c_str(), NULL, 16); @@ -624,7 +624,7 @@ void CRomList::FillRomExtensionInfo(ROM_INFO * pRomInfo) pRomInfo->SelColor = selcol; } - //Get the selected text color + // Get the selected text color String.Format("%s.Seltext", pRomInfo->Status); String = m_RomIniFile->GetString("Rom Status", String.c_str(), "FFFFFF"); pRomInfo->SelTextColor = (strtoul(String.c_str(), 0, 16) & 0xFFFFFF); @@ -638,9 +638,9 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen) switch (*((uint32_t *)&Data[0])) { case 0x12408037: - case 0x07408027: //64DD IPL - case 0xD316E848: //64DD JP Disk - case 0xEE562263: //64DD US Disk + case 0x07408027: // 64DD IPL + case 0xD316E848: // 64DD JP disk + case 0xEE562263: // 64DD US disk for (count = 0; count < DataLen; count += 4) { Data[count] ^= Data[count + 2]; @@ -651,11 +651,11 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen) Data[count + 1] ^= Data[count + 3]; } break; - case 0x40072780: //64DD IPL - case 0x16D348E8: //64DD JP Disk - case 0x56EE6322: //64DD US Disk + case 0x40072780: // 64DD IPL + case 0x16D348E8: // 64DD JP disk + case 0x56EE6322: // 64DD US disk case 0x40123780: - case 0x00000000: //64DD DEV Disk + case 0x00000000: // 64DD DEV disk for (count = 0; count < DataLen; count += 4) { Data[count] ^= Data[count + 3]; @@ -667,9 +667,9 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen) } break; case 0x80371240: - case 0x80270740: //64DD IPL - case 0xE848D316: //64DD JP Disk - case 0x2263EE56: //64DD US Disk + case 0x80270740: // 64DD IPL + case 0xE848D316: // 64DD JP disk + case 0x2263EE56: // 64DD US disk break; } } @@ -682,7 +682,7 @@ void CRomList::LoadRomList(void) if (!file.IsOpen()) { - //if file does not exist then refresh the data + // If file does not exist then refresh the data RefreshRomList(); return; } @@ -694,7 +694,7 @@ void CRomList::LoadRomList(void) return; } - //Read the size of ROM_INFO + // Read the size of ROM_INFO int32_t RomInfoSize = 0; if (!file.Read(&RomInfoSize, sizeof(RomInfoSize)) || RomInfoSize != sizeof(ROM_INFO)) { @@ -703,11 +703,11 @@ void CRomList::LoadRomList(void) return; } - //Read the Number of entries + // Read the number of entries int32_t Entries = 0; file.Read(&Entries, sizeof(Entries)); - //Read Every Entry + // Read every entry m_RomInfo.clear(); RomListReset(); for (int32_t count = 0; count < Entries; count++) @@ -722,10 +722,9 @@ void CRomList::LoadRomList(void) WriteTrace(TraceRomList, TraceVerbose, "Done"); } -/* -* 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 -*/ +// SaveRomList - save all the ROM information about the current ROMs in the ROM browser +// to a cache file, so it is quick to reload the information + void CRomList::SaveRomList(strlist & FileList) { MD5 ListHash = RomListHash(FileList); @@ -734,21 +733,21 @@ void CRomList::SaveRomList(strlist & FileList) CFile file(FileName, CFileBase::modeWrite | CFileBase::modeCreate); file.Write(ListHash.raw_digest(), 16); - //Write the size of ROM_INFO + // Write the size of ROM_INFO int32_t RomInfoSize = sizeof(ROM_INFO); file.Write(&RomInfoSize, sizeof(RomInfoSize)); - //Write the Number of entries + // Write the number of entries int32_t Entries = m_RomInfo.size(); file.Write(&Entries, sizeof(Entries)); - //Write Every Entry + // Write every entry for (int32_t count = 0; count < Entries; count++) { file.Write(&m_RomInfo[count], RomInfoSize); } - //Close the file handle + // Close the file handle file.Close(); }