Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
dbf7d2b
Add DJGPP to configure scripts
jayschwa Feb 22, 2020
593979d
Do not use MMX or SSE on x86 hosts by default
jayschwa Feb 22, 2020
8c297b5
djgpp: Get testfile (mostly) passing
jayschwa Feb 23, 2020
63f0003
dos: Add support for basic timing functions
jayschwa Feb 24, 2020
1ae45fe
Create SVGA video driver (cloned from dummy driver)
jayschwa Feb 27, 2020
3d40fe7
svga: Add VBE types
jayschwa Feb 29, 2020
0b4fd9d
svga: Tweak file names
jayschwa Feb 29, 2020
a55ec2b
svga: Read VBE info and require VBE 2.0
jayschwa Feb 29, 2020
773715c
svga: Use structs for special VBE fields
jayschwa Mar 2, 2020
8236e8a
svga: Assert VBE struct sizes at compile time
jayschwa Mar 2, 2020
58edca8
svga: Implement `GetVBEModeInfo`
jayschwa Mar 2, 2020
7906114
svga: Add `GetCurrentVBEMode`
jayschwa Mar 3, 2020
4e0797a
svga: Implement `GetDisplayModes`
jayschwa Mar 3, 2020
3d99753
svga: Remove `SDL` prefix from VBE functions
jayschwa Mar 3, 2020
3dcab18
svga: Only use color graphics modes with linear memory
jayschwa Mar 4, 2020
b6943f3
svga: Convert from VBE to SDL pixel format
jayschwa Mar 4, 2020
c65fdad
svga: Add SetVBEMode
jayschwa Mar 4, 2020
c070749
WIP: svga: Implement framebuffer functions
jayschwa Mar 19, 2020
63c27e8
svga: Use color masks to derive pixel format
jayschwa Mar 20, 2020
c01008a
svga: Calculate surface size with pitch field
jayschwa Mar 20, 2020
e10b1f2
svga: Save framebuffer ptr in device data
jayschwa Mar 20, 2020
d8b2e85
svga: Add `VBE_FLAT_PTR` macro function
jayschwa Mar 20, 2020
58df679
svga: Add window functions and data
jayschwa Mar 21, 2020
0ff763e
svga: Modes must have 4-byte aligned scan lines
jayschwa Mar 21, 2020
56f214a
svga: Use safer form of memory mapping for framebuffer
jayschwa Mar 21, 2020
6b21e8a
svga: Implement double buffering
jayschwa Mar 21, 2020
630ef22
WIP: svga: Support indexed color formats
jayschwa Mar 22, 2020
6fe697e
svga: Naively generate key press events
jayschwa Mar 27, 2020
8689844
svga: Restore original video state on quit
jayschwa Mar 28, 2020
dbe5c10
dos: Write logs to a file
jayschwa Apr 12, 2020
88d8427
svga: Invalidate window surface after freeing it
jayschwa Apr 12, 2020
bd0280e
dos: Move keyboard handling out of svga
jayschwa Apr 19, 2020
1c3335b
dos: Use interrupt service routine for keyboard events
jayschwa Apr 19, 2020
cd0e976
dos: Use PS/2 status register to poll keyboard
jayschwa Apr 20, 2020
360dddd
dos: Do not set `pm_selector`
jayschwa Apr 21, 2020
e8c6797
svga: Add some debug logs
jayschwa Apr 23, 2020
58863eb
svga: Remove obsolete SVGA_Available
jayschwa Feb 7, 2021
0dca333
WIP: dos: Add mouse support
jayschwa May 2, 2020
0a8e2bc
Add SDL_mouse.h include to SDL_svga_framebuffer.c
AJenbo Aug 30, 2025
643bd9b
dos: fix functions for latest SDL2
glebm Aug 31, 2025
5f92a76
dos: Do not bother attempting framebuffer texture
glebm Aug 31, 2025
8048fa3
dos: #if SDL_VIDEO_DRIVER_SVGA -> #ifdef
glebm Aug 31, 2025
6a87741
dos: Add CMake configuration
glebm Aug 31, 2025
6529694
dos: implement some extended keys
glebm Aug 31, 2025
d9cf906
dos: handle text input events
glebm Sep 1, 2025
027fb04
dos: modernize fullscreen-only handling
glebm Sep 1, 2025
b55cac0
dos: Implement palette support
glebm Sep 1, 2025
6e5751f
dos: Only draw the cursor if it is enabled
glebm Sep 1, 2025
4862825
Change return to continue on SVGA mode info error
AJenbo Sep 1, 2025
4764588
dos: Use protected-mode interface to set palette
glebm Sep 2, 2025
20b47a6
dos: Use protected-mode interface to request flip
glebm Sep 2, 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
43 changes: 39 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC)
endif()

