sdl12-compat: Surface20to12: don't calculate SDL_SRCALPHA and then lose it.

From a9ec24879251cf1ba98e309b3c3cc031a7d74e37 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 21 Jun 2021 22:58:04 -0400
Subject: [PATCH] Surface20to12: don't calculate SDL_SRCALPHA and then lose it.

(we were SDL_zerop'ing the struct after setting this field, whoops.)

Fixes rendering issues in enigma.

Fixes #112.
---
 src/SDL12_compat.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 0593abc..ee352a3 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -3097,7 +3097,7 @@ Rect12to20(const SDL12_Rect *rect12, SDL_Rect *rect20)
 static SDL12_Surface *
 Surface20to12(SDL_Surface *surface20)
 {
-    SDL_BlendMode blendmode;
+    SDL_BlendMode blendmode = SDL_BLENDMODE_NONE;
     SDL12_Surface *surface12 = NULL;
     SDL12_Palette *palette12 = NULL;
     SDL12_PixelFormat *format12 = NULL;
@@ -3163,11 +3163,6 @@ Surface20to12(SDL_Surface *surface20)
         format12->alpha = 255;
     }
 
-    blendmode = SDL_BLENDMODE_NONE;
-    if ((SDL20_GetSurfaceBlendMode(surface20, &blendmode) == 0) && (blendmode == SDL_BLENDMODE_BLEND)) {
-        surface12->flags |= SDL12_SRCALPHA;
-    }
-
     SDL20_zerop(surface12);
     flags = surface20->flags;
     flags &= ~SDL_SIMD_ALIGNED;  /* we don't need to map this to 1.2 */
@@ -3178,6 +3173,10 @@ Surface20to12(SDL_Surface *surface20)
     #undef MAPSURFACEFLAGS
     SDL_assert(flags == 0);  /* non-zero if there's a flag we didn't map. */
 
+    if ((SDL20_GetSurfaceBlendMode(surface20, &blendmode) == 0) && (blendmode == SDL_BLENDMODE_BLEND)) {
+        surface12->flags |= SDL12_SRCALPHA;
+    }
+
     surface12->format = format12;
     surface12->w = surface20->w;
     surface12->h = surface20->h;