dsda: load wads correctly regardless of their order in xml
internal wad goes first, then whatever IWAD we found, then all the PWADs show all files in rom info
This commit is contained in:
parent
631e5c37b4
commit
c0f93b05fc
|
@ -7,6 +7,7 @@ using System.Text;
|
|||
using BizHawk.BizInvoke;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.PathExtensions;
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.Properties;
|
||||
using BizHawk.Emulation.Cores.Waterbox;
|
||||
|
@ -35,6 +36,7 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
_wadFiles = lp.Roms;
|
||||
|
||||
// Checking for correct IWAD configuration
|
||||
_pwadFiles = new();
|
||||
bool foundIWAD = false;
|
||||
string IWADName = "";
|
||||
foreach (var wadFile in _wadFiles)
|
||||
|
@ -45,11 +47,13 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
// 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");
|
||||
IWADName = wadFile.RomPath;
|
||||
_iwadFile = wadFile;
|
||||
foundIWAD = true;
|
||||
recognized = true;
|
||||
}
|
||||
else if (wadFile.RomData is [ (byte) 'P', (byte) 'W', (byte) 'A', (byte) 'D', .. ])
|
||||
{
|
||||
_pwadFiles.Add(wadFile);
|
||||
recognized = true;
|
||||
}
|
||||
if (!recognized) throw new Exception($"Unrecognized WAD provided: '{wadFile.RomPath}' has non-standard header.");
|
||||
|
@ -133,10 +137,15 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
// Adding dsda-doom wad file
|
||||
_core.dsda_add_wad_file(_dsdaWadFileName, _dsdaWadFileData.Length, _loadCallback);
|
||||
|
||||
// Adding rom files
|
||||
foreach (var wadFile in _wadFiles)
|
||||
// Adding IWAD file
|
||||
var loadWadResult = _core.dsda_add_wad_file(_iwadFile.RomPath, _iwadFile.RomData.Length, _loadCallback);
|
||||
if (loadWadResult is 0) throw new Exception($"Could not load WAD file: '{_iwadFile.RomPath}'");
|
||||
_gameMode = (LibDSDA.GameMode)loadWadResult;
|
||||
|
||||
// Adding PWAD file(s)
|
||||
foreach (var wadFile in _pwadFiles)
|
||||
{
|
||||
var loadWadResult = _core.dsda_add_wad_file(wadFile.RomPath, wadFile.RomData.Length, _loadCallback);
|
||||
loadWadResult = _core.dsda_add_wad_file(wadFile.RomPath, wadFile.RomData.Length, _loadCallback);
|
||||
if (loadWadResult is 0) throw new Exception($"Could not load WAD file: '{wadFile.RomPath}'");
|
||||
_gameMode = (LibDSDA.GameMode)loadWadResult;
|
||||
}
|
||||
|
@ -148,11 +157,19 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
var initResult = _core.dsda_init(ref initSettings, _args.Count, _args.ToArray());
|
||||
if (!initResult) throw new Exception($"{nameof(_core.dsda_init)}() failed");
|
||||
|
||||
int fps = 35;
|
||||
VsyncNumerator = fps;
|
||||
VsyncNumerator = 35;
|
||||
VsyncDenominator = 1;
|
||||
|
||||
RomDetails = $"{lp.Game.Name}\r\n{SHA1Checksum.ComputePrefixedHex(_wadFiles[0].RomData)}\r\n{MD5Checksum.ComputePrefixedHex(_wadFiles[0].RomData)}";
|
||||
RomDetails += $"IWAD: {GetFullName(_iwadFile)}" +
|
||||
$"\r\n{SHA1Checksum.ComputePrefixedHex(_iwadFile.RomData)}" +
|
||||
$"\r\n{MD5Checksum.ComputePrefixedHex(_iwadFile.RomData)}";
|
||||
|
||||
foreach (var file in _pwadFiles)
|
||||
{
|
||||
RomDetails += $"\r\n\r\nPWAD: {GetFullName(file)}" +
|
||||
$"\r\n{SHA1Checksum.ComputePrefixedHex(file.RomData)}" +
|
||||
$"\r\n{MD5Checksum.ComputePrefixedHex(file.RomData)}";
|
||||
}
|
||||
|
||||
_elf.Seal();
|
||||
}
|
||||
|
@ -206,6 +223,8 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
}
|
||||
}
|
||||
|
||||
private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|'));
|
||||
|
||||
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
||||
private readonly WaterboxHost _elf;
|
||||
private readonly LibDSDA _core;
|
||||
|
@ -221,7 +240,9 @@ namespace BizHawk.Emulation.Cores.Computers.Doom
|
|||
private int _turnCarry = 0; // Chocolate Doom mouse behaviour (enabled in upstream by default)
|
||||
private bool _lastGammaInput = false;
|
||||
private List<string> _args;
|
||||
private IRomAsset _iwadFile;
|
||||
private List<IRomAsset> _wadFiles;
|
||||
private List<IRomAsset> _pwadFiles;
|
||||
private LibDSDA.GameMode _gameMode;
|
||||
public string RomDetails { get; } // IRomInfo
|
||||
|
||||
|
|
Loading…
Reference in New Issue