From 563ee060dd9210f3d6d25da224afe6caaf7b7070 Mon Sep 17 00:00:00 2001 From: Vincent Cunningham Date: Wed, 3 Mar 2021 19:20:48 -0500 Subject: [PATCH 1/4] RomList: Fix 7zip filenames --- Source/Project64-core/RomList/RomList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 09d7da023..e0ad73cc0 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -231,7 +231,7 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) } WriteTrace(TraceUserInterface, TraceDebug, "7"); memset(&RomInfo, 0, sizeof(ROM_INFO)); - stdstr_f zipFileName("%s?%s", (LPCSTR)SearchPath, FileName.c_str()); + stdstr_f zipFileName("%s?%s", (LPCSTR)SearchDir, FileName.c_str()); ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB, this); strncpy(RomInfo.szFullFileName, zipFileName.c_str(), sizeof(RomInfo.szFullFileName) - 1); From a4bb7f588f4ee3f59be68866e129189432bb5b55 Mon Sep 17 00:00:00 2001 From: Vincent Cunningham Date: Wed, 3 Mar 2021 19:53:13 -0500 Subject: [PATCH 2/4] RomList: Another one in a trace message --- Source/Project64-core/RomList/RomList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index e0ad73cc0..88f864407 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -310,7 +310,7 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) } catch (...) { - WriteTrace(TraceUserInterface, TraceError, "exception processing %s", (LPCSTR)SearchPath); + WriteTrace(TraceUserInterface, TraceError, "exception processing %s", (LPCSTR)SearchDir); } } #endif From 008567781b6303f0b2c3bc5cfaa2744f53f0759b Mon Sep 17 00:00:00 2001 From: Vincent Cunningham Date: Thu, 4 Mar 2021 17:22:26 -0500 Subject: [PATCH 3/4] N64Rom: Load first found ROM in 7z file Should now search the entire 7zip file looking for a valid N64 ROM file and load the first one it finds. Left comments referring to a future dialog for selecting which file you want to open as it seems like a good idea, but I don't have the familiarity with WTL yet to try to add it. May be necessary to skip files of a certain size while opening this way as Project64 will try to allocate memory for the "ROM" file before it is able to check if it really is a ROM file. --- .../Project64-core/N64System/N64RomClass.cpp | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Source/Project64-core/N64System/N64RomClass.cpp b/Source/Project64-core/N64System/N64RomClass.cpp index bd6d98b2f..1c744dc1f 100644 --- a/Source/Project64-core/N64System/N64RomClass.cpp +++ b/Source/Project64-core/N64System/N64RomClass.cpp @@ -510,18 +510,16 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) //this should be a 7zip file char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); - if (SubFile == NULL) - { - //Pop up a dialog and select file - //allocate memory for sub name and copy selected file name to var - WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); - return false; //remove once dialog is done - } - else + if (SubFile != NULL) { *SubFile = '\0'; SubFile += 1; } + //else load first found file until dialog is implemented + //{ + //Pop up a dialog and select file + //allocate memory for sub name and copy selected file name to var + //} C7zip ZipFile(FullPath.c_str()); ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB, this); @@ -565,6 +563,11 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) if (!IsValidRomImage(m_ROMImage)) { + if (i < ZipFile.NumFiles() - 1) + { + UnallocateRomImage(); + continue; + } SetError(MSG_FAIL_IMAGE); WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; @@ -703,17 +706,16 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) //this should be a 7zip file char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); - if (SubFile == NULL) - { - //Pop up a dialog and select file - //allocate memory for sub name and copy selected file name to var - return false; //remove once dialog is done - } - else + if (SubFile != NULL) { *SubFile = '\0'; SubFile += 1; } + //else load first found file until dialog is implemented + //{ + //Pop up a dialog and select file + //allocate memory for sub name and copy selected file name to var + //} C7zip ZipFile(FullPath.c_str()); ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB, this); @@ -755,6 +757,11 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (!IsValidRomImage(m_ROMImage)) { + if (i < ZipFile.NumFiles() - 1) + { + UnallocateRomImage(); + continue; + } SetError(MSG_FAIL_IMAGE_IPL); return false; } From bc130baa3a3fab5e35b9ac4430d5ebdce805404c Mon Sep 17 00:00:00 2001 From: Vincent Cunningham Date: Thu, 4 Mar 2021 17:27:48 -0500 Subject: [PATCH 4/4] N64Rom: Add trace logs to LoadIN64mageIPL --- Source/Project64-core/N64System/N64RomClass.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Project64-core/N64System/N64RomClass.cpp b/Source/Project64-core/N64System/N64RomClass.cpp index 1c744dc1f..1467cacd0 100644 --- a/Source/Project64-core/N64System/N64RomClass.cpp +++ b/Source/Project64-core/N64System/N64RomClass.cpp @@ -744,6 +744,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (!AllocateRomImage(RomFileSize)) { + WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; } @@ -752,6 +753,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (!ZipFile.GetFile(i, m_ROMImage, RomFileSize)) { SetError(MSG_FAIL_IMAGE_IPL); + WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; } @@ -763,6 +765,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) continue; } SetError(MSG_FAIL_IMAGE_IPL); + WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; } g_Notify->DisplayMessage(5, MSG_BYTESWAP); @@ -776,6 +779,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (!Loaded7zFile) { SetError(MSG_7Z_FILE_NOT_FOUND); + WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; } }