From a8957f1916218f511b3fb77cde481255f0bfa9d6 Mon Sep 17 00:00:00 2001 From: saxxonpike Date: Wed, 14 Nov 2012 04:58:39 +0000 Subject: [PATCH] commodore64: D64 loading fills gap bits to meet MNIB standard track lengths --- BizHawk.Emulation/Computers/Commodore64/D64.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BizHawk.Emulation/Computers/Commodore64/D64.cs b/BizHawk.Emulation/Computers/Commodore64/D64.cs index 70710df23e..523b63542e 100644 --- a/BizHawk.Emulation/Computers/Commodore64/D64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/D64.cs @@ -60,6 +60,11 @@ namespace BizHawk.Emulation.Computers.Commodore64 17, 17, 17, 17, 17 }; + private static int[] standardTrackLengthBytes = + { + 6250, 6666, 7142, 7692 + }; + private static byte Checksum(byte[] source) { int count = source.Length; @@ -221,9 +226,15 @@ namespace BizHawk.Emulation.Computers.Commodore64 byte[] diskData = ConvertSectorToGCR(sectorData, (byte)j, (byte)i, (byte)0x00, (byte)0x00, out bitsWritten); trackMem.Write(diskData, 0, diskData.Length); } + track.density = densityTable[i]; + + // we pad the tracks with extra gap bytes to meet MNIB standards + while (trackMem.Length < standardTrackLengthBytes[track.density]) + { + trackMem.WriteByte(0x55); + } track.data = trackMem.ToArray(); track.bits = (int)trackMem.Length; - track.density = densityTable[i]; track.index = i; result.tracks.Add(track); trackMem.Dispose();