Misc. cleanups in LoadRom and helpers
This commit is contained in:
parent
7c9792db58
commit
f6f6106ccf
|
@ -312,10 +312,10 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEmulator nextEmulator = null;
|
IEmulator nextEmulator;
|
||||||
switch (game.System)
|
switch (game.System)
|
||||||
{
|
{
|
||||||
case "NULL":
|
default:
|
||||||
nextEmulator = null;
|
nextEmulator = null;
|
||||||
break;
|
break;
|
||||||
case "GEN":
|
case "GEN":
|
||||||
|
@ -335,9 +335,9 @@ namespace BizHawk.Client.Common
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var sw = new StringWriter();
|
var sw = new StringWriter();
|
||||||
sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}", discHash);
|
sw.WriteLine($"Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{discHash}");
|
||||||
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
||||||
sw.WriteLine("According to redump.org, the ideal hash for entire disc is: CRC32:{0:X8}", game.GetStringValue("dh"));
|
sw.WriteLine($"According to redump.org, the ideal hash for entire disc is: CRC32:{game.GetStringValue("dh")}");
|
||||||
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
||||||
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
||||||
romDetails = sw.ToString();
|
romDetails = sw.ToString();
|
||||||
|
@ -352,7 +352,7 @@ namespace BizHawk.Client.Common
|
||||||
case "PCE": // TODO: this is clearly not used, its set to PCE by code above
|
case "PCE": // TODO: this is clearly not used, its set to PCE by code above
|
||||||
case "PCECD":
|
case "PCECD":
|
||||||
string core = CoreNames.PceHawk;
|
string core = CoreNames.PceHawk;
|
||||||
if (_config.PreferredCores.TryGetValue("PCECD", out string preferredCore))
|
if (_config.PreferredCores.TryGetValue("PCECD", out var preferredCore))
|
||||||
{
|
{
|
||||||
core = preferredCore;
|
core = preferredCore;
|
||||||
}
|
}
|
||||||
|
@ -366,9 +366,9 @@ namespace BizHawk.Client.Common
|
||||||
nextEmulator = new TerboGrafix(game, new[] { disc }, nextComm,
|
nextEmulator = new TerboGrafix(game, new[] { disc }, nextComm,
|
||||||
(Emulation.Cores.Waterbox.NymaCore.NymaSettings)GetCoreSettings<TerboGrafix>(),
|
(Emulation.Cores.Waterbox.NymaCore.NymaSettings)GetCoreSettings<TerboGrafix>(),
|
||||||
(Emulation.Cores.Waterbox.NymaCore.NymaSyncSettings)GetCoreSyncSettings<TerboGrafix>(), Deterministic);
|
(Emulation.Cores.Waterbox.NymaCore.NymaSyncSettings)GetCoreSyncSettings<TerboGrafix>(), Deterministic);
|
||||||
// nextEmulator = new TerboGrafixSanic(game, new[] { disc }, nextComm,
|
// nextEmulator = new TerboGrafixSanic(game, new[] { disc }, nextComm,
|
||||||
// (Emulation.Cores.Waterbox.NymaCore.NymaSettings)GetCoreSettings<TerboGrafixSanic>(),
|
// (Emulation.Cores.Waterbox.NymaCore.NymaSettings)GetCoreSettings<TerboGrafixSanic>(),
|
||||||
// (Emulation.Cores.Waterbox.NymaCore.NymaSyncSettings)GetCoreSyncSettings<TerboGrafixSanic>(), Deterministic);
|
// (Emulation.Cores.Waterbox.NymaCore.NymaSyncSettings)GetCoreSyncSettings<TerboGrafixSanic>(), Deterministic);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -413,9 +413,9 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}", discHash);
|
sw.WriteLine($"Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{discHash}");
|
||||||
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
||||||
sw.WriteLine("According to redump.org, the ideal hash for entire disc is: CRC32:{0:X8}", game.GetStringValue("dh"));
|
sw.WriteLine($"According to redump.org, the ideal hash for entire disc is: CRC32:{game.GetStringValue("dh")}");
|
||||||
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
||||||
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
||||||
}
|
}
|
||||||
|
@ -486,17 +486,10 @@ namespace BizHawk.Client.Common
|
||||||
switch (game.System)
|
switch (game.System)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
if (_config.PreferredCores.TryGetValue(game.System, out string coreName))
|
core = _config.PreferredCores.TryGetValue(game.System, out var coreName)
|
||||||
{
|
? CoreInventory.Instance[game.System, coreName]
|
||||||
core = CoreInventory.Instance[game.System, coreName];
|
: CoreInventory.Instance[game.System];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core = CoreInventory.Instance[game.System];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case null:
|
case null:
|
||||||
// The user picked nothing in the Core picker
|
// The user picked nothing in the Core picker
|
||||||
break;
|
break;
|
||||||
|
@ -515,7 +508,6 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "SNES":
|
case "SNES":
|
||||||
{
|
|
||||||
var name = _config.PreferredCores["SNES"];
|
var name = _config.PreferredCores["SNES"];
|
||||||
if (game.ForcedCore.ToLower() == "snes9x")
|
if (game.ForcedCore.ToLower() == "snes9x")
|
||||||
{
|
{
|
||||||
|
@ -540,9 +532,7 @@ namespace BizHawk.Client.Common
|
||||||
nextEmulator = snes;
|
nextEmulator = snes;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case "NES":
|
case "NES":
|
||||||
{
|
|
||||||
// apply main spur-of-the-moment switcheroo as lowest priority
|
// apply main spur-of-the-moment switcheroo as lowest priority
|
||||||
string preference = _config.PreferredCores["NES"];
|
string preference = _config.PreferredCores["NES"];
|
||||||
|
|
||||||
|
@ -563,9 +553,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
core = CoreInventory.Instance["NES", preference];
|
core = CoreInventory.Instance["NES", preference];
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "GB":
|
case "GB":
|
||||||
case "GBC":
|
case "GBC":
|
||||||
if (!_config.GbAsSgb)
|
if (!_config.GbAsSgb)
|
||||||
|
@ -615,15 +603,7 @@ namespace BizHawk.Client.Common
|
||||||
rom.GameInfo.Name = gameName;
|
rom.GameInfo.Name = gameName;
|
||||||
break;
|
break;
|
||||||
case "GEN":
|
case "GEN":
|
||||||
if (game.ForcedCore?.ToLower() == "pico")
|
core = CoreInventory.Instance["GEN", game.ForcedCore?.ToLower() == "pico" ? CoreNames.PicoDrive : CoreNames.Gpgx];
|
||||||
{
|
|
||||||
core = CoreInventory.Instance["GEN", CoreNames.PicoDrive];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core = CoreInventory.Instance["GEN", CoreNames.Gpgx];
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "32X":
|
case "32X":
|
||||||
core = CoreInventory.Instance["GEN", CoreNames.PicoDrive];
|
core = CoreInventory.Instance["GEN", CoreNames.PicoDrive];
|
||||||
|
@ -643,16 +623,16 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
private (IEmulator NextEmulator, RomGame Rom, GameInfo Game) LoadPSF(string path, CoreComm nextComm, HawkFile file)
|
private (IEmulator NextEmulator, RomGame Rom, GameInfo Game) LoadPSF(string path, CoreComm nextComm, HawkFile file)
|
||||||
{
|
{
|
||||||
Func<Stream, int, byte[]> cbDeflater = (Stream instream, int size) =>
|
byte[] CbDeflater(Stream instream, int size)
|
||||||
{
|
{
|
||||||
var inflater = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(false);
|
var inflater = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(false);
|
||||||
var iis = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(instream, inflater);
|
var iis = new ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream(instream, inflater);
|
||||||
MemoryStream ret = new MemoryStream();
|
MemoryStream ret = new MemoryStream();
|
||||||
iis.CopyTo(ret);
|
iis.CopyTo(ret);
|
||||||
return ret.ToArray();
|
return ret.ToArray();
|
||||||
};
|
}
|
||||||
PSF psf = new PSF();
|
PSF psf = new PSF();
|
||||||
psf.Load(path, cbDeflater);
|
psf.Load(path, CbDeflater);
|
||||||
var nextEmulator = new Octoshock(nextComm, psf, GetCoreSettings<Octoshock>(), GetCoreSyncSettings<Octoshock>());
|
var nextEmulator = new Octoshock(nextComm, psf, GetCoreSettings<Octoshock>(), GetCoreSyncSettings<Octoshock>());
|
||||||
|
|
||||||
// total garbage, this
|
// total garbage, this
|
||||||
|
@ -821,9 +801,9 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw.WriteLine("Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{0:X8}", discHash);
|
sw.WriteLine($"Disc was identified (99.99% confidently) as known good with disc id hash CRC32:{discHash}");
|
||||||
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
sw.WriteLine("Nonetheless it could be an unrecognized romhack or patched version.");
|
||||||
sw.WriteLine("According to redump.org, the ideal hash for entire disc is: CRC32:{0:X8}", game.GetStringValue("dh"));
|
sw.WriteLine($"According to redump.org, the ideal hash for entire disc is: CRC32:{game.GetStringValue("dh")}");
|
||||||
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
sw.WriteLine("The file you loaded hasn't been hashed entirely (it would take too long)");
|
||||||
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
sw.WriteLine("Compare it with the full hash calculated by the PSX menu's Hash Discs tool");
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1031,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
else if (file.Extension.ToLowerInvariant() == ".xml")
|
else if (file.Extension.ToLowerInvariant() == ".xml")
|
||||||
{
|
{
|
||||||
var result = LoadXML(path, nextComm, file);
|
var result = LoadXML(path, nextComm, file); // must be called before LoadOther because of SNES hacks
|
||||||
if (result == null) return false;
|
if (result == null) return false;
|
||||||
(nextEmulator, rom, game) = result.Value;
|
(nextEmulator, rom, game) = result.Value;
|
||||||
}
|
}
|
||||||
|
@ -1076,11 +1056,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string system = null;
|
var system = game?.System;
|
||||||
if (game != null)
|
|
||||||
{
|
|
||||||
system = game.System;
|
|
||||||
}
|
|
||||||
|
|
||||||
// all of the specific exceptions we're trying to catch here aren't expected to have inner exceptions,
|
// all of the specific exceptions we're trying to catch here aren't expected to have inner exceptions,
|
||||||
// so drill down in case we got a TargetInvocationException or something like that
|
// so drill down in case we got a TargetInvocationException or something like that
|
||||||
|
|
Loading…
Reference in New Issue