diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs index 22a3cf202c..489eff95f9 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs @@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo currentside = tmp == 1234567 ? null : (int?)tmp; } for (int i = 0; i < NumSides; i++) - ser.Sync("diskdiffs" + i, ref diskdiffs[i], false); + ser.Sync("diskdiffs" + i, ref diskdiffs[i], true); ser.Sync("_timerirq", ref _timerirq); ser.Sync("_diskirq", ref _diskirq); ser.Sync("diskenable", ref diskenable); @@ -79,6 +79,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo SetIRQ(); } + public void SetDriveLightCallback(Action callback) + { + diskdrive.DriveLightCallback = callback; + } /// /// should only be called once, before emulation begins @@ -140,7 +144,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo byte[] buf = new byte[65500]; Buffer.BlockCopy(diskimage, 16 + side * 65500, buf, 0, 65500); diskdrive.InsertBrokenImage(buf, false /*true*/); - if (diskdiffs[side] != null) + if (diskdiffs[side] != null && diskdiffs[side].Length > 0) diskdrive.ApplyDiff(diskdiffs[side]); currentside = side; } diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/RamAdapter.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/RamAdapter.cs index 757a88b2e4..80ac184cdd 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/RamAdapter.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/RamAdapter.cs @@ -202,6 +202,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo #endregion + public Action DriveLightCallback; + /// /// eject the loaded disk /// @@ -211,6 +213,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo state = RamAdapterState.IDLE; SetCycles(); Console.WriteLine("FDS: Disk ejected"); + if (DriveLightCallback != null) + DriveLightCallback(false); } /// @@ -231,6 +235,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo SetCycles(); Console.WriteLine("FDS: Disk Inserted"); originaldisk = (byte[])disk.Clone(); + if (DriveLightCallback != null) + DriveLightCallback(false); } /// @@ -378,6 +384,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo state = RamAdapterState.SPINUP; SetCycles(); //} + if (DriveLightCallback != null) + DriveLightCallback(true); } } if ((value & 2) != 0) @@ -488,6 +496,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo state = RamAdapterState.RESET; transferreset = false; //numcrc = 0; + if (DriveLightCallback != null) + DriveLightCallback(false); } SetCycles(); break; @@ -500,12 +510,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo transferreset = false; //numcrc = 0; Console.WriteLine("FDS: Return or Insert Complete"); + if (DriveLightCallback != null) + DriveLightCallback(false); break; case RamAdapterState.SPINUP: state = RamAdapterState.RUNNING; SetCycles(); //transferreset = false; // this definitely does not happen. Console.WriteLine("FDS: Spin up complete! Disk is running"); + if (DriveLightCallback != null) + DriveLightCallback(true); break; case RamAdapterState.IDLE: diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index a40b15aa08..a056642241 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -32,6 +32,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo ControllerDefinition.BoolButtons.Add("FDS Eject"); for (int i = 0; i < b.NumSides; i++) ControllerDefinition.BoolButtons.Add("FDS Insert " + i); + + CoreOutputComm.UsesDriveLed = true; + b.SetDriveLightCallback((val) => CoreOutputComm.DriveLED = val); } if (vs_io) {