Example #1
0
        /// <summary>
        /// Saves BAM data to disk image
        /// </summary>
        /// <param name="disk">Disk image to write</param>
        public override void Save(BaseDisk disk)
        {
            byte[] data = BaseDisk.EmptySector();
            data[0]    = Directory.Track;
            data[1]    = Directory.Sector;
            data[2]    = (byte)DOSversion;
            data[0x14] = 0xA0;
            data[0x15] = 0xA0;
            data[0x16] = (byte)DiskId[0];
            data[0x17] = (byte)DiskId[1];
            data[0x18] = 0xA0;
            data[0x19] = (byte)DOStype[0];
            data[0x1A] = (byte)DOStype[1];
            data[0x1B] = 0xA0;
            data[0x1C] = 0xA0;
            Array.Copy(DiskLabel(), 0, data, 4, 16);
            disk.PutSector(Directory.Track, 0, data);

            data    = BAMsectorHeader();
            data[0] = Directory.Track;
            data[1] = 2;
            Array.Copy(RawMap(41, 80), 0, data, 16, 40 * EntrySize);
            disk.PutSector(Directory.Track, 1, data);

            data    = BAMsectorHeader();
            data[0] = 0;
            data[1] = 0xFF;
            Array.Copy(RawMap(1, 40), 0, data, 16, 40 * EntrySize);
            disk.PutSector(Directory.Track, 2, data);
        }
 /// <summary>
 /// Single bam sector
 /// </summary>
 /// <param name="firstTrack"></param>
 /// <param name="lastTrack"></param>
 /// <returns></returns>
 protected byte[] BAMsector(byte firstTrack, byte lastTrack)
 {
     byte[] data = BaseDisk.EmptySector();
     data[2] = (byte)DOSversion;
     data[4] = firstTrack;
     data[5] = (byte)(lastTrack + 1);
     Array.Copy(RawMap(firstTrack, lastTrack), 0, data, 6, (lastTrack - firstTrack + 1) * EntrySize);
     return(data);
 }
Example #3
0
        private byte[] BAMsectorHeader()
        {
            byte[] data = BaseDisk.EmptySector();
            data[2] = (byte)DOSversion;
            data[3] = (byte)~DOSversion;
            data[4] = (byte)DiskId[0];
            data[5] = (byte)DiskId[1];
            data[6] = 0; // No checks
            data[7] = 0; // No autorun

            return(data);
        }
Example #4
0
        /// <summary>
        /// Directory as a list of raw sector data
        /// </summary>
        /// <returns></returns>
        public List <byte[]> ToRaw()
        {
            List <byte[]> ret     = new List <byte[]>();
            int           sectors = (dir.Count + EntriesPerSector - 1) / EntriesPerSector;

            // see https://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division
            for (int j = 0; j < sectors; j++)
            {
                byte[] s = BaseDisk.EmptySector();
                for (int e = 0; e < EntriesPerSector && j * EntriesPerSector + e < dir.Count; ++e)
                {
                    Array.Copy(dir[j * EntriesPerSector + e].ToRaw(), 0,
                               s, e * DirectoryEntry.EntrySize, DirectoryEntry.EntrySize);
                }
            }
            return(ret);
        }
Example #5
0
        /// <summary>
        /// Saves BAM data to disk image
        /// </summary>
        /// <param name="disk">Disk image to write</param>
        public override void Save(BaseDisk disk)
        {
            byte[] data = BaseHeader();
            Array.Copy(RawMap(), 0, data, 4, 35 * EntrySize);
            for (int j = 0; j < 35; ++j)
            {
                data[0xDD + j] = SectorsMap[35 + j].FreeSectors;
            }
            disk.PutSector(18, 0, data);

            data = BaseDisk.EmptySector();
            for (int j = 0; j < 35; ++j)
            {
                Array.Copy(SectorsMap[35 + j].flags, 0, data, j * 3, 3);
            }
            disk.PutSector(53, 0, data);
        }
 /// <summary>
 /// Writes disk header
 /// </summary>
 /// <param name="disk"></param>
 protected void SaveHeader(BaseDisk disk)
 {
     byte[] data = BaseDisk.EmptySector();
     data[0]    = BAMtrack;
     data[1]    = 0;
     data[2]    = (byte)DOSversion;
     data[0x17] = 0xA0;
     data[0x18] = (byte)DiskId[0];
     data[0x19] = (byte)DiskId[1];
     data[0x1A] = 0xA0;
     data[0x1B] = (byte)DOStype[0];
     data[0x1C] = (byte)DOStype[1];
     data[0x1D] = 0xA0;
     data[0x1E] = 0xA0;
     data[0x1F] = 0xA0;
     data[0x20] = 0xA0;
     Array.Copy(DiskLabel(), 0, data, 6, 16);
     disk.PutSector(Directory.Track, 0, data);
 }
 /// <summary>
 /// Disk Header
 /// </summary>
 /// <returns></returns>
 protected virtual byte[] BaseHeader()
 {
     byte[] data = BaseDisk.EmptySector();
     data[0]    = Directory.Track;
     data[1]    = Directory.Sector;
     data[2]    = (byte)DOSversion;
     data[3]    = (byte)(DoubleSide ? 0x80 : 0);
     data[0xA0] = 0xA0;
     data[0xA1] = 0xA0;
     data[0xA2] = (byte)DiskId[0];
     data[0xA3] = (byte)DiskId[1];
     data[0xA4] = 0xA0;
     data[0xA5] = (byte)DOStype[0];
     data[0xA6] = (byte)DOStype[1];
     data[0xA7] = 0xA0;
     data[0xA8] = 0xA0;
     data[0xA9] = 0xA0;
     data[0xAA] = 0xA0;
     Array.Copy(DiskLabel(), 0, data, 0x90, 16);
     return(data);
 }