sdl12-compat: video: If trying to create a < 8 bit surface, force it to 8 bits.

From e86d0247d48d490f61bf94489ed3882edc6f8263 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 19 Oct 2022 15:50:41 -0400
Subject: [PATCH] video: If trying to create a < 8 bit surface, force it to 8
 bits.

This gets around a specific game (rockdodger) that creates a 2-bit surface
just to convert it to display format.

This is likely to confuse any game that wants to directly manipulate pixels
and isn't getting the surface they expected, but until now those games were
simply failing here, so we'll revisit with a more-complex solution when the
need arises.

Fixes #260.
---
 src/SDL12_compat.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 79ec24176..1c1b0e150 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -4984,6 +4984,13 @@ SDL_CreateRGBSurface(Uint32 flags12, int width, int height, int depth, Uint32 Rm
         return NULL;
     }
 
+    /* !!! 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) {
+        depth = 8;
+    }
+
     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 {