From 14c117e92e891e05f9dbf46bff261e80a53fbd4e Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 16 May 2020 11:54:36 -0500 Subject: [PATCH] RomLoader - GPGX - support rom + cd .xml files --- src/BizHawk.Client.Common/RomLoader.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 5a90cdcfb9..68ceabf1ce 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -203,7 +203,7 @@ namespace BizHawk.Client.Common { var discs = new List(); var sw = new StringWriter(); - foreach (var e in xmlGame.AssetFullPaths) + foreach (var e in xmlGame.AssetFullPaths.Where(a => IsDisc(Path.GetExtension(a)))) { string discPath = e; @@ -468,7 +468,7 @@ namespace BizHawk.Client.Common System = "PSX" }; } - else if (ext == ".iso" || ext == ".cue" || ext == ".ccd" || ext == ".mds") + else if (IsDisc(ext)) { if (file.IsArchive) { @@ -818,13 +818,15 @@ namespace BizHawk.Client.Common (Tst.Settings)GetCoreSettings(), (Tst.SyncSettings)GetCoreSyncSettings()); break; case "GEN": - // We are assuming discs only, for now var genDiscs = DiscsFromXml(xmlGame, "GEN", DiscType.MegaCD); - if (!genDiscs.Any()) + var romBytes = xmlGame.Assets.Where(a => !IsDisc(a.Key)) + .Select(a => a.Value) + .FirstOrDefault(); + if (!genDiscs.Any() && romBytes == null) { return false; } - nextEmulator = new GPGX(nextComm, game, null, genDiscs, GetCoreSettings(), GetCoreSyncSettings()); + nextEmulator = new GPGX(nextComm, game, romBytes, genDiscs, GetCoreSettings(), GetCoreSyncSettings()); break; case "Game Gear": var leftBytesGG = xmlGame.Assets.First().Value; @@ -1165,5 +1167,11 @@ namespace BizHawk.Client.Common Game = game; return true; } + + private static bool IsDisc(string extension) => + extension == ".iso" + || extension == ".cue" + || extension == ".ccd" + || extension == ".mds"; } }