Skip to content

Commit 0ff2539

Browse files
author
adelikat
committed
subneshawk - support DatachBarcode service
1 parent 09f90cc commit 0ff2539

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,21 @@ public void HardReset()
142142
// set controller definition first time only
143143
if (ControllerDefinition == null)
144144
{
145-
ControllerDefinition = new ControllerDefinition(ControllerDeck.GetDefinition());
146-
ControllerDefinition.Name = "NES Controller";
145+
ControllerDefinition = new ControllerDefinition(ControllerDeck.GetDefinition())
146+
{
147+
Name = "NES Controller"
148+
};
149+
147150
// controls other than the deck
148151
ControllerDefinition.BoolButtons.Add("Power");
149152
ControllerDefinition.BoolButtons.Add("Reset");
150-
if (Board is FDS)
153+
if (Board is FDS b)
151154
{
152-
var b = Board as FDS;
153155
ControllerDefinition.BoolButtons.Add("FDS Eject");
154156
for (int i = 0; i < b.NumSides; i++)
157+
{
155158
ControllerDefinition.BoolButtons.Add("FDS Insert " + i);
159+
}
156160
}
157161

158162
if (_isVS)
@@ -164,7 +168,7 @@ public void HardReset()
164168
}
165169

166170
// Add in the reset timing float control for subneshawk
167-
if (using_reset_timing && (ControllerDefinition.FloatControls.Count() == 0))
171+
if (using_reset_timing && ControllerDefinition.FloatControls.Count == 0)
168172
{
169173
ControllerDefinition.FloatControls.Add("Reset Cycle");
170174
ControllerDefinition.FloatRanges.Add(new ControllerDefinition.FloatRange(0, 0, 500000));

BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public NES(CoreComm comm, GameInfo game, byte[] rom, object settings, object syn
2323
var ser = new BasicServiceProvider(this);
2424
ServiceProvider = ser;
2525

26-
byte[] fdsbios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false);
27-
if (fdsbios != null && fdsbios.Length == 40976)
26+
byte[] fdsBios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false);
27+
if (fdsBios != null && fdsBios.Length == 40976)
2828
{
2929
comm.ShowMessage("Your FDS BIOS is a bad dump. BizHawk will attempt to use it, but no guarantees! You should find a new one.");
3030
var tmp = new byte[8192];
31-
Buffer.BlockCopy(fdsbios, 16 + 8192 * 3, tmp, 0, 8192);
32-
fdsbios = tmp;
31+
Buffer.BlockCopy(fdsBios, 16 + 8192 * 3, tmp, 0, 8192);
32+
fdsBios = tmp;
3333
}
3434

3535
SyncSettings = (NESSyncSettings)syncSettings ?? new NESSyncSettings();
@@ -38,11 +38,11 @@ public NES(CoreComm comm, GameInfo game, byte[] rom, object settings, object syn
3838

3939
BootGodDB.Initialize();
4040
videoProvider = new MyVideoProvider(this);
41-
Init(game, rom, fdsbios);
42-
if (Board is FDS)
41+
Init(game, rom, fdsBios);
42+
if (Board is FDS fds)
4343
{
4444
DriveLightEnabled = true;
45-
(Board as FDS).SetDriveLightCallback((val) => DriveLightOn = val);
45+
fds.SetDriveLightCallback(val => DriveLightOn = val);
4646
// bit of a hack: we don't have a private gamedb for FDS, but the frontend
4747
// expects this to be set.
4848
RomStatus = game.Status;

BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ public SubNESHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/
5050
VBL_CNT = 0;
5151

5252
_nesStatable = subnes.ServiceProvider.GetService<IStatable>();
53+
54+
var barCodeService = subnes.ServiceProvider.GetService<DatachBarcode>();
55+
if (barCodeService != null)
56+
{
57+
ser.Register(barCodeService);
58+
}
5359
}
5460

5561
public void HardReset() => subnes.HardReset();

0 commit comments

Comments
 (0)