From 1c6b5baf3923e5afcd115e00273d9d7ffcb22956 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 17 Nov 2022 01:11:24 -0800
Subject: [PATCH] SDL does support 1 and 4 bit surfaces, so allow these depths
1-bit bitmap surfaces are used by Maelstrom for rendering text, for example
Fixes https://github.com/libsdl-org/sdl12-compat/issues/274
---
src/SDL12_compat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 1123cc91f..6964e2b7d 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -4992,16 +4992,16 @@ SDL_CreateRGBSurface(Uint32 flags12, int width, int height, int depth, Uint32 Rm
}
/* !!! FIXME: this isn't strictly correct, but SDL2 doesn't support
- !!! FIXME: surfaces smaller than 8 bits, and this lets at
- !!! FIXME: least one game function correctly. */
- if (depth < 8) {
+ !!! FIXME: arbitrary depths smaller than 8 bits, and this lets at
+ !!! FIXME: least one game (rockdodger) function correctly. */
+ if (depth < 8 && depth != 1 && depth != 4) {
if (WantDebugLogging) {
SDL20_Log("This app is creating an %d-bit SDL_Surface, but we are bumping it to 8-bits. If you see rendering issues, please report them!", depth);
}
depth = 8;
}
- if (depth == 8) { /* don't pass masks to SDL2 for 8-bit surfaces, it'll cause problems. */
+ if (depth <= 8) { /* don't pass masks to SDL2 for <= 8-bit surfaces, it'll cause problems. */
surface20 = SDL20_CreateRGBSurface(0, width, height, depth, 0, 0, 0, 0);
} else {
surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask);