Explorar o código

Added SDL_BLENDMODE_BLEND_PREMULTIPLIED and SDL_BLENDMODE_ADD_PREMULTIPLIED

Fixes https://github.com/libsdl-org/SDL/issues/2485
Sam Lantinga hai 9 meses
pai
achega
df573391b1

+ 26 - 20
include/SDL3/SDL_blendmode.h

@@ -41,8 +41,9 @@ extern "C" {
 /**
  * A set of blend modes used in drawing operations.
  *
- * Note that additional values may be obtained from
- * SDL_ComposeCustomBlendMode.
+ * These predefined blend modes are supported everywhere.
+ *
+ * Additional values may be obtained from SDL_ComposeCustomBlendMode.
  *
  * \since This datatype is available since SDL 3.0.0.
  *
@@ -50,20 +51,25 @@ extern "C" {
  */
 typedef Uint32 SDL_BlendMode;
 
-#define SDL_BLENDMODE_NONE      0x00000000u /**< no blending
-                                                 dstRGBA = srcRGBA */
-#define SDL_BLENDMODE_BLEND     0x00000001u /**< alpha blending
-                                                 dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
-                                                 dstA = srcA + (dstA * (1-srcA)) */
-#define SDL_BLENDMODE_ADD       0x00000002u /**< additive blending
-                                                 dstRGB = (srcRGB * srcA) + dstRGB
-                                                 dstA = dstA */
-#define SDL_BLENDMODE_MOD       0x00000004u /**< color modulate
-                                                 dstRGB = srcRGB * dstRGB
-                                                 dstA = dstA */
-#define SDL_BLENDMODE_MUL       0x00000008u /**< color multiply
-                                                 dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
-                                                 dstA = dstA */
+#define SDL_BLENDMODE_NONE                  0x00000000u /**< no blending
+                                                             dstRGBA = srcRGBA */
+#define SDL_BLENDMODE_BLEND                 0x00000001u /**< alpha blending
+                                                             dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
+                                                             dstA = srcA + (dstA * (1-srcA)) */
+#define SDL_BLENDMODE_BLEND_PREMULTIPLIED   0x00000010u /**< pre-multiplied alpha blending
+                                                             dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */
+#define SDL_BLENDMODE_ADD                   0x00000002u /**< additive blending
+                                                             dstRGB = (srcRGB * srcA) + dstRGB
+                                                             dstA = dstA */
+#define SDL_BLENDMODE_ADD_PREMULTIPLIED     0x00000020u /**< pre-multiplied additive blending
+                                                             dstRGB = srcRGB + dstRGB
+                                                             dstA = dstA */
+#define SDL_BLENDMODE_MOD                   0x00000004u /**< color modulate
+                                                             dstRGB = srcRGB * dstRGB
+                                                             dstA = dstA */
+#define SDL_BLENDMODE_MUL                   0x00000008u /**< color multiply
+                                                             dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
+                                                             dstA = dstA */
 #define SDL_BLENDMODE_INVALID   0x7FFFFFFFu
 
 /**
@@ -75,10 +81,10 @@ typedef Uint32 SDL_BlendMode;
 typedef enum SDL_BlendOperation
 {
     SDL_BLENDOPERATION_ADD              = 0x1,  /**< dst + src: supported by all renderers */
-    SDL_BLENDOPERATION_SUBTRACT         = 0x2,  /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
-    SDL_BLENDOPERATION_REV_SUBTRACT     = 0x3,  /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
-    SDL_BLENDOPERATION_MINIMUM          = 0x4,  /**< min(dst, src) : supported by D3D9, D3D11 */
-    SDL_BLENDOPERATION_MAXIMUM          = 0x5   /**< max(dst, src) : supported by D3D9, D3D11 */
+    SDL_BLENDOPERATION_SUBTRACT         = 0x2,  /**< src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan */
+    SDL_BLENDOPERATION_REV_SUBTRACT     = 0x3,  /**< dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan */
+    SDL_BLENDOPERATION_MINIMUM          = 0x4,  /**< min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */
+    SDL_BLENDOPERATION_MAXIMUM          = 0x5   /**< max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */
 } SDL_BlendOperation;
 
 /**

+ 22 - 0
src/render/SDL_render.c

@@ -83,10 +83,18 @@ this should probably be removed at some point in the future.  --ryan. */
     SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
                           SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
 
+#define SDL_BLENDMODE_BLEND_PREMULTIPLIED_FULL                                                              \
+    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \
+                          SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD)
+
 #define SDL_BLENDMODE_ADD_FULL                                                                    \
     SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \
                           SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
 
+#define SDL_BLENDMODE_ADD_PREMULTIPLIED_FULL                                                 \
+    SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ONE,  SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, \
+                          SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
+
 #define SDL_BLENDMODE_MOD_FULL                                                                     \
     SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_SRC_COLOR, SDL_BLENDOPERATION_ADD, \
                           SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD)
@@ -1234,7 +1242,9 @@ static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend
     /* These are required to be supported by all renderers */
     case SDL_BLENDMODE_NONE:
     case SDL_BLENDMODE_BLEND:
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
     case SDL_BLENDMODE_MOD:
     case SDL_BLENDMODE_MUL:
         return SDL_TRUE;
@@ -4682,9 +4692,15 @@ static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode)
     if (blendMode == SDL_BLENDMODE_BLEND_FULL) {
         return SDL_BLENDMODE_BLEND;
     }
+    if (blendMode == SDL_BLENDMODE_BLEND_PREMULTIPLIED_FULL) {
+        return SDL_BLENDMODE_BLEND_PREMULTIPLIED;
+    }
     if (blendMode == SDL_BLENDMODE_ADD_FULL) {
         return SDL_BLENDMODE_ADD;
     }
+    if (blendMode == SDL_BLENDMODE_ADD_PREMULTIPLIED_FULL) {
+        return SDL_BLENDMODE_ADD_PREMULTIPLIED;
+    }
     if (blendMode == SDL_BLENDMODE_MOD_FULL) {
         return SDL_BLENDMODE_MOD;
     }
@@ -4702,9 +4718,15 @@ static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
     if (blendMode == SDL_BLENDMODE_BLEND) {
         return SDL_BLENDMODE_BLEND_FULL;
     }
+    if (blendMode == SDL_BLENDMODE_BLEND_PREMULTIPLIED) {
+        return SDL_BLENDMODE_BLEND_PREMULTIPLIED_FULL;
+    }
     if (blendMode == SDL_BLENDMODE_ADD) {
         return SDL_BLENDMODE_ADD_FULL;
     }
+    if (blendMode == SDL_BLENDMODE_ADD_PREMULTIPLIED) {
+        return SDL_BLENDMODE_ADD_PREMULTIPLIED_FULL;
+    }
     if (blendMode == SDL_BLENDMODE_MOD) {
         return SDL_BLENDMODE_MOD_FULL;
     }

+ 14 - 0
src/render/ps2/SDL_render_ps2.c

@@ -416,12 +416,26 @@ static void PS2_SetBlendMode(PS2_RenderData *data, int blendMode)
         data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
         break;
     }
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+    {
+        /* FIXME: What are the settings for this? */
+        gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_DEST, A_ALPHA_SOURCE, A_COLOR_DEST, 0), 0);
+        data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
+        break;
+    }
     case SDL_BLENDMODE_ADD:
     {
         gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
         data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
         break;
     }
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
+    {
+        /* FIXME: What are the settings for this? */
+        gsKit_set_primalpha(data->gsGlobal, GS_SETREG_ALPHA(A_COLOR_SOURCE, A_COLOR_NULL, A_ALPHA_FIX, A_COLOR_DEST, 0x80), 0);
+        data->gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
+        break;
+    }
     case SDL_BLENDMODE_MUL:
     case SDL_BLENDMODE_MOD:
     {

+ 10 - 0
src/render/psp/SDL_render_psp.c

@@ -990,11 +990,21 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state)
             sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
             sceGuEnable(GU_BLEND);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA);
+            sceGuBlendFunc(GU_ADD, GU_FIX, GU_ONE_MINUS_SRC_ALPHA, 0x00FFFFFF, 0 );
+            sceGuEnable(GU_BLEND);
+            break;
         case SDL_BLENDMODE_ADD:
             sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
             sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF);
             sceGuEnable(GU_BLEND);
             break;
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
+            sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
+            sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0, 0x00FFFFFF);
+            sceGuEnable(GU_BLEND);
+            break;
         case SDL_BLENDMODE_MOD:
             sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
             sceGuBlendFunc(GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0);

+ 28 - 0
src/render/software/SDL_blendfillrect.c

@@ -34,7 +34,11 @@ static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
     case SDL_BLENDMODE_BLEND:
         FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB555);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
         break;
     case SDL_BLENDMODE_MOD:
@@ -59,7 +63,11 @@ static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
     case SDL_BLENDMODE_BLEND:
         FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB565);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
         break;
     case SDL_BLENDMODE_MOD:
@@ -84,7 +92,11 @@ static int SDL_BlendFillRect_XRGB8888(SDL_Surface *dst, const SDL_Rect *rect,
     case SDL_BLENDMODE_BLEND:
         FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_XRGB8888);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         FILLRECT(Uint32, DRAW_SETPIXEL_ADD_XRGB8888);
         break;
     case SDL_BLENDMODE_MOD:
@@ -109,7 +121,11 @@ static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
     case SDL_BLENDMODE_BLEND:
         FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
         break;
     case SDL_BLENDMODE_MOD:
@@ -137,7 +153,11 @@ static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
         case SDL_BLENDMODE_BLEND:
             FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
@@ -156,7 +176,11 @@ static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
         case SDL_BLENDMODE_BLEND:
             FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGB);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
             break;
         case SDL_BLENDMODE_MOD:
@@ -187,7 +211,11 @@ static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
         case SDL_BLENDMODE_BLEND:
             FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGBA);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
             break;
         case SDL_BLENDMODE_MOD:

+ 126 - 0
src/render/software/SDL_blendline.c

@@ -51,7 +51,11 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -69,7 +73,11 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -87,7 +95,11 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -107,7 +119,13 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
                    DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY2_BLEND_CLAMPED_RGB, DRAW_SETPIXELXY2_BLEND_CLAMPED_RGB,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
                    draw_end);
@@ -155,7 +173,11 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB555, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -173,7 +195,11 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB555, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -191,7 +217,11 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB555, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -211,7 +241,13 @@ static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y
                    DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_CLAMPED_RGB555, DRAW_SETPIXELXY_BLEND_CLAMPED_RGB555,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
                    draw_end);
@@ -259,7 +295,11 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB565, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -277,7 +317,11 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB565, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -295,7 +339,11 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint16, DRAW_SETPIXEL_BLEND_CLAMPED_RGB565, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -315,7 +363,13 @@ static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y
                    DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_CLAMPED_RGB565, DRAW_SETPIXELXY_BLEND_CLAMPED_RGB565,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
                    draw_end);
@@ -364,7 +418,11 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -382,7 +440,11 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -400,7 +462,11 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGB, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -420,7 +486,13 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
                    DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_BLEND_CLAMPED_RGB, DRAW_SETPIXELXY4_BLEND_CLAMPED_RGB,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
                    draw_end);
