Example #1
0
        private void lstFloppyGeometries_SelectedIndexChanged(object sender, EventArgs e)
        {
            _ = Enum.TryParse(lstFloppyGeometries.SelectedValue.ToString(), out selectedItem);

            if (selectedItem != FloppyGeometry.FriendlyName.Custom)
            {
                Geometry = FloppyGeometry.KnownGeometries[selectedItem];
            }

            //Acorn 800k format does not have a boot sector at all
            if (selectedItem == FloppyGeometry.FriendlyName.Acorn800k)
            {
                cbxFloppyBPB.Checked = false;
                cbxFloppyBPB.Enabled = false;
                lstFloppyBPB.Enabled = false;
                BPBVersion           = BiosParameterBlockVersion.Dos20;
            }
            else
            {
                cbxFloppyBPB.Checked = true;
                cbxFloppyBPB.Enabled = true;
                lstFloppyBPB.Enabled = true;
            }

            if (selectedItem == FloppyGeometry.FriendlyName.DMF1024 || selectedItem == FloppyGeometry.FriendlyName.DMF2048)
            {
                OEMID = "MSDMF3.2";
            }
            else
            {
                OEMID = "MSDOS5.0";
            }
        }
Example #2
0
        private void dlgNewImage_Load(object sender, EventArgs e)
        {
            cbxFloppyBPB.Checked       = true;
            pnlFloppy.Visible          = true;
            pnlHardDisk.Visible        = false;
            WriteBPB                   = true;
            lstFloppyBPB.SelectedIndex = 2;
            BPBVersion                 = BiosParameterBlockVersion.Dos40;

            lstFloppyGeometries.DisplayMember = "Name";
            lstFloppyGeometries.ValueMember   = "Value";
            lstFloppyGeometries.DataSource    = Enum.GetValues(typeof(FloppyGeometry.FriendlyName))
                                                .Cast <Enum>()
                                                .Select(value => new
            {
                (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DisplayAttribute)) as
                 DisplayAttribute).Name,
                value
            })
                                                .OrderBy(item => item.value)
                                                .ToList();

            lstFloppyGeometries.SelectedValue = FloppyGeometry.FriendlyName.HighDensity1440k;
            SerialNumber   = GenerateVolumeID().ToString("X8");
            OEMID          = "MSDOS5.0";
            FileSystemType = "FAT12";
        }
Example #3
0
        //TODO: Should the capacities list be loaded from the KnownGeometries list or something like that?
        private void dlgNewImage_Load(object sender, EventArgs e)
        {
            //Default values are for a 1440 KiB disk with DOS 4.0+ BPB
            cbxFloppyBPB.Checked       = true;
            WriteBPB                   = true;
            lstFloppyBPB.SelectedIndex = 3;
            BPBVersion                 = BiosParameterBlockVersion.Dos40;

            //Get the list of presets from KnownGeometries and display the fancy Name attribute of the enum
            lstFloppyCapacity.DisplayMember = "Name";
            lstFloppyCapacity.ValueMember   = "Value";
            lstFloppyCapacity.DataSource    = Enum.GetValues(typeof(FloppyGeometry.FriendlyName))
                                              .Cast <Enum>()
                                              .Select(value => new
            {
                (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DisplayAttribute)) as
                 DisplayAttribute).Name,
                value
            })
                                              .OrderBy(item => item.value)
                                              .ToList();

            lstFloppyCapacity.SelectedValue = FloppyGeometry.FriendlyName.HighDensity1440k;
            txtFloppySerial.Text            = GenerateVolumeID().ToString("X8");
            SerialNumber   = txtFloppySerial.Text;
            OEMID          = txtFloppyOEMID.Text;
            VolumeLabel    = txtFloppyLabel.Text;
            FileSystemType = txtFloppyFSType.Text;
        }
