示例#1
0
        private void Write(PD765FormattedTrack track, WriteContext context)
        {
            xml.WriteAttributeString("sectorSize", track.SectorSize.ToString());
            xml.WriteAttributeString("sectors", track.SectorCount.ToString());

            if (track.DataRate != 0)
            {
                xml.WriteAttributeString("dataRate", track.DataRate.ToString());
            }

            if (track.RecordingMode != 0)
            {
                xml.WriteAttributeString("recordingMode", track.RecordingMode.ToString());
            }
        }
示例#2
0
        private static Track ReadTrack(Stream rs, DiskImage image, uint trackSize)
        {
            if (rs.Position == rs.Length)
            {
                return(new UnformattedTrack());
            }

            var sectorData = rs.Position + 0x100;

            var trackSig = rs.ReadText(trackSignature.Length);

            if (!trackSig.Equals(trackSignature))
            {
                throw new InvalidDataException(String.Format("Missing track info at offset {0}", rs.Position));
            }

            rs.Ignore(3);

            var track = new PD765FormattedTrack();

            track.Number = (uint)rs.ReadByte();
            track.Side   = (byte)rs.ReadByte();
            track.Size   = trackSize;

            track.DataRate      = (byte)rs.ReadByte();
            track.RecordingMode = (byte)rs.ReadByte();
            track.SectorSize    = CalculateSectorSize(image, rs.ReadByte());
            track.SectorCount   = (byte)rs.ReadByte();

            track.Gap    = (byte)rs.ReadByte();
            track.Filler = (byte)rs.ReadByte();

            for (var i = 0; i < track.SectorCount; i++)
            {
                track.Sectors.Add(ReadSector(rs, image));
            }

            rs.Seek(sectorData, SeekOrigin.Begin);

            foreach (var sector in track.Sectors)
            {
                sector.Data = rs.ReadBlock(sector.Size);
            }

            return(track);
        }