add a simple "XMLGame" capability where a game can be theoretically loaded from an xml definition. very preliminary. hooked up dual gameboy to it, so you can now load dual gameboy again by using a .xml
This commit is contained in:
parent
6fd7c22d01
commit
7830ec7384
|
@ -517,6 +517,7 @@
|
|||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tools\WatchCommon.cs" />
|
||||
<Compile Include="XmlGame.cs" />
|
||||
<EmbeddedResource Include="AVOut\FFmpegWriterForm.resx">
|
||||
<DependentUpon>FFmpegWriterForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -1922,15 +1922,48 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (file.Extension.ToLower() == ".xml")
|
||||
{
|
||||
var XMLG = XmlGame.Create(file);
|
||||
|
||||
if (XMLG != null)
|
||||
{
|
||||
game = XMLG.GI;
|
||||
|
||||
switch (game.System)
|
||||
{
|
||||
case "DGB":
|
||||
|
||||
var L = Database.GetGameInfo(XMLG.Assets["LeftRom"], "left.gb");
|
||||
var R = Database.GetGameInfo(XMLG.Assets["RightRom"], "right.gb");
|
||||
|
||||
if (Global.Config.GB_ForceDMG) L.AddOption("ForceDMG");
|
||||
if (Global.Config.GB_GBACGB) L.AddOption("GBACGB");
|
||||
if (Global.Config.GB_MulticartCompat) L.AddOption("MulitcartCompat");
|
||||
if (Global.Config.GB_ForceDMG) R.AddOption("ForceDMG");
|
||||
if (Global.Config.GB_GBACGB) R.AddOption("GBACGB");
|
||||
if (Global.Config.GB_MulticartCompat) R.AddOption("MulitcartCompat");
|
||||
|
||||
GambatteLink gbl = new GambatteLink(nextComm, L, XMLG.Assets["LeftRom"], R, XMLG.Assets["RightRom"]);
|
||||
nextEmulator = gbl;
|
||||
// other stuff todo
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
// if load fails, second chance to identify as a bsnes XML
|
||||
}
|
||||
else // most extensions
|
||||
{
|
||||
rom = new RomGame(file);
|
||||
game = rom.GameInfo;
|
||||
|
||||
bool isXml = false;
|
||||
|
||||
//right now, xml is always snes.
|
||||
//later, we may need to inspect the XML ourselves to dispatch it to the correct system (if any other systems ever use xml...)
|
||||
// other xml has already been handled
|
||||
if (file.Extension.ToLower() == ".xml")
|
||||
{
|
||||
game.System = "SNES";
|
||||
|
@ -2031,20 +2064,6 @@ namespace BizHawk.MultiClient
|
|||
break;
|
||||
case "GB":
|
||||
case "GBC":
|
||||
//if (false) // this code will load up a dual game boy
|
||||
//{
|
||||
// // this is horrible. we MUST decide when we should be using Game.System and when we should be using Emulator.SystemID
|
||||
// game.System = "DGB"; // HACK
|
||||
|
||||
// if (Global.Config.GB_ForceDMG) game.AddOption("ForceDMG");
|
||||
// if (Global.Config.GB_GBACGB) game.AddOption("GBACGB");
|
||||
// if (Global.Config.GB_MulticartCompat) game.AddOption("MulitcartCompat");
|
||||
// GambatteLink gbl = new GambatteLink(nextComm, game, rom.FileData, game, rom.FileData);
|
||||
// nextEmulator = gbl;
|
||||
// // other stuff todo
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
if (!Global.Config.GB_AsSGB)
|
||||
{
|
||||
if (Global.Config.GB_ForceDMG) game.AddOption("ForceDMG");
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class XmlGame
|
||||
{
|
||||
public XmlDocument Xml;
|
||||
public GameInfo GI = new GameInfo();
|
||||
public Dictionary<string, byte[]> Assets = new Dictionary<string, byte[]>();
|
||||
|
||||
public static XmlGame Create(HawkFile f)
|
||||
{
|
||||
try
|
||||
{
|
||||
var x = new XmlDocument();
|
||||
x.Load(f.GetStream());
|
||||
var y = x.SelectSingleNode("./BizHawk-XMLGame");
|
||||
if (y == null)
|
||||
return null;
|
||||
|
||||
var ret = new XmlGame();
|
||||
ret.GI.System = y.Attributes["System"].Value;
|
||||
ret.GI.Name = y.Attributes["Name"].Value;
|
||||
ret.GI.Status = RomStatus.Unknown;
|
||||
ret.Xml = x;
|
||||
|
||||
var n = y.SelectSingleNode("./LoadAssets");
|
||||
if (n != null)
|
||||
{
|
||||
foreach (XmlNode a in n.ChildNodes)
|
||||
{
|
||||
string name = a.Name;
|
||||
string filename = a.Attributes["FileName"].Value;
|
||||
if (filename[0] == '|')
|
||||
{
|
||||
// in same archive
|
||||
var ai = f.FindArchiveMember(filename.Substring(1));
|
||||
if (ai != null)
|
||||
{
|
||||
f.BindArchiveMember(ai);
|
||||
byte[] data = Util.ReadAllBytes(f.GetStream());
|
||||
ret.Assets[name] = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
string fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|')[0]);
|
||||
fullpath = Path.Combine(fullpath, filename);
|
||||
try
|
||||
{
|
||||
byte[] data = File.ReadAllBytes(fullpath);
|
||||
ret.Assets[name] = data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue