An IBM PC Emulator written in C using SDL3
- i8086 CPU
- i8237 DMA
- i8253 PIT
- i8255 PPI
- i8259 PIC
- i8272 FDC (NEC uPD765)
- IBM Fixed Disk Drive (XEBEC)
- MDA ISA Card (IBM Monochrome Display Adapter)
- CGA ISA Card (IBM Color Graphics Adapter)
- FDC ISA Card
- XEBEC ISA Card
The project is built in Visual Studio 2022 or 2026
| Dependencies | Github |
|---|---|
| I8086 | https://github.com/tommojphillips/i8086 |
| TOMI | https://github.com/tommojphillips/TOMI |
| SDL3 3.2.24 | https://github.com/libsdl-org/SDL |
| SDL3_ttf-3.2.2 | https://github.com/libsdl-org/SDL_ttf |
| ImGui 1.92.3 | https://github.com/ocornut/imgui/tree/v1.92.3 |
- Clone the repo and submodules
git clone --recurse-submodules https://github.com/tommojphillips/ibm_pc.git
- cd dir to
ibm_pc
cd ibm_pc
- Fetch SDL3/SDL3_TTF VC Release
scripts\fetch_sdl3.sh
-
Open
lib\UI\vc\UI.sln, build -
Open
vc\ibm_pc.sln, build, run.
Make sure these files are next to ibm_pc.exe or on your PATH:
- SDL3.dll
- SDL3_ttf.dll
- UI.dll (built via
UI.sln)
If building from source, and launching through visual studio, all .dll files are already on your PATH. You only need to copy the .FON files to the same directory as ibm_pc.exe
Font files are required for full functionality. FONTS can be found here: https://int10h.org/oldschool-pc-fonts/download/
| Description | File |
|---|---|
| MDA Font 9x14 | Bm437_IBM_MDA.FON |
| CGA Font 8x8 | Bm437_IBM_CGA.FON |
They have been included in the fonts\ directory of the repo.
ROMS are required for full functionality.
Make sure these files are next to ibm_pc.exe:
- Bm437_IBM_CGA.FON
- Bm437_IBM_MDA.FON
| Switch | Switch (ALT) | Description | Values |
|---|---|---|---|
-config <config_file> |
-c <config_file> |
Set the config file | file path |
-o <offset> |
N/A | Set the memory offset for the next ROM file. | 0x00000 - 0xFFFFF |
<rom_file> |
N/A | Path to a ROM file. It is loaded at the current offset. | file path |
<A-D>: <disk_path> |
N/A | Load a disk image into a drive. | A, B, C, D ; file path |
-disk-write-protect |
-dwp |
Write protect the next loaded disk. | N/A |
-disks <0-4> |
-ds <0-4> |
Number of floppy drives present. 0-4. | 0 - 4 |
-video <video_adapter> |
-v <video_adapter> |
Selects which display adapter to emulate | MDA, CGA |
-ram <ram> |
-r <ram> |
Amount of conventional RAM. | 16KB - 736KB |
-sw1 <sw1> |
N/A | Value of motherboard DIP switch SW1 | 0 - 255 |
-sw2 <sw2> |
N/A | Value of motherboard DIP switch SW2 | 0 - 255 |
-model <model> |
N/A | Motherboard model | 5150_16_64, 5150_64_256, 5160 |
-dbg |
N/A | Enables the debug UI | N/A |
- Numbers can be written in decimal, hexadecimal (0x), or binary (0b) form.
- RAM can be provided in KB or BYTES.
- When a ROM is loaded,
-ois automatically incremented by the files size; You can chain ROM files with a single-o <offset> - If a DIP switch (
sw1,sw2) isnt provided; it is set automatically based on the provided config
ibm_pc.exe -o 0xF6000 cb10_1.bin cb10_2.bin cb10_3.bin cb10_4.bin bios.bin -video CGA -ram 640 -model 5150_64_256 A: msdos4_startup.img
Means:
Load cb10_1.bin (2K file) at 0xF6000
Load cb10_2.bin (2K file) at 0xF8000
Load cb10_3.bin (2K file) at 0xFA000
Load cb10_4.bin (2K file) at 0xFC000
Load bios.bin (8K file) at 0xFE000
Video adapter is a CGA Card
640KB conventional RAM installed
Model 64KB-256KB Motherboard
msdos4_startup.img disk is in drive A:
The emulator supports configuration files written in a custom structured INI-like format called TOMI
| Key | Type | Description | Values |
|---|---|---|---|
model |
ENUM | Motherboard model | 5150_16_64, 5150_64_256, 5160 |
video_adapter |
ENUM | Selects which display adapter to emulate | MDA, CGA, CGA40, CGA80 |
conventional_ram |
INT | Amount of conventional RAM installed | 16K - 736K |
num_floppies |
INT | Number of floppy drives present | 0 - 4 |
sw1 |
INT | Value of motherboard DIP switch SW1 | 0 - 255 |
sw2 |
INT | Value of motherboard DIP switch SW2 | 0 - 255 |
sw1_override |
BOOL | Forces manual SW1 value instead of auto-calculated | true, false |
sw2_override |
BOOL | Forces manual SW2 value instead of auto-calculated | true, false |
disk |
STRUCT | Defines one or more floppy disk drives | See below |
hdd |
STRUCT | Defines one or more Hard disk images | See below |
rom |
STRUCT | Defines one or more ROM images | See below |
texture_scale_mode |
ENUM | Texture sampling mode | Nearest, Linear |
display_scale_mode |
ENUM | Display scaling behavior | Fit, Stretched |
display_view_mode |
ENUM | Display framing mode | Cropped, Full |
correct_aspect_ratio |
BOOL | Enables 4:3 aspect correction | true, false |
emulate_max_scanline |
BOOL | true, false |
|
allow_display_disable |
BOOL | Allow software to disable the display | true, false |
delay_display_disable |
BOOL | Delay the display disable (prevents flickering due to software disabling and enabling the display rapidly) | true, false |
delay_display_disable_time |
INT | The display disable delay time | milliseconds |
mda_font |
STRING | Path to the MDA font file | file path |
cga_font |
STRING | Path to the CGA font file | file path |
dbg_ui |
BOOL | Enables the debug UI | true, false |
| Key | Type | Description | Values |
|---|---|---|---|
path |
STRING | Path to the ROM file | file path |
offset |
INT | The offset to load the ROM file | 0x00000 - 0xFFFFF |
| Key | Type | Description | Values |
|---|---|---|---|
path |
STRING | Path to the Disk file | file path |
drive |
INT | The drive to load the disk file in. | A, B |
write_protect |
BOOL | write protects the drive | true, false |
| Key | Type | Description | Values |
|---|---|---|---|
path |
STRING | Path to the Disk file | file path |
drive |
INT | The drive to load the disk file in. | C, D |
geometry |
STRUCT | Geometry override for RAW images | See below |
type |
ENUM | Type override for RAW images | Type1, Type2, Type13, Type16 |
- If loading a raw hard disk image; some geometries have ambiguous file sizes and cant determine the geometry from the file size alone.
- Use
geometryORtypeparameter of the hard disk to tell the emulator what the disk geometry is. - If both
geometryandtypeare supplied then thegeometryis used to determine it.
| Key | Type | Description | Values |
|---|---|---|---|
c |
INT | Max cylinders of the hard disk | |
h |
INT | Max heads of the hard disk | |
s |
INT | Max sectors of the hard disk |
See Hard disk drive geometries
- Each
disk,hddorromstruct can appear multiple times to define multiple drives or ROMS. - Numbers can be written in decimal, hexadecimal (0x), or binary (0b) form.
- Comments start with
;and extend to the end of the line. - Missing values fall back to defaults defined in the emulator.
- If a
sw1_overrideorsw2_overrideisfalse; the associated SW is set automatically based on the provided config - RAM must be provided in BYTES.
2 Image formats are currently support for hard disks. VHD or RAW/IMG images.
If using a VHD the geometry of the disk will be automatically detected since the VHD Stores the disk geometry. Using the VHD format allows you to browse a FAT12/FAT16 formated Hard disk in your Host OS like any other VHD.
-
A VHD cannot be saved while it is mounted in the Host OS.
-
A VHD can be loaded while it is mounted in the Host OS.
-
DOS will not see changes to the VHD made by the Host OS until a reboot of the emulator has been done. DOS caches the FAT and accessed files in RAM. Any new files created or modified might not show up until a reboot of the emulator. Using a program i have created i have been able to get around this issue. See FDFLUSH.COM
If using a RAW image, Some hard disk geometries cant be determined from the file size alone due to multiple hard disk geometries having the same total size.
| Type | Geometry | Total size (MB) |
|---|---|---|
Type1 |
C = 306, H = 4, S = 17 | 10.16MB |
Type2 |
C = 615, H = 4, S = 17 | 20.41MB |
Type13 |
C = 306, H = 8, S = 17 | 20.32MB (ambiguous) |
Type16 |
C = 612, H = 4, S = 17 | 20.32MB (ambiguous) |
[TODO]
- Load the unformatted hard disk in the emulator. For this demo; the hard disk is in Drive
C: - Boot a DOS floppy in drive A: that has the
FDISKandFORMATutilities - Run
FDISKto create a partition table on the hard disk. - Run
FORMAT C: /sto format the hard disk and copy the system files to it. - Eject the floppy from drive A:
- Reboot the emulator.
This program invalidates the FAT and forces all floppies and hdds to be re-cached next time they are accessed. This allows changes made by the host OS to show up without a reboot of the emulator. This program can be found in the programs\ directory of the repo.



