sdl12-compat: Quirks: Hyperspace Delivery Boy should run in 16bpp mode

From 52a898ddb12387f2cc9501947dd9d24e927c2c71 Mon Sep 17 00:00:00 2001
From: David Gow <[EMAIL REDACTED]>
Date: Thu, 14 Sep 2023 21:19:00 +0800
Subject: [PATCH] Quirks: Hyperspace Delivery Boy should run in 16bpp mode

The LGP port of Hyperspace Delivery Boy has broken colour keys if run in
32-bpp mode (see bug #317). This is because it relies heavily on the
imprecise RGB565->RGB888 conversion in earlier SDL 1.2 versions, when
running in 32-bpp mode.

The game's assets are all in 565 format, and the game converts these to
the screen's format on load. It then sets a colour key. This presents a
problem, because:
- The generic BlitNToN implementation in SDL 1.2 just shifted the
  values, so the resulting image was not at full range. Magenta became
- Early versions of SDL 1.2 fell back to the BlitNToN blitter very
- So, Hyperspace Delivery Boy calls SDL_MapRGB(0xF8, 0, 0xF8) to get the
  colour key, then sets it on the converted surface.
- In SDL 2.0, the blitters now properly do a full-range conversion, so
  the magenta becomes (FF00FF), which now doesn't match the hardcoded
- That being said, in general, it's not guaranteed that SDL_MapRGB()
  will do the same format conversion as SDL_CovertSurface(), so the
  "correct" way of handling this is to set the colour key before
  converting, which works (albeit slowly) in SDL2:
- Since the conversion behaviour is different even between SDL 1.2
  versions, it's not worth trying to imitate it here, so we just force
  the game to run in 16-bpp mode, which works fine.
- (And the game's README recommends it, too.)
 src/SDL12_compat.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 0319ce557..f3ecd3bf5 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -1274,6 +1274,10 @@ static QuirkEntryType quirks[] = {
     {"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"},