FDS: connect drive LED front end feature. also fix a bitsy savestate&saveram issue

This commit is contained in:
goyuken 2012-11-26 21:27:54 +00:00
parent 7e9d487580
commit 91a71febe5
3 changed files with 23 additions and 2 deletions

View File

@ -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<bool> callback)
{
diskdrive.DriveLightCallback = callback;
}
/// <summary>
/// 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;
}

View File

@ -202,6 +202,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
#endregion
public Action<bool> DriveLightCallback;
/// <summary>
/// eject the loaded disk
/// </summary>
@ -211,6 +213,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
state = RamAdapterState.IDLE;
SetCycles();
Console.WriteLine("FDS: Disk ejected");
if (DriveLightCallback != null)
DriveLightCallback(false);
}
/// <summary>
@ -231,6 +235,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
SetCycles();
Console.WriteLine("FDS: Disk Inserted");
originaldisk = (byte[])disk.Clone();
if (DriveLightCallback != null)
DriveLightCallback(false);
}
/// <summary>
@ -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:

View File

@ -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)
{