mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-27 16:15:41 +00:00
System: Support loading libps.exe (for Net Yaroze)
This commit is contained in:
parent
d53daf2f26
commit
aae0fb3f2b
|
@ -1616,11 +1616,14 @@ void ResetPerformanceCounters()
|
||||||
ResetThrottler();
|
ResetThrottler();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadEXE(const char* filename)
|
static bool LoadEXEToRAM(const char* filename, bool patch_bios)
|
||||||
{
|
{
|
||||||
std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
|
std::FILE* fp = FileSystem::OpenCFile(filename, "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
{
|
||||||
|
Log_ErrorPrintf("Failed to open exe file '%s'", filename);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::fseek(fp, 0, SEEK_END);
|
std::fseek(fp, 0, SEEK_END);
|
||||||
const u32 file_size = static_cast<u32>(std::ftell(fp));
|
const u32 file_size = static_cast<u32>(std::ftell(fp));
|
||||||
|
@ -1629,6 +1632,7 @@ bool LoadEXE(const char* filename)
|
||||||
BIOS::PSEXEHeader header;
|
BIOS::PSEXEHeader header;
|
||||||
if (std::fread(&header, sizeof(header), 1, fp) != 1 || !BIOS::IsValidPSExeHeader(header, file_size))
|
if (std::fread(&header, sizeof(header), 1, fp) != 1 || !BIOS::IsValidPSExeHeader(header, file_size))
|
||||||
{
|
{
|
||||||
|
Log_ErrorPrintf("'%s' is not a valid PS-EXE", filename);
|
||||||
std::fclose(fp);
|
std::fclose(fp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1672,6 +1676,18 @@ bool LoadEXE(const char* filename)
|
||||||
return BIOS::PatchBIOSForEXE(Bus::g_bios, Bus::BIOS_SIZE, r_pc, r_gp, r_sp, r_fp);
|
return BIOS::PatchBIOSForEXE(Bus::g_bios, Bus::BIOS_SIZE, r_pc, r_gp, r_sp, r_fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadEXE(const char* filename)
|
||||||
|
{
|
||||||
|
const std::string libps_path(FileSystem::BuildRelativePath(filename, "libps.exe"));
|
||||||
|
if (!libps_path.empty() && FileSystem::FileExists(libps_path.c_str()) && !LoadEXEToRAM(libps_path.c_str(), false))
|
||||||
|
{
|
||||||
|
Log_ErrorPrintf("Failed to load libps.exe from '%s'", libps_path.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadEXEToRAM(filename, true);
|
||||||
|
}
|
||||||
|
|
||||||
bool InjectEXEFromBuffer(const void* buffer, u32 buffer_size, bool patch_bios)
|
bool InjectEXEFromBuffer(const void* buffer, u32 buffer_size, bool patch_bios)
|
||||||
{
|
{
|
||||||
const u8* buffer_ptr = static_cast<const u8*>(buffer);
|
const u8* buffer_ptr = static_cast<const u8*>(buffer);
|
||||||
|
|
Loading…
Reference in a new issue