Description: Fix sprite rendering broken by SDL3-compat stack
 (Patch by claude.ai)
 .
 On a default modern Debian/Ubuntu system the runtime SDL 1.2 library is the
 sdl12-compat shim, which now further sits on top of sdl2-compat, which sits
 on top of SDL3. The user's strace confirms this: libSDL-1.2.so.0,
 libSDL2-2.0.so.0 and libSDL3.so.0 are all loaded. SDL 1.2 idioms that worked
 on real SDL 1.2 (and on sdl12-compat directly against SDL2) fall over when
 the chain bottoms out at SDL3, because SDL3 changed surface semantics and
 the two-layer shim doesn't reliably re-implement every legacy detail.
 .
 Three concrete bugs caused by this:
 .
 1. Mecha sprites disappear. The pilot-color recoloring routine
    (MakeSwapBitmap in sdlgfx.pp) used to create an 8-bit indexed surface
    with a curated palette, blit the 24-bit RGB mecha sprite into it
    (relying on SDL to color-quantize), and then redefine palette entries to
    substitute pilot colors. SDL3 dropped automatic RGB->indexed
    quantization in blits and sdl2-compat doesn't reimplement it: the blit
    silently writes no pixels, the destination's pre-filled colorkey blue
    stays, and the resulting "sprite" is fully transparent. Mecha vanish;
    their shadows (Items_Sprite, loaded with empty Color and bypassing
    MakeSwapBitmap) still render. Title-screen "shadows but no mecha".
 .
 2. Translucent surfaces render solid. Water tiles, the infobox backdrop,
    and the mini-map sprite all relied on SDL_SetAlpha (per-surface alpha
    modulation, SDL_SRCALPHA) combined with the surface's colorkey for
    transparency. The screen format the AddSprite path converts to has no
    alpha mask (Amask=0), so the per-surface alpha modifier has nothing to
    multiply into and is silently dropped. The surface blits opaque, so
    water tiles are solid bright blue over the grass and the infobox is
    fully opaque.
 .
 3. RGBA-source sprites render with the colorkey-blue background opaque.
    Wall sprites, mecha portrait sprites, and other RGBA-source PNGs load
    as SDL surfaces with a per-pixel alpha channel. On real SDL 1.2,
    SDL_SetColorKey followed by SDL_ConvertSurface(..., SDL_SRCCOLORKEY)
    converts the colorkey blue into transparent pixels in the destination.
    Under the shim chain this doesn't reliably happen for RGBA sources, so
    the converted surface still has the blue background as opaque pixels.
    DrawAlphaSprite (used for "fade nearby walls so you can see the
    player") makes the bug worse because SDL_SetAlpha on a colorkeyed
    surface drops the colorkey through the compat layer. In-game effect:
    every building wall renders as a solid blue block.
 .
 The unifying fix is to stop depending on SDL's flag-and-modifier
 transparency semantics and instead store per-pixel alpha in the surface,
 which every SDL stack handles identically.
 .
 - Rewrite MakeSwapBitmap to do the color swap directly in 24-bit RGB,
   inspecting each pixel's (r,g,b) to classify it as transparent / grey /
   red ramp / yellow ramp / green ramp, and writing the swap color scaled
   by the source intensity. No indexed intermediate.
 - Add BakeAlphaIntoSprite, which replaces a sprite's surface with an
   RGBA8888 copy: alpha=0 for colorkey-blue pixels, alpha=N elsewhere.
 - Call BakeAlphaIntoSprite(it, 255) at the end of AddSprite so every
   loaded sprite is normalized to per-pixel-alpha transparency. This is
   the fix for the wall-blue-block bug; it also makes every downstream
   alpha operation work on every stack.
 - Replace the static per-surface SDL_SetAlpha calls (water_sprite1,
   water_sprite2, infobox_backdrop, mini_map_sprite) with
   BakeAlphaIntoSprite(..., N). Idempotent over the AddSprite bake.
 - Rewrite DrawAlphaSprite to do the alpha blend manually pixel-by-pixel,
   skipping colorkey-blue pixels and blending the rest with
   Alpha_Level/255 over the destination. SDL_SetAlpha-via-shim drops the
   colorkey; manual blend respects it. Runs only for sprites within ~one
   tile of the camera center, so the per-frame cost is negligible.
 .
 Verified by building gearhead-sdl against the user's source plus these
 changes and running under both (a) system sdl12-compat 1.2.68 with no
 sdl2-compat in the chain and (b) sdl12-compat 1.2.76 + sdl2-compat + SDL3
 all built from upstream, which reproduces the user's reported breakage.
 Before the patch (a) renders correctly while (b) shows mecha vanish, water
 solid, and walls as blue blocks. After the patch both stacks render
 correctly across multiple random map seeds (mecha visible on shadows,
 water properly translucent, wall sprites show their actual texture).
Author: Kari Pahula <kaol@debian.org>
Forwarded: not-yet
Last-Update: 2026-05-16

--- a/sdlgfx.pp	2026-05-16 18:25:12.737700230 +0000
+++ b/sdlgfx.pp	2026-05-16 20:12:58.332132440 +0000
@@ -198,6 +198,7 @@
 procedure DrawSprite( Spr: SensibleSpritePtr; MyDest: TSDL_Rect; Frame: Integer );
 procedure DrawAlphaSprite( Spr: SensibleSpritePtr; MyDest: TSDL_Rect; Frame: Integer );
 Function ConfirmSprite( Name: String; const Color: String; W,H: Integer ): SensibleSpritePtr;
+Procedure BakeAlphaIntoSprite( Spr: SensibleSpritePtr; Alpha: Byte );
 
 Procedure FillRectWithSprite( MyRect: TSDL_Rect; MySprite: SensibleSpritePtr; MyFrame,OffX,OffY: Integer );
 Procedure FillRectWithSprite( MyRect: TSDL_Rect; MySprite: SensibleSpritePtr; MyFrame: Integer );
@@ -317,67 +318,153 @@
 end;
 
 Function MakeSwapBitmap( MyImage: PSDL_Surface; RSwap,YSwap,GSwap: PSDL_Color ): PSDL_Surface;
-	{ Given a bitmap, create an 8-bit copy with pure colors. }
-	{         0 : Transparent (0,0,255) }
-	{   1 -  63 : Grey Scale            }
-	{  64 - 127 : Pure Red              }
-	{ 128 - 191 : Pure Yellow           }
-	{ 192 - 255 : Pure Green            }
-	{ Then, swap those colors out for the requested colors. }
+	{ Given an RGB bitmap that uses pure red / yellow / green pixels as       }
+	{ recolorable channels, produce a new RGB bitmap with those channels      }
+	{ swapped for the requested colors.                                       }
+	{                                                                         }
+	{ Source channel convention (mecha sprite PNGs follow this):              }
+	{    (0,   0, 255) : transparent (color key)                              }
+	{    (k,   k,   k) : grey, passed through unchanged                       }
+	{    (r,   0,   0) : pure red ramp,   swapped with RSwap scaled by r/255  }
+	{    (r,   r,   0) : pure yellow ramp, swapped with YSwap scaled by r/255 }
+	{    (0,   g,   0) : pure green ramp,  swapped with GSwap scaled by g/255 }
+	{                                                                         }
+	{ Operates directly in RGB space rather than going through an 8-bit       }
+	{ indexed intermediate, because RGB->indexed blits with automatic palette }
+	{ quantization were dropped in SDL3 and are not re-implemented by         }
+	{ sdl2-compat. The legacy path silently produced an all-transparent       }
+	{ surface under sdl12-compat -> sdl2-compat -> SDL3, making every         }
+	{ recolored mecha sprite invisible while its shadow still rendered.       }
 var
-	MyPal: Array [0..255] of TSDL_Color;
-	T: Integer;
 	MyImage2: PSDL_Surface;
-begin
-	{ Initialize the palette. }
-	for t := 1 to 64 do begin
-		MyPal[ T - 1 ].r := ( t * 4 ) - 1;
-		MyPal[ T - 1 ].g := ( t * 4 ) - 1;
-		MyPal[ T - 1 ].b := ( t * 4 ) - 1;
+	x, y: Integer;
+	src_pixels, dst_pixels: PByte;
+	src_pitch, dst_pitch: Integer;
+	src_bpp: Integer;
+	r, g, b, scale: Byte;
+	out_r, out_g, out_b: Byte;
+	pix: LongWord;
+begin
+	src_bpp := MyImage^.Format^.BytesPerPixel;
+
+	{ 24-bit RGB destination; masks below match the byte order we write. }
+	MyImage2 := SDL_CreateRGBSurface( SDL_SWSURFACE, MyImage^.W, MyImage^.H, 24,
+		$0000FF, $00FF00, $FF0000, 0 );
+
+	if SDL_MUSTLOCK(MyImage)  then SDL_LockSurface(MyImage);
+	if SDL_MUSTLOCK(MyImage2) then SDL_LockSurface(MyImage2);
+
+	src_pixels := PByte(MyImage^.pixels);
+	dst_pixels := PByte(MyImage2^.pixels);
+	src_pitch  := MyImage^.pitch;
+	dst_pitch  := MyImage2^.pitch;
+
+	for y := 0 to MyImage^.H - 1 do begin
+		for x := 0 to MyImage^.W - 1 do begin
+			{ Decode source pixel via SDL_GetRGB so we don't have to assume the }
+			{ source surface's byte order.                                      }
+			pix := 0;
+			Move((src_pixels + y*src_pitch + x*src_bpp)^, pix, src_bpp);
+			SDL_GetRGB( pix, MyImage^.Format, @r, @g, @b );
+
+			if (r = 0) and (g = 0) and (b = 255) then begin
+				out_r := 0; out_g := 0; out_b := 255;
+			end else if (g = 0) and (b = 0) then begin
+				scale := r;
+				out_r := (RSwap^.r * scale) div 255;
+				out_g := (RSwap^.g * scale) div 255;
+				out_b := (RSwap^.b * scale) div 255;
+			end else if (r = g) and (b = 0) then begin
+				scale := r;
+				out_r := (YSwap^.r * scale) div 255;
+				out_g := (YSwap^.g * scale) div 255;
+				out_b := (YSwap^.b * scale) div 255;
+			end else if (r = 0) and (b = 0) then begin
+				scale := g;
+				out_r := (GSwap^.r * scale) div 255;
+				out_g := (GSwap^.g * scale) div 255;
+				out_b := (GSwap^.b * scale) div 255;
+			end else begin
+				out_r := r; out_g := g; out_b := b;
+			end;
 
-		MyPal[ T + 63 ].r := ( t * 4 ) - 1;
-		MyPal[ T + 63 ].g := 0;
-		MyPal[ T + 63 ].b := 0;
-
-		MyPal[ T + 127 ].r := ( t * 4 ) - 1;
-		MyPal[ T + 127 ].g := ( t * 4 ) - 1;
-		MyPal[ T + 127 ].b := 0;
-
-		MyPal[ T + 191 ].r := 0;
-		MyPal[ T + 191 ].g := ( t * 4 ) - 1;
-		MyPal[ T + 191 ].b := 0;
-
-	end;
-	MyPal[ 0 ].r := 0;
-	MyPal[ 0 ].g := 0;
-	MyPal[ 0 ].b := 255;
-
-	{ Create replacement surface. }
-	MyImage2 := SDL_CreateRGBSurface( SDL_SWSURFACE , MyImage^.W , MyImage^.H , 8 , 0 , 0 , 0 , 0 );
-	SDL_SetPalette( MyImage2 , SDL_LOGPAL or SDL_PHYSPAL , MyPal , 0 , 256 );
-	SDL_FillRect( MyImage2 , Nil , SDL_MapRGB( MyImage2^.Format , 0 , 0 , 255 ) );
-	SDL_SetColorKey( MyImage2 , SDL_SRCCOLORKEY or SDL_RLEACCEL , SDL_MapRGB( MyImage2^.Format , 0 , 0, 255 ) );
+			(dst_pixels + y*dst_pitch + x*3 + 0)^ := out_r;
+			(dst_pixels + y*dst_pitch + x*3 + 1)^ := out_g;
+			(dst_pixels + y*dst_pitch + x*3 + 2)^ := out_b;
+		end;
+	end;
 
-	{ Blit from the original to the copy. }
-	SDL_BlitSurface( MyImage , Nil , MyImage2 , Nil );
+	if SDL_MUSTLOCK(MyImage2) then SDL_UnlockSurface(MyImage2);
+	if SDL_MUSTLOCK(MyImage)  then SDL_UnlockSurface(MyImage);
 
-	{ Redefine the palette. }
-	for t := 1 to 64 do begin
-		MyPal[ T + 63 ].r := ScaleColorValue( RSwap^.R , t * 4 );
-		MyPal[ T + 63 ].g := ScaleColorValue( RSwap^.G , t * 4 );
-		MyPal[ T + 63 ].b := ScaleColorValue( RSwap^.B , t * 4 );
+	SDL_SetColorKey( MyImage2, SDL_SRCCOLORKEY or SDL_RLEACCEL,
+		SDL_MapRGB( MyImage2^.Format, 0, 0, 255 ) );
 
-		MyPal[ T + 127 ].r := ScaleColorValue( YSwap^.R , t * 4 );
-		MyPal[ T + 127 ].g := ScaleColorValue( YSwap^.G , t * 4 );
-		MyPal[ T + 127 ].b := ScaleColorValue( YSwap^.B , t * 4 );
+	MakeSwapBitmap := MyImage2;
+end;
 
-		MyPal[ T + 191 ].r := ScaleColorValue( GSwap^.R , t * 4 );
-		MyPal[ T + 191 ].g := ScaleColorValue( GSwap^.G , t * 4 );
-		MyPal[ T + 191 ].b := ScaleColorValue( GSwap^.B , t * 4 );
+Procedure BakeAlphaIntoSprite( Spr: SensibleSpritePtr; Alpha: Byte );
+	{ Convert a sprite's surface to RGBA, writing per-pixel alpha=0 to     }
+	{ colorkey-blue pixels and alpha=Alpha to everything else, then drop   }
+	{ both colorkey and SDL_SetAlpha as transparency mechanisms.           }
+	{                                                                     }
+	{ SDL 1.2 surfaces could carry both a colorkey AND a per-surface       }
+	{ alpha modifier (SDL_SetAlpha) and have blits honor both. Under the   }
+	{ sdl12-compat -> sdl2-compat -> SDL3 chain the screen format ends up  }
+	{ with no alpha mask, the per-surface alpha modifier is silently       }
+	{ ignored, and blits emit solid colorkey-keyed pixels (transparent     }
+	{ where blue, fully opaque elsewhere). The result is that water tiles, }
+	{ infobox backdrops, and other intentionally semi-transparent UI       }
+	{ elements render fully opaque.                                        }
+	{                                                                     }
+	{ Per-pixel alpha is the SDL primitive that works identically on every }
+	{ stack, so we bake the per-surface alpha into the pixel data and let  }
+	{ the default per-pixel blend handle it.                               }
+var
+	src, dst: PSDL_Surface;
+	x, y: Integer;
+	r, g, b: Byte;
+	pix: LongWord;
+	src_pixels, dst_pixels: PByte;
+	src_pitch, dst_pitch, src_bpp: Integer;
+	out_a: Byte;
+begin
+	if (Spr = Nil) or (Spr^.Img = Nil) then Exit;
+	src := Spr^.Img;
+
+	dst := SDL_CreateRGBSurface( SDL_SWSURFACE, src^.W, src^.H, 32,
+		$000000FF, $0000FF00, $00FF0000, $FF000000 );
+
+	if SDL_MUSTLOCK(src) then SDL_LockSurface(src);
+	if SDL_MUSTLOCK(dst) then SDL_LockSurface(dst);
+
+	src_pixels := PByte(src^.pixels);
+	dst_pixels := PByte(dst^.pixels);
+	src_pitch  := src^.pitch;
+	dst_pitch  := dst^.pitch;
+	src_bpp    := src^.Format^.BytesPerPixel;
+
+	for y := 0 to src^.H - 1 do begin
+		for x := 0 to src^.W - 1 do begin
+			pix := 0;
+			Move((src_pixels + y*src_pitch + x*src_bpp)^, pix, src_bpp);
+			SDL_GetRGB( pix, src^.Format, @r, @g, @b );
+
+			if (r = 0) and (g = 0) and (b = 255) then out_a := 0
+			else out_a := Alpha;
+
+			(dst_pixels + y*dst_pitch + x*4 + 0)^ := r;
+			(dst_pixels + y*dst_pitch + x*4 + 1)^ := g;
+			(dst_pixels + y*dst_pitch + x*4 + 2)^ := b;
+			(dst_pixels + y*dst_pitch + x*4 + 3)^ := out_a;
+		end;
 	end;
-	SDL_SetPalette( MyImage2 , SDL_LOGPAL or SDL_PHYSPAL , MyPal , 0 , 256 );
 
-	MakeSwapBitmap := MyImage2;
+	if SDL_MUSTLOCK(dst) then SDL_UnlockSurface(dst);
+	if SDL_MUSTLOCK(src) then SDL_UnlockSurface(src);
+
+	SDL_FreeSurface(src);
+	Spr^.Img := dst;
 end;
 
 Procedure RedefinePalette( MyImage: PSDL_Surface; RSwap,YSwap,GSwap: PSDL_Color );
@@ -502,6 +589,16 @@
 			SDL_FreeSurface( it^.Img );
 			it^.Img := TMP;
 
+			{ Bake colorkey into per-pixel alpha. SDL 1.2 colorkey-on-converted- }
+			{ surface semantics are not reliably honored under the sdl12-compat ->}
+			{ sdl2-compat -> SDL3 stack, and are especially broken for sprites    }
+			{ that loaded as RGBA (their alpha channel makes SDL ignore the      }
+			{ colorkey at blit time). Standardize every sprite to RGBA8888 with  }
+			{ alpha=0 for the colorkey color and alpha=255 elsewhere, so blits   }
+			{ work via the SDL primitive that's identical on every stack:        }
+			{ per-pixel alpha.                                                   }
+			BakeAlphaIntoSprite( it , 255 );
+
 		end;
 
 		Dispose( fname );
@@ -612,15 +709,98 @@
 end;
 
 procedure DrawAlphaSprite( Spr: SensibleSpritePtr; MyDest: TSDL_Rect; Frame: Integer );
-	{ Draw a sensible sprite. }
-begin
-	{ First make sure that we have some valid sprite data... }
-	if ( Spr <> Nil ) and ( Spr^.Img <> Nil ) then begin
-		{ All the info checks out. Print it. }
-		SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , Alpha_Level );
-		DrawAnimImage( Spr^.Img , Spr^.W , Spr^.H , Frame , MyDest );
-		SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , SDL_Alpha_Opaque );
+	{ Draw a sensible sprite blended at Alpha_Level/255 onto the screen.       }
+	{                                                                          }
+	{ Originally implemented as SDL_SetAlpha + SDL_BlitSurface, which combines }
+	{ per-surface alpha modulation with the surface's colorkey transparency.   }
+	{ Under sdl12-compat -> sdl2-compat -> SDL3 this combination drops the     }
+	{ colorkey, so blue-keyed pixels render as opaque blue — visible as the    }
+	{ "blue blocks" symptom for walls near the player character.               }
+	{                                                                          }
+	{ Doing the blend manually side-steps every SDL-version-dependent          }
+	{ semantic: read source pixel, check for colorkey-blue (skip if so),       }
+	{ otherwise blend with the destination at Alpha_Level/255.                 }
+var
+	src: PSDL_Surface;
+	dst: PSDL_Surface;
+	src_x_off, src_y_off: Integer;
+	src_x, src_y, dx, dy: Integer;
+	pix_w, pix_h: Integer;
+	src_pixels, dst_pixels: PByte;
+	src_pitch, dst_pitch, src_bpp, dst_bpp: Integer;
+	pix: LongWord;
+	sr, sg, sb, dr, dg, db: Byte;
+	a, ia: Integer;
+	out_pix: LongWord;
+begin
+	if (Spr = Nil) or (Spr^.Img = Nil) then Exit;
+	src := Spr^.Img;
+	dst := Game_Screen;
+	if dst = Nil then Exit;
+
+	pix_w := Spr^.W;
+	pix_h := Spr^.H;
+
+	{ Frame layout matches DrawAnimImage: ( Image^.W div W ) columns. }
+	if pix_w > src^.W then pix_w := src^.W;
+	src_x_off := (Frame mod (src^.W div pix_w)) * pix_w;
+	src_y_off := (Frame div (src^.W div pix_w)) * pix_h;
+
+	{ Clip against destination surface. }
+	if MyDest.X < 0 then begin
+		src_x_off := src_x_off - MyDest.X;
+		pix_w := pix_w + MyDest.X;
+		MyDest.X := 0;
+	end;
+	if MyDest.Y < 0 then begin
+		src_y_off := src_y_off - MyDest.Y;
+		pix_h := pix_h + MyDest.Y;
+		MyDest.Y := 0;
 	end;
+	if MyDest.X + pix_w > dst^.W then pix_w := dst^.W - MyDest.X;
+	if MyDest.Y + pix_h > dst^.H then pix_h := dst^.H - MyDest.Y;
+	if (pix_w <= 0) or (pix_h <= 0) then Exit;
+
+	a := Alpha_Level;
+	ia := 255 - a;
+
+	if SDL_MUSTLOCK(src) then SDL_LockSurface(src);
+	if SDL_MUSTLOCK(dst) then SDL_LockSurface(dst);
+
+	src_pixels := PByte(src^.pixels);
+	dst_pixels := PByte(dst^.pixels);
+	src_pitch  := src^.pitch;
+	dst_pitch  := dst^.pitch;
+	src_bpp    := src^.Format^.BytesPerPixel;
+	dst_bpp    := dst^.Format^.BytesPerPixel;
+
+	for src_y := 0 to pix_h - 1 do begin
+		for src_x := 0 to pix_w - 1 do begin
+			pix := 0;
+			Move((src_pixels + (src_y + src_y_off)*src_pitch
+			      + (src_x + src_x_off)*src_bpp)^, pix, src_bpp);
+			SDL_GetRGB(pix, src^.Format, @sr, @sg, @sb);
+
+			{ Colorkey: skip pure blue (the convention used throughout). }
+			if (sr = 0) and (sg = 0) and (sb = 255) then continue;
+
+			dx := MyDest.X + src_x;
+			dy := MyDest.Y + src_y;
+			pix := 0;
+			Move((dst_pixels + dy*dst_pitch + dx*dst_bpp)^, pix, dst_bpp);
+			SDL_GetRGB(pix, dst^.Format, @dr, @dg, @db);
+
+			dr := (sr * a + dr * ia) div 255;
+			dg := (sg * a + dg * ia) div 255;
+			db := (sb * a + db * ia) div 255;
+
+			out_pix := SDL_MapRGB(dst^.Format, dr, dg, db);
+			Move(out_pix, (dst_pixels + dy*dst_pitch + dx*dst_bpp)^, dst_bpp);
+		end;
+	end;
+
+	if SDL_MUSTLOCK(dst) then SDL_UnlockSurface(dst);
+	if SDL_MUSTLOCK(src) then SDL_UnlockSurface(src);
 end;
 
 Function ConfirmSprite( Name: String; const Color: String; W,H: Integer ): SensibleSpritePtr;
@@ -1502,7 +1682,7 @@
 	Infobox_Border := ConfirmSprite( 'sys_boxborder.png' , '', 8 , 8 );
 	Infobox_Backdrop := ConfirmSprite( 'sys_boxbackdrop.png' , '', 16 , 16 );
 
-	if Transparent_Interface then SDL_SetAlpha( Infobox_Backdrop^.Img , SDL_SRCAlpha , 224 );
+	if Transparent_Interface then BakeAlphaIntoSprite( Infobox_Backdrop , 224 );
 
 {	MIX_OpenAudio( MIX_DEFAULT_FREQUENCY , MIX_DEFAULT_FORMAT , MIX_CHANNELS , 4096 );
 	Music_List := LoadStringList( 'music.cfg' );
--- a/sdlmap.pp	2026-05-16 18:25:12.734882107 +0000
+++ b/sdlmap.pp	2026-05-16 20:12:58.333547331 +0000
@@ -1594,8 +1594,8 @@
 
     Water_Sprite1 := ConfirmSprite( 'terrain_water1.png', '', 64, 64 );
     Water_Sprite2 := ConfirmSprite( 'terrain_water2.png', '', 64, 64 );
-    SDL_SetAlpha( Water_Sprite1^.Img , SDL_SRCAlpha , 150 );
-    SDL_SetAlpha( Water_Sprite2^.Img , SDL_SRCAlpha , 150 );
+    BakeAlphaIntoSprite( Water_Sprite1 , 150 );
+    BakeAlphaIntoSprite( Water_Sprite2 , 150 );
 
 	Thin_Wall_Sprites[ ThinWall_Earth ] := ConfirmSprite( 'wall_earth.png' , '' , 64 , 96 );
 	Thin_Wall_Sprites[ ThinWall_RustySteel ] := ConfirmSprite( 'wall_rustysteel.png' , '' , 64 , 96 );
@@ -1626,6 +1626,6 @@
     Door_Sprite := ConfirmSprite( 'terrain_door.png', '', 64, 64 );
 
 	Mini_Map_Sprite := ConfirmSprite( 'minimap.png' , '' , 3 , 3 );
-	if Use_Alpha_Blending then SDL_SetAlpha( Mini_Map_Sprite^.Img , SDL_SRCAlpha , Alpha_Level );
+	if Use_Alpha_Blending then BakeAlphaIntoSprite( Mini_Map_Sprite , Alpha_Level );
 
 end.