@@ -469,7 +541,11 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGBA, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -487,7 +563,11 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGBA, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -505,7 +585,11 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_RGBA, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -525,7 +609,13 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
                    DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY4_BLEND_CLAMPED_RGBA, DRAW_SETPIXELXY4_BLEND_CLAMPED_RGBA,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
                    draw_end);
@@ -573,7 +663,11 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint32, DRAW_SETPIXEL_BLEND_XRGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint32, DRAW_SETPIXEL_ADD_XRGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -591,7 +685,11 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint32, DRAW_SETPIXEL_BLEND_XRGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint32, DRAW_SETPIXEL_ADD_XRGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -609,7 +707,11 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint32, DRAW_SETPIXEL_BLEND_XRGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint32, DRAW_SETPIXEL_ADD_XRGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -629,7 +731,13 @@ static void SDL_BlendLine_XRGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
                    DRAW_SETPIXELXY_BLEND_XRGB8888, DRAW_SETPIXELXY_BLEND_XRGB8888,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_CLAMPED_XRGB8888, DRAW_SETPIXELXY_BLEND_CLAMPED_XRGB8888,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY_ADD_XRGB8888, DRAW_SETPIXELXY_ADD_XRGB8888,
                    draw_end);
@@ -677,7 +785,11 @@ static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            HLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -695,7 +807,11 @@ static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            VLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -713,7 +829,11 @@ static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
         case SDL_BLENDMODE_BLEND:
             DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DLINE(Uint32, DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888, draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
             break;
         case SDL_BLENDMODE_MOD:
@@ -733,7 +853,13 @@ static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int
                    DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
                    draw_end);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            AALINE(x1, y1, x2, y2,
+                   DRAW_SETPIXELXY_BLEND_CLAMPED_ARGB8888, DRAW_SETPIXELXY_BLEND_CLAMPED_ARGB8888,
+                   draw_end);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             AALINE(x1, y1, x2, y2,
                    DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
                    draw_end);

+ 28 - 0
src/render/software/SDL_blendpoint.c

@@ -34,7 +34,11 @@ static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode b
     case SDL_BLENDMODE_BLEND:
         DRAW_SETPIXELXY_BLEND_RGB555(x, y);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        DRAW_SETPIXELXY_BLEND_CLAMPED_RGB555(x, y);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         DRAW_SETPIXELXY_ADD_RGB555(x, y);
         break;
     case SDL_BLENDMODE_MOD:
@@ -59,7 +63,11 @@ static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode b
     case SDL_BLENDMODE_BLEND:
         DRAW_SETPIXELXY_BLEND_RGB565(x, y);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        DRAW_SETPIXELXY_BLEND_CLAMPED_RGB565(x, y);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         DRAW_SETPIXELXY_ADD_RGB565(x, y);
         break;
     case SDL_BLENDMODE_MOD:
@@ -84,7 +92,11 @@ static int SDL_BlendPoint_XRGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode
     case SDL_BLENDMODE_BLEND:
         DRAW_SETPIXELXY_BLEND_XRGB8888(x, y);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        DRAW_SETPIXELXY_BLEND_CLAMPED_XRGB8888(x, y);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         DRAW_SETPIXELXY_ADD_XRGB8888(x, y);
         break;
     case SDL_BLENDMODE_MOD:
@@ -109,7 +121,11 @@ static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode
     case SDL_BLENDMODE_BLEND:
         DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        DRAW_SETPIXELXY_BLEND_CLAMPED_ARGB8888(x, y);
+        break;
     case SDL_BLENDMODE_ADD:
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
         DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
         break;
     case SDL_BLENDMODE_MOD:
@@ -137,7 +153,11 @@ static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blen
         case SDL_BLENDMODE_BLEND:
             DRAW_SETPIXELXY2_BLEND_RGB(x, y);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DRAW_SETPIXELXY2_BLEND_CLAMPED_RGB(x, y);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DRAW_SETPIXELXY2_ADD_RGB(x, y);
             break;
         case SDL_BLENDMODE_MOD:
@@ -156,7 +176,11 @@ static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blen
         case SDL_BLENDMODE_BLEND:
             DRAW_SETPIXELXY4_BLEND_RGB(x, y);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DRAW_SETPIXELXY4_BLEND_CLAMPED_RGB(x, y);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DRAW_SETPIXELXY4_ADD_RGB(x, y);
             break;
         case SDL_BLENDMODE_MOD:
@@ -187,7 +211,11 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble
         case SDL_BLENDMODE_BLEND:
             DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
             break;
+        case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+            DRAW_SETPIXELXY4_BLEND_CLAMPED_RGBA(x, y);
+            break;
         case SDL_BLENDMODE_ADD:
+        case SDL_BLENDMODE_ADD_PREMULTIPLIED:
             DRAW_SETPIXELXY4_ADD_RGBA(x, y);
             break;
         case SDL_BLENDMODE_MOD:

+ 64 - 0
src/render/software/SDL_draw.h

@@ -60,6 +60,25 @@
         setpixel;                               \
     } while (0)
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED(getpixel, setpixel) \
+    do {                                                \
+        unsigned sr, sg, sb, sa = 0xFF;                 \
+        getpixel;                                       \
+        sr = DRAW_MUL(inva, sr) + r;                    \
+        if (sr > 0xff)                                  \
+            sr = 0xff;                                  \
+        sg = DRAW_MUL(inva, sg) + g;                    \
+        if (sg > 0xff)                                  \
+            sg = 0xff;                                  \
+        sb = DRAW_MUL(inva, sb) + b;                    \
+        if (sb > 0xff)                                  \
+            sb = 0xff;                                  \
+        sa = DRAW_MUL(inva, sa) + a;                    \
+        if (sa > 0xff)                                  \
+            sa = 0xff;                                  \
+        setpixel;                                       \
+    } while (0)
+
 #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
     do {                                      \
         unsigned sr, sg, sb, sa;              \
@@ -122,6 +141,10 @@
     DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
                         RGB555_FROM_RGB(*pixel, sr, sg, sb))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_RGB555                           \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
+                                RGB555_FROM_RGB(*pixel, sr, sg, sb))
+
 #define DRAW_SETPIXEL_ADD_RGB555                           \
     DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
                       RGB555_FROM_RGB(*pixel, sr, sg, sb))
@@ -140,6 +163,9 @@
 #define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
 
+#define DRAW_SETPIXELXY_BLEND_CLAMPED_RGB555(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_CLAMPED_RGB555)
+
 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
 
@@ -160,6 +186,10 @@
     DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
                         RGB565_FROM_RGB(*pixel, sr, sg, sb))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_RGB565                           \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
+                                RGB565_FROM_RGB(*pixel, sr, sg, sb))
+
 #define DRAW_SETPIXEL_ADD_RGB565                           \
     DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
                       RGB565_FROM_RGB(*pixel, sr, sg, sb))
@@ -178,6 +208,9 @@
 #define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
 
+#define DRAW_SETPIXELXY_BLEND_CLAMPED_RGB565(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_CLAMPED_RGB565)
+
 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
 
@@ -198,6 +231,10 @@
     DRAW_SETPIXEL_BLEND(RGB_FROM_XRGB8888(*pixel, sr, sg, sb), \
                         XRGB8888_FROM_RGB(*pixel, sr, sg, sb))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888                           \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGB_FROM_XRGB8888(*pixel, sr, sg, sb), \
+                                XRGB8888_FROM_RGB(*pixel, sr, sg, sb))
+
 #define DRAW_SETPIXEL_ADD_XRGB8888                           \
     DRAW_SETPIXEL_ADD(RGB_FROM_XRGB8888(*pixel, sr, sg, sb), \
                       XRGB8888_FROM_RGB(*pixel, sr, sg, sb))
@@ -216,6 +253,9 @@
 #define DRAW_SETPIXELXY_BLEND_XRGB8888(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_XRGB8888)
 
+#define DRAW_SETPIXELXY_BLEND_CLAMPED_XRGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_CLAMPED_XRGB8888)
+
 #define DRAW_SETPIXELXY_ADD_XRGB8888(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_XRGB8888)
 
@@ -236,6 +276,10 @@
     DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
                         ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888                                \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
+                                ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
+
 #define DRAW_SETPIXEL_ADD_ARGB8888                                \
     DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
                       ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
@@ -254,6 +298,9 @@
 #define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
 
+#define DRAW_SETPIXELXY_BLEND_CLAMPED_ARGB8888(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_CLAMPED_ARGB8888)
+
 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
 
@@ -274,6 +321,10 @@
     DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
                         PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_RGB                                  \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
+                                PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
+
 #define DRAW_SETPIXEL_ADD_RGB                                  \
     DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
                       PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
@@ -295,9 +346,15 @@
 #define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
 
+#define DRAW_SETPIXELXY2_BLEND_CLAMPED_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_CLAMPED_RGB)
+
 #define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
 
+#define DRAW_SETPIXELXY4_BLEND_CLAMPED_RGB(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_CLAMPED_RGB)
+
 #define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
     DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
 
@@ -327,6 +384,10 @@
     DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
                         PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
 
+#define DRAW_SETPIXEL_BLEND_CLAMPED_RGBA                                      \
+    DRAW_SETPIXEL_BLEND_CLAMPED(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
+                                PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
+
 #define DRAW_SETPIXEL_ADD_RGBA                                      \
     DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
                       PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
@@ -345,6 +406,9 @@
 #define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
 
+#define DRAW_SETPIXELXY4_BLEND_CLAMPED_RGBA(x, y) \
+    DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_CLAMPED_RGBA)
+
 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
     DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
 

+ 1 - 1
src/video/SDL_RLEaccel.c

@@ -1400,7 +1400,7 @@ int SDL_RLESurface(SDL_Surface *surface)
     /* Pass on combinations not supported */
     if ((flags & SDL_COPY_MODULATE_COLOR) ||
         ((flags & SDL_COPY_MODULATE_ALPHA) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) ||
-        (flags & (SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) ||
+        (flags & (SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) ||
         (flags & SDL_COPY_NEAREST)) {
         return -1;
     }

+ 1 - 1
src/video/SDL_blit.c

@@ -125,7 +125,7 @@ static SDL_bool SDL_UseAltivecPrefetch(void)
 static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelFormat dst_format, int flags,
                                        SDL_BlitFuncEntry *entries)
 {
-    int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST));
+    int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST));
     static unsigned int features = 0x7fffffff;
 
     /* Get the available CPU features */

+ 14 - 12
src/video/SDL_blit.h

@@ -28,18 +28,20 @@ extern const Uint8 *SDL_expand_byte[9];
 extern const Uint16 SDL_expand_byte_10[];
 
 /* SDL blit copy flags */
