SDL Now Supports DOS

· systems · Source ↗

TLDR

  • SDL3 gains a native DOS platform target via DJGPP, with VESA/VBE display, Sound Blaster audio, and joystick support compiled through a 32-bit protected-mode toolchain.

Key Takeaways

  • Display uses VESA VBE interfaces with the software renderer; double-buffered page-flipping and banked framebuffer fallback for VBE 1.2+ modes without LFB are both implemented.
  • Audio runs at 22050 Hz through the Sound Blaster DSP; mixing was moved out of the IRQ handler into the main loop to avoid reentrancy, with DMA buffer half-silencing to prevent stutter.
  • A hardware-interrupt audio trick from SDL 1.2’s MacOS Classic port was reused: if the audio lock is held when the interrupt fires, the iteration runs on lock release instead.
  • DOS-specific quirks required: excluding GTK/SDLGtkQuit (DJGPP defines `__unix` but has no display server), disabling the generic SDL_RunApp, and adding a DJGPP cmake platform detection path.
  • Joystick axis polling is throttled to ~60 Hz to reduce BIOS timing loop cost; buttons are always polled directly for responsiveness.

Hacker News Comment Review

  • Commenters clarified that DJGPP runs in 32-bit protected mode via DPMI, so this is not the classic segmented-memory DOS experience; near pointers and 64 KB limits are absent.
  • There is irony in the screenshot: DOSBox itself is built on SDL, so the new DOS SDL target can run inside DOSBox, which depends on SDL.
  • One commenter noted HXDOS previously made SDL work on DOS by emulating DirectDraw, so this is the first native SDL platform port rather than the first DOS SDL path ever.

Notable Comments

  • @theamk: DJGPP uses DPMI for 32-bit protected mode; “you won’t get old-school experience of segmented memory, near pointers and 64KB limits.”
  • @ronsor: Suggests SDL for UEFI as the logical next step, enabling games in a pre-OS environment.

Original | Discuss on HN