/// <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) };
private void btnAdvanced_Click(object sender, EventArgs e) { using dlgNewImageAdvanced dlgAdvanced = new dlgNewImageAdvanced(); dlgAdvanced.ShowDialog(); FloppyGeometry newGeometry = new FloppyGeometry((byte)(dlgAdvanced.lstFloppySides.SelectedIndex + 1), (byte)dlgAdvanced.txtFloppyTracks.Value, (byte)dlgAdvanced.txtFloppySPT.Value, (byte)(Math.Log((double)dlgAdvanced.txtFloppyBPS.Value, 2) - 7), (byte)dlgAdvanced.txtFloppyMediaDesc.Value, (byte)dlgAdvanced.txtFloppySPC.Value, (byte)dlgAdvanced.txtFloppyNumFATs.Value, (byte)dlgAdvanced.txtFloppySPF.Value, (ushort)dlgAdvanced.txtFloppyRootDir.Value, (byte)dlgAdvanced.txtFloppyReservedSect.Value); if (selectedItem != FloppyGeometry.FriendlyName.Custom && !newGeometry.Equals(Geometry)) { lstFloppyGeometries.SelectedValue = FloppyGeometry.FriendlyName.Custom; Geometry = newGeometry; } SerialNumber = dlgAdvanced.txtFloppySerial.Text; FileSystemType = dlgAdvanced.txtFloppyFSType.Text; OEMID = dlgAdvanced.txtFloppyOEMID.Text; }
//TODO: Perform some validation of parameters before leaving in case the user tries to create an impossible image private void btnOK_Click(object sender, EventArgs e) { if (!cbxFloppyBPB.Checked) { DialogResult noBpb = MessageBox.Show("You chose not to write a DOS BIOS parameter block (BPB) to the boot sector of the image." + " Many programs and operating systems may not recognize the disk because of this." + "\n\nAre you sure you want to create an image without the BPB?", "No BPB", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (noBpb == DialogResult.No) { return; } } //If the "Custom..." option is selected, create a new FloppyGeometry with the custom parameters //We don't need some of the parameters yet for raw images, so let's just ignore them for now if (selectedItem == FloppyGeometry.FriendlyName.Custom) { Geometry = new FloppyGeometry(0, (byte)(lstFloppySides.SelectedIndex + 1), 0, 0, 0, (byte)txtFloppyTracks.Value, (byte)txtFloppySPT.Value, (byte)(Math.Log((double)txtFloppyBPS.Value, 2) - 7), (byte)txtFloppyMediaDesc.Value, (byte)txtFloppySPC.Value, (byte)txtFloppyNumFATs.Value, (byte)txtFloppySPF.Value, (ushort)txtFloppyRootDir.Value, (byte)txtFloppyReservedSect.Value); } }