2017-08-02 13:57:04 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// Filename : Read.cs
|
2017-08-02 13:57:04 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Disk image plugins.
|
2017-08-02 13:57:04 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// Reads Quasi88 disk images.
|
2017-08-02 13:57:04 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2017-08-02 13:57:04 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 19:33:46 +00:00
|
|
|
|
|
2017-08-02 13:57:04 +01:00
|
|
|
|
using System;
|
2017-08-02 18:30:30 +01:00
|
|
|
|
using System.Collections.Generic;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.IO;
|
2017-08-02 18:30:30 +01:00
|
|
|
|
using System.Linq;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Enums;
|
|
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using DiscImageChef.Console;
|
2017-08-02 18:30:30 +01:00
|
|
|
|
using DiscImageChef.Decoders.Floppy;
|
2019-03-01 07:35:22 +00:00
|
|
|
|
using DiscImageChef.Helpers;
|
2017-08-02 18:30:30 +01:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
namespace DiscImageChef.DiscImages
|
2017-08-02 13:57:04 +01:00
|
|
|
|
{
|
2018-07-23 23:25:43 +01:00
|
|
|
|
public partial class D88
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-28 19:56:36 +00:00
|
|
|
|
public bool Open(IFilter imageFilter)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
|
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
// Even if disk name is supposedly ASCII, I'm pretty sure most emulators allow Shift-JIS to be used :p
|
|
|
|
|
|
Encoding shiftjis = Encoding.GetEncoding("shift_jis");
|
|
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
if(stream.Length < Marshal.SizeOf<D88Header>()) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
byte[] hdrB = new byte[Marshal.SizeOf<D88Header>()];
|
2017-12-20 17:15:26 +00:00
|
|
|
|
stream.Read(hdrB, 0, hdrB.Length);
|
2019-03-01 07:35:22 +00:00
|
|
|
|
D88Header d88Hdr = Marshal.ByteArrayToStructureLittleEndian<D88Header>(hdrB);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.name = \"{0}\"",
|
2017-12-20 17:15:26 +00:00
|
|
|
|
StringHandlers.CToString(d88Hdr.name, shiftjis));
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.reserved is empty? = {0}",
|
2017-12-20 17:15:26 +00:00
|
|
|
|
d88Hdr.reserved.SequenceEqual(reservedEmpty));
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.write_protect = 0x{0:X2}", d88Hdr.write_protect);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_type = {0} ({1})", d88Hdr.disk_type,
|
|
|
|
|
|
(byte)d88Hdr.disk_type);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "d88hdr.disk_size = {0}", d88Hdr.disk_size);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
if(d88Hdr.disk_size != stream.Length) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
if(d88Hdr.disk_type != DiskType.D2 && d88Hdr.disk_type != DiskType.Dd2 &&
|
|
|
|
|
|
d88Hdr.disk_type != DiskType.Hd2) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
if(!d88Hdr.reserved.SequenceEqual(reservedEmpty)) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
int trkCounter = 0;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
foreach(int t in d88Hdr.track_table)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(t > 0) trkCounter++;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
if(t < 0 || t > stream.Length) return false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "{0} tracks", trkCounter);
|
|
|
|
|
|
|
|
|
|
|
|
if(trkCounter == 0) return false;
|
|
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
hdrB = new byte[Marshal.SizeOf<SectorHeader>()];
|
2017-12-20 17:15:26 +00:00
|
|
|
|
stream.Seek(d88Hdr.track_table[0], SeekOrigin.Begin);
|
|
|
|
|
|
stream.Read(hdrB, 0, hdrB.Length);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
SectorHeader sechdr = Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-28 04:57:26 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.c = {0}", sechdr.c);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.h = {0}", sechdr.h);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.r = {0}", sechdr.r);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.n = {0}", sechdr.n);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.spt = {0}", sechdr.spt);
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.density = {0}", sechdr.density);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.deleted_mark = {0}", sechdr.deleted_mark);
|
2017-12-28 04:57:26 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.status = {0}", sechdr.status);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "sechdr.size_of_data = {0}", sechdr.size_of_data);
|
|
|
|
|
|
|
2017-12-28 04:57:26 +00:00
|
|
|
|
short spt = sechdr.spt;
|
|
|
|
|
|
IBMSectorSizeCode bps = sechdr.n;
|
|
|
|
|
|
bool allEqual = true;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
sectorsData = new List<byte[]>();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < trkCounter; i++)
|
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
stream.Seek(d88Hdr.track_table[i], SeekOrigin.Begin);
|
|
|
|
|
|
stream.Read(hdrB, 0, hdrB.Length);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
SortedDictionary<byte, byte[]> sectors = new SortedDictionary<byte, byte[]>();
|
|
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
sechdr = Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
if(sechdr.spt != spt || sechdr.n != bps)
|
|
|
|
|
|
{
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin",
|
|
|
|
|
|
"Disk tracks are not same size. spt = {0} (expected {1}), bps = {2} (expected {3}) at track {4} sector {5}",
|
|
|
|
|
|
sechdr.spt, spt, sechdr.n, bps, i, 0);
|
|
|
|
|
|
allEqual = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-28 04:57:26 +00:00
|
|
|
|
short maxJ = sechdr.spt;
|
2017-12-20 17:15:26 +00:00
|
|
|
|
byte[] secB;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
for(short j = 1; j < maxJ; j++)
|
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
|
secB = new byte[sechdr.size_of_data];
|
|
|
|
|
|
stream.Read(secB, 0, secB.Length);
|
|
|
|
|
|
sectors.Add(sechdr.r, secB);
|
|
|
|
|
|
stream.Read(hdrB, 0, hdrB.Length);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
sechdr = Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
|
if(sechdr.spt == spt && sechdr.n == bps) continue;
|
|
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin",
|
|
|
|
|
|
"Disk tracks are not same size. spt = {0} (expected {1}), bps = {2} (expected {3}) at track {4} sector {5}",
|
|
|
|
|
|
sechdr.spt, spt, sechdr.n, bps, i, j, sechdr.deleted_mark);
|
|
|
|
|
|
allEqual = false;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
|
secB = new byte[sechdr.size_of_data];
|
|
|
|
|
|
stream.Read(secB, 0, secB.Length);
|
|
|
|
|
|
sectors.Add(sechdr.r, secB);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
|
|
|
|
|
foreach(KeyValuePair<byte, byte[]> kvp in sectors) sectorsData.Add(kvp.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "{0} sectors", sectorsData.Count);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.Unknown;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(allEqual)
|
|
|
|
|
|
if(trkCounter == 154 && spt == 26 && bps == IBMSectorSizeCode.EighthKilo)
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_8_SD;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
else if(bps == IBMSectorSizeCode.QuarterKilo)
|
2017-12-24 00:12:31 +00:00
|
|
|
|
switch(trkCounter)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 80 when spt == 16:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_525_SS;
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case 154 when spt == 26:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_8_DD;
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
case 160 when spt == 16:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_525_DS;
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
else if(trkCounter == 154 && spt == 8 && bps == IBMSectorSizeCode.Kilo)
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_525_HD;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
else if(bps == IBMSectorSizeCode.HalfKilo)
|
2017-12-20 17:15:26 +00:00
|
|
|
|
switch(d88Hdr.track_table.Length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
case 40:
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(spt)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 8:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_525_SS_DD_8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 9:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_525_SS_DD_9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 80:
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(spt)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 8:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_525_DS_DD_8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 9:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_525_DS_DD_9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 160:
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(spt)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 15:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.NEC_35_HD_15;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 9:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_35_DS_DD_9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 18:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_35_HD;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case 36:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.MediaType = MediaType.DOS_35_ED;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 480:
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(spt == 38) imageInfo.MediaType = MediaType.NEC_35_TD;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
DicConsole.DebugWriteLine("D88 plugin", "MediaType: {0}", imageInfo.MediaType);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.ImageSize = (ulong)d88Hdr.disk_size;
|
|
|
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
|
|
|
|
|
imageInfo.Sectors = (ulong)sectorsData.Count;
|
|
|
|
|
|
imageInfo.Comments = StringHandlers.CToString(d88Hdr.name, shiftjis);
|
|
|
|
|
|
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
|
|
|
|
|
imageInfo.SectorSize = (uint)(128 << (int)bps);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
switch(imageInfo.MediaType)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
case MediaType.NEC_525_SS:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 1;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 16;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.NEC_8_SD:
|
|
|
|
|
|
case MediaType.NEC_8_DD:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 77;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 26;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.NEC_525_DS:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 16;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.NEC_525_HD:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 77;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_525_SS_DD_8:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 40;
|
|
|
|
|
|
imageInfo.Heads = 1;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_525_SS_DD_9:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 40;
|
|
|
|
|
|
imageInfo.Heads = 1;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_525_DS_DD_8:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 40;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 8;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_525_DS_DD_9:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 40;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.NEC_35_HD_15:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 15;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_35_DS_DD_9:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 9;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_35_HD:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 18;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.DOS_35_ED:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 80;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 36;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MediaType.NEC_35_TD:
|
2017-12-28 04:57:26 +00:00
|
|
|
|
imageInfo.Cylinders = 240;
|
|
|
|
|
|
imageInfo.Heads = 2;
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imageInfo.SectorsPerTrack = 38;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-31 13:17:27 +00:00
|
|
|
|
public byte[] ReadSector(ulong sectorAddress) => ReadSectors(sectorAddress, 1);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found");
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(sectorAddress + length > imageInfo.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available");
|
|
|
|
|
|
|
|
|
|
|
|
MemoryStream buffer = new MemoryStream();
|
|
|
|
|
|
for(int i = 0; i < length; i++)
|
|
|
|
|
|
buffer.Write(sectorsData[(int)sectorAddress + i], 0, sectorsData[(int)sectorAddress + i].Length);
|
|
|
|
|
|
|
|
|
|
|
|
return buffer.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-08-02 18:30:30 +01:00
|
|
|
|
}
|