예제 #1
0
파일: G64.cs 프로젝트: ddugovic/RASuite
		public static Disk Read(byte[] source)
		{
			MemoryStream mem = new MemoryStream(source);
			BinaryReader reader = new BinaryReader(mem);
			Disk result = new Disk();
			string id = new string(reader.ReadChars(8));

			if (id == @"GCR-1541")
			{
				int trackCount;
				int[] trackOffsetTable = new int[84];
				int[] trackSpeedTable = new int[84];

				reader.ReadByte(); //version
				trackCount = reader.ReadByte();
				reader.ReadInt16(); //max track size in bytes

				for (int i = 0; i < 84; i++)
					trackOffsetTable[i] = reader.ReadInt32();

				for (int i = 0; i < 84; i++)
					trackSpeedTable[i] = reader.ReadInt32();

				for (int i = 0; i < 84; i++)
				{
					if (trackOffsetTable[i] > 0)
					{
						int trackLength;
						byte[] trackData;
						Track track = new Track();

						mem.Position = trackOffsetTable[i];
						trackLength = reader.ReadInt16();
						trackData = reader.ReadBytes(trackLength);
						track.bits = trackLength * 8;
						track.data = trackData;
						track.density = trackSpeedTable[i];
						track.index = i;
						result.tracks.Add(track);
					}
				}
			}

			result.valid = (result.tracks.Count > 0);
			return result;
		}
예제 #2
0
파일: D64.cs 프로젝트: ddugovic/RASuite
		public static byte[] Write(Disk source)
		{
			return null;
		}
예제 #3
0
파일: D64.cs 프로젝트: ddugovic/RASuite
		public static Disk Read(byte[] source)
		{
			MemoryStream mem = new MemoryStream(source);
			BinaryReader reader = new BinaryReader(mem);
			Disk result = new Disk();
			int trackCount = 0;

			switch (source.Length)
			{
				case 174848: // 35 tracks no errors
					trackCount = 35;
					break;
				case 175531: // 35 tracks with errors
					trackCount = 35;
					break;
				case 196608: // 40 tracks no errors
					trackCount = 40;
					break;
				case 197376: // 40 tracks with errors
					trackCount = 40;
					break;
			}

			for (int i = 0; i < trackCount; i++)
			{
				Track track = new Track();
				int sectors = sectorsPerTrack[i];
				MemoryStream trackMem = new MemoryStream();

				for (int j = 0; j < sectors; j++)
				{
					int bitsWritten;
					byte[] sectorData = reader.ReadBytes(256);
					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.index = i;
				result.tracks.Add(track);
				trackMem.Dispose();
			}

			result.valid = (result.tracks.Count > 0);
			return result;
		}
예제 #4
0
 public static byte[] Write(Disk source)
 {
     return(null);
 }