Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve Volume table of contents.
        /// </summary>
        /// <param name="diskImage"></param>
        /// <returns></returns>
        public VolumeTableOfContents GetVolumeTableOfContents(Stream diskImage)
        {
            //var diskTracks = 35;
            var trackSectors = 16;
            var sectorLength = 256;

            var trackNumber  = 0x11;
            var sectorNumber = 0;

            var vtocLocation = trackNumber * trackSectors * sectorLength + sectorNumber * sectorLength;

            diskImage.Position = vtocLocation;
            var         sector     = new byte[sectorLength];
            Span <byte> sectorSpan = sector;
            var         read       = diskImage.Read(sectorSpan);

            var vtoc = new VolumeTableOfContents(sectorSpan.Slice(0, read));

            return(vtoc);
        }
Ejemplo n.º 2
0
        //private byte[] _data;
        public IEnumerable <CatalogEntry> GetCatalogs(Stream diskImage, VolumeTableOfContents vtoc)
        {
            var catalogTrack  = vtoc.FirstCatalogTrack;
            var catalogSector = vtoc.FirstCatalogSector;
            var trackSectors  = vtoc.NumberOfSectorsPerTrack;
            var sectorLength  = vtoc.NumberOfBytesPerSector;

nextCatalog:

            var catalogLocation = catalogTrack * trackSectors * sectorLength + catalogSector * sectorLength;

            var catalogSpan = new byte[sectorLength];

            diskImage.Position = catalogLocation;
            diskImage.Read(catalogSpan, 0, 0);
            var catalog = new CatalogEntry
            {
                // Unused0 = catalogSpan[0x0],
                NextCatalogTrack = catalogSpan[0x01],
                NextSectorTrack  = catalogSpan[0x02],
                //Unused3_A = sectorSpan.Slice(0x03, 0x0a - 0x03 + 1).ToArray(),

                FileEntries = GetFileEntries(diskImage, catalogSpan, 0x0b, 0x2e, 0x51, 0x74, 0x97, 0xba, 0xdd),
            };

            yield return(catalog);

            Console.WriteLine($"Catalog: {catalog}");

            if (catalog.NextCatalogTrack != 0 && catalog.NextSectorTrack != 0)
            {
                catalogTrack  = catalog.NextCatalogTrack;
                catalogSector = catalog.NextSectorTrack;
                goto nextCatalog;
            }
        }