Refactor 64DD game loading (supports custom settings and RDB)
(Nothing done for plugins yet)
This commit is contained in:
parent
cd80e4f0a4
commit
95e31542cf
|
@ -374,10 +374,24 @@ bool CN64System::RunFileImage(const char * FileLoc)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (g_Rom == g_DDRom && g_Rom != NULL && g_DDRom != NULL && g_Disk != NULL)
|
||||
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
|
||||
{
|
||||
g_Settings->SaveString(Game_IniKey, g_Disk->GetDiskIdent().c_str());
|
||||
g_System->RefreshGameSettings();
|
||||
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;
|
||||
}
|
||||
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
|
||||
{
|
||||
|
@ -387,6 +401,30 @@ bool CN64System::RunFileImage(const char * FileLoc)
|
|||
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;
|
||||
}
|
||||
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
|
||||
RunLoadedImage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CN64System::RunLoadedImage(void)
|
||||
{
|
||||
WriteTrace(TraceN64System, TraceDebug, "Start");
|
||||
|
@ -402,7 +440,7 @@ void CN64System::RunLoadedImage(void)
|
|||
WriteTrace(TraceN64System, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
bool CN64System::RunFileImageIPL(const char * FileLoc)
|
||||
bool CN64System::LoadFileImageIPL(const char * FileLoc)
|
||||
{
|
||||
CloseSystem();
|
||||
if (g_Settings->LoadBool(GameRunning_LoadingInProgress))
|
||||
|
@ -459,7 +497,7 @@ bool CN64System::RunFileImageIPL(const char * FileLoc)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CN64System::RunDiskImage(const char * FileLoc, const bool Expansion)
|
||||
bool CN64System::LoadDiskImage(const char * FileLoc, const bool Expansion)
|
||||
{
|
||||
CloseSystem();
|
||||
if (g_Settings->LoadBool(GameRunning_LoadingInProgress))
|
||||
|
|
|
@ -59,8 +59,10 @@ public:
|
|||
//Methods
|
||||
static bool LoadFileImage(const char * FileLoc);
|
||||
static bool RunFileImage(const char * FileLoc);
|
||||
static bool RunFileImageIPL(const char * FileLoc);
|
||||
static bool RunDiskImage(const char * FileLoc, const bool Expansion);
|
||||
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);
|
||||
|
||||
|
|
|
@ -126,18 +126,14 @@ void CMainMenu::OnOpenRom(HWND hWnd)
|
|||
return;
|
||||
}
|
||||
// Open Disk
|
||||
if (!g_BaseSystem->RunDiskImage(File.c_str(), false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str())))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(File.c_str()))
|
||||
{
|
||||
CPath FileNameIPL;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
CPath FileName;
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
if (FileNameIPL.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
g_BaseSystem->RunFileImage(FileName);
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileNameIPL);
|
||||
g_BaseSystem->RunDiskImage(File.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,17 +550,14 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
|
|||
g_BaseSystem->RunFileImage(FileName.c_str());
|
||||
else
|
||||
{
|
||||
if (g_BaseSystem->RunDiskImage(FileName.c_str(), false))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(FileName.c_str()))
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str())))
|
||||
{
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
CPath FileNameIPL;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileNameIPL.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
g_BaseSystem->RunFileImage(FileNameIPL);
|
||||
}
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileNameIPL);
|
||||
g_BaseSystem->RunDiskImage(FileName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -989,17 +989,14 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
|
|||
}
|
||||
else
|
||||
{
|
||||
if (g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom(), false))
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str())))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom()))
|
||||
{
|
||||
CPath FileName;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
g_BaseSystem->RunFileImage(FileName);
|
||||
}
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileName);
|
||||
g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1007,35 +1004,18 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
|
|||
}
|
||||
case ID_POPUPMENU_PLAYGAMEWITHDISK:
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImageIPL(IPLROM.c_str())))
|
||||
{
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
CPath FileName;
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
g_BaseSystem->RunFileImageIPL(FileName);
|
||||
// Open Disk
|
||||
const char * N64DDFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), N64DDFilter, true))
|
||||
{
|
||||
if (g_BaseSystem->RunDiskImage(FileName, true))
|
||||
{
|
||||
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Open Disk
|
||||
CPath FileName;
|
||||
const char * Filter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
if (g_BaseSystem->RunDiskImage(FileName, true))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskComboImage(_this->CurrentedSelectedRom(), FileName))
|
||||
{
|
||||
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
|
||||
CPath FileNameIPL;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileNameIPL.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileNameIPL);
|
||||
g_BaseSystem->RunDiskComboImage(_this->CurrentedSelectedRom(), FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1195,17 +1175,14 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
|
|||
else
|
||||
{
|
||||
// Open Disk
|
||||
if (CN64System::RunDiskImage(filename, false))
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(filename))
|
||||
{
|
||||
CPath FileName;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
CN64System::RunFileImage(FileName);
|
||||
}
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileName);
|
||||
g_BaseSystem->RunDiskImage(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -811,17 +811,14 @@ void CRomBrowser::RomList_OpenRom(uint32_t /*pnmh*/)
|
|||
CN64System::RunFileImage(pRomInfo->szFullFileName);
|
||||
else
|
||||
{
|
||||
if (CN64System::RunDiskImage(pRomInfo->szFullFileName, false))
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(pRomInfo->szFullFileName))
|
||||
{
|
||||
CPath FileName;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(m_MainWindow, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
CN64System::RunFileImage(FileName);
|
||||
}
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileName);
|
||||
g_BaseSystem->RunDiskImage(pRomInfo->szFullFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -887,6 +884,7 @@ void CRomBrowser::RomList_PopupMenu(uint32_t /*pnmh*/)
|
|||
if (inBasicMode) { DeleteMenu(hPopupMenu, 9, MF_BYPOSITION); }
|
||||
if (inBasicMode && !CheatsRemembered) { DeleteMenu(hPopupMenu, 8, MF_BYPOSITION); }
|
||||
DeleteMenu(hPopupMenu, 7, MF_BYPOSITION);
|
||||
if (CPath(m_SelectedRom).GetExtension() == "ndd") { DeleteMenu(hPopupMenu, 1, MF_BYPOSITION); }
|
||||
if (!inBasicMode && g_Plugins && g_Plugins->Gfx() && g_Plugins->Gfx()->GetRomBrowserMenu != NULL)
|
||||
{
|
||||
HMENU GfxMenu = (HMENU)g_Plugins->Gfx()->GetRomBrowserMenu();
|
||||
|
|
|
@ -37,17 +37,14 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
|
|||
else
|
||||
{
|
||||
//Ext is *.ndd, so it should be a disk file.
|
||||
if (CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str(), false))
|
||||
if (!CPath(g_Settings->LoadStringVal(File_DiskIPLPath)).Exists() || !g_BaseSystem->RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()))
|
||||
{
|
||||
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
|
||||
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))
|
||||
{
|
||||
CPath FileName;
|
||||
CPath FileNameIPL;
|
||||
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
|
||||
if (FileName.SelectFile(NULL, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
if (FileNameIPL.SelectFile(NULL, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
|
||||
{
|
||||
CN64System::RunFileImage(FileName);
|
||||
}
|
||||
g_Settings->SaveString(File_DiskIPLPath, (const char *)FileNameIPL);
|
||||
g_BaseSystem->RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue