diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 28f58d54e3..c934cbfc6f 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -26,39 +26,6 @@ namespace BizHawk.Client.Common public override string Name { get { return "emu"; } } - private static void SetrenderplanesDo(IList luaParam) - { - if (Global.Emulator is NES) - { - // in the future, we could do something more arbitrary here. - // but this isn't any worse than the old system - var s = (NES.NESSettings)Global.Emulator.GetSettings(); - s.DispSprites = (bool)luaParam[0]; - s.DispBackground = (bool)luaParam[1]; - Global.Emulator.PutSettings(s); - } - else if (Global.Emulator is PCEngine) - { - var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); - s.ShowOBJ1 = (bool)luaParam[0]; - s.ShowBG1 = (bool)luaParam[1]; - if (luaParam.Count > 2) - { - s.ShowOBJ2 = (bool)luaParam[2]; - s.ShowBG2 = (bool)luaParam[3]; - } - - Global.Emulator.PutSettings(s); - } - else if (Global.Emulator is SMS) - { - var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); - s.DispOBJ = (bool)luaParam[0]; - s.DispBG = (bool)luaParam[1]; - Global.Emulator.PutSettings(s); - } - } - [LuaMethodAttributes( "displayvsync", "Sets the display vsync property of the emulator" @@ -159,14 +126,47 @@ namespace BizHawk.Client.Common "setrenderpanes", "Toggles the drawing of sprites and background planes. Set to false or nil to disable a pane, anything else will draw them" )] - public static void SetRenderPlanes( // For now, it accepts arguments up to 5. - object param0, - object param1 = null, - object param2 = null, - object param3 = null, - object param4 = null) + public static void SetRenderPlanes(params bool[] luaParam) { - SetrenderplanesDo(LuaVarArgs(param0, param1, param2, param3, param4)); + if (Global.Emulator is NES) + { + // in the future, we could do something more arbitrary here. + // but this isn't any worse than the old system + var s = (NES.NESSettings)Global.Emulator.GetSettings(); + s.DispSprites = (bool)luaParam[0]; + s.DispBackground = (bool)luaParam[1]; + Global.Emulator.PutSettings(s); + } + else if (Global.Emulator is PCEngine) + { + var s = (PCEngine.PCESettings)Global.Emulator.GetSettings(); + s.ShowOBJ1 = GetSetting(0, luaParam); + s.ShowBG1 = GetSetting(1, luaParam); + if (luaParam.Length > 2) + { + s.ShowOBJ2 = GetSetting(2, luaParam); + s.ShowBG2 = GetSetting(3, luaParam); + } + + Global.Emulator.PutSettings(s); + } + else if (Global.Emulator is SMS) + { + var s = (SMS.SMSSettings)Global.Emulator.GetSettings(); + s.DispOBJ = GetSetting(0, luaParam); + s.DispBG = GetSetting(1, luaParam); + Global.Emulator.PutSettings(s); + } + } + + private static bool GetSetting(int index, bool[] settings) + { + if (index < settings.Length) + { + return settings[index]; + } + + return true; } [LuaMethodAttributes(