support some rogue FDS disk format

This commit is contained in:
goyuken 2013-12-08 21:39:17 +00:00
parent d3f088a0bc
commit de71c0d8c7
2 changed files with 17 additions and 1 deletions

View File

@ -92,6 +92,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <param name="diskimage"></param>
public void SetDiskImage(byte[] diskimage)
{
// each FDS format is worse than the last
if (diskimage.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("\x01*NI")))
{
int nsides = diskimage.Length / 65500;
MemoryStream ms = new MemoryStream();
ms.Write(System.Text.Encoding.ASCII.GetBytes("FDS\x1A"), 0, 4);
ms.WriteByte((byte)nsides);
byte[] nulls = new byte[11];
ms.Write(nulls, 0, 11);
ms.Write(diskimage, 0, diskimage.Length);
ms.Close();
diskimage = ms.ToArray();
}
this.diskimage = diskimage;
diskdiffs = new byte[NumSides][];
}

View File

@ -590,7 +590,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
hash_sha1_several.Add(hash_sha1);
LoadWriteLine("headerless rom hash: {0}", hash_sha1);
}
else if (file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("FDS\x1A")))
else if (file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("FDS\x1A"))
|| file.Take(4).SequenceEqual(System.Text.Encoding.ASCII.GetBytes("\x01*NI")))
{
// there's not much else to do with FDS images other than to feed them to the board
origin = EDetectionOrigin.FDS;