diff --git a/output/dll/faust.wbx.gz b/output/dll/faust.wbx.gz index 3084c9f131..057fc1c471 100644 Binary files a/output/dll/faust.wbx.gz and b/output/dll/faust.wbx.gz differ diff --git a/output/dll/ngp.wbx.gz b/output/dll/ngp.wbx.gz index 34489b4475..bc1547def1 100644 Binary files a/output/dll/ngp.wbx.gz and b/output/dll/ngp.wbx.gz differ diff --git a/output/dll/pce-fast.wbx.gz b/output/dll/pce-fast.wbx.gz index f570b97eef..20d4110301 100644 Binary files a/output/dll/pce-fast.wbx.gz and b/output/dll/pce-fast.wbx.gz differ diff --git a/output/dll/pce.wbx.gz b/output/dll/pce.wbx.gz index 26a9377363..3ba9950259 100644 Binary files a/output/dll/pce.wbx.gz and b/output/dll/pce.wbx.gz differ diff --git a/output/dll/pcfx.wbx.gz b/output/dll/pcfx.wbx.gz index 8e0839e56b..7ffbab68e1 100644 Binary files a/output/dll/pcfx.wbx.gz and b/output/dll/pcfx.wbx.gz differ diff --git a/output/dll/ss.wbx.gz b/output/dll/ss.wbx.gz index 304a9fe741..2411591047 100644 Binary files a/output/dll/ss.wbx.gz and b/output/dll/ss.wbx.gz differ diff --git a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs index 9a8d436db2..f4df2b172a 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/LibNymaCore.cs @@ -145,6 +145,10 @@ namespace BizHawk.Emulation.Cores.Waterbox public int FpsFixed; public int LcmWidth; public int LcmHeight; + public int PointerScaleX; + public int PointerScaleY; + public int PointerOffsetX; + public int PointerOffsetY; } [BizImport(CC, Compatibility = true)] diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs index 64de5f8083..a032100087 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.Controller.cs @@ -4,19 +4,22 @@ using System.IO; using System.Linq; using BizHawk.Emulation.Common; using NymaTypes; +using static BizHawk.Emulation.Cores.Waterbox.LibNymaCore; namespace BizHawk.Emulation.Cores.Waterbox { unsafe partial class NymaCore { + private const int MAX_INPUT_DATA = 256; + private ControllerAdapter _controllerAdapter; - private readonly byte[] _inputPortData = new byte[16 * 16]; + private readonly byte[] _inputPortData = new byte[MAX_INPUT_DATA]; private readonly string _controllerDeckName; - private void InitControls(List allPorts, bool hasCds) + private void InitControls(List allPorts, bool hasCds, ref SystemInfo si) { _controllerAdapter = new ControllerAdapter( - allPorts, _syncSettingsActual.PortDevices, ButtonNameOverrides, hasCds, ComputeHiddenPorts()); + allPorts, _syncSettingsActual.PortDevices, ButtonNameOverrides, hasCds, ref si, ComputeHiddenPorts()); _nyma.SetInputDevices(_controllerAdapter.Devices); ControllerDefinition = _controllerAdapter.Definition; } @@ -24,15 +27,6 @@ namespace BizHawk.Emulation.Cores.Waterbox protected class ControllerAdapter : IBinaryStateable { - /// - /// allowed number of input ports. must match native - /// - private const int MAX_PORTS = 16; - /// - /// total maximum bytes on each input port. must match native - /// - private const int MAX_PORT_DATA = 16; - /// /// Device list suitable to pass back to the core /// @@ -43,6 +37,7 @@ namespace BizHawk.Emulation.Cores.Waterbox IDictionary config, IDictionary overrides, bool hasCds, + ref SystemInfo systemInfo, HashSet hiddenPorts) { var ret = new ControllerDefinition @@ -59,10 +54,8 @@ namespace BizHawk.Emulation.Cores.Waterbox var finalDevices = new List(); - if (allPorts.Count > MAX_PORTS) - throw new InvalidOperationException($"Too many input ports"); var switchPreviousFrame = new List(); - for (int port = 0, devByteStart = 0; port < allPorts.Count; port++, devByteStart += MAX_PORT_DATA) + for (int port = 0, devByteStart = 0; port < allPorts.Count; port++) { var portInfo = allPorts[port]; var deviceName = config.ContainsKey(port) ? config[port] : portInfo.DefaultDeviceShortName; @@ -83,8 +76,6 @@ namespace BizHawk.Emulation.Cores.Waterbox } var deviceInfo = device; - if (deviceInfo.ByteLength > MAX_PORT_DATA) - throw new InvalidOperationException($"Input device {deviceInfo.ShortName} uses more than {MAX_PORT_DATA} bytes"); var category = portInfo.FullName + " - " + deviceInfo.FullName; var inputs = deviceInfo.Inputs @@ -205,24 +196,36 @@ namespace BizHawk.Emulation.Cores.Waterbox var val = c.AxisValue(fullName); b[byteStart] = (byte)val; b[byteStart + 1] = (byte)(val >> 8); - }); - break; + }); + break; } case InputType.PointerX: { - throw new NotImplementedException("TODO: Support Pointer"); // I think the core expects to be sent some sort of 16 bit integer, but haven't investigated much - // ret.AxisControls.Add(name); - // ret.AxisRanges.Add(new ControllerDefinition.AxisRange(0, ????, ????)); - // break; + ret.AxisControls.Add(name); + ret.AxisRanges.Add(new ControllerDefinition.AxisRange( + systemInfo.PointerOffsetX, systemInfo.PointerOffsetX, systemInfo.PointerScaleX)); + _thunks.Add((c, b) => + { + var val = c.AxisValue(name); + b[byteStart] = (byte)val; + b[byteStart + 1] = (byte)(val >> 8); + }); + break; } case InputType.PointerY: { - throw new Exception("TODO: Support Pointer"); // I think the core expects to be sent some sort of 16 bit integer, but haven't investigated much - // ret.AxisControls.Add(name); - // ret.AxisRanges.Add(new ControllerDefinition.AxisRange(0, ????, ????, true)); - // break; + ret.AxisControls.Add(name); + ret.AxisRanges.Add(new ControllerDefinition.AxisRange( + systemInfo.PointerOffsetY, systemInfo.PointerOffsetY, systemInfo.PointerScaleY)); + _thunks.Add((c, b) => + { + var val = c.AxisValue(name); + b[byteStart] = (byte)val; + b[byteStart + 1] = (byte)(val >> 8); + }); + break; } case InputType.ButtonAnalog: { @@ -239,13 +242,18 @@ namespace BizHawk.Emulation.Cores.Waterbox }); break; } - // TODO: wire up statuses to something (not controller, of course) + case InputType.Status: + // TODO: wire up statuses to something (not controller, of course) + break; default: { throw new NotImplementedException($"Unimplemented button type {input.Type}"); } } } + devByteStart += (int)deviceInfo.ByteLength; + if (devByteStart > MAX_INPUT_DATA) + throw new NotImplementedException($"More than {MAX_INPUT_DATA} input data bytes"); } ret.BoolButtons.Add("Power"); ret.BoolButtons.Add("Reset"); diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs index 9176a6b5c1..614d15a0a9 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs @@ -132,7 +132,7 @@ namespace BizHawk.Emulation.Cores.Waterbox VsyncDenominator = 1 << 24; _soundBuffer = new short[22050 * 2]; - InitControls(portData, discs?.Length > 0); + InitControls(portData, discs?.Length > 0, ref info); _nyma.SetFrontendSettingQuery(null); if (_disks != null) _nyma.SetCDCallbacks(null, null); diff --git a/waterbox/nyma/NymaCore.cpp b/waterbox/nyma/NymaCore.cpp index 6ed597dac1..e601f584bf 100644 --- a/waterbox/nyma/NymaCore.cpp +++ b/waterbox/nyma/NymaCore.cpp @@ -23,9 +23,8 @@ struct InitData const char* FileNameFull; }; -enum { MAX_PORTS = 16 }; -enum { MAX_PORT_DATA = 16 }; -static uint8_t InputPortData[(MAX_PORTS + 1) * MAX_PORT_DATA]; +enum { MAX_INPUT_DATA = 256 }; +static uint8_t InputPortData[MAX_INPUT_DATA]; bool LagFlag; void (*InputCallback)(); @@ -244,6 +243,10 @@ struct SystemInfo int32_t FpsFixed; int32_t LcmWidth; int32_t LcmHeight; + int32_t PointerScaleX; + int32_t PointerScaleY; + int32_t PointerOffsetX; + int32_t PointerOffsetY; }; SystemInfo SI; @@ -257,6 +260,10 @@ ECL_EXPORT SystemInfo* GetSystemInfo() SI.FpsFixed = Game->fps; SI.LcmWidth = Game->lcm_width; SI.LcmHeight = Game->lcm_height; + SI.PointerScaleX = Game->mouse_scale_x; + SI.PointerScaleY = Game->mouse_scale_y; + SI.PointerOffsetX = Game->mouse_offs_x; + SI.PointerOffsetY = Game->mouse_offs_y; return &SI; } @@ -277,10 +284,16 @@ ECL_EXPORT void SetInputCallback(void (*cb)()) ECL_EXPORT void SetInputDevices(const char** devices) { - for (unsigned port = 0; port < MAX_PORTS && devices[port]; port++) + for (unsigned port = 0, dataStart = 0; devices[port]; port++) { - std::string dev(devices[port]); - Game->SetInput(port, dev.c_str(), &InputPortData[port * MAX_PORT_DATA]); + unsigned dataSize = 0; + for (auto const& device: Game->PortInfo[port].DeviceInfo) + { + if (strcmp(device.ShortName, devices[port]) == 0) + dataSize = device.IDII.InputByteSize; + } + Game->SetInput(port, devices[port], &InputPortData[dataStart]); + dataStart += dataSize; } } diff --git a/waterbox/nyma/rebuild-all-released-cores.sh b/waterbox/nyma/rebuild-all-released-cores.sh new file mode 100644 index 0000000000..7311f895ce --- /dev/null +++ b/waterbox/nyma/rebuild-all-released-cores.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +make -f pce.mak install -j6 +make -f pce-fast.mak install -j6 +make -f ngp.mak install -j6 +make -f faust.mak install -j6 +make -f pcfx.mak install -j6 +make -f ss.mak install -j6