-#define SDL_COPY_MODULATE_COLOR 0x00000001
-#define SDL_COPY_MODULATE_ALPHA 0x00000002
-#define SDL_COPY_BLEND          0x00000010
-#define SDL_COPY_ADD            0x00000020
-#define SDL_COPY_MOD            0x00000040
-#define SDL_COPY_MUL            0x00000080
-#define SDL_COPY_COLORKEY       0x00000100
-#define SDL_COPY_NEAREST        0x00000200
-#define SDL_COPY_RLE_DESIRED    0x00001000
-#define SDL_COPY_RLE_COLORKEY   0x00002000
-#define SDL_COPY_RLE_ALPHAKEY   0x00004000
-#define SDL_COPY_RLE_MASK       (SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)
+#define SDL_COPY_MODULATE_COLOR         0x00000001
+#define SDL_COPY_MODULATE_ALPHA         0x00000002
+#define SDL_COPY_BLEND                  0x00000010
+#define SDL_COPY_BLEND_PREMULTIPLIED    0x00000020
+#define SDL_COPY_ADD                    0x00000040
+#define SDL_COPY_ADD_PREMULTIPLIED      0x00000080
+#define SDL_COPY_MOD                    0x00000100
+#define SDL_COPY_MUL                    0x00000200
+#define SDL_COPY_COLORKEY               0x00000400
+#define SDL_COPY_NEAREST                0x00000800
+#define SDL_COPY_RLE_DESIRED            0x00001000
+#define SDL_COPY_RLE_COLORKEY           0x00002000
+#define SDL_COPY_RLE_ALPHAKEY           0x00004000
+#define SDL_COPY_RLE_MASK               (SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)
 
 /* SDL blit CPU flags */
 #define SDL_CPU_ANY                0x00000000

+ 5151 - 1164
src/video/SDL_blit_auto.c

@@ -75,13 +75,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -136,13 +142,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -270,14 +282,13 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -286,7 +297,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -297,15 +320,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -358,14 +385,13 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -374,7 +400,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -385,15 +423,19 @@ static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -457,13 +499,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -518,13 +566,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -652,14 +706,13 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -668,7 +721,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -679,15 +744,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -740,14 +809,13 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -756,7 +824,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -767,15 +847,19 @@ static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -838,14 +922,21 @@ static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 dstA = 0xFF;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -900,14 +991,21 @@ static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 dstA = 0xFF;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1039,14 +1137,13 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1057,7 +1154,22 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1068,15 +1180,19 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -1129,14 +1245,13 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1147,7 +1262,22 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1158,15 +1288,19 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -1179,9 +1313,10 @@ static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
+    const Uint32 A = 0xFF;
     Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
