7
7
using BizHawk . BizInvoke ;
8
8
using BizHawk . Common ;
9
9
using BizHawk . Common . PathExtensions ;
10
+ using BizHawk . Common . StringExtensions ;
10
11
using BizHawk . Emulation . Common ;
11
12
using BizHawk . Emulation . Cores . Properties ;
12
13
using BizHawk . Emulation . Cores . Waterbox ;
@@ -35,6 +36,7 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
35
36
_wadFiles = lp . Roms ;
36
37
37
38
// Checking for correct IWAD configuration
39
+ _pwadFiles = new ( ) ;
38
40
bool foundIWAD = false ;
39
41
string IWADName = "" ;
40
42
foreach ( var wadFile in _wadFiles )
@@ -45,11 +47,13 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
45
47
// Check not more than one IWAD is provided
46
48
if ( foundIWAD ) throw new Exception ( $ "More than one IWAD provided. Trying to load '{ wadFile . RomPath } ', but IWAD '{ IWADName } ' was already provided") ;
47
49
IWADName = wadFile . RomPath ;
50
+ _iwadFile = wadFile ;
48
51
foundIWAD = true ;
49
52
recognized = true ;
50
53
}
51
54
else if ( wadFile . RomData is [ ( byte ) 'P' , ( byte ) 'W' , ( byte ) 'A' , ( byte ) 'D' , .. ] )
52
55
{
56
+ _pwadFiles . Add ( wadFile ) ;
53
57
recognized = true ;
54
58
}
55
59
if ( ! recognized ) throw new Exception ( $ "Unrecognized WAD provided: '{ wadFile . RomPath } ' has non-standard header.") ;
@@ -133,10 +137,15 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
133
137
// Adding dsda-doom wad file
134
138
_core . dsda_add_wad_file ( _dsdaWadFileName , _dsdaWadFileData . Length , _loadCallback ) ;
135
139
136
- // Adding rom files
137
- foreach ( var wadFile in _wadFiles )
140
+ // Adding IWAD file
141
+ var loadWadResult = _core . dsda_add_wad_file ( _iwadFile . RomPath , _iwadFile . RomData . Length , _loadCallback ) ;
142
+ if ( loadWadResult is 0 ) throw new Exception ( $ "Could not load WAD file: '{ _iwadFile . RomPath } '") ;
143
+ _gameMode = ( LibDSDA . GameMode ) loadWadResult ;
144
+
145
+ // Adding PWAD file(s)
146
+ foreach ( var wadFile in _pwadFiles )
138
147
{
139
- var loadWadResult = _core . dsda_add_wad_file ( wadFile . RomPath , wadFile . RomData . Length , _loadCallback ) ;
148
+ loadWadResult = _core . dsda_add_wad_file ( wadFile . RomPath , wadFile . RomData . Length , _loadCallback ) ;
140
149
if ( loadWadResult is 0 ) throw new Exception ( $ "Could not load WAD file: '{ wadFile . RomPath } '") ;
141
150
_gameMode = ( LibDSDA . GameMode ) loadWadResult ;
142
151
}
@@ -148,11 +157,19 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
148
157
var initResult = _core . dsda_init ( ref initSettings , _args . Count , _args . ToArray ( ) ) ;
149
158
if ( ! initResult ) throw new Exception ( $ "{ nameof ( _core . dsda_init ) } () failed") ;
150
159
151
- int fps = 35 ;
152
- VsyncNumerator = fps ;
160
+ VsyncNumerator = 35 ;
153
161
VsyncDenominator = 1 ;
154
162
155
- RomDetails = $ "{ lp . Game . Name } \r \n { SHA1Checksum . ComputePrefixedHex ( _wadFiles [ 0 ] . RomData ) } \r \n { MD5Checksum . ComputePrefixedHex ( _wadFiles [ 0 ] . RomData ) } ";
163
+ RomDetails += $ "IWAD: { GetFullName ( _iwadFile ) } " +
164
+ $ "\r \n { SHA1Checksum . ComputePrefixedHex ( _iwadFile . RomData ) } " +
165
+ $ "\r \n { MD5Checksum . ComputePrefixedHex ( _iwadFile . RomData ) } ";
166
+
167
+ foreach ( var file in _pwadFiles )
168
+ {
169
+ RomDetails += $ "\r \n \r \n PWAD: { GetFullName ( file ) } " +
170
+ $ "\r \n { SHA1Checksum . ComputePrefixedHex ( file . RomData ) } " +
171
+ $ "\r \n { MD5Checksum . ComputePrefixedHex ( file . RomData ) } ";
172
+ }
156
173
157
174
_elf . Seal ( ) ;
158
175
}
@@ -206,6 +223,8 @@ private void ConditionalArg(bool condition, string setting)
206
223
}
207
224
}
208
225
226
+ private string GetFullName ( IRomAsset rom ) => Path . GetFileName ( rom . RomPath . SubstringAfter ( '|' ) ) ;
227
+
209
228
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
210
229
private readonly WaterboxHost _elf ;
211
230
private readonly LibDSDA _core ;
@@ -221,7 +240,9 @@ private void ConditionalArg(bool condition, string setting)
221
240
private int _turnCarry = 0 ; // Chocolate Doom mouse behaviour (enabled in upstream by default)
222
241
private bool _lastGammaInput = false ;
223
242
private List < string > _args ;
243
+ private IRomAsset _iwadFile ;
224
244
private List < IRomAsset > _wadFiles ;
245
+ private List < IRomAsset > _pwadFiles ;
225
246
private LibDSDA . GameMode _gameMode ;
226
247
public string RomDetails { get ; } // IRomInfo
227
248
0 commit comments