Example #4
0
        private void lstFloppyCapacity_SelectedIndexChanged(object sender, EventArgs e)
        {
            _ = Enum.TryParse(lstFloppyCapacity.SelectedValue.ToString(), out selectedItem);

            if (selectedItem != FloppyGeometry.FriendlyName.Custom)
            {
                Geometry = FloppyGeometry.KnownGeometries[selectedItem];
                lstFloppySides.SelectedIndex = Geometry.Sides - 1;
                txtFloppyTracks.Value        = Geometry.Tracks;
                txtFloppySPT.Value           = Geometry.SPT;
                txtFloppyBPS.Value           = 128 << Geometry.BPS;
                txtFloppyMediaDesc.Value     = Geometry.MediaDescriptor;
                txtFloppySPC.Value           = Geometry.SPC;
                txtFloppyNumFATs.Value       = Geometry.NoOfFATs;
                txtFloppySPF.Value           = Geometry.SPF;
                txtFloppyRootDir.Value       = Geometry.RootDirectoryEntries;
                txtFloppyReservedSect.Value  = Geometry.ReservedSectors;
                txtFloppyTotalSect.Value     = Geometry.Tracks * Geometry.SPT * Geometry.Sides;
            }

            if (selectedItem == FloppyGeometry.FriendlyName.Acorn800k)
            {
                cbxFloppyBPB.Checked    = false;
                cbxFloppyBPB.Enabled    = false;
                lstFloppyBPB.Enabled    = false;
                txtFloppyFSType.Text    = string.Empty;
                txtFloppyFSType.Enabled = false;
                txtFloppyOEMID.Text     = string.Empty;
                txtFloppyOEMID.Enabled  = false;
                txtFloppySerial.Text    = string.Empty;
                txtFloppySerial.Enabled = false;
                BPBVersion = BiosParameterBlockVersion.Dos20;
            }
            else
            {
                cbxFloppyBPB.Checked    = true;
                cbxFloppyBPB.Enabled    = true;
                lstFloppyBPB.Enabled    = true;
                txtFloppyFSType.Text    = "FAT12";
                txtFloppyFSType.Enabled = true;
                if (selectedItem == FloppyGeometry.FriendlyName.DMF1024 || selectedItem == FloppyGeometry.FriendlyName.DMF2048)
                {
                    txtFloppyOEMID.Text = "MSDMF3.2";
                }
                else
                {
                    txtFloppyOEMID.Text = "MSDOS5.0";
                }
                txtFloppyOEMID.Enabled  = true;
                txtFloppySerial.Text    = GenerateVolumeID().ToString("X8");
                txtFloppySerial.Enabled = true;
            }
        }
Example #5
0
 private void lstFloppyBPB_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstFloppyBPB.SelectedIndex == 2) //DOS 4.0+ BPB
     {
         BPBVersion = BiosParameterBlockVersion.Dos40;
     }
     else if (lstFloppyBPB.SelectedIndex == 1) //DOS 3.4 BPB
     {
         BPBVersion = BiosParameterBlockVersion.Dos34;
     }
     else if (lstFloppyBPB.SelectedIndex == 0) //DOS 2.0-3.31 BPB
     {
         BPBVersion = BiosParameterBlockVersion.Dos20;
     }
 }
Example #6
0
 /// <summary>
 /// Create a BIOS Parameter Block from a floppy geometry object
 /// </summary>
 /// <param name="geometry">The floppy geometry</param>
 /// <param name="version">The version of the BPB to create</param>
 /// <param name="oemId">The OEM ID to include in the boot sector</param>
 /// <returns>A BIOS Parameter Block suitable for the floppy geometry provided</returns>
 public static BiosParameterBlock FromGeometry(FloppyGeometry geometry, BiosParameterBlockVersion version, string oemId)
 => new BiosParameterBlock
 {
     OemId = Helper.UseAsLabel(oemId),
     BytesPerLogicalSector    = (ushort)(128 << geometry.BPS),
     HiddenSectors            = 0,
     LogicalSectorsPerCluster = geometry.SPC,
     LogicalSectorsPerFAT     = geometry.SPF,
     MediaDescriptor          = geometry.MediaDescriptor,
     NumberOfFATs             = geometry.NoOfFATs,
     NumberOfHeads            = geometry.Sides,
     PhysicalSectorsPerTrack  = geometry.SPT,
     ReservedLogicalSectors   = geometry.ReservedSectors,
     RootDirectoryEntries     = geometry.RootDirectoryEntries,
     TotalLogicalSectors      = (uint)(geometry.Tracks * geometry.SPT * geometry.Sides)
 };
Example #7
0
 private void lstFloppyBPB_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstFloppyBPB.SelectedIndex == 3) //DOS 4.0+ BPB
     {
         txtFloppyFSType.Enabled = true;
         txtFloppySerial.Enabled = true;
         BPBVersion = BiosParameterBlockVersion.Dos40;
     }
     else if (lstFloppyBPB.SelectedIndex == 2) //DOS 3.4 BPB
     {
         txtFloppyFSType.Enabled = false;
         txtFloppySerial.Enabled = true;
         BPBVersion = BiosParameterBlockVersion.Dos34;
     }
     else if (lstFloppyBPB.SelectedIndex <= 1) //DOS 2.0-3.31 BPB
     {
         txtFloppyFSType.Enabled = false;
         txtFloppySerial.Enabled = false;
         BPBVersion = BiosParameterBlockVersion.Dos20;
     }
 }