Skip to content

Commit

Permalink
Core: Add some error message when failing to load rom
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Feb 13, 2023
1 parent 4390a09 commit baa5dbe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Lang/English.pj.Lang
Expand Up @@ -530,6 +530,10 @@
#2062# "Nintendo 64DD Development IPL ROM not found.\nIt is required to play development 64DD disk images.\n\nPlease select the required ROM in the Settings."
#2063# "Failed to update cheat, it is invalid"
#2064# "Invalid Cheat"
#2065# "Failed to read ident bytes"
#2066# "Invalid image file"
#2067# "Failed to allocate for rom"
#2068# "Failed to open rom"

/*** Android ***/

Expand Down
5 changes: 4 additions & 1 deletion Source/Project64-core/Multilanguage.h
Expand Up @@ -572,9 +572,12 @@ enum LanguageStringID
MSG_TOOL_IPL_REQUIRED = 2062,
MSG_CHEAT_INVALID_MSG = 2063,
MSG_CHEAT_INVALID_TITLE = 2064,
MSG_ROM_FAILED_READ_IDENT = 2065,
MSG_ROM_INVALID_IMAGE_FILE = 2066,
MSG_ROM_FAILED_ROM_ALLOCATE = 2067,
MSG_ROM_FAILED_TO_OPEN = 2068,

// Android

ANDROID_SETTINGS = 3000,
ANDROID_FORUM = 3001,
ANDROID_REPORT_BUG = 3002,
Expand Down
4 changes: 4 additions & 0 deletions Source/Project64-core/Multilanguage/Language.cpp
Expand Up @@ -515,6 +515,10 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(MSG_TOOL_IPL_REQUIRED, "Nintendo 64DD development IPL ROM not found.\nIt is required to play development 64DD disk images.\n\nPlease select the required ROM in the settings.");
DEF_STR(MSG_CHEAT_INVALID_MSG, "Failed to update cheat, it is invalid");
DEF_STR(MSG_CHEAT_INVALID_TITLE, "Invalid Cheat");
DEF_STR(MSG_ROM_FAILED_READ_IDENT, "Failed to read ident bytes");
DEF_STR(MSG_ROM_INVALID_IMAGE_FILE, "Invalid image file");
DEF_STR(MSG_ROM_FAILED_ROM_ALLOCATE, "Failed to allocate for rom");
DEF_STR(MSG_ROM_FAILED_TO_OPEN, "Failed to open rom");

/*** Android ***/

Expand Down
4 changes: 4 additions & 0 deletions Source/Project64-core/N64System/N64Rom.cpp
Expand Up @@ -53,6 +53,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl
WriteTrace(TraceN64System, TraceDebug, "Trying to open %s", FileLoc);
if (!m_RomFile.Open(FileLoc, CFileBase::modeRead))
{
SetError(MSG_ROM_FAILED_TO_OPEN);
WriteTrace(TraceN64System, TraceError, "Failed to open %s", FileLoc);
return false;
}
Expand All @@ -63,12 +64,14 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl
if (m_RomFile.Read(Test, sizeof(Test)) != sizeof(Test))
{
m_RomFile.Close();
SetError(MSG_ROM_FAILED_READ_IDENT);
WriteTrace(TraceN64System, TraceError, "Failed to read ident bytes");
return false;
}
if (!IsValidRomImage(Test))
{
m_RomFile.Close();
SetError(MSG_ROM_INVALID_IMAGE_FILE);
WriteTrace(TraceN64System, TraceError, "Invalid image file %X %X %X %X", Test[0], Test[1], Test[2], Test[3]);
return false;
}
Expand All @@ -85,6 +88,7 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl
if (!AllocateRomImage(RomFileSize))
{
m_RomFile.Close();
SetError(MSG_ROM_FAILED_ROM_ALLOCATE);
return false;
}

Expand Down

0 comments on commit baa5dbe

Please sign in to comment.