diff --git a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs index 3d08c54916..04acf46b2c 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs @@ -76,10 +76,10 @@ namespace BizHawk.Emulation.Cores.Waterbox SkipSoundening = 2, // render at LCM * LCM instead of raw RenderConstantSize = 4, - // switch to the previous disk, if possible - PreviousDisk = 8, - // switch to the next disk, if possible - NextDisk = 16 + // open disk tray, if possible + OpenTray = 8, + // close disk tray, if possible + CloseTray = 16 } [StructLayout(LayoutKind.Sequential)] @@ -98,6 +98,10 @@ namespace BizHawk.Emulation.Cores.Waterbox /// If the core calls time functions, this is the value that will be used /// public long FrontendTime; + /// + /// disk index to use if close tray is done + /// + public int DiskIndex; } /// diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs index ca2d5cac1a..0e52b1d538 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs @@ -19,10 +19,10 @@ namespace BizHawk.Emulation.Cores.Waterbox private readonly byte[] _inputPortData = new byte[MAX_INPUT_DATA]; private readonly string _controllerDeckName; - private void InitControls(List allPorts, bool hasCds, ref SystemInfo si) + private void InitControls(List allPorts, int numCds, ref SystemInfo si) { _controllerAdapter = new ControllerAdapter( - allPorts, _syncSettingsActual.PortDevices, OverrideButtonName, hasCds, ref si, ComputeHiddenPorts(), + allPorts, _syncSettingsActual.PortDevices, OverrideButtonName, numCds, ref si, ComputeHiddenPorts(), _controllerDeckName); _nyma.SetInputDevices(_controllerAdapter.Devices); ControllerDefinition = _controllerAdapter.Definition; @@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Waterbox List allPorts, IDictionary config, Func overrideName, - bool hasCds, + int numCds, ref SystemInfo systemInfo, HashSet hiddenPorts, string controllerDeckName) @@ -52,8 +52,9 @@ namespace BizHawk.Emulation.Cores.Waterbox { { "Power", "System" }, { "Reset", "System" }, - { "Previous Disk", "System" }, - { "Next Disk", "System" }, + { "Open Tray", "System" }, + { "Close Tray", "System" }, + { "Disk Index", "System" }, } }; @@ -261,10 +262,11 @@ namespace BizHawk.Emulation.Cores.Waterbox } ret.BoolButtons.Add("Power"); ret.BoolButtons.Add("Reset"); - if (hasCds) + if (numCds > 0) { - ret.BoolButtons.Add("Previous Disk"); - ret.BoolButtons.Add("Next Disk"); + ret.BoolButtons.Add("Open Tray"); + ret.BoolButtons.Add("Close Tray"); + ret.AddAxis("Disk Index", (-1).RangeTo(numCds - 1), 0); } Definition = ret.MakeImmutable(); finalDevices.Add(null); diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs index ac2c8aef06..ba9e1021d4 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs @@ -150,7 +150,7 @@ namespace BizHawk.Emulation.Cores.Waterbox ClockRate = info.MasterClock / (double)0x100000000; _soundBuffer = new short[22050 * 2]; - InitControls(portData, discs?.Length > 0, ref info); + InitControls(portData, discs?.Length ?? 0, ref info); PostInit(); SettingsInfo.LayerNames = GetLayerData(); _settings.Normalize(SettingsInfo); @@ -217,10 +217,10 @@ namespace BizHawk.Emulation.Cores.Waterbox flags |= LibNymaCore.BizhawkFlags.SkipSoundening; if (SettingsQuery("nyma.constantfb") != "0") flags |= LibNymaCore.BizhawkFlags.RenderConstantSize; - if (controller.IsPressed("Previous Disk")) - flags |= LibNymaCore.BizhawkFlags.PreviousDisk; - if (controller.IsPressed("Next Disk")) - flags |= LibNymaCore.BizhawkFlags.NextDisk; + if (controller.IsPressed("Open Tray")) + flags |= LibNymaCore.BizhawkFlags.OpenTray; + if (controller.IsPressed("Close Tray")) + flags |= LibNymaCore.BizhawkFlags.CloseTray; var ret = new LibNymaCore.FrameInfo { @@ -232,6 +232,7 @@ namespace BizHawk.Emulation.Cores.Waterbox : LibNymaCore.CommandType.NONE, InputPortData = (byte*)_frameAdvanceInputLock.AddrOfPinnedObject(), FrontendTime = GetRtcTime(SettingsQuery("nyma.rtcrealtime") != "0"), + DiskIndex = (int)controller.AxisValue("Disk Index") }; if (_frameThreadStart != null) { diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs index f44268f4ba..d601dbff8c 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/PSXSchema.cs @@ -67,7 +67,7 @@ namespace BizHawk.Emulation.Cores }; } - yield return NymaConsoleButtons(); + yield return NymaConsoleButtons(nyma.ControllerDefinition.Axes["Disk Index"]); } } @@ -429,23 +429,23 @@ namespace BizHawk.Emulation.Cores }; } - private static PadSchema NymaConsoleButtons() + private static PadSchema NymaConsoleButtons(AxisSpec diskRange) { return new ConsoleSchema { - Size = new Size(327, 50), - Buttons = new[] + Size = new Size(250, 100), + Buttons = new PadSchemaControl[] { new ButtonSchema(10, 15, "Reset"), new ButtonSchema(58, 15, "Power"), - new ButtonSchema(108, 15, "Previous Disk") + new ButtonSchema(108, 15, "Open Tray"), + new ButtonSchema(175, 15, "Close Tray"), + new SingleAxisSchema(10, 35, "Disk Index") { - DisplayName = "Prev Disc" - }, - new ButtonSchema(175, 15, "Next Disk") - { - DisplayName = "Next Disc" - }, + MinValue = diskRange.Min, + MaxValue = diskRange.Max, + TargetSize = new Size(235, 60) + } } }; } diff --git a/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs b/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs index a6e2a6925d..92505587bc 100644 --- a/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs +++ b/src/BizHawk.Emulation.Cores/vpads_schemata/SaturnSchema.cs @@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores } } - yield return ConsoleButtons(); + yield return ConsoleButtons(nyma.ControllerDefinition.Axes["Disk Index"]); } private static PadSchema GenerateSchemaForPort(string device, int controllerNum, Action showMessageBox) @@ -277,22 +277,22 @@ namespace BizHawk.Emulation.Cores }; } - private static PadSchema ConsoleButtons() + private static PadSchema ConsoleButtons(AxisSpec diskRange) { return new ConsoleSchema { - Size = new Size(327, 50), - Buttons = new[] + Size = new Size(327, 100), + Buttons = new PadSchemaControl[] { new ButtonSchema(10, 15, "Reset"), new ButtonSchema(58, 15, "Power"), - new ButtonSchema(108, 15, "Previous Disk") + new ButtonSchema(108, 15, "Open Tray"), + new ButtonSchema(175, 15, "Close Tray"), + new SingleAxisSchema(10, 35, "Disk Index") { - DisplayName = "Prev Disc" - }, - new ButtonSchema(175, 15, "Next Disk") - { - DisplayName = "Next Disc" + MinValue = diskRange.Min, + MaxValue = diskRange.Max, + TargetSize = new Size(310, 60) }, new ButtonSchema(242, 15, "P13 Smpc Reset") {