Beispiel #1
0
        public async static Task <DiskInfo> GetDiskInf(int drive)
        {
            var info = new DiskInfo();

            info.DriveNo = drive;
            var ten = string.Join(",", Enumerable.Range(0, 11).Select(c => $"DSKF({drive},{c})").ToArray());

            if (await Util.SendCommandAsyncAndErrorHandle($"print \"%%%\";:WRITE DSKF({drive})," + ten))
            {
                return(null);
            }
            var ar = Util.MyMainWindow.StatementResultString.Split(',').Select(c =>
            {
                int.TryParse(c.Trim(), out var r);
                return(r);
            }).ToArray();

            info.FreeClustors     = ar[0];
            info.MaxTrackNo       = ar[1];
            info.SectorsInTrack   = ar[2];
            info.Surfaces         = ar[3];
            info.ClustorsInTrack  = ar[4];
            info.ClustorsInVolume = ar[5];
            info.DirectoryTrack   = ar[6];
            info.SectorsInCluster = ar[7];
            info.FATStartSector   = ar[8];
            info.FATEndSector     = ar[9];
            info.NumberOfFATs     = ar[10];
            info.SectorInDiskAttr = ar[11];
            switch (GetDiskFormatOverride())
            {
            case DiskFormats.SS35TR:
                info.Surfaces   = 0;
                info.MaxTrackNo = 35 - 1;
                break;

            case DiskFormats.SS40TR:
                info.Surfaces   = 0;
                info.MaxTrackNo = 40 - 1;
                break;
            }
            return(info);
        }
Beispiel #2
0
        private async Task update()
        {
            using (var lck = new LockForm())
            {
                ListBoxDiskInfos.Items.Clear();
                var driveNo = Util.GetSelectedDrive();
                info = await Util.GetDiskInf(driveNo);

                if (info == null)
                {
                    return;
                }
                foreach (var item in info.GetType().GetFields())
                {
                    var v = item.GetValue(info);
                    var s = item.Name + "=" + v.ToString();
                    ListBoxDiskInfos.Items.Add(s);
                }
            }
        }
Beispiel #3
0
        private async Task readCommon(DiskInfo diskinfo)
        {
            int.TryParse(TextBoxTrack.Text, out int track);
            int.TryParse(TextBoxSector.Text, out int sector);

            var valid = diskinfo.VaridateParameters(Util.GetSelectedDrive(), ComboBoxSurface.SelectedIndex, track, sector, (message) =>
            {
                Util.ErrorPopup(message);
            });

            if (!valid)
            {
                return;
            }

            var bytes = await Util.SectorRead(Util.GetSelectedDrive(), ComboBoxSurface.SelectedIndex, track, sector);

            if (bytes == null)
            {
                return;
            }

            int x = 0, y = 0;

            foreach (var item in bytes)
            {
                if (y > 15)
                {
                    MessageBox.Show("Sector Data too large: " + bytes.Count().ToString());
                    break;
                }
                textBlocks[x, y].Text = item.ToString("X2");
                x++;
                if (x > 15)
                {
                    x = 0;
                    y++;
                }
            }
            updateAscii();
        }