@@ -1202,8 +1337,8 @@ static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            pixel = (R << 16) | (G << 8) | B;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -1213,13 +1348,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -1227,16 +1362,24 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1252,7 +1395,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -1262,13 +1405,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -1288,16 +1431,24 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1313,7 +1464,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -1323,13 +1474,15 @@ static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
     Uint32 R, G, B;
 
     while (info->dst_h--) {
@@ -1338,13 +1491,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -1354,13 +1507,15 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
     Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
@@ -1381,13 +1536,13 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -1397,7 +1552,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1408,7 +1563,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
     Uint32 srcR, srcG, srcB;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -1416,23 +1571,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1440,8 +1594,25 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1452,18 +1623,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -1473,7 +1648,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1484,7 +1659,7 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
     Uint32 srcR, srcG, srcB;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -1504,23 +1679,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1528,8 +1702,25 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1540,18 +1731,22 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -1561,8 +1756,10 @@ static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
 {
+    Uint32 pixel;
+    Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -1581,7 +1778,10 @@ static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
         while (n--) {
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
-            *dst = *src;
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            pixel = (R << 16) | (G << 8) | B;
+            *dst = pixel;
             posx += incx;
             ++dst;
         }
@@ -1590,7 +1790,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -1606,14 +1806,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1629,7 +1835,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -1639,7 +1845,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -1667,14 +1873,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 dstR = srcR;
                 dstG = srcG;
                 dstB = srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1690,7 +1902,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -1700,7 +1912,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1721,7 +1933,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             ++src;
             ++dst;
@@ -1731,7 +1943,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1764,7 +1976,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -1774,7 +1986,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1795,21 +2007,20 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1818,29 +2029,2802 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
-            case SDL_COPY_ADD:
-                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
-                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
-                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
-                break;
-            case SDL_COPY_MOD:
-                MULT_DIV_255(srcR, dstR, dstR);
-                MULT_DIV_255(srcG, dstG, dstG);
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
+{
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            *dst = *src;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
+{
+    Uint32 pixel;
+    const Uint32 A = 0xFF;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 R, G, B;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
+{
+    Uint32 pixel;
+    const Uint32 A = 0xFF;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            pixel |= (A << 24);
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR;
+                dstG = srcG;
+                dstB = srcB;
+                dstA = 0xFF;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 R, G, B;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
+    Uint32 srcR, srcG, srcB;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
+{
+    Uint32 pixel;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            pixel &= 0xFFFFFF;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
+{
+    Uint32 pixel;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            pixel = (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    Uint32 pixel;
+    Uint32 R, G, B;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            pixel = (B << 16) | (G << 8) | R;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
+{
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            *dst = *src;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
+                MULT_DIV_255(srcB, dstB, dstB);
+                break;
+            case SDL_COPY_MUL:
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
+                break;
+            }
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            *dst = dstpixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            ++src;
+            ++dst;
+        }
+        info->src += info->src_pitch;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 pixel;
+    Uint32 R, G, B, A;
+    Uint64 srcy, srcx;
+    Uint64 posy, posx;
+    Uint64 incy, incx;
+
+    incy = ((Uint64)info->src_h << 16) / info->dst_h;
+    incx = ((Uint64)info->src_w << 16) / info->dst_w;
+    posy = incy / 2;
+
+    while (info->dst_h--) {
+        Uint32 *src = 0;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        posx = incx / 2;
+
+        srcy = posy >> 16;
+        while (n--) {
+            srcx = posx >> 16;
+            src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
+            pixel = *src;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(R, modulateR, R);
+                MULT_DIV_255(G, modulateG, G);
+                MULT_DIV_255(B, modulateB, B);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            *dst = pixel;
+            posx += incx;
+            ++dst;
+        }
+        posy += incy;
+        info->dst += info->dst_pitch;
+    }
+}
+
+static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+{
+    const int flags = info->flags;
+    const Uint32 modulateR = info->r;
+    const Uint32 modulateG = info->g;
+    const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
+    Uint32 srcpixel;
+    Uint32 srcR, srcG, srcB, srcA;
+    Uint32 dstpixel;
+    Uint32 dstR, dstG, dstB, dstA;
+
+    while (info->dst_h--) {
+        Uint32 *src = (Uint32 *)info->src;
+        Uint32 *dst = (Uint32 *)info->dst;
+        int n = info->dst_w;
+        while (n--) {
+            srcpixel = *src;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            dstpixel = *dst;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & SDL_COPY_MODULATE_COLOR) {
+                MULT_DIV_255(srcR, modulateR, srcR);
+                MULT_DIV_255(srcG, modulateG, srcG);
+                MULT_DIV_255(srcB, modulateB, srcB);
+            }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            case SDL_COPY_BLEND:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
+            case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
+                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
+                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
+                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
+                break;
+            case SDL_COPY_MOD:
+                MULT_DIV_255(srcR, dstR, dstR);
+                MULT_DIV_255(srcG, dstG, dstG);
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -1850,7 +4834,7 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -1858,10 +4842,9 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     const Uint32 modulateB = info->b;
     const Uint32 modulateA = info->a;
     Uint32 srcpixel;
-    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
-    Uint32 srcR, srcG, srcB;
+    Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -1881,23 +4864,25 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -1905,8 +4890,25 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -1917,18 +4919,22 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -1938,11 +4944,10 @@ static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
-    const Uint32 A = 0xFF;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -1962,8 +4967,8 @@ static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -1973,11 +4978,11 @@ static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB;
+    Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
     Uint32 dstR, dstG, dstB, dstA;
 
@@ -1987,17 +4992,43 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
-                dstR = srcR;
-                dstG = srcG;
-                dstB = srcB;
-                dstA = 0xFF;
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2008,12 +5039,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(srcR, dstR, dstR);
-                MULT_DIV_255(srcG, dstG, dstG);
-                MULT_DIV_255(srcB, dstB, dstB);
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -2023,11 +5064,11 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
-    Uint32 srcR, srcG, srcB;
+    Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
     Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
@@ -2049,17 +5090,43 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
+                if (srcA < 255) {
+                    MULT_DIV_255(srcR, srcA, srcR);
+                    MULT_DIV_255(srcG, srcA, srcG);
+                    MULT_DIV_255(srcB, srcA, srcB);
+                }
+            }
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
-                dstR = srcR;
-                dstG = srcG;
-                dstB = srcB;
-                dstA = 0xFF;
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2070,12 +5137,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(srcR, dstR, dstR);
-                MULT_DIV_255(srcG, dstG, dstG);
-                MULT_DIV_255(srcB, dstB, dstB);
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -2085,7 +5162,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2093,8 +5170,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     const Uint32 modulateB = info->b;
     const Uint32 modulateA = info->a;
     Uint32 pixel;
-    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -2102,13 +5178,16 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -2118,7 +5197,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2126,8 +5205,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     const Uint32 modulateB = info->b;
     const Uint32 modulateA = info->a;
     Uint32 pixel;
-    const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -2147,13 +5225,16 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -2163,7 +5244,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2171,8 +5252,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     const Uint32 modulateB = info->b;
     const Uint32 modulateA = info->a;
     Uint32 srcpixel;
-    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
-    Uint32 srcR, srcG, srcB;
+    Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
     Uint32 dstR, dstG, dstB, dstA;
 
@@ -2182,23 +5262,25 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2209,7 +5291,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2220,18 +5317,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -2241,7 +5342,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2249,8 +5350,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     const Uint32 modulateB = info->b;
     const Uint32 modulateA = info->a;
     Uint32 srcpixel;
-    const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
-    Uint32 srcR, srcG, srcB;
+    Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
     Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
@@ -2272,23 +5372,25 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
+            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
                 MULT_DIV_255(srcB, modulateB, srcB);
             }
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(srcA, modulateA, srcA);
+            }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2299,7 +5401,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2310,18 +5427,22 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -2331,7 +5452,7 @@ static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
     Uint64 srcy, srcx;
@@ -2353,7 +5474,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            pixel &= 0xFFFFFF;
+            pixel >>= 8;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -2363,7 +5484,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -2377,18 +5498,17 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2397,7 +5517,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2408,15 +5540,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -2429,7 +5565,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -2455,18 +5591,17 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2475,7 +5610,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2486,15 +5633,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -2507,7 +5658,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2522,7 +5673,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -2538,7 +5689,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2565,7 +5716,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -2581,7 +5732,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2599,7 +5750,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -2611,14 +5762,13 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2627,7 +5777,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2638,15 +5800,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -2659,7 +5825,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2689,7 +5855,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -2701,14 +5867,13 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2717,7 +5882,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2728,15 +5905,19 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstR << 16) | (dstG << 8) | dstB;
@@ -2749,7 +5930,7 @@ static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
     Uint32 R, G, B;
@@ -2772,7 +5953,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
             pixel = (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
@@ -2783,7 +5964,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -2797,18 +5978,17 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2817,7 +5997,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2828,15 +6020,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -2849,7 +6045,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -2875,18 +6071,17 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -2895,7 +6090,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -2906,15 +6113,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -2927,7 +6138,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2942,7 +6153,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -2958,7 +6169,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -2985,7 +6196,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -3001,7 +6212,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3019,7 +6230,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -3031,14 +6242,13 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3047,7 +6257,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3058,15 +6280,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -3079,7 +6305,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3109,7 +6335,7 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -3121,14 +6347,13 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3137,7 +6362,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3148,15 +6385,19 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstB << 16) | (dstG << 8) | dstR;
@@ -3169,8 +6410,9 @@ static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
 {
+    Uint32 pixel;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -3189,7 +6431,9 @@ static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
         while (n--) {
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
-            *dst = *src;
+            pixel = *src;
+            pixel = (pixel >> 8) | (pixel << 24);
+            *dst = pixel;
             posx += incx;
             ++dst;
         }
@@ -3198,7 +6442,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -3212,18 +6456,17 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3234,7 +6477,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3245,15 +6503,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -3266,7 +6528,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -3292,18 +6554,17 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3314,7 +6575,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3325,15 +6601,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -3346,7 +6626,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3362,7 +6642,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -3381,7 +6661,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3409,7 +6689,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
@@ -3428,7 +6708,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3446,7 +6726,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -3458,14 +6738,13 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3476,7 +6755,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3487,15 +6781,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -3508,7 +6806,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3538,7 +6836,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
             dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -3550,14 +6848,13 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3568,7 +6865,22 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3579,15 +6891,19 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
             dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
@@ -3600,9 +6916,10 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -3622,7 +6939,8 @@ static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            pixel >>= 8;
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -3632,13 +6950,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -3648,16 +6966,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3665,8 +6982,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3677,18 +7011,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -3698,13 +7036,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -3726,16 +7064,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3743,8 +7080,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3755,18 +7109,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -3776,14 +7134,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -3791,13 +7150,16 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -3807,14 +7169,15 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -3834,13 +7197,16 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
+            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -3850,7 +7216,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3860,7 +7226,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -3870,7 +7236,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -3880,14 +7246,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3895,8 +7260,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3907,18 +7289,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -3928,7 +7314,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -3938,7 +7324,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -3960,7 +7346,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -3970,14 +7356,13 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -3985,8 +7370,25 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -3997,18 +7399,22 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -4018,7 +7424,7 @@ static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
     Uint32 R, G, B;
@@ -4041,8 +7447,8 @@ static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
-            pixel = (B << 16) | (G << 8) | R;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -4052,7 +7458,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -4066,18 +7472,17 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4086,7 +7491,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4097,18 +7514,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -4118,7 +7539,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -4144,18 +7565,17 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4164,7 +7584,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4175,18 +7607,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -4196,7 +7632,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4211,13 +7647,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             ++src;
             ++dst;
@@ -4227,7 +7663,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4254,13 +7690,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -4270,7 +7706,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4288,9 +7724,9 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -4300,14 +7736,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4316,7 +7751,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4327,18 +7774,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -4348,7 +7799,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4378,9 +7829,9 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -4390,14 +7841,13 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4406,7 +7856,19 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4417,18 +7879,22 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -4438,7 +7904,7 @@ static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
     Uint64 srcy, srcx;
@@ -4460,7 +7926,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            pixel = (pixel >> 8) | (pixel << 24);
+            pixel &= 0xFFFFFF;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -4470,13 +7936,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -4484,18 +7950,17 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4503,10 +7968,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4517,18 +7992,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -4538,13 +8017,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -4564,18 +8043,17 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4583,10 +8061,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4597,18 +8085,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -4618,15 +8110,14 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
-    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B, A;
+    Uint32 R, G, B;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -4634,16 +8125,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            if (flags & SDL_COPY_MODULATE_ALPHA) {
-                MULT_DIV_255(A, modulateA, A);
-            }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -4653,15 +8141,14 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
-    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B, A;
+    Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -4681,16 +8168,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            if (flags & SDL_COPY_MODULATE_ALPHA) {
-                MULT_DIV_255(A, modulateA, A);
-            }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -4700,7 +8184,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4710,7 +8194,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -4718,9 +8202,9 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -4730,14 +8214,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4745,10 +8228,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4759,18 +8252,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -4780,7 +8277,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -4790,7 +8287,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -4810,9 +8307,9 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
+            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -4822,14 +8319,13 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4837,10 +8333,20 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4851,18 +8357,22 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -4872,10 +8382,10 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -4895,8 +8405,8 @@ static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
-            pixel = (R << 16) | (G << 8) | B;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -4906,13 +8416,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -4922,16 +8432,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -4939,8 +8448,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -4951,18 +8477,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -4972,13 +8502,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5000,16 +8530,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5017,8 +8546,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5029,18 +8575,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -5050,14 +8600,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5065,13 +8616,16 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             ++src;
             ++dst;
@@ -5081,14 +8635,15 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5108,13 +8663,16 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -5124,7 +8682,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -5134,7 +8692,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5144,7 +8702,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -5154,14 +8712,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5169,8 +8726,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5181,18 +8755,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -5202,7 +8780,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -5212,7 +8790,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5234,7 +8812,7 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -5244,14 +8822,13 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5259,8 +8836,25 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5271,18 +8865,22 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -5292,9 +8890,8 @@ static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info)
 {
-    Uint32 pixel;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5313,9 +8910,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
         while (n--) {
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
-            pixel = *src;
-            pixel &= 0xFFFFFF;
-            *dst = pixel;
+            *dst = *src;
             posx += incx;
             ++dst;
         }
@@ -5324,13 +8919,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5340,16 +8935,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5357,8 +8951,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5369,18 +8980,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -5390,13 +9005,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5418,16 +9033,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5435,8 +9049,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5447,18 +9078,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -5468,14 +9103,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5483,13 +9119,16 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -5499,14 +9138,15 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5526,13 +9166,16 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
+            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -5542,7 +9185,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -5552,7 +9195,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5562,7 +9205,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -5572,14 +9215,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5587,8 +9229,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5599,18 +9258,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -5620,7 +9283,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -5630,7 +9293,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5652,7 +9315,7 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -5662,14 +9325,13 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5677,8 +9339,25 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5689,18 +9368,22 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -5710,10 +9393,10 @@ static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
-    Uint32 R, G, B, A;
+    Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5733,8 +9416,8 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -5744,13 +9427,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5758,18 +9441,17 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5777,10 +9459,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5791,18 +9483,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -5812,13 +9508,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5838,18 +9534,17 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -5857,10 +9552,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -5871,18 +9576,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -5892,15 +9601,14 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
-    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B, A;
+    Uint32 R, G, B;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5908,16 +9616,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            if (flags & SDL_COPY_MODULATE_ALPHA) {
-                MULT_DIV_255(A, modulateA, A);
-            }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             ++src;
             ++dst;
@@ -5927,15 +9632,14 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
-    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B, A;
+    Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -5955,16 +9659,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24);
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            if (flags & SDL_COPY_MODULATE_ALPHA) {
-                MULT_DIV_255(A, modulateA, A);
-            }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -5974,7 +9675,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -5984,7 +9685,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -5992,9 +9693,9 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6004,14 +9705,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6019,10 +9719,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6033,18 +9743,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -6054,7 +9768,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6064,7 +9778,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB, dstA;
+    Uint32 dstR, dstG, dstB;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6084,9 +9798,9 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             srcpixel = *src;
-            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24);
+            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6096,14 +9810,13 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6111,10 +9824,20 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
-                MULT_DIV_255((255 - srcA), dstA, dstA);
-                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6125,18 +9848,22 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -6146,10 +9873,9 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
-    Uint32 R, G, B;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6169,8 +9895,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
-            pixel = (R << 16) | (G << 8) | B;
+            pixel >>= 8;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -6180,7 +9905,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -6196,16 +9921,15 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6214,7 +9938,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6225,18 +9961,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -6246,7 +9986,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -6274,16 +10014,15 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6292,7 +10031,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6303,18 +10054,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -6324,7 +10079,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6345,7 +10100,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            pixel = (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -6355,7 +10110,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6388,7 +10143,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (R << 16) | (G << 8) | B;
+            pixel = (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -6398,7 +10153,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6418,7 +10173,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6428,14 +10183,13 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6444,7 +10198,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6455,18 +10221,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -6476,7 +10246,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6508,7 +10278,7 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6518,14 +10288,13 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6534,7 +10303,19 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6545,18 +10326,22 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -6566,9 +10351,10 @@ static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6588,7 +10374,8 @@ static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            pixel >>= 8;
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -6598,13 +10385,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -6614,16 +10401,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6631,8 +10417,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6643,18 +10446,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -6664,13 +10471,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6692,16 +10499,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6709,8 +10515,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6721,18 +10544,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -6742,14 +10569,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -6757,13 +10585,16 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
         int n = info->dst_w;
         while (n--) {
             pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             ++src;
             ++dst;
@@ -6773,14 +10604,15 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
     const Uint32 modulateG = info->g;
     const Uint32 modulateB = info->b;
+    const Uint32 modulateA = info->a;
     Uint32 pixel;
-    Uint32 R, G, B;
+    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6800,13 +10632,16 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
+            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(R, modulateR, R);
                 MULT_DIV_255(G, modulateG, G);
                 MULT_DIV_255(B, modulateB, B);
             }
-            pixel = (B << 16) | (G << 8) | R;
+            if (flags & SDL_COPY_MODULATE_ALPHA) {
+                MULT_DIV_255(A, modulateA, A);
+            }
+            pixel = (A << 24) | (R << 16) | (G << 8) | B;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -6816,7 +10651,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6826,7 +10661,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
 
     while (info->dst_h--) {
         Uint32 *src = (Uint32 *)info->src;
@@ -6836,7 +10671,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6846,14 +10681,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6861,8 +10695,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6873,18 +10724,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -6894,7 +10749,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -6904,7 +10759,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     Uint32 srcpixel;
     Uint32 srcR, srcG, srcB, srcA;
     Uint32 dstpixel;
-    Uint32 dstR, dstG, dstB;
+    Uint32 dstR, dstG, dstB, dstA;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -6926,7 +10781,7 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
+            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -6936,14 +10791,13 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -6951,8 +10805,25 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 dstG += srcG;
                 MULT_DIV_255((255 - srcA), dstB, dstB);
                 dstB += srcB;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -6963,18 +10834,22 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstB << 16) | (dstG << 8) | dstR;
+            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -6984,10 +10859,9 @@ static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info)
 {
     Uint32 pixel;
-    Uint32 R, G, B, A;
     Uint64 srcy, srcx;
     Uint64 posy, posx;
     Uint64 incy, incx;
@@ -7007,8 +10881,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
             srcx = posx >> 16;
             src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
             pixel = *src;
-            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (pixel >> 8) | (pixel << 24);
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -7018,7 +10891,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -7034,16 +10907,15 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -7054,7 +10926,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -7065,18 +10952,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -7086,7 +10977,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     Uint32 srcpixel;
@@ -7114,16 +11005,15 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -7134,7 +11024,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -7145,18 +11050,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -7166,7 +11075,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -7191,7 +11100,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
             if (flags & SDL_COPY_MODULATE_ALPHA) {
                 MULT_DIV_255(A, modulateA, A);
             }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             ++src;
             ++dst;
@@ -7201,7 +11110,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -7238,7 +11147,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
             if (flags & SDL_COPY_MODULATE_ALPHA) {
                 MULT_DIV_255(A, modulateA, A);
             }
-            pixel = (A << 24) | (R << 16) | (G << 8) | B;
+            pixel = (A << 24) | (B << 16) | (G << 8) | R;
             *dst = pixel;
             posx += incx;
             ++dst;
@@ -7248,7 +11157,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -7268,7 +11177,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -7278,14 +11187,13 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -7296,7 +11204,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -7307,18 +11230,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             ++src;
             ++dst;
@@ -7328,7 +11255,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
     }
 }
 
-static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
+static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 {
     const int flags = info->flags;
     const Uint32 modulateR = info->r;
@@ -7360,7 +11287,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
             srcpixel = *src;
             srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
             dstpixel = *dst;
-            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
+            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
             if (flags & SDL_COPY_MODULATE_COLOR) {
                 MULT_DIV_255(srcR, modulateR, srcR);
                 MULT_DIV_255(srcG, modulateG, srcG);
@@ -7370,14 +11297,13 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcA, modulateA, srcA);
             }
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     MULT_DIV_255(srcR, srcA, srcR);
                     MULT_DIV_255(srcG, srcA, srcG);
                     MULT_DIV_255(srcB, srcA, srcB);
                 }
             }
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
                 MULT_DIV_255((255 - srcA), dstR, dstR);
                 dstR += srcR;
@@ -7388,7 +11314,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255((255 - srcA), dstA, dstA);
                 dstA += srcA;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                MULT_DIV_255((255 - srcA), dstR, dstR);
+                dstR += srcR;
+                if (dstR > 255) dstR = 255;
+                MULT_DIV_255((255 - srcA), dstG, dstG);
+                dstG += srcG;
+                if (dstG > 255) dstG = 255;
+                MULT_DIV_255((255 - srcA), dstB, dstB);
+                dstB += srcB;
+                if (dstB > 255) dstB = 255;
+                MULT_DIV_255((255 - srcA), dstA, dstA);
+                dstA += srcA;
+                if (dstA > 255) dstA = 255;
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
                 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
                 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
@@ -7399,18 +11340,22 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
                 MULT_DIV_255(srcB, dstB, dstB);
                 break;
             case SDL_COPY_MUL:
-                MULT_DIV_255(dstR, (255 - srcA), dstR);
-                dstR += (srcR * dstR);
-                if (dstR > 255) dstR = 255;
-                MULT_DIV_255(dstB, (255 - srcA), dstB);
-                dstB += (srcB * dstB);
-                if (dstB > 255) dstB = 255;
-                MULT_DIV_255(dstG, (255 - srcA), dstG);
-                dstG += (srcG * dstG);
-                if (dstG > 255) dstG = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(srcR, dstR, tmp1);
+                    MULT_DIV_255(dstR, (255 - srcA), tmp2);
+                    dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255;
+                    MULT_DIV_255(srcG, dstG, tmp1);
+                    MULT_DIV_255(dstG, (255 - srcA), tmp2);
+                    dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255;
+                    MULT_DIV_255(srcB, dstB, tmp1);
+                    MULT_DIV_255(dstB, (255 - srcA), tmp2);
+                    dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255;
+                }
                 break;
             }
