From e6c6c417d5ad84658100c3a0697bd0cdb73252a7 Mon Sep 17 00:00:00 2001 From: feos Date: Mon, 24 May 2021 00:49:00 +0300 Subject: [PATCH] mame: populate bios menu --- .../Arcades/MAME/MAME.cs | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs index 8938019e1f..c69ad86bbf 100644 --- a/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs +++ b/src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs @@ -318,18 +318,44 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME string ROMsInfo = MameGetString(MAMELuaCommand.GetROMsInfo); string[] ROMs = ROMsInfo.Split(';'); + DriverSetting setting = new DriverSetting() + { + Name = "BIOS", + GameName = _gameShortName, + LuaCode = "bios", + Type = SettingType.BIOS + }; + foreach (string ROM in ROMs) { if (ROM != string.Empty) { - string[] substrings = ROM.Split(','); + string[] substrings = ROM.Split('~'); string name = substrings[0]; - string hashdata = substrings[1].Replace("R", " CRC:").Replace("S", " SHA:"); - string flags = substrings[2]; + string hashdata = substrings[1]; + long flags = long.Parse(substrings[2]); - _romHashes.Add(name, hashdata); + if ((flags & 0xf) == 9 || (flags & 0xf) == 10) + { + setting.Options.Add(name, hashdata); + + if ((flags & 0xf) == 10) + { + setting.DefaultValue = name; + } + } + else + { + hashdata = hashdata.Replace("R", " CRC:").Replace("S", " SHA:"); + _romHashes.Add(name, hashdata); + } } } + + if (setting.Options.Count > 0) + { + CurrentDriverSettings.Add(setting); + } } private class MAMELuaCommand @@ -378,7 +404,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME "local final = {} " + "for __, r in pairs(manager.machine.devices[\":\"].roms) do " + "if (r:hashdata() ~= \"\") then " + - "table.insert(final, string.format(\"%s,%s,%s;\", r:name(), r:hashdata(), r:flags())) " + + "table.insert(final, string.format(\"%s~%s~%s;\", r:name(), r:hashdata(), r:flags())) " + "end " + "end " + "table.sort(final) " +