Skip to content

Add DOSBox Windows Support #4294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b4e03a3
Decoupling HDD from SRAM
SergioMartin86 Apr 20, 2025
961e958
Modifying memory area
SergioMartin86 Apr 20, 2025
c199b68
Adding win-specific config
SergioMartin86 Apr 20, 2025
9651109
Mods
SergioMartin86 Apr 20, 2025
2624f4f
Adding option to save hdd contents
SergioMartin86 Apr 20, 2025
787e2e1
Fixing period
SergioMartin86 Apr 20, 2025
1408e7c
Passing hdd contents in chunks to prevent excess mem usage
SergioMartin86 Apr 21, 2025
004a6b3
Reverting changes to gui
SergioMartin86 Apr 21, 2025
86eeb39
Revert "Reverting changes to gui"
SergioMartin86 Apr 21, 2025
a3d7d49
Updating configurations
SergioMartin86 Apr 21, 2025
f17f376
Created custom submenu for DOS
SergioMartin86 Apr 22, 2025
7c0d03e
Renaming function nam names
SergioMartin86 Apr 22, 2025
564081e
Refactoring function names
SergioMartin86 Apr 22, 2025
fb45d30
Merge branch 'dosbox-win-pr' of github.com:SergioMartin86/BizHawk int…
SergioMartin86 Apr 22, 2025
3fbce20
Adding failure check for memfile alloc
SergioMartin86 Apr 22, 2025
8966dca
Adding logging on hdd size
SergioMartin86 Apr 22, 2025
33c5e3a
Merge branch 'dosbox-win-pr' of github.com:SergioMartin86/BizHawk int…
SergioMartin86 Apr 22, 2025
857925d
Re-adding configuration menu
SergioMartin86 Apr 22, 2025
6fb8e4f
Fixes
SergioMartin86 Apr 24, 2025
ec75d2d
Demoting cd recognition of yet unsupported cores
SergioMartin86 Apr 24, 2025
7a44905
Fixing timing
SergioMartin86 Apr 25, 2025
5ad6501
Reducing diff
SergioMartin86 Apr 25, 2025
5079b8b
Merge with master
SergioMartin86 Apr 25, 2025
6593396
Fixing style
SergioMartin86 Apr 25, 2025
6a4d7b9
Reducing diff
SergioMartin86 Apr 25, 2025
f9ac0b4
Reducing diff
SergioMartin86 Apr 25, 2025
1786418
Reducing diff
SergioMartin86 Apr 25, 2025
1afc536
Reducing diff
SergioMartin86 Apr 25, 2025
fa33c85
Reverting change in cast in ticks target
SergioMartin86 Apr 25, 2025
25a86a4
Reverting change in cast in ticks target
SergioMartin86 Apr 25, 2025
43696a0
Adjusting hdd precision
SergioMartin86 Apr 25, 2025
0d1521d
Removing compatibility flag (not needed)
SergioMartin86 Apr 25, 2025
6e7b030
Merge branch 'dosbox-win-pr' of github.com:SergioMartin86/BizHawk int…
SergioMartin86 Apr 25, 2025
8e6ceba
Fix line endings
YoshiRulz Apr 26, 2025
e0873fc
Remove reference to Speccy
YoshiRulz Apr 26, 2025
ff06bd7
Revert changes to `Bk2MnemonicLookup`
YoshiRulz Apr 26, 2025
fb81a51
Move DOS submenu initialisation to `MainForm_Load`
YoshiRulz Apr 26, 2025
8ece829
Minor code style fixes
YoshiRulz Apr 26, 2025
efb9c2c
Update src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.ISettable.cs
SergioMartin86 Apr 29, 2025
ce4ae38
Strip line-end whitespace
YoshiRulz Apr 29, 2025
8996aa2
Update src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.ISettable.cs
SergioMartin86 Apr 29, 2025
26a6dec
Fixing byte notation to B
SergioMartin86 Apr 29, 2025
8fd3810
Fixing byte notation to B
SergioMartin86 Apr 29, 2025
9edddc3
Update src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.ISettable.cs
vadosnaprimer Apr 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Assets/dll/dosbox.wbx.zst
Binary file not shown.
33 changes: 32 additions & 1 deletion src/BizHawk.Client.EmuHawk/MainForm.VSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,30 @@ private void GblSettingsMenuItem_Click(object sender, EventArgs e)
_ => DialogResult.None,
};

private DialogResult OpenDOSBoxSettingsDialog()
=> OpenGenericCoreConfigFor<DOSBox>(CoreNames.DOSBox + " Settings");