-            dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
+            dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR;
             *dst = dstpixel;
             posx += incx;
             ++dst;
@@ -7422,131 +11367,173 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
 
 SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
     { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
-    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend },
+    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale },
     { 0, 0, 0, 0, NULL }
 };
 

+ 21 - 4
src/video/SDL_blit_slow.c

@@ -134,7 +134,7 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
                     continue;
                 }
             }
-            if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) {
+            if ((flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL))) {
                 switch (dst_access) {
                 case SlowBlitPixelAccess_RGB:
                     DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
@@ -181,14 +181,13 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
                 srcA = (srcA * modulateA) / 255;
             }
             if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 255) {
                     srcR = (srcR * srcA) / 255;
                     srcG = (srcG * srcA) / 255;
                     srcB = (srcB * srcA) / 255;
                 }
             }
-            switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case 0:
                 dstR = srcR;
                 dstG = srcG;
@@ -201,7 +200,26 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
                 dstB = srcB + ((255 - srcA) * dstB) / 255;
                 dstA = srcA + ((255 - srcA) * dstA) / 255;
                 break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+                dstR = srcR + ((255 - srcA) * dstR) / 255;
+                if (dstR > 255) {
+                    dstR = 255;
+                }
+                dstG = srcG + ((255 - srcA) * dstG) / 255;
+                if (dstG > 255) {
+                    dstG = 255;
+                }
+                dstB = srcB + ((255 - srcA) * dstB) / 255;
+                if (dstB > 255) {
+                    dstB = 255;
+                }
+                dstA = srcA + ((255 - srcA) * dstA) / 255;
+                if (dstA > 255) {
+                    dstA = 255;
+                }
+                break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 dstR = srcR + dstR;
                 if (dstR > 255) {
                     dstR = 255;
@@ -869,7 +887,6 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
                 srcA = (srcA * modulateA) / 255;
             }
             if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (srcA < 1.0f) {
                     srcR = (srcR * srcA);
                     srcG = (srcG * srcA);

+ 15 - 3
src/video/SDL_surface.c

@@ -708,16 +708,22 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
 
     status = 0;
     flags = surface->internal->map.info.flags;
-    surface->internal->map.info.flags &= ~(SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL);
+    surface->internal->map.info.flags &= ~(SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL);
     switch (blendMode) {
     case SDL_BLENDMODE_NONE:
         break;
     case SDL_BLENDMODE_BLEND:
         surface->internal->map.info.flags |= SDL_COPY_BLEND;
         break;
+    case SDL_BLENDMODE_BLEND_PREMULTIPLIED:
+        surface->internal->map.info.flags |= SDL_COPY_BLEND_PREMULTIPLIED;
+        break;
     case SDL_BLENDMODE_ADD:
         surface->internal->map.info.flags |= SDL_COPY_ADD;
         break;
+    case SDL_BLENDMODE_ADD_PREMULTIPLIED:
+        surface->internal->map.info.flags |= SDL_COPY_ADD_PREMULTIPLIED;
+        break;
     case SDL_BLENDMODE_MOD:
         surface->internal->map.info.flags |= SDL_COPY_MOD;
         break;
@@ -746,13 +752,19 @@ int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
         return 0;
     }
 
-    switch (surface->internal->map.info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) {
+    switch (surface->internal->map.info.flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
     case SDL_COPY_BLEND:
         *blendMode = SDL_BLENDMODE_BLEND;
         break;
+    case SDL_COPY_BLEND_PREMULTIPLIED:
+        *blendMode = SDL_BLENDMODE_BLEND_PREMULTIPLIED;
+        break;
     case SDL_COPY_ADD:
         *blendMode = SDL_BLENDMODE_ADD;
         break;
+    case SDL_COPY_ADD_PREMULTIPLIED:
+        *blendMode = SDL_BLENDMODE_ADD_PREMULTIPLIED;
+        break;
     case SDL_COPY_MOD:
         *blendMode = SDL_BLENDMODE_MOD;
         break;
@@ -1088,7 +1100,7 @@ int SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect,
                                    SDL_ScaleMode scaleMode)
 {
     static const Uint32 complex_copy_flags = (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA |
-                                              SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL |
+                                              SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL |
                                               SDL_COPY_COLORKEY);
 
     if (scaleMode != SDL_SCALEMODE_NEAREST && scaleMode != SDL_SCALEMODE_LINEAR && scaleMode != SDL_SCALEMODE_BEST) {

+ 54 - 12
src/video/sdlgenblit.pl

@@ -38,6 +38,7 @@ my @dst_formats = (
     "XRGB8888",
     "XBGR8888",
     "ARGB8888",
+    "ABGR8888",
 );
 
 my %format_size = (
@@ -327,7 +328,6 @@ __EOF__
         if (!$A_is_const_FF) {
             print FILE <<__EOF__;
             if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
-                /* This goes away if we ever use premultiplied alpha */
                 if (${s}A < 255) {
                     MULT_DIV_255(${s}R, ${s}A, ${s}R);
                     MULT_DIV_255(${s}G, ${s}A, ${s}G);
@@ -337,7 +337,7 @@ __EOF__
 __EOF__
         }
         print FILE <<__EOF__;
-            switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
+            switch (flags & (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) {
             case SDL_COPY_BLEND:
 __EOF__
         if ($A_is_const_FF) {
@@ -369,9 +369,47 @@ __EOF__
             }
         }
 
+        print FILE <<__EOF__;
+                break;
+            case SDL_COPY_BLEND_PREMULTIPLIED:
+__EOF__
+        if ($A_is_const_FF) {
+            print FILE <<__EOF__;
+                ${d}R = ${s}R;
+                ${d}G = ${s}G;
+                ${d}B = ${s}B;
+__EOF__
+        } else {
+            print FILE <<__EOF__;
+                MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R);
+                ${d}R += ${s}R;
+                if (${d}R > 255) ${d}R = 255;
+                MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G);
+                ${d}G += ${s}G;
+                if (${d}G > 255) ${d}G = 255;
+                MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B);
+                ${d}B += ${s}B;
+                if (${d}B > 255) ${d}B = 255;
+__EOF__
+        }
+        if ( $dst_has_alpha ) {
+            if ($A_is_const_FF) {
+                print FILE <<__EOF__;
+                ${d}A = 0xFF;
+__EOF__
+            } else {
+                print FILE <<__EOF__;
+                MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A);
+                ${d}A += ${s}A;
+                if (${d}A > 255) ${d}A = 255;
+__EOF__
+            }
+        }
+
         print FILE <<__EOF__;
                 break;
             case SDL_COPY_ADD:
+            case SDL_COPY_ADD_PREMULTIPLIED:
                 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255;
                 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255;
                 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255;
@@ -391,15 +429,19 @@ __EOF__
 __EOF__
         } else {
             print FILE <<__EOF__;
-                MULT_DIV_255(${d}R, (255 - ${s}A), ${d}R);
-                ${d}R += (${s}R * ${d}R);
-                if (${d}R > 255) ${d}R = 255;
-                MULT_DIV_255(${d}B, (255 - ${s}A), ${d}B);
-                ${d}B += (${s}B * ${d}B);
-                if (${d}B > 255) ${d}B = 255;
-                MULT_DIV_255(${d}G, (255 - ${s}A), ${d}G);
-                ${d}G += (${s}G * ${d}G);
-                if (${d}G > 255) ${d}G = 255;
+                {
+                    Uint32 tmp1, tmp2;
+
+                    MULT_DIV_255(${s}R, ${d}R, tmp1);
+                    MULT_DIV_255(${d}R, (255 - ${s}A), tmp2);
+                    ${d}R = tmp1 + tmp2; if (${d}R > 255) ${d}R = 255;
+                    MULT_DIV_255(${s}G, ${d}G, tmp1);
+                    MULT_DIV_255(${d}G, (255 - ${s}A), tmp2);
+                    ${d}G = tmp1 + tmp2; if (${d}G > 255) ${d}G = 255;
+                    MULT_DIV_255(${s}B, ${d}B, tmp1);
+                    MULT_DIV_255(${d}B, (255 - ${s}A), tmp2);
+                    ${d}B = tmp1 + tmp2; if (${d}B > 255) ${d}B = 255;
+                }
 __EOF__
         }
 
@@ -624,7 +666,7 @@ __EOF__
                                 }
                             }
                             if ( $blend ) {
-                                $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL";
+                                $flag = "SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL";
                                 if ( $flags eq "" ) {
                                     $flags = $flag;
                                 } else {

+ 1711 - 726
test/testautomation_images.c

@@ -1652,7 +1652,7 @@ SDL_Surface *SDLTest_ImageBlitAlpha(void)
 
 /* GIMP RGB C-Source image dump (alpha.c) */
 
-static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
+static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
     80,
     60,
     3,
@@ -1710,610 +1710,43 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
-    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
-    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
-    "\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240"
+    "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0"
+    "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240"
+    "\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0"
+    "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240"
+    "\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240\0\240\240\0\240\240"
+    "\0aa\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww"
+    "\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305"
+    "\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305"
+    "\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305"
+    "\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305"
+    "\0\305\305\0\305\305\0\240\240\0\240\240\0\240\240\0\240\240\0dd\0dd\0dd"
     "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0"
-    "\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
-    "\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0"
-    "dd\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
-    "dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd"
-    "\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310"
-    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310"
-    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310"
-    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
-    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
-    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
-    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310"
-    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
-    "\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
-    "\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
-    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310"
-    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
-    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\310\310\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
-    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
-    "\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0dd\0\310\310\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
-    "dd\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310"
-    "\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\310\310\0\310\310"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0\310\310\0dd"
-    "\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\377\377\0\310\310\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\310\310\0\377\377\0\377\377\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd"
-    "\0\0\0\0\0\0\0dd\0\377\377\0\310\310\0\310\310\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
-    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
-    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
-    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0dd\0\0"
-    "\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0"
-    "\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
-    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
-    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0"
-    "dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0"
-    "\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0"
-    "\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310"
-    "\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310"
-    "\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0"
-    "\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0"
-    "\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0\310\310\0\310"
-    "\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310"
-    "\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0"
-    "dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310"
-    "\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0"
-    "\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
-    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
-    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
-    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
-    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240"
+    "\0\240\240\0\240\240\0aa\0\305\305\0\305\305\0\305\305\0ww\0\333\333\0\333"
+    "\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333"
+    "\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305"
+    "\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305"
+    "\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww"
+    "\0\333\333\0\333\333\0\305\305\0\305\305\0\305\305\0\305\305\0\240\240\0"
+    "\240\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
-};
-
-/**
- * Returns the BlitBlendAdd test image as SDL_Surface.
- */
-SDL_Surface *SDLTest_ImageBlitBlendAdd(void)
-{
-    SDL_Surface *surface = SDL_CreateSurfaceFrom(
-        SDLTest_imageBlitBlendAdd.width,
-        SDLTest_imageBlitBlendAdd.height,
-        SDL_PIXELFORMAT_RGB24,
-        (void *)SDLTest_imageBlitBlendAdd.pixel_data,
-        SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel);
-    return surface;
-}
-
-static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
-    80,
-    60,
-    3,
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\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dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240"
-    "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0"
-    "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240"
-    "\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0"
-    "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240"
-    "\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240\0\240\240\0\240\240"
-    "\0aa\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww"
-    "\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305"
-    "\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305"
-    "\0\305\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305"
-    "\305\0\305\305\0ww\0\305\305\0\305\305\0\305\305\0ww\0\305\305\0\305\305"
-    "\0\305\305\0\305\305\0\240\240\0\240\240\0\240\240\0\240\240\0dd\0dd\0dd"
-    "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0<<\0\240\240"
-    "\0\240\240\0\240\240\0aa\0\305\305\0\305\305\0\305\305\0ww\0\333\333\0\333"
-    "\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333"
-    "\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305"
-    "\305\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305"
-    "\0ww\0\333\333\0\333\333\0\305\305\0ww\0\333\333\0\333\333\0\305\305\0ww"
-    "\0\333\333\0\333\333\0\305\305\0\305\305\0\305\305\0\305\305\0\240\240\0"
-    "\240\240\0\240\240\0\240\240\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0dd\0dd\0dd\0<<\0aa\0aa\0aa\0::\0HH\0HH\0HH\0++\0PP\0PP\0PP\0"
-    "00\0PP"
-    "\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP"
-    "\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP\0PP\0PP\0"
-    "00\0PP"
-    "\0PP\0PP\0PP\0HH\0HH\0HH\0HH\0aa\0aa\0aa\0aa\0dd\0dd\0dd\0dd\0\0\0\0\0\0"
+    "\0\0dd\0dd\0dd\0<<\0aa\0aa\0aa\0::\0HH\0HH\0HH\0++\0PP\0PP\0PP\0"
+    "00\0PP"
+    "\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP"
+    "\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP\0PP\0PP\0"
+    "00\0PP"
+    "\0PP\0PP\0PP\0HH\0HH\0HH\0HH\0aa\0aa\0aa\0aa\0dd\0dd\0dd\0dd\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0dd\0dd\0dd\0$$\0aa\0\305\305\0\305\305\0``\0\205\205\0\351\351\0"
     "\351\351\0||\0\222\222\0\321\321\0\321\321\0\177\177\0\225\225\0\324\324"
@@ -2639,126 +2072,1678 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
     "\0\375\375\0\375\375\0\347\347\0\367\367\0\373\373\0\373\373\0\326\326\0"
     "\351\351\0\361\361\0\361\361\0\271\271\0\276\276\0\305\305\0\305\305\0aa"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0<<\0\305\305\0\305\305\0\236\236\0HH\0\271\271\0\271\271\0\224\224\0VV"
-    "\0\277\277\0\277\277\0\251\251\0DD\0\252\252\0\252\252\0\235\235\0FF\0\253"
-    "\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253"
-    "\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253"
-    "\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253"
-    "\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\235"
-    "\235\0rr\0uu\0uu\0^^\0\272\272\0\277\277\0\277\277\0\230\230\0\205\205\0"
-    "\222\222\0\222\222\0MM\0\266\266\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305"
-    "\305\0\305\305\0RR\0\236\236\0\254\254\0\361\361\0VV\0\267\267\0\263\263"
-    "\0\356\356\0ee\0\247\247\0\244\244\0\356\356\0^^\0\251\251\0\247\247\0\365"
-    "\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365"
-    "\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb"
-    "\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242"
-    "\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0\252\252\0ee"
-    "\0jj\0\345\345\0tt\0\246\246\0\251\251\0\321\321\0\272\272\0ff\0\222\222"
-    "\0\322\322\0ww\0\210\210\0\305\305\0\305\305\0\240\240\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240"
-    "\0\305\305\0``\0\236\236\0\236\236\0\254\254\0VV\0\264\264\0\254\254\0\261"
-    "\261\0dd\0\246\246\0\240\240\0\243\243\0^^\0\251\251\0\246\246\0\246\246"
-    "\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb"
-    "\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242"
-    "\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242"
-    "\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0\251\251\0dd\0hh"
-    "\0hh\0pp\0\243\243\0\240\240\0\236\236\0\264\264\0cc\0\177\177\0ww\0ww\0"
-    "\225\225\0\305\305\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0\240\240\0``"
-    "\0\351\351\0\333\333\0\333\333\0||\0\366\366\0\361\361\0\361\361\0\211\211"
-    "\0\373\373\0\371\371\0\371\371\0\221\221\0\375\375\0\374\374\0\374\374\0"
-    "\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374"
-    "\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374"
-    "\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0"
-    "\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365"
-    "\365\0\374\374\0\374\374\0\375\375\0\356\356\0\371\371\0\371\371\0\372\372"
-    "\0\340\340\0\361\361\0\361\361\0\364\364\0\307\307\0\333\333\0\333\333\0"
-    "\351\351\0\225\225\0\240\240\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240\240"
-    "\0aa\0\304\304\0\351\351\0\351\351\0\205\205\0\340\340\0\366\366\0\366\366"
-    "\0\222\222\0\355\355\0\373\373\0\373\373\0\227\227\0\364\364\0\375\375\0"
-    "\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375"
-    "\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360"
-    "\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0"
-    "\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230"
-    "\230\0\360\360\0\375\375\0\375\375\0\373\373\0\356\356\0\373\373\0\373\373"
-    "\0\367\367\0\340\340\0\364\364\0\364\364\0\354\354\0\304\304\0\351\351\0"
-    "\351\351\0\322\322\0\210\210\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240"
-    "\240\0<<\0\240\240\0\305\305\0\351\351\0ww\0\320\320\0\301\301\0\324\324"
-    "\0\211\211\0\345\345\0\316\316\0\324\324\0\217\217\0\356\356\0\323\323\0"
-    "\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323"
-    "\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354"
-    "\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0"
-    "\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223"
-    "\223\0\354\354\0\323\323\0\326\326\0\362\362\0\344\344\0\261\261\0\272\272"
-    "\0\364\364\0\340\340\0\225\225\0\205\205\0\340\340\0\276\276\0\351\351\0"
-    "\266\266\0\240\240\0dd\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\240\240\0aa\0\240"
-    "\240\0\240\240\0\305\305\0ww\0\305\305\0\240\240\0\266\266\0\205\205\0\333"
-    "\333\0\266\266\0\304\304\0\215\215\0\352\352\0\305\305\0\314\314\0\222\222"
-    "\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0"
-    "\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314"
-    "\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305"
-    "\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0"
-    "\305\305\0\314\314\0\361\361\0\335\335\0\242\242\0\236\236\0\333\333\0\312"
-    "\312\0ii\0aa\0\305\305\0\255\255\0\266\266\0\240\240\0\240\240\0\210\210"
-    "\0\240\240\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0aa\0\305\305\0\240\240\0\240\240\0ww\0\333"
-    "\333\0\305\305\0\305\305\0\205\205\0\351\351\0\333\333\0\333\333\0\217\217"
-    "\0\363\363\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0"
-    "\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351"
-    "\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351"
-    "\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0"
-    "\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\363\363\0\345"
-    "\345\0\333\333\0\333\333\0\340\340\0\312\312\0\305\305\0\305\305\0\322\322"
-    "\0\255\255\0\240\240\0\240\240\0\305\305\0\210\210\0dd\0dd\0dd\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd"
-    "\0dd\0dd\0aa\0\305\305\0\305\305\0\240\240\0ww\0\333\333\0\333\333\0\305"
-    "\305\0\205\205\0\355\355\0\355\355\0\336\336\0\215\215\0\364\364\0\364\364"
-    "\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0"
-    "\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364"
-    "\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215"
-    "\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0"
-    "\215\215\0\364\364\0\364\364\0\335\335\0\351\351\0\355\355\0\355\355\0\312"
-    "\312\0\305\305\0\322\322\0\322\322\0\255\255\0\240\240\0\305\305\0\305\305"
-    "\0\210\210\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0\305\305\0aa"
-    "\0"
-    "11\0\225\225\0\351\351\0\205\205\0HH\0\254\254\0\333\333\0ww\0BB\0\264"
-    "\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0"
-    "nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264"
-    "\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0"
-    "BB\0\264\264\0\340\340\0nn\0nn\0\205\205\0\314\314\0\266\266\0\304\304\0"
-    "\351\351\0\236\236\0yy\0\210\210\0\305\305\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0"
+    "\0<<\0\305\305\0\305\305\0\236\236\0HH\0\271\271\0\271\271\0\224\224\0VV"
+    "\0\277\277\0\277\277\0\251\251\0DD\0\252\252\0\252\252\0\235\235\0FF\0\253"
+    "\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253"
+    "\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253"
+    "\253\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253"
+    "\0\224\224\0EE\0\253\253\0\253\253\0\224\224\0EE\0\253\253\0\253\253\0\235"
+    "\235\0rr\0uu\0uu\0^^\0\272\272\0\277\277\0\277\277\0\230\230\0\205\205\0"
+    "\222\222\0\222\222\0MM\0\266\266\0\305\305\0\305\305\0<<\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\305"
+    "\305\0\305\305\0RR\0\236\236\0\254\254\0\361\361\0VV\0\267\267\0\263\263"
+    "\0\356\356\0ee\0\247\247\0\244\244\0\356\356\0^^\0\251\251\0\247\247\0\365"
+    "\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365"
+    "\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb"
+    "\0\242\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0bb\0\242"
+    "\242\0\247\247\0\365\365\0bb\0\242\242\0\247\247\0\365\365\0\252\252\0ee"
+    "\0jj\0\345\345\0tt\0\246\246\0\251\251\0\321\321\0\272\272\0ff\0\222\222"
+    "\0\322\322\0ww\0\210\210\0\305\305\0\305\305\0\240\240\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240"
+    "\0\305\305\0``\0\236\236\0\236\236\0\254\254\0VV\0\264\264\0\254\254\0\261"
+    "\261\0dd\0\246\246\0\240\240\0\243\243\0^^\0\251\251\0\246\246\0\246\246"
+    "\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb"
+    "\0\242\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242"
+    "\242\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0bb\0\242\242"
+    "\0\246\246\0\246\246\0bb\0\242\242\0\246\246\0\246\246\0\251\251\0dd\0hh"
+    "\0hh\0pp\0\243\243\0\240\240\0\236\236\0\264\264\0cc\0\177\177\0ww\0ww\0"
+    "\225\225\0\305\305\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\240\240\0\240\240\0\240\240\0``"
+    "\0\351\351\0\333\333\0\333\333\0||\0\366\366\0\361\361\0\361\361\0\211\211"
+    "\0\373\373\0\371\371\0\371\371\0\221\221\0\375\375\0\374\374\0\374\374\0"
+    "\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374"
+    "\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0\374\374"
+    "\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365\365\0"
+    "\374\374\0\374\374\0\224\224\0\365\365\0\374\374\0\374\374\0\224\224\0\365"
+    "\365\0\374\374\0\374\374\0\375\375\0\356\356\0\371\371\0\371\371\0\372\372"
+    "\0\340\340\0\361\361\0\361\361\0\364\364\0\307\307\0\333\333\0\333\333\0"
+    "\351\351\0\225\225\0\240\240\0\240\240\0\240\240\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240\240"
+    "\0aa\0\304\304\0\351\351\0\351\351\0\205\205\0\340\340\0\366\366\0\366\366"
+    "\0\222\222\0\355\355\0\373\373\0\373\373\0\227\227\0\364\364\0\375\375\0"
+    "\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375"
+    "\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0\360\360"
+    "\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230\230\0"
+    "\360\360\0\375\375\0\375\375\0\230\230\0\360\360\0\375\375\0\375\375\0\230"
+    "\230\0\360\360\0\375\375\0\375\375\0\373\373\0\356\356\0\373\373\0\373\373"
+    "\0\367\367\0\340\340\0\364\364\0\364\364\0\354\354\0\304\304\0\351\351\0"
+    "\351\351\0\322\322\0\210\210\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\240\240\0\240"
+    "\240\0<<\0\240\240\0\305\305\0\351\351\0ww\0\320\320\0\301\301\0\324\324"
+    "\0\211\211\0\345\345\0\316\316\0\324\324\0\217\217\0\356\356\0\323\323\0"
+    "\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323"
+    "\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0\354\354"
+    "\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223\223\0"
+    "\354\354\0\323\323\0\326\326\0\223\223\0\354\354\0\323\323\0\326\326\0\223"
+    "\223\0\354\354\0\323\323\0\326\326\0\362\362\0\344\344\0\261\261\0\272\272"
+    "\0\364\364\0\340\340\0\225\225\0\205\205\0\340\340\0\276\276\0\351\351\0"
+    "\266\266\0\240\240\0dd\0\240\240\0\240\240\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\240\240\0aa\0\240"
+    "\240\0\240\240\0\305\305\0ww\0\305\305\0\240\240\0\266\266\0\205\205\0\333"
+    "\333\0\266\266\0\304\304\0\215\215\0\352\352\0\305\305\0\314\314\0\222\222"
+    "\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0"
+    "\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305\0\314"
+    "\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0\305\305"
+    "\0\314\314\0\222\222\0\352\352\0\305\305\0\314\314\0\222\222\0\352\352\0"
+    "\305\305\0\314\314\0\361\361\0\335\335\0\242\242\0\236\236\0\333\333\0\312"
+    "\312\0ii\0aa\0\305\305\0\255\255\0\266\266\0\240\240\0\240\240\0\210\210"
+    "\0\240\240\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0aa\0\305\305\0\240\240\0\240\240\0ww\0\333"
+    "\333\0\305\305\0\305\305\0\205\205\0\351\351\0\333\333\0\333\333\0\217\217"
+    "\0\363\363\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0"
+    "\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351"
+    "\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0\351\351"
+    "\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\223\223\0\357\357\0"
+    "\351\351\0\351\351\0\223\223\0\357\357\0\351\351\0\351\351\0\363\363\0\345"
+    "\345\0\333\333\0\333\333\0\340\340\0\312\312\0\305\305\0\305\305\0\322\322"
+    "\0\255\255\0\240\240\0\240\240\0\305\305\0\210\210\0dd\0dd\0dd\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd"
+    "\0dd\0dd\0aa\0\305\305\0\305\305\0\240\240\0ww\0\333\333\0\333\333\0\305"
+    "\305\0\205\205\0\355\355\0\355\355\0\336\336\0\215\215\0\364\364\0\364\364"
+    "\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0"
+    "\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215\0\364"
+    "\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0\215\215"
+    "\0\364\364\0\364\364\0\335\335\0\215\215\0\364\364\0\364\364\0\335\335\0"
+    "\215\215\0\364\364\0\364\364\0\335\335\0\351\351\0\355\355\0\355\355\0\312"
+    "\312\0\305\305\0\322\322\0\322\322\0\255\255\0\240\240\0\305\305\0\305\305"
+    "\0\210\210\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0\305\305\0aa"
+    "\0"
+    "11\0\225\225\0\351\351\0\205\205\0HH\0\254\254\0\333\333\0ww\0BB\0\264"
+    "\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0"
+    "nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264"
+    "\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0BB\0\264\264\0\340\340\0nn\0"
+    "BB\0\264\264\0\340\340\0nn\0nn\0\205\205\0\314\314\0\266\266\0\304\304\0"
+    "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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd"
+    "\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210"
+    "\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210"
+    "\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25"
+    "\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210"
+    "\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0$$\0\0\0\0<<\0<<\0<<\0\0"
+    "\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0"
+    "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240"
+    "\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240"
+    "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0"
+    "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0\240\240\0\240\240"
+    "\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+};
+
+/**
+ * Returns the BlitBlend test image as SDL_Surface.
+ */
+SDL_Surface *SDLTest_ImageBlitBlend(void)
+{
+    SDL_Surface *surface = SDL_CreateSurfaceFrom(
+        SDLTest_imageBlitBlend.width,
+        SDLTest_imageBlitBlend.height,
+        SDL_PIXELFORMAT_RGB24,
+        (void *)SDLTest_imageBlitBlend.pixel_data,
+        SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel);
+    return surface;
+}
+
+static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendPremultiplied = {
+  80, 60, 3,
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+};
+
+/**
+ * \brief Returns the BlitBlendPremultiplied test image as SDL_Surface.
+ */
+SDL_Surface *SDLTest_ImageBlitBlendPremultiplied()
+{
+    SDL_Surface *surface = SDL_CreateSurfaceFrom(
+        SDLTest_imageBlitBlendPremultiplied.width,
+        SDLTest_imageBlitBlendPremultiplied.height,
+        SDL_PIXELFORMAT_RGB24,
+        (void *)SDLTest_imageBlitBlendPremultiplied.pixel_data,
+        SDLTest_imageBlitBlendPremultiplied.width * SDLTest_imageBlitBlendPremultiplied.bytes_per_pixel);
+   return surface;
+}
+
+static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
+    80,
+    60,
+    3,
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd"
+    "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0"
+    "dd\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
+    "dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310"
+    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310"
+    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
+    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310"
+    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
+    "\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310"
+    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
+    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\310\310\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0dd\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
+    "dd\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0\310\310\0dd"
+    "\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\377\377\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\310\310\0\377\377\0\377\377\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd"
+    "\0\0\0\0\0\0\0dd\0\377\377\0\310\310\0\310\310\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0dd\0\0"
+    "\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0"
+    "\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
+    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
+    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0"
+    "dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0"
+    "\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0"
+    "\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310"
+    "\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310"
+    "\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0"
+    "\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0"
+    "\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0\310\310\0\310"
+    "\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310"
+    "\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0"
+    "dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310"
+    "\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0"
+    "\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+};
+
+/**
+ * Returns the BlitBlendAdd test image as SDL_Surface.
+ */
+SDL_Surface *SDLTest_ImageBlitBlendAdd(void)
+{
+    SDL_Surface *surface = SDL_CreateSurfaceFrom(
+        SDLTest_imageBlitBlendAdd.width,
+        SDLTest_imageBlitBlendAdd.height,
+        SDL_PIXELFORMAT_RGB24,
+        (void *)SDLTest_imageBlitBlendAdd.pixel_data,
+        SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel);
+    return surface;
+}
+
+static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAddPremultiplied = {
+    80,
+    60,
+    3,
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0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\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd"
+    "\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0"
+    "dd\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
+    "dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310"
+    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310"
+    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310\310\0dd\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
+    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310"
+    "\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310"
+    "\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310"
+    "\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310"
+    "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\377\377\0\377\377\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\310\310\0\377\377\0\377\377\0\310\310\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0"
-    "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14"
-    "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14"
-    "\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14\0dd\0dd\0\25\25\0\14\14"
-    "\0dd\0dd\0\25\25\0\25\25\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0"
-    "\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0"
-    "\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0"
-    "yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0"
-    "\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0yy\0\0\0\0\0\0\0yy\0"
-    "yy\0\0\0\0\0\0\0$$\0$$\0\0\0\0\0\0\0<<\0<<\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0"
+    "\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310"
+    "\0\310\310\0\310\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0\310\310\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310"
+    "\310\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0\310\310\0\310\310\0dd\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\310\310\0"
+    "dd\0\310\310\0\310\310\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\310\310\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\310\310\0\310\310"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0\310\310\0dd"
+    "\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0dd\0dd\0dd\0\310\310\0\377\377\0\377\377\0\310\310\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\310\310\0\377\377\0\377\377\0\310\310\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd"
+    "\0\0\0\0\0\0\0dd\0\377\377\0\310\310\0\310\310\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377"
+    "\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0"
+    "\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377\377\0\377"
+    "\377\0\377\377\0\377\377\0\377\377\0\310\310\0\310\310\0\377\377\0dd\0\0"
+    "\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0"
+    "\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
+    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0"
+    "dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0"
+    "dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0\0\0\0"
+    "\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0"
+    "\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310"
+    "\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310"
+    "\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0"
+    "\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0\0\310\310\0\310\310\0\0\0\0\0\0"
+    "\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd"
-    "\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210"
-    "\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210"
-    "\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25"
-    "\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0\25\25\0dd\0\210"
-    "\210\0\210\210\0\25\25\0dd\0\210\210\0\210\210\0$$\0\0\0\0<<\0<<\0<<\0\0"
-    "\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0dd\0\310\310\0\310"
+    "\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310"
+    "\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0"
+    "dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310"
+    "\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0dd\0\310\310\0\310\310\0dd\0"
+    "\0\0\0dd\0dd\0dd\0\0\0\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0dd\0dd\0<<\0<<\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0"
-    "aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240"
-    "\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240"
-    "\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0"
-    "aa\0aa\0\240\240\0\240\240\0aa\0aa\0\240\240\0\240\240\0\240\240\0\240\240"
-    "\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+    "\0\0\0\0\0\0\0\0\0\0\0\0dd\0dd\0dd\0dd\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310"
+    "\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0"
+    "\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310\310\0\310"
+    "\310\0dd\0dd\0dd\0dd\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@@ -2792,20 +3777,20 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
     "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
 };
 
 /**
- * Returns the BlitBlend test image as SDL_Surface.
+ * Returns the BlitBlendAdd test image as SDL_Surface.
  */
-SDL_Surface *SDLTest_ImageBlitBlend(void)
+SDL_Surface *SDLTest_ImageBlitBlendAddPremultiplied(void)
 {
     SDL_Surface *surface = SDL_CreateSurfaceFrom(
-        SDLTest_imageBlitBlend.width,
-        SDLTest_imageBlitBlend.height,
+        SDLTest_imageBlitBlendAddPremultiplied.width,
+        SDLTest_imageBlitBlendAddPremultiplied.height,
         SDL_PIXELFORMAT_RGB24,
-        (void *)SDLTest_imageBlitBlend.pixel_data,
-        SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel);
+        (void *)SDLTest_imageBlitBlendAddPremultiplied.pixel_data,
+        SDLTest_imageBlitBlendAddPremultiplied.width * SDLTest_imageBlitBlendAddPremultiplied.bytes_per_pixel);
     return surface;
 }
 

