/// <summary>
 /// Constructor
 /// </summary>
 public BAM1541() : base()
 {
     DoubleSide = false;
     EntrySize  = 4;
     SingleSideStructure();
     Directory = new SectorId(18, 1);
     SectorsMap[Directory.Track - 1].ResetFlag(0); // Header and BAM sector on 18/0
 }
Exemple #2
0
 private void addEntry(byte[] data, SectorId id, byte record)
 {
     if (data[2] != 0)
     {
         DirectoryEntry entry = new DirectoryEntry(data);
         entry.Reference.track  = id.Track;
         entry.Reference.sector = id.Sector;
         entry.Reference.entry  = record;
         dir.Add(entry);
     }
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public BAM8050() : base()
 {
     EntrySize = 5;
     SingleSideStructure();
     Directory = new SectorId(39, 1);
     SectorsMap[Directory.Track - 1].ResetFlag(0); // Header sector on 39/0
     SectorsMap[BAMtrack].ResetFlag(0);            // BAM sector on 38/0
     SectorsMap[BAMtrack].ResetFlag(3);            // BAM sector on 38/3
     DOSversion = 'C';
     DOStype[0] = '2';
     DOStype[1] = 'C';
 }
Exemple #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 public BAM1581() : base()
 {
     EntrySize = 6;
     for (int j = 1; j <= 80; j++)
     {
         addTrackStructure(40);
     }
     Directory  = new SectorId(40, 1);
     DOSversion = 'D';
     DOStype[0] = '3';
     DOStype[1] = 'D';
     SectorsMap[Directory.Track - 1].ResetFlag(0); // Header sector on 40/0
     SectorsMap[Directory.Track - 1].ResetFlag(1); // BAM sector on 40/1
     SectorsMap[Directory.Track - 1].ResetFlag(2); // BAM sector on 40/2
 }
Exemple #5
0
        /// <summary>
        /// Load header from disk image
        /// </summary>
        /// <param name="disk">Disk image to read</param>
        /// <param name="track">Track of disk header</param>
        /// <param name="sector">Secton inside track of disk header</param>
        protected virtual void LoadHeader(BaseDisk disk, int track, int sector)
        {
            byte[] data = disk.GetSector(track, sector);

            Directory  = new SectorId(data[0], data[1]);
            DOSversion = (char)data[2];
            DiskName   = string.Empty;
            for (int j = 0x90; j <= 0x9F; j++)
            {
                DiskName += (char)data[j];
            }
            DiskId[0]  = (char)data[0xA2];
            DiskId[1]  = (char)data[0xA3];
            DOStype[0] = (char)data[0xA5];
            DOStype[1] = (char)data[0xA6];
        }
Exemple #6
0
        /// <summary>
        /// Loads directory from disk image database
        /// </summary>
        /// <param name="disk">disk image to read</param>
        /// <param name="id">directory start track/sector</param>
        public void Load(BaseDisk disk, SectorId id)
        {
            byte[] sectorData = disk.GetSector(id);

            for (byte j = 0; j < EntriesPerSector; j++)
            {
                byte[] entryData = new byte[DirectoryEntry.EntrySize];
                Array.Copy(sectorData, j * DirectoryEntry.EntrySize, entryData, 0, DirectoryEntry.EntrySize);
                addEntry(entryData, id, j);
            }

            if (sectorData[0] == 0)
            {
                return;
            }
            Load(disk, new SectorId(sectorData[0], sectorData[1]));
        }
        /// <summary>
        /// Read disk header
        /// </summary>
        /// <param name="disk">disk to analyze</param>
        /// <param name="track">header track</param>
        /// <param name="sector">header sector</param>
        protected override void LoadHeader(BaseDisk disk, int track, int sector)
        {
            byte[] data = disk.GetSector(track, sector);

            BAM        = new SectorId(data[0], data[1]);
            Directory  = new SectorId(39, 1);
            DOSversion = (char)data[2];
            DiskName   = string.Empty;
            for (int j = 0x06; j <= 0x16; j++)
            {
                DiskName += (char)data[j];
            }
            DiskId[0]  = (char)data[0x18];
            DiskId[1]  = (char)data[0x19];
            DOStype[0] = (char)data[0x1B];
            DOStype[1] = (char)data[0x1C];
        }
Exemple #8
0
        /// <summary>
        /// Build record from raw data
        /// </summary>
        /// <param name="data">raw entry data</param>
        public DirectoryEntry(byte[] data) : this()
        {
            Closed          = !((data[2] & 0x80) != 0);
            Locked          = ((data[2] & 0x40) != 0);
            Type            = (FileType)(data[2] & 0x07);
            First           = new SectorId(data[3], data[4]);
            RelFirst        = new SectorId(data[0x15], data[0x16]);
            RelRecordLength = data[0x17];
            FileSize        = Convert.ToUInt16(data[0x1E] + data[0x1F] * 256);
            StringBuilder sb = new StringBuilder(16);

            for (int j = 0x05; j <= 0x14; j++)
            {
                sb.Append((char)data[j]);
            }
            Filename = sb.ToString();
        }
        private void scanFile(List <byte> prev, SectorId id)
        {
            byte[]   data = GetSector(id);
            SectorId next = new SectorId(data[0], data[1]);

            byte[] payload;
            if (next.Track == 0)
            {
                payload = new byte[next.Sector - 1];
                Array.Copy(data, 2, payload, 0, next.Sector - 1);
                prev.AddRange(payload);
            }
            else
            {
                payload = new byte[sectorSize - 2];
                Array.Copy(data, 2, payload, 0, sectorSize - 2);
                prev.AddRange(payload);
                scanFile(prev, next);
            }
        }
Exemple #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="first">first track/sector</param>
 public Directory(SectorId first) : this()
 {
     First = first;
 }
 /// <summary>
 /// Puts raw data in a sector
 /// </summary>
 /// <param name="id"></param>
 /// <param name="data">>raw sector content</param>
 public void PutSector(SectorId id, byte[] data)
 {
     PutSector(id.Track, id.Sector, data);
 }
 /// <summary>
 /// Gets sector raw data
 /// </summary>
 /// <param name="id"></param>
 /// <returns>raw sector content</returns>
 public byte[] GetSector(SectorId id)
 {
     return(GetSector(id.Track, id.Sector));
 }