Skip to content

Commit

Permalink
Quirks: Hyperspace Delivery Boy should run in 16bpp mode
Browse files Browse the repository at this point in the history
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
  (F800F8).
- Early versions of SDL 1.2 fell back to the BlitNToN blitter very
  frequently:
  libsdl-org/SDL-1.2@6f4a75d
- 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
  (F800F8).
- 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:
  libsdl-org/SDL#1854
- 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.)
  • Loading branch information
sulix authored and slouken committed Sep 14, 2023
1 parent 4116142 commit 52a898d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SDL12_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 52a898d

Please sign in to comment.