+ 3 - 1
test/testautomation_images.h

@@ -26,8 +26,10 @@ typedef struct SDLTest_SurfaceImage_s {
 SDL_Surface *SDLTest_ImageBlit(void);
 SDL_Surface *SDLTest_ImageBlitColor(void);
 SDL_Surface *SDLTest_ImageBlitAlpha(void);
-SDL_Surface *SDLTest_ImageBlitBlendAdd(void);
 SDL_Surface *SDLTest_ImageBlitBlend(void);
+SDL_Surface *SDLTest_ImageBlitBlendPremultiplied(void);
+SDL_Surface *SDLTest_ImageBlitBlendAdd(void);
+SDL_Surface *SDLTest_ImageBlitBlendAddPremultiplied(void);
 SDL_Surface *SDLTest_ImageBlitBlendMod(void);
 SDL_Surface *SDLTest_ImageBlitBlendNone(void);
 SDL_Surface *SDLTest_ImageBlitBlendAll(void);

+ 43 - 0
test/testautomation_render.c

@@ -702,6 +702,17 @@ static int render_testBlitBlend(void *arg)
     SDL_DestroySurface(referenceSurface);
     referenceSurface = NULL;
 
+    /* Test Blend Premultiplied. */
+    testBlitBlendMode(tface, SDL_BLENDMODE_BLEND_PREMULTIPLIED);
+    referenceSurface = SDLTest_ImageBlitBlendPremultiplied();
+
+    /* Compare, then Present */
+    compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
+    SDL_RenderPresent(renderer);
+
+    SDL_DestroySurface(referenceSurface);
+    referenceSurface = NULL;
+
     /* Test Add. */
     testBlitBlendMode(tface, SDL_BLENDMODE_ADD);
     referenceSurface = SDLTest_ImageBlitBlendAdd();
@@ -713,6 +724,17 @@ static int render_testBlitBlend(void *arg)
     SDL_DestroySurface(referenceSurface);
     referenceSurface = NULL;
 
+    /* Test Add Premultiplied. */
+    testBlitBlendMode(tface, SDL_BLENDMODE_ADD_PREMULTIPLIED);
+    referenceSurface = SDLTest_ImageBlitBlendAddPremultiplied();
+
+    /* Compare, then Present */
+    compare(referenceSurface, ALLOWABLE_ERROR_BLENDED);
+    SDL_RenderPresent(renderer);
+
+    SDL_DestroySurface(referenceSurface);
+    referenceSurface = NULL;
+
     /* Test Mod. */
     testBlitBlendMode(tface, SDL_BLENDMODE_MOD);
     referenceSurface = SDLTest_ImageBlitBlendMod();
@@ -1154,6 +1176,15 @@ hasBlendModes(void)
     if (!isSupported(ret)) {
         fail = 1;
     }
+   ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND_PREMULTIPLIED );
+   if (!isSupported(ret))
+      fail = 1;
+   ret = SDL_GetRenderDrawBlendMode(renderer, &mode );
+   if (!isSupported(ret))
+      fail = 1;
+   ret = (mode != SDL_BLENDMODE_BLEND_PREMULTIPLIED);
+   if (!isSupported(ret))
+      fail = 1;
     ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD);
     if (!isSupported(ret)) {
         fail = 1;
@@ -1166,6 +1197,18 @@ hasBlendModes(void)
     if (!isSupported(ret)) {
         fail = 1;
     }
+    ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_ADD_PREMULTIPLIED);
+    if (!isSupported(ret)) {
+        fail = 1;
+    }
+    ret = SDL_GetRenderDrawBlendMode(renderer, &mode);
+    if (!isSupported(ret)) {
+        fail = 1;
+    }
+    ret = (mode != SDL_BLENDMODE_ADD_PREMULTIPLIED);
+    if (!isSupported(ret)) {
+        fail = 1;
+    }
     ret = SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_MOD);
     if (!isSupported(ret)) {
         fail = 1;

+ 57 - 3
test/testautomation_surface.c

@@ -523,6 +523,28 @@ static int surface_testBlitBlendBlend(void *arg)
     return TEST_COMPLETED;
 }
 
