From 4f3dde88a2475b2a42df18a9784a81656edc05b0 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 21 Jun 2021 22:57:01 -0400
Subject: [PATCH] SDL_VideoModeOK: report 32 bpp if the display is actually 24.
This appears to be how apps expect SDL 1.2 to report here.
Fixes assertion failure in enigma.
---
src/SDL12_compat.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 7c7fc09..0593abc 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -3456,24 +3456,25 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
if (!(sdl12flags & SDL12_FULLSCREEN)) {
SDL_DisplayMode mode;
SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode);
- return SDL_BITSPERPIXEL(mode.format);
- }
-
- for (i = 0; i < VideoModesCount; ++i) {
- VideoModeList *vmode = &VideoModes[i];
- for (j = 0; j < vmode->nummodes; ++j) {
- if (vmode->modeslist12[j].w == width && vmode->modeslist12[j].h == height)
- {
- if (!vmode->format) {
- return bpp;
- }
- if (SDL_BITSPERPIXEL(vmode->format) >= (Uint32) bpp) {
- actual_bpp = SDL_BITSPERPIXEL(vmode->format);
+ actual_bpp = SDL_BITSPERPIXEL(mode.format);
+ } else {
+ for (i = 0; i < VideoModesCount; ++i) {
+ VideoModeList *vmode = &VideoModes[i];
+ for (j = 0; j < vmode->nummodes; ++j) {
+ if (vmode->modeslist12[j].w == width && vmode->modeslist12[j].h == height)
+ {
+ if (!vmode->format) {
+ return bpp;
+ }
+ if (SDL_BITSPERPIXEL(vmode->format) >= (Uint32) bpp) {
+ actual_bpp = SDL_BITSPERPIXEL(vmode->format);
+ }
}
}
}
}
- return actual_bpp;
+
+ return (actual_bpp == 24) ? 32 : actual_bpp;
}
DECLSPEC SDL12_Rect ** SDLCALL