Manage 64DD IPL loading errors

This commit is contained in:
LuigiBlood 2019-01-27 12:52:22 +01:00
parent 0233d848c2
commit 3e52ff7b48
5 changed files with 108 additions and 92 deletions

View File

@ -556,6 +556,7 @@ enum LanguageStringID
MSG_SET_LLE_GFX_MSG = 2055,
MSG_SET_HLE_AUD_TITLE = 2056,
MSG_SET_HLE_AUD_MSG = 2057,
MSG_FAIL_IMAGE_IPL = 2058,
/*********************************************************************************
* Android *

View File

@ -522,6 +522,7 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(MSG_SET_LLE_GFX_MSG, "Graphics LLE is not for general use!!!\nIt is advisable that you only use this for testing and not for playing games.\n\nChange to graphics LLE?");
DEF_STR(MSG_SET_HLE_AUD_TITLE, "Audio High-Level Emulation");
DEF_STR(MSG_SET_HLE_AUD_MSG, "Audio HLE requires a third-party plugin!!!\nIf you do not use a third-party audio plugin that supports HLE, you will hear no sound.\n\nChange to audio HLE?");
DEF_STR(MSG_FAIL_IMAGE_IPL, "File loaded does not appear to be a valid 64DD IPL ROM.\n\nVerify your ROMs with GoodN64.");
/*********************************************************************************
* Android *

View File

@ -363,94 +363,6 @@ bool CN64System::LoadFileImage(const char * FileLoc)
return true;
}
bool CN64System::RunFileImage(const char * FileLoc)
{
//Uninitialize g_Disk and g_DDRom to prevent exception when ending emulation of a regular ROM after playing 64DD content previously.
if (g_Disk != NULL)
{
g_Disk->UnallocateDiskImage();
delete g_Disk;
g_Disk = NULL;
}
if (g_DDRom != NULL)
{
g_DDRom->UnallocateRomImage();
delete g_DDRom;
g_DDRom = NULL;
}
if (!LoadFileImage(FileLoc))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, false);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
bool CN64System::RunDiskImage(const char * FileLoc)
{
if (!LoadFileImage(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()))
{
g_Settings->SaveString(File_DiskIPLPath, "");
return false;
}
if (!LoadDiskImage(FileLoc, false))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, true);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
bool CN64System::RunDiskComboImage(const char * FileLoc, const char * FileLocDisk)
{
if (!LoadFileImageIPL(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()))
{
g_Settings->SaveString(File_DiskIPLPath, "");
return false;
}
if (!LoadDiskImage(FileLocDisk, true))
{
return false;
}
if (!LoadFileImage(FileLoc))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, true);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
void CN64System::RunLoadedImage(void)
{
WriteTrace(TraceN64System, TraceDebug, "Start");
g_BaseSystem = new CN64System(g_Plugins, (uint32_t)time(NULL), false, false);
if (g_BaseSystem)
{
g_BaseSystem->StartEmulation(true);
}
else
{
WriteTrace(TraceN64System, TraceError, "Failed to create CN64System");
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}
bool CN64System::LoadFileImageIPL(const char * FileLoc)
{
CloseSystem();
@ -555,6 +467,102 @@ bool CN64System::LoadDiskImage(const char * FileLoc, const bool Expansion)
return true;
}
bool CN64System::RunFileImage(const char * FileLoc)
{
//Uninitialize g_Disk and g_DDRom to prevent exception when ending emulation of a regular ROM after playing 64DD content previously.
if (g_Disk != NULL)
{
g_Disk->UnallocateDiskImage();
delete g_Disk;
g_Disk = NULL;
}
if (g_DDRom != NULL)
{
g_DDRom->UnallocateRomImage();
delete g_DDRom;
g_DDRom = NULL;
}
if (!LoadFileImage(FileLoc))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, false);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
bool CN64System::RunDiskImage(const char * FileLoc)
{
if (!LoadFileImage(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()))
{
g_Settings->SaveString(File_DiskIPLPath, "");
return false;
}
else
{
if (g_Rom->CicChipID() != CIC_NUS_8303 && g_Rom->CicChipID() != CIC_NUS_DDUS)
{
g_Notify->DisplayError(MSG_FAIL_IMAGE_IPL);
g_Settings->SaveString(File_DiskIPLPath, "");
return false;
}
}
if (!LoadDiskImage(FileLoc, false))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, true);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
bool CN64System::RunDiskComboImage(const char * FileLoc, const char * FileLocDisk)
{
if (!LoadFileImageIPL(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()))
{
g_Settings->SaveString(File_DiskIPLPath, "");
return false;
}
if (!LoadDiskImage(FileLocDisk, true))
{
return false;
}
if (!LoadFileImage(FileLoc))
{
return false;
}
g_Settings->SaveBool(Setting_EnableDisk, true);
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
void CN64System::RunLoadedImage(void)
{
WriteTrace(TraceN64System, TraceDebug, "Start");
g_BaseSystem = new CN64System(g_Plugins, (uint32_t)time(NULL), false, false);
if (g_BaseSystem)
{
g_BaseSystem->StartEmulation(true);
}
else
{
WriteTrace(TraceN64System, TraceError, "Failed to create CN64System");
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}
void CN64System::CloseSystem()
{
WriteTrace(TraceN64System, TraceDebug, "Start");

View File

@ -58,11 +58,11 @@ public:
//Methods
static bool LoadFileImage(const char * FileLoc);
static bool LoadFileImageIPL(const char * FileLoc);
static bool LoadDiskImage(const char * FileLoc, const bool Expansion);
static bool RunFileImage(const char * FileLoc);
static bool RunDiskImage(const char * FileLoc);
static bool RunDiskComboImage(const char * FileLoc, const char * FileLocDisk);
static bool LoadFileImageIPL(const char * FileLoc);
static bool LoadDiskImage(const char * FileLoc, const bool Expansion);
static void RunLoadedImage(void);
static void CloseSystem(void);

View File

@ -680,13 +680,13 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly)
g_Notify->DisplayMessage(5, MSG_LOADING);
if (!ZipFile.GetFile(i, m_ROMImage, RomFileSize))
{
SetError(MSG_FAIL_IMAGE);
SetError(MSG_FAIL_IMAGE_IPL);
return false;
}
if (!IsValidRomImage(m_ROMImage))
{
SetError(MSG_FAIL_IMAGE);
SetError(MSG_FAIL_IMAGE_IPL);
return false;
}
g_Notify->DisplayMessage(5, MSG_BYTESWAP);
@ -748,6 +748,12 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly)
WriteTrace(TraceN64System, TraceDebug, "Ident: %s", m_RomIdent.c_str());
CalculateCicChip();
if (CicChipID() != CIC_NUS_8303 && CicChipID() != CIC_NUS_DDUS)
{
SetError(MSG_FAIL_IMAGE_IPL);
return false;
}
if (!LoadBootCodeOnly && g_DDRom == this)
{
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);