+/**
+ * @brief Tests some more blitting routines.
+ */
+static int surface_testBlitBlendPremultiplied(void *arg)
+{
+   int ret;
+   SDL_Surface *compareSurface;
+
+   /* Blend premultiplied blitting */
+   testBlitBlendMode(SDL_BLENDMODE_BLEND_PREMULTIPLIED);
+
+   /* Verify result by comparing surfaces */
+   compareSurface = SDLTest_ImageBlitBlendPremultiplied();
+   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
+   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
+
+   /* Clean up. */
+   SDL_DestroySurface(compareSurface);
+
+   return TEST_COMPLETED;
+}
+
 /**
  * Tests some more blitting routines.
  */
@@ -545,6 +567,28 @@ static int surface_testBlitBlendAdd(void *arg)
     return TEST_COMPLETED;
 }
 
+/**
+ * Tests some more blitting routines.
+ */
+static int surface_testBlitBlendAddPremultiplied(void *arg)
+{
+    int ret;
+    SDL_Surface *compareSurface;
+
+    /* Add blitting */
+    testBlitBlendMode(SDL_BLENDMODE_ADD_PREMULTIPLIED);
+
+    /* Verify result by comparing surfaces */
+    compareSurface = SDLTest_ImageBlitBlendAddPremultiplied();
+    ret = SDLTest_CompareSurfaces(testSurface, compareSurface, 0);
+    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
+
+    /* Clean up. */
+    SDL_DestroySurface(compareSurface);
+
+    return TEST_COMPLETED;
+}
+
 /**
  * Tests some more blitting routines.
  */
