mame: obtain rom names and hashes
This commit is contained in:
parent
ef02263122
commit
36787d7292
|
@ -84,7 +84,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||||
author: "MAMEDev",
|
author: "MAMEDev",
|
||||||
isPorted: true,
|
isPorted: true,
|
||||||
isReleased: false,
|
isReleased: false,
|
||||||
portedVersion: "0.220",
|
portedVersion: "0.221",
|
||||||
portedUrl: "https://github.com/mamedev/mame.git",
|
portedUrl: "https://github.com/mamedev/mame.git",
|
||||||
singleInstance: false)]
|
singleInstance: false)]
|
||||||
public partial class MAME : IEmulator, IVideoProvider, ISoundProvider, ISettable<object, MAME.SyncSettings>, IStatable, IInputPollable
|
public partial class MAME : IEmulator, IVideoProvider, ISoundProvider, ISettable<object, MAME.SyncSettings>, IStatable, IInputPollable
|
||||||
|
@ -160,6 +160,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||||
private ManualResetEvent _memoryAccessComplete = new ManualResetEvent(false);
|
private ManualResetEvent _memoryAccessComplete = new ManualResetEvent(false);
|
||||||
private AutoResetEvent _mamePeriodicComplete = new AutoResetEvent(false);
|
private AutoResetEvent _mamePeriodicComplete = new AutoResetEvent(false);
|
||||||
private SortedDictionary<string, string> _fieldsPorts = new SortedDictionary<string, string>();
|
private SortedDictionary<string, string> _fieldsPorts = new SortedDictionary<string, string>();
|
||||||
|
private SortedDictionary<string, string> _romHashes = new SortedDictionary<string, string>();
|
||||||
private IController _controller = NullController.Instance;
|
private IController _controller = NullController.Instance;
|
||||||
private IMemoryDomains _memoryDomains;
|
private IMemoryDomains _memoryDomains;
|
||||||
private byte[] _mameSaveBuffer;
|
private byte[] _mameSaveBuffer;
|
||||||
|
@ -676,6 +677,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||||
|
|
||||||
CheckVersions();
|
CheckVersions();
|
||||||
GetInputFields();
|
GetInputFields();
|
||||||
|
GetROMsInfo();
|
||||||
UpdateVideo();
|
UpdateVideo();
|
||||||
UpdateAspect();
|
UpdateAspect();
|
||||||
UpdateFramerate();
|
UpdateFramerate();
|
||||||
|
@ -738,6 +740,25 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GetROMsInfo()
|
||||||
|
{
|
||||||
|
string ROMsInfo = MameGetString(MAMELuaCommand.GetROMsInfo);
|
||||||
|
string[] ROMs = ROMsInfo.Split(';');
|
||||||
|
|
||||||
|
foreach (string ROM in ROMs)
|
||||||
|
{
|
||||||
|
if (ROM != string.Empty)
|
||||||
|
{
|
||||||
|
string[] substrings = ROM.Split(',');
|
||||||
|
string name = substrings[0];
|
||||||
|
string hashdata = substrings[1].Replace("R", " CRC:").Replace("S", " SHA:");
|
||||||
|
string flags = substrings[2];
|
||||||
|
|
||||||
|
_romHashes.Add(name, hashdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SendInput()
|
private void SendInput()
|
||||||
{
|
{
|
||||||
foreach (var fieldPort in _fieldsPorts)
|
foreach (var fieldPort in _fieldsPorts)
|
||||||
|
@ -796,6 +817,31 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
||||||
"end " +
|
"end " +
|
||||||
"table.sort(final) " +
|
"table.sort(final) " +
|
||||||
"return table.concat(final)";
|
"return table.concat(final)";
|
||||||
|
public const string GetROMsInfo =
|
||||||
|
"final = {} " +
|
||||||
|
"devices = {} " +
|
||||||
|
"for _, d in pairs(manager:machine().devices) do " +
|
||||||
|
"devices[d:tag()] = d " +
|
||||||
|
"local device = d " +
|
||||||
|
"for i=0,10 do " +
|
||||||
|
"local owner = device:owner() " +
|
||||||
|
"if owner then " +
|
||||||
|
"devices[owner:tag()] = owner " +
|
||||||
|
"device = owner " +
|
||||||
|
"else " +
|
||||||
|
"break " +
|
||||||
|
"end " +
|
||||||
|
"end " +
|
||||||
|
"end " +
|
||||||
|
"for _, d in pairs(devices) do " +
|
||||||
|
"for __, r in pairs(d.roms) do " +
|
||||||
|
"if (r:hashdata() ~= \"\") then " +
|
||||||
|
"table.insert(final, string.format(\"%s,%s,%s;\", r:name(), r:hashdata(), r:flags())) " +
|
||||||
|
"end " +
|
||||||
|
"end " +
|
||||||
|
"end " +
|
||||||
|
"table.sort(final) " +
|
||||||
|
"return table.concat(final)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue