Map
โ†‘SDL (Simple DirectMedia Layer)

SDL3 DOS Port (DJGPP)

Wiki summarysdldosretro-computingdjgppgames โ†ณ show in map Markdown
title
SDL3 DOS Port (DJGPP)
type
summary
summary
2026 native DOS platform support for SDL3 via DJGPP โ€” VGA/VESA video, Sound Blaster audio, cooperative threading via setjmp/longjmp, merged April 23
parent
sdl
tags
sdl, dos, retro-computing, djgpp, games
created
2026-04-25
updated
2026-04-30

In April 2026, SDL3 gained native DOS support. PR #15377 by Anders Jenbo (AJenbo) โ€” combined work with icculus, madebr, glebm, jayschwa, and ccawley2011 โ€” landed on 2026-04-23: ~6,000 lines added across 58 files, building with DJGPP via a CMake cross-compilation toolchain. Tested extensively against DevilutionX inside DOSBox, with no real-hardware testing yet at merge time.

This means SDL3 games can now be cross-compiled to native DOS executables โ€” a target the SDL ecosystem hadn't shipped in modern form. The earlier SDL 1.2 DOS effort never reached parity; SDL3's port is "fairly complete," missing only audio recording, a native SDL_TIME (it falls back to DJGPP's gettimeofday), and dynamic library loading (no SDL_LoadObject).

What works

Video

  • VGA framebuffer
  • VESA 1.2+ framebuffer with hardware page-flipping and vsync
  • RGB and 8-bit indexed color, with VGA DAC palette programming
  • VBE state save/restore on exit (so quitting doesn't wreck the user's screen)

Audio

  • Sound Blaster 16 โ€” 16-bit stereo up to 44.1 kHz
  • Sound Blaster Pro โ€” 8-bit stereo up to 22 kHz
  • Sound Blaster 2.0 / 1.x โ€” 8-bit mono
  • All via IRQ-driven DMA with double-buffered auto-init (the standard SB trick for glitch-free continuous playback)

Input

  • PS/2 keyboard, including extended scancodes (the 0xE0 prefix that distinguishes things like right-Ctrl)
  • INT 33h mouse driver, with sensitivity queried from the driver
  • Gameport joystick via BIOS INT 15h, with auto-calibration

Threading

  • Cooperative scheduler built on setjmp / longjmp with stack patching โ€” conceptually borrowed from the SDL3 PS2 port
  • Real mutexes, semaphores, TLS, and condition variables (generic fallback for the latter)
  • Yield points in the event pump and delay functions keep audio and other cooperative threads responsive

Timer

  • Native PIT-based timer using DJGPP's uclock(), ~1.19 MHz resolution

Filesystem

  • SDL_GetBasePath / SDL_GetPrefPath via DJGPP's searchpath()
  • POSIX filesystem ops as fallback

Build infrastructure

  • CMake toolchain file build-scripts/i586-pc-msdosdjgpp.cmake
  • Dedicated DJGPP CI job
  • Preseed cache for faster cross-configure

What's not included

  • Audio recording (playback only)
  • Native SDL_TIME implementation โ€” uses DJGPP's POSIX gettimeofday instead
  • Shared library loading (SDL_LoadObject) โ€” DOS has no real dlopen equivalent that fits SDL's model

How to build

cmake -S. -Bbuild-dos \
  -DCMAKE_TOOLCHAIN_FILE=build-scripts/i586-pc-msdosdjgpp.cmake \
  -DCMAKE_BUILD_TYPE=Release
cmake --build build-dos -j$(nproc)

You need a DJGPP toolchain on the host. The CI job in the SDL repo gives a working reference setup.

Why this matters

SDL is the de-facto portability shim for cross-platform games. DOS being a supported SDL3 target means modern game code โ€” written against SDL3 APIs โ€” can be cross-compiled to a real DOS executable that runs on a 486-class machine (or, more commonly, on DOSBox). DevilutionX, the open-source Diablo reimplementation, is the proof-of-concept used during development.

The threading bit is the most architecturally interesting piece. DOS has no preemptive threading; the only kernel is a 16-bit single-tasking BIOS plus whatever the runtime brings. SDL's port builds full thread primitives (mutexes/sema/TLS/condvars) on top of a cooperative scheduler that swaps stack frames via setjmp / longjmp and explicit yield points scattered through the event loop and delay paths. That's enough to make audio threads stay responsive without preemption โ€” which is what real SB16-era games already had to do by hand, but now wrapped in SDL's portable thread API.

  • sdl โ€” the SDL project itself
  • dosbox-detection-callback-opcode โ€” Snow's post on detecting DOSBox; this PR was largely tested inside DOSBox
  • early-dos-paterson-listings โ€” adjacent April 2026 retro-DOS news: Microsoft's release of recovered 86-DOS / PC-DOS 1.00 source listings from Tim Paterson
  • win32-stable-abi โ€” adjacent "old binary platforms in 2026" theme: Wine/Win32 as the only stable Linux ABI for games