Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package sdl12_compat for openSUSE:Factory checked in at 2023-09-29 21:13:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/sdl12_compat (Old) and /work/SRC/openSUSE:Factory/.sdl12_compat.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "sdl12_compat" Fri Sep 29 21:13:07 2023 rev:6 rq:1113762 version:1.2.68 Changes: -------- --- /work/SRC/openSUSE:Factory/sdl12_compat/sdl12_compat.changes 2023-06-04 16:41:28.345726227 +0200 +++ /work/SRC/openSUSE:Factory/.sdl12_compat.new.28202/sdl12_compat.changes 2023-09-29 21:13:54.582475707 +0200 @@ -1,0 +2,14 @@ +Tue Sep 26 19:02:23 UTC 2023 - Jan Engelhardt <jengelh@inai.de> + +- Update to release 1.2.68 + * sync dr_mp3 with mainstream + * Add null check to SDL_LoadWAV_RW to avoid crashes + * Add quirk entry: deactivate GL scaling for Trine (2011 Humble + Bundle version) and Mark of the Ninja (HB) + * Add quirk entry: set Hyperspace Delivery Boy to run in 16bpp mode + * Add quirk handling: add ability to force XInitThreads before + main() + * Allocate the video surface object statically as a global + * Add a hint to clamp the reported screen bit depth + +------------------------------------------------------------------- Old: ---- release-1.2.64.tar.gz New: ---- release-1.2.68.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sdl12_compat.spec ++++++ --- /var/tmp/diff_new_pack.WFp5aG/_old 2023-09-29 21:13:55.862521890 +0200 +++ /var/tmp/diff_new_pack.WFp5aG/_new 2023-09-29 21:13:55.862521890 +0200 @@ -19,7 +19,7 @@ Name: sdl12_compat %define lname libSDL-1_2-0 %global _lto_cflags %_lto_cflags -ffat-lto-objects -Version: 1.2.64 +Version: 1.2.68 Release: 0 Summary: SDL-1.2 Compatibility Layer for Simple DirectMedia Layer 2.0 License: MIT ++++++ release-1.2.64.tar.gz -> release-1.2.68.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/.github/workflows/main.yml new/sdl12-compat-release-1.2.68/.github/workflows/main.yml --- old/sdl12-compat-release-1.2.64/.github/workflows/main.yml 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/.github/workflows/main.yml 2023-09-26 19:43:48.000000000 +0200 @@ -10,7 +10,7 @@ matrix: platform: - { name: Windows, os: windows-latest } - - { name: Linux, os: ubuntu-20.04, flags: -GNinja } + - { name: Linux, os: ubuntu-latest, flags: -GNinja } - { name: MacOS, os: macos-latest } steps: - name: Setup Linux dependencies @@ -19,14 +19,15 @@ sudo apt-get update sudo apt-get install cmake ninja-build libgl1-mesa-dev libglu1-mesa-dev - name: Get sdl12-compat sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Get SDL2 headers - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: libsdl-org/SDL - ref: release-2.0.18 + ref: SDL2 path: SDL2 - name: Configure CMake run: cmake -DSDL2_INCLUDE_DIR="${{ github.workspace }}/SDL2/include" -B build ${{ matrix.platform.flags }} - name: Build run: cmake --build build/ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/.github/workflows/watcom.yml new/sdl12-compat-release-1.2.68/.github/workflows/watcom.yml --- old/sdl12-compat-release-1.2.64/.github/workflows/watcom.yml 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/.github/workflows/watcom.yml 2023-09-26 19:43:48.000000000 +0200 @@ -21,7 +21,7 @@ uses: actions/checkout@v2 with: repository: libsdl-org/SDL - ref: release-2.24.0 + ref: SDL2 path: SDL2 - name: Build sdl12-compat run: | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/CMakeLists.txt new/sdl12-compat-release-1.2.68/CMakeLists.txt --- old/sdl12-compat-release-1.2.64/CMakeLists.txt 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/CMakeLists.txt 2023-09-26 19:43:48.000000000 +0200 @@ -2,9 +2,9 @@ # you can define SDL2_INCLUDE_DIR on the cmdline. For example: # cmake -DSDL2_INCLUDE_DIR=/opt/SDL2/include/SDL2 [other stuff] -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.0.0...3.5) project(sdl12_compat - VERSION 1.2.64 + VERSION 1.2.68 LANGUAGES C) option(SDL12TESTS "Enable to build SDL-1.2 test programs" ON) @@ -16,7 +16,7 @@ endif() list(APPEND CMAKE_MODULE_PATH - "${CMAKE_CURRENT_LIST_DIR}/cmake/modules" + "${CMAKE_CURRENT_LIST_DIR}/cmake/modules" ) include(CheckCSourceCompiles) @@ -33,7 +33,7 @@ # Xcode project file uses 1.0.0, but it's more compatible to use the # higher version. set(DYLIB_COMPAT_VERSION 12.0.0 CACHE STRING "library compatibility version") - set(DYLIB_CURRENT_VERSION 12.64.0 CACHE STRING "library current version") + set(DYLIB_CURRENT_VERSION 12.68.0 CACHE STRING "library current version") include_directories("/opt/X11/include") # hack. if(CMAKE_VERSION VERSION_LESS 3.9) else() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/include/SDL/SDL_config.h new/sdl12-compat-release-1.2.68/include/SDL/SDL_config.h --- old/sdl12-compat-release-1.2.64/include/SDL/SDL_config.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/include/SDL/SDL_config.h 2023-09-26 19:43:48.000000000 +0200 @@ -54,6 +54,8 @@ #include <stdarg.h> #define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + /* for now, let's try and say everything that we care about that isn't Windows has these C runtime functions available. We're trying to avoid a configure stage, though. Send patches if your platform lacks something. */ @@ -127,9 +129,13 @@ #endif #endif +#if defined(__GLIBC__) +/* glibc certainly includes this, send patches if your OS does too */ +#define HAVE_MALLOC_H 1 +#endif + /* things that aren't necessarily in Linux, some are MSVC C runtime, some are BSD. Send patches. */ #if 0 -#define HAVE_MALLOC_H 1 #define HAVE_BCOPY 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/include/SDL/SDL_platform.h new/sdl12-compat-release-1.2.68/include/SDL/SDL_platform.h --- old/sdl12-compat-release-1.2.64/include/SDL/SDL_platform.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/include/SDL/SDL_platform.h 2023-09-26 19:43:48.000000000 +0200 @@ -70,8 +70,29 @@ #if defined(__APPLE__) /* lets us know what version of Mac OS X we're compiling on */ -#include "AvailabilityMacros.h" -#include "TargetConditionals.h" +#include <AvailabilityMacros.h> +#include <TargetConditionals.h> + +/* Fix building with older SDKs that don't define these + See this for more information: + https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-tar... +*/ +#ifndef TARGET_OS_MACCATALYST +#define TARGET_OS_MACCATALYST 0 +#endif +#ifndef TARGET_OS_IOS +#define TARGET_OS_IOS 0 +#endif +#ifndef TARGET_OS_IPHONE +#define TARGET_OS_IPHONE 0 +#endif +#ifndef TARGET_OS_TV +#define TARGET_OS_TV 0 +#endif +#ifndef TARGET_OS_SIMULATOR +#define TARGET_OS_SIMULATOR 0 +#endif + #if TARGET_OS_TV #undef __TVOS__ #define __TVOS__ 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/include/SDL/SDL_version.h new/sdl12-compat-release-1.2.68/include/SDL/SDL_version.h --- old/sdl12-compat-release-1.2.64/include/SDL/SDL_version.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/include/SDL/SDL_version.h 2023-09-26 19:43:48.000000000 +0200 @@ -33,7 +33,7 @@ /* We bumped the patchlevel to 50 for sdl12-compat */ #define SDL_MAJOR_VERSION 1 #define SDL_MINOR_VERSION 2 -#define SDL_PATCHLEVEL 64 +#define SDL_PATCHLEVEL 68 typedef struct SDL_version { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/include/SDL/SDL_video.h new/sdl12-compat-release-1.2.68/include/SDL/SDL_video.h --- old/sdl12-compat-release-1.2.64/include/SDL/SDL_video.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/include/SDL/SDL_video.h 2023-09-26 19:43:48.000000000 +0200 @@ -89,7 +89,7 @@ Uint16 pitch; void *pixels; int offset; - void *hwdata; + struct private_hwdata *hwdata; SDL_Rect clip_rect; Uint32 unused1; Uint32 locked; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/Makefile.darwin new/sdl12-compat-release-1.2.68/src/Makefile.darwin --- old/sdl12-compat-release-1.2.64/src/Makefile.darwin 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/Makefile.darwin 2023-09-26 19:43:48.000000000 +0200 @@ -18,7 +18,7 @@ LDFLAGS = -mmacosx-version-min=10.6 -dynamiclib -Wl,-undefined,error -Wl,-single_module #LDFLAGS+= -Wl,-headerpad_max_install_names LDFLAGS+= -Wl,-install_name,"/usr/local/lib/$(DYLIB)" -LDFLAGS+= -Wl,-compatibility_version,1.0 -Wl,-current_version,12.64 +LDFLAGS+= -Wl,-compatibility_version,1.0 -Wl,-current_version,12.68 LDLIBS = -Wl,-framework,AppKit # this is needed for x86_64 - cross-gcc might not add it. #LDLIBS += -Wl,-lbundle1.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/Makefile.linux new/sdl12-compat-release-1.2.68/src/Makefile.linux --- old/sdl12-compat-release-1.2.64/src/Makefile.linux 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/Makefile.linux 2023-09-26 19:43:48.000000000 +0200 @@ -16,7 +16,7 @@ LDFLAGS+= -Wl,--no-undefined LDLIBS = -ldl -SHLIB = libSDL-1.2.so.1.2.64 +SHLIB = libSDL-1.2.so.1.2.68 OBJ = SDL12_compat.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/Makefile.os2 new/sdl12-compat-release-1.2.68/src/Makefile.os2 --- old/sdl12-compat-release-1.2.64/src/Makefile.os2 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/Makefile.os2 2023-09-26 19:43:48.000000000 +0200 @@ -5,7 +5,7 @@ !endif DLLNAME = SDL12 -VERSION = 1.2.64 +VERSION = 1.2.68 # change SDL2INC to point to the SDL2 headers SDL2INC = include diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/Makefile.w32 new/sdl12-compat-release-1.2.68/src/Makefile.w32 --- old/sdl12-compat-release-1.2.64/src/Makefile.w32 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/Makefile.w32 2023-09-26 19:43:48.000000000 +0200 @@ -5,7 +5,7 @@ !endif DLLNAME = SDL -VERSION = 1.2.64 +VERSION = 1.2.68 # change SDL2INC to point to the SDL2 headers SDL2INC = include diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/SDL12_compat.c new/sdl12-compat-release-1.2.68/src/SDL12_compat.c --- old/sdl12-compat-release-1.2.64/src/SDL12_compat.c 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/SDL12_compat.c 2023-09-26 19:43:48.000000000 +0200 @@ -28,7 +28,7 @@ * should be way ahead of what SDL-1.2 Classic would report, so apps can * decide if they're running under the compat layer, if they really care. */ -#define SDL12_COMPAT_VERSION 64 +#define SDL12_COMPAT_VERSION 68 #include <stdarg.h> #include <limits.h> @@ -980,6 +980,7 @@ static SDL_Renderer *VideoRenderer20 = NULL; static SDL_mutex *VideoRendererLock = NULL; static SDL_Texture *VideoTexture20 = NULL; +static SDL12_Surface VideoSurface12Location; static SDL12_Surface *VideoSurface12 = NULL; static SDL_Palette *VideoPhysicalPalette20 = NULL; static Uint32 VideoSurfacePresentTicks = 0; @@ -1273,6 +1274,14 @@ {"fillets", "SDL12COMPAT_ALLOW_SYSWM", "0"}, {"fillets", "SDL12COMPAT_COMPATIBILITY_AUDIOCVT", "1"}, + /* Hyperspace Delivery Boy relies on the exact imprecision of the format conversion in some + earlier versions of SDL 1.2. It also recommends 16-bit in the README, so force it. */ + {"hdb", "SDL12COMPAT_MAX_BPP", "16"}, + + /* Mark of the Ninja doesn't work with OpenGL scaling */ + {"ninja-bin32", "SDL12COMPAT_OPENGL_SCALING", "0"}, + {"ninja-bin64", "SDL12COMPAT_OPENGL_SCALING", "0"}, + /* Misuses SDL_AudioCVT */ {"pink-pony", "SDL12COMPAT_COMPATIBILITY_AUDIOCVT", "1"}, {"pink-pony.bin", "SDL12COMPAT_COMPATIBILITY_AUDIOCVT", "1"}, @@ -1281,6 +1290,16 @@ {"scorched3d", "SDL12COMPAT_OPENGL_SCALING", "0"}, {"scorched3dc", "SDL12COMPAT_OPENGL_SCALING", "0"}, + /* Trine (the old Humble Bundle version from 2011) doesn't render in-game with GL scaling enabled. */ + {"trine-bin32", "SDL12COMPAT_OPENGL_SCALING", "0"}, + {"trine-bin64", "SDL12COMPAT_OPENGL_SCALING", "0"}, + + /* Trine (the old Humble Bundle version from 2011)'s launcher needs X11, and needs XInitThreads _before_ GTK+ gets in there. */ + {"trine-launcher32", "SDL_VIDEODRIVER", "x11"}, + {"trine-launcher32", "SDL12COMPAT_FORCE_XINITTHREADS", "1"}, + {"trine-launcher64", "SDL_VIDEODRIVER", "x11"}, + {"trine-launcher64", "SDL12COMPAT_FORCE_XINITTHREADS", "1"}, + /* boswars has a bug where SDL_AudioCVT must not require extra buffer space. See Issue #232. */ {"boswars", "SDL12COMPAT_COMPATIBILITY_AUDIOCVT", "1"}, @@ -1381,6 +1400,18 @@ return (float) SDL20_atof(val); } +static int +SDL12Compat_GetHintInt(const char *name, int default_value) +{ + const char *val = SDL12Compat_GetHint(name); + + if (!val) { + return default_value; + } + + return SDL20_atoi(val); +} + static void SDL12Compat_ApplyQuirks(SDL_bool force_x11) { @@ -1483,6 +1514,22 @@ #endif } SDL12Compat_ApplyQuirks(force_x11); /* Apply and maybe print a list of any enabled quirks. */ + + #ifdef __linux__ + { + const char *viddrv = SDL20_getenv("SDL_VIDEODRIVER"); + if (viddrv && (SDL20_strcmp(viddrv, "x11") == 0) && SDL12Compat_GetHintBoolean("SDL12COMPAT_FORCE_XINITTHREADS", SDL_TRUE)) { + void *lib = dlopen("libX11.so.6", RTLD_GLOBAL|RTLD_NOW); + if (lib) { + int (*pXInitThreads)(void) = (int(*)(void)) dlsym(lib, "XInitThreads"); + if (pXInitThreads) { + pXInitThreads(); + } + /* leave the library open, so the XInitThreads sticks. */ + } + } + } + #endif } } if (!okay) { @@ -1998,6 +2045,21 @@ return SDL20_AtomicGet(&JoystickList[device_index].refcount) ? 1 : 0; } +static SDL_PixelFormatEnum +BPPToPixelFormat(unsigned bpp) +{ + #if !SDL_VERSION_ATLEAST(2,0,14) + #define SDL_PIXELFORMAT_XRGB8888 SDL_PIXELFORMAT_RGB888 + #endif + switch (bpp) { + case 8: return SDL_PIXELFORMAT_INDEX8; + case 16: return SDL_PIXELFORMAT_RGB565; + case 24: return SDL_PIXELFORMAT_BGR24; + case 32: return SDL_PIXELFORMAT_XRGB8888; + default: SDL20_SetError("Unsupported bits-per-pixel"); return SDL_PIXELFORMAT_UNKNOWN; + } +} + static SDL_PixelFormat * PixelFormat12to20(SDL_PixelFormat *format20, SDL_Palette *palette20, const SDL12_PixelFormat *format12) { @@ -2136,8 +2198,7 @@ } vmode->modeslist12 = (SDL12_Rect *) ptr; - vmode->modeslist12[vmode->nummodes] = *mode; - + SDL20_memcpy(&vmode->modeslist12[vmode->nummodes], mode, sizeof(vmode->modeslist12[vmode->nummodes])); vmode->nummodes++; return 0; @@ -2183,6 +2244,7 @@ { const int total = SDL20_GetNumDisplayModes(VideoDisplayIndex); const char *maxmodestr; + const unsigned max_bpp = SDL12Compat_GetHintInt("SDL12COMPAT_MAX_BPP", 32); VideoModeList *vmode = NULL; void *ptr = NULL; int i, j; @@ -2235,6 +2297,11 @@ continue; /* can't fit to 16-bits for SDL12_Rect */ } + if (SDL_BITSPERPIXEL(mode.format) > max_bpp) { + /* If we see any mode > max_bpp, reduce its bpp. */ + mode.format = BPPToPixelFormat(max_bpp); + } + if (!vmode || (mode.format != vmode->format)) { /* SDL20_GetDisplayMode() sorts on bpp first. We know when to change arrays. */ ptr = (VideoModeList *) SDL20_realloc(VideoModes, sizeof (VideoModeList) * (VideoModesCount+1)); if (!ptr) { @@ -2346,6 +2413,7 @@ { const char *driver = SDL20_GetCurrentVideoDriver(); const char *scale_method_env = SDL12Compat_GetHint("SDL12COMPAT_SCALE_METHOD"); + const unsigned max_bpp = SDL12Compat_GetHintInt("SDL12COMPAT_MAX_BPP", 32); SDL_DisplayMode mode; int i; @@ -2410,7 +2478,11 @@ SDL20_StopTextInput(); if (SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode) == 0) { - VideoInfoVfmt20 = SDL20_AllocFormat(mode.format); + if (SDL_BITSPERPIXEL(mode.format) > max_bpp) { + VideoInfoVfmt20 = SDL20_AllocFormat(BPPToPixelFormat(max_bpp)); + } else { + VideoInfoVfmt20 = SDL20_AllocFormat(mode.format); + } VideoInfo12.vfmt = PixelFormat20to12(&VideoInfoVfmt12, &VideoInfoPalette12, VideoInfoVfmt20); VideoInfo12.current_w = mode.w; VideoInfo12.current_h = mode.h; @@ -2591,6 +2663,19 @@ return InitFlags20to12(SDL20_WasInit(sdl20flags)) | extraflags; } +static void +FreeSurfaceContents(SDL12_Surface *surface12) +{ + if (surface12->surface20) { + SDL20_FreeSurface(surface12->surface20); + surface12->surface20 = NULL; + } + if (surface12->format) { + SDL20_free(surface12->format->palette); + SDL20_free(surface12->format); + surface12->format = NULL; + } +} static SDL12_Surface *EndVidModeCreate(void); static void @@ -4676,7 +4761,7 @@ } case SDL_MOUSEMOTION: - if (!VideoSurface12) { + if (!VideoSurface12 || !VideoSurface12->surface20) { return 1; /* we don't have a screen surface yet? Don't send this on to the app. */ } @@ -4912,26 +4997,21 @@ return rect20; } -static SDL12_Surface * -Surface20to12(SDL_Surface *surface20) +static SDL_bool +Surface20to12InPlace(SDL_Surface *surface20, + SDL12_Surface *surface12) { SDL_BlendMode blendmode = SDL_BLENDMODE_NONE; - SDL12_Surface *surface12 = NULL; SDL12_Palette *palette12 = NULL; SDL12_PixelFormat *format12 = NULL; Uint32 flags = 0; if (!surface20) { - return NULL; + return SDL_FALSE; } if (surface20->pitch > 65535) { SDL20_SetError("Pitch is too large"); /* can't fit to 16-bits */ - return NULL; - } - - surface12 = (SDL12_Surface *) SDL20_malloc(sizeof (SDL12_Surface)); - if (!surface12) { - goto failed; + return SDL_FALSE; } if (surface20->format->palette) { @@ -5004,12 +5084,33 @@ Rect20to12(&surface20->clip_rect, &surface12->clip_rect); surface12->refcount = surface20->refcount; - return surface12; + return SDL_TRUE; failed: - SDL20_free(surface12); SDL20_free(palette12); SDL20_free(format12); + return SDL_FALSE; +} + +static SDL12_Surface * +Surface20to12(SDL_Surface *surface20) +{ + SDL12_Surface *surface12 = NULL; + + surface12 = (SDL12_Surface *) SDL20_malloc(sizeof (SDL12_Surface)); + if (!surface12) { + goto failed; + } + + SDL20_zerop(surface12); + if (!Surface20to12InPlace(surface20, surface12)) { + goto failed; + } + + return surface12; + +failed: + SDL20_free(surface12); return NULL; } @@ -5077,11 +5178,10 @@ } } -DECLSPEC12 SDL12_Surface * SDLCALL -SDL_CreateRGBSurface(Uint32 flags12, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +static SDL_Surface * +CreateRGBSurface(Uint32 flags12, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_Surface *surface20; - SDL12_Surface *surface12; /* SDL 1.2 checks this. */ if ((width >= 16384) || (height >= 65536)) { @@ -5127,21 +5227,38 @@ surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask); } - surface12 = Surface20to12(surface20); - if (!surface12) { - SDL20_FreeSurface(surface20); - return NULL; - } - - SDL_assert((surface12->flags & ~(SDL12_SRCCOLORKEY|SDL12_SRCALPHA)) == 0); /* shouldn't have prealloc, rleaccel, or dontfree. */ + return surface20; +} +static void +Surface12SetMasks(SDL12_Surface *surface12, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ SetPalette12ForMasks(surface12, Rmask, Gmask, Bmask); if (Amask != 0) { surface12->flags |= SDL12_SRCALPHA; - SDL20_SetSurfaceBlendMode(surface20, SDL_BLENDMODE_BLEND); + SDL20_SetSurfaceBlendMode(surface12->surface20, SDL_BLENDMODE_BLEND); + } +} + +DECLSPEC12 SDL12_Surface * SDLCALL +SDL_CreateRGBSurface(Uint32 flags12, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + SDL12_Surface *surface12; + SDL_Surface *surface20; + + surface20 = CreateRGBSurface(flags12, width, height, depth, Rmask, Gmask, Bmask, Amask); + if (!surface20) { + return NULL; + } + surface12 = Surface20to12(surface20); + if (!surface12) { + SDL20_FreeSurface(surface20); + return NULL; } + SDL_assert((surface12->flags & ~(SDL12_SRCCOLORKEY|SDL12_SRCALPHA)) == 0); /* shouldn't have prealloc, rleaccel, or dontfree. */ + Surface12SetMasks(surface12, Rmask, Gmask, Bmask, Amask); return surface12; } @@ -5170,6 +5287,8 @@ SDL_assert((surface12->flags & ~(SDL12_SRCCOLORKEY|SDL12_SRCALPHA)) == SDL12_PREALLOC); /* should _only_ have prealloc. */ + /* TODO: Is it correct that this always ignored Amask, or should it be + * using Surface12SetMasks which takes Amask into account? */ SetPalette12ForMasks(surface12, Rmask, Gmask, Bmask); return surface12; @@ -5182,11 +5301,7 @@ surface12->refcount--; if (surface12->refcount) return; - SDL20_FreeSurface(surface12->surface20); - if (surface12->format) { - SDL20_free(surface12->format->palette); - SDL20_free(surface12->format); - } + FreeSurfaceContents(surface12); SDL20_free(surface12); } } @@ -5501,11 +5616,9 @@ VideoPhysicalPalette20 = NULL; } if (VideoSurface12) { - SDL12_Surface *screen12 = VideoSurface12; SDL20_free(VideoSurface12->pixels); VideoSurface12->pixels = NULL; - VideoSurface12 = NULL; /* SDL_FreeSurface will ignore the screen surface, so NULL the global variable out. */ - SDL_FreeSurface(screen12); + FreeSurfaceContents(VideoSurface12); } if (VideoConvertSurface20) { SDL20_FreeSurface(VideoConvertSurface20); @@ -5539,16 +5652,27 @@ return NULL; } - -static SDL12_Surface * -CreateSurface12WithFormat(const int w, const int h, const Uint32 fmt) +/* Essentially the same as SDL_CreateRGBSurface, but in-place */ +static void +CreateVideoSurface(const Uint32 fmt) { Uint32 rmask, gmask, bmask, amask; int bpp; + SDL_Surface *surface20; + if (!SDL20_PixelFormatEnumToMasks(fmt, &bpp, &rmask, &gmask, &bmask, &amask)) { - return NULL; + return; + } + + SDL20_zerop(VideoSurface12); + surface20 = CreateRGBSurface(0, 0, 0, bpp, rmask, gmask, bmask, amask); + + if (!Surface20to12InPlace(surface20, VideoSurface12)) { + FreeSurfaceContents(VideoSurface12); + return; } - return SDL_CreateRGBSurface(0, w, h, bpp, rmask, gmask, bmask, amask); + + Surface12SetMasks(VideoSurface12, rmask, gmask, bmask, amask); } static SDL_Surface * @@ -5878,6 +6002,7 @@ Uint32 appfmt; const char *vsync_env = SDL12Compat_GetHint("SDL12COMPAT_SYNC_TO_VBLANK"); float window_size_scaling = SDL12Compat_GetHintFloat("SDL12COMPAT_WINDOW_SCALING", 1.0f); + int max_bpp = SDL12Compat_GetHintInt("SDL12COMPAT_MAX_BPP", 32); SDL_bool use_gl_scaling = SDL_FALSE; SDL_bool use_highdpi = SDL_TRUE; SDL_bool fix_bordless_fs_win = SDL_TRUE; @@ -5885,6 +6010,8 @@ int scaled_height = height; const char *fromwin_env = NULL; + VideoSurface12 = &VideoSurface12Location; + if (flags12 & SDL12_OPENGL) { /* For now we default GL scaling to ENABLED. If an app breaks or is linked directly to glBindFramebuffer, they'll need to turn it off with this environment variable. @@ -5951,34 +6078,25 @@ formats, give them 16-bit and we'll convert later. Nothing in SDL 1.2 will handle > 32 bits, so clamp there, too. AND ALSO, most apps will handle 32-bits but not 24, so force around that...so basically, you can have 16 or 32 bit. */ - bpp = (bpp <= 16) ? 16 : 32; + bpp = (bpp <= 16) ? 16 : max_bpp; } if ((bpp != 8) && (bpp != 16) && (bpp != 24) && (bpp != 32)) { if (flags12 & SDL12_ANYFORMAT) { - bpp = 32; + bpp = max_bpp; } else { SDL20_SetError("Unsupported bits-per-pixel"); return NULL; } } - #if !SDL_VERSION_ATLEAST(2,0,14) - #define SDL_PIXELFORMAT_XRGB8888 SDL_PIXELFORMAT_RGB888 - #endif - switch (bpp) { - case 8: appfmt = SDL_PIXELFORMAT_INDEX8; break; - case 16: appfmt = SDL_PIXELFORMAT_RGB565; break; - case 24: appfmt = SDL_PIXELFORMAT_BGR24; break; - case 32: appfmt = SDL_PIXELFORMAT_XRGB8888; break; - default: SDL20_SetError("Unsupported bits-per-pixel"); return NULL; - } + appfmt = BPPToPixelFormat(bpp); - SDL_assert((VideoSurface12 != NULL) == (VideoWindow20 != NULL)); + SDL_assert((VideoSurface12->surface20 != NULL) == (VideoWindow20 != NULL)); - if (VideoSurface12 && ((VideoSurface12->flags & SDL12_OPENGL) != (flags12 & SDL12_OPENGL))) { + if (VideoSurface12->surface20 && ((VideoSurface12->flags & SDL12_OPENGL) != (flags12 & SDL12_OPENGL))) { EndVidModeCreate(); /* rebuild the window if moving to/from a GL context */ - } else if (VideoSurface12 && (VideoSurface12->surface20->format->format != appfmt)) { + } else if (VideoSurface12->surface20 && (VideoSurface12->surface20->format->format != appfmt)) { EndVidModeCreate(); /* rebuild the window if changing pixel format */ } else if (VideoGLContext20) { /* SDL 1.2 (infuriatingly!) destroys the GL context on each resize in some cases, on various platforms. Try to match that. */ @@ -6120,11 +6238,11 @@ SDL20_SetWindowResizable(VideoWindow20, (flags12 & SDL12_RESIZABLE) ? SDL_TRUE : SDL_FALSE); } - if (VideoSurface12) { + if (VideoSurface12->surface20) { SDL20_free(VideoSurface12->pixels); } else { - VideoSurface12 = CreateSurface12WithFormat(0, 0, appfmt); - if (!VideoSurface12) { + CreateVideoSurface(appfmt); + if (!VideoSurface12->surface20) { return EndVidModeCreate(); } } @@ -6640,7 +6758,7 @@ SDL_DisplayFormat(SDL12_Surface *surface12) { const Uint32 flags = surface12->flags & (SDL12_SRCCOLORKEY|SDL12_SRCALPHA|SDL12_RLEACCELOK); - if (!VideoSurface12) { + if (!VideoSurface12 || !VideoSurface12->surface20) { SDL20_SetError("No video mode has been set"); return NULL; } @@ -6656,7 +6774,7 @@ SDL_PixelFormat *fmt20 = NULL; SDL12_PixelFormat fmt12; - if (!VideoSurface12) { + if (!VideoSurface12 || !VideoSurface12->surface20) { SDL20_SetError("No video mode has been set"); return NULL; } @@ -7210,12 +7328,6 @@ const SDL_bool enable = (VideoWindowGrabbed && VideoCursorHidden) ? SDL_TRUE : SDL_FALSE; if (MouseInputIsRelative != enable) { MouseInputIsRelative = enable; - if (MouseInputIsRelative) { - /* reset position, we'll have to track it ourselves in SDL_MOUSEMOTION events, since 1.2 - * would give you window coordinates, even in relative mode. */ - SDL20_GetMouseState(&MousePosition.x, &MousePosition.y); - AdjustOpenGLLogicalScalingPoint(&MousePosition.x, &MousePosition.y); - } SDL20_SetRelativeMouseMode(MouseInputIsRelative); } } @@ -7241,7 +7353,7 @@ HandleInputGrab(SDL12_GrabMode mode) { /* SDL 1.2 always grabbed input if the video mode was fullscreen. */ - const SDL_bool isfullscreen = (VideoSurface12 && (VideoSurface12->flags & SDL12_FULLSCREEN)) ? SDL_TRUE : SDL_FALSE; + const SDL_bool isfullscreen = (VideoSurface12 && VideoSurface12->surface20 && (VideoSurface12->flags & SDL12_FULLSCREEN)) ? SDL_TRUE : SDL_FALSE; const SDL_bool wantgrab = (isfullscreen || (mode == SDL12_GRAB_ON)) ? SDL_TRUE : SDL_FALSE; if (VideoWindowGrabbed != wantgrab) { if (VideoWindow20) { @@ -7321,7 +7433,8 @@ /* we need to force the "unused" field to 255, since it's "alpha" in SDL2. */ opaquecolors = (SDL_Color *) SDL20_malloc(sizeof (SDL_Color) * ncolors); if (!opaquecolors) { - return SDL20_OutOfMemory(); + SDL20_OutOfMemory(); + return 0; } /* don't SDL_memcpy in case the 'a' field is uninitialized and upsets @@ -7333,17 +7446,17 @@ opaquecolors[i].a = 255; } - retval = 0; + retval = 1; /* "The return value is 1 if all colours could be set as requested, and 0 otherwise." */ if (flags & SDL12_LOGPAL) { if (SDL20_SetPaletteColors(palette20, opaquecolors, firstcolor, ncolors) < 0) { - retval = -1; + retval = 0; } } if ((flags & SDL12_PHYSPAL) && (surface12 == VideoSurface12) && VideoPhysicalPalette20) { if (SDL20_SetPaletteColors(VideoPhysicalPalette20, opaquecolors, firstcolor, ncolors) < 0) { - retval = -1; + retval = 0; } } @@ -8455,6 +8568,10 @@ *buf = NULL; + if (!rwops20) { + return NULL; + } + /* SDL2's LoadWAV requires a seekable stream, but SDL 1.2 didn't, so if the stream appears unseekable, try to load it into a memory rwops that we _can_ seek in */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/SDL20_include_wrapper.h new/sdl12-compat-release-1.2.68/src/SDL20_include_wrapper.h --- old/sdl12-compat-release-1.2.64/src/SDL20_include_wrapper.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/SDL20_include_wrapper.h 2023-09-26 19:43:48.000000000 +0200 @@ -895,10 +895,14 @@ #define SDL_ResetHints IGNORE_THIS_VERSION_OF_SDL_ResetHints #define SDL_strcasestr IGNORE_THIS_VERSION_OF_SDL_strcasestr #define SDL_GDKSuspendComplete IGNORE_THIS_VERSION_OF_SDL_GDKSuspendComplete +#define SDL_HasWindowSurface IGNORE_THIS_VERSION_OF_SDL_HasWindowSurface +#define SDL_DestroyWindowSurface IGNORE_THIS_VERSION_OF_SDL_DestroyWindowSurface +#define SDL_GDKGetDefaultUser IGNORE_THIS_VERSION_OF_SDL_GDKGetDefaultUser + +#if defined(_WIN32) || defined(__OS2__) /* *** HACK HACK HACK: * *** Avoid including SDL_thread.h: it defines SDL_CreateThread() as a macro */ -#if defined(_WIN32) || defined(__OS2__) #define _SDL_thread_h #define SDL_thread_h_ #define SDL_PASSED_BEGINTHREAD_ENDTHREAD @@ -937,6 +941,7 @@ #undef CreateMutex #endif /* _WIN32 */ + #ifdef SDL_BlitSurface #undef SDL_BlitSurface #endif @@ -4417,6 +4422,18 @@ #undef SDL_GDKSuspendComplete #endif +#ifdef SDL_HasWindowSurface +#undef SDL_HasWindowSurface +#endif + +#ifdef SDL_DestroyWindowSurface +#undef SDL_DestroyWindowSurface +#endif + +#ifdef SDL_GDKGetDefaultUser +#undef SDL_GDKGetDefaultUser +#endif + /* undefine these macros too: */ /* redefine using SDL2_xxx, if needed. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/dr_mp3.h new/sdl12-compat-release-1.2.68/src/dr_mp3.h --- old/sdl12-compat-release-1.2.64/src/dr_mp3.h 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/dr_mp3.h 2023-09-26 19:43:48.000000000 +0200 @@ -1,6 +1,6 @@ /* MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file. -dr_mp3 - v0.6.34 - 2022-09-17 +dr_mp3 - v0.6.36 - 2023-06-17 David Reid - mackron@gmail.com @@ -101,12 +101,12 @@ #define DRMP3_VERSION_MAJOR 0 #define DRMP3_VERSION_MINOR 6 -#define DRMP3_VERSION_REVISION 34 +#define DRMP3_VERSION_REVISION 36 #define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION) #include <stddef.h> /* For size_t. */ -/* Sized types. */ +/* Sized Types */ typedef signed char drmp3_int8; typedef unsigned char drmp3_uint8; typedef signed short drmp3_int16; @@ -139,7 +139,9 @@ typedef drmp3_uint32 drmp3_bool32; #define DRMP3_TRUE 1 #define DRMP3_FALSE 0 +/* End Sized Types */ +/* Decorations */ #if !defined(DRMP3_API) #if defined(DRMP3_DLL) #if defined(_WIN32) @@ -169,7 +171,9 @@ #define DRMP3_PRIVATE static #endif #endif +/* End Decorations */ +/* Result Codes */ typedef drmp3_int32 drmp3_result; #define DRMP3_SUCCESS 0 #define DRMP3_ERROR -1 /* A generic error. */ @@ -225,11 +229,12 @@ #define DRMP3_CANCELLED -51 #define DRMP3_MEMORY_ALREADY_MAPPED -52 #define DRMP3_AT_END -53 - +/* End Result Codes */ #define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME 1152 #define DRMP3_MAX_SAMPLES_PER_FRAME (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2) +/* Inline */ #ifdef _MSC_VER #define DRMP3_INLINE __forceinline #elif defined(__GNUC__) @@ -256,12 +261,24 @@ #else #define DRMP3_INLINE #endif +/* End Inline */ DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision); DRMP3_API const char* drmp3_version_string(void); +/* Allocation Callbacks */ +typedef struct +{ + void* pUserData; + void* (* onMalloc)(size_t sz, void* pUserData); + void* (* onRealloc)(void* p, size_t sz, void* pUserData); + void (* onFree)(void* p, void* pUserData); +} drmp3_allocation_callbacks; +/* End Allocation Callbacks */ + + /* Low Level Push API ================== @@ -338,14 +355,6 @@ typedef struct { - void* pUserData; - void* (* onMalloc)(size_t sz, void* pUserData); - void* (* onRealloc)(void* p, size_t sz, void* pUserData); - void (* onFree)(void* p, void* pUserData); -} drmp3_allocation_callbacks; - -typedef struct -{ drmp3_uint32 channels; drmp3_uint32 sampleRate; } drmp3_config; @@ -2433,6 +2442,7 @@ Main Public API ************************************************************************************************************************************************************/ +/* SIZE_MAX */ #if defined(SIZE_MAX) #define DRMP3_SIZE_MAX SIZE_MAX #else @@ -2442,6 +2452,7 @@ #define DRMP3_SIZE_MAX 0xFFFFFFFF #endif #endif +/* End SIZE_MAX */ /* Options. */ #ifndef DRMP3_SEEK_LEADING_MP3_FRAMES @@ -2949,6 +2960,7 @@ #include <stdio.h> #include <wchar.h> /* For wcslen(), wcsrtombs() */ +/* Errno */ /* drmp3_result_from_errno() is only used inside DR_MP3_NO_STDIO for now. Move this out if it's ever used elsewhere. */ #include <errno.h> static drmp3_result drmp3_result_from_errno(int e) @@ -3352,7 +3364,9 @@ default: return DRMP3_ERROR; } } +/* End Errno */ +/* fopen */ static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode) { #if defined(_MSC_VER) && _MSC_VER >= 1400 @@ -3508,7 +3522,7 @@ return DRMP3_SUCCESS; } - +/* End fopen */ static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead) @@ -4503,6 +4517,12 @@ /* REVISION HISTORY ================ +v0.6.36 - 2023-06-17 + - Fix an incorrect date in revision history. No functional change. + +v0.6.35 - 2023-05-22 + - Minor code restructure. No functional change. + v0.6.34 - 2022-09-17 - Fix compilation with DJGPP. - Fix compilation when compiling with x86 with no SSE2. @@ -4804,7 +4824,7 @@ =============================================================================== ALTERNATIVE 2 - MIT No Attribution =============================================================================== -Copyright 2020 David Reid +Copyright 2023 David Reid Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdl12-compat-release-1.2.64/src/version.rc new/sdl12-compat-release-1.2.68/src/version.rc --- old/sdl12-compat-release-1.2.64/src/version.rc 2023-05-26 02:38:18.000000000 +0200 +++ new/sdl12-compat-release-1.2.68/src/version.rc 2023-09-26 19:43:48.000000000 +0200 @@ -3,8 +3,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2,64,0 - PRODUCTVERSION 1,2,64,0 + FILEVERSION 1,2,68,0 + PRODUCTVERSION 1,2,68,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -17,12 +17,12 @@ BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "1, 2, 64, 0\0" + VALUE "FileVersion", "1, 2, 68, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2022 Sam Lantinga\0" VALUE "OriginalFilename", "SDL.dll\0" VALUE "ProductName", "Simple DirectMedia Layer 1.2 wrapper\0" - VALUE "ProductVersion", "1, 2, 64, 0\0" + VALUE "ProductVersion", "1, 2, 68, 0\0" END END BLOCK "VarFileInfo"