# Default option knobs
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR SDL_CPU_ARM64EC)
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR SDL_CPU_ARM64EC OR DOS)
set(OPT_DEF_LIBC ON)
endif()
if(WINDOWS OR MACOS OR IOS OR TVOS OR VISIONOS OR WATCHOS)
Expand Down Expand Up @@ -358,11 +358,20 @@ if(EMSCRIPTEN)
set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
endif()

if(VITA OR PSP OR PS2 OR N3DS)
if(VITA OR PSP OR PS2 OR N3DS OR DOS)
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
endif()

if(DOS)
set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
set(SDL_SSE OFF)
set(SDL_SSE2 OFF)
set(SDL_SSE3 OFF)
set(SDL_MMX OFF)
set(SDL_3DNOW OFF)
Comment on lines +368 to +372
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be detected at runtime for DOS?

endif()

set(SDL_X11_XRANDR_DEFAULT ON)
if(SOLARIS)
set(SDL_X11_XRANDR_DEFAULT OFF)
Expand Down Expand Up @@ -412,7 +421,7 @@ set_option(SDL2_DISABLE_UNINSTALL "Disable uninstallation of SDL2" OFF)
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
dep_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64;NOT DOS" OFF)
dep_option(SDL_SSE "Use SSE assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE2 "Use SSE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE3 "Use SSE3 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
Expand Down Expand Up @@ -525,6 +534,10 @@ if(VITA)
set_option(VIDEO_VITA_PVR "Build with PSVita PVR gles/gles2 support" OFF)
endif()

if(DOS)
set_option(SDL_DOS_UCLOCK "Whether to use uclock() for performance counter on DOS" TRUE)
endif()

# General source files
file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/*.c
Expand Down Expand Up @@ -2873,6 +2886,28 @@ elseif(OS2)
CheckHIDAPI()
endif()

elseif(DOS)
file(GLOB DOS_CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/dos/*.c)
list(APPEND SOURCE_FILES ${DOS_CORE_SOURCES})

if(SDL_TIMERS)
if(SDL_DOS_UCLOCK)
set(HAVE_UCLOCK TRUE)
endif()

set(SDL_TIMER_DOS 1)
file(GLOB DOS_TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dos/*.c)
list(APPEND SOURCE_FILES ${DOS_TIMER_SOURCES})
set(HAVE_SDL_TIMERS TRUE)
endif()

if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_SVGA 1)
file(GLOB SVGA_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/svga/*.c)
list(APPEND SOURCE_FILES ${SVGA_VIDEO_SOURCES})
set(HAVE_SDL_VIDEO TRUE)
endif()

elseif(N3DS)
file(GLOB N3DS_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/n3ds/*.c)
set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${N3DS_MAIN_SOURCES})
Expand Down Expand Up @@ -3028,7 +3063,7 @@ endif()
# We always need to have threads and timers around
if(NOT HAVE_SDL_THREADS)
# The emscripten platform has been carefully vetted to work without threads
if (EMSCRIPTEN)
if (EMSCRIPTEN OR DOS)
set(SDL_THREADS_DISABLED 1)
file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
list(APPEND SOURCE_FILES ${THREADS_SOURCES})
Expand Down
99 changes: 87 additions & 12 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ enable_wasapi
enable_hidapi_joystick
enable_hidapi_libusb
enable_clock_gettime
enable_uclock
enable_rpath
enable_backgrounding_signal
enable_foregrounding_signal
Expand Down Expand Up @@ -1671,9 +1672,9 @@ Optional Features:
--enable-assembly Enable assembly routines [default=yes]
--enable-ssemath Allow GCC to use SSE floating point math
[default=maybe]
--enable-mmx use MMX assembly routines [default=yes]
--enable-3dnow use 3DNow! assembly routines [default=no]
--enable-sse use SSE assembly routines [default=yes]
--enable-mmx use MMX assembly routines [default=maybe]
--enable-3dnow use 3DNow! assembly routines [default=maybe]
--enable-sse use SSE assembly routines [default=maybe]
--enable-sse2 use SSE2 assembly routines [default=maybe]
--enable-sse3 use SSE3 assembly routines [default=maybe]
--enable-altivec use Altivec assembly routines [default=yes]
Expand Down Expand Up @@ -1779,6 +1780,8 @@ Optional Features:
--enable-clock_gettime use clock_gettime() instead of gettimeofday() on
UNIX [default=yes]
--enable-rpath use an rpath when linking SDL [default=yes]
--enable-uclock use uclock() for performance counter on DOS
[default=yes]
--enable-backgrounding-signal
number to use for magic backgrounding signal or 'no'
[default=no]
Expand Down Expand Up @@ -19358,6 +19361,25 @@ printf "%s\n" "#define HAVE_MPROTECT 1" >>confdefs.h

fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
case "$host" in
*-*-msdosdjgpp*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: skipping unfinished fseeko64 in DJGPP" >&5
$as_echo "$as_me: skipping unfinished fseeko64 in DJGPP" >&6;}
;;
*)
for ac_func in fseeko64
do :
ac_fn_c_check_func "$LINENO" "fseeko64" "ac_cv_func_fseeko64"
if test "x$ac_cv_func_fseeko64" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_FSEEKO64 1
_ACEOF

fi
done

;;
esac
fi

ac_fn_c_check_func "$LINENO" "malloc" "ac_cv_func_malloc"
Expand Down Expand Up @@ -19743,12 +19765,6 @@ if test "x$ac_cv_func_fseeko" = xyes
then :
printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "fseeko64" "ac_cv_func_fseeko64"
if test "x$ac_cv_func_fseeko64" = xyes
then :
printf "%s\n" "#define HAVE_FSEEKO64 1" >>confdefs.h

fi
ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction"
if test "x$ac_cv_func_sigaction" = xyes
Expand Down Expand Up @@ -20647,7 +20663,7 @@ if test ${enable_mmx+y}
then :
enableval=$enable_mmx;
else $as_nop
enable_mmx=yes
enable_mmx=$default_ssemath
fi

if test x$enable_mmx = xyes; then
Expand Down Expand Up @@ -20703,7 +20719,7 @@ if test ${enable_3dnow+y}
then :
enableval=$enable_3dnow;
else $as_nop
enable_3dnow=no
enable_3dnow=$default_ssemath
fi

if test x$enable_3dnow = xyes; then
Expand Down Expand Up @@ -20754,7 +20770,7 @@ if test ${enable_sse+y}
then :
enableval=$enable_sse;
else $as_nop
enable_sse=yes
enable_sse=$default_ssemath
fi

if test x$enable_sse = xyes; then
Expand Down Expand Up @@ -25984,6 +26000,18 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_QSA 1" >>confdefs.h
fi
}

CheckSVGAVideo()
{
if test x$enable_video = xyes; then

$as_echo "#define SDL_VIDEO_DRIVER_SVGA 1" >>confdefs.h

SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
have_video=yes
SUMMARY_video="${SUMMARY_video} svga"
fi
}

# Check whether --enable-video-opengl was given.
if test ${enable_video_opengl+y}
then :
Expand Down Expand Up @@ -28553,6 +28581,30 @@ printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
fi
}

CheckUCLOCK()
{
# Check whether --enable-uclock was given.
if test "${enable_uclock+set}" = set; then :
enableval=$enable_uclock;
else
enable_uclock=yes
fi

if test x$enable_uclock = xyes; then
for ac_func in uclock
do :
ac_fn_c_check_func "$LINENO" "uclock" "ac_cv_func_uclock"
if test "x$ac_cv_func_uclock" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_UCLOCK 1
_ACEOF

fi
done

fi
}

CheckLinuxVersion()
{
ac_fn_c_check_header_compile "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"
Expand Down Expand Up @@ -29762,6 +29814,29 @@ printf "%s\n" "#define SDL_JOYSTICK_OS2 1" >>confdefs.h
have_joystick=yes
fi
;;
*-*-msdosdjgpp*)
ARCH=dos
CheckVisibilityHidden
CheckDeclarationAfterStatement
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckSVGAVideo
CheckDLOPEN
CheckUCLOCK

# Set up files for the timer library
if test x$enable_timers = xyes; then

$as_echo "#define SDL_TIMER_DOS 1" >>confdefs.h

SOURCES="$SOURCES $srcdir/src/timer/dos/*.c"
have_timers=yes
fi

# Set up files for shared DOS utilities and event handling
SOURCES="$SOURCES $srcdir/src/core/dos/*.c"
;;
*)
as_fn_error $? "
*** Unsupported host: Please add to configure.ac
Expand Down
67 changes: 60 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,17 @@ dnl Checks for library functions.
AC_DEFINE(HAVE_MPROTECT, 1, [ ])
],[]),
)
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction sigtimedwait setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _Exit)

case "$host" in
*-*-msdosdjgpp*)
AC_MSG_NOTICE(skipping unfinished fseeko64 in DJGPP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this apply when building with CMake as well?

;;
*)
AC_CHECK_FUNCS(fseeko64)
;;
esac

AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko sigaction sigtimedwait setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _Exit)

AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
Expand Down Expand Up @@ -664,8 +674,8 @@ if test x$enable_assembly = xyes; then

dnl Check for various instruction support
AC_ARG_ENABLE(mmx,
[AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [default=yes]])],
, enable_mmx=yes)
[AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=maybe]]])],
, enable_mmx=$default_ssemath)
if test x$enable_mmx = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_mmx=no
Expand Down Expand Up @@ -698,8 +708,8 @@ dnl Check for various instruction support
fi

AC_ARG_ENABLE(3dnow,
[AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [default=no]])],
, enable_3dnow=no)
[AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=maybe]]])],
, enable_3dnow=$default_ssemath)
if test x$enable_3dnow = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_3dnow=no
Expand Down Expand Up @@ -727,8 +737,8 @@ dnl Check for various instruction support
fi

AC_ARG_ENABLE(sse,
[AS_HELP_STRING([--enable-sse], [use SSE assembly routines [default=yes]])],
, enable_sse=yes)
[AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=maybe]]])],
, enable_sse=$default_ssemath)
if test x$enable_sse = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_sse=no
Expand Down Expand Up @@ -2508,6 +2518,17 @@ CheckQNXAudio()
fi
}

dnl Set up the SVGA video driver if enabled
CheckSVGAVideo()
{
if test x$enable_video = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_SVGA, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
have_video=yes
SUMMARY_video="${SUMMARY_video} svga"
fi
}

dnl Check to see if OpenGL support is desired
AC_ARG_ENABLE(video-opengl,
[AS_HELP_STRING([--enable-video-opengl], [include OpenGL support [default=yes]])],
Expand Down Expand Up @@ -3694,6 +3715,17 @@ CheckClockGettime()
fi
}

dnl Check for uclock()
CheckUCLOCK()
{
AC_ARG_ENABLE(uclock,
AS_HELP_STRING([--enable-uclock], [use uclock() for performance counter on DOS [[default=yes]]]),
, enable_uclock=yes)
if test x$enable_uclock = xyes; then
AC_CHECK_FUNCS(uclock)
fi
}

dnl Check for a valid linux/version.h
CheckLinuxVersion()
{
Expand Down Expand Up @@ -4673,6 +4705,27 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
have_joystick=yes
fi
;;
*-*-msdosdjgpp*)
ARCH=dos
CheckVisibilityHidden
CheckDeclarationAfterStatement
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckSVGAVideo
CheckDLOPEN
CheckUCLOCK

# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_DOS, 1, [ ])
SOURCES="$SOURCES $srcdir/src/timer/dos/*.c"
have_timers=yes
fi

# Set up files for shared DOS utilities and event handling
SOURCES="$SOURCES $srcdir/src/core/dos/*.c"
;;
*)
AC_MSG_ERROR([
*** Unsupported host: Please add to configure.ac
Expand Down
Loading
Loading