Support .xml disc bundling for PSX, note: this is sloppy code and mostly copy pasta, sorry.
This commit is contained in:
parent
4e673df06f
commit
2373e5bcd5
|
@ -436,6 +436,74 @@ namespace BizHawk.Client.Common
|
|||
roms,
|
||||
(AppleII.Settings)GetCoreSettings<AppleII>());
|
||||
break;
|
||||
case "PSX":
|
||||
var entries = xmlGame.AssetFullPaths;
|
||||
var discs = new List<Disc>();
|
||||
var discNames = new List<string>();
|
||||
var sw = new StringWriter();
|
||||
foreach (var e in entries)
|
||||
{
|
||||
Disc disc = null;
|
||||
string discPath = e;
|
||||
|
||||
//--- load the disc in a context which will let us abort if it's going to take too long
|
||||
var discMountJob = new DiscMountJob { IN_FromPath = discPath };
|
||||
discMountJob.IN_SlowLoadAbortThreshold = 8;
|
||||
discMountJob.Run();
|
||||
disc = discMountJob.OUT_Disc;
|
||||
|
||||
if (discMountJob.OUT_SlowLoadAborted)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("This disc would take too long to load. Run it through discohawk first, or find a new rip because this one is probably junk");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (disc == null)
|
||||
throw new InvalidOperationException("Can't load one of the files specified in the M3U");
|
||||
|
||||
var discName = Path.GetFileNameWithoutExtension(discPath);
|
||||
discNames.Add(discName);
|
||||
discs.Add(disc);
|
||||
|
||||
var discType = new DiscIdentifier(disc).DetectDiscType();
|
||||
sw.WriteLine("{0}", Path.GetFileName(discPath));
|
||||
if (discType == DiscType.SonyPSX)
|
||||
{
|
||||
string discHash = new DiscHasher(disc).Calculate_PSX_BizIDHash().ToString("X8");
|
||||
game = Database.CheckDatabase(discHash);
|
||||
if (game == null || game.IsRomStatusBad() || game.Status == RomStatus.NotInDatabase)
|
||||
sw.WriteLine("Disc could not be identified as known-good. Look for a better rip.");
|
||||
else
|
||||
{
|
||||
sw.WriteLine("Disc was identified (99.99% confidently) as known good.");
|
||||
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("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");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.WriteLine("Not a PSX disc");
|
||||
}
|
||||
sw.WriteLine("-------------------------");
|
||||
}
|
||||
|
||||
// todo: copy pasta from PSX .cue section
|
||||
nextEmulator = new Octoshock(nextComm, discs, discNames, null, GetCoreSettings<Octoshock>(), GetCoreSyncSettings<Octoshock>());
|
||||
if (game.IsRomStatusBad() || game.Status == RomStatus.NotInDatabase)
|
||||
nextEmulator.CoreComm.RomStatusDetails = "Disc could not be identified as known-good. Look for a better rip.";
|
||||
else
|
||||
{
|
||||
sw.WriteLine("Disc was identified (99.99% confidently) as known good.");
|
||||
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("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");
|
||||
nextEmulator.CoreComm.RomStatusDetails = sw.ToString();
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,14 @@ namespace BizHawk.Client.Common
|
|||
public XmlGame()
|
||||
{
|
||||
Assets = new List<KeyValuePair<string, byte[]>>();
|
||||
AssetFullPaths = new List<string>();
|
||||
GI = new GameInfo();
|
||||
}
|
||||
|
||||
public XmlDocument Xml { get; set; }
|
||||
public GameInfo GI { get; set; }
|
||||
public IList<KeyValuePair<string, byte[]>> Assets { get; set; }
|
||||
public IList<string> AssetFullPaths { get; set; } // TODO: Hack work around, to avoid having to refactor Assets into a object array, should be refactored!
|
||||
|
||||
public static XmlGame Create(HawkFile f)
|
||||
{
|
||||
|
@ -45,6 +47,7 @@ namespace BizHawk.Client.Common
|
|||
},
|
||||
Xml = x
|
||||
};
|
||||
string fullpath = string.Empty;
|
||||
|
||||
var n = y.SelectSingleNode("./LoadAssets");
|
||||
if (n != null)
|
||||
|
@ -79,7 +82,7 @@ namespace BizHawk.Client.Common
|
|||
else
|
||||
{
|
||||
// relative path
|
||||
var fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|').First()) ?? string.Empty;
|
||||
fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|').First()) ?? string.Empty;
|
||||
fullpath = Path.Combine(fullpath, filename.Split('|').First());
|
||||
try
|
||||
{
|
||||
|
@ -107,7 +110,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
ret.Assets.Add(new KeyValuePair<string, byte[]>(filename, data));
|
||||
|
||||
ret.AssetFullPaths.Add(fullpath);
|
||||
using (var sha1 = System.Security.Cryptography.SHA1.Create())
|
||||
{
|
||||
sha1.TransformFinalBlock(data, 0, data.Length);
|
||||
|
|
|
@ -138,7 +138,8 @@
|
|||
this.SystemDropDown.FormattingEnabled = true;
|
||||
this.SystemDropDown.Items.AddRange(new object[] {
|
||||
"GB",
|
||||
"AppleII"});
|
||||
"AppleII",
|
||||
"PSX"});
|
||||
this.SystemDropDown.Location = new System.Drawing.Point(425, 75);
|
||||
this.SystemDropDown.Name = "SystemDropDown";
|
||||
this.SystemDropDown.Size = new System.Drawing.Size(69, 21);
|
||||
|
|
Loading…
Reference in New Issue