pce: refactor CD loading to move bios determination out of RomLoader
This commit is contained in:
parent
37469faa8b
commit
17d6e866a0
|
@ -75,24 +75,46 @@ namespace BizHawk.Client.Common
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetFirmware(string sysID, string firmwareID, bool required, string msg = null)
|
private byte[] GetFirmwareWithPath(string sysID, string firmwareID, bool required, string msg, out string path)
|
||||||
{
|
{
|
||||||
byte[] ret = null;
|
byte[] ret = null;
|
||||||
var path = GetFirmwarePath(sysID, firmwareID, required, msg);
|
var path_ = GetFirmwarePath(sysID, firmwareID, required, msg);
|
||||||
if (path != null && File.Exists(path))
|
if (path_ != null && File.Exists(path_))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = File.ReadAllBytes(path);
|
ret = File.ReadAllBytes(path_);
|
||||||
}
|
}
|
||||||
catch (IOException) { }
|
catch (IOException) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == null && path != null)
|
if (ret == null && path_ != null)
|
||||||
{
|
{
|
||||||
FirmwareWarn(sysID, firmwareID, required, msg);
|
FirmwareWarn(sysID, firmwareID, required, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = path_;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFirmware(string sysID, string firmwareID, bool required, string msg = null)
|
||||||
|
{
|
||||||
|
string unused;
|
||||||
|
return GetFirmwareWithPath(sysID, firmwareID, required, msg, out unused);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetFirmwareWithGameInfo(string sysID, string firmwareID, bool required, out GameInfo gi, string msg = null)
|
||||||
|
{
|
||||||
|
string path;
|
||||||
|
byte[] ret = GetFirmwareWithPath(sysID, firmwareID, required, msg, out path);
|
||||||
|
if (ret != null && path != null)
|
||||||
|
{
|
||||||
|
gi = Database.GetGameInfo(ret, path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gi = null;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,53 +223,7 @@ namespace BizHawk.Client.Common
|
||||||
break;
|
break;
|
||||||
case "PCE":
|
case "PCE":
|
||||||
case "PCECD":
|
case "PCECD":
|
||||||
var biosPath = Global.FirmwareManager.Request("PCECD", "Bios");
|
nextEmulator = new PCEngine(nextComm, game, disc, GetCoreSettings<PCEngine>());
|
||||||
if (!File.Exists(biosPath))
|
|
||||||
{
|
|
||||||
ThrowLoadError("PCE-CD System Card not found. Please check the BIOS settings in Config->Firmwares.", game.System);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
rom = new RomGame(new HawkFile(biosPath));
|
|
||||||
|
|
||||||
if (rom.GameInfo.Status == RomStatus.BadDump)
|
|
||||||
{
|
|
||||||
ThrowLoadError(
|
|
||||||
"The PCE-CD System Card you have selected is known to be a bad dump. This may cause problems playing PCE-CD games.\n\n"
|
|
||||||
+ "It is recommended that you find a good dump of the system card. Sorry to be the bearer of bad news!",
|
|
||||||
game.System);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (rom.GameInfo.NotInDatabase)
|
|
||||||
{
|
|
||||||
ThrowLoadError(
|
|
||||||
"The PCE-CD System Card you have selected is not recognized in our database. That might mean it's a bad dump, or isn't the correct rom.",
|
|
||||||
game.System);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (rom.GameInfo["BIOS"] == false)
|
|
||||||
{
|
|
||||||
ThrowLoadError(
|
|
||||||
"The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom.",
|
|
||||||
game.System);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rom.GameInfo["SuperSysCard"])
|
|
||||||
{
|
|
||||||
game.AddOption("SuperSysCard");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game["NeedSuperSysCard"] && game["SuperSysCard"] == false)
|
|
||||||
{
|
|
||||||
ThrowLoadError(
|
|
||||||
"This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in Config->Paths->PC Engine.",
|
|
||||||
game.System);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
game.FirmwareHash = Util.Hash_SHA1(rom.RomData);
|
|
||||||
nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData, GetCoreSettings<PCEngine>());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace BizHawk.Emulation.Common
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
byte[] GetFirmware(string sysID, string firmwareID, bool required, string msg = null);
|
byte[] GetFirmware(string sysID, string firmwareID, bool required, string msg = null);
|
||||||
|
|
||||||
|
byte[] GetFirmwareWithGameInfo(string sysID, string firmwareID, bool required, out GameInfo gi, string msg = null);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
||||||
|
|
||||||
public string BoardName { get { return null; } }
|
public string BoardName { get { return null; } }
|
||||||
|
|
||||||
public PCEngine(CoreComm comm, GameInfo game, Disc disc, byte[] rom, object Settings)
|
public PCEngine(CoreComm comm, GameInfo game, Disc disc, object Settings)
|
||||||
{
|
{
|
||||||
CoreComm = comm;
|
CoreComm = comm;
|
||||||
CoreComm.CpuTraceAvailable = true;
|
CoreComm.CpuTraceAvailable = true;
|
||||||
|
@ -85,6 +85,45 @@ namespace BizHawk.Emulation.Cores.PCEngine
|
||||||
Type = NecSystemType.TurboCD;
|
Type = NecSystemType.TurboCD;
|
||||||
this.disc = disc;
|
this.disc = disc;
|
||||||
this.Settings = (PCESettings)Settings ?? new PCESettings();
|
this.Settings = (PCESettings)Settings ?? new PCESettings();
|
||||||
|
|
||||||
|
GameInfo biosInfo;
|
||||||
|
byte[] rom = CoreComm.CoreFileProvider.GetFirmwareWithGameInfo("PCECD", "Bios", true, out biosInfo,
|
||||||
|
"PCE-CD System Card not found. Please check the BIOS settings in Config->Firmwares.");
|
||||||
|
|
||||||
|
if (biosInfo.Status == RomStatus.BadDump)
|
||||||
|
{
|
||||||
|
CoreComm.ShowMessage(
|
||||||
|
"The PCE-CD System Card you have selected is known to be a bad dump. This may cause problems playing PCE-CD games.\n\n"
|
||||||
|
+ "It is recommended that you find a good dump of the system card. Sorry to be the bearer of bad news!");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
else if (biosInfo.NotInDatabase)
|
||||||
|
{
|
||||||
|
CoreComm.ShowMessage(
|
||||||
|
"The PCE-CD System Card you have selected is not recognized in our database. That might mean it's a bad dump, or isn't the correct rom.");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
else if (biosInfo["BIOS"] == false)
|
||||||
|
{
|
||||||
|
CoreComm.ShowMessage(
|
||||||
|
"The PCE-CD System Card you have selected is not a BIOS image. You may have selected the wrong rom.");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biosInfo["SuperSysCard"])
|
||||||
|
{
|
||||||
|
game.AddOption("SuperSysCard");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game["NeedSuperSysCard"] && game["SuperSysCard"] == false)
|
||||||
|
{
|
||||||
|
CoreComm.ShowMessage(
|
||||||
|
"This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in the firmware configuration.");
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
game.FirmwareHash = Util.Hash_SHA1(rom);
|
||||||
|
|
||||||
Init(game, rom);
|
Init(game, rom);
|
||||||
// the default RomStatusDetails don't do anything with Disc
|
// the default RomStatusDetails don't do anything with Disc
|
||||||
CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, disc.GetHash());
|
CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, disc.GetHash());
|
||||||
|
|
Loading…
Reference in New Issue