@@ -958,10 +1002,20 @@ static const SDLTest_TestCaseReference surfaceTest10 = {
 
 /* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
 static const SDLTest_TestCaseReference surfaceTest11 = {
-    (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED
+    (SDLTest_TestCaseFp)surface_testBlitBlendPremultiplied, "surface_testBlitBlendPremultiplied", "Tests blitting routines with premultiplied blending mode.", TEST_DISABLED
 };
 
+/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
 static const SDLTest_TestCaseReference surfaceTest12 = {
+    (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED
+};
+
+/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
+static const SDLTest_TestCaseReference surfaceTest13 = {
+    (SDLTest_TestCaseFp)surface_testBlitBlendAddPremultiplied, "surface_testBlitBlendAddPremultiplied", "Tests blitting routines with premultiplied add blending mode.", TEST_DISABLED
+};
+
+static const SDLTest_TestCaseReference surfaceTest14 = {
     (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED
 };
 
@@ -981,8 +1035,8 @@ static const SDLTest_TestCaseReference surfaceTestPalette = {
 static const SDLTest_TestCaseReference *surfaceTests[] = {
     &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
     &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
-    &surfaceTest11, &surfaceTest12, &surfaceTestOverflow, &surfaceTestFlip,
-    &surfaceTestPalette, NULL
+    &surfaceTest11, &surfaceTest12, &surfaceTest13, &surfaceTest14,
+    &surfaceTestOverflow, &surfaceTestFlip, &surfaceTestPalette, NULL
 };
 
 /* Surface test suite (global) */

+ 7 - 1
test/testdraw.c

@@ -243,9 +243,15 @@ int main(int argc, char *argv[])
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "blend_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_BLEND_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
                         blendMode = SDL_BLENDMODE_ADD;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "add_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_ADD_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
                         blendMode = SDL_BLENDMODE_MOD;
                         consumed = 2;
@@ -267,7 +273,7 @@ int main(int argc, char *argv[])
         }
         if (consumed < 0) {
             static const char *options[] = {
-                "[--blend none|blend|add|mod|mul]",
+                "[--blend none|blend|blend_premultiplied|add|add_premultiplied|mod|mul]",
                 "[--cyclecolor]",
                 "[--cyclealpha]",
                 "[num_objects]",

+ 7 - 1
test/testintersections.c

@@ -312,9 +312,15 @@ int main(int argc, char *argv[])
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "blend_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_BLEND_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
                         blendMode = SDL_BLENDMODE_ADD;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "add_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_ADD_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
                         blendMode = SDL_BLENDMODE_MOD;
                         consumed = 2;
@@ -338,7 +344,7 @@ int main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            static const char *options[] = { "[--blend none|blend|add|mod|mul]", "[--cyclecolor]", "[--cyclealpha]", "[count]", NULL };
+            static const char *options[] = { "[--blend none|blend|blend_premultiplied|add|add_premultiplied|mod|mul]", "[--cyclecolor]", "[--cyclealpha]", "[count]", NULL };
             SDLTest_CommonLogUsage(state, argv[0], options);
             return 1;
         }

+ 7 - 1
test/testsprite.c

@@ -451,9 +451,15 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
                     } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
                         blendMode = SDL_BLENDMODE_BLEND;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "blend_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_BLEND_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
                         blendMode = SDL_BLENDMODE_ADD;
                         consumed = 2;
+                    } else if (SDL_strcasecmp(argv[i + 1], "add_premultiplied") == 0) {
+                        blendMode = SDL_BLENDMODE_ADD_PREMULTIPLIED;
+                        consumed = 2;
                     } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
                         blendMode = SDL_BLENDMODE_MOD;
                         consumed = 2;
@@ -506,7 +512,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
         }
         if (consumed < 0) {
             static const char *options[] = {
-                "[--blend none|blend|add|mod|mul|sub]",
+                "[--blend none|blend|blend_premultiplied|add|add_premultiplied|mod|mul|sub]",
                 "[--cyclecolor]",
                 "[--cyclealpha]",
                 "[--suspend-when-occluded]",