From 4ccf4eafef1408a5b93c078503f51b554c006701 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 27 Sep 2024 05:46:44 +1000 Subject: [PATCH] Add missing disc presence check to `NymaCore.FrameAdvancePrep` fixes #4056 `ControllerAdapter` ctor uses `(discs?.Length ?? 0) > 0`, but it gets `discs` from earlier in core init; when it's later assigned to `_disks`, empty lists are replaced with null, and other places in `NymaCore` use `_disks != null`. The `default(int)` is to match pre-3af5b7a7f behaviour. --- src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs index 8d72141e41..11cd4045b4 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs @@ -245,10 +245,13 @@ namespace BizHawk.Emulation.Cores.Waterbox flags |= LibNymaCore.BizhawkFlags.SkipSoundening; if (SettingsQuery("nyma.constantfb") != "0") flags |= LibNymaCore.BizhawkFlags.RenderConstantSize; - if (controller.IsPressed("Open Tray")) - flags |= LibNymaCore.BizhawkFlags.OpenTray; - if (controller.IsPressed("Close Tray")) - flags |= LibNymaCore.BizhawkFlags.CloseTray; + int diskIndex = default; + if (_disks is not null) + { + if (controller.IsPressed("Open Tray")) flags |= LibNymaCore.BizhawkFlags.OpenTray; + if (controller.IsPressed("Close Tray")) flags |= LibNymaCore.BizhawkFlags.CloseTray; + diskIndex = controller.AxisValue("Disk Index"); + } var ret = new LibNymaCore.FrameInfo { @@ -260,7 +263,7 @@ namespace BizHawk.Emulation.Cores.Waterbox : LibNymaCore.CommandType.NONE, InputPortData = (byte*)_frameAdvanceInputLock.AddrOfPinnedObject(), FrontendTime = GetRtcTime(SettingsQuery("nyma.rtcrealtime") != "0"), - DiskIndex = controller.AxisValue("Disk Index") + DiskIndex = diskIndex, }; if (_frameThreadStart != null) {