This commit is contained in:
feos 2025-06-07 15:36:59 +03:00
parent 6ab684dba6
commit 4f8beb5536
11 changed files with 86 additions and 66 deletions

View File

@ -125,6 +125,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
[Flags]
public enum AllButtons : short
{
None = 0b0000000000000000,
Up = 0b0000000000000001,
Down = 0b0000000000000010,
Left = 0b0000000000000100,

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
{
public partial class UAE
{
private LibUAE.ControllerType[] _ports { get; set; }
private LibUAE.ControllerType[] Ports { get; set; }
private static readonly (string Name, LibUAE.AllButtons Button)[] _joystickMap = CreateJoystickMap();
private static readonly (string Name, LibUAE.AllButtons Button)[] _cd32padMap = CreateCd32padMap();
private static readonly (string Name, LibUAE.UAEKeyboard Key)[] _keyboardMap = CreateKeyboardMap();
@ -62,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
for (int port = 1; port <= 2; port++)
{
LibUAE.ControllerType type = port == 1
var type = port == 1
? settings.ControllerPort1
: settings.ControllerPort2;

View File

@ -145,56 +145,56 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
private void CreateArguments(UAESyncSettings settings)
{
_args = new List<string>
{
_args =
[
"uae",
};
];
switch(settings.MachineConfig)
{
case MachineConfig.A500_OCS_130_512K_512K:
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A500);
AppendSetting(new List<string>
{
AppendSetting(
[
"cpu_model=" + (int)CpuModel._68000,
"chipset=" + Chipset.OCS,
"chipset_compatible=" + _chipsetCompatible,
"chipmem_size=" + (int)ChipMemory.KB_512,
"bogomem_size=" + (int)SlowMemory.KB_512,
"fastmem_size=0",
});
]);
EnableCycleExact();
break;
case MachineConfig.A600_ECS_205_2M:
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A600);
AppendSetting(new List<string>
{
AppendSetting(
[
"cpu_model=" + (int)CpuModel._68000,
"chipset=" + Chipset.ECS,
"chipset_compatible=" + _chipsetCompatible,
"chipmem_size=" + (int)ChipMemory.MB_2,
"bogomem_size=" + (int)SlowMemory.KB_0,
"fastmem_size=0",
});
]);
EnableCycleExact();
break;
case MachineConfig.A1200_AGA_310_2M_8M:
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A1200);
AppendSetting(new List<string>
{
AppendSetting(
[
"cpu_model=" + (int)CpuModel._68020,
"chipset=" + Chipset.AGA,
"chipset_compatible=" + _chipsetCompatible,
"chipmem_size=" + (int)ChipMemory.MB_2,
"bogomem_size=" + (int)SlowMemory.KB_0,
"fastmem_size=0",
});
]);
EnableCycleExact();
break;
case MachineConfig.A4000_AGA_310_2M_8M:
_chipsetCompatible = Enum.GetName(typeof(ChipsetCompatible), ChipsetCompatible.A4000);
AppendSetting(new List<string>
{
AppendSetting(
[
"cpu_model=" + (int)CpuModel._68040,
"fpu_model=68040",
"mmu_model=68040",
@ -203,7 +203,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
"chipmem_size=" + (int)ChipMemory.MB_2,
"bogomem_size=" + (int)SlowMemory.KB_0,
"fastmem_size=8",
});
]);
break;
}
@ -258,7 +258,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
for (int port = 0; port <= 1; port++)
{
LibUAE.ControllerType type = port == 0
var type = port == 0
? settings.ControllerPort1
: settings.ControllerPort2;
AppendSetting(type is LibUAE.ControllerType.None
@ -269,13 +269,13 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
private void EnableCycleExact()
{
AppendSetting(new List<string>
{
AppendSetting(
[
"cpu_compatible=true",
"cpu_cycle_exact=true",
"cpu_memory_cycle_exact=true",
"blitter_cycle_exact=true",
});
]);
}
private void AppendSetting(List<string> settings)
@ -288,10 +288,10 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
private void AppendSetting(string setting)
{
_args.AddRange(new List<string>
{
_args.AddRange(
[
"-s", setting
});
]);
}
public object GetSettings() => null;

View File

@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
isReleased: true)]
public partial class UAE : WaterboxCore
{
private static readonly Configuration ConfigPAL = new Configuration
private static readonly Configuration ConfigPAL = new()
{
SystemId = VSystemID.Raw.Amiga,
MaxSamples = 8 * 1024,
@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
DefaultFpsDenominator = LibUAE.VIDEO_DENOMINATOR_PAL
};
private static readonly Configuration ConfigNTSC = new Configuration
private static readonly Configuration ConfigNTSC = new()
{
SystemId = VSystemID.Raw.Amiga,
MaxSamples = 8 * 1024,
@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
DeterministicEmulation = lp.DeterministicEmulationRequested || _syncSettings.FloppySpeed is FloppySpeed._100;
var filesToRemove = new List<string>();
_ports = [
Ports = [
_syncSettings.ControllerPort1,
_syncSettings.ControllerPort2
];
@ -97,7 +97,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
MmapHeapSizeKB = 20 * 1024,
SkipCoreConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
SkipMemoryConsistencyCheck = lp.Comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
}, new Delegate[] { _ledCallback });
}, [ _ledCallback ]);
for (var index = 0; index < lp.Roms.Count; index++)
{
@ -146,13 +146,13 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
{
Port1 = new LibUAE.ControllerState
{
Type = _ports[0],
Buttons = 0
Type = Ports[0],
Buttons = LibUAE.AllButtons.None
},
Port2 = new LibUAE.ControllerState
{
Type = _ports[1],
Buttons = 0
Type = Ports[1],
Buttons = LibUAE.AllButtons.None
},
Action = LibUAE.DriveAction.None
};
@ -161,7 +161,7 @@ namespace BizHawk.Emulation.Cores.Computers.Amiga
{
ref var currentPort = ref (port is 1 ? ref fi.Port1 : ref fi.Port2);
switch (_ports[port - 1])
switch (Ports[port - 1])
{
case LibUAE.ControllerType.DJoy:
{

View File

@ -8,15 +8,13 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
public static ControllerDefinition CreateControllerDefinition(DoomSyncSettings settings)
{
var controller = new ControllerDefinition($"Doom Controller");
var controller = new ControllerDefinition("Doom Controller");
var longtics = settings.TurningResolution == TurningResolution.Longtics;
for (int i = 0; i < 4; i++)
for (int port = 1; port <= 4; port++)
{
if ((PlayersPresent(settings) & (1 << i)) is not 0)
if (PlayerPresent(settings, port))
{
var port = i + 1;
controller
.AddAxis($"P{port} Run Speed", (-50).RangeTo(50), 0)
.AddAxis($"P{port} Strafing Speed", (-50).RangeTo(50), 0)
@ -31,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
controller
.AddAxis($"P{port} Weapon Select", (0).RangeTo(7), 0)
.AddAxis($"P{port} Weapon Select", 0.RangeTo(7), 0)
.AddAxis($"P{port} Mouse Running", (-128).RangeTo(127), 0)
// current max raw mouse delta is 180
.AddAxis($"P{port} Mouse Turning", (longtics ? -180 : -128).RangeTo(longtics ? 180 : 127), 0);
@ -40,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
controller
.AddAxis($"P{port} Fly / Look", (-7).RangeTo(7), 0)
.AddAxis($"P{port} Use Artifact", (0).RangeTo(10), 0);
.AddAxis($"P{port} Use Artifact", 0.RangeTo(10), 0);
}
controller.BoolButtons.AddRange([

View File

@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
// cycle through [0 - 4]
_settings.Gamma++;
_settings.Gamma %= 5;
_comm.Notify("Gamma correction " +
Comm.Notify("Gamma correction " +
(_settings.Gamma == 0 ? "OFF" : "level " + _settings.Gamma),
4); // internal messages last 4 seconds
}
@ -59,9 +59,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
for (int i = 0; i < 4; i++)
{
if ((PlayersPresent(_syncSettings) & (1 << i)) is not 0)
var port = i + 1;
if (PlayerPresent(_syncSettings, port))
{
int port = i + 1;
players[i].Buttons = LibDSDA.Buttons.None;
bool strafe = controller.IsPressed($"P{port} Strafe");
@ -231,7 +231,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
}
}
LibDSDA.PackedRenderInfo renderInfo = new LibDSDA.PackedRenderInfo()
var renderInfo = new LibDSDA.PackedRenderInfo()
{
SfxVolume = _settings.SfxVolume,
MusicVolume = _settings.MusicVolume,

View File

@ -18,15 +18,15 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
MemoryDomain.Endian.Little,
addr =>
{
if (addr > 0xFFFFFF) throw new ArgumentOutOfRangeException(paramName: nameof(addr), addr, message: "address out of range");
return _core.dsda_read_memory_array(LibDSDA.MemoryArrayType.Things, (uint)addr);
if (addr > 0xFFFFFF)
throw new ArgumentOutOfRangeException(paramName: nameof(addr), addr, message: "address out of range");
return _core.dsda_read_memory_array(LibDSDA.MemoryArrayType.Things, (uint) addr);
},
null,
1),
_elf.GetPagesDomain()
};
domains.Add(_elf.GetPagesDomain());
MemoryDomains = new MemoryDomainList(domains) { };
MemoryDomains = new MemoryDomainList(domains);
((BasicServiceProvider)ServiceProvider).Register(MemoryDomains);
}
}

View File

@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
{
using (_elf.EnterExit())
{
_core.dsda_get_video(gamma, out LibDSDA.VideoInfo vi);
_core.dsda_get_video(gamma, out var vi);
var videoBuffer = (byte*)vi.VideoBuffer.ToPointer();
var paletteBuffer = (int*)vi.PaletteBuffer.ToPointer();

View File

@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
ServiceProvider = new BasicServiceProvider(this);
_finalSyncSettings = _syncSettings = lp.SyncSettings ?? new DoomSyncSettings();
_settings = lp.Settings ?? new DoomSettings();
_comm = lp.Comm;
Comm = lp.Comm;
_loadCallback = LoadCallback;
// Gathering information for the rest of the wads
@ -46,7 +46,13 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
if (wadFile.RomData is [ (byte) 'I', (byte) 'W', (byte) 'A', (byte) 'D', .. ])
{
// Check not more than one IWAD is provided
if (foundIWAD) throw new Exception($"More than one IWAD provided. Trying to load '{wadFile.RomPath}', but IWAD '{IWADName}' was already provided");
if (foundIWAD)
{
throw new ArgumentException(
$"More than one IWAD provided. Trying to load '{wadFile.RomPath}', but IWAD '{IWADName}' was already provided",
paramName: nameof(lp));
}
IWADName = wadFile.RomPath;
_iwadFile = wadFile;
foundIWAD = true;
@ -60,14 +66,18 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
if (!recognized)
{
throw new Exception($"Unrecognized WAD provided: '{wadFile.RomPath}' has non-standard header.");
throw new ArgumentException(
$"Unrecognized WAD provided: '{wadFile.RomPath}' has non-standard header.",
paramName: nameof(lp));
}
}
// Check at least one IWAD was provided
if (!foundIWAD)
{
throw new Exception("No IWAD was provided");
throw new ArgumentException(
"No IWAD was provided",
paramName: nameof(lp));
}
// Getting dsda-doom.wad -- required by DSDA
@ -149,7 +159,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
_gameMode = _core.dsda_add_wad_file(_iwadFile.RomPath, _iwadFile.RomData.Length, _loadCallback);
if (_gameMode is LibDSDA.GameMode.Fail)
{
throw new Exception($"Could not load WAD file: '{_iwadFile.RomPath}'");
throw new ArgumentException(
$"Could not load WAD file: '{_iwadFile.RomPath}'",
paramName: nameof(lp));
}
// Adding PWAD file(s)
@ -158,18 +170,22 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
_gameMode = _core.dsda_add_wad_file(wadFile.RomPath, wadFile.RomData.Length, _loadCallback);
if (_gameMode is LibDSDA.GameMode.Fail)
{
throw new Exception($"Could not load WAD file: '{wadFile.RomPath}'");
throw new ArgumentException(
$"Could not load WAD file: '{wadFile.RomPath}'",
paramName: nameof(lp));
}
}
_elf.AddReadonlyFile(_configFile, "dsda-doom.cfg");
var initSettings = _syncSettings.GetNativeSettings(lp.Game);
var initSettings = _syncSettings.GetNativeSettings();
CreateArguments(initSettings);
var initResult = _core.dsda_init(ref initSettings, _args.Count, _args.ToArray());
if (!initResult)
{
throw new Exception($"{nameof(_core.dsda_init)}() failed");
throw new ArgumentException(
$"{nameof(_core.dsda_init)}() failed",
paramName: nameof(lp));
}
VsyncNumerator = 35;
@ -183,7 +199,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
if (_pwadFiles.Count > 0)
{
SortedList<string> hashes = new();
SortedList<string> hashes = [ ];
foreach (var file in _pwadFiles)
{
@ -266,13 +282,18 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|'));
private static int PlayersPresent(DoomSyncSettings syncSettings) => Convert.ToInt32(syncSettings.Player1Present)
| Convert.ToInt32(syncSettings.Player2Present) << 1
| Convert.ToInt32(syncSettings.Player3Present) << 2
| Convert.ToInt32(syncSettings.Player4Present) << 3;
private static bool PlayerPresent(DoomSyncSettings syncSettings, int port) =>
port switch
{
1 => syncSettings.Player1Present,
2 => syncSettings.Player2Present,
3 => syncSettings.Player3Present,
4 => syncSettings.Player4Present,
_ => false
};
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
internal CoreComm _comm { get; }
internal CoreComm Comm { get; }
private readonly WaterboxHost _elf;
private readonly LibDSDA _core;
private readonly LibDSDA.load_archive_cb _loadCallback;

View File

@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
[TypeConverter(typeof(DescribableEnumConverter))]
public Atari2600ControllerTypes Port2 { get; set; }
public CInterface.InitSettings GetNativeSettings(GameInfo game)
public CInterface.InitSettings GetNativeSettings()
{
return new CInterface.InitSettings
{

View File

@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Atari.Stella
Core = BizInvoker.GetInvoker<CInterface>(_elf, _elf, callingConventionAdapter);
_romfile = lp.Roms[0].RomData;
var initResult = Core.stella_init("rom.a26", _loadCallback, _syncSettings.GetNativeSettings(lp.Game));
var initResult = Core.stella_init("rom.a26", _loadCallback, _syncSettings.GetNativeSettings());
if (!initResult) throw new Exception($"{nameof(Core.stella_init)}() failed");