private void DOSSExportHddMenuItem_Click(object sender, EventArgs e)
{
if (Emulator is not DOSBox dosbox) return;
try
{
var result = this.ShowFileSaveDialog(
discardCWDChange: true,
fileExt: "bin",
filter: DOSBoxHDDImageFilterSet,
initDir: Config.PathEntries.ToolsAbsolutePath());
if (result is not null)
{
File.WriteAllBytes(result, dosbox.GetHDDContents());
}
}
catch (Exception)
{
// ignored
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ToggleGambatteSyncSetting(
string name,
Expand Down Expand Up @@ -956,7 +980,10 @@ private void Ti83PaletteMenuItem_Click(object sender, EventArgs e)
if (result.IsOk()) AddOnScreenMessage("Palette settings saved");
}


private static readonly FilesystemFilterSet DOSBoxHDDImageFilterSet = new(new FilesystemFilter("DOSBox HDD Images", new[] { "bin" }))
{
AppendAllFilesEntry = false,
};

private static readonly FilesystemFilterSet ZXStateFilesFSFilterSet = new(new FilesystemFilter("ZX-State files", new[] { "szx" }))
{
Expand Down Expand Up @@ -1464,6 +1491,7 @@ private void HandlePlatformMenus()
TI83SubMenu.Visible = false;
NESSubMenu.Visible = false;
GBSubMenu.Visible = false;
DOSSubMenu.Visible = false;
A7800SubMenu.Visible = false;
SNESSubMenu.Visible = false;
PSXSubMenu.Visible = false;
Expand Down Expand Up @@ -1498,6 +1526,9 @@ private void HandlePlatformMenus()
case VSystemID.Raw.Coleco:
ColecoSubMenu.Visible = true;
break;
case VSystemID.Raw.DOS when Emulator is DOSBox:
DOSSubMenu.Visible = true;
break;
case VSystemID.Raw.INTV:
IntvSubMenu.Visible = true;
break;
Expand Down
11 changes: 11 additions & 0 deletions src/BizHawk.Client.EmuHawk/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public partial class MainForm : FormBase, IDialogParent, IMainFormForApi, IMainF

private const int WINDOW_SCALE_MAX = 10;

private readonly ToolStripMenuItemEx DOSSubMenu = new() { Text = "&DOS" };

private readonly ToolStripMenuItemEx NullHawkVSysSubmenu = new() { Enabled = false, Text = "—" };

private readonly StatusLabelEx StatusBarMuteIndicator = new();
Expand Down Expand Up @@ -192,6 +194,15 @@ private void MainForm_Load(object sender, EventArgs e)

_ = MainformMenu.Items.InsertAfter(ToolsSubMenu, insert: NullHawkVSysSubmenu);

ToolStripMenuItemEx DOSSettingsToolStripMenuItem = new() { Text = "Settings..." };
DOSSettingsToolStripMenuItem.Click += (_, _) => _ = OpenDOSBoxSettingsDialog();
DOSSubMenu.DropDownItems.Add(DOSSettingsToolStripMenuItem);
ToolStripMenuItemEx DOSExportHDDImageToolStripMenuItem = new() { Text = "Export Hard Disk Drive..." };
DOSExportHDDImageToolStripMenuItem.Click += DOSSExportHddMenuItem_Click;
DOSSubMenu.DropDownItems.Add(DOSExportHDDImageToolStripMenuItem);
DOSSubMenu.DropDownOpened += (_, _) => DOSExportHDDImageToolStripMenuItem.Enabled = Emulator is DOSBox dosbox && dosbox.HasValidHDD();
_ = MainformMenu.Items.InsertAfter(NullHawkVSysSubmenu, insert: DOSSubMenu);

// Hide Status bar icons and general StatusBar prep
MainStatusBar.Padding = new Padding(MainStatusBar.Padding.Left, MainStatusBar.Padding.Top, MainStatusBar.Padding.Left, MainStatusBar.Padding.Bottom); // Workaround to remove extra padding on right
PlayRecordStatusButton.Visible = false;
Expand Down
123 changes: 82 additions & 41 deletions src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.ISettable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,88 @@ namespace BizHawk.Emulation.Cores.Computers.DOS
{
public partial class DOSBox : ISettable<object, DOSBox.SyncSettings>
{
public const int MAX_MEMORY_SIZE_MB = 256;

public enum ConfigurationPreset
{
[Display(Name = "[1981] IBM XT 5150 (4.77Mhz, 256kb RAM, Monochrome, PC Speaker)")]
[Display(Name = "[1981] IBM XT 5150 (4.77Mhz, 8086, 256KB RAM, Monochrome, PC Speaker)")]
_1981_IBM_5150,
[Display(Name = "[1983] IBM XT 5160 (4.77Mhz, 640kb RAM, CGA, PC Speaker)")]
[Display(Name = "[1983] IBM XT 5160 (4.77Mhz, 8086, 640KB RAM, CGA, PC Speaker)")]
_1983_IBM_5160,
[Display(Name = "[1986] IBM XT 286 5162-286 (6Mhz, 640kb RAM, EGA, PC Speaker)")]
[Display(Name = "[1986] IBM XT 286 5162-286 (6Mhz, 8086, 640KB RAM, EGA, PC Speaker)")]
_1986_IBM_5162,
[Display(Name = "[1987] IBM PS/2 25 (8Mhz, 640kb RAM, MCGA, Game Blaster)")]
[Display(Name = "[1987] IBM PS/2 25 (8Mhz, 186, 640KB RAM, MCGA, Game Blaster)")]
_1987_IBM_PS2_25,
[Display(Name = "[1990] IBM PS/2 25 286 (10Mhz, 4Mb RAM, VGA, Sound Blaster 1)")]
[Display(Name = "[1990] IBM PS/2 25 286 (10Mhz, 286, 4MB RAM, VGA, Sound Blaster 1)")]
_1990_IBM_PS2_25_286,
[Display(Name = "[1991] IBM PS/2 25 386 (25Mhz, 6Mb RAM, VGA, Sound Blaster 2)")]
[Display(Name = "[1991] IBM PS/2 25 386 (25Mhz, 386, 6MB RAM, VGA, Sound Blaster 2)")]
_1991_IBM_PS2_25_386,
[Display(Name = "[1993] IBM PS/2 53 SLC2 486 (50Mhz, 64Mb RAM, SVGA, Sound Blaster Pro 2)")]
[Display(Name = "[1993] IBM PS/2 53 SLC2 486 (50Mhz, 486, 64MB RAM, SVGA, Sound Blaster Pro 2)")]
_1993_IBM_PS2_53_SLC2_486,
[Display(Name = "[1994] IBM PS/2 76i SLC2 486 (100Mhz, 64Mb RAM, SVGA, Sound Blaster 16)")]
[Display(Name = "[1994] IBM PS/2 76i SLC2 486 (100Mhz, 486, 64MB RAM, SVGA, Sound Blaster 16)")]
_1994_IBM_PS2_76i_SLC2_486,
[Display(Name = "[1997] IBM Aptiva 2140 (233Mhz, 96Mb RAM, SVGA + 3D Support, Sound Blaster 16)")]
[Display(Name = "[1997] IBM Aptiva 2140 (233Mhz, Pentium MMX, 96MB RAM, SVGA + 3D Support, Sound Blaster 16)")]
_1997_IBM_APTIVA_2140,
[Display(Name = "[1999] IBM Thinkpad 240 (300Mhz, 128Mb, SVGA + 3D Support , Sound Blaster 16) ")]
_1999_IBM_THINKPAD_240,
[Display(Name = "[1999] IBM Thinkpad 240 (300Mhz, Pentium III, 128MB, SVGA + 3D Support , Sound Blaster 16) ")]
_1999_IBM_THINKPAD_240
}

/// <remarks>values are the actual size in bytes for each hdd selection</remarks>
public enum WriteableHardDiskOptions : ulong
public enum HardDiskOptions : uint
{
None = 0,
[Display(Name = "21MB (FAT16)")]
FAT16_21MB = 21411840,
[Display(Name = "41MB (FAT16)")]
FAT16_41MB = 42823680,
[Display(Name = "241MB (FAT16)")]
FAT16_241MB = 252370944,
[Display(Name = "504MB (FAT16)")]
FAT16_504MB = 527966208,
[Display(Name = "2014MB (FAT16)")]
FAT16_2014MB = 2111864832,
}

public enum CPUType
{
None = 0UL,
[Display(Name = "21Mb (FAT16)")]
FAT16_21Mb = 21411840UL,
[Display(Name = "41Mb (FAT16)")]
FAT16_41Mb = 42823680UL,
[Display(Name = "241Mb (FAT16)")]
FAT16_241Mb = 252370944UL,
[Display(Name = "504Mb (FAT16)")]
FAT16_504Mb = 527966208UL,
[Display(Name = "2014Mb (FAT16)")]
FAT16_2014Mb = 2111864832UL,
[Display(Name = "4091Mb (FAT32)")]
FAT32_4091Mb = 4289725440UL,
Auto,
[Display(Name = "Intel 8086")]
C8086,
[Display(Name = "Intel 8086 + Prefetch")]
C8086_prefetch,
[Display(Name = "Intel 80186")]
C80186,
[Display(Name = "Intel 80186 + Prefetch")]
C80186_prefetch,
[Display(Name = "Intel 286")]
C286,
[Display(Name = "Intel 286 + Prefetch")]
C286_prefetch,
[Display(Name = "Intel 386")]
C386,
[Display(Name = "Intel 386 + Prefetch")]
C386_prefetch,
[Display(Name = "Intel 486 (Old)")]
C486old,
[Display(Name = "Intel 486 (Old) + Prefetch")]
C486old_prefetch,
[Display(Name = "Intel 486")]
C486,
[Display(Name = "Intel 486 + Prefetch")]
C486_prefetch,
[Display(Name = "Intel Pentium")]
pentium,
[Display(Name = "Intel Pentium MMX")]
pentium_mmx,
[Display(Name = "Intel Pentium Pro (Slow)")]
ppro_slow,
[Display(Name = "Intel Pentium II")]
pentium_ii,
[Display(Name = "Intel Pentium III")]
pentium_iii,
}

public enum MachineType
public enum VideoCardType
{
Auto,
[Display(Name = "MDA")]
Expand Down Expand Up @@ -228,16 +267,11 @@ public class SyncSettings
[DefaultValue(3.0)]
public float MouseSensitivity { get; set; }

[DisplayName("Mount Writeable Hard Disk Drive")]
[Description("Determines whether to mount an empty writable formatted hard disk in drive C:. This hard disk will be fully located in memory so make sure you have enough RAM available. Its contents can be saved and loaded as SaveRAM (can be slow).")]
[DefaultValue(WriteableHardDiskOptions.FAT16_241Mb)]
[DisplayName("Mount Formatted Hard Disk Drive")]
[Description("Determines whether to mount an empty writable formatted hard disk in drive C:. The hard disk will be fully located in memory so make sure you have enough RAM available. Its contents can be exported to the host filesystem.\n\nThis value will be ignored if a hard disk image (.bin) is provided.")]
[DefaultValue(HardDiskOptions.None)]
[TypeConverter(typeof(DescribableEnumConverter))]
public WriteableHardDiskOptions WriteableHardDisk { get; set; }

[DisplayName("Preserve Hard Disk Contents")]
[Description("Determines whether to store the contents of the writeable hard disk as SaveRAM to be reloaded on the next start. Enabling this option may cause the core to take some seconds to store and load the SRAM upon restart, depending on the size of the hard disk. If it is disabled, previous SaveRAM will not be loaded.")]
[DefaultValue(false)]
public bool PreserveHardDiskContents { get; set; }
public HardDiskOptions FormattedHardDisk { get; set; }

[DisplayName("Force FPS Numerator")]
[Description("Forces a numerator for FPS: how many Bizhawk frames to run per second of emulation. We recommend leaving this value unmodified, to follow the core's own video refresh rate. You can set it higher if you need finer subframe inputs, and; lower, in case your game runs in lower FPS and it feels more natural.")]
Expand All @@ -254,14 +288,21 @@ public class SyncSettings
[DefaultValue(-1)]
public int CPUCycles { get; set; }

[DisplayName("Machine Type")]
[Description("Chooses the machine type (CPU/GPU) to emulate. Auto uses the configuration preset's default.")]
[DisplayName("CPU Type")]
[Description("Chooses the CPU type to emulate. Auto uses the configuration preset's default.")]
[TypeConverter(typeof(DescribableEnumConverter))]
[DefaultValue(CPUType.Auto)]
public CPUType CPUType { get; set; }

[DisplayName("Video Card Type")]
[Description("Chooses the video card to emulate. Auto uses the configuration preset's default.")]
[TypeConverter(typeof(DescribableEnumConverter))]
[DefaultValue(MachineType.Auto)]
public MachineType MachineType { get; set; }
[DefaultValue(VideoCardType.Auto)]
public VideoCardType VideoCardType { get; set; }

[DisplayName("RAM Size (Mb)")]
[Description("The size of the memory capacity (RAM) to emulate. -1 to keep the value for the machine preset")]
[DisplayName("RAM Size (MB)")]
[Description("The size of the memory capacity (RAM) to emulate. -1 to keep the value for the machine preset. Maximum value: 256")]
[Range(-1, 256)]
[DefaultValue(-1)]
public int RAMSize { get; set; }

Expand Down
Loading