puae: fix crash

This commit is contained in:
feos 2024-11-07 00:08:19 +03:00
parent 869bef4989
commit 7c88dba814
2 changed files with 9 additions and 3 deletions

View File

@ -10,6 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
{ {
public partial class PUAE public partial class PUAE
{ {
private ControllerType[] _ports { get; set; }
private static readonly (string Name, LibPUAE.AllButtons Button)[] _joystickMap = CreateJoystickMap(); private static readonly (string Name, LibPUAE.AllButtons Button)[] _joystickMap = CreateJoystickMap();
private static readonly (string Name, LibPUAE.AllButtons Button)[] _cd32padMap = CreateCd32padMap(); private static readonly (string Name, LibPUAE.AllButtons Button)[] _cd32padMap = CreateCd32padMap();
private static readonly (string Name, LibPUAE.PUAEKeyboard Key)[] _keyboardMap = CreateKeyboardMap(); private static readonly (string Name, LibPUAE.PUAEKeyboard Key)[] _keyboardMap = CreateKeyboardMap();

View File

@ -50,6 +50,12 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
_syncSettings = lp.SyncSettings ?? new(); _syncSettings = lp.SyncSettings ?? new();
_syncSettings.FloppyDrives = Math.Min(LibPUAE.MAX_FLOPPIES, _syncSettings.FloppyDrives); _syncSettings.FloppyDrives = Math.Min(LibPUAE.MAX_FLOPPIES, _syncSettings.FloppyDrives);
var filesToRemove = new List<string>(); var filesToRemove = new List<string>();
_ports = [
_syncSettings.ControllerPort1,
_syncSettings.ControllerPort2
];
CreateArguments(_syncSettings); CreateArguments(_syncSettings);
ControllerDefinition = CreateControllerDefinition(_syncSettings); ControllerDefinition = CreateControllerDefinition(_syncSettings);
@ -157,10 +163,9 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
for (int port = 1; port <= 2; port++) for (int port = 1; port <= 2; port++)
{ {
ControllerType type = (port == 1) ? _syncSettings.ControllerPort1 : _syncSettings.ControllerPort2;
var currentPort = (port == 1) ? fi.Port1 : fi.Port2; var currentPort = (port == 1) ? fi.Port1 : fi.Port2;
switch (type) switch (_ports[port - 1])
{ {
case ControllerType.Joystick: case ControllerType.Joystick:
{ {